Ejemplo n.º 1
0
        internal static bool HandleHsvSlider(string Title, ref LGuiColor Hsv, LGuiVec2 Pos, float Length)
        {
            var TitleWidth      = LGuiContext.Font.FontWidth * 2.5f;
            var SpacingY        = LGuiStyle.GetValue(LGuiStyleValueIndex.ControlSpacingY);
            var SliderSize      = LGuiStyle.GetValue(LGuiStyleValueIndex.SliderSize);
            var HsvValueChanged = false;

            LGuiGraphics.DrawText("H:", new LGuiVec2(Pos.X, Pos.Y), LGuiStyleColorIndex.Text);
            if (LGuiSlider.OnProcess($"{Title}_HueSlider", ref Hsv.R, 0.0f, 1.0f, 0.005f, true, "{0:0.00}",
                                     new LGuiRect(Pos.X + TitleWidth, Pos.Y, Length - TitleWidth, SliderSize)))
            {
                HsvValueChanged = true;
            }

            LGuiGraphics.DrawText("S:", new LGuiVec2(Pos.X, Pos.Y + SliderSize + SpacingY), LGuiStyleColorIndex.Text);
            if (LGuiSlider.OnProcess($"{Title}_SaturationSlider", ref Hsv.G, 0.0f, 1.0f, 0.005f, true, "{0:0.00}",
                                     new LGuiRect(Pos.X + TitleWidth, Pos.Y + SliderSize + SpacingY, Length - TitleWidth, SliderSize)))
            {
                HsvValueChanged = true;
            }

            LGuiGraphics.DrawText("V:", new LGuiVec2(Pos.X, Pos.Y + (SliderSize + SpacingY) * 2.0f), LGuiStyleColorIndex.Text);
            if (LGuiSlider.OnProcess($"{Title}_ValueSlider", ref Hsv.B, 0.0f, 1.0f, 0.005f, true, "{0:0.00}",
                                     new LGuiRect(Pos.X + TitleWidth, Pos.Y + (SliderSize + SpacingY) * 2.0f, Length - TitleWidth, SliderSize)))
            {
                HsvValueChanged = true;
            }

            return(HsvValueChanged);
        }
Ejemplo n.º 2
0
        internal static bool HandleRgbSlider(string Title, ref LGuiColor Color, LGuiVec2 Pos, float Length)
        {
            var A               = (int)(Color.A * 255.0f);
            var R               = (int)(Color.R * 255.0f);
            var G               = (int)(Color.G * 255.0f);
            var B               = (int)(Color.B * 255.0f);
            var TitleWidth      = LGuiContext.Font.FontWidth * 2.5f;
            var SpacingY        = LGuiStyle.GetValue(LGuiStyleValueIndex.ControlSpacingY);
            var SliderSize      = LGuiStyle.GetValue(LGuiStyleValueIndex.SliderSize);
            var RgbValueChanged = false;

            LGuiGraphics.DrawText("R:", new LGuiVec2(Pos.X, Pos.Y), LGuiStyleColorIndex.Text);
            if (LGuiSlider.OnProcess($"{Title}_RedSlider", ref R, 0, 255, 1, true, "{0}",
                                     new LGuiRect(Pos.X + TitleWidth, Pos.Y, Length - TitleWidth, SliderSize)))
            {
                RgbValueChanged = true;
            }

            LGuiGraphics.DrawText("G:", new LGuiVec2(Pos.X, Pos.Y + SliderSize + SpacingY), LGuiStyleColorIndex.Text);
            if (LGuiSlider.OnProcess($"{Title}_GreenSlider", ref G, 0, 255, 1, true, "{0}",
                                     new LGuiRect(Pos.X + TitleWidth, Pos.Y + SliderSize + SpacingY, Length - TitleWidth, SliderSize)))
            {
                RgbValueChanged = true;
            }

            LGuiGraphics.DrawText("B:", new LGuiVec2(Pos.X, Pos.Y + (SliderSize + SpacingY) * 2.0f), LGuiStyleColorIndex.Text);
            if (LGuiSlider.OnProcess($"{Title}_BlueSlider", ref B, 0, 255, 1, true, "{0}",
                                     new LGuiRect(Pos.X + TitleWidth, Pos.Y + (SliderSize + SpacingY) * 2.0f, Length - TitleWidth, SliderSize)))
            {
                RgbValueChanged = true;
            }

            LGuiGraphics.DrawText("A:", new LGuiVec2(Pos.X, Pos.Y + (SliderSize + SpacingY) * 3.0f), LGuiStyleColorIndex.Text);
            if (LGuiSlider.OnProcess($"{Title}_AlphaSlider", ref A, 0, 255, 1, true, "{0}",
                                     new LGuiRect(Pos.X + TitleWidth, Pos.Y + (SliderSize + SpacingY) * 3.0f, Length - TitleWidth, SliderSize)))
            {
                RgbValueChanged = true;
            }

            if (RgbValueChanged)
            {
                Color = new LGuiColor(R, G, B, A);
            }

            return(RgbValueChanged);
        }
Ejemplo n.º 3
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();
        }