Compare commits
25 Commits
master
...
features/s
Author | SHA1 | Date |
---|---|---|
|
e3ec499cc3 | |
|
0f4c9de0e6 | |
|
6de763ec2a | |
|
476b969d7d | |
|
7f324d2d48 | |
|
8d780244b6 | |
|
128ce8f79b | |
|
6a8d9096be | |
|
43286c2b83 | |
|
1608ef8596 | |
|
83670c997c | |
|
177e929dbb | |
|
9f6ad841c2 | |
|
52ac73111e | |
|
b19515c801 | |
|
b53f60dd0e | |
|
4778feaaa2 | |
|
e3b87338c0 | |
|
d93459496a | |
|
dd74bc7595 | |
|
ad7e24faa5 | |
|
b82097fdb4 | |
|
f04dedd30a | |
|
3fdd72c5a3 | |
|
e7b64bf4a0 |
|
@ -1004,6 +1004,21 @@ void Editor::setupSlider()
|
||||||
const auto disabledColor = flattenedColor( m_pal.onSurface, m_pal.background, 0.38 );
|
const auto disabledColor = flattenedColor( m_pal.onSurface, m_pal.background, 0.38 );
|
||||||
setGradient( Q::Handle | Q::Disabled, disabledColor );
|
setGradient( Q::Handle | Q::Disabled, disabledColor );
|
||||||
|
|
||||||
|
for( const auto state : { Q::Focused, Q::Pressed } )
|
||||||
|
{
|
||||||
|
setStrutSize( Q::LabelContainer | state, 48_px, 44_px,
|
||||||
|
{ QskStateCombination::CombinationNoState, Q::Hovered } );
|
||||||
|
}
|
||||||
|
|
||||||
|
setBoxShape( Q::LabelContainer, 100, Qt::RelativeSize );
|
||||||
|
setGradient( Q::LabelContainer, m_pal.inverseSurface );
|
||||||
|
setMargin( Q::LabelContainer | A::Horizontal, { 0, 0, 0, 4_px } );
|
||||||
|
setMargin( Q::LabelContainer | A::Vertical, { 4_px, 0, 0, 0 } );
|
||||||
|
|
||||||
|
setFontRole( Q::LabelText, LabelMedium );
|
||||||
|
setColor( Q::LabelText, m_pal.inverseOnSurface );
|
||||||
|
setAlignment( Q::LabelText, Qt::AlignCenter );
|
||||||
|
|
||||||
setAnimation( Q::Handle | A::Metric | A::Position, 2 * qskDuration );
|
setAnimation( Q::Handle | A::Metric | A::Position, 2 * qskDuration );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,8 @@ QSK_SUBCONTROL( QskSlider, Fill )
|
||||||
QSK_SUBCONTROL( QskSlider, Scale )
|
QSK_SUBCONTROL( QskSlider, Scale )
|
||||||
QSK_SUBCONTROL( QskSlider, Tick )
|
QSK_SUBCONTROL( QskSlider, Tick )
|
||||||
QSK_SUBCONTROL( QskSlider, Handle )
|
QSK_SUBCONTROL( QskSlider, Handle )
|
||||||
|
QSK_SUBCONTROL( QskSlider, LabelContainer )
|
||||||
|
QSK_SUBCONTROL( QskSlider, LabelText )
|
||||||
|
|
||||||
QSK_SYSTEM_STATE( QskSlider, Pressed, QskAspect::FirstSystemState << 2 )
|
QSK_SYSTEM_STATE( QskSlider, Pressed, QskAspect::FirstSystemState << 2 )
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,8 @@ class QSK_EXPORT QskSlider : public QskBoundedValueInput
|
||||||
using Inherited = QskBoundedValueInput;
|
using Inherited = QskBoundedValueInput;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QSK_SUBCONTROLS( Panel, Groove, Fill, Scale, Tick, Handle )
|
QSK_SUBCONTROLS( Panel, Groove, Fill, Scale, Tick, Handle,
|
||||||
|
LabelContainer, LabelText )
|
||||||
QSK_STATES( Pressed )
|
QSK_STATES( Pressed )
|
||||||
|
|
||||||
explicit QskSlider( QQuickItem* parent = nullptr );
|
explicit QskSlider( QQuickItem* parent = nullptr );
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <qvector.h>
|
#include <qvector.h>
|
||||||
#include <qpair.h>
|
#include <qpair.h>
|
||||||
#include <qmath.h>
|
#include <qmath.h>
|
||||||
|
#include <qfontmetrics.h>
|
||||||
|
|
||||||
// the color of graduation ticks might different, when being on top of the filling
|
// the color of graduation ticks might different, when being on top of the filling
|
||||||
QSK_SYSTEM_STATE( QskSliderSkinlet, Filled, QskAspect::FirstUserState >> 1 )
|
QSK_SYSTEM_STATE( QskSliderSkinlet, Filled, QskAspect::FirstUserState >> 1 )
|
||||||
|
@ -87,7 +88,8 @@ static inline QPair< qreal, qreal > qskTickSpan( qreal min, qreal max, qreal len
|
||||||
QskSliderSkinlet::QskSliderSkinlet( QskSkin* skin )
|
QskSliderSkinlet::QskSliderSkinlet( QskSkin* skin )
|
||||||
: Inherited( skin )
|
: Inherited( skin )
|
||||||
{
|
{
|
||||||
setNodeRoles( { PanelRole, GrooveRole, FillRole, TicksRole, HandleRole } );
|
setNodeRoles( { PanelRole, GrooveRole, FillRole, TicksRole, HandleRole,
|
||||||
|
LabelContainerRole, LabelTextRole } );
|
||||||
}
|
}
|
||||||
|
|
||||||
QskSliderSkinlet::~QskSliderSkinlet()
|
QskSliderSkinlet::~QskSliderSkinlet()
|
||||||
|
@ -114,6 +116,12 @@ QRectF QskSliderSkinlet::subControlRect( const QskSkinnable* skinnable,
|
||||||
if ( subControl == Q::Handle )
|
if ( subControl == Q::Handle )
|
||||||
return handleRect( slider, contentsRect );
|
return handleRect( slider, contentsRect );
|
||||||
|
|
||||||
|
if ( subControl == Q::LabelContainer )
|
||||||
|
return labelContainerRect( slider, contentsRect );
|
||||||
|
|
||||||
|
if ( subControl == Q::LabelText )
|
||||||
|
return labelContainerRect( slider, contentsRect );
|
||||||
|
|
||||||
return Inherited::subControlRect( skinnable, contentsRect, subControl );
|
return Inherited::subControlRect( skinnable, contentsRect, subControl );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,6 +146,12 @@ QSGNode* QskSliderSkinlet::updateSubNode(
|
||||||
|
|
||||||
case TicksRole:
|
case TicksRole:
|
||||||
return updateSeriesNode( slider, Q::Tick, node );
|
return updateSeriesNode( slider, Q::Tick, node );
|
||||||
|
|
||||||
|
case LabelContainerRole:
|
||||||
|
return updateBoxNode( slider, node, Q::LabelContainer );
|
||||||
|
|
||||||
|
case LabelTextRole:
|
||||||
|
return updateTextNode( slider, node, slider->valueText(), Q::LabelText );
|
||||||
}
|
}
|
||||||
|
|
||||||
return Inherited::updateSubNode( skinnable, nodeRole, node );
|
return Inherited::updateSubNode( skinnable, nodeRole, node );
|
||||||
|
@ -362,6 +376,40 @@ QRectF QskSliderSkinlet::tickRect( const QskSlider* slider,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QRectF QskSliderSkinlet::labelContainerRect(
|
||||||
|
const QskSlider* slider, const QRectF& rect ) const
|
||||||
|
{
|
||||||
|
auto size = slider->strutSizeHint( Q::LabelContainer );
|
||||||
|
|
||||||
|
if( size.isEmpty() )
|
||||||
|
return QRectF();
|
||||||
|
|
||||||
|
const QFontMetricsF fm( slider->effectiveFont( Q::LabelText ) );
|
||||||
|
const auto w = qskHorizontalAdvance( fm, slider->valueText() );
|
||||||
|
|
||||||
|
const auto padding = slider->paddingHint( Q::LabelContainer );
|
||||||
|
const auto h = fm.height() + padding.top() + padding.bottom();
|
||||||
|
|
||||||
|
size = size.expandedTo( { w, h } );
|
||||||
|
|
||||||
|
const auto hr = subControlRect( slider, rect, Q::Handle );
|
||||||
|
const auto margins = slider->marginHint( Q::LabelContainer );
|
||||||
|
|
||||||
|
qreal x, y;
|
||||||
|
|
||||||
|
if( slider->orientation() == Qt::Horizontal )
|
||||||
|
{
|
||||||
|
x = hr.center().x() - size.width() / 2;
|
||||||
|
y = hr.top() - margins.bottom() - size.height();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x = hr.left() - size.width() - margins.left();
|
||||||
|
y = hr.center().y() - size.height() / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return QRectF( x, y, size.width(), size.height() );
|
||||||
|
}
|
||||||
QSizeF QskSliderSkinlet::sizeHint( const QskSkinnable* skinnable,
|
QSizeF QskSliderSkinlet::sizeHint( const QskSkinnable* skinnable,
|
||||||
Qt::SizeHint which, const QSizeF& ) const
|
Qt::SizeHint which, const QSizeF& ) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,6 +26,8 @@ class QSK_EXPORT QskSliderSkinlet : public QskSkinlet
|
||||||
FillRole,
|
FillRole,
|
||||||
TicksRole,
|
TicksRole,
|
||||||
HandleRole,
|
HandleRole,
|
||||||
|
LabelContainerRole,
|
||||||
|
LabelTextRole,
|
||||||
|
|
||||||
RoleCount
|
RoleCount
|
||||||
};
|
};
|
||||||
|
@ -65,6 +67,8 @@ class QSK_EXPORT QskSliderSkinlet : public QskSkinlet
|
||||||
QRectF fillRect( const QskSlider*, const QRectF& ) const;
|
QRectF fillRect( const QskSlider*, const QRectF& ) const;
|
||||||
QRectF handleRect( const QskSlider*, const QRectF& ) const;
|
QRectF handleRect( const QskSlider*, const QRectF& ) const;
|
||||||
QRectF tickRect( const QskSlider*, const QRectF&, int index ) const;
|
QRectF tickRect( const QskSlider*, const QRectF&, int index ) const;
|
||||||
|
|
||||||
|
QRectF labelContainerRect( const QskSlider*, const QRectF& ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue