Ejemplo 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);
        }
Ejemplo n.º 2
0
        internal static void CheckAndSetContextID(ref LGuiRect Rect, int ID, bool OnlyHovered = false)
        {
            var FrameContext = LGuiContext.GetCurrentFrame();

            if (!Contains(ref FrameContext.Rect, ref LGuiContext.IO.MousePos))
            {
                return;
            }

            if (!LGuiWindow.CurrentWindowCanHandleMouseMsg(true))
            {
                return;
            }

            if (Contains(ref Rect, ref LGuiContext.IO.MousePos))
            {
                LGuiContext.HoveredID = ID;

                if (LGuiContext.ActiveID == 0 && LGuiContext.IO.IsMouseDown(LGuiMouseButtons.Left) && !OnlyHovered)
                {
                    LGuiContext.ActiveID   = ID;
                    LGuiContext.ActiveRect = Rect;
                }
            }
        }
Ejemplo n.º 3
0
        internal static bool Contains(ref LGuiRect Rect, ref LGuiVec2 Value)
        {
            if (Value.X < Rect.Left || Value.X > Rect.Right || Value.Y < Rect.Top || Value.Y > Rect.Bottom)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 4
0
        internal static bool Overlaps(ref LGuiRect Left, ref LGuiRect Right)
        {
            if (Left.Left >= Right.Right || Left.Right <= Right.Left || Left.Top >= Right.Bottom || Left.Bottom <= Right.Top)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 5
0
 internal LGuiWindowContext(string Title, int ID, int Order, LGuiRect Rect, bool Moveable, bool Focusable)
 {
     this.Title     = Title;
     this.ID        = ID;
     this.Order     = Order;
     this.Rect      = Rect;
     this.Moveable  = Moveable;
     this.Focusable = Focusable;
 }
Ejemplo n.º 6
0
        internal LGuiFrameContext(string Title, LGuiRect Rect)
        {
            this.Title    = Title;
            this.Rect     = Rect;
            this.Size     = Rect.Size;
            this.Visibled = true;

            this.GroupStack = new Stack <LGuiGroupContext>();
        }
Ejemplo n.º 7
0
        internal static LGuiRect CombineRect(ref LGuiRect Parent, ref LGuiRect Child)
        {
            var Result = LGuiRect.Zero;

            if (!IntersectRect(Parent, Child, ref Result))
            {
                return(Parent);
            }

            return(Result);
        }
Ejemplo n.º 8
0
        internal static bool CheckVisible(ref LGuiRect Rect)
        {
            var FrameContext = LGuiContext.GetCurrentFrame();

            if (!FrameContext.Visibled)
            {
                return(false);
            }

            return(Overlaps(ref FrameContext.Rect, ref Rect));
        }
Ejemplo n.º 9
0
        internal static bool IntersectRect(LGuiRect Left, LGuiRect Right, ref LGuiRect Result)
        {
            if (!Overlaps(ref Left, ref Right))
            {
                return(false);
            }

            Result = LGuiRect.CreateWithBoundary(
                Max(Left.Left, Right.Left),
                Max(Left.Top, Right.Top),
                Min(Left.Right, Right.Right),
                Min(Left.Bottom, Right.Bottom));
            return(true);
        }
Ejemplo n.º 10
0
        internal static void Clear()
        {
            LGuiContextCache.Clear();

            IO.Clear();
            Font = LGuiFont.Default;

            FocusID           = 0;
            ActiveID          = 0;
            HoveredID         = 0;
            FrameCount        = 0;
            PreviousControlID = 0;
            ActiveRect        = LGuiRect.Zero;
        }
Ejemplo n.º 11
0
 public static void BeginFrame(string Title, LGuiRect Rect)
 {
     LGuiFrame.Begin(Title, Rect);
 }
Ejemplo n.º 12
0
 public static void Texture(string FilePath, LGuiRect SrcRect, LGuiVec2 DstSize)
 {
     LGuiTexture.OnProcess(FilePath, SrcRect, DstSize);
 }
Ejemplo n.º 13
0
 public static void Texture(int TextureID, LGuiRect SrcRect, LGuiVec2 DstSize)
 {
     LGuiTexture.OnProcess(TextureID, SrcRect, DstSize);
 }
Ejemplo n.º 14
0
 public static bool BeginWindow(string Title, LGuiRect Rect, LGuiWindowFlags Flags = LGuiWindowFlags.None)
 {
     return(LGuiWindow.BeginWindow(Title, Rect, Flags));
 }