summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Nelson <peter1138@openttd.org>2019-02-14 06:26:29 +0000
committerCharles Pigott <charlespigott@googlemail.com>2019-02-21 08:11:35 +0000
commit6dfe36b5cde442b40208e1cebb4b2c7b2f08a4b1 (patch)
tree73f877fc8e4abef21b3428c79ba51b0366ade3aa /src
parentde9f54ccc185d35727858a36fcebc82178c519c6 (diff)
downloadopenttd-6dfe36b5cde442b40208e1cebb4b2c7b2f08a4b1.tar.xz
Change: Make volume slider widget capture mouse when clicked.
This makes the slider continue to respond even when mouse cursor is no longer over the widget.
Diffstat (limited to 'src')
-rw-r--r--src/music_gui.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/music_gui.cpp b/src/music_gui.cpp
index 87a073b0a..885647427 100644
--- a/src/music_gui.cpp
+++ b/src/music_gui.cpp
@@ -799,7 +799,7 @@ struct MusicWindow : public Window {
byte *vol = (widget == WID_M_MUSIC_VOL) ? &_settings_client.music.music_vol : &_settings_client.music.effect_vol;
- byte new_vol = x * 127 / this->GetWidget<NWidgetBase>(widget)->current_x;
+ byte new_vol = Clamp(x * 127 / (int)this->GetWidget<NWidgetBase>(widget)->current_x, 0, 127);
if (_current_text_dir == TD_RTL) new_vol = 127 - new_vol;
/* Clamp to make sure min and max are properly settable */
if (new_vol > 124) new_vol = 127;
@@ -810,7 +810,7 @@ struct MusicWindow : public Window {
this->SetDirty();
}
- _left_button_clicked = false;
+ if (click_count > 0) this->mouse_capture_widget = widget;
break;
}