pub struct UiNode(pub Box<dyn Control<Target = Widget>>);
Expand description
UI node is a type-agnostic wrapper for any widget type. Internally, it is just a trait object
that provides common widget interface. Its main use is to reduce code bloat (no need to type
Box<dyn Control>
everywhere, just UiNode
) and to provide some useful methods such as type
casting, component querying, etc. You could also be interested in Control
docs, since it
contains all the interesting stuff and detailed description for each method.
Tuple Fields§
§0: Box<dyn Control<Target = Widget>>
Implementations§
Source§impl UiNode
impl UiNode
Sourcepub fn new<T>(widget: T) -> UiNodewhere
T: Control,
pub fn new<T>(widget: T) -> UiNodewhere
T: Control,
Creates a new UI node from any object that implements Control
trait. Its main use
is to finish widget creation like so:
#[derive(Clone, Visit, Reflect, Debug, ComponentProvider)]
struct MyWidget {
widget: Widget,
}
struct MyWidgetBuilder {
widget_builder: WidgetBuilder,
}
impl MyWidgetBuilder {
pub fn build(self, ctx: &mut BuildContext) -> Handle<UiNode> {
let my_widget = MyWidget {
widget: self.widget_builder.build(ctx),
};
// Wrap your widget in the type-agnostic wrapper so it can be placed in the UI.
let node = UiNode::new(my_widget);
ctx.add_node(node)
}
}
Sourcepub fn cast<T>(&self) -> Option<&T>where
T: Control,
pub fn cast<T>(&self) -> Option<&T>where
T: Control,
Tries to perform direct downcasting to a particular widget type. It is just a simple wrapper
for Any::downcast_ref
.
Sourcepub fn cast_mut<T>(&mut self) -> Option<&mut T>where
T: Control,
pub fn cast_mut<T>(&mut self) -> Option<&mut T>where
T: Control,
Tries to perform direct downcasting to a particular widget type. It is just a simple wrapper
for Any::downcast_mut
.
Sourcepub fn query_component<T>(&self) -> Option<&T>where
T: 'static,
pub fn query_component<T>(&self) -> Option<&T>where
T: 'static,
Tries to fetch a component of the given type T
. At very basis it mimics Self::cast
behaviour, but
also allows you to fetch components of other types as well. For example, your widget may be built on
top of existing one (via composition) and you have it as a field inside your widget. In this case, you
can fetch it by using this method with the appropriate type. See docs for fyrox_core::type_traits::ComponentProvider::query_component_ref
for more info.
Sourcepub fn has_component<T>(&self) -> boolwhere
T: 'static,
pub fn has_component<T>(&self) -> boolwhere
T: 'static,
This method checks if the widget has a component of the given type T
. Internally, it queries the component
of the given type and checks if it exists.
Trait Implementations§
Source§impl ComponentProvider for UiNode
impl ComponentProvider for UiNode
Source§impl ConstructorProvider<UiNode, UserInterface> for AlphaBar
impl ConstructorProvider<UiNode, UserInterface> for AlphaBar
Source§impl<T> ConstructorProvider<UiNode, UserInterface> for BitField<T>where
T: BitContainer,
impl<T> ConstructorProvider<UiNode, UserInterface> for BitField<T>where
T: BitContainer,
Source§impl ConstructorProvider<UiNode, UserInterface> for Border
impl ConstructorProvider<UiNode, UserInterface> for Border
Source§impl ConstructorProvider<UiNode, UserInterface> for Button
impl ConstructorProvider<UiNode, UserInterface> for Button
Source§impl ConstructorProvider<UiNode, UserInterface> for Canvas
impl ConstructorProvider<UiNode, UserInterface> for Canvas
Source§impl ConstructorProvider<UiNode, UserInterface> for CheckBox
impl ConstructorProvider<UiNode, UserInterface> for CheckBox
Source§impl ConstructorProvider<UiNode, UserInterface> for ColorField
impl ConstructorProvider<UiNode, UserInterface> for ColorField
Source§impl ConstructorProvider<UiNode, UserInterface> for ColorPicker
impl ConstructorProvider<UiNode, UserInterface> for ColorPicker
Source§impl ConstructorProvider<UiNode, UserInterface> for ColorPoint
impl ConstructorProvider<UiNode, UserInterface> for ColorPoint
Source§impl ConstructorProvider<UiNode, UserInterface> for ContextMenu
impl ConstructorProvider<UiNode, UserInterface> for ContextMenu
Source§impl ConstructorProvider<UiNode, UserInterface> for CurveEditor
impl ConstructorProvider<UiNode, UserInterface> for CurveEditor
Source§impl ConstructorProvider<UiNode, UserInterface> for Decorator
impl ConstructorProvider<UiNode, UserInterface> for Decorator
Source§impl ConstructorProvider<UiNode, UserInterface> for Expander
impl ConstructorProvider<UiNode, UserInterface> for Expander
Source§impl ConstructorProvider<UiNode, UserInterface> for FileBrowser
impl ConstructorProvider<UiNode, UserInterface> for FileBrowser
Source§impl ConstructorProvider<UiNode, UserInterface> for Grid
impl ConstructorProvider<UiNode, UserInterface> for Grid
Source§impl ConstructorProvider<UiNode, UserInterface> for HueBar
impl ConstructorProvider<UiNode, UserInterface> for HueBar
Source§impl ConstructorProvider<UiNode, UserInterface> for Image
impl ConstructorProvider<UiNode, UserInterface> for Image
Source§impl ConstructorProvider<UiNode, UserInterface> for Inspector
impl ConstructorProvider<UiNode, UserInterface> for Inspector
Source§impl ConstructorProvider<UiNode, UserInterface> for ListView
impl ConstructorProvider<UiNode, UserInterface> for ListView
Source§impl ConstructorProvider<UiNode, UserInterface> for Menu
impl ConstructorProvider<UiNode, UserInterface> for Menu
Source§impl ConstructorProvider<UiNode, UserInterface> for MenuItem
impl ConstructorProvider<UiNode, UserInterface> for MenuItem
Source§impl ConstructorProvider<UiNode, UserInterface> for MessageBox
impl ConstructorProvider<UiNode, UserInterface> for MessageBox
Source§impl ConstructorProvider<UiNode, UserInterface> for NinePatch
impl ConstructorProvider<UiNode, UserInterface> for NinePatch
Source§impl<T> ConstructorProvider<UiNode, UserInterface> for NumericUpDown<T>where
T: NumericType,
impl<T> ConstructorProvider<UiNode, UserInterface> for NumericUpDown<T>where
T: NumericType,
Source§impl ConstructorProvider<UiNode, UserInterface> for PathEditor
impl ConstructorProvider<UiNode, UserInterface> for PathEditor
Source§impl ConstructorProvider<UiNode, UserInterface> for Popup
impl ConstructorProvider<UiNode, UserInterface> for Popup
Source§impl ConstructorProvider<UiNode, UserInterface> for ProgressBar
impl ConstructorProvider<UiNode, UserInterface> for ProgressBar
Source§impl<T> ConstructorProvider<UiNode, UserInterface> for RangeEditor<T>where
T: NumericType,
impl<T> ConstructorProvider<UiNode, UserInterface> for RangeEditor<T>where
T: NumericType,
Source§impl<T> ConstructorProvider<UiNode, UserInterface> for RectEditor<T>where
T: NumericType,
impl<T> ConstructorProvider<UiNode, UserInterface> for RectEditor<T>where
T: NumericType,
Source§impl ConstructorProvider<UiNode, UserInterface> for Screen
impl ConstructorProvider<UiNode, UserInterface> for Screen
Source§impl ConstructorProvider<UiNode, UserInterface> for ScrollBar
impl ConstructorProvider<UiNode, UserInterface> for ScrollBar
Source§impl ConstructorProvider<UiNode, UserInterface> for ScrollPanel
impl ConstructorProvider<UiNode, UserInterface> for ScrollPanel
Source§impl ConstructorProvider<UiNode, UserInterface> for SearchBar
impl ConstructorProvider<UiNode, UserInterface> for SearchBar
Source§impl ConstructorProvider<UiNode, UserInterface> for Selector
impl ConstructorProvider<UiNode, UserInterface> for Selector
Source§impl ConstructorProvider<UiNode, UserInterface> for StackPanel
impl ConstructorProvider<UiNode, UserInterface> for StackPanel
Source§impl ConstructorProvider<UiNode, UserInterface> for TabControl
impl ConstructorProvider<UiNode, UserInterface> for TabControl
Source§impl ConstructorProvider<UiNode, UserInterface> for Text
impl ConstructorProvider<UiNode, UserInterface> for Text
Source§impl ConstructorProvider<UiNode, UserInterface> for TextBox
impl ConstructorProvider<UiNode, UserInterface> for TextBox
Source§impl ConstructorProvider<UiNode, UserInterface> for Thumb
impl ConstructorProvider<UiNode, UserInterface> for Thumb
Source§impl ConstructorProvider<UiNode, UserInterface> for Tile
impl ConstructorProvider<UiNode, UserInterface> for Tile
Source§impl ConstructorProvider<UiNode, UserInterface> for Tree
impl ConstructorProvider<UiNode, UserInterface> for Tree
Source§impl ConstructorProvider<UiNode, UserInterface> for TreeRoot
impl ConstructorProvider<UiNode, UserInterface> for TreeRoot
Source§impl ConstructorProvider<UiNode, UserInterface> for UuidEditor
impl ConstructorProvider<UiNode, UserInterface> for UuidEditor
Source§impl<T, const D: usize> ConstructorProvider<UiNode, UserInterface> for VecEditor<T, D>where
T: NumericType,
impl<T, const D: usize> ConstructorProvider<UiNode, UserInterface> for VecEditor<T, D>where
T: NumericType,
Source§impl ConstructorProvider<UiNode, UserInterface> for VectorImage
impl ConstructorProvider<UiNode, UserInterface> for VectorImage
Source§impl ConstructorProvider<UiNode, UserInterface> for Window
impl ConstructorProvider<UiNode, UserInterface> for Window
Source§impl ConstructorProvider<UiNode, UserInterface> for WrapPanel
impl ConstructorProvider<UiNode, UserInterface> for WrapPanel
Source§impl NameProvider for UiNode
impl NameProvider for UiNode
Source§impl Reflect for UiNode
impl Reflect for UiNode
fn source_path() -> &'static str
fn type_name(&self) -> &'static str
fn doc(&self) -> &'static str
Source§fn assembly_name(&self) -> &'static str
fn assembly_name(&self) -> &'static str
#[derive(Reflect)]
) to ensure that this method will return correct assembly
name. In other words - there’s no guarantee, that any implementation other than proc-macro
will return a correct name of the assembly. Alternatively, you can use env!("CARGO_PKG_NAME")
as an implementation.Source§fn type_assembly_name() -> &'static str
fn type_assembly_name() -> &'static str
#[derive(Reflect)]
) to ensure that this method will return correct assembly
name. In other words - there’s no guarantee, that any implementation other than proc-macro
will return a correct name of the assembly. Alternatively, you can use env!("CARGO_PKG_NAME")
as an implementation.fn fields_info(&self, func: &mut dyn FnMut(&[FieldInfo<'_, '_>]))
fn into_any(self: Box<UiNode>) -> Box<dyn Any>
fn as_any(&self, func: &mut dyn FnMut(&(dyn Any + 'static)))
fn as_any_mut(&mut self, func: &mut dyn FnMut(&mut (dyn Any + 'static)))
fn as_reflect(&self, func: &mut dyn FnMut(&(dyn Reflect + 'static)))
fn as_reflect_mut(&mut self, func: &mut dyn FnMut(&mut (dyn Reflect + 'static)))
fn set( &mut self, value: Box<dyn Reflect>, ) -> Result<Box<dyn Reflect>, Box<dyn Reflect>>
Source§fn set_field(
&mut self,
field: &str,
value: Box<dyn Reflect>,
func: &mut dyn FnMut(Result<Box<dyn Reflect>, Box<dyn Reflect>>),
)
fn set_field( &mut self, field: &str, value: Box<dyn Reflect>, func: &mut dyn FnMut(Result<Box<dyn Reflect>, Box<dyn Reflect>>), )
#[reflect(setter = ..)]
or falls back to
Reflect::field_mut
fn fields(&self, func: &mut dyn FnMut(&[&(dyn Reflect + 'static)]))
fn fields_mut( &mut self, func: &mut dyn FnMut(&mut [&mut (dyn Reflect + 'static)]), )
fn field( &self, name: &str, func: &mut dyn FnMut(Option<&(dyn Reflect + 'static)>), )
fn field_mut( &mut self, name: &str, func: &mut dyn FnMut(Option<&mut (dyn Reflect + 'static)>), )
fn as_array(&self, func: &mut dyn FnMut(Option<&(dyn ReflectArray + 'static)>))
fn as_array_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectArray + 'static)>), )
fn as_list(&self, func: &mut dyn FnMut(Option<&(dyn ReflectList + 'static)>))
fn as_list_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectList + 'static)>), )
fn as_inheritable_variable( &self, func: &mut dyn FnMut(Option<&(dyn ReflectInheritableVariable + 'static)>), )
fn as_inheritable_variable_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectInheritableVariable + 'static)>), )
fn as_hash_map( &self, func: &mut dyn FnMut(Option<&(dyn ReflectHashMap + 'static)>), )
fn as_hash_map_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectHashMap + 'static)>), )
Source§impl SceneGraphNode for UiNode
impl SceneGraphNode for UiNode
type Base = Widget
type SceneGraph = UserInterface
type ResourceData = UserInterface
fn base(&self) -> &<UiNode as SceneGraphNode>::Base
fn set_base(&mut self, base: <UiNode as SceneGraphNode>::Base)
fn is_resource_instance_root(&self) -> bool
fn original_handle_in_resource(&self) -> Handle<UiNode>
fn set_original_handle_in_resource(&mut self, handle: Handle<UiNode>)
fn resource(&self) -> Option<Resource<<UiNode as SceneGraphNode>::ResourceData>>
fn self_handle(&self) -> Handle<UiNode>
fn parent(&self) -> Handle<UiNode>
fn children(&self) -> &[Handle<UiNode>]
fn children_mut(&mut self) -> &mut [Handle<UiNode>]
Source§fn swap_child_position(
&mut self,
child: Handle<Self>,
pos: usize,
) -> Option<usize>
fn swap_child_position( &mut self, child: Handle<Self>, pos: usize, ) -> Option<usize>
child
handle to the given position pos
, by swapping positions.fn set_child_position( &mut self, child: Handle<Self>, dest_pos: usize, ) -> Option<usize>
fn child_position(&self, child: Handle<Self>) -> Option<usize>
fn has_child(&self, child: Handle<Self>) -> bool
fn revert_inheritable_property( &mut self, path: &str, ) -> Option<Box<dyn Reflect>>
Source§fn component_ref<T>(&self) -> Option<&T>where
T: Any,
fn component_ref<T>(&self) -> Option<&T>where
T: Any,
Source§fn component_mut<T>(&mut self) -> Option<&mut T>where
T: Any,
fn component_mut<T>(&mut self) -> Option<&mut T>where
T: Any,
Source§fn has_component<T>(&self) -> boolwhere
T: Any,
fn has_component<T>(&self) -> boolwhere
T: Any,
Auto Trait Implementations§
impl Freeze for UiNode
impl !RefUnwindSafe for UiNode
impl Send for UiNode
impl !Sync for UiNode
impl Unpin for UiNode
impl !UnwindSafe for UiNode
Blanket Implementations§
Source§impl<T> AsyncTaskResult for T
impl<T> AsyncTaskResult for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Any
. Could be used to downcast a trait object
to a particular type.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Any
. Could be used to downcast a trait object
to a particular type.fn into_any(self: Box<T>) -> Box<dyn Any>
Source§impl<T> FieldValue for Twhere
T: 'static,
impl<T> FieldValue for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ReflectBase for Twhere
T: Reflect,
impl<T> ReflectBase for Twhere
T: Reflect,
fn as_any_raw(&self) -> &(dyn Any + 'static)
fn as_any_raw_mut(&mut self) -> &mut (dyn Any + 'static)
Source§impl<T> ResolvePath for Twhere
T: Reflect,
impl<T> ResolvePath for Twhere
T: Reflect,
fn resolve_path<'p>( &self, path: &'p str, func: &mut dyn FnMut(Result<&(dyn Reflect + 'static), ReflectPathError<'p>>), )
fn resolve_path_mut<'p>( &mut self, path: &'p str, func: &mut dyn FnMut(Result<&mut (dyn Reflect + 'static), ReflectPathError<'p>>), )
fn get_resolve_path<'p, T>(
&self,
path: &'p str,
func: &mut dyn FnMut(Result<&T, ReflectPathError<'p>>),
)where
T: Reflect,
fn get_resolve_path_mut<'p, T>(
&mut self,
path: &'p str,
func: &mut dyn FnMut(Result<&mut T, ReflectPathError<'p>>),
)where
T: Reflect,
Source§impl<T> ScriptMessagePayload for T
impl<T> ScriptMessagePayload for T
Source§fn as_any_ref(&self) -> &(dyn Any + 'static)
fn as_any_ref(&self) -> &(dyn Any + 'static)
self
as &dyn Any
Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
self
as &dyn Any
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.