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 Begin() { BeginLayout(LGuiLayoutMode.Vertical, new LGuiVec2( LGuiStyle.GetValue(LGuiStyleValueIndex.FrameChildSpacingX), LGuiStyle.GetValue(LGuiStyleValueIndex.FrameChildSpacingY)), true); }
internal static void NextLine() { var Context = GetCurrentLayoutContext(); if (Context.LayoutMode == LGuiLayoutMode.Horizontal) { Context.CursorPos.X = Context.PreviousPos.X; Context.CursorPos.Y = Context.PreviousPos.Y + LGuiStyle.GetValue(LGuiStyleValueIndex.ControlSpacingY); } }
internal static void SameLine() { var Context = GetCurrentLayoutContext(); if (Context.LayoutMode == LGuiLayoutMode.Vertical) { Context.CursorPos.X = Context.PreviousPos.X + LGuiStyle.GetValue(LGuiStyleValueIndex.ControlSpacingX); Context.CursorPos.Y = Context.PreviousPos.Y; } }
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); }