Exemplo n.º 1
0
        internal static LGuiRect DoLayout(LGuiVec2 Size)
        {
            var Context = GetCurrentLayoutContext();
            var Rect    = new LGuiRect(Context.CursorPos, Size);

            switch (Context.LayoutMode)
            {
            case LGuiLayoutMode.None:
                break;

            case LGuiLayoutMode.Horizontal:
                Context.PreviousPos.X = Context.CursorPos.X;
                Context.PreviousPos.Y = Context.CursorPos.Y + Size.Y;
                Context.CursorPos.X  += (Size.X + LGuiStyle.GetValue(LGuiStyleValueIndex.ControlSpacingX));
                Context.CursorPos.Y   = Context.BeginCursorPos.Y;
                Context.ChildSize.X   = LGuiMisc.Max(Context.ChildSize.X, Context.CursorPos.X - Context.BeginCursorPos.X);
                Context.ChildSize.Y   = LGuiMisc.Max(Context.ChildSize.Y, Context.PreviousPos.Y - Context.BeginCursorPos.Y);
                break;

            case LGuiLayoutMode.Vertical:
                Context.PreviousPos.X = Context.CursorPos.X + Size.X;
                Context.PreviousPos.Y = Context.CursorPos.Y;
                Context.CursorPos.X   = Context.BeginCursorPos.X;
                Context.CursorPos.Y  += (Size.Y + LGuiStyle.GetValue(LGuiStyleValueIndex.ControlSpacingY));
                Context.ChildSize.X   = LGuiMisc.Max(Context.ChildSize.X, Context.PreviousPos.X - Context.BeginCursorPos.X);
                Context.ChildSize.Y   = LGuiMisc.Max(Context.ChildSize.Y, Context.CursorPos.Y - Context.BeginCursorPos.Y);
                break;

            default:
                break;
            }

            return(Rect);
        }
Exemplo n.º 2
0
        internal static void BeginFrame(LGuiFrameContext Context, bool IsChild)
        {
            PushID(LGuiHash.CalculateID(Context.Title));
            var ClipRect = FrameContextStack.Count > 0 && IsChild
                ? LGuiMisc.CombineRect(ref GetCurrentFrame().Rect, ref Context.Rect)
                : Context.Rect;

            FrameContextStack.Push(Context);
            LGuiGraphics.SetClipRect(ClipRect);
        }
Exemplo n.º 3
0
        /// <summary>
        /// h = r
        /// s = g
        /// v = b
        /// </summary>
        /// <returns></returns>
        public static LGuiColor Rgb2Hsv(LGuiColor Rgb)
        {
            var H = 0.0f;
            var S = 0.0f;
            var V = 0.0f;
            var R = Rgb.R;
            var G = Rgb.G;
            var B = Rgb.B;

            var Max = LGuiMisc.Max(LGuiMisc.Max(R, G), B);
            var Min = LGuiMisc.Min(LGuiMisc.Min(R, G), B);

            if (Max == Min)
            {
                H = 0;
            }
            else if (Max == R)
            {
                if (G >= B)
                {
                    H = (G - B) / (Max - Min) * 60.0f;
                }
                else
                {
                    H = (G - B) / (Max - Min) * 60.0f + 360.0f;
                }
            }
            else if (Max == G)
            {
                H = (B - R) / (Max - Min) * 60.0f + 120.0f;
            }
            else if (Max == B)
            {
                H = (R - G) / (Max - Min) * 60.0f + 240.0f;
            }

            if (Max == 0)
            {
                S = 0;
            }
            else
            {
                S = (Max - Min) / Max;
            }

            V = Max;

            return(new LGuiColor(H / 360.0f, S, V, Rgb.A));
        }
Exemplo n.º 4
0
        internal static int DoMouseWheelEvent(int ID, int Min, int Max, int Value)
        {
            if (LGuiContext.HoveredID == ID)
            {
                var MouseWheel = LGuiContext.IO.MouseWheel;
                if (MouseWheel < 0)
                {
                    Value = LGuiMisc.Min(Value + (int)(LGuiStyle.GetValue(LGuiStyleValueIndex.ControlSpacingY) * 5), Max);
                }
                else if (MouseWheel > 0)
                {
                    Value = LGuiMisc.Max(Value - (int)(LGuiStyle.GetValue(LGuiStyleValueIndex.ControlSpacingY) * 5), Min);
                }

                LGuiContext.IO.MouseWheel = 0;
            }

            return(Value);
        }
Exemplo n.º 5
0
 public static void PreviousControlFocus()
 {
     LGuiMisc.PreviousControlFocus();
 }
Exemplo n.º 6
0
 public static bool PreviousControlIsActive()
 {
     return(LGuiMisc.PreviousControlIsActive());
 }
Exemplo n.º 7
0
 public static bool PreviousControlIsHovered()
 {
     return(LGuiMisc.PreviousControlIsHovered());
 }
Exemplo n.º 8
0
 public bool IsMouseMove()
 {
     return(LGuiMisc.Abs((MouseCurDeltaPos.X - MousePreDeltaPos.X) + (MouseCurDeltaPos.Y - MousePreDeltaPos.Y)) > 0);
 }