Struct qmetaobject::scenegraph::SGNode [−][src]
Expand description
A typed node in the scene graph
the SGNode owns a QSGNode* of a given type. The type information is given by T which is a Tag type (an empty enum)
Fields
raw: *mut c_void
Implementations
pub fn update_dynamic<T: Any, Iter: ExactSizeIterator, F>(
&mut self,
iter: Iter,
f: F
) where
F: FnMut(<Iter as Iterator>::Item, SGNode<T>) -> SGNode<T>,
pub fn update_dynamic<T: Any, Iter: ExactSizeIterator, F>(
&mut self,
iter: Iter,
f: F
) where
F: FnMut(<Iter as Iterator>::Item, SGNode<T>) -> SGNode<T>,
Update the child nodes from an iterator.
When calling this function, all child nodes must be of the same type, but the amount of node must not be known at compile time.
The array must have the same size every time the function is called on the node. (panic otherwise). call reset() if you want to change the size.
use qmetaobject::scenegraph::{SGNode, ContainerNode, RectangleNode};
use qttypes::QRectF;
// in the reimplementation of QQuickItem::update_paint_node
fn update_paint_node(&mut self, mut node: SGNode<ContainerNode>) -> SGNode<ContainerNode> {
let items: &Vec<QRectF> = &self.items;
node.update_dynamic(items.iter(),
|i, mut n| -> SGNode<RectangleNode> {
n.create(self);
n.set_rect(*i);
n
});
node
}
Update the child node: given a tuple of update function, runs it for every node
The argument is a tuple of update functions. The same node types must be used every time this function is called. (If reset() was not called in between) (Panic otherwise). Each node type can be different.
In this example, the node has two children node
use qmetaobject::scenegraph::{SGNode, ContainerNode, RectangleNode};
use qttypes::QRectF;
// in the reimplementation of QQuickItem::update_paint_node
fn update_paint_node(&mut self, mut node : SGNode<ContainerNode> ) -> SGNode<ContainerNode> {
node.update_static((
|mut n : SGNode<RectangleNode>| -> SGNode<RectangleNode> {
n.create(self);
n.set_rect(QRectF { x: 0., y: 0., width: 42., height: 42. });
n
},
|mut n : SGNode<RectangleNode>| -> SGNode<RectangleNode> {
n.create(self);
n.set_rect(QRectF { x: 0., y: 0., width: 42., height: 42. });
n
}));
node
}