Skip to main content

ZenMode

Struct ZenMode 

Source
pub struct ZenMode { /* private fields */ }
Expand description

Zen Mode wrapper for distraction-free content display

Wraps any View and provides a toggle between normal and fullscreen modes. In zen mode, the content fills the entire screen with configurable padding.

§Example

use revue::widget::{zen, text, Text};

let content = Text::new("Focus on this content...");
let mut zen_view = zen(content)
    .padding(4)
    .bg(Color::rgb(20, 20, 30));

// Toggle zen mode
zen_view.toggle();

// Check state
if zen_view.is_enabled() {
    // Renders fullscreen
}

Implementations§

Source§

impl ZenMode

Source

pub fn new(content: impl View + 'static) -> Self

Create a new zen mode wrapper

Source

pub fn padding(self, padding: u16) -> Self

Set horizontal and vertical padding

Source

pub fn padding_x(self, padding: u16) -> Self

Set horizontal padding

Source

pub fn padding_y(self, padding: u16) -> Self

Set vertical padding

Source

pub fn bg(self, color: Color) -> Self

Set background color

Source

pub fn dim(self, opacity: f32) -> Self

Set dim opacity for transition effect (0.0 = no dim, 1.0 = full dim)

Source

pub fn center(self) -> Self

Center content vertically in zen mode

Source

pub fn enable(&mut self)

Enable zen mode

Source

pub fn disable(&mut self)

Disable zen mode

Source

pub fn toggle(&mut self)

Toggle zen mode

Source

pub fn is_enabled(&self) -> bool

Check if zen mode is enabled

Source

pub fn set_enabled(&mut self, enabled: bool)

Set enabled state

Source

pub fn content(&self) -> &dyn View

Get reference to inner content

Source

pub fn content_mut(&mut self) -> &mut dyn View

Get mutable reference to inner content

Source§

impl ZenMode

Source

pub fn element_id(self, id: impl Into<String>) -> Self

Set element ID for CSS selector (#id)

Source

pub fn class(self, class: impl Into<String>) -> Self

Add a CSS class

Source

pub fn classes<I, S>(self, classes: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Add multiple CSS classes

Trait Implementations§

Source§

impl Default for ZenMode

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl StyledView for ZenMode

Source§

fn set_id(&mut self, id: impl Into<String>)

Set element ID
Source§

fn add_class(&mut self, class: impl Into<String>)

Add a CSS class
Source§

fn remove_class(&mut self, class: &str)

Remove a CSS class
Source§

fn toggle_class(&mut self, class: &str)

Toggle a CSS class
Source§

fn has_class(&self, class: &str) -> bool

Check if has class
Source§

impl View for ZenMode

Source§

fn render(&self, ctx: &mut RenderContext<'_>)

Render the view to the given context Read more
Source§

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

Get element ID (for CSS #id selectors) Read more
Source§

fn classes(&self) -> &[String]

Get CSS classes (for CSS .class selectors) Read more
Source§

fn meta(&self) -> WidgetMeta

Get widget metadata for DOM Read more
Source§

fn widget_type(&self) -> &'static str

Get widget type name (for CSS type selectors) Read more
Source§

fn children(&self) -> &[Box<dyn View>]

Get child views (for container widgets) Read more

Auto Trait Implementations§

§

impl Freeze for ZenMode

§

impl !RefUnwindSafe for ZenMode

§

impl !Send for ZenMode

§

impl !Sync for ZenMode

§

impl Unpin for ZenMode

§

impl !UnwindSafe for ZenMode

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.