示例#1
0
        private void InitButtonStyles(StyleRuleSet ruleSet)
        {
            StyleRuleSetBuilder builder = new StyleRuleSetBuilder(ruleSet);

            builder
            .Border(1.0, GUIState.Normal)
            .Border(1.0, GUIState.Hover)
            .Border(1.0, GUIState.Active)
            .Padding(5.0, GUIState.Normal)
            .Padding(5.0, GUIState.Hover)
            .Padding(5.0, GUIState.Active)
            .BorderColor(Color.Rgb(166, 166, 166), GUIState.Normal)
            .BorderColor(Color.Rgb(123, 123, 123), GUIState.Hover)
            .BorderColor(Color.Rgb(148, 148, 148), GUIState.Active)
            .BackgroundColor(Color.Rgb(0x65a9d7), GUIState.Normal)
            .BackgroundColor(Color.Rgb(0x28597a), GUIState.Hover)
            .BackgroundColor(Color.Rgb(0x1b435e), GUIState.Active)
            .BackgroundGradient(Gradient.TopBottom)
            .AlignmentVertical(Alignment.Center, GUIState.Normal)
            .AlignmentVertical(Alignment.Center, GUIState.Hover)
            .AlignmentVertical(Alignment.Center, GUIState.Active)
            .AlignmentHorizontal(Alignment.Center, GUIState.Normal)
            .AlignmentHorizontal(Alignment.Center, GUIState.Hover)
            .AlignmentHorizontal(Alignment.Center, GUIState.Active)
            .GradientTopDownColor(Color.Rgb(247, 247, 247), Color.Rgb(221, 221, 221), GUIState.Normal)
            .GradientTopDownColor(Color.Rgb(247, 247, 247), Color.Rgb(221, 221, 221), GUIState.Hover)
            .GradientTopDownColor(Color.Rgb(222, 222, 222), Color.Rgb(248, 248, 248), GUIState.Active);
        }
示例#2
0
        private void InitComboBoxStyles(StyleRuleSet ruleSet)
        {
            StyleRuleSetBuilder builder = new StyleRuleSetBuilder(ruleSet);

            builder
            .Border(1.0, GUIState.Normal)
            .Border(1.0, GUIState.Hover)
            .Border(1.0, GUIState.Active)
            .Padding(5.0, GUIState.Normal)
            .Padding(5.0, GUIState.Hover)
            .Padding(5.0, GUIState.Active)
            .BorderColor(new Color(0.26f, 0.59f, 0.98f, 0.40f), GUIState.Normal)
            .BorderColor(new Color(0.26f, 0.59f, 0.98f, 1.00f), GUIState.Hover)
            .BorderColor(new Color(0.06f, 0.53f, 0.98f, 1.00f), GUIState.Active)
            .BackgroundColor(Color.Rgb(0x65a9d7), GUIState.Normal)
            .BackgroundColor(Color.Rgb(0x28597a), GUIState.Hover)
            .BackgroundColor(Color.Rgb(0x1b435e), GUIState.Active)
            .BackgroundGradient(Gradient.TopBottom)
            .FontColor(Color.Black)
            .AlignmentVertical(Alignment.Center, GUIState.Normal)
            .AlignmentVertical(Alignment.Center, GUIState.Hover)
            .AlignmentVertical(Alignment.Center, GUIState.Active)
            .AlignmentHorizontal(Alignment.Center, GUIState.Normal)
            .AlignmentHorizontal(Alignment.Center, GUIState.Hover)
            .AlignmentHorizontal(Alignment.Center, GUIState.Active)
            .GradientTopDownColor(Color.Rgb(247, 247, 247), Color.Rgb(221, 221, 221), GUIState.Normal)
            .GradientTopDownColor(Color.Rgb(247, 247, 247), Color.Rgb(221, 221, 221), GUIState.Hover)
            .GradientTopDownColor(Color.Rgb(222, 222, 222), Color.Rgb(248, 248, 248), GUIState.Active);
        }
示例#3
0
文件: Slider.cs 项目: zwcloud/ImGui
        private void InitSliderStyles(StyleRuleSet ruleSet)
        {
            StyleRuleSetBuilder builder = new StyleRuleSetBuilder(ruleSet);

            builder.BackgroundColor(new Color(0.67f, 0.40f, 0.40f, 0.60f), GUIState.Normal)
            .BackgroundColor(new Color(0.67f, 0.40f, 0.40f, 1.00f), GUIState.Hover)
            .BackgroundColor(new Color(0.80f, 0.50f, 0.50f, 1.00f), GUIState.Active);
        }
