public void Render()
        {
            GUI.backgroundColor = ColorMixer.FromHex(0x335fd8).ToColor();

            GUI.backgroundColor = Color.white;

            EditorGUILayout.BeginVertical(StyleCache.Instance.ScrollviewBackground, GUILayout.ExpandWidth(true));

            _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition, GUILayout.ExpandHeight(true));

            //GUILayout.Label(new GUIContent("ID: " + _message.Id), StyleCache.Instance.WrongSelection, GUILayout.ExpandWidth(false));//, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
            GUILayout.Label(new GUIContent(_data.Title), StyleCache.Instance.Title, GUILayout.ExpandWidth(true));//, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
            GUILayout.Box(new GUIContent(_data.Message), StyleCache.Instance.NormalBox, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(true));
            if (!string.IsNullOrEmpty(_data.Url))
            {
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button(new GUIContent(string.IsNullOrEmpty(_data.UrlText) ? "Open Link" : _data.UrlText, TextureCache.Instance.CheckForUpdatesLink), StyleCache.Instance.BigLightButton, GUILayout.Height(30), GUILayout.ExpandWidth(false)))
                {
                    //Debug.Log("Opening: " + _message.Url);
                    Application.OpenURL(_data.Url);
                }
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            }

            EditorGUILayout.EndScrollView();

            GUILayout.Space(3);

            EditorGUILayout.EndVertical();  // panel chrome

            GUILayout.Space(1);
        }
        private static void Initialize()
        {
            //_instance.font = FontMapper.IsMapping("pixel") ? FontMapper.Get("pixel") : FontMapper.GetDefault();

            //Debug.Log("LabelStyle initializer");

            _style = new ProgramaticStyle
            {
                Style     = _instance,
                Alignment = TextAnchor.MiddleLeft,
                Padding   = new RectOffset(10, 10, 10, 10)
            };

            //_style.Font = CoreSkinMapper.Instance.System.font;
            //_style.Font = FontMapper.GetDefault();
            //_style.Font = FontMapper.GetDefault();

            const int w = (Weight + 1) * 2;

            //_style.FixedWidth = 100;
            //_style.FixedHeight = 100;
            _style.Border = new RectOffset(Weight + 1, Weight + 1, Weight + 1, Weight + 1);

            //_style.FontSize = 8;
            _style.NormalTextColor = Color.white;
            //_style.NormalGraphics = new Rect(w, w, new Fill(RgbColor.FromHex(0x214078).ToColor())); /*new Color(0.3f, 0.3f, 0.3f, 0.85f)*/
            _style.NormalGraphics = new Rect(w, w, new Fill(ColorMixer.FromHex(0xFF0000).ToColor())); /*new Color(0.3f, 0.3f, 0.3f, 0.85f)*/

            _style.Commit();
        }
        private static void Initialize()
        {
            _instance.name = "LoadingMaskBoxStyle";

            _style = new ProgramaticStyle {
                Style = _instance
            };

            //_style.Alignment = TextAnchor.MiddleCenter;

            //_style.Font = FontMapper.GetDefault();

            const int w = (Weight + 1) * 2;

            _style.Border = new RectOffset(Weight + 1, Weight + 1, Weight + 1, Weight + 1);
            //_style.Padding = new RectOffset(2, 2, 2, 2);

            //_style.FontSize = 8;
            //_style.NormalTextColor = Color.white;
            _style.NormalGraphics = new Rect(w, w, new Fill(new Color(1, 1, 1, 1)),
                                             new Stroke(1)
            {
                Color = ColorMixer.FromHex(6328252).ToColor()
            });                                                                   // 6328252 = blueish, 965FFF = purple

            _style.Commit();
        }
        private static void Initialize()
        {
            _instance.name = "PortletOverlayStyle";

            _style = new ProgramaticStyle {
                Style = _instance
            };

            //_style.Alignment = TextAnchor.MiddleCenter;

            //_style.Font = FontMapper.GetDefault();

            const int w = (Weight + 1) * 2;

            _style.Border = new RectOffset(Weight + 1, Weight + 1, Weight + 1, Weight + 1);
            //_style.Padding = new RectOffset(2, 2, 2, 2);

            //_style.FontSize = 8;
            _style.NormalTextColor = Color.white;
            _style.NormalGraphics  = new Rect(w, w, new Fill(new Color(1, 1, 1, 0)), new Stroke(Weight)
            {
                Color = ColorMixer.FromHex(0xbf9eff /*0xc0c0c0*//*0x214078*/).ToColor()
            });

            //_style.HoverGraphics = new Rect(w, w, new Fill(new Color(1, 1, 1, 0)), new Stroke(new Color(0.2f, 0.2f, 0.2f, 1), Weight));

            //_style.ActiveGraphics = new Rect(w, w, new Fill(new Color(1, 1, 1, 0)), new Stroke(new Color(0.1f, 0.1f, 0.1f, 1), Weight));

            _style.Commit();
        }
Exemple #5
0
        protected override void CreateChildren()
        {
            base.CreateChildren();

            #region Background

            _background = new RectShape
            {
                Id   = "background",
                Left = 0, Right = 0, Top = 0, Bottom = 0
            };
            _background.SetStyle("backgroundColor", ColorMixer.FromHex(0x439dde).ToColor());
            AddChild(_background);

            #endregion

            #region Content group

            ContentGroup = new Group
            {
                Id = "contentGroup",
                //Left = 6,
                //Right = 6,
                //Top = 50,
                //Bottom = 50
            };
            AddChild(ContentGroup);

            #endregion
        }
Exemple #6
0
        private static void Initialize()
        {
            _instance.name = "PagerButtonStyle";
            _instance.font = FontMapper.GetDefault().Font;

            _style = new ProgramaticStyle
            {
                Font      = FontMapper.GetDefault().Font,
                Style     = _instance,
                Alignment = TextAnchor.MiddleCenter,
                Padding   = new RectOffset(6, 6, 6, 6)
            };

            const int w = (Weight + 1) * 2;

            _style.Border = new RectOffset(Weight + 1, Weight + 1, Weight + 1, Weight + 1);

            //_style.FontSize = 8;
            _style.NormalTextColor = new Color(0.1f, 0.1f, 0.1f, 1);
            _style.NormalGraphics  = new Rect(w, w,
                                              new Fill(ColorMixer.FromHex(0xC0C0C0).ToColor()),
                                              new Stroke(Weight)
            {
                Color = ColorMixer.FromHex(0x404040).ToColor()
            }
                                              );
            _style.HoverTextColor = new Color(0.1f, 0.1f, 0.1f, 1);
            _style.HoverGraphics  = new Rect(w, w,
                                             new Fill(new Color(1f, 1f, 1f, 1f)),
                                             new Stroke(Weight)
            {
                Color = Color.grey
            }
                                             );
            _style.ActiveTextColor = new Color(0.1f, 0.1f, 0.1f, 1);
            _style.ActiveGraphics  = new Rect(w, w,
                                              new Fill(ColorMixer.FromHex(0x808080).ToColor()),
                                              new Stroke(Weight)
            {
                Color = ColorMixer.FromHex(0xD3D3D3).ToColor()
            }
                                              );

            _style.OnNormalTextColor = Color.white;
            _style.OnNormalGraphics  = new Rect(w, w,
                                                new Fill(ColorMixer.FromHex(0x808080).ToColor()),
                                                new Stroke(Weight)
            {
                Color = ColorMixer.FromHex(0xD3D3D3).ToColor()
            }
                                                );

            _style.FixedHeight = 25;
            _style.FixedWidth  = 25;

            _style.Commit();
        }
