|
| 1 | +package imgui; |
| 2 | + |
| 3 | +/** |
| 4 | + * The viewports created and managed by Dear ImGui. The role of the platform back-end is to create the platform/OS windows corresponding to each viewport. |
| 5 | + * - Main Area = entire viewport. |
| 6 | + * - Work Area = entire viewport minus sections optionally used by menu bars, status bars. Some positioning code will prefer to use this. Window are also trying to stay within this area. |
| 7 | + */ |
| 8 | +public final class ImGuiViewport { |
| 9 | + final long ptr; |
| 10 | + |
| 11 | + ImGuiViewport(final long ptr) { |
| 12 | + this.ptr = ptr; |
| 13 | + } |
| 14 | + |
| 15 | + /*JNI |
| 16 | + #include <stdint.h> |
| 17 | + #include <imgui.h> |
| 18 | + #include "jni_common.h" |
| 19 | +
|
| 20 | + jfieldID imGuiViewportPtrID; |
| 21 | +
|
| 22 | + #define IMGUI_VIEWPORT ((ImGuiViewport*)env->GetLongField(object, imGuiViewportPtrID)) |
| 23 | + */ |
| 24 | + |
| 25 | + static native void nInit(); /* |
| 26 | + jclass jImGuiViewportClass = env->FindClass("imgui/ImGuiViewport"); |
| 27 | + imGuiViewportPtrID = env->GetFieldID(jImGuiViewportClass, "ptr", "J"); |
| 28 | + */ |
| 29 | + |
| 30 | + /** |
| 31 | + * Unique identifier for the viewport. |
| 32 | + */ |
| 33 | + public native int getImGuiId(); /* |
| 34 | + return IMGUI_VIEWPORT->ID; |
| 35 | + */ |
| 36 | + |
| 37 | + /** |
| 38 | + * Unique identifier for the viewport. |
| 39 | + */ |
| 40 | + public native void setImGuiId(int imGuiID); /* |
| 41 | + IMGUI_VIEWPORT->ID = imGuiID; |
| 42 | + */ |
| 43 | + |
| 44 | + /** |
| 45 | + * See ImGuiViewportFlags_. |
| 46 | + */ |
| 47 | + public native int getFlags(); /* |
| 48 | + return IMGUI_VIEWPORT->Flags; |
| 49 | + */ |
| 50 | + |
| 51 | + /** |
| 52 | + * See ImGuiViewportFlags_. |
| 53 | + */ |
| 54 | + public native void setFlags(int flags); /* |
| 55 | + IMGUI_VIEWPORT->Flags = flags; |
| 56 | + */ |
| 57 | + |
| 58 | + /** |
| 59 | + * Main Area: Position of the viewport (the imgui coordinates are the same as OS desktop/native coordinates). |
| 60 | + */ |
| 61 | + public native void getPos(ImVec2 dstImVec2); /* |
| 62 | + Jni::ImVec2Cpy(env, &IMGUI_VIEWPORT->Pos, dstImVec2); |
| 63 | + */ |
| 64 | + |
| 65 | + /** |
| 66 | + * Main Area: Position of the viewport (the imgui coordinates are the same as OS desktop/native coordinates). |
| 67 | + */ |
| 68 | + public native float getPosX(); /* |
| 69 | + return IMGUI_VIEWPORT->Pos.x; |
| 70 | + */ |
| 71 | + |
| 72 | + /** |
| 73 | + * Main Area: Position of the viewport (the imgui coordinates are the same as OS desktop/native coordinates). |
| 74 | + */ |
| 75 | + public native float getPosY(); /* |
| 76 | + return IMGUI_VIEWPORT->Pos.y; |
| 77 | + */ |
| 78 | + |
| 79 | + /** |
| 80 | + * Main Area: Position of the viewport (the imgui coordinates are the same as OS desktop/native coordinates). |
| 81 | + */ |
| 82 | + public native void setPos(float x, float y); /* |
| 83 | + IMGUI_VIEWPORT->Pos = ImVec2(x, y); |
| 84 | + */ |
| 85 | + |
| 86 | + /** |
| 87 | + * Main Area: Size of the viewport. |
| 88 | + */ |
| 89 | + public native void getSize(ImVec2 dstImVec2); /* |
| 90 | + Jni::ImVec2Cpy(env, &IMGUI_VIEWPORT->Size, dstImVec2); |
| 91 | + */ |
| 92 | + |
| 93 | + /** |
| 94 | + * Main Area: Size of the viewport. |
| 95 | + */ |
| 96 | + public native float getSizeX(); /* |
| 97 | + return IMGUI_VIEWPORT->Size.x; |
| 98 | + */ |
| 99 | + |
| 100 | + /** |
| 101 | + * Main Area: Size of the viewport. |
| 102 | + */ |
| 103 | + public native float getSizeY(); /* |
| 104 | + return IMGUI_VIEWPORT->Size.y; |
| 105 | + */ |
| 106 | + |
| 107 | + /** |
| 108 | + * Main Area: Size of the viewport. |
| 109 | + */ |
| 110 | + public native void seSize(float x, float y); /* |
| 111 | + IMGUI_VIEWPORT->Size = ImVec2(x, y); |
| 112 | + */ |
| 113 | + |
| 114 | + /** |
| 115 | + * Work Area: Offset from Pos to top-left corner of Work Area. Generally (0,0) or (0,+main_menu_bar_height). |
| 116 | + * Work Area is Full Area but without menu-bars/status-bars (so WorkArea always fit inside Pos/Size!) |
| 117 | + */ |
| 118 | + public native void getWorkOffsetMin(ImVec2 dstImVec2); /* |
| 119 | + Jni::ImVec2Cpy(env, &IMGUI_VIEWPORT->WorkOffsetMin, dstImVec2); |
| 120 | + */ |
| 121 | + |
| 122 | + /** |
| 123 | + * Work Area: Offset from Pos to top-left corner of Work Area. Generally (0,0) or (0,+main_menu_bar_height). |
| 124 | + * Work Area is Full Area but without menu-bars/status-bars (so WorkArea always fit inside Pos/Size!) |
| 125 | + */ |
| 126 | + public native float getWorkOffsetMinX(); /* |
| 127 | + return IMGUI_VIEWPORT->WorkOffsetMin.x; |
| 128 | + */ |
| 129 | + |
| 130 | + /** |
| 131 | + * Work Area: Offset from Pos to top-left corner of Work Area. Generally (0,0) or (0,+main_menu_bar_height). |
| 132 | + * Work Area is Full Area but without menu-bars/status-bars (so WorkArea always fit inside Pos/Size!) |
| 133 | + */ |
| 134 | + public native float getWorkOffsetMinY(); /* |
| 135 | + return IMGUI_VIEWPORT->WorkOffsetMin.y; |
| 136 | + */ |
| 137 | + |
| 138 | + /** |
| 139 | + * Work Area: Offset from Pos to top-left corner of Work Area. Generally (0,0) or (0,+main_menu_bar_height). |
| 140 | + * Work Area is Full Area but without menu-bars/status-bars (so WorkArea always fit inside Pos/Size!) |
| 141 | + */ |
| 142 | + public native void seWorkOffsetMin(float x, float y); /* |
| 143 | + IMGUI_VIEWPORT->WorkOffsetMin = ImVec2(x, y); |
| 144 | + */ |
| 145 | + |
| 146 | + /** |
| 147 | + * Work Area: Offset from Pos+Size to bottom-right corner of Work Area. Generally (0,0) or (0,-status_bar_height). |
| 148 | + */ |
| 149 | + public native void getWorkOffsetMax(ImVec2 dstImVec2); /* |
| 150 | + Jni::ImVec2Cpy(env, &IMGUI_VIEWPORT->WorkOffsetMax, dstImVec2); |
| 151 | + */ |
| 152 | + |
| 153 | + /** |
| 154 | + * Work Area: Offset from Pos+Size to bottom-right corner of Work Area. Generally (0,0) or (0,-status_bar_height). |
| 155 | + */ |
| 156 | + public native float getWorkOffsetMaxX(); /* |
| 157 | + return IMGUI_VIEWPORT->WorkOffsetMax.x; |
| 158 | + */ |
| 159 | + |
| 160 | + /** |
| 161 | + * Work Area: Offset from Pos+Size to bottom-right corner of Work Area. Generally (0,0) or (0,-status_bar_height). |
| 162 | + */ |
| 163 | + public native float getWorkOffsetMaxY(); /* |
| 164 | + return IMGUI_VIEWPORT->WorkOffsetMax.y; |
| 165 | + */ |
| 166 | + |
| 167 | + /** |
| 168 | + * Work Area: Offset from Pos+Size to bottom-right corner of Work Area. Generally (0,0) or (0,-status_bar_height). |
| 169 | + */ |
| 170 | + public native void seWorkOffsetMax(float x, float y); /* |
| 171 | + IMGUI_VIEWPORT->WorkOffsetMax = ImVec2(x, y); |
| 172 | + */ |
| 173 | + |
| 174 | + /** |
| 175 | + * 1.0f = 96 DPI = No extra scale. |
| 176 | + */ |
| 177 | + public native float getDpiScale(); /* |
| 178 | + return IMGUI_VIEWPORT->DpiScale; |
| 179 | + */ |
| 180 | + |
| 181 | + /** |
| 182 | + * 1.0f = 96 DPI = No extra scale. |
| 183 | + */ |
| 184 | + public native void setDpiScale(float dpiScale); /* |
| 185 | + IMGUI_VIEWPORT->DpiScale = dpiScale; |
| 186 | + */ |
| 187 | + |
| 188 | + // TODO: DrawData |
| 189 | + |
| 190 | + /** |
| 191 | + * (Advanced) 0: no parent. Instruct the platform back-end to setup a parent/child relationship between platform windows. |
| 192 | + */ |
| 193 | + public native int getParentViewportId(); /* |
| 194 | + return IMGUI_VIEWPORT->ParentViewportId; |
| 195 | + */ |
| 196 | + |
| 197 | + /** |
| 198 | + * (Advanced) 0: no parent. Instruct the platform back-end to setup a parent/child relationship between platform windows. |
| 199 | + */ |
| 200 | + public native void setParentViewportId(int parentViewportId); /* |
| 201 | + IMGUI_VIEWPORT->ParentViewportId = parentViewportId; |
| 202 | + */ |
| 203 | + |
| 204 | + // Our design separate the Renderer and Platform back-ends to facilitate combining default back-ends with each others. |
| 205 | + // When our create your own back-end for a custom engine, it is possible that both Renderer and Platform will be handled |
| 206 | + // by the same system and you may not need to use all the UserData/Handle fields. |
| 207 | + // The library never uses those fields, they are merely storage to facilitate back-end implementation. |
| 208 | + |
| 209 | + // TODO: PlatformUserData, PlatformHandle, PlatformHandleRaw |
| 210 | + |
| 211 | + /** |
| 212 | + * Platform window requested move (e.g. window was moved by the OS / host window manager, authoritative position will be OS window position). |
| 213 | + */ |
| 214 | + public native boolean getPlatformRequestMove(); /* |
| 215 | + return IMGUI_VIEWPORT->PlatformRequestMove; |
| 216 | + */ |
| 217 | + |
| 218 | + /** |
| 219 | + * Platform window requested move (e.g. window was moved by the OS / host window manager, authoritative position will be OS window position). |
| 220 | + */ |
| 221 | + public native void setPlatformRequestMove(boolean platformRequestMove); /* |
| 222 | + IMGUI_VIEWPORT->PlatformRequestMove = platformRequestMove; |
| 223 | + */ |
| 224 | + |
| 225 | + /** |
| 226 | + * Platform window requested resize (e.g. window was resized by the OS / host window manager, authoritative size will be OS window size). |
| 227 | + */ |
| 228 | + public native boolean getPlatformRequestResize(); /* |
| 229 | + return IMGUI_VIEWPORT->PlatformRequestResize; |
| 230 | + */ |
| 231 | + |
| 232 | + /** |
| 233 | + * Platform window requested resize (e.g. window was resized by the OS / host window manager, authoritative size will be OS window size). |
| 234 | + */ |
| 235 | + public native void setPlatformRequestResize(boolean platformRequestResize); /* |
| 236 | + IMGUI_VIEWPORT->PlatformRequestResize = platformRequestResize; |
| 237 | + */ |
| 238 | + |
| 239 | + /** |
| 240 | + * Platform window requested closure (e.g. window was moved by the OS / host window manager, e.g. pressing ALT-F4). |
| 241 | + */ |
| 242 | + public native boolean getPlatformRequestClose(); /* |
| 243 | + return IMGUI_VIEWPORT->PlatformRequestClose; |
| 244 | + */ |
| 245 | + |
| 246 | + /** |
| 247 | + * Platform window requested closure (e.g. window was moved by the OS / host window manager, e.g. pressing ALT-F4). |
| 248 | + */ |
| 249 | + public native void setPlatformRequestClose(boolean platformRequestClose); /* |
| 250 | + IMGUI_VIEWPORT->PlatformRequestClose = platformRequestClose; |
| 251 | + */ |
| 252 | + |
| 253 | + // Access work-area rectangle with GetWorkXXX functions (see comments above) |
| 254 | + |
| 255 | + public native void getCenter(ImVec2 dstImVec2); /* |
| 256 | + Jni::ImVec2Cpy(env, IMGUI_VIEWPORT->GetCenter(), dstImVec2); |
| 257 | + */ |
| 258 | + |
| 259 | + public native float getCenterX(); /* |
| 260 | + return IMGUI_VIEWPORT->GetCenter().x; |
| 261 | + */ |
| 262 | + |
| 263 | + public native float getCenterY(); /* |
| 264 | + return IMGUI_VIEWPORT->GetCenter().y; |
| 265 | + */ |
| 266 | + |
| 267 | + public native void getWorkPos(ImVec2 dstImVec2); /* |
| 268 | + Jni::ImVec2Cpy(env, IMGUI_VIEWPORT->GetWorkPos(), dstImVec2); |
| 269 | + */ |
| 270 | + |
| 271 | + public native float getWorkPosX(); /* |
| 272 | + return IMGUI_VIEWPORT->GetWorkPos().x; |
| 273 | + */ |
| 274 | + |
| 275 | + public native float getWorkPosY(); /* |
| 276 | + return IMGUI_VIEWPORT->GetWorkPos().y; |
| 277 | + */ |
| 278 | + |
| 279 | + public native void getWorkSize(ImVec2 dstImVec2); /* |
| 280 | + Jni::ImVec2Cpy(env, IMGUI_VIEWPORT->GetWorkSize(), dstImVec2); |
| 281 | + */ |
| 282 | + |
| 283 | + public native float getWorkSizeX(); /* |
| 284 | + return IMGUI_VIEWPORT->GetWorkSize().x; |
| 285 | + */ |
| 286 | + |
| 287 | + public native float getWorkSizeY(); /* |
| 288 | + return IMGUI_VIEWPORT->GetWorkSize().y; |
| 289 | + */ |
| 290 | +} |
0 commit comments