QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskQuick.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_QUICK_H
7#define QSK_QUICK_H
8
9#include "QskGlobal.h"
10#include "QskPlacementPolicy.h"
11
12#include <qnamespace.h>
13#include <qquickitem.h>
14
15class QskSizePolicy;
16
17class QSGNode;
18class QSGTransformNode;
19class QSGRootNode;
20class QRectF;
21class QRhi;
22
23template< typename T > class QList;
24
25/*
26 Exporting useful methods from QQuickItemPrivate/QQuickWindowPrivate
27 */
28
29QSK_EXPORT QRhi* qskRenderingHardwareInterface( const QQuickWindow* );
30
31QSK_EXPORT bool qskIsItemInDestructor( const QQuickItem* );
32QSK_EXPORT bool qskIsItemComplete( const QQuickItem* );
33QSK_EXPORT bool qskIsAncestorOf( const QQuickItem* item, const QQuickItem* child );
34QSK_EXPORT bool qskIsTabFence( const QQuickItem* );
35QSK_EXPORT bool qskIsShortcutScope( const QQuickItem* );
36QSK_EXPORT bool qskIsVisibleTo( const QQuickItem* item, const QQuickItem* ancestor );
37QSK_EXPORT bool qskIsVisibleToParent( const QQuickItem* );
38QSK_EXPORT bool qskIsPolishScheduled( const QQuickItem* );
39
40QSK_EXPORT bool qskIsVisibleToLayout( const QQuickItem* );
41QSK_EXPORT bool qskIsAdjustableByLayout( const QQuickItem* );
42
43QSK_EXPORT QSizeF qskEffectiveSizeHint( const QQuickItem*,
44 Qt::SizeHint, const QSizeF& constraint = QSizeF() );
45
46QSK_EXPORT QSizeF qskSizeConstraint( const QQuickItem*,
47 Qt::SizeHint, const QSizeF& constraint = QSizeF() );
48
49QSK_EXPORT QSizeF qskConstrainedItemSize( const QQuickItem*, const QSizeF& );
50QSK_EXPORT QRectF qskConstrainedItemRect(
51 const QQuickItem*, const QRectF&, Qt::Alignment );
52
53QSK_EXPORT QskSizePolicy qskSizePolicy( const QQuickItem* );
54QSK_EXPORT Qt::Alignment qskLayoutAlignmentHint( const QQuickItem* );
55
56QSK_EXPORT QskPlacementPolicy qskPlacementPolicy( const QQuickItem* );
57QSK_EXPORT void qskSetPlacementPolicy( QQuickItem*, QskPlacementPolicy );
58
59QSK_EXPORT QskPlacementPolicy::Policy qskEffectivePlacementPolicy( const QQuickItem* );
60
61QSK_EXPORT QRectF qskItemRect( const QQuickItem* );
62
63QSK_EXPORT QRectF qskItemGeometry( const QQuickItem* );
64QSK_EXPORT void qskSetItemGeometry( QQuickItem*, const QRectF& );
65
66QSK_EXPORT QQuickItem* qskNearestFocusScope( const QQuickItem* );
67QSK_EXPORT void qskForceActiveFocus( QQuickItem*, Qt::FocusReason );
68
69QSK_EXPORT QList< QQuickItem* > qskPaintOrderChildItems( const QQuickItem* );
70
71QSK_EXPORT void qskUpdateInputMethod( const QQuickItem*, Qt::InputMethodQueries );
72QSK_EXPORT void qskInputMethodSetVisible( const QQuickItem*, bool );
73
74QSK_EXPORT const QSGTransformNode* qskItemNode( const QQuickItem* );
75QSK_EXPORT const QSGNode* qskPaintNode( const QQuickItem* );
76
77QSK_EXPORT const QSGRootNode* qskScenegraphAnchorNode( const QQuickItem* );
78QSK_EXPORT const QSGRootNode* qskScenegraphAnchorNode( const QQuickWindow* );
79QSK_EXPORT void qskSetScenegraphAnchor( QQuickItem*, bool on, bool hide = false );
80
81QSK_EXPORT void qskItemUpdateRecursive( QQuickItem* );
82
83QSK_EXPORT bool qskGrabMouse( QQuickItem* );
84QSK_EXPORT void qskUngrabMouse( QQuickItem* );
85QSK_EXPORT bool qskIsMouseGrabber( const QQuickItem* );
86
87inline void qskSetItemGeometry(
88 QQuickItem* item, qreal x, qreal y, qreal width, qreal height )
89{
90 qskSetItemGeometry( item, QRectF( x, y, width, height ) );
91}
92
93template< typename T >
94inline T qskFindAncestorOf( QQuickItem* item )
95{
96 for ( auto it = item; it != nullptr; it = it->parentItem() )
97 {
98 if ( auto ancestor = qobject_cast< T >( it ) )
99 return ancestor;
100 }
101
102 return nullptr;
103}
104
105template< typename T >
106inline T qskFindAncestorOf( const QQuickItem* item )
107{
108 return qskFindAncestorOf< T >( const_cast< QQuickItem* >( item ) );
109}
110
111inline qreal qskHeightForWidth(
112 const QQuickItem* item, Qt::SizeHint which, qreal width )
113{
114 return qskEffectiveSizeHint(
115 item, which, QSizeF( width, -1.0 ) ).height();
116}
117
118inline qreal qskWidthForHeight(
119 const QQuickItem* item, Qt::SizeHint which, qreal height )
120{
121 return qskEffectiveSizeHint(
122 item, which, QSizeF( -1.0, height ) ).width();
123}
124
125inline QRectF qskConstrainedItemRect( const QQuickItem* item, const QRectF& rect )
126{
127 return qskConstrainedItemRect( item, rect, qskLayoutAlignmentHint( item ) );
128}
129
130#endif