Exemple #7
0
        private static void Initialize()
        {
            _instance.name = "CheckBoxStyle";
            _instance.font = FontMapper.GetDefault().Font;

            _style = new ProgramaticStyle
            {
                Font          = FontMapper.GetDefault().Font,
                Style         = _instance,
                Alignment     = TextAnchor.MiddleCenter,
                ContentOffset = new Vector2(-1, -1) // fix bad Unity offset
                                                    //Padding = new RectOffset(6, 6, 3, 3) // no GUIStyle padding
            };

            const int w = (Weight + 1) * 2;

            //_style.FixedWidth = 100;
            //_style.FixedHeight = 100;
            _style.Border = new RectOffset(Weight + 1, Weight + 1, Weight + 1, Weight + 1);

            //_style.FontSize = 8;
            _style.NormalTextColor = new Color(0.1f, 0.1f, 0.1f, 1);
            _style.NormalGraphics  = new Rect(w, w,
                                              new Fill(Color.white), // RgbColor.FromHex(0xC0C0C0).ToColor()
                                              new Stroke(Weight)
            {
                Color = ColorMixer.FromHex(0x404040).ToColor()
            }
                                              );
            _style.HoverTextColor = new Color(0.1f, 0.1f, 0.1f, 1);
            _style.HoverGraphics  = new Rect(w, w,
                                             new Fill(new Color(1f, 1f, 1f, 1f)),
                                             new Stroke(Weight)
            {
                Color = Color.grey
            }
                                             );
            _style.ActiveTextColor = new Color(0.1f, 0.1f, 0.1f, 1);
            _style.ActiveGraphics  = new Rect(w, w,
                                              new Fill(ColorMixer.FromHex(0x808080).ToColor()),
                                              new Stroke(Weight)
            {
                Color = ColorMixer.FromHex(0xD3D3D3).ToColor()
            }
                                              );

            //_style.OnNormalTextColor = Color.white;
            //_style.OnNormalGraphics = new Rect(w, w,
            //                                   new Fill(RgbColor.FromHex(0x808080).ToColor()),
            //                                   new Stroke(RgbColor.FromHex(0xD3D3D3).ToColor(), Weight)
            //     );

            _style.Commit();

            //_style.FixedHeight = 20;
            //_style.FixedWidth = 100;
        }
        private static void Initialize()
        {
            _instance.name = "TabButtonStyle";
            _instance.font = FontMapper.GetDefault().Font;

            _style = new ProgramaticStyle
            {
                Font      = FontMapper.GetDefault().Font,
                Style     = _instance,
                Alignment = TextAnchor.MiddleCenter,
                Padding   = new RectOffset(6, 6, 3, 3)
            };

            const int w = (Weight + 1) * 2;

            //_style.FixedWidth = 100;
            //_style.FixedHeight = 100;
            _style.Border = new RectOffset(Weight + 1, Weight + 1, Weight + 1, Weight + 1);

            //_style.FontSize = 8;
            _style.NormalTextColor = Color.black; // Color.white;
            _style.NormalGraphics  = new Rect(w, w,
                                                  //new Fill(RgbColor.FromHex(0x965FFF).ToColor()),
                                              new Fill(ColorMixer.FromHex(0xc0c0c0).ToColor()),
                                              new Stroke(Weight)
            {
                Color = Color.grey
            }
                                              );
            //_style.HoverTextColor = new Color(0.1f, 0.1f, 0.1f, 1);
            //_style.HoverGraphics = new Rect(w, w,
            //                                new Fill(new Color(1f, 1f, 1f, 1f)),
            //                                new Stroke(Color.grey, Weight)
            //    );
            _style.ActiveTextColor = Color.white;
            _style.ActiveGraphics  = new Rect(w, w,
                                              new Fill(ColorMixer.FromHex(0xA97FFF).ToColor()),
                                              new Stroke(Weight)
            {
                Color = Color.grey
            }
                                              );

            //_style.OnNormalTextColor = Color.white;
            //_style.OnNormalGraphics = new Rect(w, w,
            //                                   new Fill(RgbColor.FromHex(0x808080).ToColor()),
            //                                   new Stroke(RgbColor.FromHex(0xD3D3D3).ToColor(), Weight)
            //     );

            //_style.ImagePosition = ImagePosition.ImageAbove;

            _style.ContentOffset = new Vector2(-3, 0);

            _style.Commit();
        }
        public static void ApplyButtonStyle(ProgramaticStyle programaticStyle, int w, int weight, TriangleDirection direction)
        {
            programaticStyle.Border = new RectOffset(weight + 1, weight + 1, weight + 1, weight + 1);

            var size   = new Point(w, w);
            int pixels = w <= 20 ? 4 : 5; // the "height" of the triangle in pixels

            //programaticStyle.FontSize = 30;
            //programaticStyle.NormalTextColor = Color.grey;
            programaticStyle.NormalGraphics = new GraphicGroup(w, w,
                                                               new Rect(
                                                                   new Fill(NormalColor),
                                                                   new Stroke(weight)
            {
                Color = StrokeColor
            }
                                                                   ),
                                                               new Triangle(new Fill(ColorMixer.FromHex(0x666666).ToColor()))
            {
                Direction = direction, Pixels = pixels
            }
                                                               );
            //programaticStyle.HoverTextColor = Color.white;
            programaticStyle.HoverGraphics = new GraphicGroup(w, w,
                                                              new Rect(
                                                                  new Fill(HoverColor),
                                                                  new Stroke(weight)
            {
                Color = StrokeColor
            }
                                                                  ),
                                                              new Triangle(new Fill(Color.black))
            {
                Direction = direction, Pixels = pixels
            }
                                                              );
            //programaticStyle.ActiveTextColor = Color.white;
            programaticStyle.ActiveGraphics = new GraphicGroup(w, w,
                                                               new Rect(
                                                                   new Fill(ActiveColor),
                                                                   new Stroke(weight)
            {
                Color = StrokeColor
            }
                                                                   ),
                                                               new Triangle(new Fill(ColorMixer.FromHex(0x333333).ToColor()))
            {
                Direction = direction, Pixels = pixels
            }
                                                               );
        }
        private static void RenderStatus(string label, bool monitoring)
        {
            _oldColor = GUI.color;

            GUI.color = monitoring ? Color.green : ColorMixer.FromHex(0x222222).ToColor();
            EditorGUILayout.BeginHorizontal(StyleCache.Instance.StatusToolbar, GUILayout.Height(35));

            GUI.color = monitoring ? Color.black : ColorMixer.FromHex(0xb1b1b1).ToColor();
            GUILayout.Label(label, StyleCache.Instance.CenteredWhiteLabel, GUILayout.ExpandWidth(true),
                            GUILayout.ExpandHeight(true));

            GUILayout.EndHorizontal();
            GUI.color = _oldColor;
        }
        private static void Initialize()
        {
            _style = new ProgramaticStyle
            {
                Style     = _instance,
                Alignment = TextAnchor.MiddleLeft,
                Padding   = new RectOffset(6, 6, 4, 4),
                Font      = FontMapper.GetWithFallback("pixel").Font
            };

            const int w = (Weight + 1) * 2;

            _style.Border          = new RectOffset(Weight + 1, Weight + 1, Weight + 1, Weight + 1);
            _style.NormalTextColor = Color.white;
            _style.NormalGraphics  = new Rect(w, w, new Fill(ColorMixer.FromHex(0x1261c1).ToColor()));

            _style.Commit();
        }
        private static void Initialize()
        {
            _instance.name = "GreenButtonStyle";
            _instance.font = FontMapper.GetDefault().Font;

            _style = new ProgramaticStyle
            {
                Font      = FontMapper.GetDefault().Font,
                Style     = _instance,
                Alignment = TextAnchor.MiddleCenter,
                Padding   = new RectOffset(6, 6, 3, 3)
            };

            const int w = (Weight + 1) * 2;

            //_style.FixedWidth = 100;
            //_style.FixedHeight = 100;
            _style.Border = new RectOffset(Weight + 1, Weight + 1, Weight + 1, Weight + 1);

            //_style.FontSize = 8;
            _style.NormalTextColor = Color.black;
            _style.NormalGraphics  = new Rect(w, w,
                                              new Fill(Green),
                                              new Stroke(Weight)
            {
                Color = Color.black
            }
                                              );

            _style.HoverTextColor = Color.black;
            _style.HoverGraphics  = new Rect(w, w,
                                             new Fill(ColorMixer.FromHex(0x14FF99).ToColor()),
                                             new Stroke(Weight)
            {
                Color = Color.black
            }
                                             );

            _style.Commit();
        }
        private static void Initialize()
        {
            //_instance.font = FontMapper.IsMapping("pixel") ? FontMapper.Get("pixel") : FontMapper.GetDefault();

            //Debug.Log("LabelStyle initializer");

            _style = new ProgramaticStyle
            {
                Style     = _instance,
                Alignment = TextAnchor.MiddleLeft,
                //Padding = new RectOffset(10, 10, 10, 10)
            };

            //_style.Font = CoreSkinMapper.Instance.System.font;
            //_style.Font = FontMapper.GetDefault();
            //_style.Font = FontMapper.GetDefault();

            const int w = (Weight + 1) * 2;

            //_style.FixedWidth = 100;
            //_style.FixedHeight = 100;
            _style.Border = new RectOffset(Weight + 1, Weight + 1, Weight + 1, Weight + 1);

            //_style.FixedHeight = 50;

            //_style.FontSize = 8;
            //_style.NormalTextColor = Color.white; // no text in header background
            _style.NormalGraphics = new Rect(w, w,
                                                                                              //new Fill(RgbColor.FromHex(0x214078).ToColor())
                                             new Fill(ColorMixer.FromHex(0x965FFF).ToColor()) // 0xc0c0c0
                                             );

            //_style.HoverTextColor = Color.black;
            //_style.HoverGraphics = new Rect(w, w, new Fill(Purple)); // Green

            _style.Commit();
        }
Exemple #14
0
        public static void ApplyThumbStyle(ProgramaticStyle programaticStyle, int w, int weight)
        {
            programaticStyle.Border = new RectOffset(weight + 1, weight + 1, weight + 1, weight + 1);

            //programaticStyle.FontSize = 30;
            //programaticStyle.NormalTextColor = Color.grey;

            programaticStyle.Margin = new RectOffset(weight, weight, weight, weight);

            programaticStyle.NormalGraphics = new Rect(w, w,
                                                       new Fill(ColorMixer.FromHex(0x666666).ToColor())/*,
                                                                                                        * new Stroke(Color.white, weight)*/
                                                       );
            //programaticStyle.HoverTextColor = Color.white;
            programaticStyle.HoverGraphics = new Rect(w, w,
                                                      new Fill(ColorMixer.FromHex(0x999999).ToColor())/*,
                                                                                                       * new Stroke(Color.white, weight)*/
                                                      );
            //programaticStyle.ActiveTextColor = Color.white;
            programaticStyle.ActiveGraphics = new Rect(w, w,
                                                       new Fill(ColorMixer.FromHex(0xAAAAAA).ToColor())/*,
                                                                                                        * new Stroke(Color.white, weight)*/
                                                       );
        }
Exemple #15
0
        private static void Initialize()
        {
            _instance.name = "ButtonSingleStateStyle";
            _instance.font = FontMapper.GetDefault().Font;

            _style = new ProgramaticStyle
            {
                Font          = FontMapper.GetDefault().Font,
                Style         = _instance,
                Alignment     = TextAnchor.MiddleCenter,
                ContentOffset = new Vector2(-1, -1)              // fix bad Unity offset
            };

            const int w = (Weight + 1) * 2;

            _style.Border         = new RectOffset(Weight + 1, Weight + 1, Weight + 1, Weight + 1);
            _style.NormalGraphics = new Rect(w, w,
                                             new Fill(Color.white),
                                             new Stroke(Weight)
            {
                Color = ColorMixer.FromHex(0x404040).ToColor()
            });
            _style.Commit();
        }
