qsgnode.sip 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. // qsgnode.sip generated by MetaSIP
  2. //
  3. // This file is part of the QtQuick Python extension module.
  4. //
  5. // Copyright (c) 2026 Riverbank Computing Limited <info@riverbankcomputing.com>
  6. //
  7. // This file is part of PyQt6.
  8. //
  9. // This file may be used under the terms of the GNU General Public License
  10. // version 3.0 as published by the Free Software Foundation and appearing in
  11. // the file LICENSE included in the packaging of this file. Please review the
  12. // following information to ensure the GNU General Public License version 3.0
  13. // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  14. //
  15. // If you do not wish to use this file under the terms of the GPL version 3.0
  16. // then you may purchase a commercial license. For more information contact
  17. // info@riverbankcomputing.com.
  18. //
  19. // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  20. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  21. class QSGNode /Supertype=PyQt6.sip.wrapper/
  22. {
  23. %TypeHeaderCode
  24. #include <qsgnode.h>
  25. %End
  26. %TypeCode
  27. static sipErrorState qsgnode_handle_flags(QSGNode *node, PyObject *self, QSGNode::Flags old_flags)
  28. {
  29. QSGNode::Flags new_flags = node->flags();
  30. if (node->parent())
  31. {
  32. if ((old_flags & QSGNode::OwnedByParent) != (new_flags & QSGNode::OwnedByParent))
  33. {
  34. if (old_flags & QSGNode::OwnedByParent)
  35. {
  36. sipTransferBack(self);
  37. }
  38. else
  39. {
  40. PyObject *parent = sipConvertFromType(node->parent(), sipType_QSGNode, 0);
  41. if (!parent)
  42. return sipErrorFail;
  43. sipTransferTo(self, parent);
  44. Py_DECREF(parent);
  45. }
  46. }
  47. }
  48. QSGNode::NodeType ntype = node->type();
  49. if (ntype == QSGNode::BasicNodeType || ntype == QSGNode::GeometryNodeType || ntype == QSGNode::ClipNodeType)
  50. {
  51. QSGBasicGeometryNode *bg_node = (QSGBasicGeometryNode *)node;
  52. if (bg_node->geometry())
  53. {
  54. if ((old_flags & QSGNode::OwnsGeometry) != (new_flags & QSGNode::OwnsGeometry))
  55. {
  56. PyObject *geom = sipConvertFromType(bg_node->geometry(), sipType_QSGGeometry, 0);
  57. if (!geom)
  58. return sipErrorFail;
  59. if (old_flags & QSGNode::OwnsGeometry)
  60. sipTransferBack(geom);
  61. else
  62. sipTransferTo(geom, self);
  63. Py_DECREF(geom);
  64. }
  65. }
  66. }
  67. if (ntype == QSGNode::GeometryNodeType)
  68. {
  69. QSGGeometryNode *g_node = (QSGGeometryNode *)node;
  70. if (g_node->material())
  71. {
  72. if ((old_flags & QSGNode::OwnsMaterial) != (new_flags & QSGNode::OwnsMaterial))
  73. {
  74. PyObject *mat = sipConvertFromType(g_node->material(), sipType_QSGMaterial, 0);
  75. if (!mat)
  76. return sipErrorFail;
  77. if (old_flags & QSGNode::OwnsMaterial)
  78. sipTransferBack(mat);
  79. else
  80. sipTransferTo(mat, self);
  81. Py_DECREF(mat);
  82. }
  83. }
  84. if (g_node->opaqueMaterial())
  85. {
  86. if ((old_flags & QSGNode::OwnsOpaqueMaterial) != (new_flags & QSGNode::OwnsOpaqueMaterial))
  87. {
  88. PyObject *omat = sipConvertFromType(g_node->opaqueMaterial(), sipType_QSGMaterial, 0);
  89. if (!omat)
  90. return sipErrorFail;
  91. if (old_flags & QSGNode::OwnsOpaqueMaterial)
  92. sipTransferBack(omat);
  93. else
  94. sipTransferTo(omat, self);
  95. Py_DECREF(omat);
  96. }
  97. }
  98. }
  99. return sipErrorNone;
  100. }
  101. %End
  102. %ConvertToSubClassCode
  103. switch (sipCpp->type())
  104. {
  105. case QSGNode::BasicNodeType:
  106. sipType = sipType_QSGBasicGeometryNode;
  107. break;
  108. case QSGNode::GeometryNodeType:
  109. sipType = sipType_QSGGeometryNode;
  110. break;
  111. case QSGNode::TransformNodeType:
  112. sipType = sipType_QSGClipNode;
  113. break;
  114. case QSGNode::ClipNodeType:
  115. sipType = sipType_QSGTransformNode;
  116. break;
  117. case QSGNode::OpacityNodeType:
  118. sipType = sipType_QSGOpacityNode;
  119. break;
  120. default:
  121. sipType = 0;
  122. }
  123. %End
  124. public:
  125. enum NodeType
  126. {
  127. BasicNodeType,
  128. GeometryNodeType,
  129. TransformNodeType,
  130. ClipNodeType,
  131. OpacityNodeType,
  132. };
  133. enum Flag /BaseType=Flag/
  134. {
  135. OwnedByParent,
  136. UsePreprocess,
  137. OwnsGeometry,
  138. OwnsMaterial,
  139. OwnsOpaqueMaterial,
  140. };
  141. typedef QFlags<QSGNode::Flag> Flags;
  142. enum DirtyStateBit /BaseType=Flag/
  143. {
  144. DirtyMatrix,
  145. DirtyNodeAdded,
  146. DirtyNodeRemoved,
  147. DirtyGeometry,
  148. DirtyMaterial,
  149. DirtyOpacity,
  150. };
  151. typedef QFlags<QSGNode::DirtyStateBit> DirtyState;
  152. QSGNode();
  153. virtual ~QSGNode();
  154. QSGNode *parent() const;
  155. void removeChildNode(QSGNode *node);
  156. void removeAllChildNodes();
  157. void prependChildNode(QSGNode *node /GetWrapper/);
  158. %MethodCode
  159. sipCpp->prependChildNode(a0);
  160. if (a0->flags() & QSGNode::OwnedByParent)
  161. sipTransferTo(a0Wrapper, sipSelf);
  162. %End
  163. void appendChildNode(QSGNode *node /GetWrapper/);
  164. %MethodCode
  165. sipCpp->appendChildNode(a0);
  166. if (a0->flags() & QSGNode::OwnedByParent)
  167. sipTransferTo(a0Wrapper, sipSelf);
  168. %End
  169. void insertChildNodeBefore(QSGNode *node /GetWrapper/, QSGNode *before);
  170. %MethodCode
  171. sipCpp->insertChildNodeBefore(a0, a1);
  172. if (a0->flags() & QSGNode::OwnedByParent)
  173. sipTransferTo(a0Wrapper, sipSelf);
  174. %End
  175. void insertChildNodeAfter(QSGNode *node /GetWrapper/, QSGNode *after);
  176. %MethodCode
  177. sipCpp->insertChildNodeAfter(a0, a1);
  178. if (a0->flags() & QSGNode::OwnedByParent)
  179. sipTransferTo(a0Wrapper, sipSelf);
  180. %End
  181. int childCount() const /__len__/;
  182. QSGNode *childAtIndex(int i) const;
  183. QSGNode *firstChild() const;
  184. QSGNode *lastChild() const;
  185. QSGNode *nextSibling() const;
  186. QSGNode *previousSibling() const;
  187. QSGNode::NodeType type() const;
  188. void markDirty(QSGNode::DirtyState bits);
  189. virtual bool isSubtreeBlocked() const;
  190. QSGNode::Flags flags() const;
  191. void setFlag(QSGNode::Flag, bool enabled = true);
  192. %MethodCode
  193. QSGNode::Flags old_flags = sipCpp->flags();
  194. sipCpp->setFlag(a0, a1);
  195. sipError = qsgnode_handle_flags(sipCpp, sipSelf, old_flags);
  196. %End
  197. void setFlags(QSGNode::Flags, bool enabled = true);
  198. virtual void preprocess();
  199. private:
  200. QSGNode(const QSGNode &);
  201. };
  202. class QSGBasicGeometryNode : public QSGNode /NoDefaultCtors/
  203. {
  204. %TypeHeaderCode
  205. #include <qsgnode.h>
  206. %End
  207. public:
  208. virtual ~QSGBasicGeometryNode();
  209. void setGeometry(QSGGeometry *geometry /GetWrapper/);
  210. %MethodCode
  211. sipCpp->setGeometry(a0);
  212. if (sipCpp->flags() & QSGNode::OwnsGeometry)
  213. sipTransferTo(a0Wrapper, sipSelf);
  214. %End
  215. QSGGeometry *geometry();
  216. };
  217. class QSGGeometryNode : public QSGBasicGeometryNode
  218. {
  219. %TypeHeaderCode
  220. #include <qsgnode.h>
  221. %End
  222. public:
  223. QSGGeometryNode();
  224. virtual ~QSGGeometryNode();
  225. void setMaterial(QSGMaterial *material /GetWrapper/);
  226. %MethodCode
  227. sipCpp->setMaterial(a0);
  228. if (sipCpp->flags() & QSGNode::OwnsMaterial)
  229. sipTransferTo(a0Wrapper, sipSelf);
  230. %End
  231. QSGMaterial *material() const;
  232. void setOpaqueMaterial(QSGMaterial *material /GetWrapper/);
  233. %MethodCode
  234. sipCpp->setOpaqueMaterial(a0);
  235. if (sipCpp->flags() & QSGNode::OwnsOpaqueMaterial)
  236. sipTransferTo(a0Wrapper, sipSelf);
  237. %End
  238. QSGMaterial *opaqueMaterial() const;
  239. };
  240. class QSGClipNode : public QSGBasicGeometryNode
  241. {
  242. %TypeHeaderCode
  243. #include <qsgnode.h>
  244. %End
  245. public:
  246. QSGClipNode();
  247. virtual ~QSGClipNode();
  248. void setIsRectangular(bool rectHint);
  249. bool isRectangular() const;
  250. void setClipRect(const QRectF &);
  251. QRectF clipRect() const;
  252. };
  253. class QSGTransformNode : public QSGNode
  254. {
  255. %TypeHeaderCode
  256. #include <qsgnode.h>
  257. %End
  258. public:
  259. QSGTransformNode();
  260. virtual ~QSGTransformNode();
  261. void setMatrix(const QMatrix4x4 &matrix);
  262. const QMatrix4x4 &matrix() const;
  263. };
  264. class QSGOpacityNode : public QSGNode
  265. {
  266. %TypeHeaderCode
  267. #include <qsgnode.h>
  268. %End
  269. public:
  270. QSGOpacityNode();
  271. virtual ~QSGOpacityNode();
  272. void setOpacity(qreal opacity);
  273. qreal opacity() const;
  274. };