From 97a063884560edeea90f02cfd7a38631d6187128 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Thu, 1 Feb 2018 18:21:57 +0100 Subject: [PATCH] Added (fixed) tickmark intervals to SliderWidget --- src/emucore/FrameBuffer.cxx | 12 ++++++------ src/gui/DeveloperDialog.cxx | 1 + src/gui/VideoDialog.cxx | 1 + src/gui/Widget.cxx | 34 +++++++++++++++++++++++++++++++++- src/gui/Widget.hxx | 3 +++ 5 files changed, 44 insertions(+), 7 deletions(-) diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index 1554ddd94..b80bcfc5b 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -1008,11 +1008,11 @@ void FrameBuffer::VideoModeList::setZoom(uInt32 zoom) kScrollColor Normal scrollbar color kScrollColorHi Highlighted scrollbar color *** Slider colors *** - kSliderColor, - kSliderColorHi - kSliderBGColor - kSliderBGColorHi - kSliderBGColorLo, + kSliderColor Enabled slider + kSliderColorHi Focussed slider + kSliderBGColor Enabled slider background + kSliderBGColorHi Focussed slider background + kSliderBGColorLo Disabled slider background *** Debugger colors *** kDbgChangedColor Background color for changed cells kDbgChangedTextColor Text color for changed cells @@ -1055,7 +1055,7 @@ uInt32 FrameBuffer::ourGUIColors[3][kNumColors-256] = { 0xe1e1e1, 0xe5f1fb, 0x808080, 0x0078d7, 0x000000, 0x000000, // buttons 0x333333, // checkbox 0xc0c0c0, 0x808080, // scrollbar - 0x333333, 0x0078d7, 0xc0c0c0, 0x808080, 0xe1e1e1, // slider + 0x333333, 0x0078d7, 0xc0c0c0, 0xffffff, 0xc0c0c0, // slider 0xBDDEF9| 0xe1e1e1 | 0xffffff 0xffc0c0, 0x000000, 0xe00000, 0xc00000, // debugger 0xffffff, 0x333333, 0xf0f0f0, 0x808080, 0xc0c0c0 // other } diff --git a/src/gui/DeveloperDialog.cxx b/src/gui/DeveloperDialog.cxx index b1f2b4883..bacf28358 100644 --- a/src/gui/DeveloperDialog.cxx +++ b/src/gui/DeveloperDialog.cxx @@ -205,6 +205,7 @@ void DeveloperDialog::addVideoTab(const GUI::Font& font) myTVJitterWidget->getRight() + fontWidth * 3, ypos - 1, "Recovery ", 0, kTVJitterChanged); myTVJitterRecWidget->setMinValue(1); myTVJitterRecWidget->setMaxValue(20); + myTVJitterRecWidget->setTickmarkInterval(5); wid.push_back(myTVJitterRecWidget); myTVJitterRecLabelWidget = new StaticTextWidget(myTab, font, myTVJitterRecWidget->getRight() + 4, diff --git a/src/gui/VideoDialog.cxx b/src/gui/VideoDialog.cxx index 5db0df12b..70636d052 100644 --- a/src/gui/VideoDialog.cxx +++ b/src/gui/VideoDialog.cxx @@ -94,6 +94,7 @@ VideoDialog::VideoDialog(OSystem& osystem, DialogContainer& parent, SliderWidget* s = new SliderWidget(myTab, font, xpos, ypos - 1, swidth, lineHeight, "TIA zoom", lwidth, 0, fontWidth * 4, "%"); s->setMinValue(200); s->setMaxValue(500); + s->setTickmarkInterval(3); // just for testing now; TODO: remove or redefine wid.push_back(s); ypos += lineHeight + VGAP; diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index d8501bf32..47a43cce7 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -638,7 +638,8 @@ SliderWidget::SliderWidget(GuiObject* boss, const GUI::Font& font, _valueLabelGap(valueLabelGap), _valueLabelWidth(valueLabelWidth), _valueLabel(""), - _valueUnit(valueUnit) + _valueUnit(valueUnit), + _numIntervals(0) { _flags = WIDGET_ENABLED | WIDGET_TRACK_MOUSE; _bgcolor = kDlgColor; @@ -721,6 +722,13 @@ void SliderWidget::setValueUnit(const string& valueUnit) setDirty(); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void SliderWidget::setTickmarkInterval(int numIntervals) +{ + _numIntervals = numIntervals; + setDirty(); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void SliderWidget::handleMouseMoved(int x, int y) { @@ -816,6 +824,30 @@ void SliderWidget::drawWidget(bool hilite) // Draw the 'bar' s.fillRect(x, y, p, h, !isEnabled() ? kColor : hilite ? kSliderColorHi : kSliderColor); + + // Draw the 'tickmarks' + for(int i = 1; i < _numIntervals; ++i) + { + int xt = x + (_w - _labelWidth - _valueLabelGap - _valueLabelWidth) * i / _numIntervals - 1; + uInt32 color; + + if(isEnabled()) + { + if(xt > x + p) + color = hilite ? kSliderColorHi : kSliderColor; + else + color = hilite ? kSliderBGColorHi : kSliderBGColor; + } + else + { + if(xt > x + p) + color = kColor; + else + color = kSliderBGColorLo; + } + s.vLine(xt, y + h / 2, y + h - 1, color); + } + // Draw the 'handle' s.fillRect(x + p, y - 2, 2, h + 4, !isEnabled() ? kColor : hilite ? kSliderColorHi : kSliderColor); diff --git a/src/gui/Widget.hxx b/src/gui/Widget.hxx index 06de06337..5d94d0215 100644 --- a/src/gui/Widget.hxx +++ b/src/gui/Widget.hxx @@ -328,6 +328,8 @@ class SliderWidget : public ButtonWidget const string& getValueLabel() const { return _valueLabel; } void setValueUnit(const string& valueUnit); + void setTickmarkInterval(int numIntervals); + protected: void handleMouseMoved(int x, int y) override; void handleMouseDown(int x, int y, MouseButton b, int clickCount) override; @@ -349,6 +351,7 @@ class SliderWidget : public ButtonWidget string _valueUnit; int _valueLabelWidth; int _valueLabelGap; + int _numIntervals; private: // Following constructors and assignment operators not supported