Exemple #16
0
        private static void Initialize()
        {
            //_instance.font = FontMapper.IsMapping("pixel") ? FontMapper.Get("pixel") : FontMapper.GetDefault();

            //Debug.Log("ImageStyle initializer");

            const int w = (Weight + 1) * 2;

            _style = new ProgramaticStyle
            {
                Style          = _instance,
                Alignment      = TextAnchor.MiddleLeft,
                Padding        = new RectOffset(Weight, Weight, Weight, Weight),
                Margin         = new RectOffset(0, 0, 0, 0),
                Font           = FontMapper.GetWithFallback("pixel").Font,
                Border         = new RectOffset(Weight + 1, Weight + 1, Weight + 1, Weight + 1),
                NormalGraphics = new Rect(w, w,
                                          new Fill(ColorMixer.FromHex(0xC0C0C0).ToColor()),
                                          new Stroke(Weight)
                {
                    Color = ColorMixer.FromHex(0x404040).ToColor()
                }
                                          )
            };
            //_style.Font = CoreSkinMapper.Instance.System.font;
            //_style.Font = FontMapper.GetDefault();


            //_style.FixedWidth = 100;
            //_style.FixedHeight = 100;

            //_style.FontSize = 8;
            //_style.NormalTextColor = Color.white;

            _style.Commit();
        }
Exemple #17
0
        override protected void CreateChildren()
        {
            base.CreateChildren();

            //Scroller scroller = new Scroller
            //                        {
            //                            SkinClass = typeof(ScrollerSkin2),
            //                            Left = 0,
            //                            Right = 0,
            //                            Top = 0,
            //                            Bottom = 0
            //                        };
            ////scroller.SetStyle("horizontalScrollPolicy", ScrollPolicy.Off);
            ////scroller.SetStyle("verticalScrollPolicy", ScrollPolicy.Off);
            //AddChild(scroller);

            //Group viewport = new Group
            //                     {
            //                         Layout = new VerticalLayout
            //                                      {
            //                                          HorizontalAlign = HorizontalAlign.Left,
            //                                          PaddingLeft = 10, PaddingRight = 10, PaddingTop = 10, PaddingBottom = 10,
            //                                          Gap = 10
            //                                      }
            //                     };
            //scroller.Viewport = viewport;

            #region Controls

            HGroup hbox = new HGroup
            {
                VerticalAlign = VerticalAlign.Middle,
                PaddingLeft   = 10,
                PaddingRight  = 10,
                PaddingTop    = 10,
                PaddingBottom = 10,
                Gap           = 10
            };

            hbox.SetStyle("showBackground", true);
            hbox.SetStyle("backgroundColor", ColorMixer.FromHex(0x004CFF).ToColor());
            /*viewport.*/ AddChild(hbox);

            Button button = new Button
            {
                Text      = "Increase width",
                SkinClass = typeof(ImageButtonSkin),
                Icon      = ImageLoader.Instance.Load("Icons/shape_square_add")
            };
            button.Click += delegate
            {
                button.Width += 10;
                _dataProvider.AddItem("miki " + button.Width);
            };
            hbox.AddChild(button);

            Button btnWindow = new Button
            {
                Text         = "New window",
                FocusEnabled = false,
                SkinClass    = typeof(ImageButtonSkin),
                Icon         = ImageLoader.Instance.Load("Icons/comment")
            };
            btnWindow.Click += delegate
            {
                //_container.RemoveAllChildren();
                //for (int i = _container.NumberOfChildren - 1; i >= 0; i--)
                //{
                //    _container.RemoveContentChildAt(i);
                //}
                //_container.RemoveAllContentChildren();
                //_count = 0;
                _count++;

                var window = new MyWindow
                {
                    Title     = "The Window " + _count,
                    Id        = "window_" + _count,
                    SkinClass = typeof(WindowSkin2),
                    Icon      = ImageLoader.Instance.Load("Icons/balloon_32"),
                    Width     = 400,
                    Height    = 600
                };

                //System.Random rnd = new System.Random();
                //if (rnd.Next(2) > 0)

                window.Plugins.Add(new Resizable {
                    ShowOverlay = false
                });
                window.AddEventListener(CloseEvent.CLOSE, delegate
                {
                    PopupManager.Instance.RemovePopup(window);
                });

                #region Cannot use plugin!

                // NOTE: We cannot use the plugin having a DragHandle because the placehoder group is being switched live
                // we just have to use the MoveArea skin part and do the dragging thing from inside the Dialog

                //var draggable = new Draggable
                //                    {
                //                        DragHandle = b.HeaderGroup
                //                    };
                //b.Plugins.Add(draggable);

                #endregion

                PopupManager.Instance.AddPopup(window, false);
                PopupManager.Instance.CenterPopUp(window);
            };
            hbox.AddChild(btnWindow);

            #endregion

            hbox = new HGroup
            {
                PaddingLeft   = 10,
                PaddingRight  = 10,
                PaddingTop    = 10,
                PaddingBottom = 10,
                Gap           = 10
            };

            //hbox.SetStyle("showBackground", true);
            //hbox.SetStyle("backgroundColor", RgbColor.FromHex(0x004CFF).ToColor());
            /*viewport.*/ AddChild(hbox);

            #region Data controls

            List <object> source = new List <object> {
                "Failure", "Teaches", "Success", "One", "Two", "Three", "Four", "Five", "Six"
            };

            _dataProvider = new ArrayList(source);

            var factory = new ItemRendererFactory <DefaultItemRenderer>();

            //DataGroup dataGroup = new DataGroup
            //                          {
            //                              Layout = new VerticalLayout(),
            //                              DataProvider = _dataProvider,
            //                              //ItemRenderer = new ItemRendererFactory <DefaultItemRenderer>(),
            //                              ItemRendererFunction = delegate(object item)
            //                                                         {
            //                                                             return factory;
            //                                                         }
            //                          };
            //hbox.AddChild(dataGroup);

            //dataGroup = new DataGroup
            //                {
            //                    Layout = new TileLayout { RequestedColumnCount = 4 },
            //                    //Width = 200, Height = 200,
            //                    DataProvider = _dataProvider,
            //                    //ItemRenderer = new ItemRendererFactory <DefaultItemRenderer>(),
            //                    ItemRendererFunction = delegate
            //                                               {
            //                                                   return factory;
            //                                               },
            //                    //ClipAndEnableScrolling = true
            //                };
            //hbox.AddChild(dataGroup);

            List list = new List
            {
                //Layout = new TileLayout { RequestedColumnCount = 4 },
                Width        = 200, Height = 200,
                Left         = 100, Top = 50,
                DataProvider = _dataProvider,
                //ItemRenderer = new ItemRendererFactory <DefaultItemRenderer>(),
                ItemRendererFunction = delegate
                {
                    return(factory);
                }
            };
            /*viewport.*/ AddChild(list);

            #endregion
        }
Exemple #18
0
        public void Render()
        {
            //GUILayout.Space(-5);

            if (AddEventHandlerDialog.Instance.ShowHelp)
            {
                EditorGUILayout.HelpBox(Help.EventList, MessageType.Info, true);
            }

            /**
             * Toggle buttons (mode switch)
             * */
            EditorGUILayout.BeginHorizontal(StyleCache.Instance.Toolbar, GUILayout.Height(35));

            _oldEnabled = GUI.enabled;
            GUI.enabled = _allowBubbling && !_inputMode;

            _selected = GUILayout.Toggle(_targetMode, new GUIContent("Target", _targetMode ? TextureCache.Instance.EventPhaseTargetOn : TextureCache.Instance.EventPhaseTarget), StyleCache.Instance.Toggle, GUILayout.Height(30), GUILayout.ExpandWidth(false));
            if (_selected != _targetMode)
            {
                _targetMode = _selected;
                _changed    = true;
            }

            _selected = GUILayout.Toggle(_bubblingMode, new GUIContent("Bubbling", _bubblingMode ? TextureCache.Instance.EventPhaseBubblingOn : TextureCache.Instance.EventPhaseBubbling), StyleCache.Instance.Toggle, GUILayout.Height(30), GUILayout.ExpandWidth(false));
            if (_selected != _bubblingMode)
            {
                _bubblingMode = _selected;
                _changed      = true;
            }
            GUI.enabled = _oldEnabled;

            /**
             * Search box
             * */
            _oldEnabled = GUI.enabled;
            GUI.enabled = !_inputMode;

            EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(true));
            GUILayout.FlexibleSpace();

            GUILayout.Label(GuiContentCache.Instance.Search, StyleCache.Instance.Label);

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(false));
            GUILayout.FlexibleSpace();

            if (!_inputMode)
            {
                GUI.SetNextControlName(InputTextFocusId);
            }
            _newSearchText = GUILayout.TextField(_searchText, GUILayout.Width(200) /*, GUILayout.Height(30), */);
            if (!_inputMode)
            {
                GUI.FocusControl(InputTextFocusId);
            }

            if (_newSearchText != _searchText)
            {
                _searchText = _newSearchText;
                _changed    = true;
            }

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();

            /**
             * Reset button
             * */
            if (!string.IsNullOrEmpty(_searchText))
            {
                EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(false));
                GUILayout.FlexibleSpace();

                if (GUILayout.Button(TextureCache.Instance.Cancel, StyleCache.Instance.SmallOpenButton, GUILayout.ExpandWidth(false)))
                {
                    _searchText = string.Empty;
                    _changed    = true;
                }

                GUILayout.FlexibleSpace();
                EditorGUILayout.EndVertical();
            }

            GUI.enabled = _oldEnabled;

            GUILayout.FlexibleSpace();

            /**
             * Input mode button
             * */
            _selected = GUILayout.Toggle(_inputMode, new GUIContent("Input mode", _inputMode ? TextureCache.Instance.InputModeOn : TextureCache.Instance.InputMode), StyleCache.Instance.Toggle, GUILayout.Height(30), GUILayout.ExpandWidth(false));
            if (_selected != _inputMode)
            {
                _inputMode = _selected;
                _changed   = true;

                if (_selectedIndex > -1 && _selectedIndex < _strEvents.Length)
                {
                    _inputText = _strEvents[_selectedIndex - 1];
                }

                EditorSettings.AddEventHandlerInputMode = _inputMode;
            }

            if (_changed)
            {
                _changed = false;
                Process();
            }

            EditorGUILayout.EndHorizontal();

            GUI.backgroundColor = ColorMixer.FromHex(0x335fd8).ToColor();

            GUI.backgroundColor = Color.white;

