mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-30 09:59:10 +00:00
Codechange: Change scrolling_scrollbar to mouse_capture_widget, and dispatch OnClick() event if widget is not a scrollbar.
This allows any widget to support mouse capture.
This commit is contained in:
@@ -99,7 +99,7 @@ static void ScrollbarClickPositioning(Window *w, NWidgetScrollbar *sb, int x, in
|
||||
_scroller_click_timeout = 3;
|
||||
sb->UpdatePosition(rtl ? 1 : -1);
|
||||
}
|
||||
w->scrolling_scrollbar = sb->index;
|
||||
w->mouse_capture_widget = sb->index;
|
||||
} else if (pos >= ma - button_size) {
|
||||
/* Pressing the lower button? */
|
||||
SetBit(sb->disp_flags, NDB_SCROLLBAR_DOWN);
|
||||
@@ -108,7 +108,7 @@ static void ScrollbarClickPositioning(Window *w, NWidgetScrollbar *sb, int x, in
|
||||
_scroller_click_timeout = 3;
|
||||
sb->UpdatePosition(rtl ? -1 : 1);
|
||||
}
|
||||
w->scrolling_scrollbar = sb->index;
|
||||
w->mouse_capture_widget = sb->index;
|
||||
} else {
|
||||
Point pt = HandleScrollbarHittest(sb, mi, ma, sb->type == NWID_HSCROLLBAR);
|
||||
|
||||
@@ -119,7 +119,7 @@ static void ScrollbarClickPositioning(Window *w, NWidgetScrollbar *sb, int x, in
|
||||
} else {
|
||||
_scrollbar_start_pos = pt.x - mi - button_size;
|
||||
_scrollbar_size = ma - mi - button_size * 2;
|
||||
w->scrolling_scrollbar = sb->index;
|
||||
w->mouse_capture_widget = sb->index;
|
||||
_cursorpos_drag_start = _cursor.pos;
|
||||
}
|
||||
}
|
||||
@@ -2038,7 +2038,7 @@ void NWidgetScrollbar::Draw(const Window *w)
|
||||
|
||||
bool up_lowered = HasBit(this->disp_flags, NDB_SCROLLBAR_UP);
|
||||
bool down_lowered = HasBit(this->disp_flags, NDB_SCROLLBAR_DOWN);
|
||||
bool middle_lowered = !(this->disp_flags & ND_SCROLLBAR_BTN) && w->scrolling_scrollbar == this->index;
|
||||
bool middle_lowered = !(this->disp_flags & ND_SCROLLBAR_BTN) && w->mouse_capture_widget == this->index;
|
||||
|
||||
if (this->type == NWID_HSCROLLBAR) {
|
||||
DrawHorizontalScrollbar(r, this->colour, up_lowered, middle_lowered, down_lowered, this);
|
||||
|
Reference in New Issue
Block a user