示例#4
0
        private void InitImageStyles(StyleRuleSet ruleSet)
        {
            var builder = new StyleRuleSetBuilder(ruleSet);

            builder
            .Border(1.0)
            .BorderColor(Color.Black);
        }
示例#5
0
        private void InitSelectableStyles(StyleRuleSet ruleSet)
        {
            var builder = new StyleRuleSetBuilder(ruleSet);

            builder.Padding(2.0)
            .BackgroundColor(Color.Clear, GUIState.Normal)
            .BackgroundColor(new Color(0.26f, 0.59f, 0.98f, 0.80f), GUIState.Hover)
            .BackgroundColor(new Color(0.26f, 0.59f, 0.98f, 1.00f), GUIState.Active);
        }
示例#6
0
        private void InitListBoxStyles(StyleRuleSet ruleSet)
        {
            StyleRuleSetBuilder builder = new StyleRuleSetBuilder(ruleSet);

            builder
            .Padding(2.0)
            .BackgroundColor(Color.Clear, GUIState.Normal)
            .BackgroundColor(Color.Rgb(206, 220, 236), GUIState.Hover)
            .BackgroundColor(Color.Rgb(30, 144, 255), GUIState.Active);
        }
示例#7
0
        private void InitBoxStyles(StyleRuleSet ruleSet)
        {
            StyleRuleSetBuilder builder = new StyleRuleSetBuilder(ruleSet);

            builder
            .Border(1.0)
            .Padding(5.0)
            .BorderColor(Color.Black)
            .BackgroundColor(Color.White)
            .AlignmentVertical(Alignment.Center)
            .AlignmentHorizontal(Alignment.Center);
        }
示例#8
0
        private void InitTextBoxStyles(StyleRuleSet ruleSet)
        {
            StyleRuleSetBuilder builder = new StyleRuleSetBuilder(ruleSet);

            builder
            .Border(1.0)
            .Padding(3.0)
            .BorderColor(Color.Rgb(112), GUIState.Normal)
            .BorderColor(Color.Rgb(23), GUIState.Hover)
            .BorderColor(Color.Rgb(0, 120, 215), GUIState.Active);
            ruleSet.OverflowY = OverflowPolicy.Scroll;
        }
示例#9
0
        private void InitSeparatorStyle(StyleRuleSet ruleSet)
        {
            var builder = new StyleRuleSetBuilder(ruleSet);

            builder.Padding(2.0)
            .StrokeWidth(1, GUIState.Normal)
            .StrokeWidth(1, GUIState.Hover)
            .StrokeWidth(1, GUIState.Active)
            .StrokeColor(new Color(0.50f, 0.50f, 0.50f, 0.60f), GUIState.Normal)
            .StrokeColor(new Color(0.60f, 0.60f, 0.70f, 1.00f), GUIState.Hover)
            .StrokeColor(new Color(0.70f, 0.70f, 0.90f, 1.00f), GUIState.Active);
        }
示例#10
0
文件: Label.cs 项目: zwcloud/ImGui
        private void InitLabelStyles(StyleRuleSet ruleSet)
        {
            StyleRuleSetBuilder builder = new StyleRuleSetBuilder(ruleSet);

            builder
            .Padding(1.0)
            .AlignmentVertical(Alignment.Center, GUIState.Normal)
            .AlignmentVertical(Alignment.Center, GUIState.Hover)
            .AlignmentVertical(Alignment.Center, GUIState.Active)
            .AlignmentHorizontal(Alignment.Start, GUIState.Normal)
            .AlignmentHorizontal(Alignment.Start, GUIState.Hover)
            .AlignmentHorizontal(Alignment.Start, GUIState.Active);
        }
