From b8bbd3a1350a9ff5a37bf04e91b5c3d1dad2bce6 Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Sun, 27 Dec 2020 11:11:31 +0100 Subject: [PATCH] usig QskSkinHintTableEditor --- examples/gallery/slider/CustomSlider.cpp | 21 +++++++----- examples/gallery/slider/OtherSlider.cpp | 41 +++++++++++++----------- 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/examples/gallery/slider/CustomSlider.cpp b/examples/gallery/slider/CustomSlider.cpp index 003cecd4..993ef68a 100644 --- a/examples/gallery/slider/CustomSlider.cpp +++ b/examples/gallery/slider/CustomSlider.cpp @@ -12,6 +12,9 @@ #include #include +#include +#include + QSK_SUBCONTROL( CustomSlider, Scale ) QSK_SUBCONTROL( CustomSlider, Decoration ) @@ -20,19 +23,21 @@ CustomSlider::CustomSlider( QQuickItem* parentItem ) { using namespace QskRgb; - setBoxShapeHint( Fill, 0 ); - setGradientHint( Fill, Grey700 ); - setColor( Scale, qRgb( 178, 178, 178 ) ); // for the ticks + QskSkinHintTableEditor ed( &hintTable() ); - setStrutSizeHint( Handle, 80, 80 ); - setColor( Handle, Grey800 ); + ed.setBoxShape( Fill, 0 ); + ed.setGradient( Fill, Grey700 ); + ed.setColor( Scale, qRgb( 178, 178, 178 ) ); // for the ticks + + ed.setStrutSize( Handle, 80, 80 ); + ed.setColor( Handle, Grey800 ); for ( auto state : { Pressed, Focused | Hovered, Hovered, Focused } ) - setColor( Handle | state, Orange600 ); + ed.setColor( Handle | state, Orange600 ); - setAnimationHint( Handle | QskAspect::Color, 1000 ); + ed.setAnimation( Handle | QskAspect::Color, 1000 ); for ( auto state : { Focused | Hovered, Hovered, Focused } ) - setAnimationHint( Handle | QskAspect::Color | state, 300 ); + ed.setAnimation( Handle | QskAspect::Color | state, 300 ); // using an individual skinlet, not known by the skin diff --git a/examples/gallery/slider/OtherSlider.cpp b/examples/gallery/slider/OtherSlider.cpp index daeed5b4..bba59381 100644 --- a/examples/gallery/slider/OtherSlider.cpp +++ b/examples/gallery/slider/OtherSlider.cpp @@ -11,6 +11,9 @@ #include #include +#include +#include + #include OtherSlider::OtherSlider( QQuickItem* parentItem ) @@ -23,22 +26,24 @@ OtherSlider::OtherSlider( QQuickItem* parentItem ) const qreal w = 2.0 * h; const qreal paddingW = 0.5 * w + 1; + QskSkinHintTableEditor ed( &hintTable() ); + // Panel for ( auto placement : { A::Horizontal, A::Vertical } ) { const auto aspect = Panel | placement; - setMetric( aspect | A::Size, h ); - setBoxShapeHint( aspect, 4 ); - setBoxBorderMetricsHint( aspect, 1 ); - setBoxBorderColorsHint( aspect, Grey900 ); - setGradientHint( aspect, Grey400 ); + ed.setMetric( aspect | A::Size, h ); + ed.setBoxShape( aspect, 4 ); + ed.setBoxBorderMetrics( aspect, 1 ); + ed.setBoxBorderColors( aspect, Grey900 ); + ed.setGradient( aspect, Grey400 ); if ( placement == A::Horizontal ) - setPaddingHint( aspect, QskMargins( paddingW, 0 ) ); + ed.setPadding( aspect, QskMargins( paddingW, 0 ) ); else - setPaddingHint( aspect, QskMargins( 0, paddingW ) ); + ed.setPadding( aspect, QskMargins( 0, paddingW ) ); } // Groove @@ -47,18 +52,18 @@ OtherSlider::OtherSlider( QQuickItem* parentItem ) { const auto aspect = Groove | placement; - setMetric( aspect | A::Size, 4 ); - setBoxBorderMetricsHint( aspect, 0 ); - setBoxShapeHint( aspect, 1 ); + ed.setMetric( aspect | A::Size, 4 ); + ed.setBoxBorderMetrics( aspect, 0 ); + ed.setBoxShape( aspect, 1 ); - setGradientHint( aspect, Qt::black ); + ed.setGradient( aspect, Qt::black ); } // no Fill for ( auto placement : { A::Horizontal, A::Vertical } ) { const auto aspect = Fill | placement; - setMetric( aspect | A::Size, 0 ); + ed.setMetric( aspect | A::Size, 0 ); } // Handle @@ -67,20 +72,20 @@ OtherSlider::OtherSlider( QQuickItem* parentItem ) { const auto aspect = Handle | placement; - setBoxBorderMetricsHint( aspect, 1 ); - setBoxShapeHint( aspect, 4 ); + ed.setBoxBorderMetrics( aspect, 1 ); + ed.setBoxShape( aspect, 4 ); const qreal m = 0.5 * std::ceil( 0.5 * ( w - h ) ) + 1; if ( placement == A::Horizontal ) - setMarginHint( aspect, QskMargins( -m, 0 ) ); + ed.setMargin( aspect, QskMargins( -m, 0 ) ); else - setMarginHint( aspect, QskMargins( 0, -m ) ); + ed.setMargin( aspect, QskMargins( 0, -m ) ); for ( auto state : { A::NoState, Pressed } ) { - setBoxBorderColorsHint( aspect | state, Grey600 ); - setGradientHint( aspect | state, Blue400 ); + ed.setBoxBorderColors( aspect | state, Grey600 ); + ed.setGradient( aspect | state, Blue400 ); } } }