예제 #1
0
        public static bool BuildButton(this ImGui gui, string text, SchemeColor color = SchemeColor.Primary, Padding?padding = null, bool active = true)
        {
            if (!active)
            {
                color = SchemeColor.Grey;
            }
            using (gui.EnterGroup(padding ?? DefaultButtonPadding, active ? color + 2 : color + 3))
                gui.BuildText(text, Font.text, align: RectAlignment.Middle);

            return(gui.BuildButton(gui.lastRect, color, color + 1) == Event.Click && active);
        }
예제 #2
0
        public void BuildHeader(ImGui gui)
        {
            var spacing      = innerPadding.left + innerPadding.right;
            var x            = 0f;
            var topSeparator = gui.AllocateRect(0f, 0.1f);
            var y            = gui.statePosition.Y;

            using (var group = gui.EnterFixedPositioning(0f, 1f, innerPadding))
            {
                foreach (var column in columns)
                {
                    if (column.width < column.minWidth)
                    {
                        column.width = column.minWidth;
                    }
                    var rect = new Rect(x, y, column.width, 0f);
                    group.SetManualRectRaw(rect, RectAllocator.LeftRow);
                    gui.BuildText(column.header);
                    rect.Bottom = gui.statePosition.Y;
                    x          += column.width + spacing;

                    if (!column.isFixedSize)
                    {
                        BuildHeaderResizer(gui, column, new Rect(x - 0.7f, y, 1f, 2.2f));
                    }

                    if (column.menuBuilder != null)
                    {
                        var menuRect = new Rect(rect.Right - 1.7f, rect.Y + 0.3f, 1.5f, 1.5f);
                        if (gui.isBuilding)
                        {
                            gui.DrawIcon(menuRect, Icon.DropDown, SchemeColor.BackgroundText);
                        }
                        if (gui.BuildButton(menuRect, SchemeColor.None, SchemeColor.Grey) == ImGuiUtils.Event.Click)
                        {
                            gui.ShowDropDown(menuRect, column.menuBuilder, new Padding(1f));
                        }
                    }
                }
            }
            width = x + 0.2f - spacing;

            var separator = gui.AllocateRect(x, 0.1f);

            if (gui.isBuilding)
            {
                topSeparator.Width = separator.Width = width;
                gui.DrawRectangle(topSeparator, SchemeColor.GreyAlt);
                gui.DrawRectangle(separator, SchemeColor.GreyAlt);
                //DrawVerticalGrid(gui, topSeparator.Bottom, separator.Top, SchemeColor.GreyAlt);
            }
        }
예제 #3
0
 public static bool BuildContextMenuButton(this ImGui gui, string text, string rightText = null)
 {
     using (gui.EnterGroup(DefaultButtonPadding, RectAllocator.LeftRow, SchemeColor.BackgroundText))
     {
         gui.BuildText(text, Font.text, wrap: true);
         if (rightText != null)
         {
             gui.allocator = RectAllocator.RightRow;
             gui.BuildText(rightText, align: RectAlignment.MiddleRight);
         }
     }
     return(gui.BuildButton(gui.lastRect, SchemeColor.None, SchemeColor.Grey) == Event.Click);
 }
예제 #4
0
 protected override void BuildContents(ImGui gui)
 {
     gui.BuildText(ex.GetType().Name, Font.header);
     gui.BuildText(ex.Message, Font.subheader, true);
     gui.BuildText(ex.StackTrace, Font.text, true);
     using (gui.EnterRow(0.5f, RectAllocator.RightRow))
     {
         if (gui.BuildButton("Close"))
         {
             Close();
         }
         if (gui.BuildButton("Ignore future errors", SchemeColor.Grey))
         {
             ignoreAll = true;
             Close();
         }
         if (gui.BuildButton("Copy to clipboard", SchemeColor.Grey))
         {
             SDL.SDL_SetClipboardText(ex.Message + "\n\n" + ex.StackTrace);
         }
     }
 }
예제 #5
0
        public static Event BuildRedButton(this ImGui gui, Icon icon, float size = 1.5f)
        {
            Rect iconRect;

            using (gui.EnterGroup(new Padding(0.3f)))
                iconRect = gui.AllocateRect(size, size, RectAlignment.Middle);
            var evt = gui.BuildButton(gui.lastRect, SchemeColor.None, SchemeColor.Error);

            if (gui.isBuilding)
            {
                gui.DrawIcon(iconRect, icon, gui.IsMouseOver(gui.lastRect) ? SchemeColor.ErrorText : SchemeColor.Error);
            }
            return(evt);
        }
예제 #6
0
        public static Event BuildRedButton(this ImGui gui, string text)
        {
            Rect      textRect;
            TextCache cache;

            using (gui.EnterGroup(DefaultButtonPadding))
                textRect = gui.AllocateTextRect(out cache, text, align: RectAlignment.Middle);
            var evt = gui.BuildButton(gui.lastRect, SchemeColor.None, SchemeColor.Error);

            if (gui.isBuilding)
            {
                gui.DrawRenderable(textRect, cache, gui.IsMouseOver(gui.lastRect) ? SchemeColor.ErrorText : SchemeColor.Error);
            }
            return(evt);
        }
예제 #7
0
        public static bool BuildErrorRow(this ImGui gui, string text)
        {
            var closed = false;

            using (gui.EnterRow(allocator: RectAllocator.RightRow, textColor: SchemeColor.ErrorText))
            {
                if (gui.BuildButton(Icon.Close, size: 1f, over: SchemeColor.ErrorAlt))
                {
                    closed = true;
                }
                gui.RemainingRow().BuildText(text, align: RectAlignment.Middle);
            }
            if (gui.isBuilding)
            {
                gui.DrawRectangle(gui.lastRect, SchemeColor.Error);
            }
            return(closed);
        }
예제 #8
0
 public static bool BuildButton(this ImGui gui, Icon icon, SchemeColor normal = SchemeColor.None, SchemeColor over = SchemeColor.Grey, SchemeColor down = SchemeColor.None, float size = 1.5f)
 {
     using (gui.EnterGroup(new Padding(0.3f)))
         gui.BuildIcon(icon, size);
     return(gui.BuildButton(gui.lastRect, normal, over, down) == Event.Click);
 }