diff --git a/playground/drawer/main.cpp b/playground/drawer/main.cpp index 02acfa0d..81963fc8 100644 --- a/playground/drawer/main.cpp +++ b/playground/drawer/main.cpp @@ -40,24 +40,30 @@ namespace switch( edge ) { case Qt::LeftEdge: - content->setBackgroundColor( QskRgb::Tomato ); + setPanel( QskRgb::Tomato ); break; case Qt::RightEdge: + setPanel( QskRgb::Orchid ); content->setFixedWidth( 1.5 * size.width() ); - content->setBackgroundColor( QskRgb::Orchid ); break; case Qt::TopEdge: - content->setBackgroundColor( QskRgb::Chartreuse ); + setPanel( QskRgb::Chartreuse ); break; case Qt::BottomEdge: + setPanel( QskRgb::Wheat ); content->setFixedHeight( 2 * size.height() ); - content->setBackgroundColor( QskRgb::Wheat ); break; } } + + private: + void setPanel( const QColor& color ) + { + setGradientHint( Panel, color ); + } }; class DrawerBox : public QskControl diff --git a/skins/fluent2/QskFluent2Skin.cpp b/skins/fluent2/QskFluent2Skin.cpp index c8615dcb..4f5de05d 100644 --- a/skins/fluent2/QskFluent2Skin.cpp +++ b/skins/fluent2/QskFluent2Skin.cpp @@ -626,8 +626,11 @@ void Editor::setupDrawerMetrics() setAnimation( Q::Panel | A::Position, 300, QEasingCurve::OutCubic ); } -void Editor::setupDrawerColors( QskAspect::Section, const QskFluent2Theme& ) +void Editor::setupDrawerColors( + QskAspect::Section section, const QskFluent2Theme& theme ) { + setGradient( QskDrawer::Panel | section, + theme.palette.background.solid.base ); } void Editor::setupFocusIndicatorMetrics() diff --git a/skins/material3/QskMaterial3Skin.cpp b/skins/material3/QskMaterial3Skin.cpp index ad81f397..8443dbf5 100644 --- a/skins/material3/QskMaterial3Skin.cpp +++ b/skins/material3/QskMaterial3Skin.cpp @@ -809,6 +809,7 @@ void Editor::setupDrawer() using Q = QskDrawer; using A = QskAspect; + setGradient( Q::Panel, m_pal.background ); setAnimation( Q::Panel | A::Position, 300, QEasingCurve::OutCubic ); } diff --git a/skins/squiek/QskSquiekSkin.cpp b/skins/squiek/QskSquiekSkin.cpp index 9de18a3d..19530b32 100644 --- a/skins/squiek/QskSquiekSkin.cpp +++ b/skins/squiek/QskSquiekSkin.cpp @@ -761,6 +761,7 @@ void Editor::setupDrawer() using Q = QskDrawer; using A = QskAspect; + setPanel( Q::Panel, Plain ); setAnimation( Q::Panel | A::Position, 300, QEasingCurve::OutCubic ); } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 237d1577..a2f36047 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -176,6 +176,7 @@ list(APPEND HEADERS controls/QskComboBoxSkinlet.h controls/QskControl.h controls/QskDrawer.h + controls/QskDrawerSkinlet.h controls/QskEvent.h controls/QskFlickAnimator.h controls/QskFocusIndicator.h @@ -279,6 +280,7 @@ list(APPEND SOURCES controls/QskControlPrivate.cpp controls/QskDirtyItemFilter.cpp controls/QskDrawer.cpp + controls/QskDrawerSkinlet.cpp controls/QskEvent.cpp controls/QskFlickAnimator.cpp controls/QskFocusIndicator.cpp diff --git a/src/controls/QskDrawer.cpp b/src/controls/QskDrawer.cpp index fa254316..d0851ac0 100644 --- a/src/controls/QskDrawer.cpp +++ b/src/controls/QskDrawer.cpp @@ -460,4 +460,9 @@ QskAspect QskDrawer::fadingAspect() const return QskDrawer::Panel | QskAspect::Position; } +QRectF QskDrawer::layoutRectForSize( const QSizeF& size ) const +{ + return subControlContentsRect( size, Panel ); +} + #include "moc_QskDrawer.cpp" diff --git a/src/controls/QskDrawer.h b/src/controls/QskDrawer.h index 631e5492..5947ae2b 100644 --- a/src/controls/QskDrawer.h +++ b/src/controls/QskDrawer.h @@ -43,6 +43,8 @@ class QSK_EXPORT QskDrawer : public QskPopup QRectF clipRect() const override; QskAspect fadingAspect() const override; + QRectF layoutRectForSize( const QSizeF& ) const override; + Q_SIGNALS: void edgeChanged( Qt::Edge ); void dragMarginChanged( qreal ); diff --git a/src/controls/QskDrawerSkinlet.cpp b/src/controls/QskDrawerSkinlet.cpp new file mode 100644 index 00000000..e10f5923 --- /dev/null +++ b/src/controls/QskDrawerSkinlet.cpp @@ -0,0 +1,45 @@ +/****************************************************************************** + * QSkinny - Copyright (C) 2016 Uwe Rathmann + * SPDX-License-Identifier: BSD-3-Clause + *****************************************************************************/ + +#include "QskDrawerSkinlet.h" +#include "QskDrawer.h" + +QskDrawerSkinlet::QskDrawerSkinlet( QskSkin* skin ) + : Inherited( skin ) +{ + appendNodeRoles( { PanelRole } ); +} + +QskDrawerSkinlet::~QskDrawerSkinlet() = default; + +QRectF QskDrawerSkinlet::subControlRect( + const QskSkinnable* skinnable, const QRectF& contentsRect, + QskAspect::Subcontrol subControl ) const +{ + if ( subControl == QskDrawer::Panel ) + return contentsRect; + + return Inherited::subControlRect( skinnable, contentsRect, subControl ); +} + +QSGNode* QskDrawerSkinlet::updateSubNode( + const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const +{ + if ( nodeRole == PanelRole ) + return updateBoxNode( skinnable, node, QskDrawer::Panel ); + + return Inherited::updateSubNode( skinnable, nodeRole, node ); +} + +QSizeF QskDrawerSkinlet::sizeHint( const QskSkinnable* skinnable, + Qt::SizeHint which, const QSizeF& constraint ) const +{ + if ( which == Qt::PreferredSize ) + return skinnable->strutSizeHint( QskDrawer::Panel ); + + return Inherited::sizeHint( skinnable, which, constraint ); +} + +#include "moc_QskDrawerSkinlet.cpp" diff --git a/src/controls/QskDrawerSkinlet.h b/src/controls/QskDrawerSkinlet.h new file mode 100644 index 00000000..b6d1c771 --- /dev/null +++ b/src/controls/QskDrawerSkinlet.h @@ -0,0 +1,40 @@ +/****************************************************************************** + * QSkinny - Copyright (C) 2016 Uwe Rathmann + * SPDX-License-Identifier: BSD-3-Clause + *****************************************************************************/ + +#ifndef QSK_DRAWER_SKINLET_H +#define QSK_DRAWER_SKINLET_H + +#include "QskPopupSkinlet.h" + +class QSK_EXPORT QskDrawerSkinlet : public QskPopupSkinlet +{ + Q_GADGET + + using Inherited = QskPopupSkinlet; + + public: + enum NodeRole + { + ContentsRole = Inherited::RoleCount, + PanelRole, + + RoleCount + }; + + Q_INVOKABLE QskDrawerSkinlet( QskSkin* = nullptr ); + ~QskDrawerSkinlet() override; + + QRectF subControlRect( const QskSkinnable*, + const QRectF&, QskAspect::Subcontrol ) const override; + + QSizeF sizeHint( const QskSkinnable*, + Qt::SizeHint, const QSizeF& ) const override; + + protected: + QSGNode* updateSubNode( const QskSkinnable*, + quint8 nodeRole, QSGNode* ) const override; +}; + +#endif diff --git a/src/controls/QskSkin.cpp b/src/controls/QskSkin.cpp index a24a212f..a791eb05 100644 --- a/src/controls/QskSkin.cpp +++ b/src/controls/QskSkin.cpp @@ -32,6 +32,9 @@ #include "QskComboBox.h" #include "QskComboBoxSkinlet.h" +#include "QskDrawer.h" +#include "QskDrawerSkinlet.h" + #include "QskFocusIndicator.h" #include "QskFocusIndicatorSkinlet.h" @@ -160,6 +163,7 @@ QskSkin::QskSkin( QObject* parent ) declareSkinlet< QskBox, QskBoxSkinlet >(); declareSkinlet< QskCheckBox, QskCheckBoxSkinlet >(); declareSkinlet< QskComboBox, QskComboBoxSkinlet >(); + declareSkinlet< QskDrawer, QskDrawerSkinlet >(); declareSkinlet< QskFocusIndicator, QskFocusIndicatorSkinlet >(); declareSkinlet< QskGraphicLabel, QskGraphicLabelSkinlet >(); declareSkinlet< QskListView, QskListViewSkinlet >();