mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 20:07:01 +00:00
Shallow tidying up ctrl+wheel scaling code in NewFrame()
This commit is contained in:
parent
20a0fde012
commit
4735802096
25
imgui.cpp
25
imgui.cpp
@ -2733,23 +2733,20 @@ void ImGui::NewFrame()
|
|||||||
if (g.HoveredWindow && g.IO.MouseWheel != 0.0f && !g.HoveredWindow->Collapsed)
|
if (g.HoveredWindow && g.IO.MouseWheel != 0.0f && !g.HoveredWindow->Collapsed)
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = g.HoveredWindow;
|
ImGuiWindow* window = g.HoveredWindow;
|
||||||
if (g.IO.KeyCtrl)
|
if (g.IO.KeyCtrl && g.IO.FontAllowUserScaling)
|
||||||
{
|
{
|
||||||
if (g.IO.FontAllowUserScaling)
|
// Zoom / Scale window
|
||||||
{
|
const float new_font_scale = ImClamp(window->FontWindowScale + g.IO.MouseWheel * 0.10f, 0.50f, 2.50f);
|
||||||
// Zoom / Scale window
|
const float scale = new_font_scale / window->FontWindowScale;
|
||||||
float new_font_scale = ImClamp(window->FontWindowScale + g.IO.MouseWheel * 0.10f, 0.50f, 2.50f);
|
window->FontWindowScale = new_font_scale;
|
||||||
float scale = new_font_scale / window->FontWindowScale;
|
|
||||||
window->FontWindowScale = new_font_scale;
|
|
||||||
|
|
||||||
const ImVec2 offset = window->Size * (1.0f - scale) * (g.IO.MousePos - window->Pos) / window->Size;
|
const ImVec2 offset = window->Size * (1.0f - scale) * (g.IO.MousePos - window->Pos) / window->Size;
|
||||||
window->Pos += offset;
|
window->Pos += offset;
|
||||||
window->PosFloat += offset;
|
window->PosFloat += offset;
|
||||||
window->Size *= scale;
|
window->Size *= scale;
|
||||||
window->SizeFull *= scale;
|
window->SizeFull *= scale;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (!(window->Flags & ImGuiWindowFlags_NoScrollWithMouse))
|
else if (!g.IO.KeyCtrl && !(window->Flags & ImGuiWindowFlags_NoScrollWithMouse))
|
||||||
{
|
{
|
||||||
// Scroll
|
// Scroll
|
||||||
const int scroll_lines = (window->Flags & ImGuiWindowFlags_ComboBox) ? 3 : 5;
|
const int scroll_lines = (window->Flags & ImGuiWindowFlags_ComboBox) ? 3 : 5;
|
||||||
|
Loading…
Reference in New Issue
Block a user