summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNiels Martin Hansen <nielsm@indvikleren.dk>2020-01-05 15:20:18 +0100
committerNiels Martin Hansen <nielsm@indvikleren.dk>2020-01-07 18:13:58 +0100
commitf02b643a4490b7e84990836a8820552a20b0ac51 (patch)
tree936d40836246200892aed960492c02b794573ea0 /src
parent35c55dfe70767204597aeada2b3676825ce2bacc (diff)
downloadopenttd-f02b643a4490b7e84990836a8820552a20b0ac51.tar.xz
Change: Show volume sliders with wedges instead of boxy slider
Diffstat (limited to 'src')
-rw-r--r--src/music_gui.cpp43
1 files changed, 18 insertions, 25 deletions
diff --git a/src/music_gui.cpp b/src/music_gui.cpp
index 269bb7f3c..7bae6dc1e 100644
--- a/src/music_gui.cpp
+++ b/src/music_gui.cpp
@@ -743,12 +743,23 @@ struct MusicWindow : public Window {
}
case WID_M_MUSIC_VOL: case WID_M_EFFECT_VOL: {
- int sw = ScaleGUITrad(slider_width);
- int hsw = sw / 2;
- DrawFrameRect(r.left + hsw, r.top + 2, r.right - hsw, r.bottom - 2, COLOUR_GREY, FR_LOWERED);
+ /* Draw a wedge indicating low to high volume level. */
+ const int ha = (r.bottom - r.top) / 5;
+ int wx1 = r.left, wx2 = r.right;
+ if (_current_text_dir == TD_RTL) std::swap(wx1, wx2);
+ const uint shadow = _colour_gradient[COLOUR_GREY][3];
+ const uint fill = _colour_gradient[COLOUR_GREY][6];
+ const uint light = _colour_gradient[COLOUR_GREY][7];
+ const std::vector<Point> wedge{ Point{wx1, r.bottom - ha}, Point{wx2, r.top + ha}, Point{wx2, r.bottom - ha} };
+ GfxFillPolygon(wedge, fill);
+ GfxDrawLine(wedge[0].x, wedge[0].y, wedge[2].x, wedge[2].y, light);
+ GfxDrawLine(wedge[1].x, wedge[1].y, wedge[2].x, wedge[2].y, _current_text_dir == TD_RTL ? shadow : light);
+ GfxDrawLine(wedge[0].x, wedge[0].y, wedge[1].x, wedge[1].y, shadow);
+ /* Draw a slider handle indicating current volume level. */
+ const int sw = ScaleGUITrad(slider_width);
byte volume = (widget == WID_M_MUSIC_VOL) ? _settings_client.music.music_vol : _settings_client.music.effect_vol;
if (_current_text_dir == TD_RTL) volume = 127 - volume;
- int x = r.left + (volume * (r.right - r.left - sw) / 127);
+ const int x = r.left + (volume * (r.right - r.left - sw) / 127);
DrawFrameRect(x, r.top, x + sw, r.bottom, COLOUR_GREY, FR_NONE);
break;
}
@@ -853,32 +864,14 @@ static const NWidgetPart _nested_music_window_widgets[] = {
NWidget(WWT_PANEL, COLOUR_GREY, -1), SetFill(1, 1), EndContainer(),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_GREY, WID_M_SLIDERS),
- NWidget(NWID_HORIZONTAL), SetPIP(20, 20, 20),
+ NWidget(NWID_HORIZONTAL), SetPIP(4, 0, 4),
NWidget(NWID_VERTICAL),
NWidget(WWT_LABEL, COLOUR_GREY, -1), SetFill(1, 0), SetDataTip(STR_MUSIC_MUSIC_VOLUME, STR_NULL),
- NWidget(WWT_EMPTY, COLOUR_GREY, WID_M_MUSIC_VOL), SetMinimalSize(67, 0), SetMinimalTextLines(1, 0), SetFill(1, 0), SetDataTip(0x0, STR_MUSIC_TOOLTIP_DRAG_SLIDERS_TO_SET_MUSIC),
- NWidget(NWID_HORIZONTAL),
- NWidget(WWT_LABEL, COLOUR_GREY, -1), SetDataTip(STR_MUSIC_RULER_MIN, STR_NULL),
- NWidget(WWT_LABEL, COLOUR_GREY, -1), SetDataTip(STR_MUSIC_RULER_MARKER, STR_NULL), SetFill(1, 0),
- NWidget(WWT_LABEL, COLOUR_GREY, -1), SetDataTip(STR_MUSIC_RULER_MARKER, STR_NULL), SetFill(1, 0),
- NWidget(WWT_LABEL, COLOUR_GREY, -1), SetDataTip(STR_MUSIC_RULER_MARKER, STR_NULL), SetFill(1, 0),
- NWidget(WWT_LABEL, COLOUR_GREY, -1), SetDataTip(STR_MUSIC_RULER_MARKER, STR_NULL), SetFill(1, 0),
- NWidget(WWT_LABEL, COLOUR_GREY, -1), SetDataTip(STR_MUSIC_RULER_MARKER, STR_NULL), SetFill(1, 0),
- NWidget(WWT_LABEL, COLOUR_GREY, -1), SetDataTip(STR_MUSIC_RULER_MAX, STR_NULL),
- EndContainer(),
+ NWidget(WWT_EMPTY, COLOUR_GREY, WID_M_MUSIC_VOL), SetMinimalSize(67, 0), SetPadding(2), SetMinimalTextLines(1, 0), SetFill(1, 0), SetDataTip(0x0, STR_MUSIC_TOOLTIP_DRAG_SLIDERS_TO_SET_MUSIC),
EndContainer(),
NWidget(NWID_VERTICAL),
NWidget(WWT_LABEL, COLOUR_GREY, -1), SetFill(1, 0), SetDataTip(STR_MUSIC_EFFECTS_VOLUME, STR_NULL),
- NWidget(WWT_EMPTY, COLOUR_GREY, WID_M_EFFECT_VOL), SetMinimalSize(67, 0), SetMinimalTextLines(1, 0), SetFill(1, 0), SetDataTip(0x0, STR_MUSIC_TOOLTIP_DRAG_SLIDERS_TO_SET_MUSIC),
- NWidget(NWID_HORIZONTAL),
- NWidget(WWT_LABEL, COLOUR_GREY, -1), SetDataTip(STR_MUSIC_RULER_MIN, STR_NULL),
- NWidget(WWT_LABEL, COLOUR_GREY, -1), SetDataTip(STR_MUSIC_RULER_MARKER, STR_NULL), SetFill(1, 0),
- NWidget(WWT_LABEL, COLOUR_GREY, -1), SetDataTip(STR_MUSIC_RULER_MARKER, STR_NULL), SetFill(1, 0),
- NWidget(WWT_LABEL, COLOUR_GREY, -1), SetDataTip(STR_MUSIC_RULER_MARKER, STR_NULL), SetFill(1, 0),
- NWidget(WWT_LABEL, COLOUR_GREY, -1), SetDataTip(STR_MUSIC_RULER_MARKER, STR_NULL), SetFill(1, 0),
- NWidget(WWT_LABEL, COLOUR_GREY, -1), SetDataTip(STR_MUSIC_RULER_MARKER, STR_NULL), SetFill(1, 0),
- NWidget(WWT_LABEL, COLOUR_GREY, -1), SetDataTip(STR_MUSIC_RULER_MAX, STR_NULL),
- EndContainer(),
+ NWidget(WWT_EMPTY, COLOUR_GREY, WID_M_EFFECT_VOL), SetMinimalSize(67, 0), SetPadding(2), SetMinimalTextLines(1, 0), SetFill(1, 0), SetDataTip(0x0, STR_MUSIC_TOOLTIP_DRAG_SLIDERS_TO_SET_MUSIC),
EndContainer(),
EndContainer(),
EndContainer(),