summaryrefslogtreecommitdiffstats
path: root/native/src/widget/toggler.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-01-02 19:40:20 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-01-02 19:40:57 +0100
commit76a2e65c4fc08da451215990238befd030d58128 (patch)
tree1e42a8a84b2eb4d3216a57ff28bf25a72085e86a /native/src/widget/toggler.rs
parenta5a406f9de2b7d9a3f31560af114c5fc577afb62 (diff)
downloadiced-76a2e65c4fc08da451215990238befd030d58128.tar.gz
iced-76a2e65c4fc08da451215990238befd030d58128.tar.bz2
iced-76a2e65c4fc08da451215990238befd030d58128.zip
Rename `is_checked` to `is_toggled` in `Toggler`
Diffstat (limited to 'native/src/widget/toggler.rs')
-rw-r--r--native/src/widget/toggler.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/native/src/widget/toggler.rs b/native/src/widget/toggler.rs
index 3696bf04..f0a944a3 100644
--- a/native/src/widget/toggler.rs
+++ b/native/src/widget/toggler.rs
@@ -24,9 +24,9 @@ pub use iced_style::toggler::{Appearance, StyleSheet};
/// TogglerToggled(bool),
/// }
///
-/// let is_checked = true;
+/// let is_toggled = true;
///
-/// Toggler::new(String::from("Toggle me!"), is_checked, |b| Message::TogglerToggled(b));
+/// Toggler::new(String::from("Toggle me!"), is_toggled, |b| Message::TogglerToggled(b));
/// ```
#[allow(missing_debug_implementations)]
pub struct Toggler<'a, Message, Renderer>
@@ -34,7 +34,7 @@ where
Renderer: text::Renderer,
Renderer::Theme: StyleSheet,
{
- is_checked: bool,
+ is_toggled: bool,
on_toggle: Box<dyn Fn(bool) -> Message + 'a>,
label: Option<String>,
width: Length,
@@ -64,14 +64,14 @@ where
/// `Message`.
pub fn new<F>(
label: impl Into<Option<String>>,
- is_checked: bool,
+ is_toggled: bool,
f: F,
) -> Self
where
F: 'a + Fn(bool) -> Message,
{
Toggler {
- is_checked,
+ is_toggled,
on_toggle: Box::new(f),
label: label.into(),
width: Length::Fill,
@@ -193,7 +193,7 @@ where
let mouse_over = layout.bounds().contains(cursor_position);
if mouse_over {
- shell.publish((self.on_toggle)(!self.is_checked));
+ shell.publish((self.on_toggle)(!self.is_toggled));
event::Status::Captured
} else {
@@ -260,9 +260,9 @@ where
let is_mouse_over = bounds.contains(cursor_position);
let style = if is_mouse_over {
- theme.hovered(&self.style, self.is_checked)
+ theme.hovered(&self.style, self.is_toggled)
} else {
- theme.active(&self.style, self.is_checked)
+ theme.active(&self.style, self.is_toggled)
};
let border_radius = bounds.height / BORDER_RADIUS_RATIO;
@@ -289,7 +289,7 @@ where
let toggler_foreground_bounds = Rectangle {
x: bounds.x
- + if self.is_checked {
+ + if self.is_toggled {
bounds.width - 2.0 * space - (bounds.height - (4.0 * space))
} else {
2.0 * space