Struct TextWidget

Source
pub struct TextWidget { /* private fields */ }
Expand description

Text Widget.

Trait Implementations§

Source§

impl Default for TextWidget

Source§

fn default() -> TextWidget

Returns the “default value” for a type. Read more
Source§

impl Widget for TextWidget

Implementation for drawing a TextWidget, with the Widget trait objects applied.

Source§

fn draw( &mut self, c: &mut Canvas<Window>, t: &mut TextureCache, ) -> Option<&Texture>

This is the draw implementation of the TextWidget. It uses the following properties:

  • PROPERTY_MAIN_COLOR: the Color of the body of the Widget
  • PROPERTY_BORDER_WIDTH: the width of the border to draw
  • PROPERTY_BORDER_COLOR: the Color of the border.
  • PROPERTY_FONT_COLOR: the color of the font
  • PROPERTY_FONT_NAME: full or relative path to the font file to use to render the text
  • PROPERTY_FONT_SIZE: the size in points of the font
  • PROPERTY_FONT_STYLE: the FontStyle to apply to the font
  • PROPERTY_TEXT_JUSTIFICATION: The TEXT_JUSTIFY_* constant to use to position the text inside the Widget
  • PROPERTY_TEXT: String containing the text to display
Source§

fn properties(&mut self) -> &mut WidgetProperties

This provides access to the WidgetProperties set for a Widget. These must be defined in the structure of the Widget, as they allow for direct manipulation of the properties.
Source§

fn widget_name(&self) -> String

Returns the name of the type of Widget. Must be implemented by Widgets, as this helps with (de)serialization.
Source§

fn handle_event(&mut self, _e: PushrodEvent) -> Option<PushrodEvent>

Handles a PushrodEvent sent to the Widget that would also be sent to the application. If any PushrodEvents trigger a custom Widget-based event, this function can intercept the incoming event, and issue one of its own. If the function returns no events, a None can be returned, otherwise a Some(PushrodEvent) should be returned. If this function returns an event, that event will be sent on to the application as soon as it has been generated.
Source§

fn build_layout(&mut self) -> Vec<Box<dyn Widget>>

This is called when PROPERTY_NEEDS_LAYOUT is enabled in properties. When a layout is required to be built, this function is called, returning the list of Widgets that are to be added. If no Widgets are to be added, an empty list is valid to return here. Otherwise, the list of Widgets that this parent Widget controls are returned as a list here.
Source§

fn constructed_layout_ids(&mut self, _ids: Vec<u32>)

After a build_layout call has been completed, the list of IDs that were added to the display list are returned in the same order in from build_layout. The Widget that created these IDs should then store them here in an array, so that they can be referenced when interacted with.
Source§

fn invalidate(&mut self)

Set the invalidation key for this Widget, indicating that the TextureCache needs to be redrawn.
Source§

fn invalidated(&mut self) -> bool

Flag indicating whether or not the draw method needs to be called for this Widget so that its TextureCache is refreshed.
Source§

fn hide(&mut self)

Sets the Widget to hidden state. If not overridden, this function will only hide the current Widget, not its children. To do that, you will need to use the set_hidden function in WidgetCache, which walks the tree.
Source§

fn show(&mut self)

Sets the Widget to visible state. If not overridden, this function will only show the current Widget, not its children. To do that, you’ll need to use the set_hidden function in WidgetCache, which walks the tree.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.