示例#1
0
        internal static bool OnProcess(string Title, ref string Value, LGuiRect Rect, uint MaxLength, LGuiInputTextFlags Flags)
        {
            var ID = LGuiHash.CalculateID(Title);

            LGuiContext.SetPreviousControlID(ID);

            if (!LGuiMisc.CheckVisible(ref Rect))
            {
                return(false);
            }

            LGuiMisc.CheckAndSetContextID(ref Rect, ID);

            LGuiGraphics.DrawRect(Rect, LGuiStyleColorIndex.Frame, true);
            LGuiGraphics.DrawRect(Rect, LGuiStyleColorIndex.Border, false);

            if (LGuiMisc.CheckAndSetFocusID(ID))
            {
            }

            var ValueChanged = false;

            if (LGuiContext.FocusID == ID || LGuiContext.ActiveID == ID)
            {
                ValueChanged = LGuiTextFieldController.OnProcess(ID, ref Value, Rect, MaxLength, Flags, null);
            }
            else
            {
                LGuiTextFieldController.OnProcess(ID, ref Value, Rect, MaxLength, Flags | LGuiInputTextFlags.OnlyDisplay, null);
            }

            return(ValueChanged);
        }
示例#2
0
        internal static bool OnProcess(string Title, bool Value, LGuiRect Rect)
        {
            var ID = LGuiHash.CalculateID(Title);

            LGuiContext.SetPreviousControlID(ID);

            if (!LGuiMisc.CheckVisible(ref Rect))
            {
                return(Value);
            }

            var BoxSize = LGuiStyle.GetValue(LGuiStyleValueIndex.CheckBoxSize);
            var BoxRect = new LGuiRect(new LGuiVec2(Rect.X, Rect.Y + (Rect.Height - BoxSize) / 2.0f), new LGuiVec2(BoxSize, BoxSize));

            LGuiMisc.CheckAndSetContextID(ref Rect, ID);

            var BgColorIndex = LGuiContext.ActiveID == ID ? LGuiStyleColorIndex.FrameActived :
                               LGuiContext.HoveredID == ID ? LGuiStyleColorIndex.FrameHovered : LGuiStyleColorIndex.Frame;

            LGuiGraphics.DrawRect(BoxRect, BgColorIndex, true);
            LGuiGraphics.DrawRect(BoxRect, LGuiStyleColorIndex.Border, false);
            if (Value)
            {
                LGuiGraphics.DrawRect(new LGuiRect(BoxRect.X + 2, BoxRect.Y + 2, BoxRect.Width - 4, BoxRect.Height - 4), LGuiStyleColorIndex.CheckMask, true);
            }
            LGuiGraphics.DrawText(Title, new LGuiVec2(Rect.X + BoxSize + 3, Rect.Y + 1), LGuiStyleColorIndex.Text);

            if (LGuiMisc.CheckAndSetFocusID(ID))
            {
                Value = !Value;
            }

            return(Value);
        }
示例#3
0
        internal static void OnProcess(string Title, float Value, LGuiRect Rect)
        {
            var ID = LGuiHash.CalculateID(Title);

            LGuiContext.SetPreviousControlID(ID);

            if (!LGuiMisc.CheckVisible(ref Rect))
            {
                return;
            }

            LGuiMisc.CheckAndSetContextID(ref Rect, ID, true);

            Value = LGuiMisc.Clamp01(Value);
            var MaskRect = new LGuiRect(Rect.X + 1, Rect.Y + 1, (Rect.Width - 2) * Value, Rect.Height - 2);

            LGuiGraphics.DrawRect(Rect, LGuiStyleColorIndex.Frame, true, false);
            LGuiGraphics.DrawRect(MaskRect, LGuiStyleColorIndex.CheckMask, true, false);
            LGuiGraphics.DrawRect(Rect, LGuiStyleColorIndex.Border, false, false);

            var Text     = $"{(Value * 100):00}%";
            var TextSize = LGuiConvert.GetTextSize(Text, LGuiContext.Font);

            LGuiGraphics.DrawText(Text, new LGuiVec2(Rect.CenterX - TextSize.X / 2.0f, Rect.CenterY - TextSize.Y / 2.0f), LGuiStyleColorIndex.Text);
        }
