Added float GetWindowDpiScale(). (#1542, #1676)

This commit is contained in:
omar 2018-05-23 18:23:58 +02:00
parent ed84b2aaeb
commit 002e513b82
3 changed files with 13 additions and 3 deletions

View File

@ -264,6 +264,8 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
- focus: SetKeyboardFocusHere() on with >= 0 offset could be done on same frame (else latch and modulate on beginning of next frame)
- focus: unable to use SetKeyboardFocusHere() on clipped widgets. (#787)
- examples: move ImGui::NewFrame() out of the backend _NewFrame() ?
- viewport: make it possible to have no main/hosting viewport
- viewport: use getfocus/setfocus api to synchronize imgui<>platform focus better (e.g imgui-side ctrl-tab can focus os window, OS initial setup and alt-tab can focus imgui window etc.)
- viewport: store per-viewport/monitor DPI in .ini file so an application reload or main window changing DPI on reload can be properly patched for.
- viewport: vulkan renderer implementation.

View File

@ -8192,11 +8192,18 @@ ImDrawList* ImGui::GetWindowDrawList()
return window->DrawList;
}
float ImGui::GetWindowDpiScale()
{
ImGuiContext& g = *GImGui;
IM_ASSERT(g.CurrentViewport != NULL);
return g.CurrentViewport->DpiScale;
}
ImGuiViewport* ImGui::GetWindowViewport()
{
ImGuiWindow* window = GetCurrentWindowRead();
IM_ASSERT(window->Viewport != NULL);
return window->Viewport;
ImGuiContext& g = *GImGui;
IM_ASSERT(g.CurrentViewport != NULL && g.CurrentViewport == g.CurrentWindow->Viewport);
return g.CurrentViewport;
}
ImFont* ImGui::GetFont()

View File

@ -197,6 +197,7 @@ namespace ImGui
IMGUI_API bool IsWindowFocused(ImGuiFocusedFlags flags=0); // is current window focused? or its root/child, depending on flags. see flags for options.
IMGUI_API bool IsWindowHovered(ImGuiHoveredFlags flags=0); // is current window hovered (and typically: not blocked by a popup/modal)? see flags for options. NB: If you are trying to check whether your mouse should be dispatched to imgui or to your app, you should use the 'io.WantCaptureMouse' boolean for that! Please read the FAQ!
IMGUI_API ImDrawList* GetWindowDrawList(); // get draw list associated to the current window, to append your own drawing primitives
IMGUI_API float GetWindowDpiScale(); // get DPI scale currently associated to the current window's viewport.
IMGUI_API ImGuiViewport*GetWindowViewport(); // get viewport currently associated to the current window.
IMGUI_API ImVec2 GetWindowPos(); // get current window position in screen space (useful if you want to do your own drawing via the DrawList API)
IMGUI_API ImVec2 GetWindowSize(); // get current window size