Rename is_checked to is_toggled in Toggler
This commit is contained in:
parent
a5a406f9de
commit
76a2e65c4f
1 changed files with 9 additions and 9 deletions
|
|
@ -24,9 +24,9 @@ pub use iced_style::toggler::{Appearance, StyleSheet};
|
||||||
/// TogglerToggled(bool),
|
/// 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)]
|
#[allow(missing_debug_implementations)]
|
||||||
pub struct Toggler<'a, Message, Renderer>
|
pub struct Toggler<'a, Message, Renderer>
|
||||||
|
|
@ -34,7 +34,7 @@ where
|
||||||
Renderer: text::Renderer,
|
Renderer: text::Renderer,
|
||||||
Renderer::Theme: StyleSheet,
|
Renderer::Theme: StyleSheet,
|
||||||
{
|
{
|
||||||
is_checked: bool,
|
is_toggled: bool,
|
||||||
on_toggle: Box<dyn Fn(bool) -> Message + 'a>,
|
on_toggle: Box<dyn Fn(bool) -> Message + 'a>,
|
||||||
label: Option<String>,
|
label: Option<String>,
|
||||||
width: Length,
|
width: Length,
|
||||||
|
|
@ -64,14 +64,14 @@ where
|
||||||
/// `Message`.
|
/// `Message`.
|
||||||
pub fn new<F>(
|
pub fn new<F>(
|
||||||
label: impl Into<Option<String>>,
|
label: impl Into<Option<String>>,
|
||||||
is_checked: bool,
|
is_toggled: bool,
|
||||||
f: F,
|
f: F,
|
||||||
) -> Self
|
) -> Self
|
||||||
where
|
where
|
||||||
F: 'a + Fn(bool) -> Message,
|
F: 'a + Fn(bool) -> Message,
|
||||||
{
|
{
|
||||||
Toggler {
|
Toggler {
|
||||||
is_checked,
|
is_toggled,
|
||||||
on_toggle: Box::new(f),
|
on_toggle: Box::new(f),
|
||||||
label: label.into(),
|
label: label.into(),
|
||||||
width: Length::Fill,
|
width: Length::Fill,
|
||||||
|
|
@ -193,7 +193,7 @@ where
|
||||||
let mouse_over = layout.bounds().contains(cursor_position);
|
let mouse_over = layout.bounds().contains(cursor_position);
|
||||||
|
|
||||||
if mouse_over {
|
if mouse_over {
|
||||||
shell.publish((self.on_toggle)(!self.is_checked));
|
shell.publish((self.on_toggle)(!self.is_toggled));
|
||||||
|
|
||||||
event::Status::Captured
|
event::Status::Captured
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -260,9 +260,9 @@ where
|
||||||
let is_mouse_over = bounds.contains(cursor_position);
|
let is_mouse_over = bounds.contains(cursor_position);
|
||||||
|
|
||||||
let style = if is_mouse_over {
|
let style = if is_mouse_over {
|
||||||
theme.hovered(&self.style, self.is_checked)
|
theme.hovered(&self.style, self.is_toggled)
|
||||||
} else {
|
} else {
|
||||||
theme.active(&self.style, self.is_checked)
|
theme.active(&self.style, self.is_toggled)
|
||||||
};
|
};
|
||||||
|
|
||||||
let border_radius = bounds.height / BORDER_RADIUS_RATIO;
|
let border_radius = bounds.height / BORDER_RADIUS_RATIO;
|
||||||
|
|
@ -289,7 +289,7 @@ where
|
||||||
|
|
||||||
let toggler_foreground_bounds = Rectangle {
|
let toggler_foreground_bounds = Rectangle {
|
||||||
x: bounds.x
|
x: bounds.x
|
||||||
+ if self.is_checked {
|
+ if self.is_toggled {
|
||||||
bounds.width - 2.0 * space - (bounds.height - (4.0 * space))
|
bounds.width - 2.0 * space - (bounds.height - (4.0 * space))
|
||||||
} else {
|
} else {
|
||||||
2.0 * space
|
2.0 * space
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue