Skip to main content

ImageButton

Struct ImageButton 

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

State-specific segmented image button.

§State fallback (§5.D)

When a state’s middle source is absent, the widget walks a fallback chain until a middle source is found:

  • PressedReleased
  • CheckedReleasedReleased
  • CheckedPressedCheckedReleasedPressedReleased
  • DisabledReleased
  • CheckedDisabledCheckedReleasedReleased

§Event handling

Pointer PressDown inside bounds sets the visual pressed state. PressRelease inside bounds activates the button (returns true). Disabled buttons consume no activation.

Implementations§

Source§

impl ImageButton

Source

pub fn new(bounds: Rect) -> Self

Create a new image button occupying bounds in the released state.

Source

pub fn set_src( &mut self, state: ImageButtonState, left: Option<ImageDescriptor<'static>>, middle: Option<ImageDescriptor<'static>>, right: Option<ImageDescriptor<'static>>, )

Set the left, middle, and right sources for state.

Pass None for any segment that should be absent. The middle segment must be set for the button to draw content; a missing middle is allowed but produces no visible image.

Source

pub fn src_left( &self, state: ImageButtonState, ) -> Option<&ImageDescriptor<'static>>

Return the left source configured for state (no fallback applied).

Source

pub fn src_middle( &self, state: ImageButtonState, ) -> Option<&ImageDescriptor<'static>>

Return the middle source configured for state (no fallback applied).

Source

pub fn src_right( &self, state: ImageButtonState, ) -> Option<&ImageDescriptor<'static>>

Return the right source configured for state (no fallback applied).

Source

pub fn set_state(&mut self, state: ImageButtonState)

Set the app-controlled base state.

Use ImageButtonState::Disabled or ImageButtonState::CheckedDisabled to prevent pointer activation.

Source

pub fn state(&self) -> ImageButtonState

Return the app-controlled base state.

Source

pub fn set_checked(&mut self, checked: bool)

Set the checked (toggled on) state.

Source

pub fn checked(&self) -> bool

Return true when the button is in the checked state.

Source

pub fn draw_state(&self) -> ImageButtonState

Compute the effective draw state from the base state, checked flag, and whether a pointer is currently held.

Trait Implementations§

Source§

impl Widget for ImageButton

Source§

fn bounds(&self) -> Rect

Return the area this widget occupies relative to its parent.
Source§

fn set_bounds(&mut self, bounds: Rect)

Called by the LPAR-10 layout pass to notify this widget of its layout-computed bounds. Read more
Source§

fn draw(&self, renderer: &mut dyn Renderer)

Render the widget using the provided Renderer.
Source§

fn handle_event(&mut self, event: &Event) -> bool

Handle an event and return true if it was consumed. Read more
Source§

fn clear_region(&mut self) -> Option<Rect>

Return a region (in draw/landscape coordinates) that should be restored from the pristine background copy, or None. Read more
Source§

fn widget_font_mut(&mut self) -> Option<&mut WidgetFont>

Expose this widget’s font slot for cascade-driven font resolution (FONT-05 §5.B). Read more

Auto Trait Implementations§

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.