Remove alignment, make Drawer allways expand
This commit is contained in:
parent
fb626078bf
commit
684f9c91da
@ -15,7 +15,6 @@ class QskDrawer::PrivateData {
|
|||||||
QskControl* content;
|
QskControl* content;
|
||||||
QskBox* contentBox;
|
QskBox* contentBox;
|
||||||
Qt::Edge edge = Qt::LeftEdge;
|
Qt::Edge edge = Qt::LeftEdge;
|
||||||
Qt::Alignment alignment = Qt::AlignCenter;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
QskDrawer::QskDrawer( QQuickItem* parentItem ):
|
QskDrawer::QskDrawer( QQuickItem* parentItem ):
|
||||||
@ -28,6 +27,8 @@ QskDrawer::QskDrawer( QQuickItem* parentItem ):
|
|||||||
|
|
||||||
m_data->contentBox = new QskBox(this);
|
m_data->contentBox = new QskBox(this);
|
||||||
m_data->contentBox->setSubcontrolProxy( QskBox::Panel, Panel );
|
m_data->contentBox->setSubcontrolProxy( QskBox::Panel, Panel );
|
||||||
|
m_data->contentBox->setPanel( true );
|
||||||
|
|
||||||
setSubcontrolProxy( Inherited::Overlay, Overlay );
|
setSubcontrolProxy( Inherited::Overlay, Overlay );
|
||||||
|
|
||||||
setFaderAspect( Panel | QskAspect::Metric );
|
setFaderAspect( Panel | QskAspect::Metric );
|
||||||
@ -47,10 +48,6 @@ Qt::Edge QskDrawer::edge() const {
|
|||||||
return m_data->edge;
|
return m_data->edge;
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::Alignment QskDrawer::alignment() const {
|
|
||||||
return m_data->alignment;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QskDrawer::setEdge( Qt::Edge edge ) {
|
void QskDrawer::setEdge( Qt::Edge edge ) {
|
||||||
if( m_data->edge == edge )
|
if( m_data->edge == edge )
|
||||||
{
|
{
|
||||||
@ -62,17 +59,6 @@ void QskDrawer::setEdge( Qt::Edge edge ) {
|
|||||||
edgeChanged( edge );
|
edgeChanged( edge );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskDrawer::setAlignment( Qt::Alignment alignment ) {
|
|
||||||
if( m_data->alignment == alignment )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
update();
|
|
||||||
m_data->alignment = alignment;
|
|
||||||
alignmentChanged( alignment );
|
|
||||||
}
|
|
||||||
|
|
||||||
void QskDrawer::setContent( QskControl* content ) {
|
void QskDrawer::setContent( QskControl* content ) {
|
||||||
content->setParentItem( m_data->contentBox );
|
content->setParentItem( m_data->contentBox );
|
||||||
m_data->content = content;
|
m_data->content = content;
|
||||||
@ -86,19 +72,9 @@ void QskDrawer::updateLayout() {
|
|||||||
case Qt::Edge::LeftEdge:
|
case Qt::Edge::LeftEdge:
|
||||||
{
|
{
|
||||||
qreal x = metric( faderAspect() ) * contentSize.width() * -1.0;
|
qreal x = metric( faderAspect() ) * contentSize.width() * -1.0;
|
||||||
qreal y = 0;
|
|
||||||
|
|
||||||
if( alignment().testFlag( Qt::AlignVCenter ) )
|
|
||||||
{
|
|
||||||
y = ( parentSize.height() - contentSize.height() ) / 2.0;
|
|
||||||
}
|
|
||||||
else if ( alignment().testFlag( Qt::AlignBottom ) )
|
|
||||||
{
|
|
||||||
y = ( parentSize.height() - contentSize.height() );
|
|
||||||
}
|
|
||||||
|
|
||||||
qskSetItemGeometry( m_data->contentBox,
|
qskSetItemGeometry( m_data->contentBox,
|
||||||
x, y,
|
x, 0,
|
||||||
contentSize.width(), parentSize.height() );
|
contentSize.width(), parentSize.height() );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -107,67 +83,35 @@ void QskDrawer::updateLayout() {
|
|||||||
qreal x = ( metric( faderAspect() ) * contentSize.width() )
|
qreal x = ( metric( faderAspect() ) * contentSize.width() )
|
||||||
+ parentSize.width()
|
+ parentSize.width()
|
||||||
- contentSize.width();
|
- contentSize.width();
|
||||||
qreal y = 0;
|
|
||||||
|
|
||||||
if( alignment().testFlag( Qt::AlignVCenter ) )
|
|
||||||
{
|
|
||||||
y = ( parentSize.height() - contentSize.height() ) / 2.0;
|
|
||||||
}
|
|
||||||
else if ( alignment().testFlag( Qt::AlignBottom ) )
|
|
||||||
{
|
|
||||||
y = ( parentSize.height() - contentSize.height() );
|
|
||||||
}
|
|
||||||
|
|
||||||
qskSetItemGeometry( m_data->contentBox,
|
qskSetItemGeometry( m_data->contentBox,
|
||||||
x, y,
|
x, 0,
|
||||||
contentSize.width(),
|
contentSize.width(), parentSize.height());
|
||||||
parentSize.height() );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case Qt::Edge::TopEdge:
|
case Qt::Edge::TopEdge:
|
||||||
{
|
{
|
||||||
qreal x = 0;
|
|
||||||
qreal y = metric( faderAspect() ) * contentSize.height();
|
qreal y = metric( faderAspect() ) * contentSize.height();
|
||||||
|
|
||||||
if( alignment().testFlag( Qt::AlignCenter) )
|
|
||||||
{
|
|
||||||
x = ( parentSize.width() - contentSize.width() ) / 2;
|
|
||||||
}
|
|
||||||
else if( alignment().testFlag( Qt::AlignRight) )
|
|
||||||
{
|
|
||||||
x = ( parentSize.width() - contentSize.width() );
|
|
||||||
}
|
|
||||||
|
|
||||||
qskSetItemGeometry( m_data->contentBox,
|
qskSetItemGeometry( m_data->contentBox,
|
||||||
x, -y,
|
0, -y,
|
||||||
parentSize.width(), contentSize.height() );
|
parentSize.width(), contentSize.height() );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case Qt::Edge::BottomEdge:
|
case Qt::Edge::BottomEdge:
|
||||||
{
|
{
|
||||||
qreal x = 0;
|
|
||||||
qreal y = metric( faderAspect() ) * contentSize.height() + parentSize.height() -
|
qreal y = metric( faderAspect() ) * contentSize.height() + parentSize.height() -
|
||||||
contentSize.height();
|
contentSize.height();
|
||||||
|
|
||||||
if( alignment().testFlag( Qt::AlignCenter) )
|
|
||||||
{
|
|
||||||
x = ( parentSize.width() - contentSize.width() ) / 2;
|
|
||||||
}
|
|
||||||
else if( alignment().testFlag( Qt::AlignRight) )
|
|
||||||
{
|
|
||||||
x = ( parentSize.width() - contentSize.width() );
|
|
||||||
}
|
|
||||||
|
|
||||||
qskSetItemGeometry( m_data->contentBox,
|
qskSetItemGeometry( m_data->contentBox,
|
||||||
x, y,
|
0, y,
|
||||||
parentSize.width(), contentSize.height() );
|
parentSize.width(), contentSize.height() );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
m_data->content->setGeometry( QPointF(), m_data->contentBox->size() );
|
||||||
|
|
||||||
Inherited::updateLayout();
|
Inherited::updateLayout();
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ class QSK_EXPORT QskDrawer : public QskPopup
|
|||||||
using Inherited = QskPopup;
|
using Inherited = QskPopup;
|
||||||
|
|
||||||
Q_PROPERTY( Qt::Edge edge READ edge WRITE setEdge NOTIFY edgeChanged )
|
Q_PROPERTY( Qt::Edge edge READ edge WRITE setEdge NOTIFY edgeChanged )
|
||||||
Q_PROPERTY( Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged )
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QSK_SUBCONTROLS( Panel, Overlay )
|
QSK_SUBCONTROLS( Panel, Overlay )
|
||||||
@ -18,20 +17,17 @@ class QSK_EXPORT QskDrawer : public QskPopup
|
|||||||
~QskDrawer() override;
|
~QskDrawer() override;
|
||||||
|
|
||||||
Qt::Edge edge() const;
|
Qt::Edge edge() const;
|
||||||
Qt::Alignment alignment() const;
|
|
||||||
|
|
||||||
void updateLayout() override;
|
void updateLayout() override;
|
||||||
|
|
||||||
void setContent( QskControl* t );
|
void setContent( QskControl* t );
|
||||||
void setEdge( Qt::Edge edge );
|
void setEdge( Qt::Edge edge );
|
||||||
void setAlignment( Qt::Alignment aligmnent );
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void aboutToShow() override;
|
void aboutToShow() override;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void edgeChanged( Qt::Edge );
|
void edgeChanged( Qt::Edge );
|
||||||
void alignmentChanged( Qt::Alignment );
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class PrivateData;
|
class PrivateData;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user