harmonizing skinlet code

This commit is contained in:
Uwe Rathmann 2017-09-01 11:55:55 +02:00
parent be146f2480
commit 16585a708d
25 changed files with 248 additions and 290 deletions

View File

@ -34,11 +34,12 @@ QSGNode* QskBoxSkinlet::updateSubNode(
switch( nodeRole ) switch( nodeRole )
{ {
case PanelRole: case PanelRole:
{
return updateBoxNode( skinnable, node, QskBox::Panel ); return updateBoxNode( skinnable, node, QskBox::Panel );
default:
return nullptr;
} }
}
return Inherited::updateSubNode( skinnable, nodeRole, node );
} }
#include "moc_QskBoxSkinlet.cpp" #include "moc_QskBoxSkinlet.cpp"

View File

@ -23,17 +23,12 @@ QRectF QskFocusIndicatorSkinlet::subControlRect(
if ( subControl == QskFocusIndicator::Panel ) if ( subControl == QskFocusIndicator::Panel )
{ {
return panelRect( indicator ); return indicator->boundingRect();
} }
return Inherited::subControlRect( skinnable, subControl ); return Inherited::subControlRect( skinnable, subControl );
} }
QRectF QskFocusIndicatorSkinlet::panelRect( const QskFocusIndicator* indicator ) const
{
return indicator->boundingRect();
}
QSGNode* QskFocusIndicatorSkinlet::updateSubNode( QSGNode* QskFocusIndicatorSkinlet::updateSubNode(
const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const
{ {
@ -42,11 +37,12 @@ QSGNode* QskFocusIndicatorSkinlet::updateSubNode(
switch( nodeRole ) switch( nodeRole )
{ {
case FrameRole: case FrameRole:
{
return updateFrameNode( indicator, node ); return updateFrameNode( indicator, node );
default:
return nullptr;
} }
}
return Inherited::updateSubNode( skinnable, nodeRole, node );
} }
QSGNode* QskFocusIndicatorSkinlet::updateFrameNode( QSGNode* QskFocusIndicatorSkinlet::updateFrameNode(

View File

@ -34,7 +34,6 @@ protected:
quint8 nodeRole, QSGNode* ) const override; quint8 nodeRole, QSGNode* ) const override;
private: private:
QRectF panelRect( const QskFocusIndicator* ) const;
QSGNode* updateFrameNode( const QskFocusIndicator*, QSGNode* ) const; QSGNode* updateFrameNode( const QskFocusIndicator*, QSGNode* ) const;
}; };

View File

@ -33,6 +33,22 @@ QRectF QskGraphicLabelSkinlet::subControlRect(
return Inherited::subControlRect( skinnable, subControl ); return Inherited::subControlRect( skinnable, subControl );
} }
QSGNode* QskGraphicLabelSkinlet::updateSubNode(
const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const
{
const auto label = static_cast< const QskGraphicLabel* >( skinnable );
switch( nodeRole )
{
case GraphicRole:
{
return updateGraphicNode( label, node );
}
}
return Inherited::updateSubNode( skinnable, nodeRole, node );
}
QRect QskGraphicLabelSkinlet::graphicRect( const QskGraphicLabel* label ) const QRect QskGraphicLabelSkinlet::graphicRect( const QskGraphicLabel* label ) const
{ {
// textures are in integers, to avoid useless recalculations // textures are in integers, to avoid useless recalculations
@ -62,21 +78,6 @@ QRect QskGraphicLabelSkinlet::graphicRect( const QskGraphicLabel* label ) const
( int )sz.width(), ( int )sz.height(), label->alignment() ); ( int )sz.width(), ( int )sz.height(), label->alignment() );
} }
QSGNode* QskGraphicLabelSkinlet::updateSubNode(
const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const
{
const auto label = static_cast< const QskGraphicLabel* >( skinnable );
switch( nodeRole )
{
case GraphicRole:
return updateGraphicNode( label, node );
default:
return nullptr;
}
}
QSGNode* QskGraphicLabelSkinlet::updateGraphicNode( QSGNode* QskGraphicLabelSkinlet::updateGraphicNode(
const QskGraphicLabel* label, QSGNode* node ) const const QskGraphicLabel* label, QSGNode* node ) const
{ {

View File

@ -30,6 +30,27 @@ QRectF QskPageIndicatorSkinlet::subControlRect(
return Inherited::subControlRect( skinnable, subControl ); return Inherited::subControlRect( skinnable, subControl );
} }
QSGNode* QskPageIndicatorSkinlet::updateSubNode( const QskSkinnable* skinnable,
quint8 nodeRole, QSGNode* node ) const
{
const auto indicator = static_cast< const QskPageIndicator* >( skinnable );
switch( nodeRole )
{
case PanelRole:
{
return updateBoxNode( indicator, node, QskPageIndicator::Panel );
}
case BulletsRole:
{
return updateBulletsNode( indicator, node );
}
}
return Inherited::updateSubNode( skinnable, nodeRole, node );
}
QRectF QskPageIndicatorSkinlet::bulletRect( QRectF QskPageIndicatorSkinlet::bulletRect(
const QskPageIndicator* indicator, const QRectF& rect, int index ) const const QskPageIndicator* indicator, const QRectF& rect, int index ) const
{ {
@ -108,30 +129,6 @@ QRectF QskPageIndicatorSkinlet::bulletRect(
return ret; return ret;
} }
QSGNode* QskPageIndicatorSkinlet::updateSubNode( const QskSkinnable* skinnable,
quint8 nodeRole, QSGNode* node ) const
{
const auto indicator = static_cast< const QskPageIndicator* >( skinnable );
switch( nodeRole )
{
case PanelRole:
return updatePanelNode( indicator, node );
case BulletsRole:
return updateBulletsNode( indicator, node );
default:
return nullptr;
}
}
QSGNode* QskPageIndicatorSkinlet::updatePanelNode(
const QskPageIndicator* indicator, QSGNode* node ) const
{
return updateBoxNode( indicator, node, QskPageIndicator::Panel );
}
QSGNode* QskPageIndicatorSkinlet::updateBulletsNode( QSGNode* QskPageIndicatorSkinlet::updateBulletsNode(
const QskPageIndicator* indicator, QSGNode* node) const const QskPageIndicator* indicator, QSGNode* node) const
{ {

View File

@ -35,9 +35,7 @@ protected:
quint8 nodeRole, QSGNode* ) const override; quint8 nodeRole, QSGNode* ) const override;
private: private:
QSGNode* updatePanelNode( const QskPageIndicator*, QSGNode* ) const;
QSGNode* updateBulletsNode( const QskPageIndicator*, QSGNode* ) const; QSGNode* updateBulletsNode( const QskPageIndicator*, QSGNode* ) const;
QRectF bulletRect( const QskPageIndicator*, const QRectF&, int index ) const; QRectF bulletRect( const QskPageIndicator*, const QRectF&, int index ) const;
}; };

View File

@ -34,11 +34,12 @@ QSGNode* QskPopupSkinlet::updateSubNode( const QskSkinnable* skinnable,
switch( nodeRole ) switch( nodeRole )
{ {
case OverlayRole: case OverlayRole:
{
return updateOverlayNode( popup, node ); return updateOverlayNode( popup, node );
default:
return Inherited::updateSubNode( skinnable, nodeRole, node );
} }
}
return Inherited::updateSubNode( skinnable, nodeRole, node );
} }
QSGNode* QskPopupSkinlet::updateOverlayNode( QSGNode* QskPopupSkinlet::updateOverlayNode(

View File

@ -14,7 +14,7 @@
QskPushButtonSkinlet::QskPushButtonSkinlet( QskSkin* skin ): QskPushButtonSkinlet::QskPushButtonSkinlet( QskSkin* skin ):
Inherited( skin ) Inherited( skin )
{ {
setNodeRoles( { ButtonRole, GraphicRole, TextRole } ); setNodeRoles( { PanelRole, GraphicRole, TextRole } );
} }
QskPushButtonSkinlet::~QskPushButtonSkinlet() = default; QskPushButtonSkinlet::~QskPushButtonSkinlet() = default;
@ -40,12 +40,39 @@ QRectF QskPushButtonSkinlet::subControlRect(
} }
else if ( subControl == QskPushButton::Panel ) else if ( subControl == QskPushButton::Panel )
{ {
return panelRect( button ); return button->contentsRect();
} }
return Inherited::subControlRect( skinnable, subControl ); return Inherited::subControlRect( skinnable, subControl );
} }
QSGNode* QskPushButtonSkinlet::updateSubNode(
const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const
{
const auto button = static_cast< const QskPushButton* >( skinnable );
switch( nodeRole )
{
case PanelRole:
{
return updateBoxNode( button, node, QskPushButton::Panel );
}
case TextRole:
{
return updateTextNode( button, node );
}
case GraphicRole:
{
return updateGraphicNode( button, node,
button->graphic(), QskPushButton::Graphic );
}
}
return Inherited::updateSubNode( skinnable, nodeRole, node );
}
QRectF QskPushButtonSkinlet::textRect( const QskPushButton* button ) const QRectF QskPushButtonSkinlet::textRect( const QskPushButton* button ) const
{ {
// buttonShift -> TODO // buttonShift -> TODO
@ -97,38 +124,6 @@ QRectF QskPushButtonSkinlet::graphicRect( const QskPushButton* button ) const
return QRectF( x, y, w, h ); return QRectF( x, y, w, h );
} }
QRectF QskPushButtonSkinlet::panelRect( const QskPushButton* button ) const
{
return button->contentsRect();
}
QSGNode* QskPushButtonSkinlet::updateSubNode(
const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const
{
const auto button = static_cast< const QskPushButton* >( skinnable );
switch( nodeRole )
{
case ButtonRole:
return updateButtonNode( button, node );
case TextRole:
return updateTextNode( button, node );
case GraphicRole:
return updateGraphicNode( button, node );
default:
return nullptr;
}
}
QSGNode* QskPushButtonSkinlet::updateButtonNode(
const QskPushButton* button, QSGNode* node ) const
{
return updateBoxNode( button, node, QskPushButton::Panel );
}
QSGNode* QskPushButtonSkinlet::updateTextNode( QSGNode* QskPushButtonSkinlet::updateTextNode(
const QskPushButton* button, QSGNode* node ) const const QskPushButton* button, QSGNode* node ) const
{ {
@ -145,11 +140,4 @@ QSGNode* QskPushButtonSkinlet::updateTextNode(
button->text(), button->textOptions(), QskPushButton::Text ); button->text(), button->textOptions(), QskPushButton::Text );
} }
QSGNode* QskPushButtonSkinlet::updateGraphicNode(
const QskPushButton* button, QSGNode* node ) const
{
return QskSkinlet::updateGraphicNode( button, node,
button->graphic(), QskPushButton::Graphic );
}
#include "moc_QskPushButtonSkinlet.cpp" #include "moc_QskPushButtonSkinlet.cpp"

View File

@ -20,7 +20,7 @@ class QSK_EXPORT QskPushButtonSkinlet : public QskSkinlet
public: public:
enum NodeRole enum NodeRole
{ {
ButtonRole, PanelRole,
TextRole, TextRole,
GraphicRole GraphicRole
}; };
@ -38,13 +38,10 @@ protected:
quint8 nodeRole, QSGNode* ) const override; quint8 nodeRole, QSGNode* ) const override;
private: private:
QRectF panelRect( const QskPushButton* ) const;
QRectF textRect( const QskPushButton* ) const; QRectF textRect( const QskPushButton* ) const;
QRectF graphicRect( const QskPushButton* ) const; QRectF graphicRect( const QskPushButton* ) const;
QSGNode* updateButtonNode( const QskPushButton*, QSGNode* ) const;
QSGNode* updateTextNode( const QskPushButton*, QSGNode* ) const; QSGNode* updateTextNode( const QskPushButton*, QSGNode* ) const;
QSGNode* updateGraphicNode( const QskPushButton*, QSGNode* ) const;
}; };
#endif #endif

