Struct Text
pub struct Text<'a, Theme, Renderer>{ /* private fields */ }
Available on crate feature
advanced
only.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()
}
Implementations§
§impl<'a, Theme, Renderer> Text<'a, Theme, Renderer>
impl<'a, Theme, Renderer> Text<'a, Theme, Renderer>
pub 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.
pub 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
.
pub 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.
pub 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.
pub fn align_x(
self,
alignment: impl Into<Alignment>,
) -> Text<'a, Theme, Renderer>
pub fn align_x( self, alignment: impl Into<Alignment>, ) -> Text<'a, Theme, Renderer>
Sets the alignment::Horizontal
of the Text
.
pub 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
.
pub 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
.
pub fn color_maybe(
self,
color: Option<impl Into<Color>>,
) -> Text<'a, Theme, Renderer>
pub fn color_maybe( self, color: Option<impl Into<Color>>, ) -> Text<'a, Theme, Renderer>
Trait Implementations§
§impl<'a, Message, Theme, Renderer> From<Text<'a, Theme, Renderer>> for Element<'a, Message, Theme, Renderer>
impl<'a, Message, Theme, Renderer> From<Text<'a, Theme, Renderer>> for Element<'a, Message, Theme, Renderer>
§impl<Message, Theme, Renderer> Widget<Message, Theme, Renderer> for Text<'_, Theme, Renderer>
impl<Message, Theme, Renderer> Widget<Message, Theme, Renderer> for Text<'_, Theme, Renderer>
§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
.§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, )
§fn update(
&mut self,
_state: &mut Tree,
_event: &Event,
_layout: Layout<'_>,
_cursor: Cursor,
_renderer: &Renderer,
_clipboard: &mut dyn Clipboard,
_shell: &mut Shell<'_, Message>,
_viewport: &Rectangle,
)
fn update( &mut self, _state: &mut Tree, _event: &Event, _layout: Layout<'_>, _cursor: Cursor, _renderer: &Renderer, _clipboard: &mut dyn Clipboard, _shell: &mut Shell<'_, Message>, _viewport: &Rectangle, )
§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
Auto Trait Implementations§
impl<'a, Theme, Renderer> Freeze for Text<'a, Theme, Renderer>
impl<'a, Theme, Renderer> RefUnwindSafe for Text<'a, Theme, Renderer>
impl<'a, Theme, Renderer> Send for Text<'a, Theme, Renderer>
impl<'a, Theme, Renderer> Sync for Text<'a, Theme, Renderer>
impl<'a, Theme, Renderer> Unpin for Text<'a, Theme, Renderer>
impl<'a, Theme, Renderer> UnwindSafe for Text<'a, Theme, Renderer>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<State, Message> IntoBoot<State, Message> for State
impl<State, Message> IntoBoot<State, Message> for State
Source§fn into_boot(self) -> (State, Task<Message>)
fn into_boot(self) -> (State, Task<Message>)
Turns some type into the initial state of some
Application
.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more