Struct RadioGroup

Source
pub struct RadioGroup<T, A = ()> { /* private fields */ }
Expand description

A typed single-selection set of radio options.

Selection can be controlled or two-way bound. Without a writable signal or callback the group is read-only. Arrows wrap and skip disabled options; Home/End select first/last. With no matching value, forward movement and Enter/Space choose first while backward movement chooses last.

§Examples

use ailloli_ui_widgets::controls::RadioGroup;
let group: RadioGroup<&str, ()> = RadioGroup::new()
    .option("daily", "Daily")
    .option("weekly", "Weekly")
    .selected("daily");
let _ = group;

Implementations§

Source§

impl<T: Clone + PartialEq + 'static, A: 'static> RadioGroup<T, A>

Source

pub fn new() -> Self

Creates an enabled empty vertical group with no selection/callback.

Empty groups measure zero by zero and are not focusable.

§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let group: RadioGroup<i32, ()> = RadioGroup::new();
let _ = group;
Source

pub fn option(self, value: T, label: impl Into<String>) -> Self

Appends an enabled typed option.

§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let group: RadioGroup<i32, ()> = RadioGroup::new().option(1, "One");
let _ = group;
Source

pub fn radio_option(self, option: RadioOption<T>) -> Self

Appends a fully configured option.

§Examples
use ailloli_ui_widgets::controls::{RadioGroup, RadioOption};
let group: RadioGroup<i32, ()> = RadioGroup::new()
    .radio_option(RadioOption::new(1, "One").disabled(true));
let _ = group;
Source

pub fn selected(self, selected: impl Into<Binding<T>>) -> Self

Sets controlled static/reactive selection and clears bound mode.

A value absent from options paints no selection. Equal duplicate values may paint multiple checked options.

§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let group: RadioGroup<i32, ()> = RadioGroup::new().option(1, "One").selected(1);
let _ = group;
Source

pub fn bind(self, selected: impl Into<Signal<T>>) -> Self

Installs a writable signal for two-way group selection.

§Examples
use std::{cell::RefCell, rc::Rc};
use ailloli_ui_runtime::component::Signal;
use ailloli_ui_widgets::controls::RadioGroup;
let selected = Signal::new(Rc::new(RefCell::new(1)), Rc::new(|| {}));
let group: RadioGroup<i32, ()> = RadioGroup::new().option(1, "One").bind(selected);
let _ = group;
Source

pub fn disabled(self, disabled: impl Into<Binding<bool>>) -> Self

Sets static or reactive global disabled state.

Disabled groups are not focusable and ignore interaction.

§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let group: RadioGroup<i32, ()> = RadioGroup::new().disabled(true);
let _ = group;
Source

pub fn disabled_signal(self, disabled: Memo<bool>) -> Self

Sets global disabled state from a derived memo.

§Examples
use ailloli_ui_runtime::component::Memo;
use ailloli_ui_widgets::controls::RadioGroup;
let group: RadioGroup<i32, ()> = RadioGroup::new().disabled_signal(Memo::new(|| false));
let _ = group;
Source

pub fn direction(self, direction: RadioDirection) -> Self

Sets vertical or horizontal option flow.

§Examples
use ailloli_ui_widgets::controls::{RadioDirection, RadioGroup};
let group: RadioGroup<i32, ()> = RadioGroup::new().direction(RadioDirection::Horizontal);
let _ = group;
Source

pub fn vertical(self) -> Self

Selects vertical top-to-bottom option flow.

§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let group: RadioGroup<i32, ()> = RadioGroup::new().vertical();
let _ = group;
Source

pub fn horizontal(self) -> Self

Selects horizontal left-to-right option flow.

§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let group: RadioGroup<i32, ()> = RadioGroup::new().horizontal();
let _ = group;
Source

pub fn radio_style(self, style: RadioStyle) -> Self

Replaces complete colors and option geometry.

§Examples
use ailloli_ui_widgets::controls::{RadioGroup, RadioStyle};
let group: RadioGroup<i32, ()> = RadioGroup::new().radio_style(RadioStyle::default());
let _ = group;
Source

pub fn radio_size(self, size: RadioSize) -> Self

Replaces style with a default-theme built-in size.

§Examples
use ailloli_ui_widgets::controls::{RadioGroup, RadioSize};
let group: RadioGroup<i32, ()> = RadioGroup::new().radio_size(RadioSize::Compact);
let _ = group;
Source

pub fn on_change(self, f: impl Fn(T) -> A + 'static) -> Self

Maps each distinct enabled selection to an application action.

The callback does not make a controlled source writable; use Self::bind for two-way state.

§Examples
use ailloli_ui_widgets::controls::RadioGroup;
#[derive(Clone)]
enum Action { Selected(i32) }
let group = RadioGroup::new().option(1, "One").on_change(Action::Selected);
let _ = group;
Source

pub fn on_change_ctx(self, f: impl Fn(&mut EventCtx<A>, T) + 'static) -> Self

Installs a context-aware selection handler.

§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let group = RadioGroup::<i32, ()>::new()
    .option(1, "One")
    .on_change_ctx(|_ctx, value| assert_eq!(value, 1));
let _ = group;
Source

pub fn width(self, value: impl Into<Length>) -> Self

Sets preferred width from logical pixels or an explicit Length.

§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().width(240.0);
Source

pub fn height(self, value: impl Into<Length>) -> Self

Sets preferred height from logical pixels or an explicit Length.

§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().height(120.0);
Source

pub fn min_width(self, value: impl Into<Length>) -> Self

Sets the minimum resolved width.

§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().min_width(120.0);
Source

pub fn max_width(self, value: impl Into<Length>) -> Self

Sets the maximum resolved width.

§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().max_width(400.0);
Source

pub fn min_height(self, value: impl Into<Length>) -> Self

Sets the minimum resolved height.

§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().min_height(28.0);
Source

pub fn max_height(self, value: impl Into<Length>) -> Self

Sets the maximum resolved height.

§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().max_height(300.0);
Source

pub fn fill(self) -> Self

Marks both axes as parent-fill.

§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().fill();
Source

pub fn fill_width(self) -> Self

Marks width as parent-fill while preserving height.

§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().fill_width();
Source

pub fn fill_height(self) -> Self

Marks height as parent-fill while preserving width.

§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().fill_height();
Source

pub fn margin(self, value: f32) -> Self

Sets the same logical-pixel margin on every side.

§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().margin(8.0);
Source

pub fn padding(self, value: f32) -> Self

Sets the same logical-pixel layout padding on every side.

This is separate from RadioStyle::option_padding_x.

§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().padding(4.0);
Source

pub fn flex_grow(self) -> Self

Sets the dimensionless parent flex-grow weight to one.

§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().flex_grow();
Source

pub fn flex_grow_by(self, value: f32) -> Self

Sets the dimensionless parent flex-grow weight.

§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().flex_grow_by(2.0);
Source

pub fn flex_shrink(self, value: f32) -> Self

Sets the dimensionless parent flex-shrink weight.

§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().flex_shrink(0.5);
Source

pub fn flex_basis(self, value: impl Into<Length>) -> Self

Sets the preferred parent main-axis flex basis.

§Examples
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().flex_basis(160.0);
Source

pub fn align_self(self, value: AlignItems) -> Self

Overrides this item’s parent cross-axis alignment.

§Examples
use ailloli_ui_core::style::AlignItems;
use ailloli_ui_widgets::controls::RadioGroup;
let _ = RadioGroup::<i32, ()>::new().align_self(AlignItems::End);

Trait Implementations§

Source§

impl<T: Clone + PartialEq + 'static, A: 'static> Default for RadioGroup<T, A>

Source§

fn default() -> Self

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

impl<T: Clone + PartialEq + 'static, A: 'static> IntoView<A> for RadioGroup<T, A>

Source§

fn into_view(self) -> View<A>

Consumes a builder/value and returns its declarative view tree. Read more
Source§

impl<T: Clone + PartialEq + 'static, A: 'static> LayoutExt for RadioGroup<T, A>

Source§

fn layout_mut(&mut self) -> &mut LayoutStyle

Returns the widget’s mutable declarative size/inset state. Read more

Auto Trait Implementations§

§

impl<T, A> Freeze for RadioGroup<T, A>
where T: Freeze,

§

impl<T, A = ()> !RefUnwindSafe for RadioGroup<T, A>

§

impl<T, A = ()> !Send for RadioGroup<T, A>

§

impl<T, A = ()> !Sync for RadioGroup<T, A>

§

impl<T, A> Unpin for RadioGroup<T, A>
where T: Unpin,

§

impl<T, A = ()> !UnwindSafe for RadioGroup<T, A>

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, A> FlexItemExt<A> for T
where T: IntoView<A>,

Source§

fn flex_grow(self) -> View<A>

Sets flex-grow weight to one. Read more
Source§

fn flex_grow_by(self, value: f32) -> View<A>

Sets the dimensionless flex-grow weight. Read more
Source§

fn flex_shrink(self, value: f32) -> View<A>

Sets the dimensionless flex-shrink weight. Read more
Source§

fn flex_basis(self, value: impl Into<Length>) -> View<A>

Sets the preferred main-axis flex basis. Read more
Source§

fn align_self(self, value: AlignItems) -> View<A>

Overrides the parent cross-axis alignment for this view. Read more
Source§

fn fill_width(self) -> View<A>

Marks width as parent-fill in the view size hint. Read more
Source§

fn fill_height(self) -> View<A>

Marks height as parent-fill in the view size hint. Read more
Source§

fn fill(self) -> View<A>

Marks both axes as parent-fill in the view size hint. Read more
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, A> IntoViewKeyExt<A> for T
where T: IntoView<A>,

§

fn key(self, key: impl Into<String>) -> View<A>

Converts self, assigns the owned key, and returns the view. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

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> ErasedDestructor for T
where T: 'static,