2019-09-04 06:59:43 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
|
|
|
* This file may be used under the terms of the QSkinny License, Version 1.0
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef QSK_QUICK_ITEM_H
|
|
|
|
#define QSK_QUICK_ITEM_H
|
|
|
|
|
|
|
|
#include "QskGlobal.h"
|
|
|
|
#include <qquickitem.h>
|
|
|
|
|
|
|
|
class QskQuickItemPrivate;
|
|
|
|
class QskGeometryChangeEvent;
|
|
|
|
class QskWindowChangeEvent;
|
|
|
|
|
|
|
|
class QSK_EXPORT QskQuickItem : public QQuickItem
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
Q_PROPERTY( QRectF geometry READ geometry WRITE setGeometry )
|
|
|
|
|
|
|
|
Q_PROPERTY( bool transparentForPositioners READ isTransparentForPositioner
|
|
|
|
WRITE setTransparentForPositioner NOTIFY itemFlagsChanged )
|
|
|
|
|
|
|
|
Q_PROPERTY( bool tabFence READ isTabFence
|
|
|
|
WRITE setTabFence NOTIFY itemFlagsChanged )
|
|
|
|
|
|
|
|
Q_PROPERTY( bool polishOnResize READ polishOnResize
|
|
|
|
WRITE setPolishOnResize NOTIFY itemFlagsChanged FINAL )
|
|
|
|
|
|
|
|
using Inherited = QQuickItem;
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum Flag
|
|
|
|
{
|
|
|
|
DeferredUpdate = 1 << 0,
|
|
|
|
DeferredPolish = 1 << 1,
|
|
|
|
DeferredLayout = 1 << 2,
|
|
|
|
CleanupOnVisibility = 1 << 3,
|
|
|
|
|
|
|
|
PreferRasterForTextures = 1 << 4,
|
|
|
|
|
|
|
|
DebugForceBackground = 1 << 7,
|
|
|
|
|
|
|
|
LastFlag = DebugForceBackground
|
|
|
|
};
|
|
|
|
|
|
|
|
Q_ENUM( Flag )
|
|
|
|
Q_DECLARE_FLAGS( Flags, Flag )
|
|
|
|
|
|
|
|
~QskQuickItem() override;
|
|
|
|
|
|
|
|
const char* className() const;
|
|
|
|
|
|
|
|
bool isVisibleTo( const QQuickItem* ) const;
|
2019-09-06 19:56:03 +02:00
|
|
|
bool isVisibleToParent() const;
|
2019-09-04 06:59:43 +02:00
|
|
|
|
2020-12-27 16:08:18 +01:00
|
|
|
bool hasChildItems() const;
|
|
|
|
|
2019-09-04 06:59:43 +02:00
|
|
|
QRectF rect() const;
|
2020-01-17 13:58:15 +01:00
|
|
|
#if QT_VERSION < QT_VERSION_CHECK( 5, 10, 0 )
|
2019-09-04 06:59:43 +02:00
|
|
|
QSizeF size() const;
|
2020-01-17 13:58:15 +01:00
|
|
|
#endif
|
2019-09-04 06:59:43 +02:00
|
|
|
QSizeF implicitSize() const;
|
|
|
|
|
|
|
|
void setGeometry( qreal x, qreal y, qreal width, qreal height );
|
2021-01-25 11:04:25 +01:00
|
|
|
QRectF geometry() const;
|
2019-09-04 06:59:43 +02:00
|
|
|
|
|
|
|
void setPolishOnResize( bool );
|
|
|
|
bool polishOnResize() const;
|
|
|
|
|
|
|
|
void setTransparentForPositioner( bool );
|
|
|
|
bool isTransparentForPositioner() const;
|
|
|
|
|
|
|
|
void setTabFence( bool );
|
|
|
|
bool isTabFence() const;
|
|
|
|
|
|
|
|
void setLayoutMirroring( bool on, bool recursive = false );
|
|
|
|
void resetLayoutMirroring();
|
|
|
|
bool layoutMirroring() const;
|
|
|
|
|
|
|
|
void setControlFlags( Flags );
|
|
|
|
void resetControlFlags();
|
|
|
|
Flags controlFlags() const;
|
|
|
|
|
|
|
|
Q_INVOKABLE void setControlFlag( Flag, bool on = true );
|
|
|
|
Q_INVOKABLE void resetControlFlag( Flag );
|
|
|
|
Q_INVOKABLE bool testControlFlag( Flag ) const;
|
|
|
|
|
|
|
|
void classBegin() override;
|
|
|
|
void componentComplete() override;
|
|
|
|
void releaseResources() override;
|
|
|
|
|
|
|
|
bool isPolishScheduled() const;
|
|
|
|
bool isUpdateNodeScheduled() const;
|
|
|
|
bool isInitiallyPainted() const;
|
|
|
|
|
|
|
|
bool maybeUnresized() const;
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void itemFlagsChanged();
|
|
|
|
void controlFlagsChanged();
|
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
void setGeometry( const QRectF& );
|
|
|
|
|
|
|
|
void show();
|
|
|
|
void hide();
|
|
|
|
void setVisible( bool );
|
|
|
|
|
|
|
|
void resetImplicitSize();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
QskQuickItem( QskQuickItemPrivate&, QQuickItem* = nullptr );
|
|
|
|
|
|
|
|
bool event( QEvent* ) override;
|
|
|
|
|
|
|
|
virtual void changeEvent( QEvent* );
|
|
|
|
virtual void geometryChangeEvent( QskGeometryChangeEvent* );
|
|
|
|
virtual void windowChangeEvent( QskWindowChangeEvent* );
|
|
|
|
|
|
|
|
void itemChange( ItemChange, const ItemChangeData& ) override;
|
2020-10-26 17:59:19 +01:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )
|
|
|
|
void geometryChange( const QRectF&, const QRectF& ) override;
|
|
|
|
#else
|
|
|
|
// using geometryChange also for Qt5
|
|
|
|
void geometryChanged( const QRectF&, const QRectF& ) override final;
|
|
|
|
virtual void geometryChange( const QRectF&, const QRectF& );
|
|
|
|
#endif
|
2019-09-04 06:59:43 +02:00
|
|
|
|
|
|
|
virtual void aboutToShow(); // called in updatePolish
|
|
|
|
|
|
|
|
private:
|
|
|
|
// don't use boundingRect - it seems to be deprecated
|
|
|
|
QRectF boundingRect() const override final { return rect(); }
|
|
|
|
|
|
|
|
/*
|
|
|
|
childrenRect()/childrenRectChanged does not make much sense
|
|
|
|
in a system, where the parent is responsible for laying out
|
|
|
|
its children.
|
|
|
|
*/
|
|
|
|
void childrenRect() = delete;
|
|
|
|
|
|
|
|
void updateControlFlag( uint flag, bool on );
|
2019-09-23 16:59:48 +02:00
|
|
|
void sendEnabledChangeEvent();
|
2019-09-04 06:59:43 +02:00
|
|
|
|
|
|
|
QSGNode* updatePaintNode( QSGNode*, UpdatePaintNodeData* ) override final;
|
|
|
|
virtual QSGNode* updateItemPaintNode( QSGNode* );
|
|
|
|
|
|
|
|
void updatePolish() override final;
|
|
|
|
virtual void updateItemPolish();
|
|
|
|
|
|
|
|
Q_DECLARE_PRIVATE( QskQuickItem )
|
|
|
|
};
|
|
|
|
|
2020-12-27 16:08:18 +01:00
|
|
|
inline bool QskQuickItem::hasChildItems() const
|
|
|
|
{
|
|
|
|
return !childItems().isEmpty();
|
|
|
|
}
|
|
|
|
|
2019-09-04 06:59:43 +02:00
|
|
|
inline void QskQuickItem::setGeometry( const QRectF& rect )
|
|
|
|
{
|
|
|
|
setGeometry( rect.x(), rect.y(), rect.width(), rect.height() );
|
|
|
|
}
|
|
|
|
|
2020-01-17 13:58:15 +01:00
|
|
|
#if QT_VERSION < QT_VERSION_CHECK( 5, 10, 0 )
|
|
|
|
|
2019-09-04 06:59:43 +02:00
|
|
|
inline QSizeF QskQuickItem::size() const
|
|
|
|
{
|
|
|
|
return QSizeF( width(), height() );
|
|
|
|
}
|
|
|
|
|
2020-01-17 13:58:15 +01:00
|
|
|
#endif
|
|
|
|
|
2019-09-04 06:59:43 +02:00
|
|
|
inline QSizeF QskQuickItem::implicitSize() const
|
|
|
|
{
|
|
|
|
return QSizeF( implicitWidth(), implicitHeight() );
|
|
|
|
}
|
|
|
|
|
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS( QskQuickItem::Flags )
|
|
|
|
Q_DECLARE_METATYPE( QskQuickItem::Flags )
|
|
|
|
|
|
|
|
#endif
|