示例#4
0
        internal static void OnProcess(int TextureID, LGuiRect SrcRect, LGuiVec2 DstSize)
        {
            var ID = LGuiHash.CalculateID(LGuiSettings.DefaultTextureTitle + TextureID);

            LGuiContext.SetPreviousControlID(ID);

            if (SrcRect.Width == 0 || SrcRect.Height == 0)
            {
                SrcRect.Size = LGuiConvert.GetTextureIDSize(TextureID);
            }

            if (DstSize.X == 0 || DstSize.Y == 0)
            {
                DstSize = LGuiConvert.GetTextureIDSize(TextureID);
            }

            var DstRect = LGuiLayout.DoLayout(DstSize);

            if (!LGuiMisc.CheckVisible(ref DstRect))
            {
                return;
            }

            LGuiMisc.CheckAndSetContextID(ref DstRect, ID, true);

            LGuiGraphics.DrawTexture(TextureID, SrcRect, DstRect);
        }
示例#5
0
        internal static int OnProcess(string Title, int Index, int Value, LGuiRect Rect)
        {
            var ID = LGuiHash.CalculateID(Title);

            LGuiContext.SetPreviousControlID(ID);

            if (!LGuiMisc.CheckVisible(ref Rect))
            {
                return(Value);
            }

            LGuiMisc.CheckAndSetContextID(ref Rect, ID);

            var BgColorIndex = LGuiContext.ActiveID == ID ? LGuiStyleColorIndex.FrameActived :
                               LGuiContext.HoveredID == ID ? LGuiStyleColorIndex.FrameHovered : LGuiStyleColorIndex.Frame;

            var Radius      = LGuiStyle.GetValue(LGuiStyleValueIndex.RadioButtonRadius);
            var RadioCenter = new LGuiVec2(Rect.X + Radius, Rect.Y + Rect.Height / 2.0f);

            LGuiGraphics.DrawCircle(RadioCenter, Radius, BgColorIndex, true);
            LGuiGraphics.DrawCircle(RadioCenter, Radius, LGuiStyleColorIndex.Border, false);
            if (Index == Value)
            {
                LGuiGraphics.DrawCircle(RadioCenter, Radius - 3, LGuiStyleColorIndex.CheckMask, true);
            }
            LGuiGraphics.DrawText(Title, new LGuiVec2(Rect.X + Radius * 2 + 3, Rect.Y + 1), LGuiStyleColorIndex.Text);

            if (LGuiMisc.CheckAndSetFocusID(ID))
            {
                Value = Index;
            }

            return(Value);
        }
示例#6
0
        internal static void Begin(string Title, LGuiRect Rect, bool IsChild = true)
        {
            var FullTitle = $"{LGuiContext.GetCurrentFrame().Title}/{Title}";
            var ID        = LGuiHash.CalculateID(FullTitle);

            LGuiContext.SetPreviousControlID(ID);

            var Offset  = LGuiContextCache.GetFrameOffset(FullTitle);
            var Context = new LGuiFrameContext(FullTitle, Rect);

            Context.Size = LGuiContextCache.GetFrameContextSize(FullTitle);

            if (!LGuiMisc.CheckVisible(ref Context.Rect))
            {
                Context.Visibled = false;
            }
            else
            {
                LGuiGraphics.DrawRect(Rect, LGuiStyleColorIndex.Border, false);
            }

            LGuiMisc.CheckAndSetContextID(ref Rect, ID, true);

            LGuiContext.BeginFrame(Context, IsChild);
            LGuiLayout.BeginLayout(LGuiLayout.GetCurrentLayoutMode(),
                                   new LGuiVec2(
                                       Rect.X + LGuiStyle.GetValue(LGuiStyleValueIndex.FrameChildSpacingX) - Offset.X,
                                       Rect.Y + LGuiStyle.GetValue(LGuiStyleValueIndex.FrameChildSpacingY) - Offset.Y),
                                   false);
        }
示例#7
0
        internal static bool Begin(string Title, LGuiRect Rect)
        {
            var ID = LGuiHash.CalculateID(Title);

            LGuiContext.SetPreviousControlID(ID);

            if (!LGuiMisc.CheckVisible(ref Rect))
            {
                return(false);
            }

            var IsOpen = LGuiContextCache.GetPopupOpen(Title);

            if (IsOpen)
            {
                if (LGuiContext.IO.IsMouseClick(LGuiMouseButtons.Left) && !LGuiMisc.Contains(ref Rect, ref LGuiContext.IO.MousePos))
                {
                    LGuiContextCache.SetPopupOpen(Title, false);
                    return(false);
                }

                LGuiGraphics.SetCurrentLevel(LGuiCommandLevel.Popup);
                LGuiGraphics.DrawRect(Rect, LGuiStyleColorIndex.Frame, true);
                LGuiFrame.Begin(Title, Rect, false);
            }

            return(IsOpen);
        }
示例#8
0
        internal static bool OnProcess(string Text, bool Selected, LGuiRect Rect)
        {
            var ID = LGuiHash.CalculateID(Text);

            LGuiContext.SetPreviousControlID(ID);

            if (!LGuiMisc.CheckVisible(ref Rect))
            {
                return(false);
            }

            LGuiMisc.CheckAndSetContextID(ref Rect, ID);

            var BgColorIndex = LGuiContext.ActiveID == ID ? LGuiStyleColorIndex.HeaderActive :
                               LGuiContext.HoveredID == ID ? LGuiStyleColorIndex.HeaderHovered :
                               Selected ? LGuiStyleColorIndex.Header : LGuiStyleColorIndex.Frame;

            LGuiGraphics.DrawRect(Rect, BgColorIndex, true, false);

            LGuiGraphics.DrawText(Text, new LGuiVec2(Rect.X, Rect.Y), LGuiStyleColorIndex.Text);

            if (LGuiMisc.CheckAndSetFocusID(ID))
            {
                return(true);
            }

            return(false);
        }
示例#9
0
        internal static bool Begin(string Title)
        {
            var FullTitle = $"{LGuiContext.GetCurrentFrame().Title}/{Title}";
            var ID        = LGuiHash.CalculateID(FullTitle);

            LGuiContext.SetPreviousControlID(ID);

            var Rect = LGuiLayout.DoLayout(new LGuiVec2(LGuiStyle.GetValue(LGuiStyleValueIndex.LargeControlLength), LGuiStyle.GetValue(LGuiStyleValueIndex.HeaderSize)));

            if (!LGuiMisc.CheckVisible(ref Rect))
            {
                return(false);
            }

            LGuiMisc.CheckAndSetContextID(ref Rect, ID);

            var BgColorIndex = LGuiContext.ActiveID == ID ? LGuiStyleColorIndex.GroupActived :
                               LGuiContext.HoveredID == ID ? LGuiStyleColorIndex.GroupHovered : LGuiStyleColorIndex.Group;

            LGuiGraphics.DrawRect(Rect, BgColorIndex, true);
            LGuiGraphics.DrawRect(Rect, LGuiStyleColorIndex.Border, false);
            LGuiGraphics.DrawText(Title, new LGuiVec2(Rect.X + LGuiStyle.GetValue(LGuiStyleValueIndex.GroupChildSpacing), Rect.Y), LGuiStyleColorIndex.Text);

            var Expand = LGuiContextCache.GetGroupExpand(FullTitle);

            if (Expand)
            {
                LGuiGraphics.DrawTriangle(
                    new LGuiVec2(Rect.X + 5, Rect.Y + 3),
                    new LGuiVec2(Rect.X + 15, Rect.Y + 3),
                    new LGuiVec2(Rect.X + 10, Rect.Bottom - 3),
                    LGuiStyle.GetColor(LGuiStyleColorIndex.Text),
                    true);
            }
            else
            {
                LGuiGraphics.DrawTriangle(
                    new LGuiVec2(Rect.X + 5, Rect.Y + 3),
                    new LGuiVec2(Rect.X + 15, Rect.CenterY),
                    new LGuiVec2(Rect.X + 5, Rect.Bottom - 3),
                    LGuiStyle.GetColor(LGuiStyleColorIndex.Text),
                    true);
            }

            if (LGuiMisc.CheckAndSetFocusID(ID))
            {
                Expand = !Expand;
                LGuiContextCache.SetGroupExpand(FullTitle, Expand);
            }

            if (Expand)
            {
                LGuiContext.BeginGroup(FullTitle, Rect.X + LGuiStyle.GetValue(LGuiStyleValueIndex.GroupChildSpacing));
            }
            return(Expand);
        }
示例#10
0
        internal static void OnProcess(LGuiColor Color, string Text, LGuiRect Rect)
        {
            var ID = LGuiHash.CalculateID(Text);

            LGuiContext.SetPreviousControlID(ID);

            if (!LGuiMisc.CheckVisible(ref Rect))
            {
                return;
            }

            LGuiMisc.CheckAndSetContextID(ref Rect, ID);
            LGuiGraphics.DrawText(Text, Rect.Pos, Color, LGuiContext.Font);
        }
