QskDrawer reimplemented, can be open by a swipe gesture now. more work
to do
This commit is contained in:
parent
3b5e6aa0fd
commit
5f31eb1e78
|
@ -62,7 +62,8 @@ namespace
|
||||||
Drawer( QQuickItem* parent = nullptr )
|
Drawer( QQuickItem* parent = nullptr )
|
||||||
: QskDrawer( parent )
|
: QskDrawer( parent )
|
||||||
{
|
{
|
||||||
auto box = new QskLinearBox( Qt::Vertical );
|
auto box = new QskLinearBox( Qt::Vertical, this );
|
||||||
|
|
||||||
box->setSection( QskAspect::Header );
|
box->setSection( QskAspect::Header );
|
||||||
box->setPanel( true );
|
box->setPanel( true );
|
||||||
box->setPaddingHint( QskBox::Panel, 20 );
|
box->setPaddingHint( QskBox::Panel, 20 );
|
||||||
|
@ -75,8 +76,6 @@ namespace
|
||||||
|
|
||||||
auto btn = new QskPushButton( "Close", box );
|
auto btn = new QskPushButton( "Close", box );
|
||||||
connect( btn, &QskPushButton::clicked, this, &QskDrawer::close );
|
connect( btn, &QskPushButton::clicked, this, &QskDrawer::close );
|
||||||
|
|
||||||
setContent( box );
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -606,21 +606,15 @@ void Editor::setupDialogButtonBoxColors(
|
||||||
void Editor::setupDrawerMetrics()
|
void Editor::setupDrawerMetrics()
|
||||||
{
|
{
|
||||||
using Q = QskDrawer;
|
using Q = QskDrawer;
|
||||||
|
using A = QskAspect;
|
||||||
setPadding( Q::Panel, 5 );
|
|
||||||
setHint( Q::Overlay | QskAspect::Style, false );
|
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
setAnimation( Q::Panel | QskAspect::Position, 200 );
|
setAnimation( Q::Panel | A::Metric | A::Position, 200 );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::setupDrawerColors(
|
void Editor::setupDrawerColors( QskAspect::Section, const QskFluent2Theme& )
|
||||||
QskAspect::Section section, const QskFluent2Theme& theme )
|
|
||||||
{
|
{
|
||||||
using Q = QskDrawer;
|
|
||||||
|
|
||||||
setGradient( Q::Panel | section, theme.palette.background.solid.base );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::setupFocusIndicatorMetrics()
|
void Editor::setupFocusIndicatorMetrics()
|
||||||
|
|
|
@ -809,12 +809,9 @@ void Editor::setupDialogButtonBox()
|
||||||
void Editor::setupDrawer()
|
void Editor::setupDrawer()
|
||||||
{
|
{
|
||||||
using Q = QskDrawer;
|
using Q = QskDrawer;
|
||||||
|
using A = QskAspect;
|
||||||
|
|
||||||
setPadding( Q::Panel, 5_dp );
|
setAnimation( Q::Panel | A::Metric | A::Position, qskDuration );
|
||||||
setGradient( Q::Panel, m_pal.background );
|
|
||||||
setHint( Q::Overlay | QskAspect::Style, false );
|
|
||||||
|
|
||||||
setAnimation( Q::Panel | QskAspect::Position, qskDuration );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::setupSlider()
|
void Editor::setupSlider()
|
||||||
|
|
|
@ -759,13 +759,12 @@ void Editor::setupDialogButtonBox()
|
||||||
setBoxShape( Q::Panel, 2 );
|
setBoxShape( Q::Panel, 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::setupDrawer() {
|
void Editor::setupDrawer()
|
||||||
|
{
|
||||||
|
using A = QskAspect;
|
||||||
using Q = QskDrawer;
|
using Q = QskDrawer;
|
||||||
|
|
||||||
setPadding( Q::Panel, 5 );
|
setAnimation( Q::Panel | A::Metric | A::Position, qskDuration );
|
||||||
setGradient( Q::Panel, m_pal.darker125 );
|
|
||||||
setAnimation( Q::Panel | QskAspect::Position, qskDuration );
|
|
||||||
setHint( Q::Overlay | QskAspect::Style, false );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::setupTabButton()
|
void Editor::setupTabButton()
|
||||||
|
|
|
@ -1,48 +1,258 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "QskDrawer.h"
|
#include "QskDrawer.h"
|
||||||
#include "QskAspect.h"
|
#include "QskAspect.h"
|
||||||
#include "QskControl.h"
|
#include "QskAnimationHint.h"
|
||||||
|
#include "QskQuick.h"
|
||||||
|
#include "QskEvent.h"
|
||||||
|
|
||||||
#include <QskPopup.h>
|
#include "QskPanGestureRecognizer.h"
|
||||||
#include <QskBox.h>
|
#include "QskGesture.h"
|
||||||
#include <QskAnimationHint.h>
|
|
||||||
#include <QskQuick.h>
|
|
||||||
|
|
||||||
|
#include <qguiapplication.h>
|
||||||
|
#include <qstylehints.h>
|
||||||
|
|
||||||
|
QSK_QT_PRIVATE_BEGIN
|
||||||
|
#include <private/qquickitem_p.h>
|
||||||
|
#include <private/qquickitemchangelistener_p.h>
|
||||||
|
QSK_QT_PRIVATE_END
|
||||||
|
|
||||||
|
/*
|
||||||
|
Only used for the sliding in animation. Do we want to
|
||||||
|
introduce a specific panel as background ???
|
||||||
|
*/
|
||||||
QSK_SUBCONTROL( QskDrawer, Panel )
|
QSK_SUBCONTROL( QskDrawer, Panel )
|
||||||
QSK_SUBCONTROL( QskDrawer, Overlay )
|
|
||||||
|
static void qskCatchMouseEvents( QQuickItem* item )
|
||||||
|
{
|
||||||
|
#if 1
|
||||||
|
// manipulating other items - do we really want to do this ?
|
||||||
|
item->setAcceptedMouseButtons( Qt::LeftButton );
|
||||||
|
item->setFiltersChildMouseEvents( true );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool qskCheckDirection( Qt::Edge edge, const QskPanGesture* gesture )
|
||||||
|
{
|
||||||
|
const auto degrees = gesture->angle();
|
||||||
|
|
||||||
|
switch( edge )
|
||||||
|
{
|
||||||
|
case Qt::LeftEdge:
|
||||||
|
return ( degrees < 90.0 ) || ( degrees ) > 270.0;
|
||||||
|
|
||||||
|
case Qt::RightEdge:
|
||||||
|
return ( degrees > 90.0 ) && ( degrees < 270.0 );
|
||||||
|
|
||||||
|
case Qt::TopEdge:
|
||||||
|
return degrees > 180.0;
|
||||||
|
|
||||||
|
case Qt::BottomEdge:
|
||||||
|
return degrees < 180.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void qskLayoutDrawer( const QRectF& rect, QskDrawer* drawer )
|
||||||
|
{
|
||||||
|
const auto size = qskSizeConstraint( drawer, Qt::PreferredSize );
|
||||||
|
|
||||||
|
QRectF r( 0.0, 0.0, size.width(), size.height() );
|
||||||
|
|
||||||
|
switch( drawer->edge() )
|
||||||
|
{
|
||||||
|
case Qt::LeftEdge:
|
||||||
|
{
|
||||||
|
r.setHeight( rect.height() );
|
||||||
|
r.moveRight( rect.left() + size.width() );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Qt::RightEdge:
|
||||||
|
{
|
||||||
|
r.setHeight( rect.height() );
|
||||||
|
r.moveLeft( rect.right() - size.width() );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case Qt::TopEdge:
|
||||||
|
{
|
||||||
|
r.setWidth( rect.width() );
|
||||||
|
r.moveBottom( rect.top() + size.height() );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case Qt::BottomEdge:
|
||||||
|
{
|
||||||
|
r.setWidth( rect.width() );
|
||||||
|
r.moveTop( rect.bottom() - size.height() );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
drawer->setGeometry( r );
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
class GeometryListener final : public QQuickItemChangeListener
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GeometryListener( QQuickItem* item, QQuickItem* adjustedItem )
|
||||||
|
: m_item( item )
|
||||||
|
, m_adjustedItem( adjustedItem )
|
||||||
|
{
|
||||||
|
adjust();
|
||||||
|
setEnabled( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
~GeometryListener()
|
||||||
|
{
|
||||||
|
setEnabled( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void itemGeometryChanged( QQuickItem*,
|
||||||
|
QQuickGeometryChange, const QRectF& ) override
|
||||||
|
{
|
||||||
|
adjust();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void adjust()
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
const auto pos = m_adjustedItem->mapFromItem( m_item, QPointF() );
|
||||||
|
qskSetItemGeometry( m_adjustedItem,
|
||||||
|
pos.x(), pos.y(), m_item->width(), m_item->height() );
|
||||||
|
#else
|
||||||
|
qskLayoutDrawer( QRectF( QPointF(), m_item->size() ),
|
||||||
|
qobject_cast< QskDrawer* >( m_adjustedItem ) );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void setEnabled( bool on )
|
||||||
|
{
|
||||||
|
const auto changeTypes = QQuickItemPrivate::Geometry;
|
||||||
|
|
||||||
|
auto d = QQuickItemPrivate::get( m_item );
|
||||||
|
if ( on )
|
||||||
|
d->addItemChangeListener( this, changeTypes );
|
||||||
|
else
|
||||||
|
d->removeItemChangeListener( this, changeTypes );
|
||||||
|
}
|
||||||
|
|
||||||
|
QQuickItem* m_item;
|
||||||
|
QQuickItem* m_adjustedItem;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
class GestureRecognizer : public QskPanGestureRecognizer
|
||||||
|
{
|
||||||
|
using Inherited = QskPanGestureRecognizer;
|
||||||
|
|
||||||
|
public:
|
||||||
|
GestureRecognizer( QskDrawer* drawer )
|
||||||
|
: QskPanGestureRecognizer( drawer )
|
||||||
|
{
|
||||||
|
setWatchedItem( drawer->parentItem() );
|
||||||
|
setTargetItem( drawer );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool isAcceptedPos( const QPointF& pos ) const override
|
||||||
|
{
|
||||||
|
auto drawer = qobject_cast< const QskDrawer* >( targetItem() );
|
||||||
|
|
||||||
|
const auto dragMargin = drawer->dragMargin();
|
||||||
|
if ( dragMargin <= 0.0 )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
auto rect = qskItemRect( watchedItem() );
|
||||||
|
|
||||||
|
switch( drawer->edge() )
|
||||||
|
{
|
||||||
|
case Qt::LeftEdge:
|
||||||
|
rect.setRight( rect.left() + dragMargin );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Qt::RightEdge:
|
||||||
|
rect.setLeft( rect.right() - dragMargin );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Qt::TopEdge:
|
||||||
|
rect.setBottom( rect.top() + dragMargin );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Qt::BottomEdge:
|
||||||
|
rect.setTop( rect.bottom() - dragMargin );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rect.contains( pos );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
class QskDrawer::PrivateData
|
class QskDrawer::PrivateData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QskControl* content = nullptr;
|
|
||||||
QskBox* contentBox = nullptr;
|
|
||||||
Qt::Edge edge = Qt::LeftEdge;
|
Qt::Edge edge = Qt::LeftEdge;
|
||||||
|
GestureRecognizer* gestureRecognizer = nullptr;
|
||||||
|
GeometryListener* listener = nullptr;
|
||||||
|
|
||||||
|
// a skin hint ???
|
||||||
|
qreal dragMargin = QGuiApplication::styleHints()->startDragDistance();
|
||||||
};
|
};
|
||||||
|
|
||||||
QskDrawer::QskDrawer( QQuickItem* parentItem )
|
QskDrawer::QskDrawer( QQuickItem* parentItem )
|
||||||
: Inherited ( parentItem )
|
: Inherited ( parentItem )
|
||||||
, m_data( new PrivateData )
|
, m_data( new PrivateData )
|
||||||
{
|
{
|
||||||
|
#if 1
|
||||||
setZ( 1 );
|
setZ( 1 );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
setOverlay( true );
|
||||||
|
setPolishOnResize( true );
|
||||||
|
|
||||||
setPopupFlag( PopupFlag::CloseOnPressOutside, true );
|
setPopupFlag( PopupFlag::CloseOnPressOutside, true );
|
||||||
|
setFaderAspect( Panel | QskAspect::Position | QskAspect::Metric );
|
||||||
|
|
||||||
m_data->contentBox = new QskBox(this);
|
/*
|
||||||
m_data->contentBox->setSubcontrolProxy( QskBox::Panel, Panel );
|
The drawer wants to be on top of the parent - not being
|
||||||
m_data->contentBox->setPanel( true );
|
layouted into its layoutRect(). So we opt out and do
|
||||||
|
the layout updates manually.
|
||||||
|
*/
|
||||||
|
setPlacementPolicy( QskPlacementPolicy::Ignore );
|
||||||
|
if ( parentItem )
|
||||||
|
{
|
||||||
|
m_data->listener = new GeometryListener( parentItem, this );
|
||||||
|
qskCatchMouseEvents( parentItem );
|
||||||
|
}
|
||||||
|
|
||||||
setSubcontrolProxy( Inherited::Overlay, Overlay );
|
m_data->gestureRecognizer = new GestureRecognizer( this );
|
||||||
|
|
||||||
setFaderAspect( Panel | QskAspect::Metric );
|
|
||||||
|
|
||||||
connect(this, &QskDrawer::closed, this, [this]() {
|
connect( this, &QskPopup::openChanged, this, &QskDrawer::setFading );
|
||||||
startTransition( Panel | QskAspect::Metric,
|
|
||||||
animationHint( Panel | QskAspect::Position ),
|
/*
|
||||||
0.0, 1.0 );
|
When the content of the parentItem does not fit we will have
|
||||||
});
|
a difference between fading and normal state. To overcome this problem
|
||||||
|
we need to expand the rectangle of the QQuickDefaultClipNode manually to
|
||||||
|
the window borders: TODO ...
|
||||||
|
*/
|
||||||
|
connect( this, &QskPopup::fadingChanged, parentItem, &QQuickItem::setClip );
|
||||||
}
|
}
|
||||||
|
|
||||||
QskDrawer::~QskDrawer()
|
QskDrawer::~QskDrawer()
|
||||||
{
|
{
|
||||||
|
delete m_data->listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::Edge QskDrawer::edge() const
|
Qt::Edge QskDrawer::edge() const
|
||||||
|
@ -60,79 +270,166 @@ void QskDrawer::setEdge( Qt::Edge edge )
|
||||||
edgeChanged( edge );
|
edgeChanged( edge );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskDrawer::setContent( QskControl* content )
|
void QskDrawer::setDragMargin( qreal margin )
|
||||||
{
|
{
|
||||||
content->setParentItem( m_data->contentBox );
|
margin = std::max( margin, 0.0 );
|
||||||
if ( content->parent() == nullptr )
|
|
||||||
content->setParent( m_data->contentBox );
|
|
||||||
|
|
||||||
m_data->content = content;
|
if ( margin != m_data->dragMargin )
|
||||||
|
{
|
||||||
|
m_data->dragMargin = margin;
|
||||||
|
Q_EMIT dragMarginChanged( margin );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal QskDrawer::dragMargin() const
|
||||||
|
{
|
||||||
|
return m_data->dragMargin;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QskDrawer::gestureEvent( QskGestureEvent* event )
|
||||||
|
{
|
||||||
|
if ( event->gesture()->type() == QskGesture::Pan )
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
For the moment we treat the gesture like a swipe gesture
|
||||||
|
without dragging the drawer when moving the mouse. TODO ...
|
||||||
|
*/
|
||||||
|
const auto gesture = static_cast< const QskPanGesture* >( event->gesture().get() );
|
||||||
|
if ( gesture->state() == QskGesture::Finished )
|
||||||
|
{
|
||||||
|
if ( qskCheckDirection( m_data->edge, gesture ) )
|
||||||
|
open();
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Inherited::gestureEvent( event );
|
||||||
|
}
|
||||||
|
|
||||||
|
QSizeF QskDrawer::layoutSizeHint(
|
||||||
|
Qt::SizeHint which, const QSizeF& constraint ) const
|
||||||
|
{
|
||||||
|
if ( which == Qt::MaximumSize )
|
||||||
|
return QSizeF();
|
||||||
|
|
||||||
|
qreal w = -1.0;
|
||||||
|
qreal h = -1.0;
|
||||||
|
|
||||||
|
const auto children = childItems();
|
||||||
|
|
||||||
|
for ( const auto child : children )
|
||||||
|
{
|
||||||
|
if ( !qskIsVisibleToLayout( child ) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const auto policy = qskSizePolicy( child );
|
||||||
|
|
||||||
|
if ( constraint.width() >= 0.0 && policy.isConstrained( Qt::Vertical ) )
|
||||||
|
{
|
||||||
|
const auto hint = qskSizeConstraint( child, which, constraint );
|
||||||
|
h = qMax( h, hint.height() );
|
||||||
|
}
|
||||||
|
else if ( constraint.height() >= 0.0 && policy.isConstrained( Qt::Horizontal ) )
|
||||||
|
{
|
||||||
|
const auto hint = qskSizeConstraint( child, which, constraint );
|
||||||
|
w = qMax( w, hint.width() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const auto hint = qskSizeConstraint( child, which );
|
||||||
|
|
||||||
|
w = qMax( w, hint.width() );
|
||||||
|
h = qMax( h, hint.height() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return QSizeF( w, h );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskDrawer::updateLayout()
|
void QskDrawer::updateLayout()
|
||||||
{
|
{
|
||||||
if ( !isOpen() && !isFading() )
|
if ( !( isOpen() || isFading() ) || size().isEmpty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto padding = paddingHint( Panel );
|
auto dx = 0.0;
|
||||||
|
auto dy = 0.0;
|
||||||
|
|
||||||
auto contentSize = m_data->content->preferredSize();
|
if ( isFading() )
|
||||||
contentSize = contentSize.grownBy( padding );
|
|
||||||
|
|
||||||
const auto parentSize = parentItem()->size();
|
|
||||||
|
|
||||||
switch( m_data->edge )
|
|
||||||
{
|
{
|
||||||
case Qt::Edge::LeftEdge:
|
const auto f = metric( faderAspect() );
|
||||||
|
|
||||||
|
switch( m_data->edge )
|
||||||
{
|
{
|
||||||
qreal x = metric( faderAspect() ) * contentSize.width() * -1.0;
|
case Qt::LeftEdge:
|
||||||
|
dx = -f * width();
|
||||||
|
break;
|
||||||
|
|
||||||
qskSetItemGeometry( m_data->contentBox,
|
case Qt::RightEdge:
|
||||||
x, 0, contentSize.width(), parentSize.height() );
|
dx = f * width();
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case Qt::Edge::RightEdge:
|
|
||||||
{
|
|
||||||
qreal x = ( metric( faderAspect() ) * contentSize.width() )
|
|
||||||
+ parentSize.width() - contentSize.width();
|
|
||||||
|
|
||||||
qskSetItemGeometry( m_data->contentBox,
|
case Qt::TopEdge:
|
||||||
x, 0, contentSize.width(), parentSize.height() );
|
dy = -f * height();
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case Qt::Edge::TopEdge:
|
case Qt::BottomEdge:
|
||||||
{
|
dy = f * height();
|
||||||
qreal y = metric( faderAspect() ) * contentSize.height();
|
break;
|
||||||
|
|
||||||
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() ),
|
const QRectF layoutRect( dx, dy, width(), height() );
|
||||||
m_data->contentBox->size().shrunkBy( padding ) );
|
|
||||||
|
|
||||||
Inherited::updateLayout();
|
const auto children = childItems();
|
||||||
|
for ( auto child : children )
|
||||||
|
{
|
||||||
|
if ( qskIsAdjustableByLayout( child ) )
|
||||||
|
{
|
||||||
|
const auto r = qskConstrainedItemRect( child, layoutRect );
|
||||||
|
qskSetItemGeometry( child, r );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskDrawer::aboutToShow()
|
void QskDrawer::itemChange( QQuickItem::ItemChange change,
|
||||||
|
const QQuickItem::ItemChangeData& value )
|
||||||
{
|
{
|
||||||
startTransition( Panel | QskAspect::Metric,
|
Inherited::itemChange( change, value );
|
||||||
animationHint( Panel | QskAspect::Position ), 1.0, 0.0 );
|
|
||||||
|
|
||||||
Inherited::aboutToShow();
|
switch( static_cast< int >( change ) )
|
||||||
|
{
|
||||||
|
case QQuickItem::ItemParentHasChanged:
|
||||||
|
{
|
||||||
|
if ( parentItem() )
|
||||||
|
qskCatchMouseEvents( parentItem() );
|
||||||
|
|
||||||
|
Q_FALLTHROUGH();
|
||||||
|
}
|
||||||
|
case QQuickItem::ItemVisibleHasChanged:
|
||||||
|
{
|
||||||
|
delete m_data->listener;
|
||||||
|
m_data->listener = nullptr;
|
||||||
|
|
||||||
|
if ( parentItem() && isVisible() )
|
||||||
|
m_data->listener = new GeometryListener( parentItem(), this );
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QskDrawer::setFading( bool on )
|
||||||
|
{
|
||||||
|
const qreal from = on ? 1.0 : 0.0;
|
||||||
|
const qreal to = on ? 0.0 : 1.0;
|
||||||
|
|
||||||
|
const auto aspect = faderAspect();
|
||||||
|
|
||||||
|
auto hint = animationHint( aspect );
|
||||||
|
hint.updateFlags = QskAnimationHint::UpdatePolish | QskAnimationHint::UpdateNode;
|
||||||
|
|
||||||
|
startTransition( aspect, hint, from, to );
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "moc_QskDrawer.cpp"
|
#include "moc_QskDrawer.cpp"
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifndef QSK_DRAWER_H
|
#ifndef QSK_DRAWER_H
|
||||||
#define QSK_DRAWER_H
|
#define QSK_DRAWER_H
|
||||||
|
|
||||||
|
@ -12,8 +17,11 @@ class QSK_EXPORT QskDrawer : public 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( qreal dragMargin READ dragMargin
|
||||||
|
WRITE setDragMargin NOTIFY dragMarginChanged )
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QSK_SUBCONTROLS( Panel, Overlay )
|
QSK_SUBCONTROLS( Panel )
|
||||||
|
|
||||||
QskDrawer( QQuickItem* = nullptr );
|
QskDrawer( QQuickItem* = nullptr );
|
||||||
~QskDrawer() override;
|
~QskDrawer() override;
|
||||||
|
@ -21,17 +29,24 @@ class QSK_EXPORT QskDrawer : public QskPopup
|
||||||
void setEdge( Qt::Edge );
|
void setEdge( Qt::Edge );
|
||||||
Qt::Edge edge() const;
|
Qt::Edge edge() const;
|
||||||
|
|
||||||
void updateLayout() override;
|
void setDragMargin( qreal );
|
||||||
|
qreal dragMargin() const;
|
||||||
|
|
||||||
void setContent( QskControl* );
|
void updateLayout() override;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void edgeChanged( Qt::Edge );
|
void edgeChanged( Qt::Edge );
|
||||||
|
void dragMarginChanged( qreal );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void aboutToShow() override;
|
void itemChange( ItemChange, const ItemChangeData& ) override;
|
||||||
|
|
||||||
|
QSizeF layoutSizeHint( Qt::SizeHint, const QSizeF& ) const override;
|
||||||
|
void gestureEvent( QskGestureEvent* ) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void setFading( bool );
|
||||||
|
|
||||||
class PrivateData;
|
class PrivateData;
|
||||||
std::unique_ptr< PrivateData > m_data;
|
std::unique_ptr< PrivateData > m_data;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue