[API] Add ImGuiPlatformMonitor

This commit is contained in:
SpaiR committed 2020-08-30 23:04:05 +03:00
1 parent b065d004f7
commit 13c3a28f09
3 files changed
+165

No files matched your search

@@ -72,6 +72,7 @@ import imgui.callback.ImPlatformFuncViewportSuppImVec2;
public final class ImGuiPlatformIO extends ImGuiStruct {
private static final ImGuiViewport MAIN_VIEWPORT = new ImGuiViewport(0);
private static final ImGuiViewport TMP_VIEWPORT = new ImGuiViewport(0);
private static final ImGuiPlatformMonitor TMP_MONITOR = new ImGuiPlatformMonitor(0);
private static final ImVec2 TMP_IM_VEC2 = new ImVec2();
public ImGuiPlatformIO(final long ptr) {
@@ -517,6 +518,15 @@ public final class ImGuiPlatformIO extends ImGuiStruct {
IMGUI_PLATFORM_IO->Monitors.push_back(monitor);
*/
public ImGuiPlatformMonitor getMonitors(final int idx) {
TMP_MONITOR.ptr = nGetMonitors(idx);
return TMP_MONITOR;
}
private native long nGetMonitors(int idx); /*
return (intptr_t)&IMGUI_PLATFORM_IO->Monitors[idx];
*/
// Viewports list (the list is updated by calling ImGui::EndFrame or ImGui::Render)
// (in the future we will attempt to organize this feature to remove the need for a "main viewport")
@@ -0,0 +1,153 @@
package imgui;
import imgui.binding.ImGuiStruct;
/**
* (Optional) This is required when enabling multi-viewport. Represent the bounds of each connected monitor/display and their DPI.
* We use this information for multiple DPI support + clamping the position of popups and tooltips so they don't straddle multiple monitors.
*/
public final class ImGuiPlatformMonitor extends ImGuiStruct {
public ImGuiPlatformMonitor(final long ptr) {
super(ptr);
}
/*JNI
#include <stdint.h>
#include <imgui.h>
#include "jni_common.h"
#include "jni_binding_struct.h"
#define IMGUI_PLATFORM_MONITOR ((ImGuiPlatformMonitor*)STRUCT_PTR)
*/
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public native void getMainPos(ImVec2 dstImVec2); /*
Jni::ImVec2Cpy(env, &IMGUI_PLATFORM_MONITOR->MainPos, dstImVec2);
*/
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public native float getMainPosX(); /*
return IMGUI_PLATFORM_MONITOR->MainPos.x;
*/
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public native float getMainPosY(); /*
return IMGUI_PLATFORM_MONITOR->MainPos.y;
*/
public native void setMainPos(float x, float y); /*
IMGUI_PLATFORM_MONITOR->MainPos = ImVec2(x, y);
*/
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public native void getMainSize(ImVec2 dstImVec2); /*
Jni::ImVec2Cpy(env, &IMGUI_PLATFORM_MONITOR->MainSize, dstImVec2);
*/
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public native float getMainSizeX(); /*
return IMGUI_PLATFORM_MONITOR->MainSize.x;
*/
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public native float getMainSizeY(); /*
return IMGUI_PLATFORM_MONITOR->MainSize.y;
*/
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public native void setMainSize(float x, float y); /*
IMGUI_PLATFORM_MONITOR->MainSize = ImVec2(x, y);
*/
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public native void getWorkPos(ImVec2 dstImVec2); /*
Jni::ImVec2Cpy(env, &IMGUI_PLATFORM_MONITOR->WorkPos, dstImVec2);
*/
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public native float getWorkPosX(); /*
return IMGUI_PLATFORM_MONITOR->WorkPos.x;
*/
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public native float getWorkPosY(); /*
return IMGUI_PLATFORM_MONITOR->WorkPos.y;
*/
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public native void setWorkPos(float x, float y); /*
IMGUI_PLATFORM_MONITOR->WorkPos = ImVec2(x, y);
*/
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public native void getWorkSize(ImVec2 dstImVec2); /*
Jni::ImVec2Cpy(env, &IMGUI_PLATFORM_MONITOR->WorkSize, dstImVec2);
*/
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public native float getWorkSizeX(); /*
return IMGUI_PLATFORM_MONITOR->WorkSize.x;
*/
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public native float getWorkSizeY(); /*
return IMGUI_PLATFORM_MONITOR->WorkSize.y;
*/
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public native void setWorkSize(float x, float y); /*
IMGUI_PLATFORM_MONITOR->WorkSize = ImVec2(x, y);
*/
/**
* 1.0f = 96 DPI
*/
public native float getDpiScale(); /*
return IMGUI_PLATFORM_MONITOR->DpiScale;
*/
/**
* 1.0f = 96 DPI
*/
public native void setDpiScale(float dpiScale); /*
IMGUI_PLATFORM_MONITOR->DpiScale = dpiScale;
*/
}
@@ -70,6 +70,7 @@ public class ImGuiImplGlfw {
private final int[] windowX = new int[1];
private final int[] windowY = new int[1];
// Monitor properties
private final int[] monitorX = new int[1];
private final int[] monitorY = new int[1];
private final int[] monitorWorkAreaX = new int[1];
@@ -86,6 +87,7 @@ public class ImGuiImplGlfw {
private GLFWCharCallback prevUserCallbackChar = null;
private GLFWMonitorCallback prevUserCallbackMonitor = null;
// Internal data
private boolean callbacksInstalled = false;
private boolean wantUpdateMonitors = true;
private double time = 0.0;