View File

@ -54,22 +54,34 @@ QRectF QskScrollViewSkinlet::subControlRect(
const auto scrollView = static_cast< const QskScrollView* >( skinnable ); const auto scrollView = static_cast< const QskScrollView* >( skinnable );
if ( subControl == QskScrollView::Panel ) if ( subControl == QskScrollView::Panel )
{
return scrollView->contentsRect(); return scrollView->contentsRect();
}
if ( subControl == QskScrollView::Viewport ) if ( subControl == QskScrollView::Viewport )
{
return viewportRect( scrollView ); return viewportRect( scrollView );
}
if ( subControl == QskScrollView::HorizontalScrollBar ) if ( subControl == QskScrollView::HorizontalScrollBar )
{
return scrollBarRect( scrollView, Qt::Horizontal ); return scrollBarRect( scrollView, Qt::Horizontal );
}
if ( subControl == QskScrollView::HorizontalScrollHandle ) if ( subControl == QskScrollView::HorizontalScrollHandle )
{
return scrollHandleRect( scrollView, Qt::Horizontal ); return scrollHandleRect( scrollView, Qt::Horizontal );
}
if ( subControl == QskScrollView::VerticalScrollBar ) if ( subControl == QskScrollView::VerticalScrollBar )
{
return scrollBarRect( scrollView, Qt::Vertical ); return scrollBarRect( scrollView, Qt::Vertical );
}
if ( subControl == QskScrollView::VerticalScrollHandle ) if ( subControl == QskScrollView::VerticalScrollHandle )
{
return scrollHandleRect( scrollView, Qt::Vertical ); return scrollHandleRect( scrollView, Qt::Vertical );
}
return Inherited::subControlRect( skinnable, subControl ); return Inherited::subControlRect( skinnable, subControl );
} }
@ -82,21 +94,31 @@ QSGNode* QskScrollViewSkinlet::updateSubNode(
switch( nodeRole ) switch( nodeRole )
{ {
case ViewportRole: case ViewportRole:
{
return updateViewportNode( scrollView, node ); return updateViewportNode( scrollView, node );
}
case HorizontalScrollHandleRole: case HorizontalScrollHandleRole:
{
return updateBoxNode( skinnable, node, QskScrollView::HorizontalScrollHandle ); return updateBoxNode( skinnable, node, QskScrollView::HorizontalScrollHandle );
}
case VerticalScrollHandleRole: case VerticalScrollHandleRole:
{
return updateBoxNode( skinnable, node, QskScrollView::VerticalScrollHandle ); return updateBoxNode( skinnable, node, QskScrollView::VerticalScrollHandle );
}
case ContentsRootRole: case ContentsRootRole:
{
return updateContentsRootNode( scrollView, node ); return updateContentsRootNode( scrollView, node );
}
case HorizontalScrollBarRole: case HorizontalScrollBarRole:
case VerticalScrollBarRole: case VerticalScrollBarRole:
{
return nullptr; return nullptr;
} }
}
return Inherited::updateSubNode( skinnable, nodeRole, node ); return Inherited::updateSubNode( skinnable, nodeRole, node );
} }

