pub struct Label { /* private fields */ }Expand description
A node for rendering text using a TrueType font.
Implementations§
Source§impl Label
impl Label
Sourcepub fn set_alignment(&mut self, val: TextAlign)
pub fn set_alignment(&mut self, val: TextAlign)
Sets the text alignment setting.
Sourcepub fn get_alignment(&self) -> TextAlign
pub fn get_alignment(&self) -> TextAlign
Gets the text alignment setting.
Sourcepub fn set_alpha_ref(&mut self, val: f32)
pub fn set_alpha_ref(&mut self, val: f32)
Sets the alpha threshold value. Pixels with alpha values below this value will not be drawn.
Only works with label.effect = SpriteEffect::new("builtin:vs_sprite", "builtin:fs_spritealphatest").
Sourcepub fn get_alpha_ref(&self) -> f32
pub fn get_alpha_ref(&self) -> f32
Gets the alpha threshold value. Pixels with alpha values below this value will not be drawn.
Only works with label.effect = SpriteEffect::new("builtin:vs_sprite", "builtin:fs_spritealphatest").
Sourcepub fn set_text_width(&mut self, val: f32)
pub fn set_text_width(&mut self, val: f32)
Sets the width of the text used for text wrapping.
Set to Label::AutomaticWidth to disable wrapping.
Default is Label::AutomaticWidth.
Sourcepub fn get_text_width(&self) -> f32
pub fn get_text_width(&self) -> f32
Gets the width of the text used for text wrapping.
Set to Label::AutomaticWidth to disable wrapping.
Default is Label::AutomaticWidth.
Sourcepub fn set_spacing(&mut self, val: f32)
pub fn set_spacing(&mut self, val: f32)
Sets the gap in pixels between characters.
Sourcepub fn get_spacing(&self) -> f32
pub fn get_spacing(&self) -> f32
Gets the gap in pixels between characters.
Sourcepub fn set_line_gap(&mut self, val: f32)
pub fn set_line_gap(&mut self, val: f32)
Sets the gap in pixels between lines of text.
Sourcepub fn get_line_gap(&self) -> f32
pub fn get_line_gap(&self) -> f32
Gets the gap in pixels between lines of text.
Sourcepub fn set_outline_color(&mut self, val: &Color)
pub fn set_outline_color(&mut self, val: &Color)
Sets the color of the outline, only works with SDF label.
Sourcepub fn get_outline_color(&self) -> Color
pub fn get_outline_color(&self) -> Color
Gets the color of the outline, only works with SDF label.
Sourcepub fn set_outline_width(&mut self, val: f32)
pub fn set_outline_width(&mut self, val: f32)
Sets the width of the outline, only works with SDF label.
Sourcepub fn get_outline_width(&self) -> f32
pub fn get_outline_width(&self) -> f32
Gets the width of the outline, only works with SDF label.
Sourcepub fn set_smooth(&mut self, val: &Vec2)
pub fn set_smooth(&mut self, val: &Vec2)
Sets the smooth value of the text, only works with SDF label, default is (0.7, 0.7).
Sourcepub fn get_smooth(&self) -> Vec2
pub fn get_smooth(&self) -> Vec2
Gets the smooth value of the text, only works with SDF label, default is (0.7, 0.7).
Sourcepub fn set_blend_func(&mut self, val: BlendFunc)
pub fn set_blend_func(&mut self, val: BlendFunc)
Sets the blend function for the label.
Sourcepub fn get_blend_func(&self) -> BlendFunc
pub fn get_blend_func(&self) -> BlendFunc
Gets the blend function for the label.
Sourcepub fn set_depth_write(&mut self, val: bool)
pub fn set_depth_write(&mut self, val: bool)
Sets whether depth writing is enabled. (Default is false)
Sourcepub fn is_depth_write(&self) -> bool
pub fn is_depth_write(&self) -> bool
Gets whether depth writing is enabled. (Default is false)
Sourcepub fn set_batched(&mut self, val: bool)
pub fn set_batched(&mut self, val: bool)
Sets whether the label is using batched rendering.
When using batched rendering the label.get_character() function will no longer work, but it provides better rendering performance. Default is true.
Sourcepub fn is_batched(&self) -> bool
pub fn is_batched(&self) -> bool
Gets whether the label is using batched rendering.
When using batched rendering the label.get_character() function will no longer work, but it provides better rendering performance. Default is true.
Sourcepub fn set_effect(&mut self, val: &SpriteEffect)
pub fn set_effect(&mut self, val: &SpriteEffect)
Sets the sprite effect used to render the text.
Sourcepub fn get_effect(&self) -> SpriteEffect
pub fn get_effect(&self) -> SpriteEffect
Gets the sprite effect used to render the text.
Sourcepub fn get_character_count(&self) -> i32
pub fn get_character_count(&self) -> i32
Gets the number of characters in the label.
Sourcepub fn get_character(&mut self, index: i32) -> Option<Sprite>
pub fn get_character(&mut self, index: i32) -> Option<Sprite>
Sourcepub fn get_automatic_width() -> f32
pub fn get_automatic_width() -> f32
Gets the value to use for automatic width calculation
Sourcepub fn new(font_name: &str, font_size: i32, sdf: bool) -> Option<Label>
pub fn new(font_name: &str, font_size: i32, sdf: bool) -> Option<Label>
Creates a new Label object with the specified font name and font size.
§Arguments
font_name- The name of the font to use for the label. Can be font file path with or without file extension.font_size- The size of the font to use for the label.sdf- Whether to use SDF rendering or not. With SDF rendering, the outline feature will be enabled.
§Returns
Label- The new Label object.
Trait Implementations§
Source§impl INode for Label
impl INode for Label
Source§fn set_angle_x(&mut self, val: f32)
fn set_angle_x(&mut self, val: f32)
Source§fn get_angle_x(&self) -> f32
fn get_angle_x(&self) -> f32
Source§fn set_angle_y(&mut self, val: f32)
fn set_angle_y(&mut self, val: f32)
Source§fn get_angle_y(&self) -> f32
fn get_angle_y(&self) -> f32
Source§fn set_scale_x(&mut self, val: f32)
fn set_scale_x(&mut self, val: f32)
Source§fn get_scale_x(&self) -> f32
fn get_scale_x(&self) -> f32
Source§fn set_scale_y(&mut self, val: f32)
fn set_scale_y(&mut self, val: f32)
Source§fn get_scale_y(&self) -> f32
fn get_scale_y(&self) -> f32
Source§fn set_position(&mut self, val: &Vec2)
fn set_position(&mut self, val: &Vec2)
Source§fn get_position(&self) -> Vec2
fn get_position(&self) -> Vec2
Source§fn set_skew_x(&mut self, val: f32)
fn set_skew_x(&mut self, val: f32)
Source§fn get_skew_x(&self) -> f32
fn get_skew_x(&self) -> f32
Source§fn set_skew_y(&mut self, val: f32)
fn set_skew_y(&mut self, val: f32)
Source§fn get_skew_y(&self) -> f32
fn get_skew_y(&self) -> f32
Source§fn set_visible(&mut self, val: bool)
fn set_visible(&mut self, val: bool)
Source§fn is_visible(&self) -> bool
fn is_visible(&self) -> bool
Source§fn set_anchor(&mut self, val: &Vec2)
fn set_anchor(&mut self, val: &Vec2)
Source§fn get_anchor(&self) -> Vec2
fn get_anchor(&self) -> Vec2
Source§fn set_height(&mut self, val: f32)
fn set_height(&mut self, val: f32)
Source§fn get_height(&self) -> f32
fn get_height(&self) -> f32
Source§fn set_opacity(&mut self, val: f32)
fn set_opacity(&mut self, val: f32)
Source§fn get_opacity(&self) -> f32
fn get_opacity(&self) -> f32
Source§fn set_color3(&mut self, val: &Color3)
fn set_color3(&mut self, val: &Color3)
Source§fn get_color3(&self) -> Color3
fn get_color3(&self) -> Color3
Source§fn set_pass_opacity(&mut self, val: bool)
fn set_pass_opacity(&mut self, val: bool)
Source§fn is_pass_opacity(&self) -> bool
fn is_pass_opacity(&self) -> bool
Source§fn set_pass_color3(&mut self, val: bool)
fn set_pass_color3(&mut self, val: bool)
Source§fn is_pass_color3(&self) -> bool
fn is_pass_color3(&self) -> bool
Source§fn set_transform_target(&mut self, val: &dyn INode)
fn set_transform_target(&mut self, val: &dyn INode)
Source§fn get_transform_target(&self) -> Option<Node>
fn get_transform_target(&self) -> Option<Node>
Source§fn set_scheduler(&mut self, val: &Scheduler)
fn set_scheduler(&mut self, val: &Scheduler)
Source§fn get_scheduler(&self) -> Scheduler
fn get_scheduler(&self) -> Scheduler
Source§fn get_children(&self) -> Option<Array>
fn get_children(&self) -> Option<Array>
Source§fn get_parent(&self) -> Option<Node>
fn get_parent(&self) -> Option<Node>
Source§fn is_running(&self) -> bool
fn is_running(&self) -> bool
Source§fn is_scheduled(&self) -> bool
fn is_scheduled(&self) -> bool
Source§fn get_action_count(&self) -> i32
fn get_action_count(&self) -> i32
Source§fn get_data(&self) -> Dictionary
fn get_data(&self) -> Dictionary
Source§fn set_touch_enabled(&mut self, val: bool)
fn set_touch_enabled(&mut self, val: bool)
Source§fn is_touch_enabled(&self) -> bool
fn is_touch_enabled(&self) -> bool
Source§fn set_swallow_touches(&mut self, val: bool)
fn set_swallow_touches(&mut self, val: bool)
Source§fn is_swallow_touches(&self) -> bool
fn is_swallow_touches(&self) -> bool
Source§fn set_swallow_mouse_wheel(&mut self, val: bool)
fn set_swallow_mouse_wheel(&mut self, val: bool)
Source§fn is_swallow_mouse_wheel(&self) -> bool
fn is_swallow_mouse_wheel(&self) -> bool
Source§fn set_keyboard_enabled(&mut self, val: bool)
fn set_keyboard_enabled(&mut self, val: bool)
Source§fn is_keyboard_enabled(&self) -> bool
fn is_keyboard_enabled(&self) -> bool
Source§fn set_controller_enabled(&mut self, val: bool)
fn set_controller_enabled(&mut self, val: bool)
Source§fn is_controller_enabled(&self) -> bool
fn is_controller_enabled(&self) -> bool
Source§fn set_render_group(&mut self, val: bool)
fn set_render_group(&mut self, val: bool)
Source§fn is_render_group(&self) -> bool
fn is_render_group(&self) -> bool
Source§fn set_show_debug(&mut self, val: bool)
fn set_show_debug(&mut self, val: bool)
Source§fn is_show_debug(&self) -> bool
fn is_show_debug(&self) -> bool
Source§fn set_render_order(&mut self, val: i32)
fn set_render_order(&mut self, val: i32)
Source§fn get_render_order(&self) -> i32
fn get_render_order(&self) -> i32
Source§fn add_child_with_order_tag(&mut self, child: &dyn INode, order: i32, tag: &str)
fn add_child_with_order_tag(&mut self, child: &dyn INode, order: i32, tag: &str)
Source§fn add_child_with_order(&mut self, child: &dyn INode, order: i32)
fn add_child_with_order(&mut self, child: &dyn INode, order: i32)
Source§fn add_to_with_order_tag(
&mut self,
parent: &dyn INode,
order: i32,
tag: &str,
) -> Node
fn add_to_with_order_tag( &mut self, parent: &dyn INode, order: i32, tag: &str, ) -> Node
Source§fn add_to_with_order(&mut self, parent: &dyn INode, order: i32) -> Node
fn add_to_with_order(&mut self, parent: &dyn INode, order: i32) -> Node
Source§fn add_to(&mut self, parent: &dyn INode) -> Node
fn add_to(&mut self, parent: &dyn INode) -> Node
Source§fn remove_child(&mut self, child: &dyn INode, cleanup: bool)
fn remove_child(&mut self, child: &dyn INode, cleanup: bool)
Source§fn remove_child_by_tag(&mut self, tag: &str, cleanup: bool)
fn remove_child_by_tag(&mut self, tag: &str, cleanup: bool)
Source§fn remove_all_children(&mut self, cleanup: bool)
fn remove_all_children(&mut self, cleanup: bool)
Source§fn remove_from_parent(&mut self, cleanup: bool)
fn remove_from_parent(&mut self, cleanup: bool)
Source§fn move_to_parent(&mut self, parent: &dyn INode)
fn move_to_parent(&mut self, parent: &dyn INode)
Source§fn schedule(&mut self, update_func: Box<dyn FnMut(f64) -> bool>)
fn schedule(&mut self, update_func: Box<dyn FnMut(f64) -> bool>)
Source§fn unschedule(&mut self)
fn unschedule(&mut self)
Source§fn convert_to_node_space(&mut self, world_point: &Vec2) -> Vec2
fn convert_to_node_space(&mut self, world_point: &Vec2) -> Vec2
Source§fn convert_to_world_space(&mut self, node_point: &Vec2) -> Vec2
fn convert_to_world_space(&mut self, node_point: &Vec2) -> Vec2
Source§fn convert_to_window_space(
&mut self,
node_point: &Vec2,
callback: Box<dyn FnMut(&Vec2)>,
)
fn convert_to_window_space( &mut self, node_point: &Vec2, callback: Box<dyn FnMut(&Vec2)>, )
Source§fn each_child(
&mut self,
visitor_func: Box<dyn FnMut(&dyn INode) -> bool>,
) -> bool
fn each_child( &mut self, visitor_func: Box<dyn FnMut(&dyn INode) -> bool>, ) -> bool
Source§fn traverse(&mut self, visitor_func: Box<dyn FnMut(&dyn INode) -> bool>) -> bool
fn traverse(&mut self, visitor_func: Box<dyn FnMut(&dyn INode) -> bool>) -> bool
TraverseEnabled flag are not visited. Read more