cabana: Fix slider visual inconsistency by adjusting groove height (#35688)

Fix slider visual inconsistency by adjusting groove height to match handle
pull/35699/head
Dean Lee 3 days ago committed by GitHub
parent ce92fd1a0f
commit 9d7b18c7e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 13
      tools/cabana/videowidget.cc

@ -261,14 +261,23 @@ void Slider::paintEvent(QPaintEvent *ev) {
QStyleOptionSlider opt;
initStyleOption(&opt);
QRect r = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderGroove, this);
p.fillRect(r, timeline_colors[(int)TimelineType::None]);
QRect handle_rect = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this);
QRect groove_rect = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderGroove, this);
// Adjust groove height to match handle height
int handle_height = handle_rect.height();
groove_rect.setHeight(handle_height * 0.5);
groove_rect.moveCenter(QPoint(groove_rect.center().x(), rect().center().y()));
p.fillRect(groove_rect, timeline_colors[(int)TimelineType::None]);
double min = minimum() / factor;
double max = maximum() / factor;
auto fillRange = [&](double begin, double end, const QColor &color) {
if (begin > max || end < min) return;
QRect r = groove_rect;
r.setLeft(((std::max(min, begin) - min) / (max - min)) * width());
r.setRight(((std::min(max, end) - min) / (max - min)) * width());
p.fillRect(r, color);

Loading…
Cancel
Save