pub type Text<'a, Theme = Theme, Renderer = Renderer> = Text<'a, Theme, Renderer>;
Expand description
A bunch of text.
§Example
use iced::widget::text;
use iced::color;
enum Message {
// ...
}
fn view(state: &State) -> Element<'_, Message> {
text("Hello, this is iced!")
.size(20)
.color(color!(0x0000ff))
.into()
}
Aliased Type§
struct Text<'a, Theme = Theme, Renderer = Renderer> { /* private fields */ }
Implementations
source§impl<'a, Theme, Renderer> Text<'a, Theme, Renderer>
impl<'a, Theme, Renderer> Text<'a, Theme, Renderer>
sourcepub fn new(fragment: impl IntoFragment<'a>) -> Text<'a, Theme, Renderer>
pub fn new(fragment: impl IntoFragment<'a>) -> Text<'a, Theme, Renderer>
Create a new fragment of Text
with the given contents.
sourcepub fn size(self, size: impl Into<Pixels>) -> Text<'a, Theme, Renderer>
pub fn size(self, size: impl Into<Pixels>) -> Text<'a, Theme, Renderer>
Sets the size of the Text
.
sourcepub fn line_height(
self,
line_height: impl Into<LineHeight>,
) -> Text<'a, Theme, Renderer>
pub fn line_height( self, line_height: impl Into<LineHeight>, ) -> Text<'a, Theme, Renderer>
Sets the LineHeight
of the Text
.
sourcepub fn font(
self,
font: impl Into<<Renderer as Renderer>::Font>,
) -> Text<'a, Theme, Renderer>
pub fn font( self, font: impl Into<<Renderer as Renderer>::Font>, ) -> Text<'a, Theme, Renderer>
sourcepub fn width(self, width: impl Into<Length>) -> Text<'a, Theme, Renderer>
pub fn width(self, width: impl Into<Length>) -> Text<'a, Theme, Renderer>
Sets the width of the Text
boundaries.
sourcepub fn height(self, height: impl Into<Length>) -> Text<'a, Theme, Renderer>
pub fn height(self, height: impl Into<Length>) -> Text<'a, Theme, Renderer>
Sets the height of the Text
boundaries.
sourcepub fn center(self) -> Text<'a, Theme, Renderer>
pub fn center(self) -> Text<'a, Theme, Renderer>
Centers the Text
, both horizontally and vertically.
sourcepub fn align_x(
self,
alignment: impl Into<Horizontal>,
) -> Text<'a, Theme, Renderer>
pub fn align_x( self, alignment: impl Into<Horizontal>, ) -> Text<'a, Theme, Renderer>
Sets the alignment::Horizontal
of the Text
.
sourcepub fn align_y(
self,
alignment: impl Into<Vertical>,
) -> Text<'a, Theme, Renderer>
pub fn align_y( self, alignment: impl Into<Vertical>, ) -> Text<'a, Theme, Renderer>
Sets the alignment::Vertical
of the Text
.
sourcepub fn style(
self,
style: impl Fn(&Theme) -> Style + 'a,
) -> Text<'a, Theme, Renderer>
pub fn style( self, style: impl Fn(&Theme) -> Style + 'a, ) -> Text<'a, Theme, Renderer>
Sets the style of the Text
.
Trait Implementations
source§impl<'a, Message, Theme, Renderer> Widget<Message, Theme, Renderer> for Text<'a, Theme, Renderer>
impl<'a, Message, Theme, Renderer> Widget<Message, Theme, Renderer> for Text<'a, Theme, Renderer>
source§fn draw(
&self,
tree: &Tree,
renderer: &mut Renderer,
theme: &Theme,
defaults: &Style,
layout: Layout<'_>,
_cursor_position: Cursor,
viewport: &Rectangle,
)
fn draw( &self, tree: &Tree, renderer: &mut Renderer, theme: &Theme, defaults: &Style, layout: Layout<'_>, _cursor_position: Cursor, viewport: &Rectangle, )
Draws the
Widget
using the associated Renderer
.source§fn a11y_nodes(&self, layout: Layout<'_>, _state: &Tree, _: Cursor) -> A11yTree
fn a11y_nodes(&self, layout: Layout<'_>, _state: &Tree, _: Cursor) -> A11yTree
get the a11y nodes for the widget and its children
source§fn set_id(&mut self, id: Id)
fn set_id(&mut self, id: Id)
Sets the id of the widget
This may be called while diffing the widget tree
source§fn operate(
&self,
_state: &mut Tree,
_layout: Layout<'_>,
_renderer: &Renderer,
_operation: &mut dyn Operation,
)
fn operate( &self, _state: &mut Tree, _layout: Layout<'_>, _renderer: &Renderer, _operation: &mut dyn Operation, )
source§fn on_event(
&mut self,
_state: &mut Tree,
_event: Event,
_layout: Layout<'_>,
_cursor: Cursor,
_renderer: &Renderer,
_clipboard: &mut dyn Clipboard,
_shell: &mut Shell<'_, Message>,
_viewport: &Rectangle,
) -> Status
fn on_event( &mut self, _state: &mut Tree, _event: Event, _layout: Layout<'_>, _cursor: Cursor, _renderer: &Renderer, _clipboard: &mut dyn Clipboard, _shell: &mut Shell<'_, Message>, _viewport: &Rectangle, ) -> Status
source§fn mouse_interaction(
&self,
_state: &Tree,
_layout: Layout<'_>,
_cursor: Cursor,
_viewport: &Rectangle,
_renderer: &Renderer,
) -> Interaction
fn mouse_interaction( &self, _state: &Tree, _layout: Layout<'_>, _cursor: Cursor, _viewport: &Rectangle, _renderer: &Renderer, ) -> Interaction
source§fn overlay<'a>(
&'a mut self,
_state: &'a mut Tree,
_layout: Layout<'_>,
_renderer: &Renderer,
_translation: Vector,
) -> Option<Element<'a, Message, Theme, Renderer>>
fn overlay<'a>( &'a mut self, _state: &'a mut Tree, _layout: Layout<'_>, _renderer: &Renderer, _translation: Vector, ) -> Option<Element<'a, Message, Theme, Renderer>>
Returns the overlay of the
Widget
, if there is any.source§fn drag_destinations(
&self,
_state: &Tree,
_layout: Layout<'_>,
_renderer: &Renderer,
_dnd_rectangles: &mut DndDestinationRectangles,
)
fn drag_destinations( &self, _state: &Tree, _layout: Layout<'_>, _renderer: &Renderer, _dnd_rectangles: &mut DndDestinationRectangles, )
Adds the drag destination rectangles of the widget.
Runs after the layout phase for each widget in the tree.