padding added
This commit is contained in:
parent
fa26e10c0e
commit
ff5e7574d5
@ -4,6 +4,7 @@
|
||||
*****************************************************************************/
|
||||
|
||||
#include "QskBox.h"
|
||||
#include "QskSkinHintTable.h"
|
||||
|
||||
QSK_SUBCONTROL( QskBox, Panel )
|
||||
|
||||
@ -39,6 +40,65 @@ bool QskBox::hasPanel() const
|
||||
return m_hasPanel;
|
||||
}
|
||||
|
||||
void QskBox::setPadding( qreal padding )
|
||||
{
|
||||
setPadding( QMarginsF( padding, padding, padding, padding ) );
|
||||
}
|
||||
|
||||
void QskBox::setPadding( const QMarginsF& padding )
|
||||
{
|
||||
using namespace QskAspect;
|
||||
|
||||
const QMarginsF pd(
|
||||
qMax( qreal( padding.left() ), qreal( 0.0 ) ),
|
||||
qMax( qreal( padding.top() ), qreal( 0.0 ) ),
|
||||
qMax( qreal( padding.right() ), qreal( 0.0 ) ),
|
||||
qMax( qreal( padding.bottom() ), qreal( 0.0 ) ) );
|
||||
|
||||
if ( pd != this->padding() )
|
||||
{
|
||||
const auto subControl = effectiveSubcontrol( QskBox::Panel );
|
||||
|
||||
setMarginsHint( subControl | Padding, pd );
|
||||
resetImplicitSize();
|
||||
|
||||
if ( polishOnResize() || autoLayoutChildren() )
|
||||
polish();
|
||||
|
||||
Q_EMIT paddingChanged( pd );
|
||||
}
|
||||
}
|
||||
|
||||
void QskBox::resetPadding()
|
||||
{
|
||||
using namespace QskAspect;
|
||||
const Aspect aspect = QskBox::Panel | Metric | Padding;
|
||||
|
||||
const auto oldPadding = marginsHint( aspect );
|
||||
|
||||
auto& table = hintTable();
|
||||
if ( table.hint( aspect ).isValid() )
|
||||
{
|
||||
table.removeHint( aspect );
|
||||
|
||||
const auto padding = marginsHint( aspect );
|
||||
if ( padding != oldPadding )
|
||||
{
|
||||
resetImplicitSize();
|
||||
|
||||
if ( polishOnResize() || autoLayoutChildren() )
|
||||
polish();
|
||||
|
||||
Q_EMIT paddingChanged( padding );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QMarginsF QskBox::padding() const
|
||||
{
|
||||
return marginsHint( QskBox::Panel | QskAspect::Padding );
|
||||
}
|
||||
|
||||
QRectF QskBox::layoutRectForSize( const QSizeF& size ) const
|
||||
{
|
||||
if ( !m_hasPanel )
|
||||
|
@ -17,6 +17,9 @@ class QSK_EXPORT QskBox : public QskControl
|
||||
Q_PROPERTY( bool panel READ hasPanel
|
||||
WRITE setPanel NOTIFY panelChanged FINAL )
|
||||
|
||||
Q_PROPERTY( QMarginsF padding READ padding
|
||||
WRITE setPadding RESET resetPadding NOTIFY paddingChanged )
|
||||
|
||||
public:
|
||||
QSK_SUBCONTROLS( Panel )
|
||||
|
||||
@ -28,10 +31,16 @@ class QSK_EXPORT QskBox : public QskControl
|
||||
void setPanel( bool );
|
||||
bool hasPanel() const;
|
||||
|
||||
void setPadding( qreal );
|
||||
void setPadding( const QMarginsF& );
|
||||
void resetPadding();
|
||||
QMarginsF padding() const;
|
||||
|
||||
QRectF layoutRectForSize( const QSizeF& ) const override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void panelChanged( bool );
|
||||
void paddingChanged( const QMarginsF& );
|
||||
|
||||
protected:
|
||||
QSizeF contentsSizeHint( Qt::SizeHint, const QSizeF& ) const override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user