Skip to content

Commit

Permalink
fix(style): set the scroll bar padding to 2px
Browse files Browse the repository at this point in the history
Change-Id: Iae4af0617feb5e511ebac3f9c2954400be230b7d
  • Loading branch information
zccrs committed Mar 6, 2018
1 parent 0b3472b commit 8cf9a91
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dstyleplugin/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ enum Metrics
MenuBarItem_MarginHeight = 6,

// scrollbars
ScrollBar_Extend = 8,
ScrollBar_Extend = 12,
ScrollBar_SliderWidth = 15,
ScrollBar_MinSliderHeight = 40,
ScrollBar_NoButtonHeight = (ScrollBar_Extend-ScrollBar_SliderWidth)/2,
Expand Down
3 changes: 1 addition & 2 deletions dstyleplugin/painterhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,10 @@ void drawPath(QPainter *painter, const QPainterPath &path, const QBrush &backgro
{
painter->fillPath(path, background);

if (qFuzzyIsNull(borderWidth) || background == border)
if (qFuzzyIsNull(borderWidth) || border == Qt::transparent)
return;

painter->save();
painter->setBrush(background);
painter->setPen(QPen(border, borderWidth));
painter->drawPath(path);
painter->restore();
Expand Down
2 changes: 2 additions & 0 deletions dstyleplugin/pushbuttonhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include <QDebug>
#include <QStyleOptionButton>

DWIDGET_USE_NAMESPACE

namespace dstyle {

bool Style::drawPushButtonBevel(const QStyleOption *option, QPainter *painter, const QWidget *widget) const
Expand Down
13 changes: 7 additions & 6 deletions dstyleplugin/scrollbarhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ QRect Style::scrollbarSubControlRect(const QStyleOptionComplex *opt, QStyle::Sub
case SC_ScrollBarSlider:
if (scrollbar->orientation == Qt::Horizontal) {
if (mouseOver && enabled)
ret.setRect(sliderstart, 0, sliderlen, scrollBarRect.height());
ret.setRect(sliderstart, 2, sliderlen, scrollBarRect.height() - 4);
else
ret.setRect(sliderstart, scrollBarRect.height() / 4, sliderlen, scrollBarRect.height() / 2);
ret.setRect(sliderstart, scrollBarRect.height() / 3, sliderlen, scrollBarRect.height() / 3);
} else {
if (mouseOver && enabled)
ret.setRect(0, sliderstart, scrollBarRect.width(), sliderlen);
ret.setRect(2, sliderstart, scrollBarRect.width() - 4, sliderlen);
else
ret.setRect(scrollBarRect.width() / 4, sliderstart, scrollBarRect.width() / 2, sliderlen);
ret.setRect(scrollBarRect.width() / 3, sliderstart, scrollBarRect.width() / 3, sliderlen);
}
break;
default:
Expand Down Expand Up @@ -219,8 +219,9 @@ bool Style::drawScrollBarSliderControl(const QStyleOption *option, QPainter *pai
QRectF rect = option->rect;

const QBrush &background = m_palette->brush(PaletteExtended::ScrollBar_HandleBrush, option, 0, Qt::lightGray);
const QBrush &border = m_palette->brush(PaletteExtended::ScrollBar_HandleBorderBrush, option, 0, background);
PainterHelper::drawRoundedRect(painter, rect, 3, 3, Qt::AbsoluteSize, background, Metrics::Painter_PenWidth, border);
const QBrush &border = m_palette->brush(PaletteExtended::ScrollBar_HandleBorderBrush, option, 0, Qt::transparent);
qreal radius = scrollBar->orientation == Qt::Horizontal ? rect.height() / 2.0 : rect.width() / 2.0;
PainterHelper::drawRoundedRect(painter, rect, radius, radius, Qt::AbsoluteSize, background, Metrics::Painter_PenWidth, border);

return true;
}
Expand Down

0 comments on commit 8cf9a91

Please sign in to comment.