示例#11
0
        internal static bool OnProcess(string Title, LGuiRect Rect, LGuiButtonFlags Flags)
        {
            var ID = LGuiHash.CalculateID(Title);

            LGuiContext.SetPreviousControlID(ID);

            if (!LGuiMisc.CheckVisible(ref Rect))
            {
                return(false);
            }

            LGuiMisc.CheckAndSetContextID(ref Rect, ID);

            if ((Flags & LGuiButtonFlags.Invisible) == LGuiButtonFlags.Invisible)
            {
            }
            else
            {
                var BgColorIndex = LGuiContext.ActiveID == ID ? LGuiStyleColorIndex.ButtonActived :
                                   LGuiContext.HoveredID == ID ? LGuiStyleColorIndex.ButtonHovered : LGuiStyleColorIndex.Button;

                LGuiGraphics.DrawRect(Rect, BgColorIndex, true);
                LGuiGraphics.DrawRect(Rect, LGuiStyleColorIndex.Border, false);
                LGuiGraphics.DrawText(Title, new LGuiVec2(Rect.X + 3, Rect.Y + 2), LGuiStyleColorIndex.Text);
            }

            if ((Flags & LGuiButtonFlags.Repeat) == LGuiButtonFlags.Repeat)
            {
                if (LGuiContext.ActiveID == ID)
                {
                    return(true);
                }
            }
            else if (LGuiMisc.CheckAndSetFocusID(ID))
            {
                return(true);
            }

            return(false);
        }
示例#12
0
        internal static bool OnProcess(string Title, LGuiColor Color, LGuiRect Rect)
        {
            var ID = LGuiHash.CalculateID(Title);

            LGuiContext.SetPreviousControlID(ID);

            if (!LGuiMisc.CheckVisible(ref Rect))
            {
                return(false);
            }

            LGuiMisc.CheckAndSetContextID(ref Rect, ID);

            LGuiGraphics.DrawRect(Rect, Color, true);
            LGuiGraphics.DrawRect(Rect, LGuiStyleColorIndex.Border, false);

            if (LGuiMisc.CheckAndSetFocusID(ID))
            {
                return(true);
            }

            return(false);
        }
示例#13
0
        internal static bool OnProcess(string Title, ref int ItemIndex, string[] Items, LGuiRect Rect)
        {
            var ID = LGuiHash.CalculateID(Title);

            LGuiContext.SetPreviousControlID(ID);

            if (!LGuiMisc.CheckVisible(ref Rect))
            {
                return(false);
            }

            LGuiMisc.CheckAndSetContextID(ref Rect, ID, true);

            LGuiFrame.Begin(Title, Rect);

            var NewIndex  = ItemIndex;
            var ItemWidth = Rect.Width - LGuiStyle.GetValue(LGuiStyleValueIndex.FrameChildSpacingX) * 2.0f - LGuiStyle.GetValue(LGuiStyleValueIndex.SliderSize);

            for (var Index = 0; Index < Items.Length; ++Index)
            {
                if (LGuiSelectable.OnProcess(Items[Index], ItemIndex == Index, ItemWidth))
                {
                    NewIndex = Index;
                }
            }

            LGuiFrame.End();

            if (ItemIndex != NewIndex)
            {
                ItemIndex = NewIndex;
                return(true);
            }

            return(false);
        }
