QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskBoxSkinlet.cpp
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#include "QskBoxSkinlet.h"
7#include "QskBox.h"
8
9QskBoxSkinlet::QskBoxSkinlet( QskSkin* skin )
10 : Inherited( skin )
11{
12 setNodeRoles( { PanelRole } );
13}
14
15QskBoxSkinlet::~QskBoxSkinlet()
16{
17}
18
19QRectF QskBoxSkinlet::subControlRect( const QskSkinnable* skinnable,
20 const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const
21{
22 if ( subControl == QskBox::Panel )
23 {
24 return contentsRect;
25 }
26
27 return Inherited::subControlRect( skinnable, contentsRect, subControl );
28}
29
30QSGNode* QskBoxSkinlet::updateSubNode(
31 const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const
32{
33 const auto box = static_cast< const QskBox* >( skinnable );
34
35 switch ( nodeRole )
36 {
37 case PanelRole:
38 {
39 if ( !box->hasPanel() )
40 return nullptr;
41
42 return updateBoxNode( skinnable, node, QskBox::Panel );
43 }
44 }
45
46 return Inherited::updateSubNode( skinnable, nodeRole, node );
47}
48
49QSizeF QskBoxSkinlet::sizeHint( const QskSkinnable* skinnable,
50 Qt::SizeHint which, const QSizeF& constraint ) const
51{
52 const auto box = static_cast< const QskBox* >( skinnable );
53
54 if ( box->hasPanel() && which == Qt::PreferredSize )
55 return box->strutSizeHint( QskBox::Panel );
56
57 return Inherited::sizeHint( skinnable, which, constraint );
58}
59
60#include "moc_QskBoxSkinlet.cpp"
Subcontrol
For use within the rendering or lay-outing of a specific QskSkinnable.
Definition QskAspect.h:104
QSizeF strutSizeHint(QskAspect, QskSkinHintStatus *=nullptr) const
Retrieves a strut size hint.