fixed cursor zooming algorithm

What the hell is this? How did I write this old algorithm? Did it even work?
This commit is contained in:
itsmattkc
2021-01-22 19:52:05 +11:00
parent 78ed7213c8
commit 03d31b2225
2 changed files with 17 additions and 2 deletions
+2 -2
View File
@@ -302,7 +302,7 @@ bool TimeBasedView::HandleZoomFromScroll(QWheelEvent *event)
if (!only_vertical) {
double new_x_scale = GetScale() * scale_multiplier;
int new_x_scroll = qRound(horizontalScrollBar()->value() / GetScale() * new_x_scale + (cursor_pos.x() - cursor_pos.x() / new_x_scale * GetScale()));
int new_x_scroll = qRound(double(cursor_pos.x() + horizontalScrollBar()->value()) / GetScale() * new_x_scale - cursor_pos.x());
emit ScaleChanged(new_x_scale);
@@ -312,7 +312,7 @@ bool TimeBasedView::HandleZoomFromScroll(QWheelEvent *event)
if (!only_horizontal) {
double new_y_scale = GetYScale() * scale_multiplier;
int new_y_scroll = qRound(verticalScrollBar()->value() / GetYScale() * new_y_scale + (cursor_pos.y() - cursor_pos.y() / new_y_scale * GetYScale()));
int new_y_scroll = qRound(double(cursor_pos.y() + verticalScrollBar()->value()) / GetYScale() * new_y_scale - cursor_pos.y());
SetYScale(new_y_scale);