View File

@ -28,6 +28,26 @@ QRectF QskSeparatorSkinlet::subControlRect(
return Inherited::subControlRect( skinnable, subControl ); return Inherited::subControlRect( skinnable, subControl );
} }
QSGNode* QskSeparatorSkinlet::updateSubNode(
const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const
{
const auto separator = static_cast< const QskSeparator* >( skinnable );
switch( nodeRole )
{
case PanelRole:
{
const bool isHorizontal = ( separator->orientation() == Qt::Horizontal );
const QRectF r = subControlRect( separator, QskSeparator::Panel );
return updateBoxNode( separator, node, r,
QskSeparator::Panel, isHorizontal ? 0 : -1 );
}
}
return Inherited::updateSubNode( skinnable, nodeRole, node );
}
QRectF QskSeparatorSkinlet::panelRect( const QskSeparator* separator ) const QRectF QskSeparatorSkinlet::panelRect( const QskSeparator* separator ) const
{ {
const QRectF cr = separator->contentsRect(); const QRectF cr = separator->contentsRect();
@ -50,29 +70,4 @@ QRectF QskSeparatorSkinlet::panelRect( const QskSeparator* separator ) const
return r; return r;
} }
QSGNode* QskSeparatorSkinlet::updateSubNode(
const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const
{
const auto separator = static_cast< const QskSeparator* >( skinnable );
switch( nodeRole )
{
case PanelRole:
return updatePanelNode( separator, node );
default:
return nullptr;
}
}
QSGNode* QskSeparatorSkinlet::updatePanelNode(
const QskSeparator* separator, QSGNode* node ) const
{
const bool isHorizontal = ( separator->orientation() == Qt::Horizontal );
const QRectF r = subControlRect( separator, QskSeparator::Panel );
return updateBoxNode( separator, node, r,
QskSeparator::Panel, isHorizontal ? 0 : -1 );
}
#include "moc_QskSeparatorSkinlet.cpp" #include "moc_QskSeparatorSkinlet.cpp"

View File

@ -35,7 +35,6 @@ protected:
private: private:
QRectF panelRect( const QskSeparator* ) const; QRectF panelRect( const QskSeparator* ) const;
QSGNode* updatePanelNode( const QskSeparator*, QSGNode* ) const;
}; };
#endif #endif

