pub struct Text { /* private fields */ }
Expand description
Struct for text
.
Implementations§
source§impl Text
impl Text
pub const DEFAULT_SIZE: u32 = 18u32
sourcepub fn color(self, color: Color) -> Text
pub fn color(self, color: Color) -> Text
Examples found in repository?
examples/calc.rs (line 12)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
fn digit_button(title: &str, state: StateHandle<String>) -> impl View {
let t = String::from(title);
zstack((
rectangle()
.corner_radius(10.0)
.color(RED_HIGHLIGHT)
.tap(move |cx| cx[state].push_str(&t)),
text(title).color(BLACK).offset([10.0, 10.0]),
))
.padding(Auto)
}
fn calc_button(title: &str, callback: impl Fn(&mut Context) + 'static) -> impl View {
zstack((
rectangle()
.corner_radius(10.0)
.color(GREEN_HIGHLIGHT)
.tap(callback),
text(title).color(BLACK).offset([10.0, 10.0]),
))
.padding(Auto)
}
Trait Implementations§
source§impl TextModifiers for Text
impl TextModifiers for Text
source§impl View for Text
impl View for Text
source§fn layout(&self, _id: ViewId, args: &mut LayoutArgs<'_>) -> LocalSize
fn layout(&self, _id: ViewId, args: &mut LayoutArgs<'_>) -> LocalSize
Lays out subviews and return the size of the view. Read more
source§fn hittest(
&self,
_id: ViewId,
_pt: LocalPoint,
_cx: &mut Context
) -> Option<ViewId>
fn hittest( &self, _id: ViewId, _pt: LocalPoint, _cx: &mut Context ) -> Option<ViewId>
Returns the topmost view which the point intersects.
source§fn access(
&self,
id: ViewId,
cx: &mut Context,
nodes: &mut Vec<(NodeId, Node)>
) -> Option<NodeId>
fn access( &self, id: ViewId, cx: &mut Context, nodes: &mut Vec<(NodeId, Node)> ) -> Option<NodeId>
Builds an AccessKit tree. The node ID for the subtree is returned. All generated nodes are accumulated.
source§fn commands(&self, _id: ViewId, _cx: &mut Context, _cmds: &mut Vec<CommandInfo>)
fn commands(&self, _id: ViewId, _cx: &mut Context, _cmds: &mut Vec<CommandInfo>)
Accumulates information about menu bar commands.
source§fn dirty(&self, _id: ViewId, _xform: LocalToWorld, _cx: &mut Context)
fn dirty(&self, _id: ViewId, _xform: LocalToWorld, _cx: &mut Context)
Determines dirty regions which need repainting.
source§fn gc(&self, _id: ViewId, _cx: &mut Context, _map: &mut Vec<ViewId>)
fn gc(&self, _id: ViewId, _cx: &mut Context, _map: &mut Vec<ViewId>)
Gets IDs for views currently in use. Read more
source§fn is_flexible(&self) -> bool
fn is_flexible(&self) -> bool
For detecting flexible sized things in stacks.
Auto Trait Implementations§
impl RefUnwindSafe for Text
impl Send for Text
impl Sync for Text
impl Unpin for Text
impl UnwindSafe for Text
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
source§impl<V> Modifiers for Vwhere
V: View,
impl<V> Modifiers for Vwhere V: View,
source§fn anim<F: Fn(&mut Context, f32) + 'static + Clone>(
self,
func: F
) -> AnimView<Self, F>
fn anim<F: Fn(&mut Context, f32) + 'static + Clone>( self, func: F ) -> AnimView<Self, F>
Calls a closure after rendering with context and delta time.
source§fn background<BG: View>(self, background: BG) -> Background<Self, BG>
fn background<BG: View>(self, background: BG) -> Background<Self, BG>
Puts a view behind another. The background view inherits the size of the view.
source§fn command<F: Fn(&mut Context) + 'static>(
self,
name: &str,
key: Option<HotKey>,
f: F
) -> Command<Self, F>
fn command<F: Fn(&mut Context) + 'static>( self, name: &str, key: Option<HotKey>, f: F ) -> Command<Self, F>
Adds a menu command.
source§fn command_group<T: CommandTuple>(self, cmds: T) -> CommandGroup<Self, T>
fn command_group<T: CommandTuple>(self, cmds: T) -> CommandGroup<Self, T>
Adds a group of menu commands.
source§fn drag<F: Fn(&mut Context, LocalOffset, GestureState, Option<MouseButton>) + 'static>(
self,
f: F
) -> Drag<Self, F>
fn drag<F: Fn(&mut Context, LocalOffset, GestureState, Option<MouseButton>) + 'static>( self, f: F ) -> Drag<Self, F>
Calls a function in response to a drag.
source§fn drag_s<T: 'static, B: Binding<T>, F: Fn(&mut T, LocalOffset, GestureState, Option<MouseButton>) + 'static>(
self,
s: B,
f: F
) -> DragS<Self, F, B, T>
fn drag_s<T: 'static, B: Binding<T>, F: Fn(&mut T, LocalOffset, GestureState, Option<MouseButton>) + 'static>( self, s: B, f: F ) -> DragS<Self, F, B, T>
Calls a function in response to a drag. Version which passes in a binding.
source§fn hover<F: Fn(&mut Context, bool) + 'static>(self, f: F) -> Hover<Self, F>
fn hover<F: Fn(&mut Context, bool) + 'static>(self, f: F) -> Hover<Self, F>
Calls a function in response to a mouse hovering.
source§fn env<E: Clone + 'static>(self, value: E) -> SetenvView<Self, E>
fn env<E: Clone + 'static>(self, value: E) -> SetenvView<Self, E>
Add an environment value.
source§fn fullscreen(self) -> FullscreenView<Self>
fn fullscreen(self) -> FullscreenView<Self>
Make the window full screen.
source§fn geom<F: Fn(&mut Context, LocalSize, LocalToWorld) + 'static>(
self,
f: F
) -> Geom<Self, F>
fn geom<F: Fn(&mut Context, LocalSize, LocalToWorld) + 'static>( self, f: F ) -> Geom<Self, F>
Calls a function with the view’s geometry after layout runs.
Currently only the view’s size is returned.
source§fn key<F: Fn(&mut Context, Key) + 'static>(self, f: F) -> KeyView<Self, F>
fn key<F: Fn(&mut Context, Key) + 'static>(self, f: F) -> KeyView<Self, F>
Responds to keyboard events
source§fn offset<Off: Into<LocalOffset>>(self, offset: Off) -> Offset<Self>
fn offset<Off: Into<LocalOffset>>(self, offset: Off) -> Offset<Self>
Applies an offset to the view in local space.
source§fn padding(self, param: impl Into<PaddingParam>) -> Padding<Self>
fn padding(self, param: impl Into<PaddingParam>) -> Padding<Self>
Adds space around a view. Can be either
Auto
or Px(number_of_pixels)
source§fn tap<A: 'static, F: Fn(&mut Context) -> A + 'static>(
self,
f: F
) -> Tap<Self, F>
fn tap<A: 'static, F: Fn(&mut Context) -> A + 'static>( self, f: F ) -> Tap<Self, F>
Calls a function in response to a tap.
source§fn tap_a<A: 'static>(self, action: A) -> TapA<Self, A>
fn tap_a<A: 'static>(self, action: A) -> TapA<Self, A>
Version of
tap
which takes an action type instead
of a function.source§fn window_title(self, title: &str) -> TitleView<Self>
fn window_title(self, title: &str) -> TitleView<Self>
Specify the title of the window.