Skip to content

Commit 640f56b

Browse files
committed
Add ImGui helper methods to get ImVec2 values
1 parent 50ce76a commit 640f56b

File tree

1 file changed

+253
-0
lines changed

1 file changed

+253
-0
lines changed

imgui-binding/src/main/java/imgui/ImGui.java

Lines changed: 253 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,13 +519,41 @@ public static ImDrawList getWindowDrawListNew() {
519519
Jni::ImVec2Cpy(env, ImGui::GetWindowPos(), dstImVec2);
520520
*/
521521

522+
/**
523+
* Get current window position in screen space (useful if you want to do your own drawing via the DrawList API)
524+
*/
525+
public static native float getWindowPosX(); /*
526+
return ImGui::GetWindowPos().x;
527+
*/
528+
529+
/**
530+
* Get current window position in screen space (useful if you want to do your own drawing via the DrawList API)
531+
*/
532+
public static native float getWindowPosY(); /*
533+
return ImGui::GetWindowPos().y;
534+
*/
535+
522536
/**
523537
* Get current window size
524538
*/
525539
public static native void getWindowSize(ImVec2 dstImVec2); /*
526540
Jni::ImVec2Cpy(env, ImGui::GetWindowSize(), dstImVec2);
527541
*/
528542

543+
/**
544+
* Get current window size
545+
*/
546+
public static native float getWindowSizeX(); /*
547+
return ImGui::GetWindowSize().x;
548+
*/
549+
550+
/**
551+
* Get current window size
552+
*/
553+
public static native float getWindowSizeY(); /*
554+
return ImGui::GetWindowSize().y;
555+
*/
556+
529557
/**
530558
* Get current window width (shortcut for GetWindowSize().x)
531559
*/
@@ -747,13 +775,41 @@ public static ImDrawList getWindowDrawListNew() {
747775
Jni::ImVec2Cpy(env, ImGui::GetContentRegionMax(), dstImVec2);
748776
*/
749777

778+
/**
779+
* Current content boundaries (typically window boundaries including scrolling, or current column boundaries), in windows coordinates
780+
*/
781+
public static native float getContentRegionMaxX(); /*
782+
return ImGui::GetContentRegionMax().x;
783+
*/
784+
785+
/**
786+
* Current content boundaries (typically window boundaries including scrolling, or current column boundaries), in windows coordinates
787+
*/
788+
public static native float getContentRegionMaxY(); /*
789+
return ImGui::GetContentRegionMax().y;
790+
*/
791+
750792
/**
751793
* == GetContentRegionMax() - GetCursorPos()
752794
*/
753795
public static native void getContentRegionAvail(ImVec2 dstImVec2); /*
754796
Jni::ImVec2Cpy(env, ImGui::GetContentRegionAvail(), dstImVec2);
755797
*/
756798

799+
/**
800+
* == GetContentRegionMax() - GetCursorPos()
801+
*/
802+
public static native float getContentRegionAvailX(); /*
803+
return ImGui::GetContentRegionAvail().x;
804+
*/
805+
806+
/**
807+
* == GetContentRegionMax() - GetCursorPos()
808+
*/
809+
public static native float getContentRegionAvailY(); /*
810+
return ImGui::GetContentRegionAvail().y;
811+
*/
812+
757813
/**
758814
* Content boundaries min (roughly (0,0)-Scroll), in window coordinates
759815
*/
@@ -768,10 +824,32 @@ public static ImDrawList getWindowDrawListNew() {
768824
Jni::ImVec2Cpy(env, ImGui::GetWindowContentRegionMin(), dstImVec2);
769825
*/
770826

827+
/**
828+
* Content boundaries max (roughly (0,0)+Size-Scroll) where Size can be override with SetNextWindowContentSize(), in window coordinates
829+
*/
830+
public static native float getWindowContentRegionMinX(); /*
831+
return ImGui::GetWindowContentRegionMin().x;
832+
*/
833+
834+
/**
835+
* Content boundaries max (roughly (0,0)+Size-Scroll) where Size can be override with SetNextWindowContentSize(), in window coordinates
836+
*/
837+
public static native float getWindowContentRegionMinY(); /*
838+
return ImGui::GetWindowContentRegionMin().y;
839+
*/
840+
771841
public static native void getWindowContentRegionMax(ImVec2 dstImVec2); /*
772842
Jni::ImVec2Cpy(env, ImGui::GetWindowContentRegionMax(), dstImVec2);
773843
*/
774844

845+
public static native float getWindowContentRegionMaxX(); /*
846+
return ImGui::GetWindowContentRegionMax().x;
847+
*/
848+
849+
public static native float getWindowContentRegionMaxY(); /*
850+
return ImGui::GetWindowContentRegionMax().y;
851+
*/
852+
775853
// Windows Scrolling
776854

777855
/**
@@ -962,6 +1040,20 @@ public static ImFont getFont() {
9621040
Jni::ImVec2Cpy(env, ImGui::GetFontTexUvWhitePixel(), dstImVec2);
9631041
*/
9641042

1043+
/**
1044+
* Get UV coordinate for a while pixel, useful to draw custom shapes via the ImDrawList API
1045+
*/
1046+
public static native float getFontTexUvWhitePixelX(); /*
1047+
return ImGui::GetFontTexUvWhitePixel().x;
1048+
*/
1049+
1050+
/**
1051+
* Get UV coordinate for a while pixel, useful to draw custom shapes via the ImDrawList API
1052+
*/
1053+
public static native float getFontTexUvWhitePixelY(); /*
1054+
return ImGui::GetFontTexUvWhitePixel().y;
1055+
*/
1056+
9651057
/**
9661058
* Retrieve given style color with style alpha applied and optional extra alpha multiplier
9671059
*/
@@ -1175,22 +1267,37 @@ public static ImFont getFont() {
11751267
Jni::ImVec2Cpy(env, ImGui::GetCursorPos(), dstImVec2);
11761268
*/
11771269

1270+
/**
1271+
* Cursor position in window coordinates (relative to window position)
1272+
*/
11781273
public static native float getCursorPosX(); /*
11791274
return ImGui::GetCursorPosX();
11801275
*/
11811276

1277+
/**
1278+
* Cursor position in window coordinates (relative to window position)
1279+
*/
11821280
public static native float getCursorPosY(); /*
11831281
return ImGui::GetCursorPosY();
11841282
*/
11851283

1284+
/**
1285+
* Cursor position in window coordinates (relative to window position)
1286+
*/
11861287
public static native void setCursorPos(float x, float y); /*
11871288
ImGui::SetCursorPos(ImVec2(x, y));
11881289
*/
11891290

1291+
/**
1292+
* Cursor position in window coordinates (relative to window position)
1293+
*/
11901294
public static native void setCursorPosX(float x); /*
11911295
ImGui::SetCursorPosX(x);
11921296
*/
11931297

1298+
/**
1299+
* Cursor position in window coordinates (relative to window position)
1300+
*/
11941301
public static native void setCursorPosY(float y); /*
11951302
ImGui::SetCursorPosY(y);
11961303
*/
@@ -1202,13 +1309,41 @@ public static ImFont getFont() {
12021309
Jni::ImVec2Cpy(env, ImGui::GetCursorStartPos(), dstImVec2);
12031310
*/
12041311

1312+
/**
1313+
* Initial cursor position in window coordinates
1314+
*/
1315+
public static native float getCursorStartPosX(); /*
1316+
return ImGui::GetCursorStartPos().x;
1317+
*/
1318+
1319+
/**
1320+
* Initial cursor position in window coordinates
1321+
*/
1322+
public static native float getCursorStartPosY(); /*
1323+
return ImGui::GetCursorStartPos().y;
1324+
*/
1325+
12051326
/**
12061327
* Cursor position in absolute screen coordinates [0..io.DisplaySize] (useful to work with ImDrawList API)
12071328
*/
12081329
public static native void getCursorScreenPos(ImVec2 dstImVec2); /*
12091330
Jni::ImVec2Cpy(env, ImGui::GetCursorScreenPos(), dstImVec2);
12101331
*/
12111332

1333+
/**
1334+
* Cursor position in absolute screen coordinates [0..io.DisplaySize] (useful to work with ImDrawList API)
1335+
*/
1336+
public static native float getCursorScreenPosX(); /*
1337+
return ImGui::GetCursorScreenPos().x;
1338+
*/
1339+
1340+
/**
1341+
* Cursor position in absolute screen coordinates [0..io.DisplaySize] (useful to work with ImDrawList API)
1342+
*/
1343+
public static native float getCursorScreenPosY(); /*
1344+
return ImGui::GetCursorScreenPos().y;
1345+
*/
1346+
12121347
/**
12131348
* Cursor position in absolute screen coordinates [0..io.DisplaySize]
12141349
*/
@@ -4664,20 +4799,62 @@ public static Object getDragDropPayloadObject() {
46644799
Jni::ImVec2Cpy(env, ImGui::GetItemRectMin(), dstImVec2);
46654800
*/
46664801

4802+
/**
4803+
* Get upper-left bounding rectangle of the last item (screen space)
4804+
*/
4805+
public static native float getItemRectMinX(); /*
4806+
return ImGui::GetItemRectMin().x;
4807+
*/
4808+
4809+
/**
4810+
* Get upper-left bounding rectangle of the last item (screen space)
4811+
*/
4812+
public static native float getItemRectMinY(); /*
4813+
return ImGui::GetItemRectMin().y;
4814+
*/
4815+
46674816
/**
46684817
* Get lower-right bounding rectangle of the last item (screen space)
46694818
*/
46704819
public static native void getItemRectMax(ImVec2 dstImVec2); /*
46714820
Jni::ImVec2Cpy(env, ImGui::GetItemRectMax(), dstImVec2);
46724821
*/
46734822

4823+
/**
4824+
* Get lower-right bounding rectangle of the last item (screen space)
4825+
*/
4826+
public static native float getItemRectMaxX(); /*
4827+
return ImGui::GetItemRectMax().x;
4828+
*/
4829+
4830+
/**
4831+
* Get lower-right bounding rectangle of the last item (screen space)
4832+
*/
4833+
public static native float getItemRectMaxY(); /*
4834+
return ImGui::GetItemRectMax().y;
4835+
*/
4836+
46744837
/**
46754838
* Get size of last item
46764839
*/
46774840
public static native void getItemRectSize(ImVec2 dstImVec2); /*
46784841
Jni::ImVec2Cpy(env, ImGui::GetItemRectSize(), dstImVec2);
46794842
*/
46804843

4844+
/**
4845+
* Get size of last item
4846+
*/
4847+
public static native float getItemRectSizeX(); /*
4848+
return ImGui::GetItemRectSize().x;
4849+
*/
4850+
4851+
/**
4852+
* Get size of last item
4853+
*/
4854+
public static native float getItemRectSizeY(); /*
4855+
return ImGui::GetItemRectSize().y;
4856+
*/
4857+
46814858
/**
46824859
* Allow last item to be overlapped by a subsequent item. sometimes useful with invisible buttons, selectables, etc. to catch unused area.
46834860
*/
@@ -5034,13 +5211,41 @@ public static ImGuiStorage getStateStorageNew() {
50345211
Jni::ImVec2Cpy(env, ImGui::GetMousePos(), dstImVec2);
50355212
*/
50365213

5214+
/**
5215+
* Shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls
5216+
*/
5217+
public static native float getMousePosX(); /*
5218+
return ImGui::GetMousePos().x;
5219+
*/
5220+
5221+
/**
5222+
* Shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls
5223+
*/
5224+
public static native float getMousePosY(); /*
5225+
return ImGui::GetMousePos().y;
5226+
*/
5227+
50375228
/**
50385229
* Retrieve backup of mouse position at the time of opening popup we have BeginPopup() into
50395230
*/
50405231
public static native void getMousePosOnOpeningCurrentPopup(ImVec2 dstImVec2); /*
50415232
Jni::ImVec2Cpy(env, ImGui::GetMousePosOnOpeningCurrentPopup(), dstImVec2);
50425233
*/
50435234

5235+
/**
5236+
* Retrieve backup of mouse position at the time of opening popup we have BeginPopup() into
5237+
*/
5238+
public static native float getMousePosOnOpeningCurrentPopupX(); /*
5239+
return ImGui::GetMousePosOnOpeningCurrentPopup().x;
5240+
*/
5241+
5242+
/**
5243+
* Retrieve backup of mouse position at the time of opening popup we have BeginPopup() into
5244+
*/
5245+
public static native float getMousePosOnOpeningCurrentPopupY(); /*
5246+
return ImGui::GetMousePosOnOpeningCurrentPopup().y;
5247+
*/
5248+
50445249
/**
50455250
* Return the delta from the initial clicking position while the mouse button is pressed or was just released.
50465251
* This is locked and return 0.0f until the mouse moves past a distance threshold at least once. If lockThreshold {@code < -1.0f} uses io.MouseDraggingThreshold.
@@ -5049,6 +5254,22 @@ public static ImGuiStorage getStateStorageNew() {
50495254
Jni::ImVec2Cpy(env, ImGui::GetMouseDragDelta(), dstImVec2);
50505255
*/
50515256

5257+
/**
5258+
* Return the delta from the initial clicking position while the mouse button is pressed or was just released.
5259+
* This is locked and return 0.0f until the mouse moves past a distance threshold at least once. If lockThreshold {@code < -1.0f} uses io.MouseDraggingThreshold.
5260+
*/
5261+
public static native float getMouseDragDeltaX(); /*
5262+
return ImGui::GetMouseDragDelta().x;
5263+
*/
5264+
5265+
/**
5266+
* Return the delta from the initial clicking position while the mouse button is pressed or was just released.
5267+
* This is locked and return 0.0f until the mouse moves past a distance threshold at least once. If lockThreshold {@code < -1.0f} uses io.MouseDraggingThreshold.
5268+
*/
5269+
public static native float getMouseDragDeltaY(); /*
5270+
return ImGui::GetMouseDragDelta().y;
5271+
*/
5272+
50525273
/**
50535274
* Return the delta from the initial clicking position while the mouse button is pressed or was just released.
50545275
* This is locked and return 0.0f until the mouse moves past a distance threshold at least once. If lockThreshold {@code < -1.0f} uses io.MouseDraggingThreshold.
@@ -5057,6 +5278,22 @@ public static ImGuiStorage getStateStorageNew() {
50575278
Jni::ImVec2Cpy(env, ImGui::GetMouseDragDelta(button), dstImVec2);
50585279
*/
50595280

5281+
/**
5282+
* Return the delta from the initial clicking position while the mouse button is pressed or was just released.
5283+
* This is locked and return 0.0f until the mouse moves past a distance threshold at least once. If lockThreshold {@code < -1.0f} uses io.MouseDraggingThreshold.
5284+
*/
5285+
public static native float getMouseDragDeltaX(int button); /*
5286+
return ImGui::GetMouseDragDelta(button).x;
5287+
*/
5288+
5289+
/**
5290+
* Return the delta from the initial clicking position while the mouse button is pressed or was just released.
5291+
* This is locked and return 0.0f until the mouse moves past a distance threshold at least once. If lockThreshold {@code < -1.0f} uses io.MouseDraggingThreshold.
5292+
*/
5293+
public static native float getMouseDragDeltaY(int button); /*
5294+
return ImGui::GetMouseDragDelta(button).y;
5295+
*/
5296+
50605297
/**
50615298
* Return the delta from the initial clicking position while the mouse button is pressed or was just released.
50625299
* This is locked and return 0.0f until the mouse moves past a distance threshold at least once. If lockThreshold {@code < -1.0f} uses io.MouseDraggingThreshold.
@@ -5065,6 +5302,22 @@ public static ImGuiStorage getStateStorageNew() {
50655302
Jni::ImVec2Cpy(env, ImGui::GetMouseDragDelta(button, lockThreshold), dstImVec2);
50665303
*/
50675304

5305+
/**
5306+
* Return the delta from the initial clicking position while the mouse button is pressed or was just released.
5307+
* This is locked and return 0.0f until the mouse moves past a distance threshold at least once. If lockThreshold {@code < -1.0f} uses io.MouseDraggingThreshold.
5308+
*/
5309+
public static native float getMouseDragDeltaX(int button, float lockThreshold); /*
5310+
return ImGui::GetMouseDragDelta(button, lockThreshold).x;
5311+
*/
5312+
5313+
/**
5314+
* Return the delta from the initial clicking position while the mouse button is pressed or was just released.
5315+
* This is locked and return 0.0f until the mouse moves past a distance threshold at least once. If lockThreshold {@code < -1.0f} uses io.MouseDraggingThreshold.
5316+
*/
5317+
public static native float getMouseDragDeltaY(int button, float lockThreshold); /*
5318+
return ImGui::GetMouseDragDelta(button, lockThreshold).y;
5319+
*/
5320+
50685321
public static native void resetMouseDragDelta(); /*
50695322
ImGui::ResetMouseDragDelta();
50705323
*/

0 commit comments

Comments
 (0)