minor updates for QskDrawer
This commit is contained in:
parent
87bfa8611f
commit
2980fc91e3
|
@ -55,6 +55,30 @@ namespace
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Drawer : public QskDrawer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Drawer( QQuickItem* parent = nullptr )
|
||||||
|
: QskDrawer( parent )
|
||||||
|
{
|
||||||
|
auto box = new QskLinearBox( Qt::Vertical );
|
||||||
|
box->setSection( QskAspect::Header );
|
||||||
|
box->setPanel( true );
|
||||||
|
box->setPaddingHint( QskBox::Panel, 20 );
|
||||||
|
|
||||||
|
new QskPushButton( "One", box );
|
||||||
|
new QskPushButton( "Two", box );
|
||||||
|
new QskPushButton( "Three", box );
|
||||||
|
|
||||||
|
box->addStretch( 1 );
|
||||||
|
|
||||||
|
auto btn = new QskPushButton( "Close", box );
|
||||||
|
connect( btn, &QskPushButton::clicked, this, &QskDrawer::close );
|
||||||
|
|
||||||
|
setContent( box );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class TabView : public QskTabView
|
class TabView : public QskTabView
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -213,28 +237,14 @@ namespace
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
QskDrawer* drawer = new QskDrawer( this->parentItem() );
|
auto drawer = new Drawer( parentItem() );
|
||||||
drawer->setEdge( Qt::RightEdge );
|
drawer->setEdge( Qt::RightEdge );
|
||||||
|
|
||||||
auto o = new QskLinearBox( Qt::Vertical );
|
|
||||||
|
|
||||||
auto c = new QskLinearBox( Qt::Vertical, o );
|
|
||||||
new QskPushButton( "One", c );
|
|
||||||
new QskPushButton( "Two", c );
|
|
||||||
new QskPushButton( "Three", c );
|
|
||||||
|
|
||||||
c->setExtraSpacingAt( Qt::BottomEdge );
|
|
||||||
|
|
||||||
auto close = new QskPushButton( "Close", o );
|
|
||||||
connect( close, &QskPushButton::clicked,
|
|
||||||
drawer, &QskDrawer::close );
|
|
||||||
|
|
||||||
drawer->setContent( o );
|
|
||||||
|
|
||||||
auto burger = new QskPushButton( "≡", this );
|
auto burger = new QskPushButton( "≡", this );
|
||||||
burger->setEmphasis( QskPushButton::LowEmphasis );
|
burger->setEmphasis( QskPushButton::LowEmphasis );
|
||||||
|
|
||||||
connect( burger, &QskPushButton::clicked,
|
connect( burger, &QskPushButton::clicked,
|
||||||
this, [drawer]() { drawer->open(); });
|
drawer, &QskPopup::open );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -169,6 +169,7 @@ list(APPEND HEADERS
|
||||||
controls/QskComboBox.h
|
controls/QskComboBox.h
|
||||||
controls/QskComboBoxSkinlet.h
|
controls/QskComboBoxSkinlet.h
|
||||||
controls/QskControl.h
|
controls/QskControl.h
|
||||||
|
controls/QskDrawer.h
|
||||||
controls/QskEvent.h
|
controls/QskEvent.h
|
||||||
controls/QskFlickAnimator.h
|
controls/QskFlickAnimator.h
|
||||||
controls/QskFocusIndicator.h
|
controls/QskFocusIndicator.h
|
||||||
|
@ -266,6 +267,7 @@ list(APPEND SOURCES
|
||||||
controls/QskControl.cpp
|
controls/QskControl.cpp
|
||||||
controls/QskControlPrivate.cpp
|
controls/QskControlPrivate.cpp
|
||||||
controls/QskDirtyItemFilter.cpp
|
controls/QskDirtyItemFilter.cpp
|
||||||
|
controls/QskDrawer.cpp
|
||||||
controls/QskEvent.cpp
|
controls/QskEvent.cpp
|
||||||
controls/QskFlickAnimator.cpp
|
controls/QskFlickAnimator.cpp
|
||||||
controls/QskFocusIndicator.cpp
|
controls/QskFocusIndicator.cpp
|
||||||
|
@ -340,7 +342,6 @@ list(APPEND SOURCES
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND HEADERS
|
list(APPEND HEADERS
|
||||||
layouts/QskDrawer.h
|
|
||||||
layouts/QskGridBox.h
|
layouts/QskGridBox.h
|
||||||
layouts/QskGridLayoutEngine.h
|
layouts/QskGridLayoutEngine.h
|
||||||
layouts/QskIndexedLayoutBox.h
|
layouts/QskIndexedLayoutBox.h
|
||||||
|
@ -359,7 +360,6 @@ list(APPEND PRIVATE_HEADERS
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND SOURCES
|
list(APPEND SOURCES
|
||||||
layouts/QskDrawer.cpp
|
|
||||||
layouts/QskGridBox.cpp
|
layouts/QskGridBox.cpp
|
||||||
layouts/QskGridLayoutEngine.cpp
|
layouts/QskGridLayoutEngine.cpp
|
||||||
layouts/QskIndexedLayoutBox.cpp
|
layouts/QskIndexedLayoutBox.cpp
|
||||||
|
|
|
@ -0,0 +1,135 @@
|
||||||
|
#include "QskDrawer.h"
|
||||||
|
#include "QskAspect.h"
|
||||||
|
#include "QskControl.h"
|
||||||
|
|
||||||
|
#include <QskPopup.h>
|
||||||
|
#include <QskBox.h>
|
||||||
|
#include <QskAnimationHint.h>
|
||||||
|
#include <QskQuick.h>
|
||||||
|
|
||||||
|
QSK_SUBCONTROL( QskDrawer, Panel )
|
||||||
|
QSK_SUBCONTROL( QskDrawer, Overlay )
|
||||||
|
|
||||||
|
class QskDrawer::PrivateData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QskControl* content = nullptr;
|
||||||
|
QskBox* contentBox = nullptr;
|
||||||
|
Qt::Edge edge = Qt::LeftEdge;
|
||||||
|
};
|
||||||
|
|
||||||
|
QskDrawer::QskDrawer( QQuickItem* parentItem )
|
||||||
|
: Inherited ( parentItem )
|
||||||
|
, m_data( new PrivateData )
|
||||||
|
{
|
||||||
|
setZ( 1 );
|
||||||
|
|
||||||
|
setPopupFlag( PopupFlag::CloseOnPressOutside, true );
|
||||||
|
|
||||||
|
m_data->contentBox = new QskBox(this);
|
||||||
|
m_data->contentBox->setSubcontrolProxy( QskBox::Panel, Panel );
|
||||||
|
m_data->contentBox->setPanel( true );
|
||||||
|
|
||||||
|
setSubcontrolProxy( Inherited::Overlay, Overlay );
|
||||||
|
|
||||||
|
setFaderAspect( Panel | QskAspect::Metric );
|
||||||
|
|
||||||
|
connect(this, &QskDrawer::closed, this, [this]() {
|
||||||
|
startTransition( Panel | QskAspect::Metric,
|
||||||
|
animationHint( Panel | QskAspect::Position ),
|
||||||
|
0.0, 1.0 );
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
QskDrawer::~QskDrawer()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::Edge QskDrawer::edge() const
|
||||||
|
{
|
||||||
|
return m_data->edge;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QskDrawer::setEdge( Qt::Edge edge )
|
||||||
|
{
|
||||||
|
if( m_data->edge == edge )
|
||||||
|
return;
|
||||||
|
|
||||||
|
update();
|
||||||
|
m_data->edge = edge;
|
||||||
|
edgeChanged( edge );
|
||||||
|
}
|
||||||
|
|
||||||
|
void QskDrawer::setContent( QskControl* content )
|
||||||
|
{
|
||||||
|
content->setParentItem( m_data->contentBox );
|
||||||
|
m_data->content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QskDrawer::updateLayout()
|
||||||
|
{
|
||||||
|
if ( !isOpen() && !isFading() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
const auto padding = paddingHint( Panel );
|
||||||
|
|
||||||
|
auto contentSize = m_data->content->preferredSize();
|
||||||
|
contentSize = contentSize.grownBy( padding );
|
||||||
|
|
||||||
|
const auto parentSize = parentItem()->size();
|
||||||
|
|
||||||
|
switch( m_data->edge )
|
||||||
|
{
|
||||||
|
case Qt::Edge::LeftEdge:
|
||||||
|
{
|
||||||
|
qreal x = metric( faderAspect() ) * contentSize.width() * -1.0;
|
||||||
|
|
||||||
|
qskSetItemGeometry( m_data->contentBox,
|
||||||
|
x, 0, contentSize.width(), parentSize.height() );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Qt::Edge::RightEdge:
|
||||||
|
{
|
||||||
|
qreal x = ( metric( faderAspect() ) * contentSize.width() )
|
||||||
|
+ parentSize.width() - contentSize.width();
|
||||||
|
|
||||||
|
qskSetItemGeometry( m_data->contentBox,
|
||||||
|
x, 0, contentSize.width(), parentSize.height() );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case Qt::Edge::TopEdge:
|
||||||
|
{
|
||||||
|
qreal y = metric( faderAspect() ) * contentSize.height();
|
||||||
|
|
||||||
|
qskSetItemGeometry( m_data->contentBox,
|
||||||
|
0, -y, parentSize.width(), contentSize.height() );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case Qt::Edge::BottomEdge:
|
||||||
|
{
|
||||||
|
qreal y = metric( faderAspect() ) * contentSize.height() + parentSize.height() -
|
||||||
|
contentSize.height();
|
||||||
|
|
||||||
|
qskSetItemGeometry( m_data->contentBox,
|
||||||
|
0, y, parentSize.width(), contentSize.height() );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_data->content->setGeometry( QPointF( padding.left(), padding.top() ),
|
||||||
|
m_data->contentBox->size().shrunkBy( padding ) );
|
||||||
|
|
||||||
|
Inherited::updateLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QskDrawer::aboutToShow()
|
||||||
|
{
|
||||||
|
startTransition( Panel | QskAspect::Metric,
|
||||||
|
animationHint( Panel | QskAspect::Position ), 1.0, 0.0 );
|
||||||
|
|
||||||
|
Inherited::aboutToShow();
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "moc_QskDrawer.cpp"
|
|
@ -1,8 +1,9 @@
|
||||||
#include "QskPopup.h"
|
|
||||||
|
|
||||||
#ifndef QSK_DRAWER_H
|
#ifndef QSK_DRAWER_H
|
||||||
#define QSK_DRAWER_H
|
#define QSK_DRAWER_H
|
||||||
|
|
||||||
|
#include "QskPopup.h"
|
||||||
|
#include <qnamespace.h>
|
||||||
|
|
||||||
class QSK_EXPORT QskDrawer : public QskPopup
|
class QSK_EXPORT QskDrawer : public QskPopup
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -13,22 +14,23 @@ class QSK_EXPORT QskDrawer : public QskPopup
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QSK_SUBCONTROLS( Panel, Overlay )
|
QSK_SUBCONTROLS( Panel, Overlay )
|
||||||
|
|
||||||
QskDrawer( QQuickItem* parentItem = nullptr );
|
QskDrawer( QQuickItem* parentItem = nullptr );
|
||||||
~QskDrawer() override;
|
~QskDrawer() override;
|
||||||
|
|
||||||
|
void setEdge( Qt::Edge edge );
|
||||||
Qt::Edge edge() const;
|
Qt::Edge edge() const;
|
||||||
|
|
||||||
void updateLayout() override;
|
void updateLayout() override;
|
||||||
|
|
||||||
void setContent( QskControl* t );
|
void setContent( QskControl* t );
|
||||||
void setEdge( Qt::Edge edge );
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void aboutToShow() override;
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void edgeChanged( Qt::Edge );
|
void edgeChanged( Qt::Edge );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void aboutToShow() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class PrivateData;
|
class PrivateData;
|
||||||
std::unique_ptr< PrivateData > m_data;
|
std::unique_ptr< PrivateData > m_data;
|
|
@ -1,130 +0,0 @@
|
||||||
#include "QskDrawer.h"
|
|
||||||
#include "QskAspect.h"
|
|
||||||
#include "QskControl.h"
|
|
||||||
|
|
||||||
#include <QskPopup.h>
|
|
||||||
#include <QskBox.h>
|
|
||||||
#include <QskAnimationHint.h>
|
|
||||||
#include <QskQuick.h>
|
|
||||||
|
|
||||||
QSK_SUBCONTROL( QskDrawer, Panel )
|
|
||||||
QSK_SUBCONTROL( QskDrawer, Overlay )
|
|
||||||
|
|
||||||
class QskDrawer::PrivateData {
|
|
||||||
public:
|
|
||||||
QskControl* content;
|
|
||||||
QskBox* contentBox;
|
|
||||||
Qt::Edge edge = Qt::LeftEdge;
|
|
||||||
};
|
|
||||||
|
|
||||||
QskDrawer::QskDrawer( QQuickItem* parentItem ):
|
|
||||||
Inherited ( parentItem )
|
|
||||||
, m_data( new PrivateData { } )
|
|
||||||
{
|
|
||||||
setZ( 1 );
|
|
||||||
|
|
||||||
setPopupFlag( PopupFlag::CloseOnPressOutside, true );
|
|
||||||
|
|
||||||
m_data->contentBox = new QskBox(this);
|
|
||||||
m_data->contentBox->setSubcontrolProxy( QskBox::Panel, Panel );
|
|
||||||
m_data->contentBox->setPanel( true );
|
|
||||||
|
|
||||||
setSubcontrolProxy( Inherited::Overlay, Overlay );
|
|
||||||
|
|
||||||
setFaderAspect( Panel | QskAspect::Metric );
|
|
||||||
|
|
||||||
connect(this, &QskDrawer::closed, this, [this]() {
|
|
||||||
startTransition( Panel | QskAspect::Metric,
|
|
||||||
animationHint( Panel | QskAspect::Position ),
|
|
||||||
0.0, 1.0 );
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
QskDrawer::~QskDrawer()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Qt::Edge QskDrawer::edge() const {
|
|
||||||
return m_data->edge;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QskDrawer::setEdge( Qt::Edge edge ) {
|
|
||||||
if( m_data->edge == edge )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
update();
|
|
||||||
m_data->edge = edge;
|
|
||||||
edgeChanged( edge );
|
|
||||||
}
|
|
||||||
|
|
||||||
void QskDrawer::setContent( QskControl* content ) {
|
|
||||||
content->setParentItem( m_data->contentBox );
|
|
||||||
m_data->content = content;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QskDrawer::updateLayout() {
|
|
||||||
const auto& padding = paddingHint( Panel );
|
|
||||||
const auto& contentSize = m_data->content->preferredSize()
|
|
||||||
.grownBy( padding );
|
|
||||||
const auto& parentSize = parentItem()->size();
|
|
||||||
|
|
||||||
switch( m_data->edge ) {
|
|
||||||
case Qt::Edge::LeftEdge:
|
|
||||||
{
|
|
||||||
qreal x = metric( faderAspect() ) * contentSize.width() * -1.0;
|
|
||||||
|
|
||||||
qskSetItemGeometry( m_data->contentBox,
|
|
||||||
x, 0,
|
|
||||||
contentSize.width(), parentSize.height() );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Qt::Edge::RightEdge:
|
|
||||||
{
|
|
||||||
qreal x = ( metric( faderAspect() ) * contentSize.width() )
|
|
||||||
+ parentSize.width()
|
|
||||||
- contentSize.width();
|
|
||||||
|
|
||||||
qskSetItemGeometry( m_data->contentBox,
|
|
||||||
x, 0,
|
|
||||||
contentSize.width(), parentSize.height() );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case Qt::Edge::TopEdge:
|
|
||||||
{
|
|
||||||
qreal y = metric( faderAspect() ) * contentSize.height();
|
|
||||||
|
|
||||||
qskSetItemGeometry( m_data->contentBox,
|
|
||||||
0, -y,
|
|
||||||
parentSize.width(), contentSize.height() );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case Qt::Edge::BottomEdge:
|
|
||||||
{
|
|
||||||
qreal y = metric( faderAspect() ) * contentSize.height() + parentSize.height() -
|
|
||||||
contentSize.height();
|
|
||||||
|
|
||||||
qskSetItemGeometry( m_data->contentBox,
|
|
||||||
0, y,
|
|
||||||
parentSize.width(), contentSize.height() );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_data->content->setGeometry( QPointF( padding.left(), padding.top() ),
|
|
||||||
m_data->contentBox->size().shrunkBy( padding ) );
|
|
||||||
|
|
||||||
Inherited::updateLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QskDrawer::aboutToShow()
|
|
||||||
{
|
|
||||||
startTransition( Panel | QskAspect::Metric,
|
|
||||||
animationHint( Panel | QskAspect::Position ),
|
|
||||||
1.0, 0.0 );
|
|
||||||
Inherited::aboutToShow();
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "moc_QskDrawer.cpp"
|
|
Loading…
Reference in New Issue