Exemplo n.º 1
0
        public void SetMouseState(LGuiMouseButtons Btn, int X, int Y, bool IsMouseBtnDown, bool IsMouseMove)
        {
            var Index = (int)Btn;

            MouseButton = Btn;

            if (!IsMouseMove)
            {
                MousePreState[Index] = MouseCurState[Index];
                MouseCurState[Index] = IsMouseBtnDown;
                MouseClickPos[Index] = new LGuiVec2(X, Y);

                MousePreDeltaPos = MouseCurDeltaPos;
                MouseCurDeltaPos = LGuiVec2.Zero;
            }
            else
            {
                if (MouseCurState[Index])
                {
                    MousePreDeltaPos   = MouseCurDeltaPos;
                    MouseCurDeltaPos.X = X - MouseClickPos[Index].X;
                    MouseCurDeltaPos.Y = Y - MouseClickPos[Index].Y;
                }

                MousePos.X = X;
                MousePos.Y = Y;
            }
        }
Exemplo n.º 2
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.º 3
0
        internal void End()
        {
            for (var Index = 0; Index < KeyCurState.Length; ++Index)
            {
                KeyPreState[Index] = KeyCurState[Index];

                if (!KeyCurState[Index])
                {
                    KeyPressedTime[Index] = 0.0f;
                }
            }

            for (var Index = 0; Index < MouseCurState.Length; ++Index)
            {
                MousePreState[Index] = MouseCurState[Index];

                if (!MouseCurState[Index])
                {
                    MousePressedTime[Index] = 0.0f;
                }
            }

            MousePreDeltaPos = MouseCurDeltaPos;
            MouseWheel       = 0;
        }
Exemplo n.º 4
0
        internal void Clear()
        {
            for (var Index = 0; Index < KeyCurState.Length; ++Index)
            {
                KeyCurState[Index]    = false;
                KeyPreState[Index]    = false;
                KeyPressedTime[Index] = 0;
            }

            KeyCode = LGuiKeys.None;

            for (var Index = 0; Index < MouseCurState.Length; ++Index)
            {
                MouseCurState[Index]    = false;
                MousePreState[Index]    = false;
                MousePressedTime[Index] = 0;
                MouseClickPos[Index]    = LGuiVec2.Zero;
            }

            MouseCurDeltaPos = LGuiVec2.Zero;
            MousePreDeltaPos = LGuiVec2.Zero;
            MouseButton      = LGuiMouseButtons.None;
            MousePos         = LGuiVec2.Zero;
            MouseWheel       = 0;
        }
Exemplo n.º 5
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>();
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
 internal LGuiLayoutContext(LGuiLayoutMode LayoutMode, LGuiVec2 CursorPos, bool AutoMerge)
 {
     this.LayoutMode     = LayoutMode;
     this.BeginCursorPos = CursorPos;
     this.CursorPos      = CursorPos;
     this.ChildSize      = LGuiVec2.Zero;
     this.PreviousPos    = CursorPos;
     this.AutoMerge      = AutoMerge;
 }
Exemplo n.º 8
0
 internal static void SetFrameOffset(string Title, LGuiVec2 Offset)
 {
     if (FrameOffset.ContainsKey(Title))
     {
         FrameOffset[Title] = Offset;
     }
     else
     {
         FrameOffset.Add(Title, Offset);
     }
 }
Exemplo n.º 9
0
 internal static void SetFrameContextSize(string Title, LGuiVec2 Size)
 {
     if (FrameContextSize.ContainsKey(Title))
     {
         FrameContextSize[Title] = Size;
     }
     else
     {
         FrameContextSize.Add(Title, Size);
     }
 }
Exemplo n.º 10
0
 internal static void SetPopupPos(string Title, LGuiVec2 Pos)
 {
     if (PopupPos.ContainsKey(Title))
     {
         PopupPos[Title] = Pos;
     }
     else
     {
         PopupPos.Add(Title, Pos);
     }
 }
Exemplo n.º 11
0
 public static void Texture(int TextureID, LGuiRect SrcRect, LGuiVec2 DstSize)
 {
     LGuiTexture.OnProcess(TextureID, SrcRect, DstSize);
 }
Exemplo n.º 12
0
 public static void Texture(int TextureID, LGuiVec2 DstSize)
 {
     Texture(TextureID, LGuiRect.Zero, DstSize);
 }
Exemplo n.º 13
0
 public static bool InputText(string Title, ref string Value, uint MaxLength, LGuiVec2 Size, LGuiInputTextFlags Flags = LGuiInputTextFlags.None)
 {
     return(LGuiInputText.OnProcess(Title, ref Value, MaxLength, Size, Flags));
 }
Exemplo n.º 14
0
 public static bool ColorButton(string Title, LGuiColor Color, LGuiVec2 Size)
 {
     return(LGuiColorButton.OnProcess(Title, Color, Size));
 }
Exemplo n.º 15
0
 public static bool InvisibleButton(string Title, LGuiVec2 Size)
 {
     return(LGuiButton.OnProcess(Title, Size, LGuiButtonFlags.Invisible));
 }
Exemplo n.º 16
0
 public static bool Button(string Title, LGuiVec2 Size, LGuiButtonFlags Flags = LGuiButtonFlags.None)
 {
     return(LGuiButton.OnProcess(Title, Size, Flags));
 }
Exemplo n.º 17
0
 public LGuiRect(float X, float Y, float Width, float Height)
 {
     this.Pos  = new LGuiVec2(X, Y);
     this.Size = new LGuiVec2(Width, Height);
 }
Exemplo n.º 18
0
 public static void BeginFrame(string Title, LGuiVec2 Size)
 {
     LGuiFrame.Begin(Title, Size);
 }
Exemplo n.º 19
0
 public static bool BeginToolTips(LGuiVec2 Size)
 {
     return(LGuiToolTips.Begin(Size));
 }
Exemplo n.º 20
0
 public static LGuiRect CreateWithCenter(LGuiVec2 CenterPos, LGuiVec2 Size)
 {
     return(new LGuiRect(CenterPos.X - Size.X / 2.0f, CenterPos.Y - Size.Y / 2.0f, Size.X, Size.Y));
 }
Exemplo n.º 21
0
 internal static void BeginLayout(LGuiLayoutMode LayoutMode, LGuiVec2 CursorPos, bool AutoMerge)
 {
     LayoutContextStack.Push(new LGuiLayoutContext(LayoutMode, CursorPos, AutoMerge));
 }
Exemplo n.º 22
0
 public static void Texture(string FilePath, LGuiVec2 DstSize)
 {
     Texture(FilePath, LGuiRect.Zero, DstSize);
 }
Exemplo n.º 23
0
 public static void Texture(string FilePath, LGuiRect SrcRect, LGuiVec2 DstSize)
 {
     LGuiTexture.OnProcess(FilePath, SrcRect, DstSize);
 }
Exemplo n.º 24
0
 public static bool BeginWindow(string Title, LGuiVec2 Size, LGuiWindowFlags Flags = LGuiWindowFlags.None)
 {
     return(LGuiWindow.BeginWindow(Title, Size, Flags));
 }
Exemplo n.º 25
0
 public static bool ListBox(string Title, ref int ItemIndex, string[] Items, LGuiVec2 Size)
 {
     return(LGuiListBox.OnProcess(Title, ref ItemIndex, Items, Size));
 }
Exemplo n.º 26
0
 public static bool BeginPopup(string Title, LGuiVec2 Size)
 {
     return(LGuiPopup.Begin(Title, Size));
 }
Exemplo n.º 27
0
 public static void OpenPopup(string Title, LGuiVec2 Pos)
 {
     LGuiPopup.Open(Title, Pos);
 }
Exemplo n.º 28
0
 public LGuiRect(LGuiVec2 Pos, LGuiVec2 Size)
 {
     this.Pos  = Pos;
     this.Size = Size;
 }