QuickShow: Fix for zooming with mouse wheel (#2650)

Fixes #2648.
This commit is contained in:
Hüseyin ASLITÜRK 2020-06-28 01:04:11 +03:00 committed by GitHub
parent 8d2194bdbd
commit d28a824d4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: sideshowbarker 2024-07-19 05:21:04 +09:00

View file

@ -221,16 +221,18 @@ void QSWidget::mousemove_event(GUI::MouseEvent& event)
void QSWidget::mousewheel_event(GUI::MouseEvent& event)
{
auto old_scale = m_scale;
int new_scale = m_scale - event.wheel_delta() * 10;
if (new_scale < 10)
new_scale = 10;
if (new_scale > 1000)
new_scale = 1000;
if (new_scale == m_scale) {
return;
}
auto old_scale_factor = (float)m_scale / 100.0f;
m_scale += -event.wheel_delta() * 10;
if (m_scale < 10)
m_scale = 10;
if (m_scale > 1000)
m_scale = 1000;
auto new_scale_factor = (float)m_scale / 100.0f;
auto new_scale_factor = (float)new_scale / 100.0f;
auto focus_point = Gfx::FloatPoint(
m_pan_origin.x() - ((float)event.x() - (float)width() / 2.0) / old_scale_factor,
@ -240,9 +242,7 @@ void QSWidget::mousewheel_event(GUI::MouseEvent& event)
focus_point.x() - new_scale_factor / old_scale_factor * (focus_point.x() - m_pan_origin.x()),
focus_point.y() - new_scale_factor / old_scale_factor * (focus_point.y() - m_pan_origin.y()));
if (old_scale != m_scale) {
relayout();
}
set_scale(new_scale);
}
void QSWidget::load_from_file(const String& path)