mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-24 06:36:08 +00:00
Tweak rendering of slider controls in RDStyle
This commit is contained in:
@@ -37,8 +37,9 @@
|
||||
|
||||
namespace Constants
|
||||
{
|
||||
static const int SliderHandleHalfWidth = 4;
|
||||
static const int SliderHandleHalfWidth = 5;
|
||||
static const int SliderGrooveHeight = 4;
|
||||
static const qreal SliderHandleCornerRadius = 4.0f;
|
||||
|
||||
static const int ButtonMargin = 6;
|
||||
static const int ButtonBorder = 1;
|
||||
@@ -47,7 +48,7 @@ static const int HighlightBorder = 2;
|
||||
|
||||
static const int CheckWidth = 14;
|
||||
static const int CheckHeight = 14;
|
||||
static float CheckCornerSize = 2.0f;
|
||||
static const float CheckCornerSize = 2.0f;
|
||||
static const int CheckMargin = 3;
|
||||
|
||||
static const int GroupHMargin = 8;
|
||||
@@ -480,8 +481,10 @@ QRect RDStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt,
|
||||
if(sc == QStyle::SC_SliderGroove)
|
||||
{
|
||||
int toGrooveHeightHalfReduction = (ret.height() - Constants::SliderGrooveHeight) / 2;
|
||||
ret.adjust(Constants::SliderHandleHalfWidth, toGrooveHeightHalfReduction,
|
||||
-Constants::SliderHandleHalfWidth, -toGrooveHeightHalfReduction);
|
||||
// QSlider code handles only moving the handle up to where it abutts the groove in either
|
||||
// direction, reducing it here breaks that calculation. We'll do it visually when actually
|
||||
// painting
|
||||
ret.adjust(0, toGrooveHeightHalfReduction, 0, -toGrooveHeightHalfReduction);
|
||||
}
|
||||
else if(sc == QStyle::SC_SliderHandle)
|
||||
{
|
||||
@@ -494,7 +497,10 @@ QRect RDStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt,
|
||||
int grooveRight = ret.right() - Constants::SliderHandleHalfWidth;
|
||||
int grooveWidth = grooveRight - grooveLeft;
|
||||
int sliderX = (int)(posUNorm * (qreal)grooveWidth) + grooveLeft;
|
||||
ret.setLeft(sliderX - Constants::SliderHandleHalfWidth);
|
||||
// since sizes are inclusive, x-w to x+w results in 2w+1 width (w pixels either side + the x
|
||||
// pixel itself), so we make this favour the right side so it's w-1 pixels to the left, the x
|
||||
// pixel and then w pixels to the right, for a total of 2w
|
||||
ret.setLeft(sliderX - Constants::SliderHandleHalfWidth + 1);
|
||||
ret.setRight(sliderX + Constants::SliderHandleHalfWidth);
|
||||
}
|
||||
return ret;
|
||||
@@ -1150,13 +1156,23 @@ void RDStyle::drawComplexControl(ComplexControl control, const QStyleOptionCompl
|
||||
else if(control == QStyle::CC_Slider)
|
||||
{
|
||||
QRect grooveRect = subControlRect(control, opt, QStyle::SC_SliderGroove, widget);
|
||||
p->drawLine(QLine(grooveRect.x(), grooveRect.y() + grooveRect.height() / 2, grooveRect.right(),
|
||||
p->drawLine(QLine(grooveRect.x() + Constants::SliderHandleHalfWidth + 1,
|
||||
grooveRect.y() + grooveRect.height() / 2,
|
||||
grooveRect.right() - Constants::SliderHandleHalfWidth,
|
||||
grooveRect.y() + grooveRect.height() / 2));
|
||||
|
||||
p->save();
|
||||
p->setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
QRect handleRect = subControlRect(control, opt, QStyle::SC_SliderHandle, widget);
|
||||
QBrush handleBrush = (m_Scheme == Light) ? opt->palette.brush(QPalette::Dark)
|
||||
: opt->palette.brush(QPalette::Text);
|
||||
p->fillRect(handleRect, handleBrush);
|
||||
QPainterPath path;
|
||||
path.addRoundedRect(handleRect, Constants::SliderHandleCornerRadius,
|
||||
Constants::SliderHandleCornerRadius);
|
||||
p->fillPath(path, handleBrush);
|
||||
|
||||
p->restore();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -400,42 +400,24 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="vtxExploderSlider">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>90</width>
|
||||
<height>30</height>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="mouseTracking">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::NoContextMenu</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Explode vertices</string>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string>slider name</string>
|
||||
</property>
|
||||
<property name="accessibleDescription">
|
||||
<string>slider description</string>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-100</number>
|
||||
</property>
|
||||
@@ -448,18 +430,6 @@
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="invertedAppearance">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="invertedControls">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::NoTicks</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>20</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
||||
Reference in New Issue
Block a user