From 91c16e8076c597e09f08b3509e5d2a80752eac1a Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Thu, 25 Apr 2019 14:23:39 +0200 Subject: [PATCH] making layout calculations of the skinlets independent from the current of the control --- examples/automotive/SpeedometerSkinlet.cpp | 36 ++++++++----- examples/automotive/SpeedometerSkinlet.h | 4 +- examples/mycontrols/MyToggleButtonSkinlet.cpp | 29 ++++++----- examples/mycontrols/MyToggleButtonSkinlet.h | 6 ++- examples/sliders/SliderSkinlet.cpp | 51 +++++++++++-------- examples/sliders/SliderSkinlet.h | 10 ++-- src/controls/QskBoxSkinlet.cpp | 9 ++-- src/controls/QskBoxSkinlet.h | 2 +- src/controls/QskControl.cpp | 6 +++ src/controls/QskControl.h | 2 + src/controls/QskFocusIndicatorSkinlet.cpp | 10 ++-- src/controls/QskFocusIndicatorSkinlet.h | 2 +- src/controls/QskGraphicLabelSkinlet.cpp | 15 +++--- src/controls/QskGraphicLabelSkinlet.h | 4 +- src/controls/QskPageIndicatorSkinlet.cpp | 12 ++--- src/controls/QskPageIndicatorSkinlet.h | 2 +- src/controls/QskPopupSkinlet.cpp | 6 +-- src/controls/QskPopupSkinlet.h | 2 +- src/controls/QskPushButton.cpp | 2 +- src/controls/QskPushButtonSkinlet.cpp | 28 +++++----- src/controls/QskPushButtonSkinlet.h | 6 +-- src/controls/QskScrollViewSkinlet.cpp | 50 ++++++++++-------- src/controls/QskScrollViewSkinlet.h | 8 +-- src/controls/QskSeparatorSkinlet.cpp | 18 +++---- src/controls/QskSeparatorSkinlet.h | 4 +- src/controls/QskSkinlet.cpp | 20 ++++++-- src/controls/QskSkinlet.h | 6 ++- src/controls/QskSkinnable.cpp | 5 -- src/controls/QskSkinnable.h | 2 - src/controls/QskSliderSkinlet.cpp | 49 ++++++++++-------- src/controls/QskSliderSkinlet.h | 14 ++--- src/controls/QskStatusIndicatorSkinlet.cpp | 14 ++--- src/controls/QskStatusIndicatorSkinlet.h | 4 +- src/controls/QskSubWindowAreaSkinlet.cpp | 10 ++-- src/controls/QskSubWindowAreaSkinlet.h | 2 +- src/controls/QskSubWindowSkinlet.cpp | 37 ++++++++------ src/controls/QskSubWindowSkinlet.h | 8 +-- src/controls/QskTabButton.cpp | 2 +- src/controls/QskTabButtonSkinlet.cpp | 14 ++--- src/controls/QskTabButtonSkinlet.h | 2 +- src/controls/QskTabViewSkinlet.cpp | 20 +++++--- src/controls/QskTabViewSkinlet.h | 6 +-- src/controls/QskTextInputSkinlet.cpp | 13 +++-- src/controls/QskTextInputSkinlet.h | 2 +- src/controls/QskTextLabelSkinlet.cpp | 10 ++-- src/controls/QskTextLabelSkinlet.h | 2 +- 46 files changed, 308 insertions(+), 258 deletions(-) diff --git a/examples/automotive/SpeedometerSkinlet.cpp b/examples/automotive/SpeedometerSkinlet.cpp index 59536893..b0105b39 100644 --- a/examples/automotive/SpeedometerSkinlet.cpp +++ b/examples/automotive/SpeedometerSkinlet.cpp @@ -47,13 +47,10 @@ SpeedometerSkinlet::SpeedometerSkinlet( QskSkin* skin ) SpeedometerSkinlet::~SpeedometerSkinlet() = default; -QRectF SpeedometerSkinlet::subControlRect( - const QskSkinnable* skinnable, QskAspect::Subcontrol ) const +QRectF SpeedometerSkinlet::subControlRect( const QskSkinnable*, + const QRectF& contentsRect, QskAspect::Subcontrol ) const { - const auto speedometer = static_cast< const Speedometer* >( skinnable ); - - // ### differentiate for subcontrols - return speedometer->contentsRect(); + return contentsRect; } QSGNode* SpeedometerSkinlet::updateSubNode( @@ -77,7 +74,8 @@ QSGNode* SpeedometerSkinlet::updateSubNode( } } -QSGNode* SpeedometerSkinlet::updatePanelNode( const Speedometer* speedometer, QSGNode* node ) const +QSGNode* SpeedometerSkinlet::updatePanelNode( + const Speedometer* speedometer, QSGNode* node ) const { auto boxNode = static_cast< QskBoxNode* >( node ); @@ -86,8 +84,11 @@ QSGNode* SpeedometerSkinlet::updatePanelNode( const Speedometer* speedometer, QS boxNode = new QskBoxNode; } - QRectF panelRect = subControlRect( speedometer, Speedometer::Panel ); - qreal radius = panelRect.width() / 2; + const auto panelRect = subControlRect( + speedometer, speedometer->contentsRect(), Speedometer::Panel ); + + const qreal radius = panelRect.width() / 2; + QskBoxShapeMetrics shapeMetrics( radius, radius, radius, radius ); QskBoxBorderMetrics borderMetrics = speedometer->boxBorderMetricsHint( Speedometer::Panel ); QskBoxBorderColors borderColors = speedometer->boxBorderColorsHint( Speedometer::Panel ); @@ -127,9 +128,11 @@ QSGNode* SpeedometerSkinlet::updateLabelsNode( const Speedometer* speedometer, Q auto vertexData = geometry->vertexDataAsPoint2D(); memset( vertexData, 0, static_cast< size_t >( geometry->vertexCount() ) ); - QMarginsF panelMargins = speedometer->marginsHint( Speedometer::Panel | QskAspect::Margin ); - const QRectF panelRect = subControlRect( speedometer, - Speedometer::Panel ).marginsRemoved( panelMargins ); + const auto panelMargins = speedometer->marginsHint( Speedometer::Panel | QskAspect::Margin ); + + auto panelRect = subControlRect( + speedometer, speedometer->contentsRect(), Speedometer::Panel ); + panelRect = panelRect.marginsRemoved( panelMargins ); QPointF center = QPointF( panelRect.x() + panelRect.width() / 2, panelRect.y() + panelRect.height() / 2 ); @@ -227,8 +230,13 @@ QSGNode* SpeedometerSkinlet::updateNeedleNode( boxNode = static_cast< QskBoxNode* >( needleNode->childAtIndex( 0 ) ); } - QMarginsF margins = speedometer->marginsHint( Speedometer::Panel | QskAspect::Margin ); - const QRectF panelRect = subControlRect( speedometer, Speedometer::Panel ).marginsRemoved( margins ); + const auto margins = speedometer->marginsHint( Speedometer::Panel | QskAspect::Margin ); + + auto panelRect = subControlRect( + speedometer, speedometer->contentsRect(), Speedometer::Panel ); + + panelRect = panelRect.marginsRemoved( margins ); + auto radius = speedometer->metric( Speedometer::NeedleHead | QskAspect::Size ); QPointF center = QPointF( panelRect.x() + panelRect.width() / 2, panelRect.y() + panelRect.height() / 2 ); diff --git a/examples/automotive/SpeedometerSkinlet.h b/examples/automotive/SpeedometerSkinlet.h index da9c4c62..42259caa 100644 --- a/examples/automotive/SpeedometerSkinlet.h +++ b/examples/automotive/SpeedometerSkinlet.h @@ -20,8 +20,8 @@ class SpeedometerSkinlet : public QskSkinlet Q_INVOKABLE SpeedometerSkinlet( QskSkin* skin = nullptr ); ~SpeedometerSkinlet() override; - QRectF subControlRect( const QskSkinnable* skinnable, - QskAspect::Subcontrol ) const override; + QRectF subControlRect( const QskSkinnable*, + const QRectF&, QskAspect::Subcontrol ) const override; protected: virtual QSGNode* updateSubNode( const QskSkinnable*, diff --git a/examples/mycontrols/MyToggleButtonSkinlet.cpp b/examples/mycontrols/MyToggleButtonSkinlet.cpp index 6646dd25..c7ab887f 100644 --- a/examples/mycontrols/MyToggleButtonSkinlet.cpp +++ b/examples/mycontrols/MyToggleButtonSkinlet.cpp @@ -33,8 +33,8 @@ MyToggleButtonSkinlet::MyToggleButtonSkinlet( QskSkin* skin ) ); } -QRectF MyToggleButtonSkinlet::subControlRect( - const QskSkinnable* skinnable, QskAspect::Subcontrol subControl ) const +QRectF MyToggleButtonSkinlet::subControlRect( const QskSkinnable* skinnable, + const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const { using Q = MyToggleButton; @@ -42,25 +42,25 @@ QRectF MyToggleButtonSkinlet::subControlRect( if( subControl == Q::Panel ) { - return button->contentsRect(); + return contentsRect; } else if( subControl == Q::UncheckedPanel ) { - const auto rect = innerRect( skinnable, Q::Panel ); - return sectionRect( rect, button->isInverted() ? 0 : 1 ); + const auto r = innerRect( skinnable, contentsRect, Q::Panel ); + return sectionRect( r, button->isInverted() ? 0 : 1 ); } else if( subControl == Q::CheckedPanel ) { - const auto rect = innerRect( skinnable, Q::Panel ); - return sectionRect( rect, button->isInverted() ? 1 : 0 ); + const auto r = innerRect( skinnable, contentsRect, Q::Panel ); + return sectionRect( r, button->isInverted() ? 1 : 0 ); } else if( subControl == Q::CheckedLabel || subControl == Q::CheckedIcon ) { - return innerRect( skinnable, Q::CheckedPanel ); + return innerRect( skinnable, contentsRect, Q::CheckedPanel ); } else if( subControl == Q::UncheckedLabel || subControl == Q::UncheckedIcon ) { - return innerRect( skinnable, Q::UncheckedPanel ); + return innerRect( skinnable, contentsRect, Q::UncheckedPanel ); } else if( subControl == Q::Cursor ) { @@ -68,7 +68,7 @@ QRectF MyToggleButtonSkinlet::subControlRect( if ( button->isInverted() ) position = 1.0 - position; - auto rect = innerRect( skinnable, Q::Panel ); + auto rect = innerRect( skinnable, contentsRect, Q::Panel ); rect.setWidth( 0.5 * rect.width() ); rect.moveLeft( rect.left() + position * rect.width() ); @@ -76,13 +76,14 @@ QRectF MyToggleButtonSkinlet::subControlRect( return rect; } - return Inherited::subControlRect( skinnable, subControl ); + return Inherited::subControlRect( skinnable, contentsRect, subControl ); } -QRectF MyToggleButtonSkinlet::innerRect( - const QskSkinnable* skinnable, QskAspect::Subcontrol subControl ) const +QRectF MyToggleButtonSkinlet::innerRect( const QskSkinnable* skinnable, + const QRectF& rect, QskAspect::Subcontrol subControl ) const { - return skinnable->innerBox( subControl, subControlRect( skinnable, subControl ) ); + const auto r = subControlRect( skinnable, rect, subControl ); + return skinnable->innerBox( subControl, r ); } QSGNode* MyToggleButtonSkinlet::updateSubNode( diff --git a/examples/mycontrols/MyToggleButtonSkinlet.h b/examples/mycontrols/MyToggleButtonSkinlet.h index 3cb37178..5828c2bb 100644 --- a/examples/mycontrols/MyToggleButtonSkinlet.h +++ b/examples/mycontrols/MyToggleButtonSkinlet.h @@ -34,13 +34,15 @@ class MyToggleButtonSkinlet : public QskSkinlet Q_INVOKABLE MyToggleButtonSkinlet( QskSkin* = nullptr ); ~MyToggleButtonSkinlet() override = default; - QRectF subControlRect( const QskSkinnable*, QskAspect::Subcontrol ) const override; + QRectF subControlRect( const QskSkinnable*, + const QRectF&, QskAspect::Subcontrol ) const override; protected: QSGNode* updateSubNode( const QskSkinnable*, quint8 nodeRole, QSGNode* ) const override; private: - QRectF innerRect( const QskSkinnable*, QskAspect::Subcontrol ) const; + QRectF innerRect( const QskSkinnable*, + const QRectF&, QskAspect::Subcontrol ) const; }; #endif diff --git a/examples/sliders/SliderSkinlet.cpp b/examples/sliders/SliderSkinlet.cpp index 517490f1..3610f30b 100644 --- a/examples/sliders/SliderSkinlet.cpp +++ b/examples/sliders/SliderSkinlet.cpp @@ -120,8 +120,8 @@ SliderSkinlet::~SliderSkinlet() { } -QRectF SliderSkinlet::subControlRect( - const QskSkinnable* skinnable, QskAspect::Subcontrol subControl ) const +QRectF SliderSkinlet::subControlRect( const QskSkinnable* skinnable, + const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const { const auto slider = static_cast< const QskSlider* >( skinnable ); @@ -131,22 +131,22 @@ QRectF SliderSkinlet::subControlRect( } else if ( subControl == QskSlider::Fill ) { - return fillRect( slider ); + return fillRect( slider, contentsRect ); } else if ( subControl == QskSlider::Handle ) { - return handleRect( slider ); + return handleRect( slider, contentsRect ); } else if ( subControl == Slider::Scale ) { - return scaleRect( slider ); + return scaleRect( contentsRect ); } else if ( subControl == Slider::Decoration ) { - return decorationRect( slider ); + return decorationRect( slider, contentsRect ); } - return Inherited::subControlRect( skinnable, subControl ); + return Inherited::subControlRect( skinnable, contentsRect, subControl ); } QSGNode* SliderSkinlet::updateSubNode( @@ -173,9 +173,9 @@ QSGNode* SliderSkinlet::updateSubNode( } } -QRectF SliderSkinlet::scaleRect( const QskSlider* slider ) const +QRectF SliderSkinlet::scaleRect( const QRectF& contentsRect ) const { - auto r = slider->contentsRect(); + auto r = contentsRect; r.setX( r.left() + qskMargin ); r.setBottom( r.center().y() ); @@ -185,9 +185,10 @@ QRectF SliderSkinlet::scaleRect( const QskSlider* slider ) const return r; } -QRectF SliderSkinlet::fillRect( const QskSlider* slider ) const +QRectF SliderSkinlet::fillRect( + const QskSlider* slider, const QRectF& contentsRect ) const { - auto r = subControlRect( slider, Slider::Scale ); + auto r = subControlRect( slider, contentsRect, Slider::Scale ); r.setTop( r.bottom() - qskMinorTick ); r.setWidth( r.width() * slider->position() ); @@ -195,22 +196,23 @@ QRectF SliderSkinlet::fillRect( const QskSlider* slider ) const return r; } -QRectF SliderSkinlet::decorationRect( const QskSlider* slider ) const +QRectF SliderSkinlet::decorationRect( + const QskSlider* slider, const QRectF& contentsRect ) const { // decoration exceeds scale !!!! - auto r = subControlRect( slider, Slider::Scale ); + auto r = subControlRect( slider, contentsRect, Slider::Scale ); r.setBottom( r.top() ); r.setTop( r.bottom() - QFontMetricsF( qskLabelFont ).height() ); return r; } -QRectF SliderSkinlet::handleRect( const QskSlider* slider ) const +QRectF SliderSkinlet::handleRect( + const QskSlider* slider, const QRectF& contentsRect ) const { - const QRectF contentsRect = slider->contentsRect(); - const QRectF fillRect = subControlRect( slider, QskSlider::Fill ); - const QRectF scaleRect = subControlRect( slider, Slider::Scale ); + const QRectF fillRect = subControlRect( slider, contentsRect, QskSlider::Fill ); + const QRectF scaleRect = subControlRect( slider, contentsRect, Slider::Scale ); QRectF handleRect( 0, scaleRect.bottom(), 80, 50 ); handleRect.moveCenter( QPointF( fillRect.right(), handleRect.center().y() ) ); @@ -226,7 +228,9 @@ QRectF SliderSkinlet::handleRect( const QskSlider* slider ) const QSGNode* SliderSkinlet::updateScaleNode( const QskSlider* slider, QSGNode* node ) const { - const QRectF scaleRect = subControlRect( slider, Slider::Scale ); + const auto scaleRect = subControlRect( + slider, slider->contentsRect(), Slider::Scale ); + if ( scaleRect.isEmpty() ) return nullptr; @@ -267,7 +271,9 @@ QSGNode* SliderSkinlet::updateScaleNode( QSGNode* SliderSkinlet::updateDecorationNode( const QskSlider* slider, QSGNode* node ) const { - const QRectF decorationRect = subControlRect( slider, Slider::Decoration ); + const QRectF decorationRect = subControlRect( + slider, slider->contentsRect(), Slider::Decoration ); + if ( decorationRect.isEmpty() ) return nullptr; @@ -317,11 +323,14 @@ QSGNode* SliderSkinlet::updateDecorationNode( QSGNode* SliderSkinlet::updateHandleNode( const QskSlider* slider, QSGNode* node ) const { - const QRectF handleRect = subControlRect( slider, QskSlider::Handle ); + const QRectF handleRect = subControlRect( + slider, slider->contentsRect(), QskSlider::Handle ); + if ( handleRect.isEmpty() ) return nullptr; - const QRectF fillRect = subControlRect( slider, QskSlider::Fill ); + const QRectF fillRect = subControlRect( + slider, slider->contentsRect(), QskSlider::Fill ); auto handleNode = static_cast< HandleNode* >( node ); if ( handleNode == nullptr ) diff --git a/examples/sliders/SliderSkinlet.h b/examples/sliders/SliderSkinlet.h index a970aa99..7248b65c 100644 --- a/examples/sliders/SliderSkinlet.h +++ b/examples/sliders/SliderSkinlet.h @@ -26,7 +26,7 @@ class SliderSkinlet : public QskSliderSkinlet ~SliderSkinlet() override; QRectF subControlRect( const QskSkinnable*, - QskAspect::Subcontrol ) const override; + const QRectF&, QskAspect::Subcontrol ) const override; protected: QSGNode* updateSubNode( const QskSkinnable*, @@ -37,10 +37,10 @@ class SliderSkinlet : public QskSliderSkinlet QSGNode* updateDecorationNode( const QskSlider*, QSGNode* ) const; QSGNode* updateHandleNode( const QskSlider*, QSGNode* ) const; - QRectF fillRect( const QskSlider* ) const; - QRectF scaleRect( const QskSlider* ) const; - QRectF decorationRect( const QskSlider* ) const; - QRectF handleRect( const QskSlider* ) const; + QRectF scaleRect( const QRectF& ) const; + QRectF fillRect( const QskSlider*, const QRectF& ) const; + QRectF decorationRect( const QskSlider*, const QRectF& ) const; + QRectF handleRect( const QskSlider*, const QRectF& ) const; }; #endif diff --git a/src/controls/QskBoxSkinlet.cpp b/src/controls/QskBoxSkinlet.cpp index d9d46a5d..0098969c 100644 --- a/src/controls/QskBoxSkinlet.cpp +++ b/src/controls/QskBoxSkinlet.cpp @@ -16,16 +16,15 @@ QskBoxSkinlet::~QskBoxSkinlet() { } -QRectF QskBoxSkinlet::subControlRect( - const QskSkinnable* skinnable, QskAspect::Subcontrol subControl ) const +QRectF QskBoxSkinlet::subControlRect( const QskSkinnable* skinnable, + const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const { if ( subControl == QskBox::Panel ) { - const auto box = static_cast< const QskBox* >( skinnable ); - return box->contentsRect(); + return contentsRect; } - return Inherited::subControlRect( skinnable, subControl ); + return Inherited::subControlRect( skinnable, contentsRect, subControl ); } QSGNode* QskBoxSkinlet::updateSubNode( diff --git a/src/controls/QskBoxSkinlet.h b/src/controls/QskBoxSkinlet.h index 1c55e88b..7ca5ad2f 100644 --- a/src/controls/QskBoxSkinlet.h +++ b/src/controls/QskBoxSkinlet.h @@ -24,7 +24,7 @@ class QSK_EXPORT QskBoxSkinlet : public QskSkinlet ~QskBoxSkinlet() override; QRectF subControlRect( const QskSkinnable*, - QskAspect::Subcontrol ) const override; + const QRectF&, QskAspect::Subcontrol ) const override; protected: QSGNode* updateSubNode( const QskSkinnable*, diff --git a/src/controls/QskControl.cpp b/src/controls/QskControl.cpp index 0db72187..b157cac0 100644 --- a/src/controls/QskControl.cpp +++ b/src/controls/QskControl.cpp @@ -11,6 +11,7 @@ #include "QskQuick.h" #include "QskSetup.h" #include "QskSkin.h" +#include "QskSkinlet.h" #include "QskSkinHintTable.h" #include @@ -1007,6 +1008,11 @@ QRectF QskControl::contentsRect() const return qskValidOrEmptyInnerRect( rect(), margins() ); } +QRectF QskControl::subControlRect( QskAspect::Subcontrol subControl ) const +{ + return effectiveSkinlet()->subControlRect( this, contentsRect(), subControl ); +} + bool QskControl::layoutMirroring() const { return d_func()->effectiveLayoutMirror; diff --git a/src/controls/QskControl.h b/src/controls/QskControl.h index aed3913f..79054e2b 100644 --- a/src/controls/QskControl.h +++ b/src/controls/QskControl.h @@ -115,6 +115,8 @@ class QSK_EXPORT QskControl : public QQuickItem, public QskSkinnable virtual QRectF gestureRect() const; virtual QRectF focusIndicatorRect() const; + QRectF subControlRect( QskAspect::Subcontrol ) const; + void setAutoFillBackground( bool ); bool autoFillBackground() const; diff --git a/src/controls/QskFocusIndicatorSkinlet.cpp b/src/controls/QskFocusIndicatorSkinlet.cpp index f75dceee..04036983 100644 --- a/src/controls/QskFocusIndicatorSkinlet.cpp +++ b/src/controls/QskFocusIndicatorSkinlet.cpp @@ -14,17 +14,15 @@ QskFocusIndicatorSkinlet::QskFocusIndicatorSkinlet( QskSkin* skin ) QskFocusIndicatorSkinlet::~QskFocusIndicatorSkinlet() = default; -QRectF QskFocusIndicatorSkinlet::subControlRect( - const QskSkinnable* skinnable, QskAspect::Subcontrol subControl ) const +QRectF QskFocusIndicatorSkinlet::subControlRect( const QskSkinnable* skinnable, + const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const { - const auto indicator = static_cast< const QskFocusIndicator* >( skinnable ); - if ( subControl == QskFocusIndicator::Panel ) { - return indicator->rect(); + return contentsRect; } - return Inherited::subControlRect( skinnable, subControl ); + return Inherited::subControlRect( skinnable, contentsRect, subControl ); } QSGNode* QskFocusIndicatorSkinlet::updateSubNode( diff --git a/src/controls/QskFocusIndicatorSkinlet.h b/src/controls/QskFocusIndicatorSkinlet.h index caa588ab..7c3bf29d 100644 --- a/src/controls/QskFocusIndicatorSkinlet.h +++ b/src/controls/QskFocusIndicatorSkinlet.h @@ -26,7 +26,7 @@ class QSK_EXPORT QskFocusIndicatorSkinlet : public QskSkinlet ~QskFocusIndicatorSkinlet() override; QRectF subControlRect( const QskSkinnable*, - QskAspect::Subcontrol ) const override; + const QRectF&, QskAspect::Subcontrol ) const override; protected: QSGNode* updateSubNode( const QskSkinnable*, diff --git a/src/controls/QskGraphicLabelSkinlet.cpp b/src/controls/QskGraphicLabelSkinlet.cpp index 975c216f..18b2bccf 100644 --- a/src/controls/QskGraphicLabelSkinlet.cpp +++ b/src/controls/QskGraphicLabelSkinlet.cpp @@ -20,17 +20,17 @@ QskGraphicLabelSkinlet::QskGraphicLabelSkinlet( QskSkin* skin ) QskGraphicLabelSkinlet::~QskGraphicLabelSkinlet() = default; -QRectF QskGraphicLabelSkinlet::subControlRect( - const QskSkinnable* skinnable, QskAspect::Subcontrol subControl ) const +QRectF QskGraphicLabelSkinlet::subControlRect( const QskSkinnable* skinnable, + const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const { const auto label = static_cast< const QskGraphicLabel* >( skinnable ); if ( subControl == QskGraphicLabel::Graphic ) { - return graphicRect( label ); + return graphicRect( label, contentsRect ); } - return Inherited::subControlRect( skinnable, subControl ); + return Inherited::subControlRect( skinnable, contentsRect, subControl ); } QSGNode* QskGraphicLabelSkinlet::updateSubNode( @@ -49,14 +49,15 @@ QSGNode* QskGraphicLabelSkinlet::updateSubNode( return Inherited::updateSubNode( skinnable, nodeRole, node ); } -QRect QskGraphicLabelSkinlet::graphicRect( const QskGraphicLabel* label ) const +QRect QskGraphicLabelSkinlet::graphicRect( + const QskGraphicLabel* label, const QRectF& contentsRect ) const { // textures are in integers, to avoid useless recalculations // that finally will be rounded anyway, we calculate in integers const auto fillMode = label->fillMode(); - const QRect graphicRect = label->contentsRect().toAlignedRect(); + const QRect graphicRect = contentsRect.toAlignedRect(); if ( fillMode == QskGraphicLabel::Stretch ) { @@ -82,7 +83,7 @@ QSGNode* QskGraphicLabelSkinlet::updateGraphicNode( const QskGraphicLabel* label, QSGNode* node ) const { const auto colorFilter = label->graphicFilter(); - const auto rect = subControlRect( label, QskGraphicLabel::Graphic ); + const auto rect = label->subControlRect( QskGraphicLabel::Graphic ); if ( label->fillMode() == QskGraphicLabel::Stretch ) { diff --git a/src/controls/QskGraphicLabelSkinlet.h b/src/controls/QskGraphicLabelSkinlet.h index 1f60180e..b7ecbeaf 100644 --- a/src/controls/QskGraphicLabelSkinlet.h +++ b/src/controls/QskGraphicLabelSkinlet.h @@ -26,14 +26,14 @@ class QSK_EXPORT QskGraphicLabelSkinlet : public QskSkinlet ~QskGraphicLabelSkinlet() override; QRectF subControlRect( const QskSkinnable*, - QskAspect::Subcontrol ) const override; + const QRectF&, QskAspect::Subcontrol ) const override; protected: QSGNode* updateSubNode( const QskSkinnable*, quint8 nodeRole, QSGNode* ) const override; private: - QRect graphicRect( const QskGraphicLabel* ) const; + QRect graphicRect( const QskGraphicLabel*, const QRectF& ) const; QSGNode* updateGraphicNode( const QskGraphicLabel*, QSGNode* ) const; }; diff --git a/src/controls/QskPageIndicatorSkinlet.cpp b/src/controls/QskPageIndicatorSkinlet.cpp index dd99c5ab..7b42de0d 100644 --- a/src/controls/QskPageIndicatorSkinlet.cpp +++ b/src/controls/QskPageIndicatorSkinlet.cpp @@ -18,17 +18,15 @@ QskPageIndicatorSkinlet::~QskPageIndicatorSkinlet() { } -QRectF QskPageIndicatorSkinlet::subControlRect( - const QskSkinnable* skinnable, QskAspect::Subcontrol subControl ) const +QRectF QskPageIndicatorSkinlet::subControlRect( const QskSkinnable* skinnable, + const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const { - const auto indicator = static_cast< const QskPageIndicator* >( skinnable ); - if ( subControl == QskPageIndicator::Panel ) { - return indicator->contentsRect(); + return contentsRect; } - return Inherited::subControlRect( skinnable, subControl ); + return Inherited::subControlRect( skinnable, contentsRect, subControl ); } QSGNode* QskPageIndicatorSkinlet::updateSubNode( @@ -137,7 +135,7 @@ QSGNode* QskPageIndicatorSkinlet::updateBulletsNode( if ( node == nullptr ) node = new QSGNode(); - QRectF rect = subControlRect( indicator, QskPageIndicator::Panel ); + QRectF rect = indicator->subControlRect( QskPageIndicator::Panel ); rect = indicator->innerBox( QskPageIndicator::Panel, rect ); // index of the highlighted bullet diff --git a/src/controls/QskPageIndicatorSkinlet.h b/src/controls/QskPageIndicatorSkinlet.h index a5d9ec96..a1c0ff14 100644 --- a/src/controls/QskPageIndicatorSkinlet.h +++ b/src/controls/QskPageIndicatorSkinlet.h @@ -27,7 +27,7 @@ class QSK_EXPORT QskPageIndicatorSkinlet : public QskSkinlet ~QskPageIndicatorSkinlet() override; QRectF subControlRect( const QskSkinnable*, - QskAspect::Subcontrol ) const override; + const QRectF&, QskAspect::Subcontrol ) const override; protected: QSGNode* updateSubNode( const QskSkinnable*, diff --git a/src/controls/QskPopupSkinlet.cpp b/src/controls/QskPopupSkinlet.cpp index 4bfd0b0a..9ac3642f 100644 --- a/src/controls/QskPopupSkinlet.cpp +++ b/src/controls/QskPopupSkinlet.cpp @@ -14,15 +14,15 @@ QskPopupSkinlet::QskPopupSkinlet( QskSkin* skin ) QskPopupSkinlet::~QskPopupSkinlet() = default; -QRectF QskPopupSkinlet::subControlRect( - const QskSkinnable* skinnable, QskAspect::Subcontrol subControl ) const +QRectF QskPopupSkinlet::subControlRect( const QskSkinnable* skinnable, + const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const { const auto popup = static_cast< const QskPopup* >( skinnable ); if ( subControl == QskPopup::Overlay ) return popup->overlayRect(); - return Inherited::subControlRect( skinnable, subControl ); + return Inherited::subControlRect( skinnable, contentsRect, subControl ); } QSGNode* QskPopupSkinlet::updateSubNode( diff --git a/src/controls/QskPopupSkinlet.h b/src/controls/QskPopupSkinlet.h index 53997dd6..93699256 100644 --- a/src/controls/QskPopupSkinlet.h +++ b/src/controls/QskPopupSkinlet.h @@ -26,7 +26,7 @@ class QSK_EXPORT QskPopupSkinlet : public QskSkinlet ~QskPopupSkinlet() override; QRectF subControlRect( const QskSkinnable*, - QskAspect::Subcontrol ) const override; + const QRectF&, QskAspect::Subcontrol ) const override; protected: QSGNode* updateSubNode( const QskSkinnable*, diff --git a/src/controls/QskPushButton.cpp b/src/controls/QskPushButton.cpp index 64a4adec..2d2bbc31 100644 --- a/src/controls/QskPushButton.cpp +++ b/src/controls/QskPushButton.cpp @@ -247,7 +247,7 @@ void QskPushButton::updateLayout() QRectF QskPushButton::layoutRect() const { - return innerBox( Panel, effectiveSkinlet()->subControlRect( this, Panel ) ); + return innerBox( Panel, subControlRect( Panel ) ); } QSizeF QskPushButton::contentsSizeHint() const diff --git a/src/controls/QskPushButtonSkinlet.cpp b/src/controls/QskPushButtonSkinlet.cpp index b4501cc1..f0c4098b 100644 --- a/src/controls/QskPushButtonSkinlet.cpp +++ b/src/controls/QskPushButtonSkinlet.cpp @@ -20,25 +20,25 @@ QskPushButtonSkinlet::QskPushButtonSkinlet( QskSkin* skin ) QskPushButtonSkinlet::~QskPushButtonSkinlet() = default; -QRectF QskPushButtonSkinlet::subControlRect( - const QskSkinnable* skinnable, QskAspect::Subcontrol subControl ) const +QRectF QskPushButtonSkinlet::subControlRect( const QskSkinnable* skinnable, + const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const { const auto button = static_cast< const QskPushButton* >( skinnable ); if ( subControl == QskPushButton::Text ) { - return textRect( button ); + return textRect( button, contentsRect ); } else if ( subControl == QskPushButton::Graphic ) { - return graphicRect( button ); + return graphicRect( button, contentsRect ); } else if ( subControl == QskPushButton::Panel ) { - return button->contentsRect(); + return contentsRect; } - return Inherited::subControlRect( skinnable, subControl ); + return Inherited::subControlRect( skinnable, contentsRect, subControl ); } QSGNode* QskPushButtonSkinlet::updateSubNode( @@ -68,12 +68,13 @@ QSGNode* QskPushButtonSkinlet::updateSubNode( return Inherited::updateSubNode( skinnable, nodeRole, node ); } -QRectF QskPushButtonSkinlet::textRect( const QskPushButton* button ) const +QRectF QskPushButtonSkinlet::textRect( + const QskPushButton* button, const QRectF& contentsRect ) const { // buttonShift -> TODO QRectF r = button->innerBox( QskPushButton::Panel, - subControlRect( button, QskPushButton::Panel ) ); + subControlRect( button, contentsRect, QskPushButton::Panel ) ); if ( button->hasGraphic() ) { @@ -87,14 +88,17 @@ QRectF QskPushButtonSkinlet::textRect( const QskPushButton* button ) const return r; } -QRectF QskPushButtonSkinlet::graphicRect( const QskPushButton* button ) const +QRectF QskPushButtonSkinlet::graphicRect( + const QskPushButton* button, const QRectF& contentsRect ) const { // buttonShift -> TODO - QRectF r = button->innerBox( QskPushButton::Panel, button->contentsRect() ); + + QRectF r = button->innerBox( QskPushButton::Panel, + subControlRect( button, contentsRect, QskPushButton::Panel ) ); if ( !button->text().isEmpty() ) { - qreal h = textRect( button ).height() + + qreal h = textRect( button, contentsRect ).height() + button->metric( QskPushButton::Panel | QskAspect::Spacing ); if ( h < r.height() ) @@ -149,7 +153,7 @@ QRectF QskPushButtonSkinlet::graphicRect( const QskPushButton* button ) const QSGNode* QskPushButtonSkinlet::updateTextNode( const QskPushButton* button, QSGNode* node ) const { - const auto rect = subControlRect( button, QskPushButton::Text ).toAlignedRect(); + const auto rect = button->subControlRect( QskPushButton::Text ).toAlignedRect(); const QFontMetricsF fm( button->effectiveFont( QskPushButton::Text ) ); if ( !button->clip() && ( rect.height() < fm.height() ) ) diff --git a/src/controls/QskPushButtonSkinlet.h b/src/controls/QskPushButtonSkinlet.h index 43e08be3..990cd944 100644 --- a/src/controls/QskPushButtonSkinlet.h +++ b/src/controls/QskPushButtonSkinlet.h @@ -28,15 +28,15 @@ class QSK_EXPORT QskPushButtonSkinlet : public QskSkinlet ~QskPushButtonSkinlet() override; QRectF subControlRect( const QskSkinnable*, - QskAspect::Subcontrol ) const override; + const QRectF&, QskAspect::Subcontrol ) const override; protected: QSGNode* updateSubNode( const QskSkinnable*, quint8 nodeRole, QSGNode* ) const override; private: - QRectF textRect( const QskPushButton* ) const; - QRectF graphicRect( const QskPushButton* ) const; + QRectF textRect( const QskPushButton*, const QRectF& ) const; + QRectF graphicRect( const QskPushButton*, const QRectF& ) const; QSGNode* updateTextNode( const QskPushButton*, QSGNode* ) const; }; diff --git a/src/controls/QskScrollViewSkinlet.cpp b/src/controls/QskScrollViewSkinlet.cpp index 4c54716b..b7b95b5f 100644 --- a/src/controls/QskScrollViewSkinlet.cpp +++ b/src/controls/QskScrollViewSkinlet.cpp @@ -47,43 +47,42 @@ QskScrollViewSkinlet::QskScrollViewSkinlet( QskSkin* skin ) QskScrollViewSkinlet::~QskScrollViewSkinlet() = default; -QRectF QskScrollViewSkinlet::subControlRect( - const QskSkinnable* skinnable, QskAspect::Subcontrol subControl ) const +QRectF QskScrollViewSkinlet::subControlRect( const QskSkinnable* skinnable, + const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const { const auto scrollView = static_cast< const QskScrollView* >( skinnable ); if ( subControl == QskScrollView::Panel ) { - // layoutRect ??? - return scrollView->contentsRect(); + return contentsRect; } if ( subControl == QskScrollView::Viewport ) { - return viewportRect( scrollView ); + return viewportRect( scrollView, contentsRect ); } if ( subControl == QskScrollView::HorizontalScrollBar ) { - return scrollBarRect( scrollView, Qt::Horizontal ); + return scrollBarRect( scrollView, contentsRect, Qt::Horizontal ); } if ( subControl == QskScrollView::HorizontalScrollHandle ) { - return scrollHandleRect( scrollView, Qt::Horizontal ); + return scrollHandleRect( scrollView, contentsRect, Qt::Horizontal ); } if ( subControl == QskScrollView::VerticalScrollBar ) { - return scrollBarRect( scrollView, Qt::Vertical ); + return scrollBarRect( scrollView, contentsRect, Qt::Vertical ); } if ( subControl == QskScrollView::VerticalScrollHandle ) { - return scrollHandleRect( scrollView, Qt::Vertical ); + return scrollHandleRect( scrollView, contentsRect, Qt::Vertical ); } - return Inherited::subControlRect( skinnable, subControl ); + return Inherited::subControlRect( skinnable, contentsRect, subControl ); } QSGNode* QskScrollViewSkinlet::updateSubNode( @@ -182,23 +181,28 @@ QSGNode* QskScrollViewSkinlet::contentsNode( const QskScrollView* scrollView ) return nullptr; } -QRectF QskScrollViewSkinlet::viewportRect( const QskScrollView* scrollView ) const +QRectF QskScrollViewSkinlet::viewportRect( + const QskScrollView* scrollView, const QRectF& contentsRect ) const { const Qt::Orientations orientation = scrollView->scrollableOrientations(); - QRectF vr = subControlRect( scrollView, QskScrollView::Panel ); + QRectF vr = subControlRect( scrollView, contentsRect, QskScrollView::Panel ); const qreal spacing = scrollView->metric( QskScrollView::Panel | QskAspect::Spacing ); if ( orientation & Qt::Vertical ) { - const QRectF r = subControlRect( scrollView, QskScrollView::VerticalScrollBar ); + const QRectF r = subControlRect( + scrollView, contentsRect, QskScrollView::VerticalScrollBar ); + if ( r.width() > 0.0 ) vr.setWidth( vr.width() - r.width() - spacing ); } if ( orientation & Qt::Horizontal ) { - const QRectF r = subControlRect( scrollView, QskScrollView::HorizontalScrollBar ); + const QRectF r = subControlRect( + scrollView, contentsRect, QskScrollView::HorizontalScrollBar ); + if ( r.height() >= 0.0 ) vr.setHeight( vr.height() - r.height() - spacing ); } @@ -206,15 +210,17 @@ QRectF QskScrollViewSkinlet::viewportRect( const QskScrollView* scrollView ) con return vr; } -QRectF QskScrollViewSkinlet::scrollHandleRect( - const QskScrollView* scrollView, Qt::Orientation orientation ) const +QRectF QskScrollViewSkinlet::scrollHandleRect( const QskScrollView* scrollView, + const QRectF& contentsRect, Qt::Orientation orientation ) const { const Qt::Orientations scrollOrientations = scrollView->scrollableOrientations(); if ( !( orientation & scrollOrientations ) ) return QRectF(); const QPointF pos = scrollView->scrollPos(); - const QRectF vRect = subControlRect( scrollView, QskScrollView::Viewport ); + + const QRectF vRect = subControlRect( + scrollView, contentsRect, QskScrollView::Viewport ); QRectF handleRect; @@ -222,7 +228,7 @@ QRectF QskScrollViewSkinlet::scrollHandleRect( { const auto subControlBar = QskScrollView::VerticalScrollBar; - const QRectF sbRect = subControlRect( scrollView, subControlBar ); + const QRectF sbRect = subControlRect( scrollView, contentsRect, subControlBar ); const QMarginsF padding = scrollView->marginsHint( subControlBar | QskAspect::Padding ); const qreal h = scrollView->scrollableSize().height(); @@ -245,7 +251,7 @@ QRectF QskScrollViewSkinlet::scrollHandleRect( { const auto subControlBar = QskScrollView::HorizontalScrollBar; - const QRectF sbRect = subControlRect( scrollView, subControlBar ); + const QRectF sbRect = subControlRect( scrollView, contentsRect, subControlBar ); const auto padding = scrollView->marginsHint( subControlBar | QskAspect::Padding ); const qreal w = scrollView->scrollableSize().width(); @@ -268,14 +274,14 @@ QRectF QskScrollViewSkinlet::scrollHandleRect( return handleRect; } -QRectF QskScrollViewSkinlet::scrollBarRect( - const QskScrollView* scrollView, Qt::Orientation orientation ) const +QRectF QskScrollViewSkinlet::scrollBarRect( const QskScrollView* scrollView, + const QRectF& contentsRect, Qt::Orientation orientation ) const { const Qt::Orientations scrollOrientations = scrollView->scrollableOrientations(); if ( !( orientation & scrollOrientations ) ) return QRectF(); - QRectF r = subControlRect( scrollView, QskScrollView::Panel ); + QRectF r = subControlRect( scrollView, contentsRect, QskScrollView::Panel ); if ( orientation == Qt::Horizontal ) { diff --git a/src/controls/QskScrollViewSkinlet.h b/src/controls/QskScrollViewSkinlet.h index f9caf2d1..dc39fd68 100644 --- a/src/controls/QskScrollViewSkinlet.h +++ b/src/controls/QskScrollViewSkinlet.h @@ -33,7 +33,7 @@ class QSK_EXPORT QskScrollViewSkinlet : public QskSkinlet ~QskScrollViewSkinlet() override; QRectF subControlRect( const QskSkinnable*, - QskAspect::Subcontrol ) const override; + const QRectF&, QskAspect::Subcontrol ) const override; protected: QSGNode* updateSubNode( const QskSkinnable*, @@ -45,9 +45,9 @@ class QSK_EXPORT QskScrollViewSkinlet : public QskSkinlet private: QSGNode* updateContentsRootNode( const QskScrollView*, QSGNode* ) const; - QRectF viewportRect( const QskScrollView* ) const; - QRectF scrollBarRect( const QskScrollView*, Qt::Orientation ) const; - QRectF scrollHandleRect( const QskScrollView*, Qt::Orientation ) const; + QRectF viewportRect( const QskScrollView*, const QRectF& ) const; + QRectF scrollBarRect( const QskScrollView*, const QRectF&, Qt::Orientation ) const; + QRectF scrollHandleRect( const QskScrollView*, const QRectF&, Qt::Orientation ) const; }; #endif diff --git a/src/controls/QskSeparatorSkinlet.cpp b/src/controls/QskSeparatorSkinlet.cpp index d1da70e8..26bacb14 100644 --- a/src/controls/QskSeparatorSkinlet.cpp +++ b/src/controls/QskSeparatorSkinlet.cpp @@ -16,17 +16,17 @@ QskSeparatorSkinlet::QskSeparatorSkinlet( QskSkin* skin ) QskSeparatorSkinlet::~QskSeparatorSkinlet() = default; -QRectF QskSeparatorSkinlet::subControlRect( - const QskSkinnable* skinnable, QskAspect::Subcontrol subControl ) const +QRectF QskSeparatorSkinlet::subControlRect( const QskSkinnable* skinnable, + const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const { const auto separator = static_cast< const QskSeparator* >( skinnable ); if ( subControl == QskSeparator::Panel ) { - return panelRect( separator ); + return panelRect( separator, contentsRect ); } - return Inherited::subControlRect( skinnable, subControl ); + return Inherited::subControlRect( skinnable, contentsRect, subControl ); } QSGNode* QskSeparatorSkinlet::updateSubNode( @@ -45,25 +45,25 @@ QSGNode* QskSeparatorSkinlet::updateSubNode( return Inherited::updateSubNode( skinnable, nodeRole, node ); } -QRectF QskSeparatorSkinlet::panelRect( const QskSeparator* separator ) const +QRectF QskSeparatorSkinlet::panelRect( + const QskSeparator* separator, const QRectF& contentsRect ) const { - const QRectF cr = separator->contentsRect(); const qreal m = separator->metric( QskSeparator::Panel | QskAspect::Size ); QRectF r; if ( separator->orientation() == Qt::Horizontal ) { - r.setWidth( cr.width() ); + r.setWidth( contentsRect.width() ); r.setHeight( m ); } else { - r.setHeight( cr.height() ); + r.setHeight( contentsRect.height() ); r.setWidth( m ); } - r.moveCenter( cr.center() ); + r.moveCenter( contentsRect.center() ); return r; } diff --git a/src/controls/QskSeparatorSkinlet.h b/src/controls/QskSeparatorSkinlet.h index 7a659d03..2c6fb740 100644 --- a/src/controls/QskSeparatorSkinlet.h +++ b/src/controls/QskSeparatorSkinlet.h @@ -26,14 +26,14 @@ class QSK_EXPORT QskSeparatorSkinlet : public QskSkinlet ~QskSeparatorSkinlet() override; QRectF subControlRect( const QskSkinnable*, - QskAspect::Subcontrol ) const override; + const QRectF& rect, QskAspect::Subcontrol ) const override; protected: QSGNode* updateSubNode( const QskSkinnable*, quint8 nodeRole, QSGNode* ) const override; private: - QRectF panelRect( const QskSeparator* ) const; + QRectF panelRect( const QskSeparator*, const QRectF& rect ) const; }; #endif diff --git a/src/controls/QskSkinlet.cpp b/src/controls/QskSkinlet.cpp index 4d559ee6..f6f6c1f1 100644 --- a/src/controls/QskSkinlet.cpp +++ b/src/controls/QskSkinlet.cpp @@ -57,6 +57,18 @@ static inline QSGNode* qskFindNodeByFlag( QSGNode* parent, int nodeRole ) return nullptr; } +static inline QRectF qskSubControlRect( const QskSkinlet* skinlet, + const QskSkinnable* skinnable, QskAspect::Subcontrol subControl ) +{ + if ( auto control = skinnable->controlCast() ) + { + const auto r = control->contentsRect(); + return skinlet->subControlRect( skinnable, r, subControl ); + } + + return QRectF(); +} + static inline QSGNode* qskUpdateGraphicNode( const QskSkinnable* skinnable, QSGNode* node, const QskGraphic& graphic, const QskColorFilter& colorFilter, @@ -386,7 +398,7 @@ QSGNode* QskSkinlet::findNodeByRole( QSGNode* parent, quint8 nodeRole ) QSGNode* QskSkinlet::updateBoxNode( const QskSkinnable* skinnable, QSGNode* node, QskAspect::Subcontrol subControl ) const { - const QRectF rect = subControlRect( skinnable, subControl ); + const QRectF rect = qskSubControlRect( this, skinnable, subControl ); return updateBoxNode( skinnable, node, rect, subControl ); } @@ -425,7 +437,7 @@ QSGNode* QskSkinlet::updateBoxNode( const QskSkinnable* skinnable, QSGNode* QskSkinlet::updateBoxClipNode( const QskSkinnable* skinnable, QSGNode* node, QskAspect::Subcontrol subControl ) const { - const QRectF rect = subControlRect( skinnable, subControl ); + const QRectF rect = qskSubControlRect( this, skinnable, subControl ); return updateBoxClipNode( skinnable, node, rect, subControl ); } @@ -513,7 +525,7 @@ QSGNode* QskSkinlet::updateTextNode( const QString& text, const QskTextOptions& textOptions, QskAspect::Subcontrol subControl ) const { - const QRectF rect = subControlRect( skinnable, subControl ); + const QRectF rect = qskSubControlRect( this, skinnable, subControl ); const auto alignment = skinnable->flagHint< Qt::Alignment >( QskAspect::Alignment | subControl, Qt::AlignLeft ); @@ -525,7 +537,7 @@ QSGNode* QskSkinlet::updateGraphicNode( const QskSkinnable* skinnable, QSGNode* node, const QskGraphic& graphic, QskAspect::Subcontrol subcontrol ) const { - const QRectF rect = subControlRect( skinnable, subcontrol ); + const QRectF rect = qskSubControlRect( this, skinnable, subcontrol ); const Qt::Alignment alignment = skinnable->flagHint< Qt::Alignment >( subcontrol | QskAspect::Alignment, Qt::AlignCenter ); diff --git a/src/controls/QskSkinlet.h b/src/controls/QskSkinlet.h index 4117b7b4..b717286d 100644 --- a/src/controls/QskSkinlet.h +++ b/src/controls/QskSkinlet.h @@ -38,7 +38,9 @@ class QSK_EXPORT QskSkinlet QskSkin* skin() const; void updateNode( QskSkinnable*, QSGNode* parent ) const; - virtual QRectF subControlRect( const QskSkinnable*, QskAspect::Subcontrol ) const; + + virtual QRectF subControlRect( + const QskSkinnable*, const QRectF&, QskAspect::Subcontrol ) const; const QVector< quint8 >& nodeRoles() const; @@ -105,7 +107,7 @@ class QSK_EXPORT QskSkinlet }; inline QRectF QskSkinlet::subControlRect( - const QskSkinnable*, QskAspect::Subcontrol ) const + const QskSkinnable*, const QRectF&, QskAspect::Subcontrol ) const { return QRectF(); } diff --git a/src/controls/QskSkinnable.cpp b/src/controls/QskSkinnable.cpp index 5ae98644..16854455 100644 --- a/src/controls/QskSkinnable.cpp +++ b/src/controls/QskSkinnable.cpp @@ -886,11 +886,6 @@ QskAspect::Subcontrol QskSkinnable::effectiveSubcontrol( return subControl; } -QRectF QskSkinnable::subControlRect( QskAspect::Subcontrol subControl ) const -{ - return effectiveSkinlet()->subControlRect( this, subControl ); -} - QskControl* QskSkinnable::controlCast() { return qskIsControl( this ) diff --git a/src/controls/QskSkinnable.h b/src/controls/QskSkinnable.h index 96496db3..d6e34a9c 100644 --- a/src/controls/QskSkinnable.h +++ b/src/controls/QskSkinnable.h @@ -134,8 +134,6 @@ class QSK_EXPORT QskSkinnable QMarginsF innerPadding( QskAspect::Aspect, const QSizeF& ) const; - QRectF subControlRect( QskAspect::Subcontrol ) const; - virtual const QskSkinlet* effectiveSkinlet() const; QskSkin* effectiveSkin() const; diff --git a/src/controls/QskSliderSkinlet.cpp b/src/controls/QskSliderSkinlet.cpp index feac1f02..520d20e0 100644 --- a/src/controls/QskSliderSkinlet.cpp +++ b/src/controls/QskSliderSkinlet.cpp @@ -25,37 +25,37 @@ QskSliderSkinlet::QskSliderSkinlet( QskSkin* skin ) QskSliderSkinlet::~QskSliderSkinlet() = default; -QRectF QskSliderSkinlet::subControlRect( - const QskSkinnable* skinnable, QskAspect::Subcontrol subControl ) const +QRectF QskSliderSkinlet::subControlRect( const QskSkinnable* skinnable, + const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const { const auto slider = static_cast< const QskSlider* >( skinnable ); if ( subControl == QskSlider::Panel ) { - return panelRect( slider ); + return panelRect( slider, contentsRect ); } if ( subControl == QskSlider::Groove ) { - return grooveRect( slider ); + return grooveRect( slider, contentsRect ); } if ( subControl == QskSlider::Fill ) { - return fillRect( slider ); + return fillRect( slider, contentsRect ); } if ( subControl == QskSlider::Handle ) { - return handleRect( slider ); + return handleRect( slider, contentsRect ); } if ( subControl == QskSlider::Scale ) { - return scaleRect( slider ); + return scaleRect( slider, contentsRect ); } - return Inherited::subControlRect( skinnable, subControl ); + return Inherited::subControlRect( skinnable, contentsRect, subControl ); } QSGNode* QskSliderSkinlet::updateSubNode( @@ -89,7 +89,8 @@ QSGNode* QskSliderSkinlet::updateSubNode( return Inherited::updateSubNode( skinnable, nodeRole, node ); } -QRectF QskSliderSkinlet::panelRect( const QskSlider* slider ) const +QRectF QskSliderSkinlet::panelRect( + const QskSlider* slider, const QRectF& contentsRect ) const { using namespace QskAspect; @@ -112,7 +113,7 @@ QRectF QskSliderSkinlet::panelRect( const QskSlider* slider ) const size = qMin( size, maxSize ); } - QRectF r = slider->contentsRect(); + QRectF r = contentsRect; if ( size > 0 && size < r.height() ) { @@ -128,12 +129,12 @@ QRectF QskSliderSkinlet::panelRect( const QskSlider* slider ) const return r; } -QRectF QskSliderSkinlet::innerRect( - const QskSlider* slider, QskAspect::Subcontrol subControl ) const +QRectF QskSliderSkinlet::innerRect( const QskSlider* slider, + const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const { using namespace QskAspect; - QRectF r = subControlRect( slider, QskSlider::Panel ); + QRectF r = subControlRect( slider, contentsRect, QskSlider::Panel ); r = r.marginsRemoved( qskPadding( slider, QskSlider::Panel ) ); QskSkinHintStatus status; @@ -160,27 +161,30 @@ QRectF QskSliderSkinlet::innerRect( return r; } -QRectF QskSliderSkinlet::grooveRect( const QskSlider* slider ) const +QRectF QskSliderSkinlet::grooveRect( + const QskSlider* slider, const QRectF& rect ) const { - return innerRect( slider, QskSlider::Groove ); + return innerRect( slider, rect, QskSlider::Groove ); } -QRectF QskSliderSkinlet::scaleRect( const QskSlider* slider ) const +QRectF QskSliderSkinlet::scaleRect( + const QskSlider* slider, const QRectF& rect ) const { - return innerRect( slider, QskSlider::Groove ); + return innerRect( slider, rect, QskSlider::Groove ); } -QRectF QskSliderSkinlet::fillRect( const QskSlider* slider ) const +QRectF QskSliderSkinlet::fillRect( + const QskSlider* slider, const QRectF& contentsRect ) const { using namespace QskAspect; - QRectF r = subControlRect( slider, QskSlider::Panel ); + QRectF r = subControlRect( slider, contentsRect, QskSlider::Panel ); r = r.marginsRemoved( qskPadding( slider, QskSlider::Panel ) ); qreal pos = slider->metric( QskSlider::Handle | Position ); pos = qBound( 0.0, pos, 1.0 ); - QRectF fillRect = innerRect( slider, QskSlider::Fill ); + QRectF fillRect = innerRect( slider, contentsRect, QskSlider::Fill ); if ( slider->orientation() == Qt::Horizontal ) { fillRect.setLeft( r.left() ); @@ -195,11 +199,12 @@ QRectF QskSliderSkinlet::fillRect( const QskSlider* slider ) const return fillRect; } -QRectF QskSliderSkinlet::handleRect( const QskSlider* slider ) const +QRectF QskSliderSkinlet::handleRect( + const QskSlider* slider, const QRectF& contentsRect ) const { using namespace QskAspect; - QRectF r = subControlRect( slider, QskSlider::Panel ); + QRectF r = subControlRect( slider, contentsRect, QskSlider::Panel ); r = r.marginsRemoved( qskPadding( slider, QskSlider::Panel ) ); const bool isHorizontal = slider->orientation() == Qt::Horizontal; diff --git a/src/controls/QskSliderSkinlet.h b/src/controls/QskSliderSkinlet.h index 885a3b82..dd9ed61e 100644 --- a/src/controls/QskSliderSkinlet.h +++ b/src/controls/QskSliderSkinlet.h @@ -29,20 +29,20 @@ class QSK_EXPORT QskSliderSkinlet : public QskSkinlet ~QskSliderSkinlet() override; QRectF subControlRect( const QskSkinnable*, - QskAspect::Subcontrol ) const override; + const QRectF& rect, QskAspect::Subcontrol ) const override; protected: QSGNode* updateSubNode( const QskSkinnable*, quint8 nodeRole, QSGNode* ) const override; private: - QRectF panelRect( const QskSlider* ) const; - QRectF grooveRect( const QskSlider* ) const; - QRectF fillRect( const QskSlider* ) const; - QRectF handleRect( const QskSlider* ) const; - QRectF scaleRect( const QskSlider* ) const; + QRectF panelRect( const QskSlider*, const QRectF& ) const; + QRectF grooveRect( const QskSlider*, const QRectF& ) const; + QRectF fillRect( const QskSlider*, const QRectF& ) const; + QRectF handleRect( const QskSlider*, const QRectF& ) const; + QRectF scaleRect( const QskSlider*, const QRectF& ) const; - QRectF innerRect( const QskSlider*, QskAspect::Subcontrol ) const; + QRectF innerRect( const QskSlider*, const QRectF&, QskAspect::Subcontrol ) const; }; #endif diff --git a/src/controls/QskStatusIndicatorSkinlet.cpp b/src/controls/QskStatusIndicatorSkinlet.cpp index be90c585..3740bdd1 100644 --- a/src/controls/QskStatusIndicatorSkinlet.cpp +++ b/src/controls/QskStatusIndicatorSkinlet.cpp @@ -19,17 +19,17 @@ QskStatusIndicatorSkinlet::QskStatusIndicatorSkinlet( QskSkin* skin ) QskStatusIndicatorSkinlet::~QskStatusIndicatorSkinlet() = default; -QRectF QskStatusIndicatorSkinlet::subControlRect( - const QskSkinnable* skinnable, QskAspect::Subcontrol subControl ) const +QRectF QskStatusIndicatorSkinlet::subControlRect( const QskSkinnable* skinnable, + const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const { const auto label = static_cast< const QskStatusIndicator* >( skinnable ); if ( subControl == QskStatusIndicator::Graphic ) { - return graphicRect( label ); + return graphicRect( label, contentsRect ); } - return Inherited::subControlRect( skinnable, subControl ); + return Inherited::subControlRect( skinnable, contentsRect, subControl ); } QSGNode* QskStatusIndicatorSkinlet::updateSubNode( @@ -49,14 +49,14 @@ QSGNode* QskStatusIndicatorSkinlet::updateSubNode( } QRect QskStatusIndicatorSkinlet::graphicRect( - const QskStatusIndicator* indicator ) const + const QskStatusIndicator* indicator, const QRectF& contentsRect ) const { // maybe we should have a common base class for // QskStatusIndicator and QskGraphicLabel // PreserveAspectFit/PreserveAspectCrop - const QRect graphicRect = indicator->contentsRect().toAlignedRect(); + const QRect graphicRect = contentsRect.toAlignedRect(); QSizeF sz = indicator->graphic( indicator->status() ).defaultSize(); sz.scale( graphicRect.size(), Qt::KeepAspectRatio ); @@ -70,7 +70,7 @@ QSGNode* QskStatusIndicatorSkinlet::updateGraphicNode( { const auto subControl = QskStatusIndicator::Graphic; - const QRectF rect = subControlRect( indicator, subControl ); + const QRectF rect = subControlRect( indicator, indicator->contentsRect(), subControl ); const Qt::Alignment alignment = indicator->flagHint< Qt::Alignment >( subControl | QskAspect::Alignment, Qt::AlignCenter ); diff --git a/src/controls/QskStatusIndicatorSkinlet.h b/src/controls/QskStatusIndicatorSkinlet.h index 82361e24..fe715103 100644 --- a/src/controls/QskStatusIndicatorSkinlet.h +++ b/src/controls/QskStatusIndicatorSkinlet.h @@ -26,14 +26,14 @@ class QSK_EXPORT QskStatusIndicatorSkinlet : public QskSkinlet ~QskStatusIndicatorSkinlet() override; QRectF subControlRect( const QskSkinnable*, - QskAspect::Subcontrol ) const override; + const QRectF&, QskAspect::Subcontrol ) const override; protected: QSGNode* updateSubNode( const QskSkinnable*, quint8 nodeRole, QSGNode* ) const override; private: - QRect graphicRect( const QskStatusIndicator* ) const; + QRect graphicRect( const QskStatusIndicator*, const QRectF& ) const; QSGNode* updateGraphicNode( const QskStatusIndicator*, QSGNode* ) const; }; diff --git a/src/controls/QskSubWindowAreaSkinlet.cpp b/src/controls/QskSubWindowAreaSkinlet.cpp index 9161baa2..6570fe73 100644 --- a/src/controls/QskSubWindowAreaSkinlet.cpp +++ b/src/controls/QskSubWindowAreaSkinlet.cpp @@ -14,15 +14,13 @@ QskSubWindowAreaSkinlet::QskSubWindowAreaSkinlet( QskSkin* skin ) QskSubWindowAreaSkinlet::~QskSubWindowAreaSkinlet() = default; -QRectF QskSubWindowAreaSkinlet::subControlRect( - const QskSkinnable* skinnable, QskAspect::Subcontrol subControl ) const +QRectF QskSubWindowAreaSkinlet::subControlRect( const QskSkinnable* skinnable, + const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const { - const auto area = static_cast< const QskSubWindowArea* >( skinnable ); - if ( subControl == QskSubWindowArea::Panel ) - return area->contentsRect(); + return contentsRect; - return Inherited::subControlRect( skinnable, subControl ); + return Inherited::subControlRect( skinnable, contentsRect, subControl ); } QSGNode* QskSubWindowAreaSkinlet::updateSubNode( diff --git a/src/controls/QskSubWindowAreaSkinlet.h b/src/controls/QskSubWindowAreaSkinlet.h index 8d8a422b..0e6034b4 100644 --- a/src/controls/QskSubWindowAreaSkinlet.h +++ b/src/controls/QskSubWindowAreaSkinlet.h @@ -26,7 +26,7 @@ class QSK_EXPORT QskSubWindowAreaSkinlet : public QskSkinlet ~QskSubWindowAreaSkinlet() override; QRectF subControlRect( const QskSkinnable*, - QskAspect::Subcontrol ) const override; + const QRectF&, QskAspect::Subcontrol ) const override; protected: QSGNode* updateSubNode( const QskSkinnable*, diff --git a/src/controls/QskSubWindowSkinlet.cpp b/src/controls/QskSubWindowSkinlet.cpp index fbaf2e7a..f3eff751 100644 --- a/src/controls/QskSubWindowSkinlet.cpp +++ b/src/controls/QskSubWindowSkinlet.cpp @@ -21,29 +21,29 @@ QskSubWindowSkinlet::QskSubWindowSkinlet( QskSkin* skin ) QskSubWindowSkinlet::~QskSubWindowSkinlet() = default; -QRectF QskSubWindowSkinlet::subControlRect( - const QskSkinnable* skinnable, QskAspect::Subcontrol subControl ) const +QRectF QskSubWindowSkinlet::subControlRect( const QskSkinnable* skinnable, + const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const { const auto subWindow = static_cast< const QskSubWindow* >( skinnable ); if ( subControl == QskSubWindow::Panel ) { - return subWindow->contentsRect(); + return contentsRect; } else if ( subControl == QskSubWindow::TitleBar ) { - return titleBarRect( subWindow ); + return titleBarRect( subWindow, contentsRect ); } else if ( subControl == QskSubWindow::TitleBarSymbol ) { - return symbolRect( subWindow ); + return symbolRect( subWindow, contentsRect ); } else if ( subControl == QskSubWindow::TitleBarText ) { - return titleRect( subWindow ); + return titleRect( subWindow, contentsRect ); } - return Inherited::subControlRect( skinnable, subControl ); + return Inherited::subControlRect( skinnable, contentsRect, subControl ); } QSGNode* QskSubWindowSkinlet::updateSubNode( @@ -89,14 +89,15 @@ QSGNode* QskSubWindowSkinlet::updateSubNode( return Inherited::updateSubNode( skinnable, nodeRole, node ); } -QRectF QskSubWindowSkinlet::titleBarRect( const QskSubWindow* subWindow ) const +QRectF QskSubWindowSkinlet::titleBarRect( + const QskSubWindow* subWindow, const QRectF& contentsRect ) const { const auto border = subWindow->boxBorderMetricsHint( QskSubWindow::Panel ); - QRectF rect = subWindow->contentsRect().marginsRemoved( border.widths() ); - rect.setHeight( titleBarHeight( subWindow ) ); + QRectF r = contentsRect.marginsRemoved( border.widths() ); + r.setHeight( titleBarHeight( subWindow ) ); - return rect; + return r; } qreal QskSubWindowSkinlet::titleBarHeight( const QskSubWindow* subWindow ) const @@ -115,9 +116,10 @@ qreal QskSubWindowSkinlet::titleBarHeight( const QskSubWindow* subWindow ) const return qMax( height, minHeight ); } -QRectF QskSubWindowSkinlet::symbolRect( const QskSubWindow* subWindow ) const +QRectF QskSubWindowSkinlet::symbolRect( + const QskSubWindow* subWindow, const QRectF& contentsRect ) const { - auto rect = subControlRect( subWindow, QskSubWindow::TitleBar ); + auto rect = subControlRect( subWindow, contentsRect, QskSubWindow::TitleBar ); rect = subWindow->innerBox( QskSubWindow::TitleBar, rect ); int w = 0; @@ -134,9 +136,10 @@ QRectF QskSubWindowSkinlet::symbolRect( const QskSubWindow* subWindow ) const return rect; } -QRectF QskSubWindowSkinlet::titleRect( const QskSubWindow* subWindow ) const +QRectF QskSubWindowSkinlet::titleRect( + const QskSubWindow* subWindow, const QRectF& contentsRect ) const { - auto rect = subControlRect( subWindow, QskSubWindow::TitleBar ); + auto rect = subControlRect( subWindow, contentsRect, QskSubWindow::TitleBar ); rect = subWindow->innerBox( QskSubWindow::TitleBar, rect ); if ( !rect.isEmpty() ) @@ -144,7 +147,9 @@ QRectF QskSubWindowSkinlet::titleRect( const QskSubWindow* subWindow ) const const auto spacing = subWindow->metric( QskSubWindow::TitleBar | QskAspect::Spacing ); - const auto symbolRect = subControlRect( subWindow, QskSubWindow::TitleBarSymbol ); + const auto symbolRect = subControlRect( + subWindow, rect, QskSubWindow::TitleBarSymbol ); + rect.setX( rect.x() + symbolRect.right() + spacing ); #if 0 diff --git a/src/controls/QskSubWindowSkinlet.h b/src/controls/QskSubWindowSkinlet.h index 302ec27f..84f1c3e4 100644 --- a/src/controls/QskSubWindowSkinlet.h +++ b/src/controls/QskSubWindowSkinlet.h @@ -29,7 +29,7 @@ class QSK_EXPORT QskSubWindowSkinlet : public QskPopupSkinlet ~QskSubWindowSkinlet() override; QRectF subControlRect( const QskSkinnable*, - QskAspect::Subcontrol ) const override; + const QRectF&, QskAspect::Subcontrol ) const override; protected: QSGNode* updateSubNode( const QskSkinnable*, @@ -38,9 +38,9 @@ class QSK_EXPORT QskSubWindowSkinlet : public QskPopupSkinlet private: qreal titleBarHeight( const QskSubWindow* ) const; - QRectF titleBarRect( const QskSubWindow* ) const; - QRectF symbolRect( const QskSubWindow* ) const; - QRectF titleRect( const QskSubWindow* ) const; + QRectF titleBarRect( const QskSubWindow*, const QRectF& ) const; + QRectF symbolRect( const QskSubWindow*, const QRectF& ) const; + QRectF titleRect( const QskSubWindow*, const QRectF& ) const; }; #endif diff --git a/src/controls/QskTabButton.cpp b/src/controls/QskTabButton.cpp index 2aa7eb3c..d4d686e6 100644 --- a/src/controls/QskTabButton.cpp +++ b/src/controls/QskTabButton.cpp @@ -103,7 +103,7 @@ QSizeF QskTabButton::contentsSizeHint() const QRectF QskTabButton::layoutRect() const { - return innerBox( Panel, effectiveSkinlet()->subControlRect( this, Panel ) ); + return innerBox( Panel, subControlRect( Panel ) ); } QskAspect::Placement QskTabButton::effectivePlacement() const diff --git a/src/controls/QskTabButtonSkinlet.cpp b/src/controls/QskTabButtonSkinlet.cpp index 32defa3c..abd03607 100644 --- a/src/controls/QskTabButtonSkinlet.cpp +++ b/src/controls/QskTabButtonSkinlet.cpp @@ -16,24 +16,24 @@ QskTabButtonSkinlet::QskTabButtonSkinlet( QskSkin* skin ) QskTabButtonSkinlet::~QskTabButtonSkinlet() = default; -QRectF QskTabButtonSkinlet::subControlRect( - const QskSkinnable* skinnable, QskAspect::Subcontrol subControl ) const +QRectF QskTabButtonSkinlet::subControlRect( const QskSkinnable* skinnable, + const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const { auto tabButton = static_cast< const QskTabButton* >( skinnable ); if ( subControl == QskTabButton::Text ) { - QRectF rect = subControlRect( tabButton, QskTabButton::Panel ); - rect = tabButton->innerBox( QskTabButton::Panel, rect ); + auto r = subControlRect( tabButton, contentsRect, QskTabButton::Panel ); + r = tabButton->innerBox( QskTabButton::Panel, r ); - return rect; + return r; } else if ( subControl == QskTabButton::Panel ) { - return tabButton->contentsRect(); + return contentsRect; } - return Inherited::subControlRect( skinnable, subControl ); + return Inherited::subControlRect( skinnable, contentsRect, subControl ); } QSGNode* QskTabButtonSkinlet::updateSubNode( diff --git a/src/controls/QskTabButtonSkinlet.h b/src/controls/QskTabButtonSkinlet.h index 7cfc6e90..5a846797 100644 --- a/src/controls/QskTabButtonSkinlet.h +++ b/src/controls/QskTabButtonSkinlet.h @@ -25,7 +25,7 @@ class QSK_EXPORT QskTabButtonSkinlet : public QskSkinlet ~QskTabButtonSkinlet() override; QRectF subControlRect( const QskSkinnable*, - QskAspect::Subcontrol ) const override; + const QRectF& rect, QskAspect::Subcontrol ) const override; protected: QSGNode* updateSubNode( const QskSkinnable*, diff --git a/src/controls/QskTabViewSkinlet.cpp b/src/controls/QskTabViewSkinlet.cpp index 31411088..fdf0b803 100644 --- a/src/controls/QskTabViewSkinlet.cpp +++ b/src/controls/QskTabViewSkinlet.cpp @@ -16,22 +16,22 @@ QskTabViewSkinlet::QskTabViewSkinlet( QskSkin* skin ) QskTabViewSkinlet::~QskTabViewSkinlet() = default; -QRectF QskTabViewSkinlet::subControlRect( - const QskSkinnable* skinnable, QskAspect::Subcontrol subControl ) const +QRectF QskTabViewSkinlet::subControlRect( const QskSkinnable* skinnable, + const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const { const auto tabView = static_cast< const QskTabView* >( skinnable ); if ( subControl == QskTabView::Page ) { - return pageRect( tabView ); + return pageRect( tabView, contentsRect ); } if ( subControl == QskTabView::TabBar ) { - return tabBarRect( tabView ); + return tabBarRect( tabView, contentsRect ); } - return Inherited::subControlRect( skinnable, subControl ); + return Inherited::subControlRect( skinnable, contentsRect, subControl ); } QSGNode* QskTabViewSkinlet::updateSubNode( @@ -48,9 +48,10 @@ QSGNode* QskTabViewSkinlet::updateSubNode( return Inherited::updateSubNode( skinnable, nodeRole, node ); } -QRectF QskTabViewSkinlet::pageRect( const QskTabView* tabView ) const +QRectF QskTabViewSkinlet::pageRect( + const QskTabView* tabView, const QRectF& rect ) const { - const QRectF barRect = subControlRect( tabView, QskTabView::TabBar ); + const QRectF barRect = subControlRect( tabView, rect, QskTabView::TabBar ); #if 1 QRectF r = tabView->layoutRect(); @@ -78,8 +79,11 @@ QRectF QskTabViewSkinlet::pageRect( const QskTabView* tabView ) const return r; } -QRectF QskTabViewSkinlet::tabBarRect( const QskTabView* tabView ) const +QRectF QskTabViewSkinlet::tabBarRect( + const QskTabView* tabView, const QRectF& rect ) const { + Q_UNUSED( rect ) + const QSizeF hint = tabView->tabBar()->sizeHint(); #if 1 diff --git a/src/controls/QskTabViewSkinlet.h b/src/controls/QskTabViewSkinlet.h index 6689d247..e18f058c 100644 --- a/src/controls/QskTabViewSkinlet.h +++ b/src/controls/QskTabViewSkinlet.h @@ -26,15 +26,15 @@ class QSK_EXPORT QskTabViewSkinlet : public QskSkinlet ~QskTabViewSkinlet() override; QRectF subControlRect( const QskSkinnable*, - QskAspect::Subcontrol ) const override; + const QRectF& rect, QskAspect::Subcontrol ) const override; protected: QSGNode* updateSubNode( const QskSkinnable*, quint8 nodeRole, QSGNode* ) const override; private: - QRectF pageRect( const QskTabView* ) const; - QRectF tabBarRect( const QskTabView* ) const; + QRectF pageRect( const QskTabView*, const QRectF& ) const; + QRectF tabBarRect( const QskTabView*, const QRectF& ) const; }; #endif diff --git a/src/controls/QskTextInputSkinlet.cpp b/src/controls/QskTextInputSkinlet.cpp index 94f88e2b..35f9b274 100644 --- a/src/controls/QskTextInputSkinlet.cpp +++ b/src/controls/QskTextInputSkinlet.cpp @@ -16,21 +16,20 @@ QskTextInputSkinlet::~QskTextInputSkinlet() { } -QRectF QskTextInputSkinlet::subControlRect( - const QskSkinnable* skinnable, QskAspect::Subcontrol subControl ) const +QRectF QskTextInputSkinlet::subControlRect( const QskSkinnable* skinnable, + const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const { if ( subControl == QskTextInput::Panel ) { - const auto textInput = static_cast< const QskTextInput* >( skinnable ); - return textInput->contentsRect(); + return contentsRect; } else if ( subControl == QskTextInput::Text ) { - return skinnable->innerBox( QskTextInput::Panel, - subControlRect( skinnable, QskTextInput::Panel ) ); + const auto r = subControlRect( skinnable, contentsRect, QskTextInput::Panel ); + return skinnable->innerBox( QskTextInput::Panel, r ); } - return Inherited::subControlRect( skinnable, subControl ); + return Inherited::subControlRect( skinnable, contentsRect, subControl ); } QSGNode* QskTextInputSkinlet::updateSubNode( diff --git a/src/controls/QskTextInputSkinlet.h b/src/controls/QskTextInputSkinlet.h index 7e0528bd..8d4655dd 100644 --- a/src/controls/QskTextInputSkinlet.h +++ b/src/controls/QskTextInputSkinlet.h @@ -24,7 +24,7 @@ class QSK_EXPORT QskTextInputSkinlet : public QskSkinlet ~QskTextInputSkinlet() override; QRectF subControlRect( const QskSkinnable*, - QskAspect::Subcontrol ) const override; + const QRectF& rect, QskAspect::Subcontrol ) const override; protected: QSGNode* updateSubNode( const QskSkinnable*, diff --git a/src/controls/QskTextLabelSkinlet.cpp b/src/controls/QskTextLabelSkinlet.cpp index 10d1d255..f0f4763e 100644 --- a/src/controls/QskTextLabelSkinlet.cpp +++ b/src/controls/QskTextLabelSkinlet.cpp @@ -16,17 +16,15 @@ QskTextLabelSkinlet::QskTextLabelSkinlet( QskSkin* skin ) QskTextLabelSkinlet::~QskTextLabelSkinlet() = default; -QRectF QskTextLabelSkinlet::subControlRect( - const QskSkinnable* skinnable, QskAspect::Subcontrol subControl ) const +QRectF QskTextLabelSkinlet::subControlRect( const QskSkinnable* skinnable, + const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const { - const auto label = static_cast< const QskTextLabel* >( skinnable ); - if ( subControl == QskTextLabel::Text ) { - return label->contentsRect(); + return contentsRect; } - return Inherited::subControlRect( skinnable, subControl ); + return Inherited::subControlRect( skinnable, contentsRect, subControl ); } QSGNode* QskTextLabelSkinlet::updateSubNode( diff --git a/src/controls/QskTextLabelSkinlet.h b/src/controls/QskTextLabelSkinlet.h index 2e60df03..5544983d 100644 --- a/src/controls/QskTextLabelSkinlet.h +++ b/src/controls/QskTextLabelSkinlet.h @@ -24,7 +24,7 @@ class QSK_EXPORT QskTextLabelSkinlet : public QskSkinlet ~QskTextLabelSkinlet() override; QRectF subControlRect( const QskSkinnable*, - QskAspect::Subcontrol ) const override; + const QRectF&, QskAspect::Subcontrol ) const override; protected: QSGNode* updateSubNode( const QskSkinnable*,