Esempio n. 1
0
        internal static void EndWindow()
        {
            LGuiFrame.End();
            LGuiGraphics.SetTargetCommandList(null);

            if (!CurrentWindowCanHandleMouseMsg(false))
            {
                CurrentWindow_ = 0;
                return;
            }

            HandleMouseMsg(ref WindowList_[CurrentWindow_].Rect);

            CurrentWindow_ = 0;
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
 internal static void End()
 {
     LGuiFrame.End();
     LGuiGraphics.RestoreCurrentLevel();
 }