QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskTabViewSkinlet.cpp
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#include "QskTabViewSkinlet.h"
7#include "QskTabView.h"
8
9#include "QskTabBar.h"
10
11QskTabViewSkinlet::QskTabViewSkinlet( QskSkin* skin )
12 : Inherited( skin )
13{
14 setNodeRoles( { PageRole } );
15}
16
17QskTabViewSkinlet::~QskTabViewSkinlet() = default;
18
19QRectF QskTabViewSkinlet::subControlRect( const QskSkinnable* skinnable,
20 const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const
21{
22 const auto tabView = static_cast< const QskTabView* >( skinnable );
23
24 if ( subControl == QskTabView::Page )
25 {
26 return pageRect( tabView, contentsRect );
27 }
28
29 if ( subControl == QskTabView::TabBar )
30 {
31 return tabBarRect( tabView, contentsRect );
32 }
33
34 return Inherited::subControlRect( skinnable, contentsRect, subControl );
35}
36
37QSGNode* QskTabViewSkinlet::updateSubNode(
38 const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const
39{
40 switch ( nodeRole )
41 {
42 case PageRole:
43 {
44 return updateBoxNode( skinnable, node, QskTabView::Page );
45 }
46 }
47
48 return Inherited::updateSubNode( skinnable, nodeRole, node );
49}
50
51QRectF QskTabViewSkinlet::pageRect(
52 const QskTabView* tabView, const QRectF& rect ) const
53{
54 const auto barRect = subControlRect( tabView, rect, QskTabView::TabBar );
55
56#if 1
57 auto r = tabView->layoutRect();
58#endif
59
60 switch( tabView->tabBarEdge() )
61 {
62 case Qt::TopEdge:
63 r.setTop( barRect.bottom() );
64 break;
65
66 case Qt::BottomEdge:
67 r.setBottom( barRect.top() );
68 break;
69
70 case Qt::LeftEdge:
71 r.setLeft( barRect.right() );
72 break;
73
74 case Qt::RightEdge:
75 r.setRight( barRect.left() );
76 break;
77 }
78
79 return r;
80}
81
82QRectF QskTabViewSkinlet::tabBarRect(
83 const QskTabView* tabView, const QRectF& rect ) const
84{
85 Q_UNUSED( rect )
86
87 const QSizeF barSize = tabView->tabBar()->sizeConstraint();
88
89#if 1
90 QRectF r = tabView->layoutRect();
91#endif
92
93 switch( tabView->tabBarEdge() )
94 {
95 case Qt::TopEdge:
96 r.setHeight( barSize.height() );
97 break;
98
99 case Qt::BottomEdge:
100 r.setTop( r.bottom() - barSize.height() );
101 break;
102
103 case Qt::LeftEdge:
104 r.setWidth( barSize.width() );
105 break;
106
107 case Qt::RightEdge:
108 r.setLeft( r.right() - barSize.width() );
109 break;
110 }
111
112 return r;
113}
114
115#include "moc_QskTabViewSkinlet.cpp"
Subcontrol
For use within the rendering or lay-outing of a specific QskSkinnable.
Definition QskAspect.h:104
QRectF layoutRect() const
QSizeF sizeConstraint
Definition QskControl.h:50