summaryrefslogtreecommitdiffstats
path: root/native/src/widget/button.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-05-26 23:07:34 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-05-26 23:07:34 +0200
commitcf0230072c01ea9523f4d98a3656f5c975b3f347 (patch)
treeed24c6b90c6e319129e5fe963d50593846aaab72 /native/src/widget/button.rs
parent7f3b7075db68a215f4331b4bfba1c8ddd1c4d7f3 (diff)
downloadiced-cf0230072c01ea9523f4d98a3656f5c975b3f347.tar.gz
iced-cf0230072c01ea9523f4d98a3656f5c975b3f347.tar.bz2
iced-cf0230072c01ea9523f4d98a3656f5c975b3f347.zip
Rename `Variant` to `Style` and `Style` to `Appearance`
Diffstat (limited to 'native/src/widget/button.rs')
-rw-r--r--native/src/widget/button.rs38
1 files changed, 20 insertions, 18 deletions
diff --git a/native/src/widget/button.rs b/native/src/widget/button.rs
index 09c59cbe..d4e88424 100644
--- a/native/src/widget/button.rs
+++ b/native/src/widget/button.rs
@@ -12,7 +12,7 @@ use crate::{
Rectangle, Shell, Vector, Widget,
};
-pub use iced_style::button::{Style, StyleSheet};
+pub use iced_style::button::{Appearance, StyleSheet};
/// A generic widget that produces a message when pressed.
///
@@ -66,7 +66,7 @@ where
width: Length,
height: Length,
padding: Padding,
- variant: <Renderer::Theme as StyleSheet>::Variant,
+ style: <Renderer::Theme as StyleSheet>::Style,
}
impl<'a, Message, Renderer> Button<'a, Message, Renderer>
@@ -74,7 +74,6 @@ where
Message: Clone,
Renderer: crate::Renderer,
Renderer::Theme: StyleSheet,
- <Renderer::Theme as StyleSheet>::Variant: Default,
{
/// Creates a new [`Button`] with some local [`State`] and the given
/// content.
@@ -89,7 +88,7 @@ where
width: Length::Shrink,
height: Length::Shrink,
padding: Padding::new(5),
- variant: <Renderer::Theme as StyleSheet>::Variant::default(),
+ style: Default::default(),
}
}
@@ -118,12 +117,12 @@ where
self
}
- /// Sets the style variant of this [`Button`].
+ /// Sets the style of this [`Button`].
pub fn style(
mut self,
- variant: <Renderer::Theme as StyleSheet>::Variant,
+ style: <Renderer::Theme as StyleSheet>::Style,
) -> Self {
- self.variant = variant;
+ self.style = style;
self
}
}
@@ -196,29 +195,34 @@ pub fn update<'a, Message: Clone>(
}
/// Draws a [`Button`].
-pub fn draw<'a, Renderer: crate::Renderer, Variant>(
+pub fn draw<'a, Renderer: crate::Renderer>(
renderer: &mut Renderer,
bounds: Rectangle,
cursor_position: Point,
is_enabled: bool,
- style_sheet: &dyn StyleSheet<Variant = Variant>,
- variation: Variant,
+ style_sheet: &dyn StyleSheet<
+ Style = <Renderer::Theme as StyleSheet>::Style,
+ >,
+ style: <Renderer::Theme as StyleSheet>::Style,
state: impl FnOnce() -> &'a State,
-) -> Style {
+) -> Appearance
+where
+ Renderer::Theme: StyleSheet,
+{
let is_mouse_over = bounds.contains(cursor_position);
let styling = if !is_enabled {
- style_sheet.disabled(variation)
+ style_sheet.disabled(style)
} else if is_mouse_over {
let state = state();
if state.is_pressed {
- style_sheet.pressed(variation)
+ style_sheet.pressed(style)
} else {
- style_sheet.hovered(variation)
+ style_sheet.hovered(style)
}
} else {
- style_sheet.active(variation)
+ style_sheet.active(style)
};
if styling.background.is_some() || styling.border_width > 0.0 {
@@ -295,7 +299,6 @@ where
Message: Clone,
Renderer: crate::Renderer,
Renderer::Theme: StyleSheet,
- <Renderer::Theme as StyleSheet>::Variant: Copy,
{
fn width(&self) -> Length {
self.width
@@ -378,7 +381,7 @@ where
cursor_position,
self.on_press.is_some(),
theme,
- self.variant,
+ self.style,
|| &self.state,
);
@@ -410,7 +413,6 @@ where
Message: 'a + Clone,
Renderer: 'a + crate::Renderer,
Renderer::Theme: StyleSheet,
- <Renderer::Theme as StyleSheet>::Variant: Copy,
{
fn from(
button: Button<'a, Message, Renderer>,