mirror of
https://github.com/ocornut/imgui.git
synced 2025-02-13 09:12:38 +01:00
Internals: merge ScaleWindowsInViewport() from docking branch.
This commit is contained in:
parent
2a600bddcb
commit
18929bd6d6
19
imgui.cpp
19
imgui.cpp
@ -14788,6 +14788,7 @@ void ImGui::LocalizeRegisterEntries(const ImGuiLocEntry* entries, int count)
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// - GetMainViewport()
|
// - GetMainViewport()
|
||||||
// - SetWindowViewport() [Internal]
|
// - SetWindowViewport() [Internal]
|
||||||
|
// - ScaleWindowsInViewport() [Internal]
|
||||||
// - UpdateViewportsNewFrame() [Internal]
|
// - UpdateViewportsNewFrame() [Internal]
|
||||||
// (this section is more complete in the 'docking' branch)
|
// (this section is more complete in the 'docking' branch)
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -14803,6 +14804,24 @@ void ImGui::SetWindowViewport(ImGuiWindow* window, ImGuiViewportP* viewport)
|
|||||||
window->Viewport = viewport;
|
window->Viewport = viewport;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ScaleWindow(ImGuiWindow* window, float scale)
|
||||||
|
{
|
||||||
|
ImVec2 origin = window->Viewport->Pos;
|
||||||
|
window->Pos = ImFloor((window->Pos - origin) * scale + origin);
|
||||||
|
window->Size = ImTrunc(window->Size * scale);
|
||||||
|
window->SizeFull = ImTrunc(window->SizeFull * scale);
|
||||||
|
window->ContentSize = ImTrunc(window->ContentSize * scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scale all windows (position, size). Use when e.g. changing DPI. (This is a lossy operation!)
|
||||||
|
void ImGui::ScaleWindowsInViewport(ImGuiViewportP* viewport, float scale)
|
||||||
|
{
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
|
for (ImGuiWindow* window : g.Windows)
|
||||||
|
if (window->Viewport == viewport)
|
||||||
|
ScaleWindow(window, scale);
|
||||||
|
}
|
||||||
|
|
||||||
// Update viewports and monitor infos
|
// Update viewports and monitor infos
|
||||||
static void ImGui::UpdateViewportsNewFrame()
|
static void ImGui::UpdateViewportsNewFrame()
|
||||||
{
|
{
|
||||||
|
@ -3020,6 +3020,7 @@ namespace ImGui
|
|||||||
IMGUI_API void CallContextHooks(ImGuiContext* context, ImGuiContextHookType type);
|
IMGUI_API void CallContextHooks(ImGuiContext* context, ImGuiContextHookType type);
|
||||||
|
|
||||||
// Viewports
|
// Viewports
|
||||||
|
IMGUI_API void ScaleWindowsInViewport(ImGuiViewportP* viewport, float scale);
|
||||||
IMGUI_API void SetWindowViewport(ImGuiWindow* window, ImGuiViewportP* viewport);
|
IMGUI_API void SetWindowViewport(ImGuiWindow* window, ImGuiViewportP* viewport);
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
|
Loading…
x
Reference in New Issue
Block a user