1
0
Fork 0

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

pull/14211/head
Peter Nelson 2025-05-04 14:16:05 +01:00 committed by GitHub
parent afc1e76575
commit 3e608b5fe4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 23 additions and 13 deletions

View File

@ -361,8 +361,9 @@ struct IConsoleWindow : Window
return GetCharAtPosition(_iconsole_cmdline.GetText(), pt.x - delta);
}
void OnMouseWheel(int wheel) override
void OnMouseWheel(int wheel, WidgetID widget) override
{
if (widget != WID_C_BACKGROUND) return;
this->Scroll(-wheel);
}

View File

@ -1131,8 +1131,9 @@ public:
}
}
void OnMouseWheel(int wheel) override
void OnMouseWheel(int wheel, WidgetID widget) override
{
if (widget != WID_IV_VIEWPORT) return;
if (_settings_client.gui.scrollwheel_scrolling != SWS_OFF) {
DoZoomInOutWindow(wheel < 0 ? ZOOM_IN : ZOOM_OUT, this);
}

View File

@ -433,8 +433,9 @@ struct MainWindow : Window
this->refresh_timeout.Reset();
}
void OnMouseWheel(int wheel) override
void OnMouseWheel(int wheel, WidgetID widget) override
{
if (widget != WID_M_VIEWPORT) return;
if (_settings_client.gui.scrollwheel_scrolling != SWS_OFF) {
bool in = wheel < 0;

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);
}
}

View File

@ -577,8 +577,9 @@ public:
}
}
void OnMouseWheel(int wheel) override
void OnMouseWheel(int wheel, WidgetID widget) override
{
if (widget != WID_TV_VIEWPORT) return;
if (_settings_client.gui.scrollwheel_scrolling != SWS_OFF) {
DoZoomInOutWindow(wheel < 0 ? ZOOM_IN : ZOOM_OUT, this);
}

View File

@ -3332,8 +3332,9 @@ public:
}
}
void OnMouseWheel(int wheel) override
void OnMouseWheel(int wheel, WidgetID widget) override
{
if (widget != WID_VV_VIEWPORT) return;
if (_settings_client.gui.scrollwheel_scrolling != SWS_OFF) {
DoZoomInOutWindow(wheel < 0 ? ZOOM_IN : ZOOM_OUT, this);
}

View File

@ -124,8 +124,9 @@ public:
return widget == WID_EV_VIEWPORT;
}
void OnMouseWheel(int wheel) override
void OnMouseWheel(int wheel, WidgetID widget) override
{
if (widget != WID_EV_VIEWPORT) return;
if (_settings_client.gui.scrollwheel_scrolling != SWS_OFF) {
ZoomInOrOutToCursorWindow(wheel < 0, this);
}

View File

@ -2823,7 +2823,11 @@ static void MouseLoop(MouseClick click, int mousewheel)
if (mousewheel != 0) {
/* Send mousewheel event to window, unless we're scrolling a viewport or the map */
if (!scrollwheel_scrolling || (vp == nullptr && w->window_class != WC_SMALLMAP)) w->OnMouseWheel(mousewheel);
if (!scrollwheel_scrolling || (vp == nullptr && w->window_class != WC_SMALLMAP)) {
if (NWidgetCore *nwid = w->nested_root->GetWidgetFromPos(x - w->left, y - w->top); nwid != nullptr) {
w->OnMouseWheel(mousewheel, nwid->GetIndex());
}
}
/* Dispatch a MouseWheelEvent for widgets if it is not a viewport */
if (vp == nullptr) DispatchMouseWheelEvent(w, w->nested_root->GetWidgetFromPos(x - w->left, y - w->top), mousewheel);

View File

@ -720,8 +720,9 @@ public:
/**
* The mouse wheel has been turned.
* @param wheel the amount of movement of the mouse wheel.
* @param widget the widget the mouse hovers over.
*/
virtual void OnMouseWheel([[maybe_unused]] int wheel) {}
virtual void OnMouseWheel([[maybe_unused]] int wheel, [[maybe_unused]] WidgetID widget) {}
/**