From 5764a73d89495c85b732c2456f774bf4937d30f7 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Wed, 7 Feb 2018 14:55:43 +0100 Subject: [PATCH] finalized TimeLineWidget for new UI look --- src/gui/TimeLineWidget.cxx | 35 ++++++++++++++++++++++++++--------- src/gui/TimeMachineDialog.cxx | 14 +++++++------- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/src/gui/TimeLineWidget.cxx b/src/gui/TimeLineWidget.cxx index 83a0c4166..a3074ab72 100644 --- a/src/gui/TimeLineWidget.cxx +++ b/src/gui/TimeLineWidget.cxx @@ -25,6 +25,9 @@ #include "TimeLineWidget.hxx" +const int HANDLE_W = 3; +const int HANDLE_H = 3; // size above/below the slider + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - TimeLineWidget::TimeLineWidget(GuiObject* boss, const GUI::Font& font, int x, int y, int w, int h, @@ -85,7 +88,7 @@ void TimeLineWidget::setStepValues(const IntArray& steps) if(steps.size() > _stepValue.capacity()) _stepValue.reserve(2 * steps.size()); - double scale = (_w - _labelWidth - 2) / double(steps.back()); + double scale = (_w - _labelWidth - 2 - HANDLE_W*0) / double(steps.back()); // 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) @@ -93,7 +96,7 @@ void TimeLineWidget::setStepValues(const IntArray& steps) // Due to integer <-> double conversion, the last value is sometimes // slightly less than the maximum value; we assign it manually to fix this - _stepValue.push_back(_w - _labelWidth - 2); + _stepValue.push_back(_w - _labelWidth - 2 - HANDLE_W*0); } else _stepValue.push_back(0); @@ -148,18 +151,29 @@ void TimeLineWidget::drawWidget(bool hilite) isEnabled() ? kTextColor : kColor, TextAlign::Left); int p = valueToPos(_value), - x = _x + _labelWidth; + x = _x + _labelWidth, + w = _w - _labelWidth; + + // Frame the handle + const int HANDLE_W2 = (HANDLE_W + 1) / 2; + s.hLine(x + p - HANDLE_W2, _y + 0, x + p - HANDLE_W2 + HANDLE_W, kColorInfo); + s.vLine(x + p - HANDLE_W2, _y + 1, _y + _h - 2, kColorInfo); + s.hLine(x + p - HANDLE_W2 + 1, _y + _h - 1, x + p - HANDLE_W2 + 1 + HANDLE_W, kBGColor); + s.vLine(x + p - HANDLE_W2 + 1 + HANDLE_W, _y + 1, _y + _h - 2, kBGColor); + // Frame the box + s.hLine(x, _y + HANDLE_H, x + w - 2, kColorInfo); + s.vLine(x, _y + HANDLE_H, _y + _h - 2 - HANDLE_H, kColorInfo); + s.hLine(x + 1, _y + _h - 1 - HANDLE_H, x + w - 1, kBGColor); + s.vLine(x + w - 1, _y + 1 + HANDLE_H, _y + _h - 2 - HANDLE_H, kBGColor); - // Draw the box - s.frameRect(x, _y, _w - _labelWidth, _h, isEnabled() && hilite ? kScrollColor : kColor); // Fill the box - s.fillRect(x + 1, _y + 1, _w - _labelWidth - 2, _h - 2, + s.fillRect(x + 1, _y + 1 + HANDLE_H, w - 2, _h - 2 - HANDLE_H * 2, !isEnabled() ? kSliderBGColorLo : hilite ? kSliderBGColorHi : kSliderBGColor); // Draw the 'bar' - s.fillRect(x + 1, _y + 1, p, _h - 2, + s.fillRect(x + 1, _y + 1 + HANDLE_H, p, _h - 2 - HANDLE_H * 2, !isEnabled() ? kColor : hilite ? kSliderColorHi : kSliderColor); - // add 4 tickmarks for 5 intervals + // Add 4 tickmarks for 5 intervals int numTicks = std::min(5, int(_stepValue.size())); for(int i = 1; i < numTicks; ++i) { @@ -183,9 +197,12 @@ void TimeLineWidget::drawWidget(bool hilite) else color = kSliderBGColorLo; } - s.vLine(xt, _y + _h / 2, _y + _h - 2, color); + s.vLine(xt, _y + _h / 2, _y + _h - 2 - HANDLE_H, color); } } + // Draw the handle + s.fillRect(x + p + 1 - HANDLE_W2, _y + 1, HANDLE_W, _h - 2, + !isEnabled() ? kColor : hilite ? kSliderColorHi : kSliderColor); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/TimeMachineDialog.cxx b/src/gui/TimeMachineDialog.cxx index 560a22ff0..658e61f98 100644 --- a/src/gui/TimeMachineDialog.cxx +++ b/src/gui/TimeMachineDialog.cxx @@ -184,17 +184,17 @@ TimeMachineDialog::TimeMachineDialog(OSystem& osystem, DialogContainer& parent, ypos = V_BORDER; // Add index info - myCurrentIdxWidget = new StaticTextWidget(this, font, xpos, ypos, " ", TextAlign::Left, kBGColor); + myCurrentIdxWidget = new StaticTextWidget(this, font, xpos, ypos, "1000", TextAlign::Left, kBGColor); myCurrentIdxWidget->setTextColor(kColorInfo); - myLastIdxWidget = new StaticTextWidget(this, font, _w - H_BORDER - font.getStringWidth("8888"), ypos, - " ", TextAlign::Right, kBGColor); + myLastIdxWidget = new StaticTextWidget(this, font, _w - H_BORDER - font.getStringWidth("1000"), ypos, + "1000", TextAlign::Right, kBGColor); myLastIdxWidget->setTextColor(kColorInfo); // Add timeline - const uInt32 tl_h = myCurrentIdxWidget->getHeight() / 2, - tl_x = xpos + myCurrentIdxWidget->getWidth() + 8, - tl_y = ypos + (myCurrentIdxWidget->getHeight() - tl_h) / 2 - 1, - tl_w = myLastIdxWidget->getAbsX() - tl_x - 8; + const uInt32 tl_h = myCurrentIdxWidget->getHeight() / 2 + 6, + tl_x = xpos + myCurrentIdxWidget->getWidth() + 8, + tl_y = ypos + (myCurrentIdxWidget->getHeight() - tl_h) / 2 - 1, + tl_w = myLastIdxWidget->getAbsX() - tl_x - 8; myTimeline = new TimeLineWidget(this, font, tl_x, tl_y, tl_w, tl_h, "", 0, kTimeline); myTimeline->setMinValue(0); ypos += rowHeight;