示例#14
0
        internal static bool OnProcess(string Title, ref int Value, int Min, int Max, int Step, bool IsHorizontal, string Format, LGuiRect Rect)
        {
            var ID = LGuiHash.CalculateID(Title);

            LGuiContext.SetPreviousControlID(ID);

            if (!LGuiMisc.CheckVisible(ref Rect))
            {
                return(false);
            }

            var NewValue = LGuiMisc.Clamp(Min, Max, Value);

            Step = LGuiMisc.Min(Max - Min, Step);

            var GrabRect = CalculateGrabRect(ref Rect,
                                             new LGuiVec2((float)Step / (float)(Max - Min) * Rect.Width, (float)Step / (float)(Max - Min) * Rect.Height),
                                             LGuiStyle.GetGrabMinSize(),
                                             (float)(NewValue - Min) / (float)(Max - Min),
                                             IsHorizontal);

            LGuiMisc.CheckAndSetContextID(ref GrabRect, ID, true);

            var GrabColorIndex = LGuiContext.ActiveID == ID ? LGuiStyleColorIndex.SliderGrabActived :
                                 LGuiContext.HoveredID == ID ? LGuiStyleColorIndex.SliderGrabHovered : LGuiStyleColorIndex.SliderGrab;

            LGuiGraphics.DrawRect(Rect, LGuiStyleColorIndex.Frame, true);
            LGuiGraphics.DrawRect(Rect, LGuiStyleColorIndex.Border, false);
            LGuiGraphics.DrawRect(GrabRect, GrabColorIndex, true);
            if (!string.IsNullOrWhiteSpace(Format))
            {
                var Text     = string.Format(Format, NewValue);
                var TextSize = LGuiConvert.GetTextSize(Text, LGuiContext.Font);
                LGuiGraphics.DrawText(Text, new LGuiVec2(Rect.X + (Rect.Width - TextSize.X) / 2.0f, Rect.Y + (Rect.Height - TextSize.Y) / 2.0f), LGuiStyleColorIndex.Text);
            }

            LGuiMisc.CheckAndSetContextID(ref Rect, ID);

            if (LGuiContext.ActiveID == ID)
            {
                NewValue = CalculateCurrentValue(ref Rect, ref GrabRect, Min, Max, Step, IsHorizontal);
            }
            else if (!IsHorizontal)
            {
                NewValue = LGuiMisc.DoMouseWheelEvent(ID, Min, Max, NewValue);
            }

            if (LGuiMisc.CheckAndSetFocusID(ID))
            {
            }

            var ValueChanged = false;

            if (NewValue != Value)
            {
                ValueChanged = true;
                Value        = NewValue;
            }

            return(ValueChanged);
        }
示例#15
0
        internal static bool OnProcess(string Title, LGuiRect Rect, ref LGuiColor Color)
        {
            LGuiFrame.Begin(Title, Rect);

            var ID = LGuiHash.CalculateID(Title);

            LGuiContext.SetPreviousControlID(ID);

            if (!LGuiMisc.CheckVisible(ref Rect))
            {
                return(false);
            }

            var Hsv          = LGuiContextCache.GetColorPickerHsv(Title);
            var FrameSpacing = LGuiStyle.GetFrameChildSpacing();
            var SpacingY     = LGuiStyle.GetValue(LGuiStyleValueIndex.ControlSpacingY);
            var SliderSize   = LGuiStyle.GetValue(LGuiStyleValueIndex.SliderSize);

            var ColorRect = new LGuiRect(Rect.Pos + FrameSpacing, new LGuiVec2(Rect.Width - FrameSpacing.X * 2.0f, Rect.Height - (SliderSize + SpacingY) * 4.0f - SpacingY * 3.0f - 20));

            RenderColorRect(ColorRect, Hsv.R);
            RenderColorCross(ColorRect, Hsv.G, Hsv.B);

            var IDColor = LGuiHash.CalculateID($"{Title}_ColorSelector");

            LGuiMisc.CheckAndSetContextID(ref ColorRect, IDColor);

            var HsvValueChanged = false;

            if (LGuiContext.ActiveID == IDColor)
            {
                var X = LGuiMisc.Lerp(0.0f, 1.0f, (LGuiContext.IO.MousePos.X - ColorRect.X) / ColorRect.Width);
                var Y = LGuiMisc.Lerp(0.0f, 1.0f, (ColorRect.Height - (LGuiContext.IO.MousePos.Y - ColorRect.Y)) / ColorRect.Height);

                if (X != Hsv.G || Y != Hsv.B)
                {
                    HsvValueChanged = true;
                    Hsv.G           = X;
                    Hsv.B           = Y;
                }
            }

            var HueRect = new LGuiRect(Rect.X + FrameSpacing.X, ColorRect.Bottom + FrameSpacing.Y, ColorRect.Width, 20);

            RenderHueRect(HueRect);
            RenderHueArrow(HueRect, Hsv.R);

            var IDHue = LGuiHash.CalculateID($"{Title}_HueSelector");

            LGuiMisc.CheckAndSetContextID(ref HueRect, IDHue);

            if (LGuiContext.ActiveID == IDHue)
            {
                var Hue = LGuiMisc.Lerp(0.0f, 1.0f, (LGuiContext.IO.MousePos.X - HueRect.X) / HueRect.Width);

                if (Hue != Hsv.R)
                {
                    HsvValueChanged = true;
                    Hsv.R           = Hue;
                }
            }

            HsvValueChanged |= HandleHsvSlider(Title, ref Hsv, new LGuiVec2(HueRect.X, HueRect.Bottom + SpacingY), HueRect.Width / 2.0f);

            if (HsvValueChanged)
            {
                Color = LGuiColor.Hsv2Rgb(Hsv);
                LGuiContextCache.SetColorPickerHsv(Title, Hsv);
            }

            var RgbValueChanged = false;

            if (HandleRgbSlider(Title, ref Color, new LGuiVec2(HueRect.X + HueRect.Width / 2.0f + 2.5f, HueRect.Bottom + SpacingY), HueRect.Width / 2.0f))
            {
                RgbValueChanged = true;
                LGuiContextCache.SetColorPickerHsv(Title, LGuiColor.Rgb2Hsv(Color));
            }

            var CurrentTitleWidth = LGuiContext.Font.FontWidth * 8.5f;

            LGuiGraphics.DrawText("Current:", new LGuiVec2(HueRect.X, HueRect.Bottom + SpacingY + (SliderSize + SpacingY) * 3.0f), LGuiStyleColorIndex.Text);
            LGuiGraphics.DrawRect(new LGuiRect(HueRect.X + CurrentTitleWidth, HueRect.Bottom + SpacingY + (SliderSize + SpacingY) * 3.0f, HueRect.Width / 2.0f - CurrentTitleWidth, SliderSize), Color, true, false);

            LGuiFrame.End();

            return(HsvValueChanged | RgbValueChanged);
        }
