mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-12 15:59:54 +02:00
Viewport, Platform: Added a way to register monitor bounds to imgui so they can be used to clamp individual-viewport tooltips/popups so they don't straddle monitors. (#1542)
This commit is contained in:
@ -535,6 +535,22 @@ static LRESULT CALLBACK ImGui_ImplWin32_WndProcHandler_PlatformWindow(HWND hWnd,
|
||||
return DefWindowProc(hWnd, msg, wParam, lParam);
|
||||
}
|
||||
|
||||
static BOOL CALLBACK ImGui_ImplWin32_UpdateMonitors_EnumFunc(HMONITOR, HDC, LPRECT rect, LPARAM)
|
||||
{
|
||||
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);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// FIXME-PLATFORM: Update list when changed (WM_DISPLAYCHANGE?)
|
||||
static void ImGui_ImplWin32_UpdateMonitors()
|
||||
{
|
||||
ImGui::GetPlatformData()->Monitors.resize(0);
|
||||
::EnumDisplayMonitors(NULL, NULL, ImGui_ImplWin32_UpdateMonitors_EnumFunc, NULL);
|
||||
}
|
||||
|
||||
static void ImGui_ImplWin32_InitPlatformInterface()
|
||||
{
|
||||
WNDCLASSEX wcex;
|
||||
@ -552,6 +568,8 @@ static void ImGui_ImplWin32_InitPlatformInterface()
|
||||
wcex.hIconSm = NULL;
|
||||
::RegisterClassEx(&wcex);
|
||||
|
||||
ImGui_ImplWin32_UpdateMonitors();
|
||||
|
||||
// Register platform interface (will be coupled with a renderer interface)
|
||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||
platform_io.Platform_CreateWindow = ImGui_ImplWin32_CreateWindow;
|
||||
|
Reference in New Issue
Block a user