internal QskBox eliminated
This commit is contained in:
parent
7294d5a01e
commit
1132c7f878
|
@ -1,11 +1,12 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* 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 <QskPopup.h>
|
|
||||||
#include <QskBox.h>
|
|
||||||
#include <QskAnimationHint.h>
|
|
||||||
#include <QskQuick.h>
|
|
||||||
|
|
||||||
QSK_QT_PRIVATE_BEGIN
|
QSK_QT_PRIVATE_BEGIN
|
||||||
#include <private/qquickitem_p.h>
|
#include <private/qquickitem_p.h>
|
||||||
|
@ -76,32 +77,12 @@ namespace
|
||||||
private:
|
private:
|
||||||
QskDrawer* m_drawer = nullptr;
|
QskDrawer* m_drawer = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Box : public QskBox
|
|
||||||
{
|
|
||||||
using Inherited = QskBox;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Box( QskDrawer* drawer )
|
|
||||||
: QskBox( drawer )
|
|
||||||
{
|
|
||||||
setSubcontrolProxy( QskBox::Panel, Panel );
|
|
||||||
setPanel( true );
|
|
||||||
setAutoLayoutChildren( true );
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
setBackgroundColor( Qt::darkCyan );
|
|
||||||
setMargins( 20 );
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class QskDrawer::PrivateData
|
class QskDrawer::PrivateData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QskControl* content = nullptr;
|
QskControl* content = nullptr;
|
||||||
Box* contentBox = nullptr;
|
|
||||||
Qt::Edge edge = Qt::LeftEdge;
|
Qt::Edge edge = Qt::LeftEdge;
|
||||||
|
|
||||||
GeometryListener* listener = nullptr;
|
GeometryListener* listener = nullptr;
|
||||||
|
@ -115,8 +96,6 @@ QskDrawer::QskDrawer( QQuickItem* parentItem )
|
||||||
|
|
||||||
setPopupFlag( PopupFlag::CloseOnPressOutside, true );
|
setPopupFlag( PopupFlag::CloseOnPressOutside, true );
|
||||||
|
|
||||||
m_data->contentBox = new Box(this);
|
|
||||||
|
|
||||||
setSubcontrolProxy( Inherited::Overlay, Overlay );
|
setSubcontrolProxy( Inherited::Overlay, Overlay );
|
||||||
|
|
||||||
setFaderAspect( Panel | QskAspect::Position | QskAspect::Metric );
|
setFaderAspect( Panel | QskAspect::Position | QskAspect::Metric );
|
||||||
|
@ -156,18 +135,36 @@ void QskDrawer::setEdge( Qt::Edge edge )
|
||||||
|
|
||||||
void QskDrawer::setContent( QskControl* content )
|
void QskDrawer::setContent( QskControl* content )
|
||||||
{
|
{
|
||||||
content->setParentItem( m_data->contentBox );
|
if ( content == m_data->content )
|
||||||
if ( content->parent() == nullptr )
|
return;
|
||||||
content->setParent( m_data->contentBox );
|
|
||||||
|
if ( m_data->content )
|
||||||
|
{
|
||||||
|
if ( m_data->content->parent() == this )
|
||||||
|
delete m_data->content;
|
||||||
|
else
|
||||||
|
m_data->content->setParentItem( nullptr );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( content )
|
||||||
|
{
|
||||||
|
content->setParentItem( this );
|
||||||
|
if ( content->parent() == nullptr )
|
||||||
|
content->setParent( this );
|
||||||
|
}
|
||||||
|
|
||||||
m_data->content = content;
|
m_data->content = content;
|
||||||
|
polish();
|
||||||
}
|
}
|
||||||
|
|
||||||
QSizeF QskDrawer::layoutSizeHint(
|
QSizeF QskDrawer::layoutSizeHint(
|
||||||
Qt::SizeHint which, const QSizeF& constraint ) const
|
Qt::SizeHint which, const QSizeF& constraint ) const
|
||||||
{
|
{
|
||||||
// we need to handle QEvent::LayoutRequest
|
// we need to handle QEvent::LayoutRequest
|
||||||
return m_data->contentBox->effectiveSizeHint( which, constraint );
|
if ( m_data->content )
|
||||||
|
return m_data->content->effectiveSizeHint( which, constraint );
|
||||||
|
|
||||||
|
return Inherited::layoutSizeHint( which, constraint );
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF QskDrawer::layoutRectForSize( const QSizeF& size ) const
|
QRectF QskDrawer::layoutRectForSize( const QSizeF& size ) const
|
||||||
|
@ -180,13 +177,16 @@ void QskDrawer::updateLayout()
|
||||||
if ( !( isOpen() || isFading() ) )
|
if ( !( isOpen() || isFading() ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if ( m_data->content == nullptr )
|
||||||
|
return;
|
||||||
|
|
||||||
const auto targetRect = qskItemRect( parentItem() );
|
const auto targetRect = qskItemRect( parentItem() );
|
||||||
const auto size = qskConstrainedItemSize( this, targetRect.size() );
|
const auto size = qskConstrainedItemSize( this, targetRect.size() );
|
||||||
|
|
||||||
const auto rect = qskDrawerRect( targetRect,
|
const auto rect = qskDrawerRect( targetRect,
|
||||||
m_data->edge, metric( faderAspect() ), size );
|
m_data->edge, metric( faderAspect() ), size );
|
||||||
|
|
||||||
qskSetItemGeometry( m_data->contentBox, rect );
|
qskSetItemGeometry( m_data->content, rect );
|
||||||
Inherited::updateLayout();
|
Inherited::updateLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue