Struct floem_ui_kit::theme::Theme

source ·
pub struct Theme {
    pub accent_color: RwSignal<AccentColor>,
    pub horizontal_window_margin: f32,
}
Expand description

Allows you to create any of the widgets supported by Floem UI Kit. The Theme struct contains any settings that will apply across the entire UI.

use floem_ui_kit::accents::AccentColor;
use floem_ui_kit::theme::Theme;

let theme = Theme {
    ..Default::default()
};

Fields§

§accent_color: RwSignal<AccentColor>

Controls color variations of the theme. Wrapped in a signal so your UI may change appearance without restarting.

§horizontal_window_margin: f32

UI elements generally shouldn’t stick to the edge of the window, but exceptions are sometimes necessary for decorative elements. To cover your use cases, you can set a horizontal window margin here. It does not do anything by default. You may however:

  • Make use of the padded_container function to wrap your layout in an amount of padding equal to the target window margin.
  • Read the value of this field in your own code whenever you prefer to manually insert horizontal window margin.

Decorative UI elements containing text (such as Floem UI Kit’s own header) may hook in to this field to keep different parts of the window layout aligned.

Implementations§

source§

impl Theme

source

pub fn button<S: Display + 'static>( self, label_func: impl Fn() -> S + 'static, variant: ButtonVariant ) -> impl View

Instantiates a button widget.

source§

impl Theme

source

pub fn labeled_checkbox<S: Display + 'static>( self, read_signal: ReadSignal<bool>, label_render_func: impl Fn() -> S + 'static ) -> impl View

Instantiates a checkbox widget controlling a boolean with a text label next to it.

source§

impl Theme

source

pub fn simple_header(self, title: &str) -> impl View

Instantiates a minimalistic decorative element containing a title.

source§

impl Theme

source

pub fn label<S: Display + 'static>( self, render_func: impl Fn() -> S + 'static, variant: LabelVariant ) -> impl View

Instantiates a plain text label that sources its contents from a dynamic rendering function.

source§

impl Theme

source

pub fn integer_input<T>( self, int_signal: RwSignal<T>, step: T, min_value: Option<T>, max_value: Option<T> ) -> impl View
where T: Integer + Clone + Copy + Display + FromStr + SubAssign + AddAssign + 'static,

Instantiates an input field that only accepts integer numeric input. Comes with up/down arrows allowing the user to increment/decrement the value in steps. If min_value and/or max_value are set, input is restricted to the given bounds.

source§

impl Theme

source

pub fn padded_container<V: View + 'static>(self, child: V) -> impl View

Wraps a stack of UI elements in the theme’s configured horizontal window margin, and applies a padding of the same amount in vertical direction for symmetry purposes. You’d ordinarily do this to prevent form widgets from sticking to the side of the window.

source§

impl Theme

source

pub fn radio_button<T>( self, variant_to_render: T, read_signal: ReadSignal<T>, write_signal: WriteSignal<T> ) -> impl View
where T: IntoEnumIterator + 'static + Copy + Clone + PartialEq + Display,

Instantiates one option in a radio group widget. For most use cases you’ll want Self::radio_group instead. Use Self::radio_button to implement special accommodations such as non-standard layouts or to render certain options as disabled.

source

pub fn radio_group<T>( self, read_signal: ReadSignal<T>, write_signal: WriteSignal<T>, gap_between_items: f32, variant: RadioGroupVariant ) -> impl View
where T: IntoEnumIterator + Copy + Clone + PartialEq + Eq + Display + Hash + 'static,

Instantiates a radio group widget for given enum T. For the display of labels, we rely on the Display trait. We ask that your enum derives EnumIter so the radio group may list all available options. Options can be laid out horizontally or vertically. A configurable gap is inserted between items.

source§

impl Theme

source

pub fn root_view<V: View + 'static>(self, child: V) -> impl View

Instantiates a container that applies Floem UI Kit’s theme. Always use this as the foundation of your layout.

source§

impl Theme

source

pub fn text_input(self, rw_signal: RwSignal<String>) -> impl View

Trait Implementations§

source§

impl Clone for Theme

source§

fn clone(&self) -> Theme

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Default for Theme

source§

fn default() -> Self

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

impl Copy for Theme

Auto Trait Implementations§

§

impl RefUnwindSafe for Theme

§

impl Send for Theme

§

impl Sync for Theme

§

impl Unpin for Theme

§

impl UnwindSafe for Theme

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
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: 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>

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)

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)

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
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> NoneValue for T
where T: Default,

§

type NoneType = T

§

fn null_value() -> T

The none-equivalent value.
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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

§

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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSync for T
where T: Sync,