示例#11
0
        public Window(string name, Point position, Size size, WindowFlags Flags)
        {
            Form          form = Form.current;
            GUIContext    g    = form.uiContext;
            WindowManager w    = g.WindowManager;

            this.ID       = name.GetHashCode();
            this.Name     = name;
            this.Active   = this.WasActive = false;
            this.Position = position;
            this.FullSize = size;

            this.Flags = Flags;

            this.AbsoluteVisualList = new List <Visual>();
            this.RenderTree         = new RenderTree(this.ID, position, size);

            this.IDStack.Push(this.ID);
            this.MoveID = this.GetID("#MOVE");

            #region Window nodes

            {
                var windowContainer = new Node(this.GetID("window"), "window");
                this.WindowContainer = windowContainer;

                var style = windowContainer.RuleSet;
                style.BackgroundColor = Color.White;
                style.Border          = (1, 1, 1, 1);
                style.BorderColor     = (Color.Black, Color.Black, Color.Black, Color.Black);
                style.Set(GUIStyleName.BorderTopColor, Color.Blue, GUIState.Active);
                style.Set(GUIStyleName.BorderRightColor, Color.Blue, GUIState.Active);
                style.Set(GUIStyleName.BorderBottomColor, Color.Blue, GUIState.Active);
                style.Set(GUIStyleName.BorderLeftColor, Color.Blue, GUIState.Active);
                style.Set(GUIStyleName.BorderTopColor, Color.Gray, GUIState.Hover);
                style.Set(GUIStyleName.BorderRightColor, Color.Gray, GUIState.Hover);
                style.Set(GUIStyleName.BorderBottomColor, Color.Gray, GUIState.Hover);
                style.Set(GUIStyleName.BorderLeftColor, Color.Gray, GUIState.Hover);
                style.Set(GUIStyleName.BorderTop, 1.0);
                style.Set(GUIStyleName.BorderRight, 1.0);
                style.Set(GUIStyleName.BorderBottom, 1.0);
                style.Set(GUIStyleName.BorderLeft, 1.0);
                style.Set(GUIStyleName.PaddingTop, 5.0);
                style.Set(GUIStyleName.PaddingRight, 10.0);
                style.Set(GUIStyleName.PaddingBottom, 5.0);
                style.Set(GUIStyleName.PaddingLeft, 10.0);
                style.Set(GUIStyleName.WindowBorderColor, Color.Rgb(255, 0, 0), GUIState.Normal);
                style.Set(GUIStyleName.WindowBorderColor, Color.Rgb(0, 0, 255), GUIState.Active);
                style.Set(GUIStyleName.WindowShadowColor, Color.Argb(100, 227, 227, 227));
                style.Set(GUIStyleName.WindowShadowWidth, 15.0);
                style.Set(GUIStyleName.BackgroundColor, Color.White);
                style.Set(GUIStyleName.ResizeGripColor, Color.Argb(75, 102, 102, 102));
                style.Set(GUIStyleName.ResizeGripColor, Color.Argb(150, 102, 102, 102), GUIState.Hover);
                style.Set(GUIStyleName.ResizeGripColor, Color.Argb(225, 102, 102, 102), GUIState.Active);
                style.Set(GUIStyleName.WindowRounding, 20.0);
                style.Set(GUIStyleName.ScrollBarWidth, CurrentOS.IsDesktopPlatform ? 10.0 : 20.0);
                style.Set(GUIStyleName.ScrollBarBackgroundColor, Color.Rgb(240));
                style.Set(GUIStyleName.ScrollBarButtonColor, Color.Rgb(205), GUIState.Normal);
                style.Set(GUIStyleName.ScrollBarButtonColor, Color.Rgb(166), GUIState.Hover);
                style.Set(GUIStyleName.ScrollBarButtonColor, Color.Rgb(96), GUIState.Active);

                windowContainer.AttachLayoutGroup(true);
                windowContainer.UseBoxModel = true;
                var windowStyleOptions = GUILayout.Width(this.FullSize.Width).Height(
                    this.Collapsed ? this.CollapsedHeight : this.FullSize.Height
                    );
                windowContainer.RuleSet.ApplyOptions(windowStyleOptions);

                this.RenderTree.Root.AppendChild(windowContainer);
            }

            //title bar
            {
                var titleBarContainer = new Node(this.GetID("titleBar"), "title bar");
                this.titleBarNode = titleBarContainer;
                titleBarContainer.AttachLayoutGroup(false);
                titleBarContainer.RuleSet.ApplyOptions(GUILayout.ExpandWidth(true).Height(this.TitleBarHeight));
                titleBarContainer.UseBoxModel = true;
                StyleRuleSetBuilder b = new StyleRuleSetBuilder(titleBarContainer);
                b.Padding((top: 8, right: 8, bottom: 8, left: 8))
                .FontColor(Color.Black)
                .FontSize(12)
                .BackgroundColor(Color.White)
                .AlignmentVertical(Alignment.Center)
                .AlignmentHorizontal(Alignment.Start);

                var icon = new Node(this.GetID("icon"), "icon");
                icon.AttachLayoutEntry(new Size(20, 20));
                icon.RuleSet.ApplyOptions(GUILayout.Width(20).Height(20));
                icon.UseBoxModel = false;
                icon.Primitive   = new ImagePrimitive(@"assets/images/logo.png");

                var title       = new Node(this.GetID("title"), "title");
                var contentSize = title.RuleSet.CalcSize(this.Name, GUIState.Normal);
                title.AttachLayoutEntry(contentSize);
                title.RuleSet.ApplyOptions(GUILayout.Height(20));
                title.UseBoxModel      = false;
                title.Primitive        = new TextPrimitive(this.Name);
                this.titleBarTitleNode = title;

                var closeButton = new Node(this.GetID("close button"), "close button");
                closeButton.AttachLayoutEntry(new Size(20, 20));
                closeButton.RuleSet.ApplyOptions(GUILayout.Width(20).Height(20));
                closeButton.UseBoxModel = false;
                PathPrimitive path = new PathPrimitive();
                path.PathRect(new Rect(0, 0, 20, 20));
                closeButton.Primitive = path;

                titleBarContainer.AppendChild(icon);
                titleBarContainer.AppendChild(title);
                //titleBarContainer.AppendChild(closeButton);
                this.WindowContainer.AppendChild(titleBarContainer);
            }

            //client area
            {
                var node = new Node(this.GetID("client area"), "client area");
                node.AttachLayoutGroup(true);
                node.RuleSet.ApplyOptions(GUILayout.ExpandWidth(true).ExpandHeight(true));
                node.UseBoxModel          = true;
                node.RuleSet.OutlineWidth = 1;
                node.RuleSet.OutlineColor = Color.Red;
                node.RuleSet.refNode      = node;
                this.ClientAreaNode       = node;
                this.WindowContainer.AppendChild(node);
            }

            //resize grip (lasy-initialized)

            this.ShowWindowTitleBar(true);
            this.ShowWindowClientArea(!this.Collapsed);
            #endregion
        }
示例#12
0
        public Window(Form form, string name, Point position, Size size, WindowFlags flags)
        {
            this.ID               = name.GetHashCode();
            this.Name             = name;
            this.Active           = this.WasActive = false;
            this.Position         = position;
            this.ViewportPosition = form.Pos;
            this.FullSize         = size;

            this.Flags = flags;

            this.AbsoluteVisualList = new List <Visual>();
            this.RenderTree         = new RenderTree(this.ID, position, size);
            this.RenderContext      = new RenderContext(this.geometryRenderer, this.MeshList);

            this.IDStack.Push(this.ID);
            this.MoveId = this.GetID("#MOVE");

            this.MeshList.OwnerName = this.Name;

            //bool insideMainForm = w.MainForm.ClientRect.Contains(new Rect(position, size));
            if (Flags.HaveFlag(WindowFlags.Popup))//TODO consider insideMainForm when multiple-form is ready
            {
                Viewport        = new Form(position, size, name, WindowTypes.ClientAreaOnly);
                Viewport.Window = this;
                Application.AddFrom(Viewport);
            }
            else
            {
                Viewport = Application.ImGuiContext.WindowManager.MainForm;
            }

            #region Window nodes

            {
                var windowContainer = new Node(this.GetID("WindowContainer"), "Window Container");
                this.WindowContainer = windowContainer;

                var style = windowContainer.RuleSet;
                style.BackgroundColor = Color.White;
                style.BorderRadius    = (2, 2, 2, 2);
                style.BorderColor     = (Color.Rgb(0x707070), Color.Rgb(0x707070), Color.Rgb(0x707070), Color.Rgb(0x707070));
                style.Set(StylePropertyName.BorderTopColor, Color.Blue, GUIState.Active);
                style.Set(StylePropertyName.BorderRightColor, Color.Blue, GUIState.Active);
                style.Set(StylePropertyName.BorderBottomColor, Color.Blue, GUIState.Active);
                style.Set(StylePropertyName.BorderLeftColor, Color.Blue, GUIState.Active);
                style.Set(StylePropertyName.BorderTopColor, Color.Gray, GUIState.Hover);
                style.Set(StylePropertyName.BorderRightColor, Color.Gray, GUIState.Hover);
                style.Set(StylePropertyName.BorderBottomColor, Color.Gray, GUIState.Hover);
                style.Set(StylePropertyName.BorderLeftColor, Color.Gray, GUIState.Hover);
                style.Set(StylePropertyName.BorderTop, 1.0);
                style.Set(StylePropertyName.BorderRight, 1.0);
                style.Set(StylePropertyName.BorderBottom, 1.0);
                style.Set(StylePropertyName.BorderLeft, 1.0);
                style.Set(StylePropertyName.PaddingTop, 5.0);
                style.Set(StylePropertyName.PaddingRight, 10.0);
                style.Set(StylePropertyName.PaddingBottom, 5.0);
                style.Set(StylePropertyName.PaddingLeft, 10.0);
                style.Set(StylePropertyName.WindowBorderColor, Color.Rgb(255, 0, 0), GUIState.Normal);
                style.Set(StylePropertyName.WindowBorderColor, Color.Rgb(0, 0, 255), GUIState.Active);
                style.Set(StylePropertyName.WindowShadowColor, Color.Argb(100, 227, 227, 227));
                style.Set(StylePropertyName.WindowShadowWidth, 15.0);
                style.Set(StylePropertyName.ResizeGripColor, Color.Argb(0x77303030));
                style.Set(StylePropertyName.ResizeGripColor, Color.Argb(0xAA303030), GUIState.Hover);
                style.Set(StylePropertyName.ResizeGripColor, Color.Argb(0xFF303030), GUIState.Active);
                style.Set(StylePropertyName.WindowRounding, 20.0);

                windowContainer.AttachLayoutGroup(true);
                windowContainer.UseBoxModel = true;
                var windowStyleOptions = GUILayout.Width(this.FullSize.Width).Height(
                    this.Collapsed ? this.CollapsedHeight : this.FullSize.Height
                    );
                windowContainer.RuleSet.ApplyOptions(windowStyleOptions);

                this.RenderTree.Root.AppendChild(windowContainer);
            }

            //title bar
            if (!flags.HaveFlag(WindowFlags.NoTitleBar))
            {
                this.titleBar = new Node(this.GetID("titleBar"), "title bar");
                titleBar.AttachLayoutGroup(false);
                titleBar.RuleSet.ApplyOptions(GUILayout.ExpandWidth(true).Height(this.TitleBarHeight));
                titleBar.UseBoxModel = true;
                StyleRuleSetBuilder b = new StyleRuleSetBuilder(titleBar);
                b.Padding((top: 8, right: 8, bottom: 8, left: 8))
                .FontColor(Color.Black)
                .FontSize(12)
                .BackgroundColor(Color.White)
                .AlignmentVertical(Alignment.Center)
                .AlignmentHorizontal(Alignment.Start);

                this.titleIcon = new Node(this.GetID("icon"), "icon");
                titleIcon.AttachLayoutEntry(new Size(20, 20));
                titleIcon.RuleSet.ApplyOptions(GUILayout.Width(20).Height(20));
                titleIcon.UseBoxModel = false;

                this.titleText = new Node(this.GetID("title"), "title");
                var contentSize = titleText.RuleSet.CalcContentBoxSize(this.Name, GUIState.Normal);
                titleText.AttachLayoutEntry(contentSize);
                titleText.RuleSet.ApplyOptions(GUILayout.Height(20));
                titleText.UseBoxModel = false;

                var closeButton = new Node(this.GetID("close button"), "close button");
                closeButton.AttachLayoutEntry(new Size(20, 20));
                closeButton.RuleSet.ApplyOptions(GUILayout.Width(20).Height(20));
                closeButton.UseBoxModel = false;

                titleBar.AppendChild(titleIcon);
                titleBar.AppendChild(titleText);

                this.WindowContainer.AppendChild(titleBar);
            }

            //client area
            {
                this.clientArea = new Node(this.GetID("Client Area"), "Client Area");
                clientArea.AttachLayoutGroup(true);
                clientArea.RuleSet.BackgroundColor = Color.White;
                clientArea.RuleSet.Set(StylePropertyName.OverflowY, (int)OverflowPolicy.Scroll);
                clientArea.RuleSet.Set(StylePropertyName.ScrollBarWidth, CurrentOS.IsDesktopPlatform ? 10.0 : 20.0);
                clientArea.RuleSet.Set(StylePropertyName.ScrollBarBackgroundColor, Color.Rgb(240));
                clientArea.RuleSet.Set(StylePropertyName.ScrollBarButtonColor, Color.Rgb(205), GUIState.Normal);
                clientArea.RuleSet.Set(StylePropertyName.ScrollBarButtonColor, Color.Rgb(166), GUIState.Hover);
                clientArea.RuleSet.Set(StylePropertyName.ScrollBarButtonColor, Color.Rgb(96), GUIState.Active);
                clientArea.RuleSet.ApplyOptions(GUILayout.ExpandWidth(true).ExpandHeight(true));
                clientArea.UseBoxModel     = true;
                clientArea.RuleSet.refNode = clientArea;
#if ShowClientAreaOutline
                clientArea.RuleSet.OutlineWidth = 1;
                clientArea.RuleSet.OutlineColor = Color.DarkRed;
#endif
                this.ClientAreaNode = clientArea;
                this.WindowContainer.AppendChild(clientArea);
            }

            //resize grip (lasy-initialized)

            if (!flags.HaveFlag(WindowFlags.NoTitleBar))
            {
                this.ShowWindowTitleBar(true);
            }
            this.ShowWindowClientArea(!this.Collapsed);
            #endregion
        }