diff --git a/examples/segmented_button/src/main.rs b/examples/segmented_button/src/main.rs index fe7e63bb..9d4d2149 100644 --- a/examples/segmented_button/src/main.rs +++ b/examples/segmented_button/src/main.rs @@ -1,6 +1,6 @@ use iced::widget::container; +use iced::widget::{column, row, text}; use iced::{Element, Length, Sandbox, Settings}; -use iced::widget::{column, row, text}; use iced_aw::native::segmented_button; use segmented_button::SegmentedButton; @@ -43,23 +43,22 @@ impl Sandbox for Example { fn view(&self) -> Element { // let selected_radio = Some(Choice::A); - // i added a row just to demonstrate that anything can be used as a child, - //in this case instead of A B C you might add icons + // i added a row just to demonstrate that anything can be used as a child, + //in this case instead of A B C you might add icons let a = SegmentedButton::new( row!(text("HEAVY "), "A"), Choice::A, self.selected_radio, Message::RadioSelected, ); - - + let b = SegmentedButton::new( row!(text("MEDIUM "), "B"), Choice::B, self.selected_radio, Message::RadioSelected, ); - + let c = SegmentedButton::new( row!(text("LIGHT "), "C"), Choice::C, diff --git a/src/native/mod.rs b/src/native/mod.rs index 02e39316..306f4b18 100644 --- a/src/native/mod.rs +++ b/src/native/mod.rs @@ -126,9 +126,9 @@ pub mod context_menu; pub type ContextMenu<'a, Overlay, Message, Renderer> = context_menu::ContextMenu<'a, Overlay, Message, Renderer>; - #[cfg(feature = "segmented_button")] pub mod segmented_button; #[cfg(feature = "segmented_button")] /// A badge for color highlighting small information. -pub type SegmentedButton<'a, Message, Renderer> = segmented_button::SegmentedButton<'a, Message, Renderer>; \ No newline at end of file +pub type SegmentedButton<'a, Message, Renderer> = + segmented_button::SegmentedButton<'a, Message, Renderer>; diff --git a/src/native/segmented_button.rs b/src/native/segmented_button.rs index 6f9e6bd2..ef02d26e 100644 --- a/src/native/segmented_button.rs +++ b/src/native/segmented_button.rs @@ -1,6 +1,6 @@ -//! Create choices using segnmented_button buttons. +//! Create choices using `segnmented_button` buttons. use iced_widget::core::{ - event, + event, layout::{Limits, Node}, mouse::{self, Cursor}, renderer, touch, @@ -11,9 +11,7 @@ use iced_widget::core::{ pub use crate::style::segmented_button::StyleSheet; - - -/// A segmented_button for color highlighting small information. +/// A `segnmented_button` for color highlighting small information. /// /// # Example /// ```ignore @@ -79,36 +77,42 @@ where } /// Sets the padding of the [`SegmentedButton`](SegmentedButton). + #[must_use] pub fn padding(mut self, units: Padding) -> Self { self.padding = units; self } /// Sets the width of the [`SegmentedButton`](SegmentedButton). + #[must_use] pub fn width(mut self, width: Length) -> Self { self.width = width; self } /// Sets the height of the [`SegmentedButton`](SegmentedButton). + #[must_use] pub fn height(mut self, height: Length) -> Self { self.height = height; self } /// Sets the horizontal alignment of the content of the [`SegmentedButton`](SegmentedButton). + #[must_use] pub fn align_x(mut self, alignment: Alignment) -> Self { self.horizontal_alignment = alignment; self } /// Sets the vertical alignment of the content of the [`SegmentedButton`](SegmentedButton). + #[must_use] pub fn align_y(mut self, alignment: Alignment) -> Self { self.vertical_alignment = alignment; self } /// Sets the style of the [`SegmentedButton`](SegmentedButton). + #[must_use] pub fn style(mut self, style: ::Style) -> Self { self.style = style; self @@ -138,7 +142,7 @@ where } fn layout(&self, renderer: &Renderer, limits: &Limits) -> Node { - let padding = self.padding.into(); + let padding = self.padding; let limits = limits .loose() .width(self.width) diff --git a/src/style/segmented_button.rs b/src/style/segmented_button.rs index cf3faeec..093144a3 100644 --- a/src/style/segmented_button.rs +++ b/src/style/segmented_button.rs @@ -1,4 +1,4 @@ -//! Use a segmented_button as an alternative to radio button. +//! Use a `segmented_button` as an alternative to radio button. use iced_widget::{ core::{Background, Color},