//            EditorGUILayout.BeginHorizontal();
//
//            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginVertical(StyleCache.Instance.ScrollviewBackground, GUILayout.ExpandWidth(true));

            if (_inputMode)
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();

                EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(true));
                GUILayout.FlexibleSpace();

                GUILayout.Label("Event name: ", EditorStyles.largeLabel);

                GUILayout.FlexibleSpace();
                EditorGUILayout.EndVertical();

                EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(false));
                GUILayout.FlexibleSpace();

                GUI.SetNextControlName(InputTextFocusId);
                _newInputText = GUILayout.TextField(_inputText, GUILayout.Width(200) /*, GUILayout.Height(30), */);
                GUI.FocusControl(InputTextFocusId);

                if (_newInputText != _inputText)
                {
                    _inputText = _newInputText;
                    _changed   = true;
                    AddEventHandlerDialog.Instance.Data.EventAttribute = null;
                    AddEventHandlerDialog.Instance.Data.EventName      = _inputText;
                }

                GUILayout.FlexibleSpace();
                EditorGUILayout.EndVertical();

                if (string.IsNullOrEmpty(_inputText))
                {
                    EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(false));
                    GUILayout.FlexibleSpace();

                    GUILayout.Label(GuiContentCache.Instance.Error, GUILayout.ExpandWidth(false));

                    GUILayout.FlexibleSpace();
                    EditorGUILayout.EndVertical();
                }

                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();
            }
            else
            {
                if (_contents.Length == 0)
                {
                    GUILayout.Label(GuiContentCache.Instance.NoEventsFound, StyleCache.Instance.CenteredLabel, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
                }
                else
                {
                    GUILayout.Space(1);

                    _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition, GUILayout.ExpandHeight(true));

                    _newIndex = GUILayout.SelectionGrid(_selectedIndex, _contents, 1,
                                                        StyleCache.Instance.GridButton,
                                                        GUILayout.ExpandWidth(true));

                    if (_newIndex != _selectedIndex)
                    {
                        _selectedIndex = _newIndex;
                        EventAttribute attr = _actualEventDict[_actualEventList[_selectedIndex]];
                        if (null != attr)
                        {
                            AddEventHandlerDialog.Instance.Data.EventAttribute = _actualEventDict[attr.Name];
                            AddEventHandlerDialog.Instance.Data.EventName      = null;
                        }

                        GotoSignal.Emit(1);
                    }

                    EditorGUILayout.EndScrollView();

                    GUILayout.Space(2);
                }
            }

            EditorGUILayout.EndVertical();  // panel chrome

            GUILayout.Space(1);
        }
Exemple #19
0
        public void Render()
        {
            _changed = false;

            _halfWidth = (int)Math.Floor(Screen.width * 0.5f - 10);

            if (StyleDeclarationDialog.Instance.ShowHelp)
            {
                EditorGUILayout.HelpBox(Help.ComponentStyleList, MessageType.Info, true);
            }

            /**
             * Toggle buttons (mode switch)
             * */
            EditorGUILayout.BeginHorizontal(StyleCache.Instance.Toolbar, GUILayout.Height(35));

            /**
             * Search box
             * */
            _oldEnabled = GUI.enabled;

            EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(true));
            GUILayout.FlexibleSpace();

            GUILayout.Label(GuiContentCache.Instance.Search, StyleCache.Instance.Label);

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(false));
            GUILayout.FlexibleSpace();

            GUI.SetNextControlName(InputTextFocusId);
            _newSearchText = GUILayout.TextField(_searchText, GUILayout.MinWidth(150), GUILayout.MaxWidth(400) /*, GUILayout.Height(30), */);
            GUI.FocusControl(InputTextFocusId);

            if (_newSearchText != _searchText)
            {
                _searchText = _newSearchText;
                _changed    = true;
            }

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();

            /**
             * Reset button
             * */
            if (!string.IsNullOrEmpty(_searchText))
            {
                EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(false));
                GUILayout.FlexibleSpace();

                if (GUILayout.Button(TextureCache.Instance.Cancel, StyleCache.Instance.SmallOpenButton, GUILayout.ExpandWidth(false)))
                {
                    _searchText = string.Empty;
                    _changed    = true;
                }

                GUILayout.FlexibleSpace();
                EditorGUILayout.EndVertical();
            }

            GUI.enabled = _oldEnabled;

            GUILayout.FlexibleSpace();

            if (_changed)
            {
                _changed = false;
                BuildLists();
            }

            EditorGUILayout.EndHorizontal();

            GUI.backgroundColor = ColorMixer.FromHex(0x335fd8).ToColor();

            GUI.backgroundColor = Color.white;

            EditorGUILayout.BeginVertical(StyleCache.Instance.ScrollviewBackground, GUILayout.ExpandWidth(true));

            GUILayout.Space(1);

            EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));

            #region Left

            if (_leftContents.Length == 0)
            {
                GUILayout.Label(GuiContentCache.Instance.NoStylePropertiesFound, StyleCache.Instance.CenteredLabel, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
            }
            else
            {
                _leftScrollPosition = EditorGUILayout.BeginScrollView(_leftScrollPosition,
                                                                      GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true), GUILayout.MinWidth(_halfWidth));

                _leftNewIndex = -1;
                for (int i = 0; i < _leftContents.Length; i++)
                {
                    var content = _leftContents[i];
                    if (GUILayout.Button(content, StyleCache.Instance.GridButton, GUILayout.ExpandWidth(true)))
                    {
                        _leftNewIndex = i;
                    }
                }

                if (-1 != _leftNewIndex)
                {
                    string propertyName = _leftPropertyNameList[_leftNewIndex];
                    if (null != propertyName)
                    {
                        var attr = GetStyleProperty(propertyName);

                        var match = StyleDeclarationDialog.Instance.Data.StyleProperties.Find(delegate(StyleProperty prop)
                        {
                            return(prop.Name == attr.Name);
                        });

                        if (null == match)
                        {
                            StyleDeclarationDialog.Instance.Data.StyleProperties.Add(attr);
                        }
                    }
                    BuildLists();
                }
                EditorGUILayout.EndScrollView();
            }

            #endregion

            #region Right

            if (_rightContents.Length == 0)
            {
                GUILayout.Label(GuiContentCache.Instance.NoStylePropertiesSelected, StyleCache.Instance.CenteredLabel, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
            }
            else
            {
                StyleProperty toRemove = null;

                _rightScrollPosition = EditorGUILayout.BeginScrollView(_rightScrollPosition,
                                                                       GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true), GUILayout.MinWidth(_halfWidth));

                _rightNewIndex = -1;
                for (int i = 0; i < _rightContents.Length; i++)
                {
                    var content = _rightContents[i];
                    if (GUILayout.Button(content, StyleCache.Instance.GridButton, GUILayout.ExpandWidth(true)))
                    {
                        _rightNewIndex = i;
                    }
                }

                if (-1 != _rightNewIndex)
                {
                    string propertyName = _rightPropertyNameList[_rightNewIndex];
                    if (null != propertyName)
                    {
                        toRemove = GetStyleProperty(propertyName);
                    }

                    if (null != toRemove)
                    {
                        var match =
                            StyleDeclarationDialog.Instance.Data.StyleProperties.Find(
                                delegate(StyleProperty styleProperty)
                        {
                            return(styleProperty.Name == toRemove.Name);
                        });

                        if (null != match)
                        {
                            StyleDeclarationDialog.Instance.Data.StyleProperties.Remove(match);
                        }
                    }
                    else
                    {
                        StyleDeclarationDialog.Instance.Data.StyleProperties.RemoveAt(_rightNewIndex);
                    }
                    BuildLists();
                }
                EditorGUILayout.EndScrollView();
            }

            #endregion

            EditorGUILayout.EndHorizontal();

            GUILayout.Space(2);

            EditorGUILayout.EndVertical();  // panel chrome

            GUILayout.Space(1);
        }
    override protected void CreateChildren()
    {
        base.CreateChildren();

        TitleLabel label = new TitleLabel
        {
            StyleName = "title",
            Left      = 10,
            Top       = 20
        };

        AddChild(label);

        var labelStyles = new Hashtable
        {
            { "labelStyle", BlueLabelStyle.Instance }
        };

        new TextRotator
        {
            Delay = 5, // 5 seconds delay
            Lines = new[]
            {
                "Composite Control Demo",
                "Created with eDriven.Gui",
                //"Author: Danko Kozar",
                "Composite controls could be built using child controls",
                "These controls could treated as simple controls...",
                "... and used to build even more complex controls"
            },
            Callback = delegate(string line) { label.Text = line; }
        }.Start();

        AddChild(new Spacer {
            Height = 20
        });

        HGroup hbox = new HGroup
        {
            HorizontalCenter = 0,
            VerticalCenter   = 0,
            Gap = 50
        };

        AddChild(hbox);

        WrapVBox(hbox, new Label {
            Text = "RGB Mixer", Styles = labelStyles, PercentWidth = 100
        },
                 new RgbMixer {
            RgbColor = ColorMixer.FromHex(0xFBAF5C).ToColor()
        });

        WrapVBox(hbox, new Label {
            Text = "RGB Mixer", Styles = labelStyles, PercentWidth = 100
        },
                 new RgbMixer {
            RgbColor = ColorMixer.FromHex(0x855FA8).ToColor()
        });

        WrapVBox(hbox, new Label {
            Text = "RGB Mixer", Styles = labelStyles, PercentWidth = 100
        },
                 new RgbMixer {
            RgbColor = ColorMixer.FromHex(0x438CCA).ToColor()
        });
    }
Exemple #21
0
        /*private Color _textColorAccent;
         * public Color TextColorAccent
         * {
         *  get { return _textColorAccent; }
         * }*/

        /// <summary>
        /// Initializes the Singleton instance
        /// </summary>
        private void Initialize()
        {
            var isDarkSkin         = EditorSettings.UseDarkSkin;
            var darkSkinTextColor  = ColorMixer.FromHex(0xb1b1b1).ToColor();
            var lightSkinTextColor = Color.black;

            _textColor = isDarkSkin ? darkSkinTextColor : lightSkinTextColor;
            //_textColorAccent = isDarkSkin ? RgbColor.FromHex(0xffff00).ToColor() : RgbColor.FromHex(0x0000ff).ToColor();

            var lightTextColor = isDarkSkin ? ColorMixer.FromHex(0xeeeeee).ToColor() : Color.white;

            string prefix = "Light/";

            if (isDarkSkin)
            {
                prefix = "Dark/";
            }

            //Debug.Log("Text color: " + textColor);

            /**
             * Note: EditorStyles.label introduces a BUG
             * NullReferenceException: Object reference not set to an instance of an object
             * UnityEditor.EditorStyles.get_label () (at C:/BuildAgent/work/d3d49558e4d408f4/Editor/Mono/GUI/EditorStyles.cs:11)
             * eDriven.Gui.Editor.Rendering.StyleCache.Initialize () (at
             * */

            GUIStyle labelBase = new GUIStyle(EditorStyles.label) //EditorStyles.largeLabel
                                                                  //GUIStyle labelBase = new GUIStyle(GUI.skin.label) //EditorStyles.largeLabel
            {
                normal    = { textColor = _textColor },
                alignment = TextAnchor.MiddleLeft,
                padding   = new RectOffset(3, 3, 2, 2),
                margin    = new RectOffset(3, 3, 3, 3)
            };

            Label = new GUIStyle(labelBase);

            GUIStyle buttonBase = new GUIStyle(GUI.skin.button)
            {
                normal   = { textColor = _textColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "button_normal") },
                hover    = { textColor = _textColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "button_hover") },
                active   = { textColor = _textColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "button_active") },
                onNormal = { textColor = _textColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "button_on_normal") },
                onHover  = { textColor = _textColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "button_on_hover") },
                onActive = { textColor = _textColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "button_on_active") }
            };

            GUIStyle controlButtonBase = new GUIStyle(buttonBase)
            {
                hover  = { textColor = _textColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "control_button_hover") },
                active = { textColor = _textColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "control_button_active") },
            };

            ControlButton = new GUIStyle(controlButtonBase)
            {
                alignment   = TextAnchor.MiddleLeft,
                padding     = new RectOffset(10, 10, 2, 2),
                fixedHeight = 32,
                margin      = new RectOffset(3, 3, 3, 3),
                clipping    = TextClipping.Clip
            };

            DisplayRowButton = new GUIStyle(controlButtonBase)
            {
                normal      = { textColor = _textColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "control_button_normal") },
                alignment   = TextAnchor.MiddleLeft,
                padding     = new RectOffset(10, 10, 2, 2),
                fixedHeight = 32,
                margin      = new RectOffset(3, 3, 3, 3),
                clipping    = TextClipping.Clip
            };

            Header = new GUIStyle(GUI.skin.label)
            {
                padding = new RectOffset(5, 5, 2, 2), alignment = TextAnchor.MiddleLeft
            };
            Background = new GUIStyle(GUI.skin.box)
            {
                padding = new RectOffset(10, 10, 2, 2), alignment = TextAnchor.MiddleCenter
            };

            Toggle = new GUIStyle(buttonBase)
            {
                padding   = new RectOffset(10, 10, 2, 2),
                alignment = TextAnchor.MiddleCenter
            };
            Toggle2 = new GUIStyle(buttonBase)
            {
                normal    = { textColor = _textColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "button_normal2") },
                padding   = new RectOffset(10, 10, 2, 2),
                alignment = TextAnchor.MiddleCenter
            };

            GridButton = new GUIStyle(Toggle)
            {
                alignment   = TextAnchor.MiddleLeft,
                fixedHeight = 32,
                margin      = new RectOffset(3, 3, 3, 3),
                clipping    = TextClipping.Clip
            };

            CenteredLabel = new GUIStyle(labelBase)
            {
                padding = new RectOffset(10, 10, 10, 10), alignment = TextAnchor.MiddleCenter, imagePosition = ImagePosition.ImageAbove
            };

            CenteredWhiteLabel = new GUIStyle(labelBase)
            {
                padding       = new RectOffset(10, 10, 10, 10),
                alignment     = TextAnchor.MiddleCenter,
                imagePosition = ImagePosition.ImageAbove,
                normal        = { textColor = Color.white }
            };

            NormalLabel = new GUIStyle(labelBase)
            {
                padding       = new RectOffset(10, 10, 10, 10),
                alignment     = TextAnchor.UpperLeft,
                imagePosition = ImagePosition.TextOnly,
                //wordWrap = true,
                normal  = { textColor = _textColor },
                hover   = { textColor = _textColor },
                active  = { textColor = _textColor },
                focused = { textColor = _textColor }, // for EditorGUILayout.TextArea
            };

            RichTextLabel = new GUIStyle(NormalLabel)
            {
                richText = true
            };

            DragHandle = new GUIStyle(GUI.skin.label)
            {
                padding = new RectOffset(2, 2, 2, 2), alignment = TextAnchor.MiddleLeft
            };

            ListRow = new GUIStyle(GUI.skin.box)
            {
                normal      = { background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "list_row") },
                padding     = new RectOffset(4, 4, 4, 4),
                fixedHeight = 31
            };
            GroupRow = new GUIStyle(GUI.skin.box)
            {
                normal      = { background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "group_row") },
                padding     = new RectOffset(8, 8, 4, 4),
                fixedHeight = 31
            };
            ComponentHandle = new GUIStyle(GUI.skin.label)
            {
                fixedHeight = 23,
                padding     = new RectOffset(8, 8, 3, 3),
                alignment   = TextAnchor.MiddleLeft,
                normal      = { textColor = _textColor },
                margin      = new RectOffset(2, 2, 0, 0),
                border      = new RectOffset(3, 3, 3, 3),
                wordWrap    = false
            };
            ContainerHandle = new GUIStyle(GUI.skin.label)
            {
                fixedHeight = 23,
                padding     = new RectOffset(8, 8, 2, 2),
                alignment   = TextAnchor.MiddleLeft,
                normal      = { textColor = _textColor },
                fontStyle   = FontStyle.Italic,
                //normal = { textColor = Color.white },
                margin   = new RectOffset(2, 2, 0, 0),
                wordWrap = false
            };
            GroupRowLabel = new GUIStyle(labelBase)
            {
                normal      = { textColor = darkSkinTextColor },
                fixedHeight = 23,
                //padding = new RectOffset(8, 8, 2, 2),
                alignment = TextAnchor.MiddleLeft,
                fontStyle = FontStyle.Bold,
                //normal = { textColor = Color.white },
                margin   = new RectOffset(2, 2, 0, 0),
                wordWrap = false
            };

            EventFlow = new GUIStyle(GUI.skin.box)
            {
                normal     = { background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + "event_flow") },
                fixedWidth = 50, fixedHeight = 16
            };

            EventFlowDisabled = new GUIStyle(GUI.skin.box)
            {
                normal      = { background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + "event_flow_disabled") },
                fixedWidth  = 50,
                fixedHeight = 16
            };

            ImageOnlyButton = new GUIStyle(buttonBase)
            {
                fixedWidth  = 22,
                fixedHeight = 22,
                border      = new RectOffset(15, 15, 22, 0),
                padding     = new RectOffset(2, 2, 3, 2),
                margin      = new RectOffset(2, 6, 0, 0)
            };
            ImageOnlyNoFrameButton = new GUIStyle(ImageOnlyButton)
            {
                normal = { background = null },
                margin = new RectOffset(3, 3, 3, 3)
            };
            SmallOpenButton = new GUIStyle(ImageOnlyButton)
            {
                normal = { background = null },
                margin = new RectOffset(-2, -2, -2, -2)
            };
            ImageOnlyButtonWide = new GUIStyle(ImageOnlyButton)
            {
                fixedWidth = 0,                           // no fixed width
                padding    = new RectOffset(5, 5, 3, 2),
            };

            Button = new GUIStyle(buttonBase)
            {
                border  = new RectOffset(3, 3, 3, 3),
                padding = new RectOffset(6, 11, 5, 4)
            };
            Button2 = new GUIStyle(buttonBase)
            {
                normal  = { textColor = _textColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "button_normal2") },
                border  = new RectOffset(3, 3, 3, 3),
                padding = new RectOffset(6, 11, 5, 4)
            };

            BigButton = new GUIStyle(buttonBase)
            {
                //normal = { textColor = textColor, background = EditorResourceLoader<Texture2D>.Load(EditorIconsPath + prefix + "button_normal2") },
                border  = new RectOffset(3, 3, 3, 3),
                padding = new RectOffset(8, 8, 4, 3)
            };

            BigLightButton = new GUIStyle(buttonBase)
            {
                normal   = { textColor = lightSkinTextColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + "Light/button_normal2") },
                hover    = { textColor = lightSkinTextColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + "Light/button_hover") },
                active   = { textColor = lightSkinTextColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + "Light/button_active") },
                onNormal = { textColor = lightSkinTextColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + "Light/button_on_normal") },
                onHover  = { textColor = lightSkinTextColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + "Light/button_on_hover") },
                onActive = { textColor = lightSkinTextColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + "Light/button_on_active") },
                border   = new RectOffset(3, 3, 3, 3),
                padding  = new RectOffset(8, 8, 4, 3)
            };

            TabButton = new GUIStyle(buttonBase)
            {
                border  = new RectOffset(3, 11, 11, 3),
                padding = new RectOffset(10, 14, 5, 4),
                margin  = new RectOffset(0, 4, 0, 0)
            };

            TabButton = new GUIStyle(GUI.skin.button)
            {
                normal   = { textColor = _textColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "tab_button_normal") },
                hover    = { textColor = _textColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "tab_button_hover") },
                active   = { textColor = _textColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "tab_button_active") },
                onNormal = { textColor = _textColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "tab_button_on_normal") },
                onHover  = { textColor = _textColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "tab_button_on_hover") },
                onActive = { textColor = _textColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "tab_button_on_active") },
                border   = new RectOffset(3, 11, 11, 3),
                padding  = new RectOffset(10, 14, 5, 4),
                margin   = new RectOffset(0, 4, 0, 0)
            };

            TabBackground = new GUIStyle(GUI.skin.button)
            {
                normal  = { textColor = _textColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + (isDarkSkin ? prefix + "tab_background" : prefix + "tab_background")) },
                border  = new RectOffset(3, 3, 3, 3),
                padding = new RectOffset(0, 0, 0, 0),
                margin  = new RectOffset(0, 0, 0, 0)
            };

            Breadcrumb = new GUIStyle(GUI.skin.button)
            {
                normal      = { textColor = _textColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "breadcrumb_normal") },
                hover       = { textColor = _textColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "breadcrumb_hover") },
                active      = { textColor = _textColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "breadcrumb_active") },
                onNormal    = { textColor = lightTextColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "breadcrumb_on_normal") },
                onHover     = { textColor = lightTextColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "breadcrumb_on_hover") },
                onActive    = { textColor = lightTextColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "breadcrumb_on_normal") },
                fixedHeight = 22,
                border      = new RectOffset(15, 15, 22, 0),
                padding     = new RectOffset(15, 15, 1, 1),
                margin      = new RectOffset(-12, -12, 0, 0),
                //fontStyle = FontStyle.Bold
            };

            BreadcrumbFirst = new GUIStyle(GUI.skin.button)
            {
                normal      = { textColor = _textColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "breadcrumb_first_normal") },
                hover       = { textColor = _textColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "breadcrumb_first_hover") },
                active      = { textColor = _textColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "breadcrumb_first_active") },
                onNormal    = { textColor = lightTextColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "breadcrumb_first_on_normal") },
                onHover     = { textColor = lightTextColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "breadcrumb_first_on_hover") },
                onActive    = { textColor = lightTextColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "breadcrumb_first_on_normal") },
                fixedHeight = 22,
                border      = new RectOffset(15, 15, 22, 0),
                padding     = new RectOffset(6, 15, 1, 1),
                margin      = new RectOffset(4, -12, 0, 0),
                //fontStyle = FontStyle.Bold
            };

            GreenToggle = new GUIStyle(Button)
            {
                onNormal = { textColor = Color.black, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "button_green_on_normal") },
                onHover  = { textColor = Color.black, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "button_green_on_hover") },
                onActive = { textColor = Color.black, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "button_green_on_active") }
            };

            GreenToggle2 = new GUIStyle(Button)
            {
                normal   = { textColor = _textColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "button_normal2") },
                onNormal = { textColor = Color.black, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "button_green_on_normal") },
                onHover  = { textColor = Color.black, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "button_green_on_hover") },
                onActive = { textColor = Color.black, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "button_green_on_active") }
            };

            Toolbar = isDarkSkin ?
                      new GUIStyle(GUI.skin.button)
            {
                normal  = { /*textColor = textColor, */ background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "toolbar") },
                border  = new RectOffset(3, 3, 3, 3),
                padding = new RectOffset(5, 5, 5, 5),
                margin  = new RectOffset(0, 0, 0, 0)
            }:
            new GUIStyle(GUI.skin.button)
            {
                normal  = { /*textColor = textColor, */ background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + "toolbar") },
                border  = new RectOffset(3, 3, 3, 3),
                padding = new RectOffset(5, 5, 5, 5),
                margin  = new RectOffset(0, 0, 0, 0)
            };

            StatusToolbar = new GUIStyle(GUI.skin.button)
            {
                normal  = { /*textColor = textColor, */ background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + "white") },
                border  = new RectOffset(3, 3, 3, 3),
                padding = new RectOffset(5, 5, 5, 5),
                margin  = new RectOffset(0, 0, 0, 0)
            };

            Fieldset = new GUIStyle(GUI.skin.box)
            {
                normal  = { textColor = _textColor, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "fieldset") },
                border  = new RectOffset(5, 5, 5, 5),
                padding = new RectOffset(5, 5, 5, 5),
                margin  = new RectOffset(4, 4, 4, 0)
            };

            /* ========== Panel ========== */
            PanelChrome = new GUIStyle(GUI.skin.box)
            {
                normal  = { /*textColor = Color.black, */ background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + "panel_chrome") },
                border  = new RectOffset(5, 5, 5, 5),
                padding = new RectOffset(5, 5, 5, 5),
                margin  = new RectOffset(4, 4, 4, 0)
            };
            PanelChromeSquared = new GUIStyle(PanelChrome)
            {
                normal = { /*textColor = Color.black, */ background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + "panel_chrome_squared") }
            };

            PanelHeader = new GUIStyle(GUI.skin.label)
            {
                alignment = TextAnchor.MiddleLeft,
                padding   = new RectOffset(3, 3, 3, 3),
                margin    = new RectOffset(3, 3, 3, 3),
                normal    = { textColor = lightTextColor },
                fontStyle = FontStyle.Bold
            };
            PanelContent = new GUIStyle(GUI.skin.box)
            {
                normal  = { background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "panel_content") },
                border  = new RectOffset(5, 5, 5, 5),
                padding = new RectOffset(5, 5, 5, 5),
                margin  = new RectOffset(4, 4, 4, 0)
            };

            ScrollviewBackground = new GUIStyle(GUI.skin.box)
            {
                normal  = { /*textColor = Color.black, */ background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "panel_content") },
                border  = new RectOffset(5, 5, 5, 5),
                padding = new RectOffset(0, 0, 0, 0),
                margin  = new RectOffset(0, 0, 0, 0)
            };

            /* ========== Inset ========== */
            InsetChrome = new GUIStyle(GUI.skin.box)
            {
                normal  = { /*textColor = Color.black, */ background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + prefix + "inset_chrome_normal") },
                border  = new RectOffset(3, 3, 3, 3),
                padding = new RectOffset(4, 4, 4, 4),
                margin  = new RectOffset(4, -12, 0, 0)
            };
            InsetHeaderCollapsed = new GUIStyle(GUI.skin.label)
            {
                alignment = TextAnchor.MiddleLeft,
                padding   = new RectOffset(0, 2, 2, 2),
                margin    = new RectOffset(2, 2, 2, 2),
                normal    = { textColor = Color.black }
            };
            InsetHeaderExpanded = new GUIStyle(GUI.skin.label)
            {
                alignment = TextAnchor.MiddleLeft,
                padding   = new RectOffset(0, 2, 2, 2),
                margin    = new RectOffset(2, 2, 2, 2),
                normal    = { textColor = Color.black }
            };
            InsetContent = new GUIStyle(GUI.skin.box)
            {
                normal  = { textColor = Color.black, background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + "panel_content") },
                border  = new RectOffset(5, 5, 5, 5),
                padding = new RectOffset(5, 5, 5, 5),
                margin  = new RectOffset(4, 4, 4, 0)
            };

            Foldout = new GUIStyle(GUI.skin.label)
            {
                alignment = TextAnchor.MiddleLeft,
                padding   = new RectOffset(0, 0, 0, 0),
                margin    = new RectOffset(3, 3, 3, 3)
            };
            AboutLabel = new GUIStyle(GUI.skin.label)
            {
                alignment = TextAnchor.MiddleLeft,
                padding   = new RectOffset(3, 3, 2, 2),
                margin    = new RectOffset(3, 3, 3, 3),
                normal    = { textColor = lightTextColor },
                fontStyle = FontStyle.Bold
            };
            AboutPanelContent = new GUIStyle(GUI.skin.box)
            {
                normal  = { background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + "about_panel_content") },
                border  = new RectOffset(5, 5, 5, 5),
                padding = new RectOffset(5, 5, 5, 5),
                margin  = new RectOffset(4, 4, 4, 0)
            };
            AboutPanelContent2 = new GUIStyle(GUI.skin.box)
            {
                normal  = { background = EditorResourceLoader <Texture2D> .Load(EditorIconsPath + "about_panel_content2") },
                border  = new RectOffset(5, 5, 5, 5),
                padding = new RectOffset(5, 5, 5, 5),
                margin  = new RectOffset(4, 4, 4, 0)
            };
            PurchaseBox = new GUIStyle(GUI.skin.box)
            {
                alignment = TextAnchor.UpperLeft,
                padding   = new RectOffset(10, 10, 2, 2),
                margin    = new RectOffset(3, 3, 3, 3),
                normal    = { textColor = lightTextColor, background = null },
                //fontStyle = FontStyle.Bold
            };
            NormalBox = new GUIStyle(GUI.skin.box)
            {
                alignment = TextAnchor.UpperLeft,
                padding   = new RectOffset(3, 3, 2, 2),
                margin    = new RectOffset(3, 3, 3, 3),
                normal    = { background = null },
            };

            Title = new GUIStyle(GUI.skin.label)
            {
                alignment = TextAnchor.MiddleCenter,
                padding   = new RectOffset(3, 3, 2, 2),
                margin    = new RectOffset(3, 3, 15, 15),
                fontStyle = FontStyle.Bold
            };

            Dot = new GUIStyle(GUI.skin.label)
            {
                border  = new RectOffset(0, 0, 0, 0),
                padding = new RectOffset(0, 0, 0, 0),
                margin  = new RectOffset(0, 0, 0, 0)
            };
        }
        //private string _typeToFind;

        public void Render()
        {
            if (StyleDeclarationDialog.Instance.ShowHelp)
            {
                EditorGUILayout.HelpBox(Help.StyleableComponentList, MessageType.Info, true);
            }

            /**
             * Toggle buttons (mode switch)
             * */
            EditorGUILayout.BeginHorizontal(StyleCache.Instance.Toolbar, GUILayout.Height(35));

            /**
             * Search box
             * */
            EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(false), GUILayout.Width(16));
            GUILayout.FlexibleSpace();

            GUILayout.Label(GuiContentCache.Instance.Search, StyleCache.Instance.Label, GUILayout.ExpandWidth(false));

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(true));
            GUILayout.FlexibleSpace();

            GUI.SetNextControlName(InputTextFocusId);
            _newSearchText = GUILayout.TextField(_searchText, GUILayout.MinWidth(150), GUILayout.MaxWidth(400) /*, GUILayout.ExpandWidth(true)*//*, GUILayout.Height(30), */);
            GUI.FocusControl(InputTextFocusId);

            if (_newSearchText != _searchText)
            {
                _searchText = _newSearchText;
                _changed    = true;
            }

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();

            if (null != _selectedType)
            {
                _searchText = _selectedType;
                _changed    = true;
            }

            /**
             * Reset button
             * */
            if (!string.IsNullOrEmpty(_searchText))
            {
                EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(false), GUILayout.Width(16));
                GUILayout.FlexibleSpace();

                if (GUILayout.Button(TextureCache.Instance.Cancel, StyleCache.Instance.SmallOpenButton, GUILayout.ExpandWidth(false)))
                {
                    _searchText = string.Empty;
                    _changed    = true;
                }

                GUILayout.FlexibleSpace();
                EditorGUILayout.EndVertical();
            }

            GUILayout.FlexibleSpace();

            if (_buttons.Count > 0)
            {
                EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(false), GUILayout.Width(16));
                GUILayout.FlexibleSpace();

                EditorGUILayout.BeginHorizontal();
                for (int i = 0; i < _buttons.Count; i++)
                {
                    var  oldEnabled = StyleModuleManager.Instance.AllModules[i].Enabled;
                    bool newEnabled = GUILayout.Toggle(oldEnabled, _buttons[i], StyleCache.Instance.ImageOnlyButton);
                    if (newEnabled != oldEnabled)
                    {
                        StyleModuleManager.Instance.AllModules[i].Enabled = newEnabled;
                        _changed = true;
                    }
                }
                EditorGUILayout.EndHorizontal();

                GUILayout.FlexibleSpace();
                EditorGUILayout.EndVertical();
            }

            if (_changed)
            {
                _changed = false;
                BuildList();
            }

            EditorGUILayout.EndHorizontal();

            GUI.backgroundColor = ColorMixer.FromHex(0x335fd8).ToColor();

            GUI.backgroundColor = Color.white;

            EditorGUILayout.BeginVertical(StyleCache.Instance.ScrollviewBackground, GUILayout.ExpandWidth(true));

            if (_contents.Length == 0)
            {
                GUILayout.Label(GuiContentCache.Instance.NoStyleableClassesFound, StyleCache.Instance.CenteredLabel, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
            }
            else
            {
                GUILayout.Space(1);

                _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition, GUILayout.ExpandHeight(true));

                _newIndex = GUILayout.SelectionGrid(_selectedIndex, _contents, 1,
                                                    StyleCache.Instance.GridButton,
                                                    GUILayout.ExpandWidth(true));

                EditorGUILayout.EndScrollView();

                GUILayout.Space(2);
            }

            EditorGUILayout.EndVertical();  // panel chrome

            GUILayout.Space(1);

            if (_newIndex != _selectedIndex) // proposed = from outside
            {
                _selectedIndex = _newIndex;

                var selectedType = _typeDescriptorList[_selectedIndex].Type;

                bool typeChanged = selectedType.FullName != StyleDeclarationDialog.Instance.Data.Type;

                StyleDeclarationDialog.Instance.Data.Type = selectedType.FullName;

                var module = StyleModuleManager.Instance.GetOwnerModule(selectedType);
                StyleDeclarationDialog.Instance.Data.ModuleId             = module.Id;
                StyleDeclarationDialog.Instance.Data.AllowSubjectOmmision = module.AllowSubjectOmmision;

                /* If type changed and multiple clients not supported, clear the current collection */
                if (typeChanged && !module.AllowMultipleClients)
                {
                    StyleDeclarationDialog.Instance.Data.StyleProperties.Clear();
                }

                //StyleDeclarationDialogStep2.Instance.Descriptors = module.GetStyleDescriptors(selectedType);

                /*var mediaQueries = MediaQueryManager.Instance.Queries;
                 *
                 * var descriptors = new Dictionary<string, MediaQueryDescriptor>();
                 * foreach (var mediaQueryId in mediaQueries.Keys)
                 * {
                 *  descriptors[mediaQueryId] = new MediaQueryDescriptor(mediaQueryId, TextureCache.Instance.MediaQuery);
                 * }
                 * StyleDeclarationDialogStep3.Instance.Descriptors = descriptors;*/

                GotoSignal.Emit(1);
            }
        }
Exemple #23
0
        public ButtonSkin2()
        {
            MouseEnabled  = false;
            MouseChildren = false;

            States = new List <State>
            {
                new State("up")
                {
                    Overrides = new List <IOverride>
                    {
                        new SetStyle("backgroundColor", ColorMixer.FromHex(0xeeeeee).ToColor())
                    }
                },
                new State("over")
                {
                    Overrides = new List <IOverride>
                    {
                        new SetStyle("backgroundColor", ColorMixer.FromHex(0xf9f9f9).ToColor())
                    }
                },
                new State("down")
                {
                    Overrides = new List <IOverride>
                    {
                        new SetProperty("BackgroundColor", ColorMixer.FromHex(0xdadada).ToColor())
                    }
                },
                new State("disabled")
                {
                    Overrides = new List <IOverride>
                    {
                        new SetProperty("Alpha", 0.6f)
                    }
                },
                new State("upAndSelected")
                {
                    Overrides = new List <IOverride>
                    {
                        new SetProperty("BackgroundColor", ColorMixer.FromHex(0x439dde).ToColor()),
                        new SetStyle("textColor", Color.white)
                    }
                },
                new State("overAndSelected")
                {
                    BasedOn   = "upAndSelected",
                    Overrides = new List <IOverride>
                    {
                        new SetProperty("BackgroundColor", ColorMixer.FromHex(0x4488fc).ToColor())
                    }
                },
                new State("downAndSelected")
                {
                    BasedOn   = "upAndSelected",
                    Overrides = new List <IOverride>
                    {
                        new SetProperty("BackgroundColor", ColorMixer.FromHex(0x1261c1).ToColor())
                    }
                },
                new State("disabledAndSelected")
                {
                    BasedOn   = "upAndSelected",
                    Overrides = new List <IOverride>
                    {
                        new SetProperty("Alpha", 0.6f)
                    }
                }
            };
        }
Exemple #24
0
        // ReSharper restore MemberCanBePrivate.Global

        #endregion

        #region Rollovers

        public ButtonSkin3()
        {
            MouseEnabled  = false;
            MouseChildren = false;

            States = new List <State>
            {
                new State("up")
                {
                    Overrides = new List <IOverride>
                    {
                        new SetStyle("backgroundColor", ColorMixer.FromHex(0xeeeeee).ToColor())
                    }
                },
                new State("over")
                {
                    Overrides = new List <IOverride>
                    {
                        new SetStyle("backgroundColor", ColorMixer.FromHex(0xf9f9f9).ToColor())
                    }
                },
                new State("down")
                {
                    Overrides = new List <IOverride>
                    {
                        new SetProperty("BackgroundColor", ColorMixer.FromHex(0xdadada).ToColor())
                    }
                },
                new State("disabled")
                {
                    Overrides = new List <IOverride>
                    {
                        new SetProperty("Alpha", 0.6f)
                    }
                },
                new State("upAndSelected")
                {
                    Overrides = new List <IOverride>
                    {
                        new SetProperty("BackgroundColor", ColorMixer.FromHex(0x439dde).ToColor()),
                        new SetStyle("textColor", Color.white)
                    }
                },
                new State("overAndSelected")
                {
                    BasedOn   = "upAndSelected",
                    Overrides = new List <IOverride>
                    {
                        new SetProperty("BackgroundColor", ColorMixer.FromHex(0x4488fc).ToColor())
                    }
                },
                new State("downAndSelected")
                {
                    BasedOn   = "upAndSelected",
                    Overrides = new List <IOverride>
                    {
                        new SetProperty("BackgroundColor", ColorMixer.FromHex(0x1261c1).ToColor())
                    }
                },
                new State("disabledAndSelected")
                {
                    BasedOn   = "upAndSelected",
                    Overrides = new List <IOverride>
                    {
                        new SetProperty("Alpha", 0.6f)
                    }
                }
            };

            AddEventListener(MouseEvent.ROLL_OVER, RollOverHandler, EventPhase.Capture | EventPhase.Target);
            AddEventListener(MouseEvent.ROLL_OUT, RollOutHandler, EventPhase.Capture | EventPhase.Target);
        }
Exemple #25
0
        /// <summary>
        /// Note: state creation cannot be static/singleton!
        /// Each and every object needs its own set of states
        /// </summary>
        /// <returns></returns>
        public static List <State> CreateStates()
        {
            return(new List <State>
            {
                new State("up")
                {
                    Overrides = new List <IOverride>
                    {
                        new SetStyle("backgroundColor", ColorMixer.FromHex(0xeeeeee).ToColor()), // 0xfffffe??
                    }
                },
                new State("over")
                {
                    Overrides = new List <IOverride>
                    {
                        new SetStyle("backgroundColor", ColorMixer.FromHex(0xf9f9f9).ToColor()), // 0xfffffe??

                        #region Just for test

                        /* Can set child property */
                        //new SetProperty("IconDisplay", "Color", Color.red),
                        //new SetProperty("IconDisplay", "Scale", new Vector2(2f, 2f)),

                        /* Can access private part */
                        //new SetProperty("_hGroup", "Rotation", 30)

                        #endregion
                    }
                },
                new State("down")
                {
                    Overrides = new List <IOverride>
                    {
                        new SetProperty("BackgroundColor", ColorMixer.FromHex(0xdadada).ToColor())
                    }
                },
                new State("disabled")
                {
                    Overrides = new List <IOverride>
                    {
                        new SetProperty("Alpha", 0.6f)
                    }
                },
                new State("upAndSelected")
                {
                    Overrides = new List <IOverride>
                    {
                        new SetProperty("BackgroundColor", ColorMixer.FromHex(0x439dde).ToColor()),
                        new SetStyle("textColor", Color.white)
                    }
                },
                new State("overAndSelected")
                {
                    BasedOn = "upAndSelected",
                    Overrides = new List <IOverride>
                    {
                        new SetProperty("BackgroundColor", ColorMixer.FromHex(0x4488fc).ToColor())
                    }
                },
                new State("downAndSelected")
                {
                    BasedOn = "upAndSelected",
                    Overrides = new List <IOverride>
                    {
                        new SetProperty("BackgroundColor", ColorMixer.FromHex(0x1261c1).ToColor())
                    }
                },
                new State("disabledAndSelected")
                {
                    BasedOn = "upAndSelected",
                    Overrides = new List <IOverride>
                    {
                        new SetProperty("Alpha", 0.6f)
                    }
                }
            });
        }
