Add QskDrawer
This commit is contained in:
parent
ffe4e11b21
commit
2e44c07a06
|
@ -340,6 +340,7 @@ 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
|
||||||
|
@ -358,6 +359,7 @@ 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,118 @@
|
||||||
|
#include "QskDrawer.h"
|
||||||
|
#include "QskAnimationHint.h"
|
||||||
|
#include "QskAspect.h"
|
||||||
|
#include "QskControl.h"
|
||||||
|
#include "QskPopup.h"
|
||||||
|
#include "QskBox.h"
|
||||||
|
#include <algorithm>
|
||||||
|
#include <qnamespace.h>
|
||||||
|
#include <qquickitem.h>
|
||||||
|
#include <QskQuick.h>
|
||||||
|
|
||||||
|
#include <QskSkinlet.h>
|
||||||
|
#include <QskSkin.h>
|
||||||
|
#include <QskWindow.h>
|
||||||
|
#include <qsize.h>
|
||||||
|
|
||||||
|
QSK_SUBCONTROL( QskDrawer, DasPanel )
|
||||||
|
|
||||||
|
class QskDrawer::PrivateData {
|
||||||
|
public:
|
||||||
|
QskControl* control = nullptr;
|
||||||
|
QskBox* content;
|
||||||
|
Qt::Edge edge = Qt::LeftEdge;
|
||||||
|
};
|
||||||
|
|
||||||
|
QskDrawer::QskDrawer( QQuickItem* parentItem ) :
|
||||||
|
Inherited ( parentItem )
|
||||||
|
, m_data( new PrivateData { } )
|
||||||
|
{
|
||||||
|
using Q = QskDrawer;
|
||||||
|
setZ( 1 );
|
||||||
|
|
||||||
|
setPolishOnResize( true );
|
||||||
|
this->setPopupFlags( PopupFlag::CloseOnPressOutside );
|
||||||
|
setPopupFlag( PopupFlag::CloseOnPressOutside, true );
|
||||||
|
|
||||||
|
m_data->content = new QskBox(this);
|
||||||
|
m_data->content->setSubcontrolProxy( QskBox::Panel, QskDrawer::DasPanel );
|
||||||
|
m_data->content->setClip( true );
|
||||||
|
|
||||||
|
setAnimationHint( QskDrawer::DasPanel | QskAspect::Metric, QskAnimationHint(300) );
|
||||||
|
setModal( false );
|
||||||
|
setFaderAspect( QskDrawer::DasPanel | QskAspect::Metric );
|
||||||
|
setMetric( DasPanel, 0.1);
|
||||||
|
setFaderAspect( DasPanel | QskAspect::Metric );
|
||||||
|
|
||||||
|
setSkinHint( Q::Overlay | QskAspect::Style, false );
|
||||||
|
|
||||||
|
initSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed );
|
||||||
|
}
|
||||||
|
|
||||||
|
QskDrawer::~QskDrawer()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::Edge QskDrawer::edge() const {
|
||||||
|
return m_data->edge;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QskDrawer::setEdge( Qt::Edge edge ) {
|
||||||
|
if( m_data->edge == edge ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_data->edge = edge;
|
||||||
|
edgeChanged( edge );
|
||||||
|
}
|
||||||
|
|
||||||
|
void QskDrawer::setContent( QskControl* t ) {
|
||||||
|
m_data->control = t;
|
||||||
|
t->setParentItem( m_data->content );
|
||||||
|
// polish();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QskDrawer::updateLayout() {
|
||||||
|
if( !m_data->control ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto rect = parentItem()->childrenRect();
|
||||||
|
rect.setSize( {200, 400} ); //m_data->content->preferredSize() );
|
||||||
|
|
||||||
|
switch( m_data->edge ) {
|
||||||
|
case Qt::Edge::LeftEdge:
|
||||||
|
case Qt::Edge::RightEdge:
|
||||||
|
// rect.setWidth( m_data->control->preferredSize().width() );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Qt::Edge::TopEdge:
|
||||||
|
case Qt::Edge::BottomEdge:
|
||||||
|
// rect.setHeight( m_data->control->preferredSize().height() );
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
auto size = rect.size();
|
||||||
|
qreal off = metric( faderAspect() ) * size.width();
|
||||||
|
|
||||||
|
qskSetItemGeometry( m_data->content, -off, 0, size.width(), size.height());
|
||||||
|
|
||||||
|
m_data->content->polish();
|
||||||
|
|
||||||
|
Inherited::updateLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
QSizeF QskDrawer::contentsSizeHint( Qt::SizeHint, const QSizeF& ) const {
|
||||||
|
return {200, 200};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QskDrawer::aboutToShow()
|
||||||
|
{
|
||||||
|
startTransition( DasPanel | QskAspect::Metric, QskAnimationHint(2000), 1.0, .0 );
|
||||||
|
Inherited::aboutToShow();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include "moc_QskDrawer.cpp"
|
|
@ -0,0 +1,43 @@
|
||||||
|
#include "QskGlobal.h"
|
||||||
|
#include "QskPopup.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <qnamespace.h>
|
||||||
|
#include <qobjectdefs.h>
|
||||||
|
|
||||||
|
#ifndef QSK_DRAWER_H
|
||||||
|
#define QSK_DRAWER_H
|
||||||
|
|
||||||
|
class QSK_EXPORT QskDrawer : public QskPopup
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
using Inherited = QskPopup;
|
||||||
|
|
||||||
|
Q_PROPERTY( Qt::Edge edge READ edge WRITE setEdge NOTIFY edgeChanged )
|
||||||
|
|
||||||
|
public:
|
||||||
|
QSK_SUBCONTROLS( DasPanel )
|
||||||
|
QskDrawer( QQuickItem* parentItem = nullptr );
|
||||||
|
~QskDrawer() override;
|
||||||
|
|
||||||
|
Qt::Edge edge() const;
|
||||||
|
|
||||||
|
void updateLayout() override;
|
||||||
|
|
||||||
|
void setContent( QskControl* t );
|
||||||
|
void setEdge( Qt::Edge edge );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void aboutToShow() override;
|
||||||
|
QSizeF contentsSizeHint( Qt::SizeHint, const QSizeF& ) const override;
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void edgeChanged( Qt::Edge );
|
||||||
|
|
||||||
|
private:
|
||||||
|
class PrivateData;
|
||||||
|
std::unique_ptr< PrivateData > m_data;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue