1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-21 19:32:54 +01:00

Fix: Zoom-scroll extra viewports only if the mouse cursor is over the viewport. (#14209)

This commit is contained in:
Peter Nelson
2025-05-04 14:16:05 +01:00
committed by GitHub
parent afc1e76575
commit 3e608b5fe4
9 changed files with 23 additions and 13 deletions

View File

@@ -1857,16 +1857,15 @@ public:
return true;
}
void OnMouseWheel(int wheel) override
void OnMouseWheel(int wheel, WidgetID widget) override
{
if (widget != WID_SM_MAP) return;
if (_settings_client.gui.scrollwheel_scrolling != SWS_OFF) {
const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_SM_MAP);
int cursor_x = _cursor.pos.x - this->left - wid->pos_x;
int cursor_y = _cursor.pos.y - this->top - wid->pos_y;
if (IsInsideMM(cursor_x, 0, wid->current_x) && IsInsideMM(cursor_y, 0, wid->current_y)) {
Point pt = {cursor_x, cursor_y};
this->SetZoomLevel((wheel < 0) ? ZLC_ZOOM_IN : ZLC_ZOOM_OUT, &pt);
}
Point pt = {cursor_x, cursor_y};
this->SetZoomLevel((wheel < 0) ? ZLC_ZOOM_IN : ZLC_ZOOM_OUT, &pt);
}
}