layout code moved from QskInputPanel to QskBox
This commit is contained in:
parent
62de379794
commit
b97a43008c
@ -43,4 +43,75 @@ QSizeF QskBox::contentsSizeHint() const
|
||||
return outerBoxSize( Panel, size ).expandedTo( minSize );
|
||||
}
|
||||
|
||||
qreal QskBox::heightForWidth( qreal width ) const
|
||||
{
|
||||
qreal height = -1;
|
||||
|
||||
if ( autoLayoutChildren() )
|
||||
{
|
||||
const auto children = childItems();
|
||||
if ( !children.isEmpty() )
|
||||
{
|
||||
const auto margins = this->margins();
|
||||
width -= margins.left() + margins.right();
|
||||
|
||||
const auto padding = innerPadding( Panel, QSizeF( width, width ) );
|
||||
width -= padding.left() + padding.right();
|
||||
|
||||
for ( auto child : children )
|
||||
{
|
||||
if ( auto control = qobject_cast< const QskControl* >( child ) )
|
||||
{
|
||||
if ( !control->isTransparentForPositioner() )
|
||||
height = qMax( height, control->heightForWidth( width ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( height >= 0 )
|
||||
{
|
||||
height += padding.top() + padding.bottom();
|
||||
height += margins.top() + margins.bottom();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return height;
|
||||
}
|
||||
|
||||
qreal QskBox::widthForHeight( qreal height ) const
|
||||
{
|
||||
qreal width = -1;
|
||||
|
||||
if ( autoLayoutChildren() )
|
||||
{
|
||||
const auto children = childItems();
|
||||
if ( !children.isEmpty() )
|
||||
{
|
||||
const auto margins = this->margins();
|
||||
height -= margins.top() + margins.bottom();
|
||||
|
||||
const auto padding = innerPadding( Panel, QSizeF( height, height ) );
|
||||
height -= padding.top() + padding.bottom();
|
||||
|
||||
for ( auto child : children )
|
||||
{
|
||||
if ( auto control = qobject_cast< const QskControl* >( child ) )
|
||||
{
|
||||
if ( !control->isTransparentForPositioner() )
|
||||
width = qMax( width, control->widthForHeight( height ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( width >= 0 )
|
||||
{
|
||||
width += padding.left() + padding.right();
|
||||
width += margins.left() + margins.right();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
|
||||
#include "moc_QskBox.cpp"
|
||||
|
@ -22,6 +22,9 @@ public:
|
||||
|
||||
virtual QRectF layoutRect() const override;
|
||||
virtual QSizeF contentsSizeHint() const override;
|
||||
|
||||
virtual qreal heightForWidth( qreal width ) const override;
|
||||
virtual qreal widthForHeight( qreal height ) const override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -637,36 +637,4 @@ void QskInputPanel::keyReleaseEvent( QKeyEvent* event )
|
||||
return Inherited::keyReleaseEvent( event );
|
||||
}
|
||||
|
||||
qreal QskInputPanel::heightForWidth( qreal width ) const
|
||||
{
|
||||
const auto margins = this->margins();
|
||||
width -= margins.left() + margins.right();
|
||||
|
||||
const auto padding = innerPadding( Panel, QSizeF( width, width ) );
|
||||
width -= padding.left() + padding.right();
|
||||
|
||||
qreal height = m_data->layout->heightForWidth( width );
|
||||
|
||||
height += padding.top() + padding.bottom();
|
||||
height += margins.top() + margins.bottom();
|
||||
|
||||
return height;
|
||||
}
|
||||
|
||||
qreal QskInputPanel::widthForHeight( qreal height ) const
|
||||
{
|
||||
const auto margins = this->margins();
|
||||
height -= margins.top() + margins.bottom();
|
||||
|
||||
const auto padding = innerPadding( Panel, QSizeF( height, height ) );
|
||||
height -= padding.top() + padding.bottom();
|
||||
|
||||
qreal width = m_data->keyboard->widthForHeight( height );
|
||||
|
||||
width += padding.left() + padding.right();
|
||||
width += margins.left() + margins.right();
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
#include "moc_QskInputPanel.cpp"
|
||||
|
@ -41,9 +41,6 @@ public:
|
||||
bool hasInputProxy() const;
|
||||
QString inputPrompt() const;
|
||||
|
||||
virtual qreal heightForWidth( qreal width ) const override;
|
||||
virtual qreal widthForHeight( qreal height ) const override;
|
||||
|
||||
virtual QskAspect::Subcontrol effectiveSubcontrol(
|
||||
QskAspect::Subcontrol ) const override;
|
||||
|
||||
|
@ -37,6 +37,7 @@ public:
|
||||
|
||||
virtual qreal heightForWidth( qreal width ) const override;
|
||||
virtual qreal widthForHeight( qreal height ) const override;
|
||||
|
||||
virtual QSizeF contentsSizeHint() const override;
|
||||
|
||||
virtual QskAspect::Subcontrol effectiveSubcontrol(
|
||||
@ -49,10 +50,9 @@ Q_SIGNALS:
|
||||
protected:
|
||||
virtual void updateLayout() override;
|
||||
|
||||
private Q_SLOTS:
|
||||
private:
|
||||
void buttonPressed();
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
std::unique_ptr< PrivateData > m_data;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user