working examples with iced-sctk
This commit is contained in:
parent
5331cfb61b
commit
45ccc8c3d2
8 changed files with 447 additions and 39 deletions
|
|
@ -82,7 +82,7 @@ impl Default for Application {
|
|||
impl application::StyleSheet for Theme {
|
||||
type Style = Application;
|
||||
|
||||
fn appearance(&self, style: Self::Style) -> application::Appearance {
|
||||
fn appearance(&self, style: &Self::Style) -> application::Appearance {
|
||||
let cosmic = self.cosmic();
|
||||
|
||||
match style {
|
||||
|
|
@ -129,7 +129,7 @@ impl Button {
|
|||
impl button::StyleSheet for Theme {
|
||||
type Style = Button;
|
||||
|
||||
fn active(&self, style: Self::Style) -> button::Appearance {
|
||||
fn active(&self, style: &Self::Style) -> button::Appearance {
|
||||
let cosmic = style.cosmic(self);
|
||||
|
||||
button::Appearance {
|
||||
|
|
@ -143,8 +143,8 @@ impl button::StyleSheet for Theme {
|
|||
}
|
||||
}
|
||||
|
||||
fn hovered(&self, style: Self::Style) -> button::Appearance {
|
||||
let active = self.active(style);
|
||||
fn hovered(&self, style: &Self::Style) -> button::Appearance {
|
||||
let active = self.active(&style);
|
||||
let cosmic = style.cosmic(self);
|
||||
|
||||
button::Appearance {
|
||||
|
|
@ -176,7 +176,7 @@ impl checkbox::StyleSheet for Theme {
|
|||
|
||||
fn active(
|
||||
&self,
|
||||
style: Self::Style,
|
||||
style: &Self::Style,
|
||||
is_checked: bool,
|
||||
) -> checkbox::Appearance {
|
||||
let palette = self.extended_palette();
|
||||
|
|
@ -211,7 +211,7 @@ impl checkbox::StyleSheet for Theme {
|
|||
|
||||
fn hovered(
|
||||
&self,
|
||||
style: Self::Style,
|
||||
style: &Self::Style,
|
||||
is_checked: bool,
|
||||
) -> checkbox::Appearance {
|
||||
let palette = self.extended_palette();
|
||||
|
|
@ -319,7 +319,7 @@ impl From<fn(&Theme) -> container::Appearance> for Container {
|
|||
impl container::StyleSheet for Theme {
|
||||
type Style = Container;
|
||||
|
||||
fn appearance(&self, style: Self::Style) -> container::Appearance {
|
||||
fn appearance(&self, style: &Self::Style) -> container::Appearance {
|
||||
match style {
|
||||
Container::Transparent => Default::default(),
|
||||
Container::Box => {
|
||||
|
|
@ -344,7 +344,7 @@ impl container::StyleSheet for Theme {
|
|||
impl slider::StyleSheet for Theme {
|
||||
type Style = ();
|
||||
|
||||
fn active(&self, _style: Self::Style) -> slider::Appearance {
|
||||
fn active(&self, _style: &Self::Style) -> slider::Appearance {
|
||||
let cosmic = self.cosmic();
|
||||
|
||||
//TODO: no way to set rail thickness
|
||||
|
|
@ -365,8 +365,8 @@ impl slider::StyleSheet for Theme {
|
|||
}
|
||||
}
|
||||
|
||||
fn hovered(&self, style: Self::Style) -> slider::Appearance {
|
||||
let mut style = self.active(style);
|
||||
fn hovered(&self, style: &Self::Style) -> slider::Appearance {
|
||||
let mut style = self.active(&style);
|
||||
style.handle.shape = slider::HandleShape::Circle {
|
||||
radius: 16.0
|
||||
};
|
||||
|
|
@ -378,8 +378,8 @@ impl slider::StyleSheet for Theme {
|
|||
style
|
||||
}
|
||||
|
||||
fn dragging(&self, style: Self::Style) -> slider::Appearance {
|
||||
let mut style = self.hovered(style);
|
||||
fn dragging(&self, style: &Self::Style) -> slider::Appearance {
|
||||
let mut style = self.hovered(&style);
|
||||
style.handle.border_color = match self {
|
||||
Theme::Dark => Color::from_rgba8(0xFF, 0xFF, 0xFF, 0.2),
|
||||
Theme::Light => Color::from_rgba8(0, 0, 0, 0.2),
|
||||
|
|
@ -394,7 +394,7 @@ impl slider::StyleSheet for Theme {
|
|||
impl menu::StyleSheet for Theme {
|
||||
type Style = ();
|
||||
|
||||
fn appearance(&self, _style: Self::Style) -> menu::Appearance {
|
||||
fn appearance(&self, _style: &Self::Style) -> menu::Appearance {
|
||||
let cosmic = self.cosmic();
|
||||
|
||||
menu::Appearance {
|
||||
|
|
@ -415,7 +415,7 @@ impl menu::StyleSheet for Theme {
|
|||
impl pick_list::StyleSheet for Theme {
|
||||
type Style = ();
|
||||
|
||||
fn active(&self, _style: ()) -> pick_list::Appearance {
|
||||
fn active(&self, _style: &()) -> pick_list::Appearance {
|
||||
let cosmic = &self.cosmic().primary.component;
|
||||
|
||||
pick_list::Appearance {
|
||||
|
|
@ -429,12 +429,12 @@ impl pick_list::StyleSheet for Theme {
|
|||
}
|
||||
}
|
||||
|
||||
fn hovered(&self, style: ()) -> pick_list::Appearance {
|
||||
fn hovered(&self, style: &()) -> pick_list::Appearance {
|
||||
let cosmic = &self.cosmic().primary.component;
|
||||
|
||||
pick_list::Appearance {
|
||||
background: Background::Color(cosmic.hover.into()),
|
||||
..self.active(style)
|
||||
..self.active(&style)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -445,7 +445,7 @@ impl pick_list::StyleSheet for Theme {
|
|||
impl radio::StyleSheet for Theme {
|
||||
type Style = ();
|
||||
|
||||
fn active(&self, _style: Self::Style) -> radio::Appearance {
|
||||
fn active(&self, _style: &Self::Style, is_checked: bool) -> radio::Appearance {
|
||||
let palette = self.extended_palette();
|
||||
|
||||
radio::Appearance {
|
||||
|
|
@ -457,8 +457,8 @@ impl radio::StyleSheet for Theme {
|
|||
}
|
||||
}
|
||||
|
||||
fn hovered(&self, style: Self::Style) -> radio::Appearance {
|
||||
let active = self.active(style);
|
||||
fn hovered(&self, style: &Self::Style, is_checked: bool) -> radio::Appearance {
|
||||
let active = self.active(&style, is_checked);
|
||||
let palette = self.extended_palette();
|
||||
|
||||
radio::Appearance {
|
||||
|
|
@ -477,7 +477,7 @@ impl toggler::StyleSheet for Theme {
|
|||
|
||||
fn active(
|
||||
&self,
|
||||
_style: Self::Style,
|
||||
_style: &Self::Style,
|
||||
is_active: bool,
|
||||
) -> toggler::Appearance {
|
||||
let palette = self.palette();
|
||||
|
|
@ -504,7 +504,7 @@ impl toggler::StyleSheet for Theme {
|
|||
|
||||
fn hovered(
|
||||
&self,
|
||||
style: Self::Style,
|
||||
style: &Self::Style,
|
||||
is_active: bool,
|
||||
) -> toggler::Appearance {
|
||||
//TODO: grab colors from palette
|
||||
|
|
@ -515,7 +515,7 @@ impl toggler::StyleSheet for Theme {
|
|||
} else {
|
||||
Color::from_rgb8(0xb6, 0xb6, 0xb6)
|
||||
},
|
||||
..self.active(style, is_active)
|
||||
..self.active(&style, is_active)
|
||||
},
|
||||
Theme::Light => toggler::Appearance {
|
||||
background: if is_active {
|
||||
|
|
@ -523,7 +523,7 @@ impl toggler::StyleSheet for Theme {
|
|||
} else {
|
||||
Color::from_rgb8(0x54, 0x54, 0x54)
|
||||
},
|
||||
..self.active(style, is_active)
|
||||
..self.active(&style, is_active)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -535,7 +535,7 @@ impl toggler::StyleSheet for Theme {
|
|||
impl pane_grid::StyleSheet for Theme {
|
||||
type Style = ();
|
||||
|
||||
fn picked_split(&self, _style: Self::Style) -> Option<pane_grid::Line> {
|
||||
fn picked_split(&self, _style: &Self::Style) -> Option<pane_grid::Line> {
|
||||
let palette = self.extended_palette();
|
||||
|
||||
Some(pane_grid::Line {
|
||||
|
|
@ -544,7 +544,7 @@ impl pane_grid::StyleSheet for Theme {
|
|||
})
|
||||
}
|
||||
|
||||
fn hovered_split(&self, _style: Self::Style) -> Option<pane_grid::Line> {
|
||||
fn hovered_split(&self, _style: &Self::Style) -> Option<pane_grid::Line> {
|
||||
let palette = self.extended_palette();
|
||||
|
||||
Some(pane_grid::Line {
|
||||
|
|
@ -574,7 +574,7 @@ impl Default for ProgressBar {
|
|||
impl progress_bar::StyleSheet for Theme {
|
||||
type Style = ProgressBar;
|
||||
|
||||
fn appearance(&self, style: Self::Style) -> progress_bar::Appearance {
|
||||
fn appearance(&self, style: &Self::Style) -> progress_bar::Appearance {
|
||||
let palette = self.extended_palette();
|
||||
|
||||
let from_palette = |bar: Color| progress_bar::Appearance {
|
||||
|
|
@ -610,7 +610,7 @@ impl Default for Rule {
|
|||
impl rule::StyleSheet for Theme {
|
||||
type Style = Rule;
|
||||
|
||||
fn style(&self, style: Self::Style) -> rule::Appearance {
|
||||
fn appearance(&self, style: &Self::Style) -> rule::Appearance {
|
||||
let palette = self.extended_palette();
|
||||
|
||||
match style {
|
||||
|
|
@ -631,7 +631,7 @@ impl rule::StyleSheet for Theme {
|
|||
impl scrollable::StyleSheet for Theme {
|
||||
type Style = ();
|
||||
|
||||
fn active(&self, _style: Self::Style) -> scrollable::Scrollbar {
|
||||
fn active(&self, _style: &Self::Style) -> scrollable::Scrollbar {
|
||||
let palette = self.extended_palette();
|
||||
|
||||
scrollable::Scrollbar {
|
||||
|
|
@ -648,7 +648,7 @@ impl scrollable::StyleSheet for Theme {
|
|||
}
|
||||
}
|
||||
|
||||
fn hovered(&self, _style: Self::Style) -> scrollable::Scrollbar {
|
||||
fn hovered(&self, _style: &Self::Style) -> scrollable::Scrollbar {
|
||||
let palette = self.extended_palette();
|
||||
|
||||
scrollable::Scrollbar {
|
||||
|
|
@ -730,7 +730,7 @@ impl text::StyleSheet for Theme {
|
|||
impl text_input::StyleSheet for Theme {
|
||||
type Style = ();
|
||||
|
||||
fn active(&self, _style: Self::Style) -> text_input::Appearance {
|
||||
fn active(&self, _style: &Self::Style) -> text_input::Appearance {
|
||||
let palette = self.extended_palette();
|
||||
|
||||
text_input::Appearance {
|
||||
|
|
@ -741,7 +741,7 @@ impl text_input::StyleSheet for Theme {
|
|||
}
|
||||
}
|
||||
|
||||
fn hovered(&self, _style: Self::Style) -> text_input::Appearance {
|
||||
fn hovered(&self, _style: &Self::Style) -> text_input::Appearance {
|
||||
let palette = self.extended_palette();
|
||||
|
||||
text_input::Appearance {
|
||||
|
|
@ -752,7 +752,7 @@ impl text_input::StyleSheet for Theme {
|
|||
}
|
||||
}
|
||||
|
||||
fn focused(&self, _style: Self::Style) -> text_input::Appearance {
|
||||
fn focused(&self, _style: &Self::Style) -> text_input::Appearance {
|
||||
let palette = self.extended_palette();
|
||||
|
||||
text_input::Appearance {
|
||||
|
|
@ -763,19 +763,19 @@ impl text_input::StyleSheet for Theme {
|
|||
}
|
||||
}
|
||||
|
||||
fn placeholder_color(&self, _style: Self::Style) -> Color {
|
||||
fn placeholder_color(&self, _style: &Self::Style) -> Color {
|
||||
let palette = self.extended_palette();
|
||||
|
||||
palette.background.strong.color
|
||||
}
|
||||
|
||||
fn value_color(&self, _style: Self::Style) -> Color {
|
||||
fn value_color(&self, _style: &Self::Style) -> Color {
|
||||
let palette = self.extended_palette();
|
||||
|
||||
palette.background.base.text
|
||||
}
|
||||
|
||||
fn selection_color(&self, _style: Self::Style) -> Color {
|
||||
fn selection_color(&self, _style: &Self::Style) -> Color {
|
||||
let palette = self.extended_palette();
|
||||
|
||||
palette.primary.weak.color
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ where
|
|||
cursor_position: Point,
|
||||
viewport: &Rectangle,
|
||||
) {
|
||||
let color_scheme = theme.appearance(self.style);
|
||||
let color_scheme = theme.appearance(&self.style);
|
||||
|
||||
draw_background(renderer, &color_scheme, layout.bounds());
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue