[−][src]Struct pushrod::widget::text_widget::TextWidget
This is the TextWidget, which draws a line of text on the screen. This structure contains
no accessable objects, they are all internal to TextWidget's implementation.
Methods
impl TextWidget[src]
Implementation of the constructor for the TextWidget. Creates a new text object to be
displayed on the screen, given a font name, font size, and text message.
pub fn new(
factory: GfxFactory,
font_name: String,
text: String,
font_size: u32
) -> Self[src]
factory: GfxFactory,
font_name: String,
text: String,
font_size: u32
) -> Self
Creates a new TextWidget object, requiring the current PistonWindow's factory object
(which can be cloned), the name of the font (filename in the assets directory), the
text to display, and the font size in which to use.
pub fn set_text_color(&mut self, color: Color)[src]
Sets the color of the text for this Widget.
pub fn get_text_color(&mut self) -> Color[src]
Retrieves the color of the text for this Widget.
Defaults to black if not set.
pub fn set_text(&mut self, text: String)[src]
Changes the text, redraws after change.
pub fn draw_text(&mut self, c: Context, g: &mut G2d)[src]
Function to draw the text. Generates a context transformation to display the text based on the point of origin's X and Y coordinates. Since the text is drawn upwards from the point of origin, the starting point is the lower left-hand corner of the widget. (This may change based on text justification, and other optional padding, once padding is introduced.)
Trait Implementations
impl Widget for TextWidget[src]
Implementation of the BoxWidget object with the Widget traits implemented.
This implementation is similar to the BaseWidget, but incorporates a drawable box inside
the widget. Base widget is the BaseWidget.
This is basically just a box with a fill color. Use this to draw other things like buttons, text widgets, and so on, if you need anything with a drawable border.
Example usage:
let mut window: PistonWindow = WindowSettings::new("Pushrod Window", [800, 600]) .opengl(OpenGL::V3_2) .resizable(false) .build() .unwrap_or_else(|error| panic!("Failed to build PistonWindow: {}", error)); let factory: GfxFactory = window.factory.clone(); let mut prod: Pushrod = Pushrod::new(window); let mut text_widget = TextWidget::new( factory, "OpenSans-Regular.ttf".to_string(), "Welcome to Pushrod!".to_string(), 32, ); text_widget.set_origin(8, 8); text_widget.set_size(400, 40); text_widget.set_color([0.75, 0.75, 1.0, 1.0]); text_widget.set_text_color([0.0, 0.0, 1.0, 1.0]); prod.widget_store.add_widget(Box::new(text_widget));
fn config(&mut self) -> &mut Configurable[src]
fn mouse_entered(&mut self, widget_id: i32)[src]
fn mouse_exited(&mut self, widget_id: i32)[src]
fn mouse_scrolled(&mut self, widget_id: i32, point: Point)[src]
fn draw(&mut self, c: Context, g: &mut G2d)[src]
Draws the contents of the widget.
fn invalidate(&mut self)[src]
Indicates that a widget needs to be redrawn/refreshed.
fn clear_invalidate(&mut self)[src]
Clears the invalidation flag.
fn is_invalidated(&mut self) -> bool[src]
Checks to see whether or not the widget needs to be redrawn/refreshed.
fn set_origin(&mut self, x: i32, y: i32)[src]
Sets the Point of origin for this widget, given the X and Y origin points. Invalidates the widget afterward.
fn get_origin(&mut self) -> Point[src]
Retrieves the Point of origin for this object. Defaults to origin (0, 0) if not set. Read more
fn set_size(&mut self, w: i32, h: i32)[src]
Sets the Size for this widget, given a width and height. Invalidates the widget afterward.
fn get_size(&mut self) -> Size[src]
Retrieves the Size bounds for this widget. Defaults to size (0, 0) if not set. Read more
fn set_color(&mut self, color: Color)[src]
Sets the color for this widget. Invalidates the widget afterward.
fn get_color(&mut self) -> Color[src]
Retrieves the color of this widget. Defaults to white color [1.0; 4] if not set. Read more
fn set_autoclip(&mut self, clip: bool)[src]
fn get_autoclip(&mut self) -> bool[src]
Auto Trait Implementations
impl !Send for TextWidget
impl !Sync for TextWidget
Blanket Implementations
impl<T> From for T[src]
impl<T, U> Into for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>, [src]
U: Into<T>,
type Error = !
try_from)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T> Borrow for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T, U> TryInto for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,
Sets value as a parameter of self.