mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-11 00:04:24 +00:00
Merge pull request #92 from memononen/master
Smoother mouse wheel scrolling
This commit is contained in:
commit
31654958f9
3 changed files with 6 additions and 7 deletions
|
|
@ -1433,16 +1433,15 @@ void ImGui::NewFrame()
|
|||
g.IO.WantCaptureKeyboard = (g.ActiveId != 0);
|
||||
|
||||
// Scale & Scrolling
|
||||
if (g.HoveredWindow && g.IO.MouseWheel != 0)
|
||||
if (g.HoveredWindow && g.IO.MouseWheel != 0.0f)
|
||||
{
|
||||
ImGuiWindow* window = g.HoveredWindow;
|
||||
const int mouse_wheel_dir = g.IO.MouseWheel > 0 ? +1 : -1;
|
||||
if (g.IO.KeyCtrl)
|
||||
{
|
||||
if (g.IO.FontAllowUserScaling)
|
||||
{
|
||||
// Zoom / Scale window
|
||||
float new_font_scale = ImClamp(window->FontWindowScale + mouse_wheel_dir * 0.10f, 0.50f, 2.50f);
|
||||
float new_font_scale = ImClamp(window->FontWindowScale + g.IO.MouseWheel * 0.10f, 0.50f, 2.50f);
|
||||
float scale = new_font_scale / window->FontWindowScale;
|
||||
window->FontWindowScale = new_font_scale;
|
||||
|
||||
|
|
@ -1457,7 +1456,7 @@ void ImGui::NewFrame()
|
|||
{
|
||||
// Scroll
|
||||
const int scroll_lines = (window->Flags & ImGuiWindowFlags_ComboBox) ? 3 : 5;
|
||||
window->NextScrollY -= mouse_wheel_dir * window->FontSize() * scroll_lines;
|
||||
window->NextScrollY -= g.IO.MouseWheel * window->FontSize() * scroll_lines;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1607,7 +1606,7 @@ void ImGui::Render()
|
|||
g.Windows.swap(sorted_windows);
|
||||
|
||||
// Clear data for next frame
|
||||
g.IO.MouseWheel = 0;
|
||||
g.IO.MouseWheel = 0.0f;
|
||||
memset(g.IO.InputCharacters, 0, sizeof(g.IO.InputCharacters));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue