subControlContentsRect added
This commit is contained in:
parent
c419b26850
commit
79cceb1b09
@ -46,21 +46,21 @@ QRectF MyToggleButtonSkinlet::subControlRect( const QskSkinnable* skinnable,
|
||||
}
|
||||
else if( subControl == Q::UncheckedPanel )
|
||||
{
|
||||
const auto r = innerRect( skinnable, contentsRect, Q::Panel );
|
||||
const auto r = button->subControlContentsRect( contentsRect, Q::Panel );
|
||||
return sectionRect( r, button->isInverted() ? 0 : 1 );
|
||||
}
|
||||
else if( subControl == Q::CheckedPanel )
|
||||
{
|
||||
const auto r = innerRect( skinnable, contentsRect, Q::Panel );
|
||||
const auto r = button->subControlContentsRect( contentsRect, Q::Panel );
|
||||
return sectionRect( r, button->isInverted() ? 1 : 0 );
|
||||
}
|
||||
else if( subControl == Q::CheckedLabel || subControl == Q::CheckedIcon )
|
||||
{
|
||||
return innerRect( skinnable, contentsRect, Q::CheckedPanel );
|
||||
return button->subControlContentsRect( contentsRect, Q::CheckedPanel );
|
||||
}
|
||||
else if( subControl == Q::UncheckedLabel || subControl == Q::UncheckedIcon )
|
||||
{
|
||||
return innerRect( skinnable, contentsRect, Q::UncheckedPanel );
|
||||
return button->subControlContentsRect( contentsRect, Q::UncheckedPanel );
|
||||
}
|
||||
else if( subControl == Q::Cursor )
|
||||
{
|
||||
@ -68,7 +68,7 @@ QRectF MyToggleButtonSkinlet::subControlRect( const QskSkinnable* skinnable,
|
||||
if ( button->isInverted() )
|
||||
position = 1.0 - position;
|
||||
|
||||
auto rect = innerRect( skinnable, contentsRect, Q::Panel );
|
||||
auto rect = button->subControlContentsRect( contentsRect, Q::Panel );
|
||||
|
||||
rect.setWidth( 0.5 * rect.width() );
|
||||
rect.moveLeft( rect.left() + position * rect.width() );
|
||||
@ -79,13 +79,6 @@ QRectF MyToggleButtonSkinlet::subControlRect( const QskSkinnable* skinnable,
|
||||
return Inherited::subControlRect( skinnable, contentsRect, subControl );
|
||||
}
|
||||
|
||||
QRectF MyToggleButtonSkinlet::innerRect( const QskSkinnable* skinnable,
|
||||
const QRectF& rect, QskAspect::Subcontrol subControl ) const
|
||||
{
|
||||
const auto r = subControlRect( skinnable, rect, subControl );
|
||||
return skinnable->innerBox( subControl, r );
|
||||
}
|
||||
|
||||
QSGNode* MyToggleButtonSkinlet::updateSubNode(
|
||||
const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const
|
||||
{
|
||||
|
@ -43,10 +43,6 @@ class MyToggleButtonSkinlet : public QskSkinlet
|
||||
protected:
|
||||
QSGNode* updateSubNode( const QskSkinnable*,
|
||||
quint8 nodeRole, QSGNode* ) const override;
|
||||
|
||||
private:
|
||||
QRectF innerRect( const QskSkinnable*,
|
||||
const QRectF&, QskAspect::Subcontrol ) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -66,10 +66,10 @@ QMarginsF QskBox::padding() const
|
||||
|
||||
QRectF QskBox::layoutRectForSize( const QSizeF& size ) const
|
||||
{
|
||||
if ( !m_hasPanel )
|
||||
return Inherited::layoutRectForSize( size );
|
||||
if ( m_hasPanel )
|
||||
return subControlContentsRect( size, Panel );
|
||||
|
||||
return innerBox( Panel, subControlRect( size, Panel ) );
|
||||
return Inherited::layoutRectForSize( size );
|
||||
}
|
||||
|
||||
#include "moc_QskBox.cpp"
|
||||
|
@ -196,13 +196,7 @@ QRectF QskControl::contentsRect() const
|
||||
|
||||
QRectF QskControl::subControlRect( QskAspect::Subcontrol subControl ) const
|
||||
{
|
||||
return effectiveSkinlet()->subControlRect( this, contentsRect(), subControl );
|
||||
}
|
||||
|
||||
QRectF QskControl::subControlRect(
|
||||
const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const
|
||||
{
|
||||
return effectiveSkinlet()->subControlRect( this, contentsRect, subControl );
|
||||
return subControlRect( contentsRect(), subControl );
|
||||
}
|
||||
|
||||
QRectF QskControl::subControlRect(
|
||||
@ -211,7 +205,21 @@ QRectF QskControl::subControlRect(
|
||||
QRectF rect( 0.0, 0.0, size.width(), size.height() );
|
||||
rect = qskValidOrEmptyInnerRect( rect, margins() );
|
||||
|
||||
return effectiveSkinlet()->subControlRect( this, rect, subControl );
|
||||
return subControlRect( rect, subControl );
|
||||
}
|
||||
|
||||
QRectF QskControl::subControlContentsRect( QskAspect::Subcontrol subControl ) const
|
||||
{
|
||||
return subControlContentsRect( contentsRect(), subControl );
|
||||
}
|
||||
|
||||
QRectF QskControl::subControlContentsRect(
|
||||
const QSizeF& size, QskAspect::Subcontrol subControl ) const
|
||||
{
|
||||
QRectF rect( 0.0, 0.0, size.width(), size.height() );
|
||||
rect = qskValidOrEmptyInnerRect( rect, margins() );
|
||||
|
||||
return subControlContentsRect( rect, subControl );
|
||||
}
|
||||
|
||||
QLocale QskControl::locale() const
|
||||
|
@ -93,10 +93,14 @@ class QSK_EXPORT QskControl : public QskQuickItem, public QskSkinnable
|
||||
virtual QRectF focusIndicatorRect() const;
|
||||
virtual QRectF focusIndicatorClipRect() const;
|
||||
|
||||
using QskSkinnable::subControlRect;
|
||||
QRectF subControlRect( QskAspect::Subcontrol ) const;
|
||||
QRectF subControlRect( const QRectF&, QskAspect::Subcontrol ) const;
|
||||
QRectF subControlRect( const QSizeF&, QskAspect::Subcontrol ) const;
|
||||
|
||||
using QskSkinnable::subControlContentsRect;
|
||||
QRectF subControlContentsRect( QskAspect::Subcontrol ) const;
|
||||
QRectF subControlContentsRect( const QSizeF&, QskAspect::Subcontrol ) const;
|
||||
|
||||
void setAutoFillBackground( bool );
|
||||
bool autoFillBackground() const;
|
||||
|
||||
|
@ -140,8 +140,7 @@ QSGNode* QskPageIndicatorSkinlet::updateBulletsNode(
|
||||
if ( node == nullptr )
|
||||
node = new QSGNode();
|
||||
|
||||
QRectF rect = indicator->subControlRect( QskPageIndicator::Panel );
|
||||
rect = indicator->innerBox( QskPageIndicator::Panel, rect );
|
||||
const auto rect = indicator->subControlContentsRect( QskPageIndicator::Panel );
|
||||
|
||||
// index of the highlighted bullet
|
||||
int currentBullet = qRound( indicator->currentIndex() );
|
||||
|
@ -242,7 +242,7 @@ void QskPushButton::updateResources()
|
||||
|
||||
QRectF QskPushButton::layoutRectForSize( const QSizeF& size ) const
|
||||
{
|
||||
return innerBox( Panel, subControlRect( size, Panel ) );
|
||||
return subControlContentsRect( size, Panel );
|
||||
}
|
||||
|
||||
void QskPushButton::changeEvent( QEvent* event )
|
||||
|
@ -73,8 +73,7 @@ QRectF QskPushButtonSkinlet::textRect(
|
||||
{
|
||||
// buttonShift -> TODO
|
||||
|
||||
QRectF r = button->innerBox( QskPushButton::Panel,
|
||||
subControlRect( button, contentsRect, QskPushButton::Panel ) );
|
||||
auto r = button->subControlContentsRect( contentsRect, QskPushButton::Panel );
|
||||
|
||||
if ( button->hasGraphic() )
|
||||
{
|
||||
@ -93,8 +92,7 @@ QRectF QskPushButtonSkinlet::graphicRect(
|
||||
{
|
||||
// buttonShift -> TODO
|
||||
|
||||
auto r = button->innerBox( QskPushButton::Panel,
|
||||
subControlRect( button, contentsRect, QskPushButton::Panel ) );
|
||||
auto r = button->subControlContentsRect( contentsRect, QskPushButton::Panel );
|
||||
|
||||
if ( !button->text().isEmpty() )
|
||||
{
|
||||
|
@ -893,14 +893,7 @@ static inline QskMargins qskEffectivePadding( const QskSkinnable* skinnable,
|
||||
// sin 45° ceiled : 0.70710678;
|
||||
padding *= 1.0 - 0.70710678;
|
||||
|
||||
const auto paddingHint = skinnable->paddingHint( aspect );
|
||||
|
||||
return QskMargins(
|
||||
qMax( padding.left(), paddingHint.left() ),
|
||||
qMax( padding.top(), paddingHint.top() ),
|
||||
qMax( padding.right(), paddingHint.right() ),
|
||||
qMax( padding.bottom(), paddingHint.bottom() )
|
||||
);
|
||||
return padding.expandedTo( skinnable->paddingHint( aspect ) );
|
||||
}
|
||||
|
||||
QMarginsF QskSkinnable::innerPadding(
|
||||
@ -942,6 +935,18 @@ QRectF QskSkinnable::outerBox(
|
||||
return innerBox.marginsAdded( m );
|
||||
}
|
||||
|
||||
QRectF QskSkinnable::subControlRect(
|
||||
const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const
|
||||
{
|
||||
return effectiveSkinlet()->subControlRect( this, contentsRect, subControl );
|
||||
}
|
||||
|
||||
QRectF QskSkinnable::subControlContentsRect(
|
||||
const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const
|
||||
{
|
||||
return innerBox( subControl, subControlRect( contentsRect, subControl ) );
|
||||
}
|
||||
|
||||
bool QskSkinnable::isTransitionAccepted( QskAspect aspect ) const
|
||||
{
|
||||
Q_UNUSED( aspect )
|
||||
|
@ -97,6 +97,9 @@ class QSK_EXPORT QskSkinnable
|
||||
const char* skinStateAsPrintable() const;
|
||||
const char* skinStateAsPrintable( QskAspect::State ) const;
|
||||
|
||||
QRectF subControlRect( const QRectF&, QskAspect::Subcontrol ) const;
|
||||
QRectF subControlContentsRect( const QRectF&, QskAspect::Subcontrol ) const;
|
||||
|
||||
QSizeF outerBoxSize( QskAspect, const QSizeF& innerBoxSize ) const;
|
||||
QSizeF innerBoxSize( QskAspect, const QSizeF& outerBoxSize ) const;
|
||||
|
||||
|
@ -15,12 +15,15 @@ static inline QRectF qskInnerPanelRect(
|
||||
{
|
||||
using Q = QskSlider;
|
||||
|
||||
// QskSkinnable::innerBox ???
|
||||
#if 1
|
||||
auto padding = slider->paddingHint( Q::Panel );
|
||||
padding += slider->boxBorderMetricsHint( Q::Panel ).widths();
|
||||
|
||||
auto r = slider->subControlRect( contentsRect, Q::Panel );
|
||||
r = r.marginsRemoved( padding );
|
||||
#else
|
||||
r = slider->subControlContentsRect( contentsRect, Q::Panel );
|
||||
#endif
|
||||
|
||||
return r;
|
||||
}
|
||||
|
@ -121,8 +121,7 @@ QRectF QskSubWindowSkinlet::symbolRect(
|
||||
{
|
||||
using Q = QskSubWindow;
|
||||
|
||||
auto rect = subControlRect( subWindow, contentsRect, Q::TitleBar );
|
||||
rect = subWindow->innerBox( Q::TitleBar, rect );
|
||||
auto rect = subWindow->subControlContentsRect( contentsRect, Q::TitleBar );
|
||||
|
||||
int w = 0;
|
||||
|
||||
@ -143,8 +142,7 @@ QRectF QskSubWindowSkinlet::titleRect(
|
||||
{
|
||||
using Q = QskSubWindow;
|
||||
|
||||
auto rect = subControlRect( subWindow, contentsRect, Q::TitleBar );
|
||||
rect = subWindow->innerBox( Q::TitleBar, rect );
|
||||
auto rect = subWindow->subControlContentsRect( contentsRect, Q::TitleBar );
|
||||
|
||||
if ( !rect.isEmpty() )
|
||||
{
|
||||
|
@ -89,7 +89,7 @@ QskTextOptions QskTabButton::textOptions() const
|
||||
|
||||
QRectF QskTabButton::layoutRectForSize( const QSizeF& size ) const
|
||||
{
|
||||
return innerBox( Panel, subControlRect( size, Panel ) );
|
||||
return subControlContentsRect( size, Panel );
|
||||
}
|
||||
|
||||
QskAspect::Placement QskTabButton::effectivePlacement() const
|
||||
|
@ -20,14 +20,9 @@ QskTabButtonSkinlet::~QskTabButtonSkinlet() = default;
|
||||
QRectF QskTabButtonSkinlet::subControlRect( const QskSkinnable* skinnable,
|
||||
const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const
|
||||
{
|
||||
auto tabButton = static_cast< const QskTabButton* >( skinnable );
|
||||
|
||||
if ( subControl == QskTabButton::Text )
|
||||
{
|
||||
auto r = subControlRect( tabButton, contentsRect, QskTabButton::Panel );
|
||||
r = tabButton->innerBox( QskTabButton::Panel, r );
|
||||
|
||||
return r;
|
||||
return skinnable->subControlContentsRect( contentsRect, QskTabButton::Panel );
|
||||
}
|
||||
else if ( subControl == QskTabButton::Panel )
|
||||
{
|
||||
|
@ -320,13 +320,10 @@ void QskTabView::updateLayout()
|
||||
if ( maybeUnresized() )
|
||||
return;
|
||||
|
||||
m_data->tabBar->setGeometry( subControlRect( TabBar ) );
|
||||
const auto cr = contentsRect();
|
||||
|
||||
#if 1
|
||||
m_data->stackBox->setGeometry( subControlRect( Page ) );
|
||||
#else
|
||||
m_data->stackBox->setGeometry( innerBox( Page, subControlRect( Page ) ) );
|
||||
#endif
|
||||
m_data->tabBar->setGeometry( subControlRect( cr, TabBar ) );
|
||||
m_data->stackBox->setGeometry( subControlContentsRect( cr, Page ) );
|
||||
}
|
||||
|
||||
#include "moc_QskTabView.cpp"
|
||||
|
@ -25,8 +25,7 @@ QRectF QskTextInputSkinlet::subControlRect( const QskSkinnable* skinnable,
|
||||
}
|
||||
else if ( subControl == QskTextInput::Text )
|
||||
{
|
||||
const auto r = subControlRect( skinnable, contentsRect, QskTextInput::Panel );
|
||||
return skinnable->innerBox( QskTextInput::Panel, r );
|
||||
return skinnable->subControlContentsRect( contentsRect, QskTextInput::Panel );
|
||||
}
|
||||
|
||||
return Inherited::subControlRect( skinnable, contentsRect, subControl );
|
||||
|
@ -23,19 +23,16 @@ QskTextLabelSkinlet::~QskTextLabelSkinlet() = default;
|
||||
QRectF QskTextLabelSkinlet::subControlRect( const QskSkinnable* skinnable,
|
||||
const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const
|
||||
{
|
||||
const auto label = static_cast< const QskTextLabel* >( skinnable );
|
||||
|
||||
if ( subControl == QskTextLabel::Panel )
|
||||
{
|
||||
return contentsRect;
|
||||
}
|
||||
else if ( subControl == QskTextLabel::Text )
|
||||
{
|
||||
const auto label = static_cast< const QskTextLabel* >( skinnable );
|
||||
|
||||
if ( label->hasPanel() )
|
||||
{
|
||||
auto r = subControlRect( label, contentsRect, QskTextLabel::Panel );
|
||||
return label->innerBox( QskTextLabel::Panel, r );
|
||||
}
|
||||
return label->subControlContentsRect( contentsRect, QskTextLabel::Panel );
|
||||
|
||||
return contentsRect;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user