示例#1
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);
        }
示例#2
0
        internal static void OnProcess(LGuiColor Color)
        {
            var FrameContext = LGuiContext.GetCurrentFrame();
            var Size         = new LGuiVec2(FrameContext.Size.X, 1);
            var Rect         = LGuiLayout.DoLayout(Size);

            OnProcess(Color, new LGuiVec2(Rect.Left, Rect.CenterY), new LGuiVec2(Rect.Right, Rect.CenterY));
        }
示例#3
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);
        }
示例#4
0
        internal static void End()
        {
            var FrameContext = LGuiContext.GetCurrentFrame();

            FrameContext.Size = FrameContext.Rect.Size - LGuiStyle.GetFrameChildSpacing() * 2.0f;

            if (FrameContext.Visibled)
            {
                var LayoutContext = LGuiLayout.GetCurrentLayoutContext();
                var Width         = LayoutContext.ChildSize.X - FrameContext.Rect.Width + LGuiStyle.GetValue(LGuiStyleValueIndex.FrameChildSpacingX);
                var Height        = LayoutContext.ChildSize.Y - FrameContext.Rect.Height + LGuiStyle.GetValue(LGuiStyleValueIndex.FrameChildSpacingY);
                var SliderSize    = LGuiStyle.GetValue(LGuiStyleValueIndex.SliderSize);

                var Offset = LGuiContextCache.GetFrameOffset(FrameContext.Title);

                if (Width > 0)
                {
                    LGuiSlider.OnProcess(
                        $"{FrameContext.Title}_hsbar",
                        ref Offset.X,
                        0.0f,
                        Width,
                        LGuiStyle.GetValue(LGuiStyleValueIndex.ControlSpacingX),
                        true,
                        string.Empty,
                        new LGuiRect(FrameContext.Rect.X, FrameContext.Rect.Bottom - SliderSize,
                                     FrameContext.Rect.Width - SliderSize, SliderSize));
                    FrameContext.Size.Y -= SliderSize;
                }
                else
                {
                    Offset.X = 0;
                }

                if (Height > 0)
                {
                    LGuiSlider.OnProcess(
                        $"{FrameContext.Title}_vsbar",
                        ref Offset.Y,
                        0.0f,
                        Height,
                        LGuiStyle.GetValue(LGuiStyleValueIndex.ControlSpacingY),
                        false,
                        string.Empty,
                        new LGuiRect(FrameContext.Rect.Right - SliderSize,
                                     FrameContext.Rect.Y, SliderSize, FrameContext.Rect.Height));
                    FrameContext.Size.X -= SliderSize;

                    var ID = LGuiHash.CalculateID(FrameContext.Title);
                    LGuiMisc.CheckAndSetContextID(ref FrameContext.Rect, ID, true);
                    Offset.Y = LGuiMisc.DoMouseWheelEvent(ID, 0.0f, Height, Offset.Y);
                }
                else
                {
                    Offset.Y = 0;
                }

                LGuiContextCache.SetFrameOffset(FrameContext.Title, Offset);
            }

            LGuiContextCache.SetFrameContextSize(FrameContext.Title, FrameContext.Size);
            LGuiLayout.EndLayout();
            LGuiContext.EndFrame();
        }