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