2
0
Эх сурвалжийг харах

Added SetCursorPosX, SetCursorPosY shortcuts

ocornut 11 жил өмнө
parent
commit
dd5d251273
2 өөрчлөгдсөн 14 нэмэгдсэн , 0 устгасан
  1. 12 0
      imgui.cpp
  2. 2 0
      imgui.h

+ 12 - 0
imgui.cpp

@@ -2461,6 +2461,18 @@ void SetCursorPos(const ImVec2& pos)
     window->DC.CursorPos = window->Pos + pos;
 }
 
+void SetCursorPosX(float x)
+{
+    ImGuiWindow* window = GetCurrentWindow();
+    window->DC.CursorPos.x = window->Pos.x + x;
+}
+
+void SetCursorPosY(float y)
+{
+    ImGuiWindow* window = GetCurrentWindow();
+    window->DC.CursorPos.y = window->Pos.y + y;
+}
+
 ImVec2 GetCursorScreenPos()
 {
     ImGuiWindow* window = GetCurrentWindow();

+ 2 - 0
imgui.h

@@ -168,6 +168,8 @@ namespace ImGui
     float       GetColumnWidth(int column_index = -1);
     ImVec2      GetCursorPos();                                                     // cursor position relative to window position
     void        SetCursorPos(const ImVec2& pos);                                    // "
+    void        SetCursorPosX(float x);                                             // "
+    void        SetCursorPosY(float y);                                             // "
     ImVec2      GetCursorScreenPos();												// cursor position in screen space
     void        AlignFirstTextHeightToWidgets();                                    // call once if the first item on the line is a Text() item and you want to vertically lower it to match higher widgets.
     float       GetTextLineSpacing();