diff --git a/src/common/bspf.hxx b/src/common/bspf.hxx index 84164a087..a26d9f5a3 100644 --- a/src/common/bspf.hxx +++ b/src/common/bspf.hxx @@ -76,6 +76,7 @@ using std::memcpy; // Common array types using IntArray = std::vector; +using uIntArray = std::vector; using BoolArray = std::vector; using ByteArray = std::vector; using ShortArray = std::vector; diff --git a/src/gui/TimeLineWidget.cxx b/src/gui/TimeLineWidget.cxx index b79496561..25b8bdf0e 100644 --- a/src/gui/TimeLineWidget.cxx +++ b/src/gui/TimeLineWidget.cxx @@ -28,11 +28,11 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - TimeLineWidget::TimeLineWidget(GuiObject* boss, const GUI::Font& font, int x, int y, int w, int h, - const string& label, int labelWidth, int cmd) + const string& label, uInt32 labelWidth, int cmd) : ButtonWidget(boss, font, x, y, w, h, label, cmd), _value(0), _valueMin(0), - _valueMax(100), + _valueMax(0), _isDragging(false), _labelWidth(labelWidth) { @@ -45,14 +45,13 @@ TimeLineWidget::TimeLineWidget(GuiObject* boss, const GUI::Font& font, _w = w + _labelWidth; - _stepValue.reserve(_valueMax); + _stepValue.reserve(100); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void TimeLineWidget::setValue(int value) +void TimeLineWidget::setValue(uInt32 value) { - if(value < _valueMin) value = _valueMin; - else if(value > _valueMax) value = _valueMax; + value = BSPF::clamp(value, _valueMin, _valueMax); if(value != _value) { @@ -63,13 +62,13 @@ void TimeLineWidget::setValue(int value) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void TimeLineWidget::setMinValue(int value) +void TimeLineWidget::setMinValue(uInt32 value) { _valueMin = value; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void TimeLineWidget::setMaxValue(int value) +void TimeLineWidget::setMaxValue(uInt32 value) { _valueMax = value; } @@ -129,9 +128,9 @@ void TimeLineWidget::handleMouseWheel(int x, int y, int direction) { if(isEnabled()) { - if(direction < 0) + if(direction < 0 && _value < _valueMax) setValue(_value + 1); - else if(direction > 0) + else if(direction > 0 && _value > _valueMin) setValue(_value - 1); } } @@ -186,16 +185,13 @@ void TimeLineWidget::drawWidget(bool hilite) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -int TimeLineWidget::valueToPos(int value) +uInt32 TimeLineWidget::valueToPos(uInt32 value) { - if(_valueMax >= 0) - return _stepValue[BSPF::clamp(value, _valueMin, _valueMax)]; - else - return 0; + return _stepValue[BSPF::clamp(value, _valueMin, _valueMax)]; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -int TimeLineWidget::posToValue(int pos) +uInt32 TimeLineWidget::posToValue(uInt32 pos) { // Find the interval in which 'pos' falls, and then the endpoint which // it is closest to diff --git a/src/gui/TimeLineWidget.hxx b/src/gui/TimeLineWidget.hxx index 4348452a3..3a60c1c06 100644 --- a/src/gui/TimeLineWidget.hxx +++ b/src/gui/TimeLineWidget.hxx @@ -25,15 +25,15 @@ class TimeLineWidget : public ButtonWidget public: TimeLineWidget(GuiObject* boss, const GUI::Font& font, int x, int y, int w, int h, const string& label = "", - int labelWidth = 0, int cmd = 0); + uInt32 labelWidth = 0, int cmd = 0); - void setValue(int value); - int getValue() const { return _value; } + void setValue(uInt32 value); + uInt32 getValue() const { return _value; } - void setMinValue(int value); - int getMinValue() const { return _valueMin; } - void setMaxValue(int value); - int getMaxValue() const { return _valueMax; } + void setMinValue(uInt32 value); + uInt32 getMinValue() const { return _valueMin; } + void setMaxValue(uInt32 value); + uInt32 getMaxValue() const { return _valueMax; } /** Steps are not necessarily linear in a timeline, so we need info @@ -49,16 +49,16 @@ class TimeLineWidget : public ButtonWidget void drawWidget(bool hilite) override; - int valueToPos(int value); - int posToValue(int pos); + uInt32 valueToPos(uInt32 value); + uInt32 posToValue(uInt32 pos); protected: - int _value; - int _valueMin, _valueMax; - bool _isDragging; - int _labelWidth; + uInt32 _value; + uInt32 _valueMin, _valueMax; + bool _isDragging; + uInt32 _labelWidth; - IntArray _stepValue; + uIntArray _stepValue; private: // Following constructors and assignment operators not supported diff --git a/src/gui/TimeMachineDialog.cxx b/src/gui/TimeMachineDialog.cxx index be386dea1..d00499770 100644 --- a/src/gui/TimeMachineDialog.cxx +++ b/src/gui/TimeMachineDialog.cxx @@ -212,7 +212,7 @@ void TimeMachineDialog::loadConfig() IntArray cycles = r.cyclesList(); // Set range and intervals for timeline - myTimeline->setMaxValue(int(cycles.size()) - 1); + myTimeline->setMaxValue(cycles.size() > 1 ? cycles.size() - 1 : 0); myTimeline->setStepValues(cycles); // Enable blending (only once is necessary)