6#include "QskTabButtonSkinlet.h"
7#include "QskTabButton.h"
9#include "QskTextOptions.h"
10#include <qfontmetrics.h>
12QskTabButtonSkinlet::QskTabButtonSkinlet(
QskSkin* skin )
15 setNodeRoles( { PanelRole, TextRole } );
18QskTabButtonSkinlet::~QskTabButtonSkinlet() =
default;
20QRectF QskTabButtonSkinlet::subControlRect(
const QskSkinnable* skinnable,
23 if ( subControl == QskTabButton::Text )
27 else if ( subControl == QskTabButton::Panel )
32 return Inherited::subControlRect( skinnable, contentsRect, subControl );
35QSGNode* QskTabButtonSkinlet::updateSubNode(
36 const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node )
const
38 const auto tabButton =
static_cast< const QskTabButton*
>( skinnable );
44 return updateBoxNode( tabButton, node, QskTabButton::Panel );
49 return updateTextNode( tabButton, node,
50 tabButton->text(), QskTabButton::Text );
54 return Inherited::updateSubNode( skinnable, nodeRole, node );
57QSizeF QskTabButtonSkinlet::sizeHint(
const QskSkinnable* skinnable,
58 Qt::SizeHint which,
const QSizeF& )
const
62 if ( which != Qt::PreferredSize )
65 const auto tabButton =
static_cast< const QskTabButton*
>( skinnable );
68 const auto text = tabButton->text();
70 if ( !text.isEmpty() )
72 const QFontMetricsF fm( tabButton->effectiveFont( QskTabButton::Text ) );
73 size = fm.size( Qt::TextShowMnemonic, text );
76 size = tabButton->outerBoxSize( Q::Panel, size );
77 size = size.expandedTo( tabButton->strutSizeHint( Q::Panel ) );
78 size = size.grownBy( skinnable->
marginHint( Q::Panel ) );
83#include "moc_QskTabButtonSkinlet.cpp"
Subcontrol
For use within the rendering or lay-outing of a specific QskSkinnable.
QMarginsF marginHint(QskAspect, QskSkinHintStatus *=nullptr) const
Retrieves a margin hint.
QRectF subControlContentsRect(const QRectF &, QskAspect::Subcontrol) const
Calculate the inner rectangle for subControl.