示例#16
0
        internal static bool OnProcess(string Title, ref int ItemIndex, string[] Items, LGuiRect Rect, float PopupHeight)
        {
            var ID = LGuiHash.CalculateID(Title);

            LGuiContext.SetPreviousControlID(ID);

            if (!LGuiMisc.CheckVisible(ref Rect))
            {
                return(false);
            }

            var TitleBgColorIndex = LGuiContext.ActiveID == ID ? LGuiStyleColorIndex.FrameActived :
                                    LGuiContext.HoveredID == ID ? LGuiStyleColorIndex.FrameHovered : LGuiStyleColorIndex.Frame;

            LGuiMisc.CheckAndSetContextID(ref Rect, ID);

            LGuiGraphics.DrawRect(Rect, TitleBgColorIndex, true);
            LGuiGraphics.DrawText(Items[ItemIndex], Rect.Pos + new LGuiVec2(LGuiStyle.GetValue(LGuiStyleValueIndex.ControlSpacingX), 0), LGuiStyleColorIndex.Text);

            var GrabRect         = new LGuiRect(Rect.Right - LGuiContext.Font.FontHeight, Rect.Y, LGuiContext.Font.FontHeight, LGuiContext.Font.FontHeight);
            var GrabBgColorIndex = LGuiContext.ActiveID == ID ? LGuiStyleColorIndex.ButtonActived :
                                   LGuiContext.HoveredID == ID ? LGuiStyleColorIndex.ButtonHovered : LGuiStyleColorIndex.Button;

            LGuiGraphics.DrawRect(GrabRect, GrabBgColorIndex, true);
            LGuiGraphics.DrawTriangle(
                new LGuiVec2(GrabRect.Left + 4, GrabRect.Top + 4),
                new LGuiVec2(GrabRect.Right - 4, GrabRect.Top + 4),
                new LGuiVec2(GrabRect.CenterX, GrabRect.Bottom - 4),
                LGuiStyle.GetColor(LGuiStyleColorIndex.Text), true);

            LGuiGraphics.DrawRect(Rect, LGuiStyleColorIndex.Border, false);

            var PopupID = $"{Title}_ItemPopup";

            if (LGuiMisc.CheckAndSetFocusID(ID))
            {
                LGuiPopup.Open(PopupID);
            }

            var NewIndex = ItemIndex;

            if (LGuiPopup.Begin(PopupID, new LGuiRect(Rect.X, Rect.Bottom + 1, Rect.Width, PopupHeight)))
            {
                var ItemWidth = Rect.Width - LGuiStyle.GetValue(LGuiStyleValueIndex.FrameChildSpacingX) * 2.0f - LGuiStyle.GetValue(LGuiStyleValueIndex.SliderSize);
                for (var Index = 0; Index < Items.Length; ++Index)
                {
                    if (LGuiSelectable.OnProcess(Items[Index], ItemIndex == Index, ItemWidth))
                    {
                        NewIndex = Index;
                        LGuiPopup.Close(PopupID);
                    }
                }
                LGuiPopup.End();
            }

            if (ItemIndex != NewIndex)
            {
                ItemIndex = NewIndex;
                return(true);
            }

            return(false);
        }