Skip to main content

ViewExt

Trait ViewExt 

Source
pub trait ViewExt: Sized + View {
    // Provided methods
    fn padding(self, padding: impl Into<Insets>) -> Styled<Self> { ... }
    fn background(self, fill: impl Into<Fill>) -> Styled<Self> { ... }
    fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self> { ... }
    fn width(self, width: f32) -> Styled<Self> { ... }
    fn height(self, height: f32) -> Styled<Self> { ... }
    fn grow(self, grow: f32) -> Styled<Self> { ... }
    fn stretch(self) -> Styled<Self> { ... }
    fn centered(self) -> Styled<Self> { ... }
    fn tooltip(self, text: impl Into<String>) -> Tooltip<Self> { ... }
    fn opacity(self, opacity: f32) -> Faded<Self> { ... }
}
Expand description

SwiftUI-style modifiers available on every view.

use ravenrs_style::Semantic;
use ravenrs_widgets::{Text, ViewExt};

let chip = Text::new("New").padding((4.0, 10.0)).background(Semantic::Control).corner_radius(999.0);

Provided Methods§

Source

fn padding(self, padding: impl Into<Insets>) -> Styled<Self>

Adds padding inside the box, in logical pixels.

Source

fn background(self, fill: impl Into<Fill>) -> Styled<Self>

Paints a background behind the content.

Source

fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>

Fixes the width and/or height in logical pixels; None keeps the content size.

Source

fn width(self, width: f32) -> Styled<Self>

Fixes the width in logical pixels.

Source

fn height(self, height: f32) -> Styled<Self>

Fixes the height in logical pixels.

Source

fn grow(self, grow: f32) -> Styled<Self>

Takes a share of the free space in the parent stack.

Source

fn stretch(self) -> Styled<Self>

Stretches across the parent stack’s cross axis.

Source

fn centered(self) -> Styled<Self>

Centers the content inside the box.

Source

fn tooltip(self, text: impl Into<String>) -> Tooltip<Self>

Shows text above the view while the pointer is over it; see Tooltip.

Source

fn opacity(self, opacity: f32) -> Faded<Self>

Draws the view and everything in it at this opacity, from 0.0 to 1.0, easing to it when it changes. Layout and input stay as they are; see Faded.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<V> ViewExt for V
where V: View,