View File

@ -132,11 +132,6 @@ const QVector< quint8 >& QskSkinlet::nodeRoles() const
return m_data->nodeRoles; return m_data->nodeRoles;
} }
QRectF QskSkinlet::subControlRect( const QskSkinnable*, QskAspect::Subcontrol ) const
{
return QRectF();
}
void QskSkinlet::updateNode( QskSkinnable* skinnable, QSGNode* parentNode ) const void QskSkinlet::updateNode( QskSkinnable* skinnable, QSGNode* parentNode ) const
{ {
QSGNode* oldNode; QSGNode* oldNode;
@ -178,12 +173,6 @@ void QskSkinlet::updateNode( QskSkinnable* skinnable, QSGNode* parentNode ) cons
} }
} }
QSGNode* QskSkinlet::updateSubNode(
const QskSkinnable*, quint8, QSGNode*) const
{
return nullptr;
}
QSGNode* QskSkinlet::updateBackgroundNode( QSGNode* QskSkinlet::updateBackgroundNode(
const QskControl* control, QSGNode* node ) const const QskControl* control, QSGNode* node ) const
{ {

View File

@ -10,6 +10,7 @@
#include "QskAspect.h" #include "QskAspect.h"
#include <Qt> #include <Qt>
#include <QRectF>
#include <memory> #include <memory>
class QskSkin; class QskSkin;
@ -99,4 +100,16 @@ private:
std::unique_ptr< PrivateData > m_data; std::unique_ptr< PrivateData > m_data;
}; };
inline QRectF QskSkinlet::subControlRect(
const QskSkinnable*, QskAspect::Subcontrol ) const
{
return QRectF();
}
inline QSGNode* QskSkinlet::updateSubNode(
const QskSkinnable*, quint8, QSGNode*) const
{
return nullptr;
}
#endif #endif

