cosmic::widget

Type Alias Text

source
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>
where Theme: Catalog, Renderer: Renderer,

source

pub fn new(fragment: impl IntoFragment<'a>) -> Text<'a, Theme, Renderer>

Create a new fragment of Text with the given contents.

source

pub fn size(self, size: impl Into<Pixels>) -> Text<'a, Theme, Renderer>

Sets the size of the Text.

source

pub fn line_height( self, line_height: impl Into<LineHeight>, ) -> Text<'a, Theme, Renderer>

Sets the LineHeight of the Text.

source

pub fn font( self, font: impl Into<<Renderer as Renderer>::Font>, ) -> Text<'a, Theme, Renderer>

Sets the Font of the Text.

source

pub fn width(self, width: impl Into<Length>) -> Text<'a, Theme, Renderer>

Sets the width of the Text boundaries.

source

pub fn height(self, height: impl Into<Length>) -> Text<'a, Theme, Renderer>

Sets the height of the Text boundaries.

source

pub fn center(self) -> Text<'a, Theme, Renderer>

Centers the Text, both horizontally and vertically.

source

pub fn align_x( self, alignment: impl Into<Horizontal>, ) -> Text<'a, Theme, Renderer>

Sets the alignment::Horizontal of the Text.

source

pub fn align_y( self, alignment: impl Into<Vertical>, ) -> Text<'a, Theme, Renderer>

Sets the alignment::Vertical of the Text.

source

pub fn shaping(self, shaping: Shaping) -> Text<'a, Theme, Renderer>

Sets the Shaping strategy of the Text.

source

pub fn wrapping(self, wrapping: Wrapping) -> Text<'a, Theme, Renderer>

Sets the Wrapping strategy of the Text.

source

pub fn style( self, style: impl Fn(&Theme) -> Style + 'a, ) -> Text<'a, Theme, Renderer>
where <Theme as Catalog>::Class<'a>: From<Box<dyn Fn(&Theme) -> Style + 'a>>,

Sets the style of the Text.

source

pub fn color(self, color: impl Into<Color>) -> Text<'a, Theme, Renderer>
where <Theme as Catalog>::Class<'a>: From<Box<dyn Fn(&Theme) -> Style + 'a>>,

Sets the Color of the Text.

source

pub fn color_maybe( self, color: Option<impl Into<Color>>, ) -> Text<'a, Theme, Renderer>
where <Theme as Catalog>::Class<'a>: From<Box<dyn Fn(&Theme) -> Style + 'a>>,

Sets the Color of the Text, if Some.

source

pub fn class( self, class: impl Into<<Theme as Catalog>::Class<'a>>, ) -> Text<'a, Theme, Renderer>

Sets the style class of the Text.

Trait Implementations

source§

impl<'a, Theme, Renderer> From<&'a str> for Text<'a, Theme, Renderer>
where Theme: Catalog + 'a, Renderer: Renderer,

source§

fn from(content: &'a str) -> Text<'a, Theme, Renderer>

Converts to this type from the input type.
source§

impl<'a, Message, Theme, Renderer> Widget<Message, Theme, Renderer> for Text<'a, Theme, Renderer>
where Theme: Catalog, Renderer: Renderer,

source§

fn tag(&self) -> Tag

Returns the Tag of the Widget.
source§

fn state(&self) -> State

Returns the State of the Widget.
source§

fn size(&self) -> Size<Length>

Returns the Size of the Widget in lengths.
source§

fn layout(&self, tree: &mut Tree, renderer: &Renderer, limits: &Limits) -> Node

Returns the layout::Node of the Widget. Read more
source§

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

get the a11y nodes for the widget and its children
source§

fn id(&self) -> Option<Id>

Returns the id of the widget
source§

fn set_id(&mut self, id: Id)

Sets the id of the widget This may be called while diffing the widget tree
source§

fn size_hint(&self) -> Size<Length>

Returns a Size hint for laying out the Widget. Read more
source§

fn children(&self) -> Vec<Tree>

Returns the state Tree of the children of the Widget.
source§

fn diff(&mut self, _tree: &mut Tree)

Reconciliates the Widget with the provided Tree.
source§

fn operate( &self, _state: &mut Tree, _layout: Layout<'_>, _renderer: &Renderer, _operation: &mut dyn Operation, )

Applies an Operation to the Widget.
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

Processes a runtime Event. Read more
source§

fn mouse_interaction( &self, _state: &Tree, _layout: Layout<'_>, _cursor: Cursor, _viewport: &Rectangle, _renderer: &Renderer, ) -> Interaction

Returns the current mouse::Interaction of the Widget. Read more
source§

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, )

Adds the drag destination rectangles of the widget. Runs after the layout phase for each widget in the tree.