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); }
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; } } }
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); }
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); }
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; }
internal LGuiFrameContext(string Title, LGuiRect Rect) { this.Title = Title; this.Rect = Rect; this.Size = Rect.Size; this.Visibled = true; this.GroupStack = new Stack <LGuiGroupContext>(); }
internal static LGuiRect CombineRect(ref LGuiRect Parent, ref LGuiRect Child) { var Result = LGuiRect.Zero; if (!IntersectRect(Parent, Child, ref Result)) { return(Parent); } return(Result); }
internal static bool CheckVisible(ref LGuiRect Rect) { var FrameContext = LGuiContext.GetCurrentFrame(); if (!FrameContext.Visibled) { return(false); } return(Overlaps(ref FrameContext.Rect, ref Rect)); }
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); }
internal static void Clear() { LGuiContextCache.Clear(); IO.Clear(); Font = LGuiFont.Default; FocusID = 0; ActiveID = 0; HoveredID = 0; FrameCount = 0; PreviousControlID = 0; ActiveRect = LGuiRect.Zero; }
public static void BeginFrame(string Title, LGuiRect Rect) { LGuiFrame.Begin(Title, Rect); }
public static void Texture(string FilePath, LGuiRect SrcRect, LGuiVec2 DstSize) { LGuiTexture.OnProcess(FilePath, SrcRect, DstSize); }
public static void Texture(int TextureID, LGuiRect SrcRect, LGuiVec2 DstSize) { LGuiTexture.OnProcess(TextureID, SrcRect, DstSize); }
public static bool BeginWindow(string Title, LGuiRect Rect, LGuiWindowFlags Flags = LGuiWindowFlags.None) { return(LGuiWindow.BeginWindow(Title, Rect, Flags)); }