added tickmarks to TimeLineWidget (5 intervals)

replaced 3d box with rect for TimeLineWidget
This commit is contained in:
thrust26 2018-02-02 13:05:41 +01:00
parent 883a9249b1
commit cbeeda6f55
2 changed files with 19 additions and 6 deletions

View File

@ -86,7 +86,7 @@ void TimeLineWidget::setStepValues(const IntArray& steps)
if(steps.size() > _stepValue.capacity()) if(steps.size() > _stepValue.capacity())
_stepValue.reserve(2 * steps.size()); _stepValue.reserve(2 * steps.size());
double scale = (_w - _labelWidth - 4) / double(steps.back()); double scale = (_w - _labelWidth - 2) / double(steps.back());
// Skip the very last value; we take care of it outside the end of the loop // Skip the very last value; we take care of it outside the end of the loop
for(uInt32 i = 0; i < steps.size() - 1; ++i) for(uInt32 i = 0; i < steps.size() - 1; ++i)
@ -95,7 +95,7 @@ void TimeLineWidget::setStepValues(const IntArray& steps)
// Due to integer <-> double conversion, the last value is sometimes // Due to integer <-> double conversion, the last value is sometimes
// slightly less than the maximum value; we assign it manually to fix this // slightly less than the maximum value; we assign it manually to fix this
_stepValue.push_back(_w - _labelWidth - 4); _stepValue.push_back(_w - _labelWidth - 2);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -148,13 +148,26 @@ void TimeLineWidget::drawWidget(bool hilite)
isEnabled() ? kTextColor : kColor, TextAlign::Right); isEnabled() ? kTextColor : kColor, TextAlign::Right);
// Draw the box // Draw the box
s.box(_x + _labelWidth, _y, _w - _labelWidth, _h, kColor, kShadowColor); s.frameRect(_x + _labelWidth, _y, _w - _labelWidth, _h, kColor);
// Fill the box // Fill the box
s.fillRect(_x + _labelWidth + 2, _y + 2, _w - _labelWidth - 4, _h - 4, s.fillRect(_x + _labelWidth + 1, _y + 1, _w - _labelWidth - 2, _h - 2,
!isEnabled() ? kBGColorHi : kWidColor); !isEnabled() ? kBGColorHi : kWidColor);
// Draw the 'bar' // Draw the 'bar'
s.fillRect(_x + _labelWidth + 2, _y + 2, valueToPos(_value), _h - 4, int vp = valueToPos(_value);
s.fillRect(_x + _labelWidth + 1, _y + 1, vp, _h - 2,
!isEnabled() ? kColor : hilite ? kSliderColorHi : kSliderColor); !isEnabled() ? kColor : hilite ? kSliderColorHi : kSliderColor);
// add 4 tickmarks for 5 intervals
int numTicks = std::min(5, int(_stepValue.size()));
for(int i = 1; i < numTicks; ++i)
{
int idx = (_stepValue.size() * i + numTicks / 2) / numTicks;
if(idx > 1)
{
int tp = valueToPos(idx - 1);
s.vLine(_x + _labelWidth + tp, _y + _h / 2, _y + _h - 2, tp > vp ? kSliderColor : kWidColor);
}
}
#else #else
// Draw the label, if any // Draw the label, if any
if(_labelWidth > 0) if(_labelWidth > 0)

View File

@ -155,7 +155,7 @@ TimeMachineDialog::TimeMachineDialog(OSystem& osystem, DialogContainer& parent,
// Add timeline // Add timeline
const uInt32 tl_h = myCurrentIdxWidget->getHeight() / 2, const uInt32 tl_h = myCurrentIdxWidget->getHeight() / 2,
tl_x = xpos + myCurrentIdxWidget->getWidth() + 8, tl_x = xpos + myCurrentIdxWidget->getWidth() + 8,
tl_y = ypos + (myCurrentIdxWidget->getHeight() - tl_h) / 2, tl_y = ypos + (myCurrentIdxWidget->getHeight() - tl_h) / 2 - 1,
tl_w = myLastIdxWidget->getAbsX() - tl_x - 8; tl_w = myLastIdxWidget->getAbsX() - tl_x - 8;
myTimeline = new TimeLineWidget(this, font, tl_x, tl_y, tl_w, tl_h, "", 0, kTimeline); myTimeline = new TimeLineWidget(this, font, tl_x, tl_y, tl_w, tl_h, "", 0, kTimeline);
myTimeline->setMinValue(0); myTimeline->setMinValue(0);