#include "imgui.h"
struct ImVec2_Pod {
float x, y;
};
struct ImVec4_Pod {
float x, y, z, w;
};
static inline ImVec2_Pod to_pod(const ImVec2& v) {
ImVec2_Pod result;
result.x = v.x;
result.y = v.y;
return result;
}
extern "C" {
#ifdef _MSC_VER
ImVec2_Pod ImGui_GetWindowPos() {
return to_pod(ImGui::GetWindowPos());
}
ImVec2_Pod ImGui_GetWindowSize() {
return to_pod(ImGui::GetWindowSize());
}
ImVec2_Pod ImGui_GetContentRegionAvail() {
return to_pod(ImGui::GetContentRegionAvail());
}
ImVec2_Pod ImGui_GetFontTexUvWhitePixel() {
return to_pod(ImGui::GetFontTexUvWhitePixel());
}
ImVec2_Pod ImGui_GetCursorScreenPos() {
return to_pod(ImGui::GetCursorScreenPos());
}
ImVec2_Pod ImGui_GetCursorPos() {
return to_pod(ImGui::GetCursorPos());
}
ImVec2_Pod ImGui_GetCursorStartPos() {
return to_pod(ImGui::GetCursorStartPos());
}
ImVec2_Pod ImGui_GetItemRectMin() {
return to_pod(ImGui::GetItemRectMin());
}
ImVec2_Pod ImGui_GetItemRectMax() {
return to_pod(ImGui::GetItemRectMax());
}
ImVec2_Pod ImGui_GetItemRectSize() {
return to_pod(ImGui::GetItemRectSize());
}
ImVec2_Pod ImGui_CalcTextSize(const char* text, const char* text_end, bool hide_text_after_double_hash, float wrap_width) {
return to_pod(ImGui::CalcTextSize(text, text_end, hide_text_after_double_hash, wrap_width));
}
ImVec2_Pod ImGui_GetMousePos() {
return to_pod(ImGui::GetMousePos());
}
ImVec2_Pod ImGui_GetMousePosOnOpeningCurrentPopup() {
return to_pod(ImGui::GetMousePosOnOpeningCurrentPopup());
}
ImVec2_Pod ImGui_GetMouseDragDelta(ImGuiMouseButton button, float lock_threshold) {
return to_pod(ImGui::GetMouseDragDelta(button, lock_threshold));
}
#endif
static void (*g_Platform_GetWindowPos_OutParam)(ImGuiViewport*, ImVec2*) = nullptr;
static void (*g_Platform_GetWindowSize_OutParam)(ImGuiViewport*, ImVec2*) = nullptr;
static void (*g_Platform_GetWindowFramebufferScale_OutParam)(ImGuiViewport*, ImVec2*) = nullptr;
static void (*g_Platform_GetWindowWorkAreaInsets_OutParam)(ImGuiViewport*, ImVec4*) = nullptr;
static ImVec2 Platform_GetWindowPos_Thunk(ImGuiViewport* viewport) {
ImVec2 result = ImVec2(0, 0);
if (g_Platform_GetWindowPos_OutParam) {
g_Platform_GetWindowPos_OutParam(viewport, &result);
}
return result;
}
static ImVec2 Platform_GetWindowSize_Thunk(ImGuiViewport* viewport) {
ImVec2 result = ImVec2(800, 600);
if (g_Platform_GetWindowSize_OutParam) {
g_Platform_GetWindowSize_OutParam(viewport, &result);
}
return result;
}
static ImVec2 Platform_GetWindowFramebufferScale_Thunk(ImGuiViewport* viewport) {
ImVec2 result = ImVec2(1.0f, 1.0f);
if (g_Platform_GetWindowFramebufferScale_OutParam) {
g_Platform_GetWindowFramebufferScale_OutParam(viewport, &result);
}
return result;
}
static ImVec4 Platform_GetWindowWorkAreaInsets_Thunk(ImGuiViewport* viewport) {
ImVec4 result = ImVec4(0.0f, 0.0f, 0.0f, 0.0f);
if (g_Platform_GetWindowWorkAreaInsets_OutParam) {
g_Platform_GetWindowWorkAreaInsets_OutParam(viewport, &result);
}
return result;
}
void ImGui_Platform_SetGetWindowPosCallback(void (*callback)(ImGuiViewport*, ImVec2*)) {
g_Platform_GetWindowPos_OutParam = callback;
if (callback) {
ImGui::GetPlatformIO().Platform_GetWindowPos = Platform_GetWindowPos_Thunk;
} else {
ImGui::GetPlatformIO().Platform_GetWindowPos = nullptr;
}
}
void ImGui_Platform_SetGetWindowSizeCallback(void (*callback)(ImGuiViewport*, ImVec2*)) {
g_Platform_GetWindowSize_OutParam = callback;
if (callback) {
ImGui::GetPlatformIO().Platform_GetWindowSize = Platform_GetWindowSize_Thunk;
} else {
ImGui::GetPlatformIO().Platform_GetWindowSize = nullptr;
}
}
void ImGui_Platform_SetGetWindowFramebufferScaleCallback(void (*callback)(ImGuiViewport*, ImVec2*)) {
g_Platform_GetWindowFramebufferScale_OutParam = callback;
if (callback) {
ImGui::GetPlatformIO().Platform_GetWindowFramebufferScale = Platform_GetWindowFramebufferScale_Thunk;
} else {
ImGui::GetPlatformIO().Platform_GetWindowFramebufferScale = nullptr;
}
}
void ImGui_Platform_SetGetWindowWorkAreaInsetsCallback(void (*callback)(ImGuiViewport*, ImVec4*)) {
g_Platform_GetWindowWorkAreaInsets_OutParam = callback;
if (callback) {
ImGui::GetPlatformIO().Platform_GetWindowWorkAreaInsets = Platform_GetWindowWorkAreaInsets_Thunk;
} else {
ImGui::GetPlatformIO().Platform_GetWindowWorkAreaInsets = nullptr;
}
}
}