Rename Variant to Style and Style to Appearance

This commit is contained in:
Héctor Ramón Jiménez 2022-05-26 23:07:34 +02:00
parent 7f3b7075db
commit cf0230072c
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
12 changed files with 91 additions and 99 deletions

View file

@ -54,7 +54,6 @@ pub fn button<'a, Message, Renderer>(
where
Renderer: iced_native::Renderer,
Renderer::Theme: widget::button::StyleSheet,
<Renderer::Theme as widget::button::StyleSheet>::Variant: Default,
{
widget::Button::new(content)
}

View file

@ -12,7 +12,7 @@ use iced_native::{
Clipboard, Layout, Length, Padding, Point, Rectangle, Shell,
};
pub use iced_style::button::{Style, StyleSheet};
pub use iced_style::button::{Appearance, StyleSheet};
use button::State;
@ -60,14 +60,13 @@ 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>
where
Renderer: iced_native::Renderer,
Renderer::Theme: StyleSheet,
<Renderer::Theme as StyleSheet>::Variant: Default,
{
/// Creates a new [`Button`] with the given content.
pub fn new(content: impl Into<Element<'a, Message, Renderer>>) -> Self {
@ -77,7 +76,7 @@ where
width: Length::Shrink,
height: Length::Shrink,
padding: Padding::new(5),
variant: <Renderer::Theme as StyleSheet>::Variant::default(),
style: <Renderer::Theme as StyleSheet>::Style::default(),
}
}
@ -110,9 +109,9 @@ where
/// Sets the style variant 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
}
}
@ -123,7 +122,6 @@ where
Message: 'a + Clone,
Renderer: 'a + iced_native::Renderer,
Renderer::Theme: StyleSheet,
<Renderer::Theme as StyleSheet>::Variant: Copy,
{
fn tag(&self) -> tree::Tag {
tree::Tag::of::<State>()
@ -217,7 +215,7 @@ where
cursor_position,
self.on_press.is_some(),
theme,
self.variant,
self.style,
|| tree.state.downcast_ref::<State>(),
);
@ -269,7 +267,6 @@ where
Message: Clone + 'a,
Renderer: iced_native::Renderer + 'a,
Renderer::Theme: StyleSheet,
<Renderer::Theme as StyleSheet>::Variant: Copy,
{
fn into(self) -> Element<'a, Message, Renderer> {
Element::new(self)

View file

@ -11,7 +11,7 @@ use iced_native::{Clipboard, Layout, Length, Point, Rectangle, Shell, Size};
use std::ops::RangeInclusive;
pub use iced_style::slider::{Handle, HandleShape, Style, StyleSheet};
pub use iced_style::slider::{Appearance, Handle, HandleShape, StyleSheet};
/// An horizontal bar and a handle that selects a single value from a range of
/// values.
@ -49,7 +49,7 @@ where
on_release: Option<Message>,
width: Length,
height: u16,
variant: <Renderer::Theme as StyleSheet>::Variant,
style: <Renderer::Theme as StyleSheet>::Style,
}
impl<'a, T, Message, Renderer> Slider<'a, T, Message, Renderer>
@ -94,7 +94,7 @@ where
on_release: None,
width: Length::Fill,
height: Self::DEFAULT_HEIGHT,
variant: Default::default(),
style: Default::default(),
}
}
@ -124,9 +124,9 @@ where
/// Sets the style of the [`Slider`].
pub fn style(
mut self,
variant: impl Into<<Renderer::Theme as StyleSheet>::Variant>,
style: impl Into<<Renderer::Theme as StyleSheet>::Style>,
) -> Self {
self.variant = variant.into();
self.style = style.into();
self
}
@ -216,7 +216,7 @@ where
self.value,
&self.range,
theme,
self.variant,
self.style,
)
}