Struct Node2D
pub struct Node2D(/* private fields */);Expand description
Node2D is the base class of 2D nodes.
Node2D implements functionality common to all 2D nodes, such as rendering, layouting, and hit testing.
To create UI graphs, use classes derived from Node2D, such as Image2D, EmptyNode2D, and StackLayout2D. To implement your own custom rendering and layout, derive from Node2D.
You can use methods of the Node2D class to configure common parameters for rendering and layout. Use methods of the derived classes to control behavior specific to them.
§Creating nodes
To create a 2D node, call a create function that returns a shared pointer to the node.
To create an EmptyNode2D node: To create an Image2D node: Each node has its own type of create function.
The constructors of nodes are protected, and can be accessed only by the inheriting classes. Node initialization happens within the create function, after constructing the node.
§%Node tree
Kanzi arranges nodes in a tree that you can think of as a directed acyclic graph with no loops. Each node can have multiple children but only one parent.
The root node of the node tree is always a 2D node. The root node does not have a parent, and it is usually of type Screen.
The Viewport2D node serves as a window to a 3D scene graph that Kanzi displays in the viewport area. A Viewport2D node must have a child Scene node as the root of the 3D scene graph. The child nodes of the Scene node are Node3D nodes.
§Constructing the node tree
You can manipulate the node tree by adding children to nodes: You can remove children from a parent node: Parents take ownership, and hold a reference to the children.
§Iterating the node tree
You can explore the node tree from a node by iterating its children: You can also go upwards to the parent: The parent returned is valid except for the root node that has no parent (it returns nullptr).
§Finding nodes
Finding nodes in the node tree is inherited from Node base class. You can look for nodes with a path: The paths work relative from the node doing the lookup. You can also traverse upwards: If lookup fails, no node is returned. See node tree lookup in Node documentation.
§Rendering
Kanzi renders nodes starting from the root node of the node tree, iterating the tree in depth-first algorithm.
A 2D node has a foreground and a background. Kanzi renders the foreground and background separately. Node classes can override the foreground or background rendering separately.
Foreground is the content of the node. For example, an image.
Background is the full node area. The background can be of the same size as the node content, or larger.
To fit the content to the node area, use the ContentStretchProperty.
§Rendering order
Kanzi renders nodes in the order in which you add the nodes to the parent node. The node that you add first is rendered first.
You can modify the rendering order by reordering the child nodes within a parent node.
To render a node last, move that node to the front: To render a node first, move that node to the back: Kanzi always renders the content of a parent node before rendering its child nodes.
§Using brushes
Kanzi uses brushes to render the foreground, background, and the optional composition of a node. Brushes determine how Kanzi does the rendering. A brush can display a color or an image, tint content provided by the node, or use an arbitrary shader to render the content of a node.
A 2D node can have a foreground brush, background brush, and a composition brush. Use the ForegroundBrushProperty, BackgroundBrushProperty, and CompositionBrushProperty to access the brushes.
To set the foreground brush of a 2D node: Use the foreground brush to render the content that the node provides. For example, an Image2D node provides an image. If a node does not provide foreground content, setting the foreground brush has no effect. Most 2D nodes render on top of the background an empty foreground of the same size as the background. For example, the EmptyNode2D node.
To set the background brush of a 2D node: Use the background brush to render the content outside and behind the node foreground area. If the node has no foreground or the foreground is translucent, the background fills the entire node area. If the foreground is opaque and fills the entire node area, Kanzi does not render the background.
To disable rendering, set null brush: Note that some node types have default brushes, which is why removing the brush property is not enough to disable rendering. Instead, Kanzi renders the node using the default brush.
§Opacity
To control the translucency of a node, use the OpacityProperty. You can set the opacity of a node: Opacity affects node background, foreground, and all node children.
When the brushes or content of a 2D node are translucent, the foreground and background of that node can be translucent even when you do not set the OpacityProperty.
Setting a 2D node as translucent affects all children of that node. To render overlapping translucency in the child nodes correctly, it is possible that you have to composite the parent node. See Composition “Composition”.
§Render transformation
To set the rendering position of a node relative to its parent, use the RenderTransformationProperty: Kanzi specifies the render transformation as SRT, that is, Scale, Rotation, and Translation.
By default, Kanzi performs the render transformation of a 2D node relative to the top-left corner of that node. To set the origin of the render transformation within the node, use the RenderTransformationOriginProperty: You can also set the render transformation origin outside the node: The values set to render transform origin are relative to the size of the node. For example, the value 0.5 ; 0.5 sets the origin at the center of the node.
Kanzi applies the render transformation after applying layout transformation. Render transformation is not affected by layout constraints such as alignment and margins, and does not modify the size layout nodes take into account. See LayoutTransformation “Layout transformation”.
§Perspective transformation
To bring limited 3D effects to a 2D node tree, you can apply perspective transformation in 3D space. Perspective transformation is an optional transformation that Kanzi applies as the last Node2D transformation, after the layout and render transformations.
To set the perspective transformation: Kanzi applies the projection for perspective transformation in the space of the current composition space. Kanzi specifies the perspective transformation as 3D SRT, that is, 3-component Scale, Rotation, and Translation vectors.
§%NodeVisual2D
Kanzi stores in an object of type NodeVisual2D all information related to the foreground and background rendering in Node2D. NodeVisual2D holds the brush and geometry information that Kanzi needs to render 2D node. To save memory, if node has nothing to render, Kanzi does not allocate a visual component.
Once the visual component is allocated, Node2D never releases it.
§Composition
By default, Kanzi renders a 2D node into the rendering context of the parent node. Usually, the top-level rendering context is the backbuffer, provided by the Screen node.
You can manually override this and render a node into a render target: When you specify the render target, the node takes its size from the render target size. You can define fixed width and fixed height for a node that also has a render target set. The fixed size can be smaller than the size of the render target. In this case, rendering happens only on a part of the render target area. Specifying a fixed size larger than the render target size is undefined behavior. A node that Kanzi renders into a render target also draws the resulting composition to the rendering context of their parent.
To achieve the correct rendering result, in some cases, Kanzi automatically renders nodes using a render target.
If the opacity of a Viewport2D is not 1.0 or if its transformation has non-translation components, that Viewport2D renders to a render target: Viewport2D is a ‘window’ to a 3D scene. It must be aligned to the units in the parent render context. If this is not the case, it needs to be composited.
All nodes render to render targets if they have children and their opacity is not one: The parent has opacity set, so it will first need to do composition of all its children, and then render this composition using that opacity.
When you assign a render target manually, you can set that render target to take its size from the size of the node. In this case, Kanzi resizes the composition target to the size that the node gets during layout:
§Offscreen rendering
Nodes do not necessarily have to draw their composition onto the render context of their parent. To enable offscreen rendering: When you enable offscreen rendering, Kanzi does not draw the node anywhere after rendering to its render target.
You can render the render target of the node using some other node: The render target behaves like a normal texture when used. Setting the render target to an Image2D determines its size unless you set the render target to use fixed size.
§Clearing a render target
When Kanzi renders a Node2D to a render target, it clears the color and depth buffers of that render target. If the render target has a depth buffer, and the node is not a Viewport2D that clears it in a RenderPass, Kanzi clears the depth buffer. If the foreground of the node does not fill the complete composition area, or the combination of background and foreground is translucent, Kanzi clears the color buffer.
To disable the clearing of a render target: When you disable the clearing of a render target, you prevent the node from clearing the render target even if the node would otherwise do it.
By default, Kanzi clears all render targets. This simplifies the rendering code and increases performance on GPUs that use tiled renderers.
§Caching
To avoid rendering a 2D node and its descendants every frame, you can cache the rendering results of a 2D node. Caching carries a cost in GPU memory. Cache only complex nodes that are expensive to render and change rarely. You can either:
- Let Kanzi update the cache automatically whenever the node or any of its descendants change.
- Make Kanzi use the same cache until you manually invalidate that cache.
To control the caching of a 2D node, use the CachingModeProperty. You can enable or disable the cache: When the CachingModeProperty is set to CachingModeEnabled, the node content does not change until you either:
- Set the CachingModeProperty to CachingModeDisabled.
- Invalidate the cache.
To invalidate the cache: After you invalidate the cache, Kanzi renders the node content once. After this, Kanzi considers the node cached again. You can disable the cache: After you disable the cache, Kanzi renders the node normally and all changes to the node and its descendants are visible immediately.
Setting the CachingModeProperty to CachingModeAutomatic causes Kanzi to automatically update the cache of the node whenever the content of the node or its descendants change. To set Kanzi to automatically update the cache: When the caching mode is set to automatic, any change to the node or its descendants causes Kanzi to update the cache. You can manually set the draw flag on a child node to invalidate the cache: Setting any property that controls rendering will eventually invalidate draw.
§%NodeCompositor2D
Kanzi stores in NodeCompositor2D all information related to compositing. This object holds composition targets, caching information, and a composition brush. Because compositing implies rendering, it is not possible to allocate a compositor without also allocating a NodeVisual2D. To save memory, if composition is not needed, Kanzi does not allocate a compositor component.
Once the compositor component is allocated, Node2D never releases it. Composition targets within compositor can be released if not needed.
§Basic Layout
A 2D node tries to determine its size automatically. A 2D node with content by default takes the size of its content. For example, Image2D takes the size of the image that it displays. EmptyNode2D and Viewport2D have unbounded layout by default. This means that they take the entire available size. Kanzi calculates the available size from the size of the parent node, or the available screen area. To arrange nodes in a layout, use layout control nodes such as StackLayout2D or GridLayout2D.
To set the size of a 2D node:
To set a 2D node to determine its size automatically, remove the fixed size: or:
You can configure a node to take its width or height based on a specified fixed size and an aspect ratio: If fixed width and aspect ratio are defined, height is width divided by aspect ratio. If fixed height and aspect ratio are defined, width is height multiplied by aspect ratio. If both fixed width and fixed height are defined, aspect ratio has no effect.
If neither width or height are defined, but aspect ratio is defined, the result depends on the node. A node that has unbounded layout takes the largest size it can with the given aspect ratio while still fitting within its allocated size. Aspect ratio has no effect when the content of a node defines its size. This is analogous to having both fixed width and fixed height.
A 2D node has an allocated area specified by the area of the parent node or a layout node. You can configure a 2D node to align in its allocated area by setting horizontal and vertical alignment:
Available values for horizontal alignment are:
- HorizontalAlignmentLeft
- HorizontalAlignmentRight
- HorizontalAlignmentCenter
- HorizontalAlignmentStretch
Available values for vertical alignment are:
- VerticalAlignmentTop
- VerticalAlignmentBottom
- VerticalAlignmentCenter
- VerticalAlignmentStretch
You can configure 2D node to fill its allocated area by setting alignment to stretch:
You can offset a 2D node from the edges of its parent node: For horizontal margins, the order of values is left, then right. For vertical margins, the order of values is top, then bottom. Kanzi offsets the node from the edge of its allocated area by the amount equal to the margin that you set. When you do not set the margins, Kanzi aligns the node at the edge of allocated area.
§Layout transformation
To set the transformation of a node relative to its parent node, set the LayoutTransformationProperty: Kanzi specifies the layout transform as SRT, that is, Scale, Rotation, and Translation.
When you transform a node with layout transformation, Kanzi applies alignment and margins to that node after the transformation. Kanzi applies render transformation after layout transformation, alignment, and margins.
See RenderTransformation “Render transformation” and PerspectiveTransformation “Perspective transformation”.
§Content stretch
The foreground content, such as an image, of a 2D node, has rules on how to stretch in relation to the node area.
These are the available content stretch modes:
-
ContentStretchNone centers the foreground area in the node area and keeps the exact size of the content.
If the node is smaller than the foreground area, it displays only a part of the content.
If the node is larger than the foreground area, the remaining area is left for background rendering.
-
ContentStretchFill sets the foreground area to take the exact node area.
This can change the aspect ratio of the content.
-
ContentStretchUniform sets the foreground content to stretch to fill the node area while keeping its aspect ratio.
If the aspect ratio of the node is different from content aspect ratio, the remaining area is left for background rendering.
This is the default content stretch mode.
-
ContentStretchUniformToFill centers the foreground area relative to the node area and scales the foreground uniformly to fill the node area.
If the aspect ratio of the node is different from the content aspect ratio, the node displays only part of the content.
To set the content stretch mode:
§Layout in main loop
During the main loop of the application, Kanzi calls layout for the root node. Before calling layout, Kanzi sets the allocated size of the Screen node to the size of the current graphics output. The layout pass evaluates only nodes that are marked as requiring layout. Kanzi calls render immediately after layout.
Because Kanzi calls render immediately after layout, you can modify the node tree and see the changes before the next call to the update function. It can be useful to determine the calculated sizes or locations of nodes before waiting for the next frame. To call layout manually:
After calling layout(), you can call getActualSize() to get the size determined by the node. Default allocated size is unbounded layout or infinity. When calling layout() manually, you must set the allocated size for the node that receives the layout() call.
See CustomNodeLayout “Implementing a custom 2D node - Layout”.
§Hit testing
You can hit test nodes in regard to their location on screen: Hit testing uses the ‘world’ or ‘render’ coordinates of the node. These coordinates are relative to the screen, not to the parent node or to the node that does the hit testing. Hit testing takes into account the visibility and all transformations of a node.
Hit testing transforms global coordinates into Node2D local coordinates to determine if the node is hit. You can determine world (screen) space coordinates in the local coordinate space of a 2D node: The return value is enclosed in an optional value, but is always valid if the node has a real nondegenerate transformation.
You can test whether given coordinates hit a node: Checking whether a global coordinate is within a node is equal to calling globalToLocal() and then testing the result with containsLocal().
§Implementing a custom 2D node
To do custom rendering and layout, you can implement a custom 2D node.
§Defining the class
To define a custom Node2D implementation, inherit from the Node2D base class.
To define a Node2D implementation:
The next sections explain different parts of the node declaration.
§%Metaclass
Each class derived from Node2D must have a metaclass definition. To declare the metaclass, inherit from the Node2D base class and list the properties specific to the inherited node:
For details about metaclass, see the description in Node documentation.
§Property types
Local property types are declared in metaclass to belong to the node. Additionally, property types must be declared within the node: It is also often useful to declare setters and getters to wrap getProperty() and setProperty() for the custom property.
After declaring a property type in the class, you must add the property definition. The definition lists property metadata. The example property is defined as follows:
Note that the property has the PropertyTypeChangeFlagFinalTransformation flag set. This means that updateRender must be called for the node when the property value changes.
These property change flags determine what Kanzi has to recalculate when the property value changes.
-
PropertyTypeChangeFlagMeasure means that the node has to be measured.
This causes measure and arrange to propagate from the node.
Kanzi runs measure() to the node and potentially all of its ancestors if measured size changed.
Then, Kanzi runs arrange() and updateRender() to the node, all of the changed nodes, and their descendants.
-
PropertyTypeChangeFlagArrange means that the node has to be arranged.
This causes arrange to propagate from the node.
Kanzi runs arrange() and updateRender() to the node and all of its children.
-
PropertyTypeChangeFlagRender means that the rendering parameters of the node changed and have to be updated.
Kanzi runs updateRender() to the node. If the transformation or composition status of the node changed, Kanzi runs updateRender() to all children of the node.
Updating the transformation of the node is a phase in updateRender(). If the transformation has not changed, Kanzi does not run this phase. Measure and arrange imply that the transform changed.
-
PropertyTypeChangeFlagFinalTransformation means that the transformation of the node and its children have to be updated.
Kanzi runs updateRender() to the node and its children.
Nodes can have class values for properties: A class value overrides the default value that the node otherwise has for a property, but the value applies only to objects of a certain class.
For more information about properties in nodes, see the documentation of the Node class.
§Message types
To communicate with each other, Kanzi nodes send messages.
Declare the message types in the node: Like the node itself, the message class must define a metaclass and properties.
You must also define the message type, metadata, and related property metadata: The argument definition is similar to property type definition. You also need to define the message type and metadata for Kanzi Studio.
A node can subscribe to listen to any messages. Typically this happens on initialization.
For more information about messages, see the documentation of the Node class.
§Initialize pattern
Constructing a node initializes node-specific values and passes them to the base class constructor. Class values are initialized in the constructor.
Further initialization is done in Node::initialize(), that is called from the create function:
In this example, the node subscribes to listen a message defined earlier upon initialize:
For details of initialization, see the documentation of the Node class.
§Attach and detach
When a node becomes a part of the node tree, it is attached. When a node is no longer a part of the node tree, it is detached. Nodes can also be attached or detached if their parent is attached or detached. This typically happens when the parent is added or removed from the node tree.
Attaching connects and activates node features related to its location in the node tree. This includes resource references, bindings, triggers, input manipulators, and so on.
For details on attach and detach, see the documentation of the Node class.
§Rendering
Custom node rendering is controlled by overriding rendering functions and setting the render type. During the render process, nodes first call their rendering functions, then rendering descends to the children.
§Rendering functions
To override the rendering of the foreground, implement renderForegroundOverride(). The default implementation of renderForegroundOverride() is empty, because all nodes decide on their own rendering.
To override the rendering of both the foreground and background, implement renderSelfOverride(). The default implementation of renderSelfOverride() applies the composition stack, and then defers to background and foreground rendering. When implementing this function, remember to ensure that the viewport settings are correct before you issue draw calls.
To use normal background rendering within overridden rendering, call renderBackground(). renderBackground() checks whether a background brush exists, and then renders the background quad. In the case of opaque foreground, background rendering renders a ‘frame’ around the node content area, if possible.
When you want to override the entire rendering process of a 2D node, implement renderOverride(). This can be necessary in some rare cases. For example, implement renderOverride() when you want to alter the way caching or the allocation of composition targets works.
For most nodes, implementing renderSelfOverride() is enough.
§Render type
Node2D rendering is controlled by RenderType. Set it upon constructor or node initialization to reflect on node rendering behavior. RenderType acts as a hint to the rendering system, regarding how to set viewport settings and how to handle background rendering.
-
RenderTypeNone is for nodes that do not have foreground content to render. For example, EmptyNode2D.
-
RenderTypeTexture is for nodes that render their foreground as a rectangular quad. For example, Image2D.
-
RenderTypeManual is for nodes that handle their own foreground rendering. For example, Viewport2D.
This implies that the system has to set up viewport coordinates for the area of the node. This pushes a local viewport area to the composition stack.
A node that uses RenderTypeManual needs to implement renderSelfOverride.
-
RenderTypeManualClipped is for nodes that handle their own foreground rendering, but do not need a local viewport area. For example, TextBlock2D.
This implies that nodes that use RenderTypeManualClipped either clip their own content, or you do not care about clipping.
A node that uses RenderTypeManualClipped needs to implement at least renderForegroundOverride, possibly renderSelfOverride.
§Layout
A custom node follows the layout directives described in the BasicLayout “Basic layout” section. You can override the layout partially by implementing layout functions.
Measurement pass
In measure(), Kanzi determines the desired size of a node.
The measurement pass descends recursively downwards until it finds nodes that are flagged as needing measure. For every node whose size changed, measure ascends upwards to the root and flags the node as requiring arrange.
To override the size that Kanzi otherwise determines for the node, implement measureOverride():
The size returned by measureOverride() determines the desired size of the content. The desired size of the node is affected by the desired size of the content and the properties of the node.
Arrange pass
In arrange(), Kanzi determines the actual size and transformation of the node.
The arrange pass descends recursively downwards to nodes that are flagged as needing arrange, and then arranges those nodes and their children.
The arrange process:
- Reads the available size for the node.
- Determines the transformation and actual size of the node based on the properties of the node.
Nodes that perform layout on their child nodes must implement arrangeOverride(). During the arrange pass of the parent node, Kanzi already finished measuring the children nodes. Arranging children works by iterating over child nodes and setting their allocated sizes and arrange transformations. For non-layout nodes, (default) arrangeOverride() sets the allocated size of the child nodes as the actual size of the node, and resets child arrange transformation.
Update render pass
In updateRender(), Kanzi determines the final transformation, brushes, and composition settings of a node.
Kanzi calls updateRender() after arrange for all nodes that are marked as requiring a transformation update.
A node can implement updateRenderOverride() to do custom clipping or modify brush or composition settings:
Implementations§
§impl Node2D
impl Node2D
pub fn get_aspect_ratio(&self) -> Result<f32, Error>
pub fn get_aspect_ratio(&self) -> Result<f32, Error>
pub fn set_aspect_ratio(&self, value: f32) -> Result<(), Error>
pub fn set_aspect_ratio(&self, value: f32) -> Result<(), Error>
pub fn get_caching_mode(&self) -> Result<CachingMode, Error>
pub fn get_caching_mode(&self) -> Result<CachingMode, Error>
pub fn set_caching_mode(&self, value: CachingMode) -> Result<(), Error>
pub fn set_caching_mode(&self, value: CachingMode) -> Result<(), Error>
pub fn get_cache_valid(&self) -> Result<bool, Error>
pub fn get_cache_valid(&self) -> Result<bool, Error>
See: CACHE_VALID_PROPERTY
pub fn set_cache_valid(&self, value: bool) -> Result<(), Error>
pub fn set_cache_valid(&self, value: bool) -> Result<(), Error>
See: CACHE_VALID_PROPERTY
pub fn get_layout_transformation(&self) -> Result<SRTValue2D, Error>
pub fn get_layout_transformation(&self) -> Result<SRTValue2D, Error>
pub fn set_layout_transformation(&self, value: SRTValue2D) -> Result<(), Error>
pub fn set_layout_transformation(&self, value: SRTValue2D) -> Result<(), Error>
pub fn get_perspective_transformation(&self) -> Result<SRTValue3D, Error>
pub fn get_perspective_transformation(&self) -> Result<SRTValue3D, Error>
pub fn set_perspective_transformation(
&self,
value: SRTValue3D,
) -> Result<(), Error>
pub fn set_perspective_transformation( &self, value: SRTValue3D, ) -> Result<(), Error>
pub fn get_perspective_transformation_mode(
&self,
) -> Result<PerspectiveTransformationMode, Error>
pub fn get_perspective_transformation_mode( &self, ) -> Result<PerspectiveTransformationMode, Error>
pub fn set_perspective_transformation_mode(
&self,
value: PerspectiveTransformationMode,
) -> Result<(), Error>
pub fn set_perspective_transformation_mode( &self, value: PerspectiveTransformationMode, ) -> Result<(), Error>
pub fn get_perspective_transformation_fov(&self) -> Result<f32, Error>
pub fn get_perspective_transformation_fov(&self) -> Result<f32, Error>
pub fn set_perspective_transformation_fov(
&self,
value: f32,
) -> Result<(), Error>
pub fn set_perspective_transformation_fov( &self, value: f32, ) -> Result<(), Error>
pub fn get_perspective_transformation_pivot(&self) -> Result<Vector3, Error>
pub fn get_perspective_transformation_pivot(&self) -> Result<Vector3, Error>
pub fn set_perspective_transformation_pivot(
&self,
value: Vector3,
) -> Result<(), Error>
pub fn set_perspective_transformation_pivot( &self, value: Vector3, ) -> Result<(), Error>
pub fn get_perspective_transformation_origin(&self) -> Result<Vector3, Error>
pub fn get_perspective_transformation_origin(&self) -> Result<Vector3, Error>
pub fn set_perspective_transformation_origin(
&self,
value: Vector3,
) -> Result<(), Error>
pub fn set_perspective_transformation_origin( &self, value: Vector3, ) -> Result<(), Error>
pub fn get_render_transformation_origin(&self) -> Result<Vector2, Error>
pub fn get_render_transformation_origin(&self) -> Result<Vector2, Error>
pub fn set_render_transformation_origin(
&self,
value: Vector2,
) -> Result<(), Error>
pub fn set_render_transformation_origin( &self, value: Vector2, ) -> Result<(), Error>
pub fn get_render_transformation(&self) -> Result<SRTValue2D, Error>
pub fn get_render_transformation(&self) -> Result<SRTValue2D, Error>
pub fn set_render_transformation(&self, value: SRTValue2D) -> Result<(), Error>
pub fn set_render_transformation(&self, value: SRTValue2D) -> Result<(), Error>
pub fn get_snap_to_pixel(&self) -> Result<bool, Error>
pub fn get_snap_to_pixel(&self) -> Result<bool, Error>
pub fn set_snap_to_pixel(&self, value: bool) -> Result<(), Error>
pub fn set_snap_to_pixel(&self, value: bool) -> Result<(), Error>
pub fn get_force_composition(&self) -> Result<bool, Error>
pub fn get_force_composition(&self) -> Result<bool, Error>
pub fn set_force_composition(&self, value: bool) -> Result<(), Error>
pub fn set_force_composition(&self, value: bool) -> Result<(), Error>
pub fn get_foreground_hint(&self) -> Result<ForegroundHint, Error>
pub fn get_foreground_hint(&self) -> Result<ForegroundHint, Error>
pub fn set_foreground_hint(&self, value: ForegroundHint) -> Result<(), Error>
pub fn set_foreground_hint(&self, value: ForegroundHint) -> Result<(), Error>
pub fn get_offscreen_rendering(&self) -> Result<bool, Error>
pub fn get_offscreen_rendering(&self) -> Result<bool, Error>
pub fn set_offscreen_rendering(&self, value: bool) -> Result<(), Error>
pub fn set_offscreen_rendering(&self, value: bool) -> Result<(), Error>
pub fn get_disable_render_target_clear(&self) -> Result<bool, Error>
pub fn get_disable_render_target_clear(&self) -> Result<bool, Error>
pub fn set_disable_render_target_clear(&self, value: bool) -> Result<(), Error>
pub fn set_disable_render_target_clear(&self, value: bool) -> Result<(), Error>
pub fn get_pixel_format(&self) -> Result<PixelFormat, Error>
pub fn get_pixel_format(&self) -> Result<PixelFormat, Error>
pub fn set_pixel_format(&self, value: PixelFormat) -> Result<(), Error>
pub fn set_pixel_format(&self, value: PixelFormat) -> Result<(), Error>
pub fn get_multisample_level(&self) -> Result<MultisampleCount, Error>
pub fn get_multisample_level(&self) -> Result<MultisampleCount, Error>
pub fn set_multisample_level(
&self,
value: MultisampleCount,
) -> Result<(), Error>
pub fn set_multisample_level( &self, value: MultisampleCount, ) -> Result<(), Error>
pub fn get_render_self(&self) -> Result<bool, Error>
pub fn get_render_self(&self) -> Result<bool, Error>
See: RENDER_SELF_PROPERTY
pub fn set_render_self(&self, value: bool) -> Result<(), Error>
pub fn set_render_self(&self, value: bool) -> Result<(), Error>
See: RENDER_SELF_PROPERTY
pub fn get_render_target_minimum_width(&self) -> Result<f32, Error>
pub fn get_render_target_minimum_width(&self) -> Result<f32, Error>
pub fn set_render_target_minimum_width(&self, value: f32) -> Result<(), Error>
pub fn set_render_target_minimum_width(&self, value: f32) -> Result<(), Error>
pub fn get_render_target_minimum_height(&self) -> Result<f32, Error>
pub fn get_render_target_minimum_height(&self) -> Result<f32, Error>
pub fn set_render_target_minimum_height(&self, value: f32) -> Result<(), Error>
pub fn set_render_target_minimum_height(&self, value: f32) -> Result<(), Error>
pub fn get_render_target_reallocation_limit(&self) -> Result<f32, Error>
pub fn get_render_target_reallocation_limit(&self) -> Result<f32, Error>
pub fn set_render_target_reallocation_limit(
&self,
value: f32,
) -> Result<(), Error>
pub fn set_render_target_reallocation_limit( &self, value: f32, ) -> Result<(), Error>
pub fn get_effect(&self) -> Result<Option<Weak<Resource>>, Error>
pub fn get_effect(&self) -> Result<Option<Weak<Resource>>, Error>
See: EFFECT_PROPERTY
pub fn set_effect(&self, value: Option<&Resource>) -> Result<(), Error>
pub fn set_effect(&self, value: Option<&Resource>) -> Result<(), Error>
See: EFFECT_PROPERTY
§impl Node2D
impl Node2D
pub fn has_child(&self, child: &Node) -> Result<bool, Error>
pub fn has_child(&self, child: &Node) -> Result<bool, Error>
Returns whether the given node is a child of this node.
pub fn get_child_count(&self) -> Result<u64, Error>
pub fn get_child_count(&self) -> Result<u64, Error>
Gets the number of children of the node.
pub fn get_child(&self, index: u64) -> Result<Weak<Node2D>, Error>
pub fn get_child(&self, index: u64) -> Result<Weak<Node2D>, Error>
Returns a child from given index from object node.
§Errors
Returns an INDEX_OUT_OF_BOUNDS error if the index is out of bounds.
pub unsafe fn get_child_unchecked(
&self,
index: u64,
) -> Result<Weak<Node2D>, Error>
pub unsafe fn get_child_unchecked( &self, index: u64, ) -> Result<Weak<Node2D>, Error>
Returns a child from given index from object node.
§Safety
The caller must ensure that index < self.get_child_count().
pub fn get_child_index(&self, child: &Node) -> Result<u64, Error>
pub fn get_child_index(&self, child: &Node) -> Result<u64, Error>
Returns the index of a child in an object node.
§Error
Returns an INVALID_ARGUMENT error if the provided Node2D is not a child of self.
pub unsafe fn get_child_index_unchecked(
&self,
child: &Node,
) -> Result<u64, Error>
pub unsafe fn get_child_index_unchecked( &self, child: &Node, ) -> Result<u64, Error>
Returns the index of a child in an object node.
§Safety
The caller must ensure that self.has_child(child).
pub fn add_child(&self, child: &Node2D) -> Result<(), Error>
pub fn add_child(&self, child: &Node2D) -> Result<(), Error>
Adds a child node.
Adding a 3D node node as a child of a 2D node is only allowed when adding a scene to a viewport. Screens can have only one child which is a 2D node.
pub fn insert_child(&self, index: u64, child: &Node2D) -> Result<(), Error>
pub fn insert_child(&self, index: u64, child: &Node2D) -> Result<(), Error>
Adds a child node for object node to given index.
§Errors
Returns an INDEX_OUT_OF_BOUNDS error if the index is out of bounds.
pub unsafe fn insert_child_unchecked(
&self,
index: u64,
child: &Node2D,
) -> Result<(), Error>
pub unsafe fn insert_child_unchecked( &self, index: u64, child: &Node2D, ) -> Result<(), Error>
Adds a child node for object node to given index.
§Safety
The caller must ensure that index <= self.get_child_count().
pub fn remove_child(&self, child: &Node2D) -> Result<(), Error>
pub fn remove_child(&self, child: &Node2D) -> Result<(), Error>
Removes child node.
§Errors
Returns an INVALID_ARGUMENT error if the provided Node2D is not a child of self.
pub unsafe fn remove_child_unchecked(&self, child: &Node2D) -> Result<(), Error>
pub unsafe fn remove_child_unchecked(&self, child: &Node2D) -> Result<(), Error>
pub fn remove_child_at_index(&self, index: u64) -> Result<(), Error>
pub fn remove_child_at_index(&self, index: u64) -> Result<(), Error>
Removes child node at specified index.
§Errors
Returns an INDEX_OUT_OF_BOUNDS error if the index is out of bounds.
pub unsafe fn remove_child_at_index_unchecked(
&self,
index: u64,
) -> Result<(), Error>
pub unsafe fn remove_child_at_index_unchecked( &self, index: u64, ) -> Result<(), Error>
Removes child node at specified index.
§Safety
The caller must ensure that index < self.get_child_count().
pub fn remove_all_children(&self) -> Result<(), Error>
pub fn remove_all_children(&self) -> Result<(), Error>
Removes all child nodes.
§impl Node2D
impl Node2D
pub fn get_world_transform(&self) -> Result<Matrix3x3, Error>
pub fn get_world_transform(&self) -> Result<Matrix3x3, Error>
Gets the world transformation matrix.
pub fn move_to_back(&self) -> Result<(), Error>
pub fn move_to_back(&self) -> Result<(), Error>
Repositions the node to the beginning of its parent’s children, so that it is drawn first.
pub fn move_to_front(&self) -> Result<(), Error>
pub fn move_to_front(&self) -> Result<(), Error>
Repositions the node to the end of its parent’s children, so that it is drawn last.
pub fn get_desired_size(&self) -> Result<Vector2, Error>
pub fn get_desired_size(&self) -> Result<Vector2, Error>
Gets the desired size of a node.
pub fn set_desired_size(&self, value: Vector2) -> Result<(), Error>
pub fn set_desired_size(&self, value: Vector2) -> Result<(), Error>
Sets the desired size of a node.
pub fn get_allocated_size(&self) -> Result<Vector2, Error>
pub fn get_allocated_size(&self) -> Result<Vector2, Error>
Gets the allocated size of a node.
pub fn set_allocated_size(&self, value: Vector2) -> Result<(), Error>
pub fn set_allocated_size(&self, value: Vector2) -> Result<(), Error>
Sets the allocated size of a node.
pub fn get_actual_size(&self) -> Result<Vector2, Error>
pub fn get_actual_size(&self) -> Result<Vector2, Error>
Gets the actual size of a node.
pub fn set_actual_size(&self, value: Vector2) -> Result<(), Error>
pub fn set_actual_size(&self, value: Vector2) -> Result<(), Error>
Sets the actual size of a node.
pub fn get_arrange_transform(&self) -> Result<Matrix3x3, Error>
pub fn get_arrange_transform(&self) -> Result<Matrix3x3, Error>
Gets the arrange transform.
pub fn set_arrange_transform(&self, value: Matrix3x3) -> Result<(), Error>
pub fn set_arrange_transform(&self, value: Matrix3x3) -> Result<(), Error>
Sets the arrange transform. If the layout transform differs from the existing transform, calling this function invalidates the arrange.
pub fn layout(&self) -> Result<(), Error>
pub fn layout(&self) -> Result<(), Error>
Does a layout pass starting from this node and iterating recursively all of its children. Does a layout pass with no root transformation (identity).
Measure pass only descends up to nodes marked for requiring measure and then propagates upwards for all nodes that were changed. After measure, all nodes marked for requiring arrange and all their children are arranged.
The actual size of a node is not known before layout. You can call layout manually to determine the actual sizes of nodes. Before calling layout, the node must have allocated size set to limit node area to anything less than infinity. Normal layout process sets allocated size to current composition size.
§impl Node2D
impl Node2D
pub fn get_children_iterator(&self) -> Result<Node2DChildrenIterator, Error>
pub fn get_children_iterator(&self) -> Result<Node2DChildrenIterator, Error>
Gets an iterator over 2D node children.
pub fn get_children_rev_iterator(&self) -> Result<Node2DChildrenIterator, Error>
pub fn get_children_rev_iterator(&self) -> Result<Node2DChildrenIterator, Error>
Gets a reverse iterator over 2D node children.
Methods from Deref<Target = Node>§
pub fn get_name(&self) -> Result<KanziString, Error>
pub fn get_name(&self) -> Result<KanziString, Error>
See: NAME_PROPERTY
pub fn get_path(&self) -> Result<KanziString, Error>
pub fn get_path(&self) -> Result<KanziString, Error>
See: PATH_PROPERTY
pub fn get_locale(&self) -> Result<KanziString, Error>
pub fn get_locale(&self) -> Result<KanziString, Error>
See: LOCALE_PROPERTY
pub fn set_locale(&self, value: impl AsRef<KanziStr>) -> Result<(), Error>
pub fn set_locale(&self, value: impl AsRef<KanziStr>) -> Result<(), Error>
See: LOCALE_PROPERTY
pub fn get_width(&self) -> Result<f32, Error>
pub fn get_width(&self) -> Result<f32, Error>
See: WIDTH_PROPERTY
pub fn get_height(&self) -> Result<f32, Error>
pub fn get_height(&self) -> Result<f32, Error>
See: HEIGHT_PROPERTY
pub fn set_height(&self, value: f32) -> Result<(), Error>
pub fn set_height(&self, value: f32) -> Result<(), Error>
See: HEIGHT_PROPERTY
pub fn get_depth(&self) -> Result<f32, Error>
pub fn get_depth(&self) -> Result<f32, Error>
See: DEPTH_PROPERTY
pub fn get_actual_width(&self) -> Result<f32, Error>
pub fn get_actual_width(&self) -> Result<f32, Error>
pub fn set_actual_width(&self, value: f32) -> Result<(), Error>
pub fn set_actual_width(&self, value: f32) -> Result<(), Error>
pub fn get_actual_height(&self) -> Result<f32, Error>
pub fn get_actual_height(&self) -> Result<f32, Error>
pub fn set_actual_height(&self, value: f32) -> Result<(), Error>
pub fn set_actual_height(&self, value: f32) -> Result<(), Error>
pub fn get_actual_depth(&self) -> Result<f32, Error>
pub fn get_actual_depth(&self) -> Result<f32, Error>
pub fn set_actual_depth(&self, value: f32) -> Result<(), Error>
pub fn set_actual_depth(&self, value: f32) -> Result<(), Error>
pub fn get_horizontal_alignment(&self) -> Result<HorizontalAlignment, Error>
pub fn get_horizontal_alignment(&self) -> Result<HorizontalAlignment, Error>
pub fn set_horizontal_alignment(
&self,
value: HorizontalAlignment,
) -> Result<(), Error>
pub fn set_horizontal_alignment( &self, value: HorizontalAlignment, ) -> Result<(), Error>
pub fn get_vertical_alignment(&self) -> Result<VerticalAlignment, Error>
pub fn get_vertical_alignment(&self) -> Result<VerticalAlignment, Error>
pub fn set_vertical_alignment(
&self,
value: VerticalAlignment,
) -> Result<(), Error>
pub fn set_vertical_alignment( &self, value: VerticalAlignment, ) -> Result<(), Error>
pub fn get_depth_alignment(&self) -> Result<DepthAlignment, Error>
pub fn get_depth_alignment(&self) -> Result<DepthAlignment, Error>
pub fn set_depth_alignment(&self, value: DepthAlignment) -> Result<(), Error>
pub fn set_depth_alignment(&self, value: DepthAlignment) -> Result<(), Error>
pub fn get_horizontal_margin(&self) -> Result<Vector2, Error>
pub fn get_horizontal_margin(&self) -> Result<Vector2, Error>
pub fn set_horizontal_margin(&self, value: Vector2) -> Result<(), Error>
pub fn set_horizontal_margin(&self, value: Vector2) -> Result<(), Error>
pub fn get_vertical_margin(&self) -> Result<Vector2, Error>
pub fn get_vertical_margin(&self) -> Result<Vector2, Error>
pub fn set_vertical_margin(&self, value: Vector2) -> Result<(), Error>
pub fn set_vertical_margin(&self, value: Vector2) -> Result<(), Error>
pub fn get_depth_margin(&self) -> Result<Vector2, Error>
pub fn get_depth_margin(&self) -> Result<Vector2, Error>
pub fn set_depth_margin(&self, value: Vector2) -> Result<(), Error>
pub fn set_depth_margin(&self, value: Vector2) -> Result<(), Error>
pub fn get_hit_testable(&self) -> Result<bool, Error>
pub fn get_hit_testable(&self) -> Result<bool, Error>
pub fn set_hit_testable(&self, value: bool) -> Result<(), Error>
pub fn set_hit_testable(&self, value: bool) -> Result<(), Error>
pub fn get_hit_testable_container(&self) -> Result<bool, Error>
pub fn get_hit_testable_container(&self) -> Result<bool, Error>
pub fn set_hit_testable_container(&self, value: bool) -> Result<(), Error>
pub fn set_hit_testable_container(&self, value: bool) -> Result<(), Error>
pub fn get_visible(&self) -> Result<bool, Error>
pub fn get_visible(&self) -> Result<bool, Error>
See: VISIBLE_PROPERTY
pub fn set_visible(&self, value: bool) -> Result<(), Error>
pub fn set_visible(&self, value: bool) -> Result<(), Error>
See: VISIBLE_PROPERTY
pub fn get_enabled(&self) -> Result<bool, Error>
pub fn get_enabled(&self) -> Result<bool, Error>
See: ENABLED_PROPERTY
pub fn set_enabled(&self, value: bool) -> Result<(), Error>
pub fn set_enabled(&self, value: bool) -> Result<(), Error>
See: ENABLED_PROPERTY
pub fn get_effectively_enabled(&self) -> Result<bool, Error>
pub fn get_effectively_enabled(&self) -> Result<bool, Error>
pub fn set_effectively_enabled(&self, value: bool) -> Result<(), Error>
pub fn set_effectively_enabled(&self, value: bool) -> Result<(), Error>
pub fn get_focusable(&self) -> Result<bool, Error>
pub fn get_focusable(&self) -> Result<bool, Error>
See: FOCUSABLE_PROPERTY
pub fn set_focusable(&self, value: bool) -> Result<(), Error>
pub fn set_focusable(&self, value: bool) -> Result<(), Error>
See: FOCUSABLE_PROPERTY
pub fn get_focused(&self) -> Result<bool, Error>
pub fn get_focused(&self) -> Result<bool, Error>
See: FOCUSED_PROPERTY
pub fn set_focused(&self, value: bool) -> Result<(), Error>
pub fn set_focused(&self, value: bool) -> Result<(), Error>
See: FOCUSED_PROPERTY
pub fn get_focus_state(&self) -> Result<FocusState, Error>
pub fn get_focus_state(&self) -> Result<FocusState, Error>
See: FOCUS_STATE_PROPERTY
pub fn set_focus_state(&self, value: FocusState) -> Result<(), Error>
pub fn set_focus_state(&self, value: FocusState) -> Result<(), Error>
See: FOCUS_STATE_PROPERTY
pub fn get_font_family(&self) -> Result<Option<Weak<Resource>>, Error>
pub fn get_font_family(&self) -> Result<Option<Weak<Resource>>, Error>
See: FONT_FAMILY_PROPERTY
pub fn set_font_family(&self, value: Option<&Resource>) -> Result<(), Error>
pub fn set_font_family(&self, value: Option<&Resource>) -> Result<(), Error>
See: FONT_FAMILY_PROPERTY
pub fn get_visible_amount_in_parent(&self) -> Result<f32, Error>
pub fn get_visible_amount_in_parent(&self) -> Result<f32, Error>
pub fn set_visible_amount_in_parent(&self, value: f32) -> Result<(), Error>
pub fn set_visible_amount_in_parent(&self, value: f32) -> Result<(), Error>
pub fn get_clip_children(&self) -> Result<bool, Error>
pub fn get_clip_children(&self) -> Result<bool, Error>
pub fn set_clip_children(&self, value: bool) -> Result<(), Error>
pub fn set_clip_children(&self, value: bool) -> Result<(), Error>
pub fn get_content_stretch(&self) -> Result<ContentStretch, Error>
pub fn get_content_stretch(&self) -> Result<ContentStretch, Error>
pub fn set_content_stretch(&self, value: ContentStretch) -> Result<(), Error>
pub fn set_content_stretch(&self, value: ContentStretch) -> Result<(), Error>
pub fn get_opacity(&self) -> Result<f32, Error>
pub fn get_opacity(&self) -> Result<f32, Error>
See: OPACITY_PROPERTY
pub fn set_opacity(&self, value: f32) -> Result<(), Error>
pub fn set_opacity(&self, value: f32) -> Result<(), Error>
See: OPACITY_PROPERTY
pub fn get_hover(&self) -> Result<bool, Error>
pub fn get_hover(&self) -> Result<bool, Error>
See: HOVER_PROPERTY
pub fn get_projection_2d_to_3d_scale(&self) -> Result<f32, Error>
pub fn get_projection_2d_to_3d_scale(&self) -> Result<f32, Error>
pub fn set_projection_2d_to_3d_scale(&self, value: f32) -> Result<(), Error>
pub fn set_projection_2d_to_3d_scale(&self, value: f32) -> Result<(), Error>
pub fn get_created_from_kzb(&self) -> Result<bool, Error>
pub fn get_created_from_kzb(&self) -> Result<bool, Error>
pub fn set_created_from_kzb(&self, value: bool) -> Result<(), Error>
pub fn set_created_from_kzb(&self, value: bool) -> Result<(), Error>
pub fn set_binding(
&self,
binding: &AbstractBinding,
) -> Result<AbstractBindingRuntime, Error>
pub fn set_binding( &self, binding: &AbstractBinding, ) -> Result<AbstractBindingRuntime, Error>
pub fn set_binding1<T>(
&self,
binding: &AbstractBinding,
property_type: &PropertyType<T>,
) -> Result<AbstractBindingRuntime, Error>
pub fn set_binding1<T>( &self, binding: &AbstractBinding, property_type: &PropertyType<T>, ) -> Result<AbstractBindingRuntime, Error>
pub fn set_binding2<T>(
&self,
binding: &AbstractBinding,
property_type: &PropertyType<T>,
property_field: PropertyField,
) -> Result<AbstractBindingRuntime, Error>
pub fn set_binding2<T>( &self, binding: &AbstractBinding, property_type: &PropertyType<T>, property_field: PropertyField, ) -> Result<AbstractBindingRuntime, Error>
pub fn set_binding_with_owner<T>(
&self,
binding: &AbstractBinding,
owner_object: &Object,
property_type: &PropertyType<T>,
) -> Result<AbstractBindingRuntime, Error>
pub fn set_binding_with_owner<T>( &self, binding: &AbstractBinding, owner_object: &Object, property_type: &PropertyType<T>, ) -> Result<AbstractBindingRuntime, Error>
pub fn set_binding_with_owner1<T>(
&self,
binding: &AbstractBinding,
owner_object: &Object,
property_type: &PropertyType<T>,
property_field: PropertyField,
) -> Result<AbstractBindingRuntime, Error>
pub fn set_binding_with_owner1<T>( &self, binding: &AbstractBinding, owner_object: &Object, property_type: &PropertyType<T>, property_field: PropertyField, ) -> Result<AbstractBindingRuntime, Error>
pub fn set_modifier_binding<T>(
&self,
binding: &AbstractBinding,
property_type: &PropertyType<T>,
) -> Result<AbstractBindingRuntime, Error>
pub fn set_modifier_binding<T>( &self, binding: &AbstractBinding, property_type: &PropertyType<T>, ) -> Result<AbstractBindingRuntime, Error>
Wrapper for setting a modifier binding.
As opposed to value source created by Self::set_binding, creates a property modifier binding.
Whole property is used.
§Arguments
binding- Binding to set.property_type- Target property type.
§Returns
Binding runtime handler created for the binding.
pub fn set_modifier_binding1<T>(
&self,
binding: &AbstractBinding,
property_type: &PropertyType<T>,
property_field: PropertyField,
) -> Result<AbstractBindingRuntime, Error>
pub fn set_modifier_binding1<T>( &self, binding: &AbstractBinding, property_type: &PropertyType<T>, property_field: PropertyField, ) -> Result<AbstractBindingRuntime, Error>
Wrapper for setting a modifier binding.
As opposed to value source created by Self::set_binding, creates a property modifier binding.
§Arguments
binding- Binding to set.property_type- Target property type.field- Property field.
§Returns
Binding runtime handler created for the binding.
pub fn set_modifier_binding_with_owner<T>(
&self,
binding: &AbstractBinding,
owner_object: &Object,
property_type: &PropertyType<T>,
) -> Result<AbstractBindingRuntime, Error>
pub fn set_modifier_binding_with_owner<T>( &self, binding: &AbstractBinding, owner_object: &Object, property_type: &PropertyType<T>, ) -> Result<AbstractBindingRuntime, Error>
Wrapper for setting a modifier binding.
As opposed to value source created by Self::set_binding, creates a property modifier binding.
§Arguments
binding- Binding to set.owner- Owner shared pointer for the binding.property_type- Target property type.
§Returns
Binding runtime handler created for the binding.
pub fn set_modifier_binding_with_owner1<T>(
&self,
binding: &AbstractBinding,
owner_object: &Object,
property_type: &PropertyType<T>,
property_field: PropertyField,
) -> Result<AbstractBindingRuntime, Error>
pub fn set_modifier_binding_with_owner1<T>( &self, binding: &AbstractBinding, owner_object: &Object, property_type: &PropertyType<T>, property_field: PropertyField, ) -> Result<AbstractBindingRuntime, Error>
Wrapper for setting a modifier binding.
As opposed to value source created by Self::set_binding, creates a property modifier binding.
§Arguments
binding- Binding to set.owner- Owner shared pointer for the binding.property_type- Target property type.field- Property field.
§Returns
Binding runtime handler created for the binding.
pub fn remove_binding(
&self,
binding_runtime: &AbstractBindingRuntime,
) -> Result<(), Error>
pub fn remove_binding( &self, binding_runtime: &AbstractBindingRuntime, ) -> Result<(), Error>
pub fn remove_bindings_with_owner(
&self,
owner_object: &Object,
) -> Result<(), Error>
pub fn remove_bindings_with_owner( &self, owner_object: &Object, ) -> Result<(), Error>
Removes all binding runtimes with the specified owner.
§Arguments
owner- Owner of the binding runtime.
pub fn add_input_manipulator(
&self,
input_manipulator: &InputManipulator,
) -> Result<(), Error>
pub fn add_input_manipulator( &self, input_manipulator: &InputManipulator, ) -> Result<(), Error>
Transfers the ownership and attaches an input manipulator to an object node.
§Arguments
input_manipulator- The input manipulator to add.
pub fn remove_input_manipulator(
&self,
input_manipulator: &InputManipulator,
) -> Result<(), Error>
pub fn remove_input_manipulator( &self, input_manipulator: &InputManipulator, ) -> Result<(), Error>
Removes the ownership and detaches an input manipulator from an object node.
§Arguments
input_manipulator- The input manipulator to remove.
pub fn get_resource_dictionary(
&self,
) -> Result<Option<Weak<ResourceDictionary>>, Error>
pub fn get_resource_dictionary( &self, ) -> Result<Option<Weak<ResourceDictionary>>, Error>
If a node has a resource dictionary, returns the resource dictionary of that node.
§Returns
The resource dictionary of the node. If None is returned, the node does not have a resource dictionary.
pub fn acquire_resource_dictionary(
&self,
) -> Result<Weak<ResourceDictionary>, Error>
pub fn acquire_resource_dictionary( &self, ) -> Result<Weak<ResourceDictionary>, Error>
Gets a resource dictionary of a node. If a resource dictionary does not exist, the function creates it.
§Returns
The resource dictionary of the node.
pub fn notify_resource_dictionary_modified(&self) -> Result<(), Error>
pub fn notify_resource_dictionary_modified(&self) -> Result<(), Error>
Forces the re-evaluation of resource IDs in a node tree.
If you modify a resource dictionary of a node that is already attached, you can use this function to update the resource properties.
Note that you need to use this function only if you modify the dictionary directly through
Self::get_resource_dictionary or Self::acquire_resource_dictionary.
If you use other Node class functions like Self::add_resource or Self::set_resource_dictionary,
you do not need to call this function.
pub fn set_resource_dictionary(
&self,
resource_dictionary: &ResourceDictionary,
) -> Result<(), Error>
pub fn set_resource_dictionary( &self, resource_dictionary: &ResourceDictionary, ) -> Result<(), Error>
Replaces the resource dictionary of a node. Updates all the resource references of the child nodes.
§Arguments
resource_dictionary- The resource dictionary.
pub fn add_resource_dictionary(
&self,
resource_dictionary: &ResourceDictionary,
) -> Result<(), Error>
pub fn add_resource_dictionary( &self, resource_dictionary: &ResourceDictionary, ) -> Result<(), Error>
Adds a nested resource dictionary to the resource dictionary of a node. Updates all the resource references of the child nodes.
§Arguments
resource_dictionary- The nested resource dictionary.
pub fn is_named(&self, name: impl AsRef<KanziStr>) -> Result<bool, Error>
pub fn is_effectively_visible(&self) -> Result<bool, Error>
pub fn is_effectively_visible(&self) -> Result<bool, Error>
Returns whether a node and its ancestor nodes are visible.
pub fn is_effectively_focusable(&self) -> Result<bool, Error>
pub fn is_effectively_focusable(&self) -> Result<bool, Error>
Returns whether a node is focusable. A node is focusable when it is a focus scope node
or has FOCUSABLE_PROPERTY attached and set to true, or both.
pub fn is_initialized(&self) -> Result<bool, Error>
pub fn is_initialized(&self) -> Result<bool, Error>
Returns true if initialize() has been called, false otherwise.
pub fn is_attached(&self) -> Result<bool, Error>
pub fn is_attached(&self) -> Result<bool, Error>
Returns true if the node is attached to a screen or one of its descendants.
pub fn is_attaching(&self) -> Result<bool, Error>
pub fn is_attaching(&self) -> Result<bool, Error>
Returns true if node is in the process of attaching, false otherwise.
pub fn is_detaching(&self) -> Result<bool, Error>
pub fn is_detaching(&self) -> Result<bool, Error>
Returns true if the node currently detaching.
pub unsafe fn attach_recursive(&self) -> Result<(), Error>
pub unsafe fn attach_recursive(&self) -> Result<(), Error>
Attaches an object node and its children recursively.
§Safety
The caller must ensure that Self::detach_recursive is called before an object is destroyed.
pub unsafe fn detach_recursive(&self) -> Result<(), Error>
pub unsafe fn detach_recursive(&self) -> Result<(), Error>
Detaches a node and its descendants.
§Safety
The caller must ensure that Self::attach_recursive was called on an object.
pub fn try_set_focus(&self) -> Result<Option<Weak<Node>>, Error>
pub fn try_set_focus(&self) -> Result<Option<Weak<Node>>, Error>
Tries to move the focus to this node. If this node is a focus scope node, this method tries to focus the
preserved focus of the focus scope, or tries to focus on the first focusable descendant node of this node.
This is a convenience function of the FocusManager::trySetFocus(), that uses the node as target node.
§Returns
If this method successfully moved focus, returns this node or a descendant node of this node.
If None is return, this method did not move focus.
pub fn lookup_node<T>(
&self,
name: impl AsRef<KanziStr>,
) -> Result<Option<Weak<T>>, Error>where
T: MetaInherits<Node>,
pub fn lookup_node<T>(
&self,
name: impl AsRef<KanziStr>,
) -> Result<Option<Weak<T>>, Error>where
T: MetaInherits<Node>,
Returns a node of specified type by looking it up with specified path or alias.
If None is returned, couldn’t find a node with a given name or node was found but of a different type
pub fn lookup_node_raw(
&self,
name: impl AsRef<KanziStr>,
) -> Result<Option<Weak<Node>>, Error>
pub fn lookup_node_raw( &self, name: impl AsRef<KanziStr>, ) -> Result<Option<Weak<Node>>, Error>
Returns a node of specified type by looking it up with specified path or alias.
If None is returned, couldn’t find a node with a given name.
pub fn get_abstract_child_count(&self) -> Result<u64, Error>
pub fn add_abstract_child(&self, child: &Node) -> Result<bool, Error>
pub fn get_abstract_child_index(&self, child: &Node) -> Result<u64, Error>
pub fn get_abstract_child(&self, index: u64) -> Result<Weak<Node>, Error>
pub fn get_abstract_child(&self, index: u64) -> Result<Weak<Node>, Error>
§Errors
Returns an INDEX_OUT_OF_BOUNDS error if the index is out of bounds.
pub unsafe fn get_abstract_child_unchecked(
&self,
index: u64,
) -> Result<Weak<Node>, Error>
pub unsafe fn get_abstract_child_unchecked( &self, index: u64, ) -> Result<Weak<Node>, Error>
§Safety
The caller must ensure that index < self.get_abstract_child_count().
pub fn remove_abstract_child(&self, child: &Node) -> Result<bool, Error>
pub fn add_message_handler<T>(
&self,
message_type: &MessageType<T>,
closure: impl FnMut(T) -> Result<(), Error> + 'static,
) -> Result<MessageSubscriptionToken, Error>where
T: MessageArgumentsConstraint,
pub fn add_message_handler<T>(
&self,
message_type: &MessageType<T>,
closure: impl FnMut(T) -> Result<(), Error> + 'static,
) -> Result<MessageSubscriptionToken, Error>where
T: MessageArgumentsConstraint,
Adds a message handler where the handler is a function. The handler is invoked when a message of messageType is signaled in the node the handler is added to.
pub fn add_message_handler_raw<T>(
&self,
message_type: &MessageType<T>,
closure: impl Handler,
) -> Result<MessageSubscriptionToken, Error>
pub fn add_message_handler_raw<T>( &self, message_type: &MessageType<T>, closure: impl Handler, ) -> Result<MessageSubscriptionToken, Error>
Adds a message handler where the handler is a function. The handler is invoked when a message of messageType is signaled in the node the handler is added to.
pub fn add_message_handler_from_source<T>(
&self,
message_type: &MessageType<T>,
message_source_filter: &Object,
closure: impl Handler,
) -> Result<MessageSubscriptionToken, Error>
pub fn add_message_handler_from_source<T>( &self, message_type: &MessageType<T>, message_source_filter: &Object, closure: impl Handler, ) -> Result<MessageSubscriptionToken, Error>
Adds a message handler where the handler is a function and you explicitly define the accepted source. The handler is invoked when a message of messageType bubbles through the node to which you add the handler, but only when you dispatch it from the given source node.
pub fn add_message_filter<T>(
&self,
message_type: &MessageType<T>,
closure: impl Handler,
) -> Result<MessageSubscriptionToken, Error>
pub fn add_message_filter<T>( &self, message_type: &MessageType<T>, closure: impl Handler, ) -> Result<MessageSubscriptionToken, Error>
Adds a message filter where the filter is a function. The filter is invoked when a message of messageType bubbles through the node the filter is added to.
pub fn add_tunneling_message_handler<T>(
&self,
message_type: &MessageType<T>,
message_source_filter: &Object,
closure: impl Handler,
) -> Result<MessageSubscriptionToken, Error>
pub fn add_tunneling_message_handler<T>( &self, message_type: &MessageType<T>, message_source_filter: &Object, closure: impl Handler, ) -> Result<MessageSubscriptionToken, Error>
Adds a message handler where the handler is a function and you explicitly define the accepted source. The handler is invoked when a message of messageType tunnels through the node to which you add the handler, but only when you dispatch it from the given source node.
pub fn add_tunneling_message_filter<T>(
&self,
message_type: &MessageType<T>,
closure: impl Handler,
) -> Result<MessageSubscriptionToken, Error>
pub fn add_tunneling_message_filter<T>( &self, message_type: &MessageType<T>, closure: impl Handler, ) -> Result<MessageSubscriptionToken, Error>
Adds a message filter where the filter is a function. The filter is invoked when a message of messageType tunnels through the node to which you add this filter.
pub fn remove_message_handler(
&self,
token: &MessageSubscriptionToken,
) -> Result<(), Error>
pub fn remove_message_handler( &self, token: &MessageSubscriptionToken, ) -> Result<(), Error>
Removes a message subscription.
pub fn dispatch_message<T>(
&self,
message_type: &MessageType<T>,
args: &T,
) -> Result<(), Error>where
T: MessageArgumentsConstraint,
pub fn dispatch_message<T>(
&self,
message_type: &MessageType<T>,
args: &T,
) -> Result<(), Error>where
T: MessageArgumentsConstraint,
Dispatches a message from this node with specified arguments.
pub fn dispatch_message_raw<T>(
&self,
message_type: &MessageType<T>,
args: &MessageArguments,
) -> Result<(), Error>
pub fn dispatch_message_raw<T>( &self, message_type: &MessageType<T>, args: &MessageArguments, ) -> Result<(), Error>
Dispatches a message from this node with specified arguments. No type verification is done
pub fn add_resource(
&self,
resource_id: &ResourceId,
resource_url: impl AsRef<KanziStr>,
) -> Result<(), Error>
pub fn add_resource( &self, resource_id: &ResourceId, resource_url: impl AsRef<KanziStr>, ) -> Result<(), Error>
Adds a resource manager resource to an object node.
If resource_id already exists in object, removes the existing entry.
pub fn remove_resource(&self, resource_id: &ResourceId) -> Result<(), Error>
pub fn remove_resource(&self, resource_id: &ResourceId) -> Result<(), Error>
Removes a resource with given ID from object node resource dictionary.
Does not do anything if resource_id was not found.
pub fn contains_resource(&self, resource_id: &ResourceId) -> Result<bool, Error>
pub fn contains_resource(&self, resource_id: &ResourceId) -> Result<bool, Error>
Returns if object node resource dictionary contains the resource with given ID. Resource can be any type: style, alias or resource manager resource.
pub fn find_resource_url(
&self,
resource_id: &ResourceId,
) -> Result<Option<KanziString>, Error>
pub fn find_resource_url( &self, resource_id: &ResourceId, ) -> Result<Option<KanziString>, Error>
Tries to find Resource URL for Resource ID from this node.
pub fn acquire_resource(
&self,
resource_id: &ResourceId,
) -> Result<Resource, Error>
pub fn acquire_resource( &self, resource_id: &ResourceId, ) -> Result<Resource, Error>
Acquires a resource from the node or the node’s closest ancestor having the resource id in the resource dictionary.
§Arguments
resource_id- Name of the resource.
pub fn try_acquire_resource(
&self,
resource_id: &ResourceId,
) -> Result<Option<Resource>, Error>
pub fn try_acquire_resource( &self, resource_id: &ResourceId, ) -> Result<Option<Resource>, Error>
Acquires a resource from the node or the node’s closest ancestor having the resource id in the resource dictionary.
§Arguments
resource_id- Name of the resource.
pub fn acquire_resource_async(
&self,
resource_id: &ResourceId,
closure: impl AcquireFinishedCallback,
) -> Result<Option<ResourceAcquireTask>, Error>
pub fn acquire_resource_async( &self, resource_id: &ResourceId, closure: impl AcquireFinishedCallback, ) -> Result<Option<ResourceAcquireTask>, Error>
pub fn add_anonymous_resource(&self, resource: &Resource) -> Result<(), Error>
pub fn add_anonymous_resource(&self, resource: &Resource) -> Result<(), Error>
Adds anonymous resource (such as style) for object node resources.
pub fn remove_anonymous_resource(
&self,
resource: &Resource,
) -> Result<(), Error>
pub fn remove_anonymous_resource( &self, resource: &Resource, ) -> Result<(), Error>
Removes anonymous resource from object node resources.
pub fn add_node_component(
&self,
node_component: &NodeComponent,
) -> Result<(), Error>
pub fn add_node_component( &self, node_component: &NodeComponent, ) -> Result<(), Error>
Transfers the ownership of a node component to an object node.
pub fn add_node_component_with_owner(
&self,
node_component: &NodeComponent,
owner: Option<&Object>,
) -> Result<(), Error>
pub fn add_node_component_with_owner( &self, node_component: &NodeComponent, owner: Option<&Object>, ) -> Result<(), Error>
Transfers the ownership of a node component to an object node and sets the owner of the node component.
pub fn remove_node_component(
&self,
node_component: &NodeComponent,
) -> Result<(), Error>
pub fn remove_node_component( &self, node_component: &NodeComponent, ) -> Result<(), Error>
Removes the ownership of a node component from an object node.
pub fn remove_node_component_with_owner(
&self,
owner: Option<&Object>,
) -> Result<(), Error>
pub fn remove_node_component_with_owner( &self, owner: Option<&Object>, ) -> Result<(), Error>
Removes all bindings with the specified owner.
pub fn lookup_node_component(
&self,
name: impl AsRef<KanziStr>,
) -> Result<Option<Weak<NodeComponent>>, Error>
pub fn lookup_node_component( &self, name: impl AsRef<KanziStr>, ) -> Result<Option<Weak<NodeComponent>>, Error>
Returns a node component of specified type by looking it up with specified name. If name is not specified, then the first anonymous node component is returned.
pub fn get_node_component_iterator(
&self,
) -> Result<NodeComponentIterator, Error>
pub fn get_node_component_iterator( &self, ) -> Result<NodeComponentIterator, Error>
Gets the node component iterator.
pub fn get_node_components(&self) -> Result<Vec<Weak<NodeComponent>>, Error>
pub fn get_node_components(&self) -> Result<Vec<Weak<NodeComponent>>, Error>
Gets all node components.
pub fn get_change_flags(&self) -> Result<i32, Error>
pub fn get_change_flags(&self) -> Result<i32, Error>
Gets current change flags.
pub fn get_child_change_flags(&self) -> Result<i32, Error>
pub fn get_child_change_flags(&self) -> Result<i32, Error>
Gets current child change flags.
pub fn set_change_flag(&self, flag: i32) -> Result<(), Error>
pub fn set_change_flag(&self, flag: i32) -> Result<(), Error>
Sets a change flag.
pub fn clear_change_flag(&self, flag: i32) -> Result<(), Error>
pub fn clear_change_flag(&self, flag: i32) -> Result<(), Error>
Clears a change flag.
Methods from Deref<Target = Object>§
pub fn as_ptr(&self) -> *mut ObjectWrapper
pub fn as_wrapper(&self) -> &ObjectWrapper
pub fn as_object(&self) -> &Object
pub fn as_object(&self) -> &Object
Represents any type inheriting from Object as &Object.
This is useful for comparisions when PartialEq traits failed to compare objects of
different types.
let child = screen.get_child(0)?;
let parent = child.get_parent()?.into_error(ErrorKind::ObjectNotFound)?;
// assert_eq!(screen, parent); // <- Fails to compile!
assert_eq!(screen.as_object(), parent.as_object());pub fn get_native(&self) -> Result<NonNull<c_void>, Error>
pub fn get_native(&self) -> Result<NonNull<c_void>, Error>
Gets a pointer to the backing C++ instance.
pub fn get_property<T>(
&self,
property_type: &PropertyType<T>,
) -> Result<<T as VariantConstraint>::RetArg, Error>where
T: PropertyTypeConstraint,
pub fn get_property<T>(
&self,
property_type: &PropertyType<T>,
) -> Result<<T as VariantConstraint>::RetArg, Error>where
T: PropertyTypeConstraint,
Returns the current value of a property disregarding modifiers.
Base value is affected by the following inputs where the highest entry in the list determines the base value:
- Local value set with setProperty or loaded from kzb
- Value set by a style affecting the property.
- Value defined by class metadata.
Modifiers are not applied, the highest-priority base value is returned.
If no inputs to the property value can be established the system returns the value default value from property type metadata.
§Arguments
property_type- The property type identifying the property to retrieve.
§Returns
The evaluated property value.
pub fn get_optional_property<T>(
&self,
property_type: &PropertyType<T>,
) -> Result<Option<<T as VariantConstraint>::RetArg>, Error>where
T: PropertyTypeConstraint,
pub fn get_optional_property<T>(
&self,
property_type: &PropertyType<T>,
) -> Result<Option<<T as VariantConstraint>::RetArg>, Error>where
T: PropertyTypeConstraint,
Returns the current value of a property disregarding modifiers, but does not default to the value in property metadata if there are no inputs to the property value.
If there is no value sources, None is returned.
If no inputs to the property value can be established the system returns the value default value from property type metadata.
§Arguments
property_type- The property type identifying the property to retrieve.
§Returns
The evaluated property value.
pub fn set_property<T>(
&self,
property_type: &PropertyType<T>,
value: <T as VariantConstraint>::DataArg<'_>,
) -> Result<(), Error>where
T: PropertyTypeConstraint,
pub fn set_property<T>(
&self,
property_type: &PropertyType<T>,
value: <T as VariantConstraint>::DataArg<'_>,
) -> Result<(), Error>where
T: PropertyTypeConstraint,
Sets the local value of a property type.
pub fn has_value<T>(
&self,
property_type: &PropertyType<T>,
) -> Result<bool, Error>where
T: PropertyTypeConstraint,
pub fn has_value<T>(
&self,
property_type: &PropertyType<T>,
) -> Result<bool, Error>where
T: PropertyTypeConstraint,
Evaluates whether there are any inputs into the property value. Both value sources and modifiers are taken into account.
§Returns
Returns true if there are inputs into the property value, false otherwise.
pub fn remove_local_value<T>(
&self,
property_type: &PropertyType<T>,
) -> Result<(), Error>where
T: PropertyTypeConstraint,
pub fn remove_local_value<T>(
&self,
property_type: &PropertyType<T>,
) -> Result<(), Error>where
T: PropertyTypeConstraint,
Removes the local value associated with the property.
pub fn get_metaclass(&self) -> Result<Metaclass, Error>
pub fn get_metaclass(&self) -> Result<Metaclass, Error>
Returns the metaclass of the dynamic type of the object.
pub fn get_domain(&self) -> Result<Domain, Error>
pub fn get_domain(&self) -> Result<Domain, Error>
Returns the domain the object belongs to.
pub fn set_flag_keep_during_patching<T>(
&self,
property_type: &PropertyType<T>,
) -> Result<(), Error>where
T: PropertyTypeConstraint,
pub fn set_flag_keep_during_patching<T>(
&self,
property_type: &PropertyType<T>,
) -> Result<(), Error>where
T: PropertyTypeConstraint,
Sets the flag to indicate that the property was loaded from KZB.
pub fn debug_string(&self) -> Result<String, Error>
pub fn debug_string(&self) -> Result<String, Error>
Builds a string representation of the object intended for debugging purposes.