mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 20:18:47 +02:00
Viewport: Merged ImGuiPlatformData into ImGuiPlatformIO. Comments. (#1542)
This commit is contained in:
@ -220,10 +220,10 @@ static void ImGui_ImplGlfw_UpdateMouse()
|
||||
g_MouseJustPressed[i] = false;
|
||||
}
|
||||
|
||||
ImGuiPlatformData* platform_data = ImGui::GetPlatformData();
|
||||
for (int n = 0; n < platform_data->Viewports.Size; n++)
|
||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||
for (int n = 0; n < platform_io.Viewports.Size; n++)
|
||||
{
|
||||
ImGuiViewport* viewport = platform_data->Viewports[n];
|
||||
ImGuiViewport* viewport = platform_io.Viewports[n];
|
||||
GLFWwindow* window = (GLFWwindow*)viewport->PlatformHandle;
|
||||
IM_ASSERT(window != NULL);
|
||||
if (glfwGetWindowAttrib(window, GLFW_FOCUSED))
|
||||
@ -522,17 +522,17 @@ static int ImGui_ImplGlfw_CreateVkSurface(ImGuiViewport* viewport, ImU64 vk_inst
|
||||
// FIXME-PLATFORM: Update when changed (using glfwSetMonitorCallback?)
|
||||
static void ImGui_ImplGlfw_UpdateMonitors()
|
||||
{
|
||||
ImGuiPlatformData* platform_data = ImGui::GetPlatformData();
|
||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||
int monitors_count = 0;
|
||||
GLFWmonitor** glfw_monitors = glfwGetMonitors(&monitors_count);
|
||||
platform_data->Monitors.resize(monitors_count);
|
||||
platform_io.Monitors.resize(monitors_count);
|
||||
for (int n = 0; n < monitors_count; n++)
|
||||
{
|
||||
int x, y;
|
||||
glfwGetMonitorPos(glfw_monitors[n], &x, &y);
|
||||
const GLFWvidmode* vid_mode = glfwGetVideoMode(glfw_monitors[n]);
|
||||
platform_data->Monitors[n].Pos = ImVec2((float)x, (float)y);
|
||||
platform_data->Monitors[n].Size = ImVec2((float)vid_mode->width, (float)vid_mode->height);
|
||||
platform_io.Monitors[n].Pos = ImVec2((float)x, (float)y);
|
||||
platform_io.Monitors[n].Size = ImVec2((float)vid_mode->width, (float)vid_mode->height);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -440,15 +440,15 @@ static int ImGui_ImplSDL2_CreateVkSurface(ImGuiViewport* viewport, ImU64 vk_inst
|
||||
// FIXME-PLATFORM: Update when changed?
|
||||
static void ImGui_ImplSDL2_UpdateMonitors()
|
||||
{
|
||||
ImGuiPlatformData* platform_data = ImGui::GetPlatformData();
|
||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||
int display_count = SDL_GetNumVideoDisplays();
|
||||
platform_data->Monitors.resize(display_count);
|
||||
platform_io.Monitors.resize(display_count);
|
||||
for (int n = 0; n < display_count; n++)
|
||||
{
|
||||
SDL_Rect r;
|
||||
SDL_GetDisplayBounds(n, &r);
|
||||
platform_data->Monitors[n].Pos = ImVec2((float)r.x, (float)r.y);
|
||||
platform_data->Monitors[n].Size = ImVec2((float)r.w, (float)r.h);
|
||||
platform_io.Monitors[n].Pos = ImVec2((float)r.x, (float)r.y);
|
||||
platform_io.Monitors[n].Size = ImVec2((float)r.w, (float)r.h);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -408,7 +408,7 @@ static void ImGui_ImplWin32_DestroyWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
if (::GetCapture() == data->Hwnd)
|
||||
{
|
||||
// Transfer capture so if we started dragging from a window that later disappears, we'll still release the MOUSEUP event.
|
||||
// Transfer capture so if we started dragging from a window that later disappears, we'll still receive the MOUSEUP event.
|
||||
::ReleaseCapture();
|
||||
::SetCapture(g_hWnd);
|
||||
}
|
||||
@ -540,14 +540,14 @@ static BOOL CALLBACK ImGui_ImplWin32_UpdateMonitors_EnumFunc(HMONITOR, HDC, LPRE
|
||||
ImGuiPlatformMonitor imgui_monitor;
|
||||
imgui_monitor.Pos = ImVec2((float)rect->left, (float)rect->top);
|
||||
imgui_monitor.Size = ImVec2((float)(rect->right - rect->left), (float)(rect->bottom - rect->top));
|
||||
ImGui::GetPlatformData()->Monitors.push_back(imgui_monitor);
|
||||
ImGui::GetPlatformIO().Monitors.push_back(imgui_monitor);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// FIXME-PLATFORM: Update list when changed (WM_DISPLAYCHANGE?)
|
||||
static void ImGui_ImplWin32_UpdateMonitors()
|
||||
{
|
||||
ImGui::GetPlatformData()->Monitors.resize(0);
|
||||
ImGui::GetPlatformIO().Monitors.resize(0);
|
||||
::EnumDisplayMonitors(NULL, NULL, ImGui_ImplWin32_UpdateMonitors_EnumFunc, NULL);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user