QskDrawerSkinlet introduced

This commit is contained in:
Uwe Rathmann 2023-11-03 17:49:26 +01:00
parent 4102276f79
commit f47e96e9ce
10 changed files with 114 additions and 5 deletions

View File

@ -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

View File

@ -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()

View File

@ -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 );
}

View File

@ -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 );
}

View File

@ -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

View File

@ -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"

View File

@ -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 );

View File

@ -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"

View File

@ -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

View File

@ -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 >();