Skip to content

Commit

Permalink
QskSlider: Add stop indicators
Browse files Browse the repository at this point in the history
... as required by M3

Resolves #391
  • Loading branch information
peter-ha committed May 29, 2024
1 parent 9ed891e commit b198ed4
Show file tree
Hide file tree
Showing 6 changed files with 211 additions and 56 deletions.
23 changes: 23 additions & 0 deletions designsystems/material3/QskMaterial3Skin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -865,15 +865,38 @@ void Editor::setupSlider()
setBoxBorderMetrics( Q::Handle, 0 );

const QSizeF handleSize( 4_dp, 44_dp );
const QSizeF handleSizeFocusedPressed( 2_dp, 44_dp );
setStrutSize( Q::Handle | A::Horizontal, handleSize );
setStrutSize( Q::Handle | A::Horizontal, handleSizeFocusedPressed,
{ QskStateCombination::Combination, Q::Focused | Q::Pressed } );

setStrutSize( Q::Handle | A::Vertical, handleSize.transposed() );
setStrutSize( Q::Handle | A::Vertical, handleSizeFocusedPressed.transposed(),
{ QskStateCombination::Combination, Q::Focused | Q::Pressed } );

setGradient( Q::Handle, m_pal.primary );
setGradient( Q::Handle | Q::Pressed, m_pal.primary );

const auto disabledColor = flattenedColor( m_pal.onSurface, m_pal.background, 0.38 );
setGradient( Q::Handle | Q::Disabled, disabledColor );

for( auto indicator : { Q::GrooveStopIndicators, Q::FillStopIndicators } )
{
setStrutSize( indicator, { 4_dp, 4_dp } );
setBoxShape( indicator, 100, Qt::RelativeSize );
}

const auto p = 6_dp;
setPadding( Q::GrooveStopIndicators | A::Horizontal, { p, 0, p, 0 } );
setPadding( Q::GrooveStopIndicators | A::Vertical, { 0, p, 0, p } );
setPadding( Q::FillStopIndicators | A::Horizontal, { p, 0, p, 0 } );
setPadding( Q::FillStopIndicators | A::Vertical, { 0, p, 0, p } );

setGradient( Q::GrooveStopIndicators, m_pal.primary );
setGradient( Q::GrooveStopIndicators | Q::Disabled, m_pal.onSurface );
setGradient( Q::FillStopIndicators, m_pal.secondaryContainer );
setGradient( Q::FillStopIndicators | Q::Disabled, m_pal.inverseOnSurface );

for( const auto state : { Q::Focused, Q::Pressed } )
{
setStrutSize( Q::LabelContainer | state, 48_dp, 44_dp,
Expand Down
17 changes: 15 additions & 2 deletions examples/gallery/inputs/InputPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,30 @@ InputPage::InputPage( QQuickItem* parent )
: Page( Qt::Horizontal, parent )
{
auto sliderH = new Slider( Qt::Horizontal );

auto discreteSliderH = new Slider( Qt::Horizontal );
discreteSliderH->setSnap( true );
discreteSliderH->setStepSize( 10 );
discreteSliderH->setPageSize( 1 );

auto sliderV = new Slider( Qt::Vertical );

auto discreteSliderV = new Slider( Qt::Vertical );
discreteSliderV->setSnap( true );
discreteSliderV->setStepSize( 10 );
discreteSliderV->setPageSize( 2 );

auto inputBox = new InputBox();

auto gridBox = new QskGridBox( this );
gridBox->setSpacing( 30 );
gridBox->setMargins( 30 );

gridBox->addItem( sliderV, 0, 0, -1, 1 );
gridBox->addItem( sliderH, 0, 1, 1, -1 );
gridBox->addItem( inputBox, 1, 1, -1, -1 );
gridBox->addItem( discreteSliderV, 0, 1, -1, 1 );
gridBox->addItem( sliderH, 0, 2, 1, -1 );
gridBox->addItem( discreteSliderH, 1, 2, 1, -1 );
gridBox->addItem( inputBox, 2, 2, -1, -1 );

auto inputs = findChildren< QskBoundedValueInput* >();

Expand Down
2 changes: 2 additions & 0 deletions src/controls/QskSlider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ QSK_SUBCONTROL( QskSlider, Fill )
QSK_SUBCONTROL( QskSlider, Scale )
QSK_SUBCONTROL( QskSlider, Handle )
QSK_SUBCONTROL( QskSlider, Ripple )
QSK_SUBCONTROL( QskSlider, GrooveStopIndicators )
QSK_SUBCONTROL( QskSlider, FillStopIndicators )
QSK_SUBCONTROL( QskSlider, LabelContainer )
QSK_SUBCONTROL( QskSlider, LabelText )

Expand Down
3 changes: 2 additions & 1 deletion src/controls/QskSlider.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class QSK_EXPORT QskSlider : public QskBoundedValueInput
using Inherited = QskBoundedValueInput;

public:
QSK_SUBCONTROLS( Panel, Groove, Fill, Scale, Handle, Ripple, LabelContainer, LabelText )
QSK_SUBCONTROLS( Panel, Groove, Fill, Scale, Handle, Ripple, GrooveStopIndicators, FillStopIndicators,
LabelContainer, LabelText )
QSK_STATES( Pressed )

explicit QskSlider( QQuickItem* parent = nullptr );
Expand Down
Loading

0 comments on commit b198ed4

Please sign in to comment.