QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskBox.cpp
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#include "QskBox.h"
7#include "QskMargins.h"
8#include "QskBoxBorderMetrics.h"
9#include "QskBoxBorderColors.h"
10#include "QskGradient.h"
11
12QSK_SUBCONTROL( QskBox, Panel )
13
14QskBox::QskBox( QQuickItem* parent )
15 : QskBox( true, parent )
16{
17}
18
19QskBox::QskBox( bool hasPanel, QQuickItem* parent )
20 : Inherited( parent )
21 , m_hasPanel( hasPanel )
22{
23}
24
25QskBox::~QskBox()
26{
27}
28
29void QskBox::setPanel( bool on )
30{
31 if ( on != m_hasPanel )
32 {
33 m_hasPanel = on;
34
36 polish();
37 update();
38 }
39}
40
41bool QskBox::hasPanel() const
42{
43 return m_hasPanel;
44}
45
46QskBoxBorderMetrics QskBox::borderMetrics() const
47{
48 return boxBorderMetricsHint( Panel );
49}
50
51void QskBox::setBorderMetrics( const QskBoxBorderMetrics& metrics )
52{
53 if ( setBoxBorderMetricsHint( Panel, metrics ) )
54 Q_EMIT borderMetricsChanged( borderMetrics() );
55}
56
57void QskBox::resetBorderMetrics()
58{
59 if ( resetBoxBorderMetricsHint( Panel ) )
60 Q_EMIT borderMetricsChanged( borderMetrics() );
61}
62
63QskBoxBorderColors QskBox::borderColors() const
64{
65 return boxBorderColorsHint( Panel );
66}
67
68void QskBox::setBorderColors( const QskBoxBorderColors& colors )
69{
70 if ( setBoxBorderColorsHint( Panel, colors ) )
71 Q_EMIT borderColorsChanged( borderColors() );
72}
73
74void QskBox::resetBorderColors()
75{
76 if ( resetBoxBorderColorsHint( Panel ) )
77 Q_EMIT borderColorsChanged( borderColors() );
78}
79
80QskGradient QskBox::fillGradient() const
81{
82 return gradientHint( Panel );
83}
84
85void QskBox::setFillGradient( const QskGradient& gradient )
86{
87 if ( setGradientHint( Panel, gradient ) )
88 Q_EMIT fillGradientChanged( gradient );
89}
90
91void QskBox::resetFillGradient()
92{
93 if ( resetColor( Panel ) )
94 Q_EMIT fillGradientChanged( fillGradient() );
95}
96
97void QskBox::setPadding( qreal padding )
98{
99 setPadding( QskMargins( padding ) );
100}
101
102void QskBox::setPadding( const QMarginsF& padding )
103{
104 const auto pd = QskMargins().expandedTo( padding );
105
106 if ( setPaddingHint( Panel, pd ) )
107 Q_EMIT paddingChanged( pd );
108}
109
110void QskBox::resetPadding()
111{
112 if ( resetPaddingHint( Panel ) )
113 Q_EMIT paddingChanged( paddingHint( Panel ) );
114}
115
116QMarginsF QskBox::padding() const
117{
118 return paddingHint( Panel );
119}
120
121QRectF QskBox::layoutRectForSize( const QSizeF& size ) const
122{
123 if ( m_hasPanel )
124 return subControlContentsRect( size, Panel );
125
126 return Inherited::layoutRectForSize( size );
127}
128
129#include "moc_QskBox.cpp"
QRectF layoutRectForSize(const QSizeF &) const override
Definition QskBox.cpp:121
QRectF subControlContentsRect(QskAspect::Subcontrol) const
virtual QRectF layoutRectForSize(const QSizeF &) const
void resetImplicitSize()
Definition QskItem.cpp:721
QMarginsF paddingHint(QskAspect, QskSkinHintStatus *=nullptr) const
Retrieves a padding hint.
bool resetColor(QskAspect)
Removes a color hint from the local table.
QskGradient gradientHint(QskAspect, QskSkinHintStatus *=nullptr) const
Retrieves a color hint as gradient.
bool setBoxBorderColorsHint(QskAspect, const QskBoxBorderColors &)
Sets a border colors hint.
bool setPaddingHint(QskAspect, qreal)
Sets a padding hint.
bool resetBoxBorderColorsHint(QskAspect)
Removes a border colors hint from the local table.
bool setGradientHint(QskAspect, const QskGradient &)
Sets a gradient as color hint.
bool setBoxBorderMetricsHint(QskAspect, const QskBoxBorderMetrics &)
Sets a border metrics hint.
bool resetBoxBorderMetricsHint(QskAspect)
Removes a border metrics hint from the local table.
QskBoxBorderColors boxBorderColorsHint(QskAspect, QskSkinHintStatus *=nullptr) const
Retrieves border colors hint.
QskBoxBorderMetrics boxBorderMetricsHint(QskAspect, QskSkinHintStatus *=nullptr) const
Retrieves a border hint.
bool resetPaddingHint(QskAspect)
Removes a padding hint from the local table.