cosmic::widget::segmented_button

Type Alias HorizontalSegmentedButton

Source
pub type HorizontalSegmentedButton<'a, SelectionMode, Message> = SegmentedButton<'a, Horizontal, SelectionMode, Message>;
Expand description

Horizontal SegmentedButton.

Aliased Type§

struct HorizontalSegmentedButton<'a, SelectionMode, Message> { /* private fields */ }

Implementations

Source§

impl<'a, Variant, SelectionMode, Message> SegmentedButton<'a, Variant, SelectionMode, Message>
where Self: SegmentedVariant, Model<SelectionMode>: Selectable, SelectionMode: Default,

Source

pub fn new(model: &'a Model<SelectionMode>) -> Self

Source

pub fn context_menu(self, context_menu: Option<Vec<Tree<'a, Message>>>) -> Self
where Message: 'static,

Source

pub fn on_activate<T>(self, on_activate: T) -> Self
where T: Fn(Entity) -> Message + 'static,

Emitted when a tab is pressed.

Source

pub fn on_close<T>(self, on_close: T) -> Self
where T: Fn(Entity) -> Message + 'static,

Emitted when a tab close button is pressed.

Source

pub fn on_context<T>(self, on_context: T) -> Self
where T: Fn(Entity) -> Message + 'static,

Emitted when a button is right-clicked.

Source

pub fn on_middle_press<T>(self, on_middle_press: T) -> Self
where T: Fn(Entity) -> Message + 'static,

Emitted when the middle mouse button is pressed on a button.

Source

pub fn on_dnd_drop<D: AllowedMimeTypes>( self, dnd_drop_handler: impl Fn(Entity, Option<D>, DndAction) -> Message + 'static, ) -> Self

Handle the dnd drop event.

Source

pub fn on_dnd_enter( self, dnd_enter_handler: impl Fn(Entity, Vec<String>) -> Message + 'static, ) -> Self

Handle the dnd enter event.

Source

pub fn on_dnd_leave( self, dnd_leave_handler: impl Fn(Entity) -> Message + 'static, ) -> Self

Handle the dnd leave event.

Source

pub fn get_drag_id(&self) -> u128

Returns the drag id of the destination.

§Panics

Panics if the destination has been assigned a Set id, which is invalid.

Source§

impl<'a, Variant, SelectionMode, Message> SegmentedButton<'a, Variant, SelectionMode, Message>
where Model<SelectionMode>: Selectable, SelectionMode: Default,

Source

pub fn id(self, value: Id) -> Self

iced widget ID

Source

pub fn close_icon(self, value: Icon) -> Self

The icon used for the close button.

Source

pub fn scrollable_focus(self, value: bool) -> Self

Scrolling switches focus between tabs.

Source

pub fn show_close_icon_on_hover(self, value: bool) -> Self

Show the close icon only when item is hovered.

Source

pub fn padding(self, value: impl Into<Padding>) -> Self

Padding of the whole widget.

Source

pub fn dividers(self, value: bool) -> Self

Whether to place dividers between buttons.

Source

pub fn button_alignment(self, value: Alignment) -> Self

Alignment of button contents.

Source

pub fn button_padding(self, value: [u16; 4]) -> Self

Padding around a button.

Source

pub fn button_height(self, value: u16) -> Self

Desired height of a button.

Source

pub fn button_spacing(self, value: u16) -> Self

Spacing between icon and text in button.

Source

pub fn maximum_button_width(self, value: u16) -> Self

Maximum width of a button.

Source

pub fn minimum_button_width(self, value: u16) -> Self

Minimum width of a button.

Source

pub fn indent_spacing(self, value: u16) -> Self

Spacing for each indent.

Source

pub fn font_active(self, value: Option<Font>) -> Self

Desired font for active tabs.

Source

pub fn font_hovered(self, value: Option<Font>) -> Self

Desired font for hovered tabs.

Source

pub fn font_inactive(self, value: Option<Font>) -> Self

Desired font for inactive tabs.

Source

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

Size of the font.

Source

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

Desired width of the widget.

Source

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

Desired height of the widget.

Source

pub fn spacing(self, value: u16) -> Self

Desired spacing between items.

Source

pub fn line_height(self, value: LineHeight) -> Self

LineHeight of the font.

Source

pub fn style(self, value: impl Into<Style>) -> Self

Style to draw the widget in.

Source

pub fn mimes(self, value: Vec<String>) -> Self

Source

pub fn drag_id(self, value: DragId) -> Self

Trait Implementations

Source§

impl<'a, SelectionMode, Message> SegmentedVariant for SegmentedButton<'a, Horizontal, SelectionMode, Message>
where Model<SelectionMode>: Selectable, SelectionMode: Default,

Source§

fn variant_appearance(theme: &Theme, style: &SegmentedButton) -> Appearance

Get the appearance for this variant of the widget.
Source§

fn variant_bounds<'b>( &'b self, state: &'b LocalState, bounds: Rectangle, ) -> Box<dyn Iterator<Item = ItemBounds> + 'b>

Calculates the bounds for visible buttons.
Source§

fn variant_layout( &self, state: &mut LocalState, renderer: &Renderer, limits: &Limits, ) -> Size

Calculates the layout of this variant.
Source§

impl<'a, Variant, SelectionMode, Message> Widget<Message, Theme, Renderer> for SegmentedButton<'a, Variant, SelectionMode, Message>
where Self: SegmentedVariant, Model<SelectionMode>: Selectable, SelectionMode: Default, Message: 'static + Clone,

Source§

fn children(&self) -> Vec<Tree>

Returns the state Tree of the children of the Widget.
Source§

fn tag(&self) -> Tag

Returns the Tag of the Widget.
Source§

fn state(&self) -> State

Returns the State of the Widget.
Source§

fn diff(&mut self, tree: &mut Tree)

Reconciliates the Widget with the provided Tree.
Source§

fn size(&self) -> Size<Length>

Returns the Size of the Widget in lengths.
Source§

fn layout(&self, tree: &mut Tree, renderer: &Renderer, limits: &Limits) -> Node

Returns the layout::Node of the Widget. Read more
Source§

fn on_event( &mut self, tree: &mut Tree, event: Event, layout: Layout<'_>, cursor_position: Cursor, _renderer: &Renderer, _clipboard: &mut dyn Clipboard, shell: &mut Shell<'_, Message>, _viewport: &Rectangle, ) -> Status

Processes a runtime Event. Read more
Source§

fn operate( &self, tree: &mut Tree, _layout: Layout<'_>, _renderer: &Renderer, operation: &mut dyn Operation<()>, )

Applies an Operation to the Widget.
Source§

fn mouse_interaction( &self, tree: &Tree, layout: Layout<'_>, cursor_position: Cursor, _viewport: &Rectangle, _renderer: &Renderer, ) -> Interaction

Returns the current mouse::Interaction of the Widget. Read more
Source§

fn draw( &self, tree: &Tree, renderer: &mut Renderer, theme: &Theme, style: &Style, layout: Layout<'_>, cursor: Cursor, viewport: &Rectangle, )

Draws the Widget using the associated Renderer.
Source§

fn overlay<'b>( &'b mut self, tree: &'b mut Tree, layout: Layout<'_>, _renderer: &Renderer, translation: Vector, ) -> Option<Element<'b, Message, Theme, Renderer>>

Returns the overlay of the Widget, if there is any.
Source§

fn drag_destinations( &self, _state: &Tree, layout: Layout<'_>, _renderer: &Renderer, dnd_rectangles: &mut DndDestinationRectangles, )

Adds the drag destination rectangles of the widget. Runs after the layout phase for each widget in the tree.
Source§

fn size_hint(&self) -> Size<Length>

Returns a Size hint for laying out the Widget. Read more
Source§

fn a11y_nodes( &self, _layout: Layout<'_>, _state: &Tree, _cursor: Cursor, ) -> A11yTree

get the a11y nodes for the widget and its children
Source§

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

Returns the id of the widget
Source§

fn set_id(&mut self, _id: Id)

Sets the id of the widget This may be called while diffing the widget tree