Exemple #26
0
        private static void Initialize()
        {
            _style = new ProgramaticStyle
            {
                Font      = FontMapper.GetDefault().Font,
                Style     = _instance,
                Alignment = TextAnchor.MiddleCenter,
                Padding   = new RectOffset(6, 6, 3, 3)
            };

            const int w  = (Weight + 1) * 2;
            int       w2 = 18;

            //_style.FixedWidth = 100;
            //_style.FixedHeight = 100;
            _style.Border = new RectOffset(Weight + 1, Weight + 1, Weight + 1, Weight + 1);

            //_style.FontSize = 8;
            _style.NormalTextColor = new Color(0.1f, 0.1f, 0.1f, 1);
            _style.NormalGraphics  = new Rect(w, w,
                                              new Fill(ColorMixer.FromHex(0xC0C0C0).ToColor()),
                                              new Stroke(Weight)
            {
                Color = ColorMixer.FromHex(0x404040).ToColor()
            }
                                              );
            _style.HoverTextColor = new Color(0.1f, 0.1f, 0.1f, 1);
            _style.HoverGraphics  = new Rect(w, w,
                                             new Fill(new Color(1f, 1f, 1f, 1f)),
                                             new Stroke(Weight)
            {
                Color = Color.grey
            }
                                             );
            _style.ActiveTextColor = new Color(0.1f, 0.1f, 0.1f, 1);
            _style.ActiveGraphics  = new Rect(w, w,
                                              new Fill(ColorMixer.FromHex(0x808080).ToColor()),
                                              new Stroke(Weight)
            {
                Color = ColorMixer.FromHex(0xD3D3D3).ToColor()
            }
                                              );

            _style.OnNormalTextColor = Color.white;
            _style.OnNormalGraphics  = new Rect(w, w,
                                                new Fill(ColorMixer.FromHex(0x808080).ToColor()),
                                                new Stroke(Weight)
            {
                Color = ColorMixer.FromHex(0xD3D3D3).ToColor()
            }
                                                );

            ScrollbarHelper.ApplyButtonStyle(_style, w2, Weight, TriangleDirection.Up);

            _style.FixedWidth  = w2;
            _style.FixedHeight = w2;

            _style.Commit();

            //_style.FixedHeight = 20;
            //_style.FixedWidth = 100;
        }
        public void Render()
        {
            GUI.backgroundColor = ColorMixer.FromHex(0x335fd8).ToColor();

            GUI.backgroundColor = Color.white;

            EditorGUILayout.BeginHorizontal(StyleCache.Instance.Toolbar, GUILayout.Height(35));

            EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(true));

            GUILayout.FlexibleSpace();
            GUILayout.Label(GuiContentCache.Instance.Search, StyleCache.Instance.Label); //EditorStyles.largeLabel);

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(true));
            GUILayout.FlexibleSpace();

            _newSearchText = GUILayout.TextField(_searchText, GUILayout.Width(200) /*, GUILayout.Height(30), */);
            if (_newSearchText != _searchText)
            {
                _searchText = _newSearchText;
                _changed    = true;
            }

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();

            if (!string.IsNullOrEmpty(_searchText))
            {
                EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(true));
                GUILayout.FlexibleSpace();

                if (GUILayout.Button(TextureCache.Instance.Cancel, StyleCache.Instance.SmallOpenButton, GUILayout.ExpandWidth(false)))
                {
                    _searchText = string.Empty;
                    _changed    = true;
                }

                GUILayout.FlexibleSpace();
                EditorGUILayout.EndVertical();
            }

            GUILayout.FlexibleSpace();

            EditorGUILayout.EndHorizontal();

            //if (EditorSettings.ShowControls)
            //{
            EditorGUILayout.BeginVertical(StyleCache.Instance.ScrollviewBackground, GUILayout.ExpandWidth(true));
            // panel content

            if (AddEventHandlerDialog.Instance.ShowHelp)
            {
                EditorGUILayout.HelpBox(Help.EventHandlerList, MessageType.Info, true);
            }

            GUILayout.Space(1);

            _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition, GUILayout.ExpandHeight(true));

            if (_contents.Length == 0)
            {
                GUILayout.Label(GuiContentCache.Instance.NoEventHandlersFound, StyleCache.Instance.CenteredLabel, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
            }
            else
            {
                _newIndex = GUILayout.SelectionGrid(_selectedIndex, _contents, 1,
                                                    StyleCache.Instance.GridButton,
                                                    GUILayout.ExpandWidth(true));

                if (_selectedIndex != _newIndex)
                {
                    _selectedIndex = _newIndex;
                    var descriptor = _descriptors[_selectedIndex];
                    AddEventHandlerDialog.Instance.Data.ClassName  = descriptor.ScriptName;
                    AddEventHandlerDialog.Instance.Data.MethodName = descriptor.Name;
                    //Debug.Log("AddEventHandlerDialog.Instance.Data.MethodName set to: " + AddEventHandlerDialog.Instance.Data.MethodName);

                    GotoSignal.Emit(1);
                    //AddEventHandlerDialog.Instance.Repaint();
                }
            }

            EditorGUILayout.EndScrollView();

            GUILayout.Space(2);

            EditorGUILayout.EndVertical();  // panel chrome

            GUILayout.Space(1);

            if (_changed)
            {
                _changed = false;
                Process();
            }
        }
Exemple #28
0
        // ReSharper restore MemberCanBePrivate.Global

        #endregion

        protected override void CreateChildren()
        {
            base.CreateChildren();

            #region Background

            _background = new RectShape
            {
                Id    = "background",
                Color = Color.white,
                Left  = 0, Right = 0, Top = 0, Bottom = 0
            };
            AddChild(_background);

            _backgroundImage = new Image
            {
                //Id = "background_image",
                Left    = 0,
                Right   = 0,
                Top     = 0,
                Bottom  = 0,
                Visible = false,
                //Rotation = 30,
                //AspectRatio = 4,
                ScaleMode = ImageScaleMode.ScaleToFill
            };
            AddChild(_backgroundImage);

            #endregion

            #region Header background

            _headerBackground = new RectShape
            {
                Id = "headerBackground",
                //Color = RgbColor.FromHex(0x000fff).ToColor(),
                BackgroundColor = (Color)GetStyle("headerBackgroundColor"),
                Left            = 0,
                Right           = 0,
                Top             = 0,
                Height          = 80
            };
            AddChild(_headerBackground);

            #endregion

            #region Header group

            HeaderGroup = new Group
            {
                Id     = "headerGroup",
                Layout = new AbsoluteLayout(),
                Left   = 0,
                Right  = 0,
                Top    = 0,
                Height = 80
            };
            AddChild(HeaderGroup);

            #endregion

            #region Title label

            TitleDisplay = new Label
            {
                Id             = "titleLabel",
                Left           = 10,
                VerticalCenter = 0
            };
            //TitleLabel.SetStyle("textColor", UnityEngine.Color.white);
            HeaderGroup.AddChild(TitleDisplay);

            #endregion

            #region Tools

            ToolGroup = new Group
            {
                Id     = "toolGroup",
                Layout = new HorizontalLayout {
                    HorizontalAlign = HorizontalAlign.Right,
                    VerticalAlign   = VerticalAlign.Middle,
                    Gap             = 4
                },
                Right          = 6,
                VerticalCenter = 0,
                MouseEnabled   = true               // not draggable when clicking space between buttons --- false // to be draggable on possible tools label click
            };
            HeaderGroup.AddChild(ToolGroup);

            #endregion

            #region Scroller

            _scroller = new Scroller
            {
                SkinClass = EvaluateSkinClassFromStyle("scrollerSkin"),
                Left      = 0,
                Right     = 0,
                Top       = 80,
                Bottom    = 50
            };
            AddChild(_scroller);

            #endregion

            #region Content group

            ContentGroup = new Group {
                Id = "contentGroup"
            };
            //AddChild(ContentGroup);
            _scroller.Viewport = ContentGroup;

            #endregion

            #region Control bar background

            _controlBarBackground = new RectShape
            {
                Id = "controlBarBackground",
                BackgroundColor = ColorMixer.FromHex(0x000fff).ToColor(),
                Left            = 0,
                Right           = 0,
                Bottom          = 0,
                Height          = 50,
                //Alpha = 0.5f
            };
            AddChild(_controlBarBackground);

            #endregion

            #region Control bar

            ControlBarGroup = new Group
            {
                Id     = "controlBar",
                Layout = new HorizontalLayout
                {
                    HorizontalAlign = HorizontalAlign.Right,
                    VerticalAlign   = VerticalAlign.Middle,
                    Gap             = 4,
                    PaddingLeft     = 10, PaddingRight = 10, PaddingTop = 10, PaddingBottom = 10
                },
                Left         = 0,
                Right        = 0,
                Bottom       = 0,
                Height       = 50,
                MouseEnabled = true                       // not draggable when clicking space between buttons --- false // to be draggable on possible tools label click
            };
            AddChild(ControlBarGroup);

            #endregion

            #region Border

            _border = new RectShape
            {
                Id           = "border",
                Left         = 0,
                Right        = 0,
                Top          = 0,
                Bottom       = 0,
                MouseEnabled = false
            };
            AddChild(_border);

            #endregion
        }