View File

@ -49,23 +49,64 @@ QRectF QskSliderSkinlet::subControlRect(
const auto slider = static_cast< const QskSlider* >( skinnable ); const auto slider = static_cast< const QskSlider* >( skinnable );
if ( subControl == QskSlider::Panel ) if ( subControl == QskSlider::Panel )
{
return panelRect( slider ); return panelRect( slider );
}
if ( subControl == QskSlider::Groove ) if ( subControl == QskSlider::Groove )
{
return grooveRect( slider ); return grooveRect( slider );
}
if ( subControl == QskSlider::Fill ) if ( subControl == QskSlider::Fill )
{
return fillRect( slider ); return fillRect( slider );
}
if ( subControl == QskSlider::Handle ) if ( subControl == QskSlider::Handle )
{
return handleRect( slider ); return handleRect( slider );
}
if ( subControl == QskSlider::Scale ) if ( subControl == QskSlider::Scale )
{
return scaleRect( slider ); return scaleRect( slider );
}
return Inherited::subControlRect( skinnable, subControl ); return Inherited::subControlRect( skinnable, subControl );
} }
QSGNode* QskSliderSkinlet::updateSubNode(
const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const
{
const auto slider = static_cast< const QskSlider* >( skinnable );
switch( nodeRole )
{
case PanelRole:
{
return updateBoxNode( slider, QskSlider::Panel, node );
}
case GrooveRole:
{
return updateBoxNode( slider, QskSlider::Groove, node );
}
case FillRole:
{
return updateBoxNode( slider, QskSlider::Fill, node );
}
case HandleRole:
{
return updateBoxNode( slider, QskSlider::Handle, node );
}
}
return Inherited::updateSubNode( skinnable, nodeRole, node );
}
QRectF QskSliderSkinlet::panelRect( const QskSlider* slider ) const QRectF QskSliderSkinlet::panelRect( const QskSlider* slider ) const
{ {
using namespace QskAspect; using namespace QskAspect;
@ -212,30 +253,6 @@ QRectF QskSliderSkinlet::handleRect( const QskSlider* slider ) const
return handleRect; return handleRect;
} }
QSGNode* QskSliderSkinlet::updateSubNode(
const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const
{
const auto slider = static_cast< const QskSlider* >( skinnable );
switch( nodeRole )
{
case PanelRole:
return updateBoxNode( slider, QskSlider::Panel, node );
case GrooveRole:
return updateBoxNode( slider, QskSlider::Groove, node );
case FillRole:
return updateBoxNode( slider, QskSlider::Fill, node );
case HandleRole:
return updateBoxNode( slider, QskSlider::Handle, node );
default:
return nullptr;
}
}
QSGNode* QskSliderSkinlet::updateBoxNode( const QskSlider* slider, QSGNode* QskSliderSkinlet::updateBoxNode( const QskSlider* slider,
QskAspect::Subcontrol subControl, QSGNode* node ) const QskAspect::Subcontrol subControl, QSGNode* node ) const
{ {

View File

@ -33,6 +33,22 @@ QRectF QskStatusIndicatorSkinlet::subControlRect(
return Inherited::subControlRect( skinnable, subControl ); return Inherited::subControlRect( skinnable, subControl );
} }
QSGNode* QskStatusIndicatorSkinlet::updateSubNode(
const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const
{
const auto indicator = static_cast< const QskStatusIndicator* >( skinnable );
switch( nodeRole )
{
case GraphicRole:
{
return updateGraphicNode( indicator, node );
}
}
return Inherited::updateSubNode( skinnable, nodeRole, node );
}
QRect QskStatusIndicatorSkinlet::graphicRect( QRect QskStatusIndicatorSkinlet::graphicRect(
const QskStatusIndicator* indicator ) const const QskStatusIndicator* indicator ) const
{ {
@ -50,21 +66,6 @@ QRect QskStatusIndicatorSkinlet::graphicRect(
( int )sz.width(), ( int )sz.height(), Qt::AlignCenter ); ( int )sz.width(), ( int )sz.height(), Qt::AlignCenter );
} }
QSGNode* QskStatusIndicatorSkinlet::updateSubNode(
const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const
{
const auto indicator = static_cast< const QskStatusIndicator* >( skinnable );
switch( nodeRole )
{
case GraphicRole:
return updateGraphicNode( indicator, node );
default:
return nullptr;
}
}
QSGNode* QskStatusIndicatorSkinlet::updateGraphicNode( QSGNode* QskStatusIndicatorSkinlet::updateGraphicNode(
const QskStatusIndicator* indicator, QSGNode* node ) const const QskStatusIndicator* indicator, QSGNode* node ) const
{ {

View File

@ -5,7 +5,6 @@
#include "QskSubWindowAreaSkinlet.h" #include "QskSubWindowAreaSkinlet.h"
#include "QskSubWindowArea.h" #include "QskSubWindowArea.h"
#include "QskSkin.h"
#include "QskGradient.h" #include "QskGradient.h"
#include "QskRectNode.h" #include "QskRectNode.h"
@ -24,17 +23,12 @@ QRectF QskSubWindowAreaSkinlet::subControlRect(
if ( subControl == QskSubWindowArea::Panel ) if ( subControl == QskSubWindowArea::Panel )
{ {
return panelRect( area ); return area->contentsRect();
} }
return Inherited::subControlRect( skinnable, subControl ); return Inherited::subControlRect( skinnable, subControl );
} }
QRectF QskSubWindowAreaSkinlet::panelRect( const QskSubWindowArea* area ) const
{
return area->contentsRect();
}
QSGNode* QskSubWindowAreaSkinlet::updateSubNode( QSGNode* QskSubWindowAreaSkinlet::updateSubNode(
const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const
{ {
@ -43,11 +37,12 @@ QSGNode* QskSubWindowAreaSkinlet::updateSubNode(
switch( nodeRole ) switch( nodeRole )
{ {
case PanelRole: case PanelRole:
{
return updatePanelNode( area, node ); return updatePanelNode( area, node );
default:
return nullptr;
} }
}
return Inherited::updateSubNode( skinnable, nodeRole, node );
} }
QSGNode* QskSubWindowAreaSkinlet::updatePanelNode( QSGNode* QskSubWindowAreaSkinlet::updatePanelNode(

View File

@ -34,7 +34,6 @@ protected:
quint8 nodeRole, QSGNode* ) const override; quint8 nodeRole, QSGNode* ) const override;
private: private:
QRectF panelRect( const QskSubWindowArea* ) const;
QSGNode* updatePanelNode( const QskSubWindowArea*, QSGNode* ) const; QSGNode* updatePanelNode( const QskSubWindowArea*, QSGNode* ) const;
}; };

View File

@ -53,14 +53,17 @@ QSGNode* QskSubWindowSkinlet::updateSubNode( const QskSkinnable* skinnable,
switch( nodeRole ) switch( nodeRole )
{ {
case PanelRole: case PanelRole:
{
return updatePanelNode( subWindow, node ); return updatePanelNode( subWindow, node );
}
case TitleBarRole: case TitleBarRole:
{
return updateTitleBarNode( subWindow, node ); return updateTitleBarNode( subWindow, node );
default:
return Inherited::updateSubNode( skinnable, nodeRole, node );
} }
}
return Inherited::updateSubNode( skinnable, nodeRole, node );
} }
QSGNode* QskSubWindowSkinlet::updatePanelNode( QSGNode* QskSubWindowSkinlet::updatePanelNode(

View File

@ -13,7 +13,7 @@
QskTabButtonSkinlet::QskTabButtonSkinlet( QskSkin* skin ): QskTabButtonSkinlet::QskTabButtonSkinlet( QskSkin* skin ):
Inherited( skin ) Inherited( skin )
{ {
setNodeRoles( { ButtonRole, TextRole } ); setNodeRoles( { PanelRole, TextRole } );
} }
QskTabButtonSkinlet::~QskTabButtonSkinlet() = default; QskTabButtonSkinlet::~QskTabButtonSkinlet() = default;
@ -25,33 +25,19 @@ QRectF QskTabButtonSkinlet::subControlRect(
if ( subControl == QskTabButton::Text ) if ( subControl == QskTabButton::Text )
{ {
return textRect( tabButton ); QRectF rect = subControlRect( tabButton, QskTabButton::Panel );
rect = tabButton->innerBox( QskTabButton::Panel, rect );
return rect;
} }
else if ( subControl == QskTabButton::Panel ) else if ( subControl == QskTabButton::Panel )
{ {
return panelRect( tabButton ); return tabButton->contentsRect();
} }
return Inherited::subControlRect( skinnable, subControl ); return Inherited::subControlRect( skinnable, subControl );
} }
QRectF QskTabButtonSkinlet::textRect( const QskTabButton* tabButton ) const
{
QRectF rect = subControlRect( tabButton, QskTabButton::Panel );
#if 1
// the margins might depend on the state ???
rect = tabButton->innerBox( QskTabButton::Panel, rect );
#endif
return rect;
}
QRectF QskTabButtonSkinlet::panelRect( const QskTabButton* tabButton ) const
{
return tabButton->contentsRect();
}
QSGNode* QskTabButtonSkinlet::updateSubNode( QSGNode* QskTabButtonSkinlet::updateSubNode(
const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const
{ {
@ -59,32 +45,23 @@ QSGNode* QskTabButtonSkinlet::updateSubNode(
switch( nodeRole ) switch( nodeRole )
{ {
case ButtonRole: case PanelRole:
return updateButtonNode( tabButton, node ); {
case TextRole:
return updateTextNode( tabButton, node );
default:
return nullptr;
}
}
QSGNode* QskTabButtonSkinlet::updateButtonNode(
const QskTabButton* tabButton, QSGNode* node ) const
{
const auto tabBar = tabButton->tabBar(); const auto tabBar = tabButton->tabBar();
const Qt::Orientation o = tabBar ? tabBar->orientation() : Qt::Horizontal; const Qt::Orientation o = tabBar ? tabBar->orientation() : Qt::Horizontal;
return updateBoxNode( tabButton, node, tabButton->contentsRect(), return updateBoxNode( tabButton, node, tabButton->contentsRect(),
QskTabButton::Panel, ( o == Qt::Vertical ) ? 1 : 0 ); QskTabButton::Panel, ( o == Qt::Vertical ) ? 1 : 0 );
} }
QSGNode* QskTabButtonSkinlet::updateTextNode( case TextRole:
const QskTabButton* tabButton, QSGNode* node ) const {
{ return updateTextNode( tabButton, node, tabButton->text(),
return QskSkinlet::updateTextNode( tabButton, node, tabButton->text(),
tabButton->textOptions(), QskTabButton::Text ); tabButton->textOptions(), QskTabButton::Text );
}
}
return Inherited::updateSubNode( skinnable, nodeRole, node );
} }
#include "moc_QskTabButtonSkinlet.cpp" #include "moc_QskTabButtonSkinlet.cpp"

View File

@ -9,8 +9,6 @@
#include "QskGlobal.h" #include "QskGlobal.h"
#include "QskSkinlet.h" #include "QskSkinlet.h"
class QskTabButton;
class QSK_EXPORT QskTabButtonSkinlet : public QskSkinlet class QSK_EXPORT QskTabButtonSkinlet : public QskSkinlet
{ {
Q_GADGET Q_GADGET
@ -20,7 +18,7 @@ class QSK_EXPORT QskTabButtonSkinlet : public QskSkinlet
public: public:
enum NodeRole enum NodeRole
{ {
ButtonRole, PanelRole,
TextRole TextRole
}; };
@ -33,13 +31,6 @@ public:
protected: protected:
virtual QSGNode* updateSubNode( virtual QSGNode* updateSubNode(
const QskSkinnable*, quint8 nodeRole, QSGNode* ) const override; const QskSkinnable*, quint8 nodeRole, QSGNode* ) const override;
private:
QRectF textRect( const QskTabButton* ) const;
QRectF panelRect( const QskTabButton* ) const;
QSGNode* updateButtonNode( const QskTabButton*, QSGNode* ) const;
QSGNode* updateTextNode( const QskTabButton*, QSGNode* ) const;
}; };
#endif #endif

View File

@ -21,14 +21,32 @@ QRectF QskTabViewSkinlet::subControlRect(
const auto tabView = static_cast< const QskTabView* >( skinnable ); const auto tabView = static_cast< const QskTabView* >( skinnable );
if ( subControl == QskTabView::Page ) if ( subControl == QskTabView::Page )
{
return pageRect( tabView ); return pageRect( tabView );
}
if ( subControl == QskTabView::TabBar ) if ( subControl == QskTabView::TabBar )
{
return tabBarRect( tabView ); return tabBarRect( tabView );
}
return Inherited::subControlRect( skinnable, subControl ); return Inherited::subControlRect( skinnable, subControl );
} }
QSGNode* QskTabViewSkinlet::updateSubNode( const QskSkinnable* skinnable,
quint8 nodeRole, QSGNode* node ) const
{
switch( nodeRole )
{
case PageRole:
{
return updateBoxNode( skinnable, node, QskTabView::Page );
}
}
return Inherited::updateSubNode( skinnable, nodeRole, node );
}
QRectF QskTabViewSkinlet::pageRect( const QskTabView* tabView ) const QRectF QskTabViewSkinlet::pageRect( const QskTabView* tabView ) const
{ {
const QRectF barRect = subControlRect( tabView, QskTabView::TabBar ); const QRectF barRect = subControlRect( tabView, QskTabView::TabBar );
@ -70,25 +88,4 @@ QRectF QskTabViewSkinlet::tabBarRect( const QskTabView* tabView ) const
return r; return r;
} }
QSGNode* QskTabViewSkinlet::updateSubNode( const QskSkinnable* skinnable,
quint8 nodeRole, QSGNode* node ) const
{
const auto tabView = static_cast< const QskTabView* >( skinnable );
switch( nodeRole )
{
case PageRole:
return updatePageNode( tabView, node );
default:
return nullptr;
}
}
QSGNode* QskTabViewSkinlet::updatePageNode(
const QskTabView* tabView, QSGNode* node ) const
{
return updateBoxNode( tabView, node, QskTabView::Page );
}
#include "moc_QskTabViewSkinlet.cpp" #include "moc_QskTabViewSkinlet.cpp"

View File

@ -36,8 +36,6 @@ protected:
private: private:
QRectF pageRect( const QskTabView* ) const; QRectF pageRect( const QskTabView* ) const;
QRectF tabBarRect( const QskTabView* ) const; QRectF tabBarRect( const QskTabView* ) const;
QSGNode* updatePageNode( const QskTabView*, QSGNode* ) const;
}; };
#endif #endif

View File

@ -22,17 +22,12 @@ QRectF QskTextLabelSkinlet::subControlRect(
if ( subControl == QskTextLabel::Text ) if ( subControl == QskTextLabel::Text )
{ {
return textRect( label ); return label->contentsRect();
} }
return Inherited::subControlRect( skinnable, subControl ); return Inherited::subControlRect( skinnable, subControl );
} }
QRectF QskTextLabelSkinlet::textRect( const QskTextLabel* label ) const
{
return label->contentsRect();
}
QSGNode* QskTextLabelSkinlet::updateSubNode( const QskSkinnable* skinnable, QSGNode* QskTextLabelSkinlet::updateSubNode( const QskSkinnable* skinnable,
quint8 nodeRole, QSGNode* node ) const quint8 nodeRole, QSGNode* node ) const
{ {
@ -41,18 +36,13 @@ QSGNode* QskTextLabelSkinlet::updateSubNode( const QskSkinnable* skinnable,
switch( nodeRole ) switch( nodeRole )
{ {
case TextRole: case TextRole:
return updateTextNode( label, node ); {
return updateTextNode( label, node,
default:
return nullptr;
}
}
QSGNode* QskTextLabelSkinlet::updateTextNode(
const QskTextLabel* label, QSGNode* node ) const
{
return QskSkinlet::updateTextNode( label, node,
label->text(), label->textOptions(), QskTextLabel::Text ); label->text(), label->textOptions(), QskTextLabel::Text );
}
}
return Inherited::updateSubNode( skinnable, nodeRole, node );
} }
#include "moc_QskTextLabelSkinlet.cpp" #include "moc_QskTextLabelSkinlet.cpp"

View File

@ -9,8 +9,6 @@
#include "QskGlobal.h" #include "QskGlobal.h"
#include "QskSkinlet.h" #include "QskSkinlet.h"
class QskTextLabel;
class QSK_EXPORT QskTextLabelSkinlet : public QskSkinlet class QSK_EXPORT QskTextLabelSkinlet : public QskSkinlet
{ {
Q_GADGET Q_GADGET
@ -32,10 +30,6 @@ public:
protected: protected:
virtual QSGNode* updateSubNode( const QskSkinnable*, virtual QSGNode* updateSubNode( const QskSkinnable*,
quint8 nodeRole, QSGNode* ) const override; quint8 nodeRole, QSGNode* ) const override;
private:
QRectF textRect( const QskTextLabel* ) const;
QSGNode* updateTextNode( const QskTextLabel*, QSGNode* ) const;
}; };
#endif #endif