1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:08:13 +00:00

Everywhere: Add -Wdouble-promotion warning

This warning informs of float-to-double conversions. The best solution
seems to be to do math *either* in 32-bit *or* in 64-bit, and only to
cross over when absolutely necessary.
This commit is contained in:
Nicholas-Baron 2021-04-15 00:36:14 -07:00 committed by Andreas Kling
parent 6606d70826
commit 73dd293ec4
26 changed files with 105 additions and 98 deletions

View file

@ -235,9 +235,10 @@ void QSWidget::mousewheel_event(GUI::MouseEvent& event)
// We want the image after scaling to be panned in such a way that the cursor
// will still point to the same image pixel. Basically, we need to solve
// (m_pan_origin + focus_point) / old_scale_factor = (new_m_pan_origin + focus_point) / new_scale_factor.
auto focus_point = Gfx::FloatPoint(
(float)event.x() - (float)width() / 2.0,
(float)event.y() - (float)height() / 2.0);
Gfx::FloatPoint focus_point {
event.x() - width() / 2.0f,
event.y() - height() / 2.0f
};
// A little algebra shows that new m_pan_origin equals to:
m_pan_origin = (m_pan_origin + focus_point) * (new_scale_factor / old_scale_factor) - focus_point;