udpate iced to use latest rebase
This commit is contained in:
parent
804b183492
commit
850968715c
13 changed files with 87 additions and 73 deletions
|
|
@ -7,23 +7,21 @@ edition = "2021"
|
||||||
name = "cosmic"
|
name = "cosmic"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["tiny_skia", "winit", "tokio", "a11y"]
|
default = ["winit", "tokio", "a11y"]
|
||||||
debug = ["iced/debug"]
|
debug = ["iced/debug"]
|
||||||
a11y = ["iced/a11y", "iced_accessibility"]
|
a11y = ["iced/a11y", "iced_accessibility"]
|
||||||
tiny_skia = ["iced/tiny-skia", "iced_tiny_skia"]
|
|
||||||
wayland = ["iced/wayland", "iced_sctk", "sctk",]
|
wayland = ["iced/wayland", "iced_sctk", "sctk",]
|
||||||
wgpu = ["iced/wgpu", "iced_wgpu"]
|
wgpu = ["iced/wgpu", "iced_wgpu"]
|
||||||
tokio = ["dep:tokio", "iced/tokio"]
|
tokio = ["dep:tokio", "iced/tokio"]
|
||||||
smol = ["iced/smol"]
|
smol = ["iced/smol"]
|
||||||
winit = ["iced/winit", "iced_winit"]
|
winit = ["iced/winit", "iced_winit"]
|
||||||
winit_tiny_skia = ["winit", "tiny_skia"]
|
|
||||||
winit_wgpu = ["winit", "wgpu"]
|
winit_wgpu = ["winit", "wgpu"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
apply = "0.3.0"
|
apply = "0.3.0"
|
||||||
derive_setters = "0.1.5"
|
derive_setters = "0.1.5"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
palette = "0.6.1"
|
palette = "0.7"
|
||||||
tokio = { version = "1.24.2", optional = true }
|
tokio = { version = "1.24.2", optional = true }
|
||||||
sctk = { package = "smithay-client-toolkit", git = "https://github.com/pop-os/client-toolkit", optional = true, tag = "themed-pointer"}
|
sctk = { package = "smithay-client-toolkit", git = "https://github.com/pop-os/client-toolkit", optional = true, tag = "themed-pointer"}
|
||||||
slotmap = "1.0.6"
|
slotmap = "1.0.6"
|
||||||
|
|
@ -61,9 +59,9 @@ path = "iced/futures"
|
||||||
path = "iced/accessibility"
|
path = "iced/accessibility"
|
||||||
|
|
||||||
optional = true
|
optional = true
|
||||||
|
|
||||||
[dependencies.iced_tiny_skia]
|
[dependencies.iced_tiny_skia]
|
||||||
path = "iced/tiny_skia"
|
path = "iced/tiny_skia"
|
||||||
optional = true
|
|
||||||
|
|
||||||
[dependencies.iced_style]
|
[dependencies.iced_style]
|
||||||
path = "iced/style"
|
path = "iced/style"
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ theme-from-image = ["kmeans_colors", "contrast-derivation", "float-cmp", "image"
|
||||||
hex-color = ["hex"]
|
hex-color = ["hex"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
palette = {version = "0.6", features = ["serializing"] }
|
palette = {version = "0.7", features = ["serializing"] }
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
hex = {version = "0.4.3", optional = true}
|
hex = {version = "0.4.3", optional = true}
|
||||||
kmeans_colors = { version = "0.5", features = ["palette_color"], default-features = false, optional = true }
|
kmeans_colors = { version = "0.5", features = ["palette_color"], default-features = false, optional = true }
|
||||||
|
|
|
||||||
|
|
@ -6,4 +6,4 @@ edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
libcosmic = { path = "../..", default-features = false, features = ["wayland", "tokio", "tiny_skia", "a11y"] }
|
libcosmic = { path = "../..", default-features = false, features = ["wayland", "tokio", "a11y"] }
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ publish = false
|
||||||
[dependencies]
|
[dependencies]
|
||||||
apply = "0.3.0"
|
apply = "0.3.0"
|
||||||
fraction = "0.13.0"
|
fraction = "0.13.0"
|
||||||
libcosmic = { path = "../..", default-features = false, features = ["debug", "winit_tiny_skia", "a11y"] }
|
libcosmic = { path = "../..", default-features = false, features = ["debug", "winit", "a11y"] }
|
||||||
once_cell = "1.15"
|
once_cell = "1.15"
|
||||||
slotmap = "1.0.6"
|
slotmap = "1.0.6"
|
||||||
env_logger = "0.10"
|
env_logger = "0.10"
|
||||||
|
|
|
||||||
2
iced
2
iced
|
|
@ -1 +1 @@
|
||||||
Subproject commit 978e9fe8142bb301ce27ad23ce0afb12ef8918a7
|
Subproject commit c308e2266867a7bb4dfadb2dc8bdf310b7c87ee8
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
pub mod expander;
|
pub mod expander;
|
||||||
mod segmented_button;
|
mod segmented_button;
|
||||||
|
|
||||||
|
use std::f32::consts::PI;
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
use std::hash::Hasher;
|
use std::hash::Hasher;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
@ -16,7 +17,9 @@ use cosmic_config::CosmicConfigEntry;
|
||||||
use cosmic_theme::util::CssColor;
|
use cosmic_theme::util::CssColor;
|
||||||
use cosmic_theme::Component;
|
use cosmic_theme::Component;
|
||||||
use cosmic_theme::LayeredTheme;
|
use cosmic_theme::LayeredTheme;
|
||||||
use iced_core::renderer::BorderRadius;
|
use iced_core::gradient::Linear;
|
||||||
|
use iced_core::BorderRadius;
|
||||||
|
use iced_core::Radians;
|
||||||
use iced_futures::Subscription;
|
use iced_futures::Subscription;
|
||||||
use iced_style::application;
|
use iced_style::application;
|
||||||
use iced_style::button;
|
use iced_style::button;
|
||||||
|
|
@ -233,8 +236,8 @@ impl button::StyleSheet for Theme {
|
||||||
let component = style.cosmic(self);
|
let component = style.cosmic(self);
|
||||||
button::Appearance {
|
button::Appearance {
|
||||||
border_radius: match style {
|
border_radius: match style {
|
||||||
Button::Link => 0.0,
|
Button::Link => 0.0.into(),
|
||||||
_ => 24.0,
|
_ => 24.0.into(),
|
||||||
},
|
},
|
||||||
background: match style {
|
background: match style {
|
||||||
Button::Link | Button::Text => None,
|
Button::Link | Button::Text => None,
|
||||||
|
|
@ -317,7 +320,7 @@ impl checkbox::StyleSheet for Theme {
|
||||||
palette.background.base.into()
|
palette.background.base.into()
|
||||||
}),
|
}),
|
||||||
icon_color: palette.accent.on.into(),
|
icon_color: palette.accent.on.into(),
|
||||||
border_radius: 4.0,
|
border_radius: 4.0.into(),
|
||||||
border_width: if is_checked { 0.0 } else { 1.0 },
|
border_width: if is_checked { 0.0 } else { 1.0 },
|
||||||
border_color: if is_checked {
|
border_color: if is_checked {
|
||||||
palette.accent.base
|
palette.accent.base
|
||||||
|
|
@ -334,7 +337,7 @@ impl checkbox::StyleSheet for Theme {
|
||||||
palette.background.base.into()
|
palette.background.base.into()
|
||||||
}),
|
}),
|
||||||
icon_color: palette.background.on.into(),
|
icon_color: palette.background.on.into(),
|
||||||
border_radius: 4.0,
|
border_radius: 4.0.into(),
|
||||||
border_width: if is_checked { 0.0 } else { 1.0 },
|
border_width: if is_checked { 0.0 } else { 1.0 },
|
||||||
border_color: neutral_7.into(),
|
border_color: neutral_7.into(),
|
||||||
text_color: None,
|
text_color: None,
|
||||||
|
|
@ -346,7 +349,7 @@ impl checkbox::StyleSheet for Theme {
|
||||||
palette.background.base.into()
|
palette.background.base.into()
|
||||||
}),
|
}),
|
||||||
icon_color: palette.success.on.into(),
|
icon_color: palette.success.on.into(),
|
||||||
border_radius: 4.0,
|
border_radius: 4.0.into(),
|
||||||
border_width: if is_checked { 0.0 } else { 1.0 },
|
border_width: if is_checked { 0.0 } else { 1.0 },
|
||||||
border_color: if is_checked {
|
border_color: if is_checked {
|
||||||
palette.success.base
|
palette.success.base
|
||||||
|
|
@ -363,7 +366,7 @@ impl checkbox::StyleSheet for Theme {
|
||||||
palette.background.base.into()
|
palette.background.base.into()
|
||||||
}),
|
}),
|
||||||
icon_color: palette.destructive.on.into(),
|
icon_color: palette.destructive.on.into(),
|
||||||
border_radius: 4.0,
|
border_radius: 4.0.into(),
|
||||||
border_width: if is_checked { 0.0 } else { 1.0 },
|
border_width: if is_checked { 0.0 } else { 1.0 },
|
||||||
border_color: if is_checked {
|
border_color: if is_checked {
|
||||||
palette.destructive.base
|
palette.destructive.base
|
||||||
|
|
@ -390,7 +393,7 @@ impl checkbox::StyleSheet for Theme {
|
||||||
neutral_10.into()
|
neutral_10.into()
|
||||||
}),
|
}),
|
||||||
icon_color: palette.accent.on.into(),
|
icon_color: palette.accent.on.into(),
|
||||||
border_radius: 4.0,
|
border_radius: 4.0.into(),
|
||||||
border_width: if is_checked { 0.0 } else { 1.0 },
|
border_width: if is_checked { 0.0 } else { 1.0 },
|
||||||
border_color: if is_checked {
|
border_color: if is_checked {
|
||||||
palette.accent.base
|
palette.accent.base
|
||||||
|
|
@ -407,7 +410,7 @@ impl checkbox::StyleSheet for Theme {
|
||||||
neutral_10.into()
|
neutral_10.into()
|
||||||
}),
|
}),
|
||||||
icon_color: self.current_container().on.into(),
|
icon_color: self.current_container().on.into(),
|
||||||
border_radius: 4.0,
|
border_radius: 4.0.into(),
|
||||||
border_width: if is_checked { 0.0 } else { 1.0 },
|
border_width: if is_checked { 0.0 } else { 1.0 },
|
||||||
border_color: if is_checked {
|
border_color: if is_checked {
|
||||||
self.current_container().base
|
self.current_container().base
|
||||||
|
|
@ -424,7 +427,7 @@ impl checkbox::StyleSheet for Theme {
|
||||||
neutral_10.into()
|
neutral_10.into()
|
||||||
}),
|
}),
|
||||||
icon_color: palette.success.on.into(),
|
icon_color: palette.success.on.into(),
|
||||||
border_radius: 4.0,
|
border_radius: 4.0.into(),
|
||||||
border_width: if is_checked { 0.0 } else { 1.0 },
|
border_width: if is_checked { 0.0 } else { 1.0 },
|
||||||
border_color: if is_checked {
|
border_color: if is_checked {
|
||||||
palette.success.base
|
palette.success.base
|
||||||
|
|
@ -441,7 +444,7 @@ impl checkbox::StyleSheet for Theme {
|
||||||
neutral_10.into()
|
neutral_10.into()
|
||||||
}),
|
}),
|
||||||
icon_color: palette.destructive.on.into(),
|
icon_color: palette.destructive.on.into(),
|
||||||
border_radius: 4.0,
|
border_radius: 4.0.into(),
|
||||||
border_width: if is_checked { 0.0 } else { 1.0 },
|
border_width: if is_checked { 0.0 } else { 1.0 },
|
||||||
border_color: if is_checked {
|
border_color: if is_checked {
|
||||||
palette.destructive.base
|
palette.destructive.base
|
||||||
|
|
@ -519,10 +522,17 @@ impl container::StyleSheet for Theme {
|
||||||
}
|
}
|
||||||
Container::HeaderBar => {
|
Container::HeaderBar => {
|
||||||
let palette = self.cosmic();
|
let palette = self.cosmic();
|
||||||
|
let mut header_top = palette.background.base;
|
||||||
|
let header_bottom = palette.background.base;
|
||||||
|
header_top.alpha = 0.8;
|
||||||
|
|
||||||
container::Appearance {
|
container::Appearance {
|
||||||
text_color: Some(Color::from(palette.background.on)),
|
text_color: Some(Color::from(palette.background.on)),
|
||||||
background: Some(iced::Background::Color(palette.background.base.into())),
|
background: Some(iced::Background::Gradient(iced_core::Gradient::Linear(
|
||||||
|
Linear::new(Radians(3.0 * PI / 2.0))
|
||||||
|
.add_stop(0.0, header_top.into())
|
||||||
|
.add_stop(1.0, header_bottom.into()),
|
||||||
|
))),
|
||||||
border_radius: BorderRadius::from([16.0, 16.0, 0.0, 0.0]),
|
border_radius: BorderRadius::from([16.0, 16.0, 0.0, 0.0]),
|
||||||
border_width: 0.0,
|
border_width: 0.0,
|
||||||
border_color: Color::TRANSPARENT,
|
border_color: Color::TRANSPARENT,
|
||||||
|
|
@ -572,6 +582,7 @@ impl slider::StyleSheet for Theme {
|
||||||
Color::TRANSPARENT,
|
Color::TRANSPARENT,
|
||||||
),
|
),
|
||||||
width: 4.0,
|
width: 4.0,
|
||||||
|
border_radius: 2.0.into(),
|
||||||
},
|
},
|
||||||
|
|
||||||
handle: slider::Handle {
|
handle: slider::Handle {
|
||||||
|
|
@ -616,7 +627,7 @@ impl menu::StyleSheet for Theme {
|
||||||
text_color: cosmic.on_bg_color().into(),
|
text_color: cosmic.on_bg_color().into(),
|
||||||
background: Background::Color(cosmic.background.base.into()),
|
background: Background::Color(cosmic.background.base.into()),
|
||||||
border_width: 0.0,
|
border_width: 0.0,
|
||||||
border_radius: 16.0,
|
border_radius: 16.0.into(),
|
||||||
border_color: Color::TRANSPARENT,
|
border_color: Color::TRANSPARENT,
|
||||||
selected_text_color: cosmic.on_bg_color().into(),
|
selected_text_color: cosmic.on_bg_color().into(),
|
||||||
// TODO doesn't seem to be specified
|
// TODO doesn't seem to be specified
|
||||||
|
|
@ -638,7 +649,7 @@ impl pick_list::StyleSheet for Theme {
|
||||||
text_color: cosmic.on_bg_color().into(),
|
text_color: cosmic.on_bg_color().into(),
|
||||||
background: Color::TRANSPARENT.into(),
|
background: Color::TRANSPARENT.into(),
|
||||||
placeholder_color: cosmic.on_bg_color().into(),
|
placeholder_color: cosmic.on_bg_color().into(),
|
||||||
border_radius: 24.0,
|
border_radius: 24.0.into(),
|
||||||
border_width: 0.0,
|
border_width: 0.0,
|
||||||
border_color: Color::TRANSPARENT,
|
border_color: Color::TRANSPARENT,
|
||||||
// icon_size: 0.7, // TODO: how to replace
|
// icon_size: 0.7, // TODO: how to replace
|
||||||
|
|
@ -772,6 +783,16 @@ impl pane_grid::StyleSheet for Theme {
|
||||||
width: 2.0,
|
width: 2.0,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn hovered_region(&self, style: &Self::Style) -> pane_grid::Appearance {
|
||||||
|
let theme = self.cosmic();
|
||||||
|
pane_grid::Appearance {
|
||||||
|
background: Background::Color(theme.bg_color().into()),
|
||||||
|
border_width: 2.0,
|
||||||
|
border_color: theme.bg_divider().into(),
|
||||||
|
border_radius: 0.0.into(),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -802,17 +823,17 @@ impl progress_bar::StyleSheet for Theme {
|
||||||
ProgressBar::Primary => progress_bar::Appearance {
|
ProgressBar::Primary => progress_bar::Appearance {
|
||||||
background: Color::from(theme.background.divider).into(),
|
background: Color::from(theme.background.divider).into(),
|
||||||
bar: Color::from(theme.accent.base).into(),
|
bar: Color::from(theme.accent.base).into(),
|
||||||
border_radius: 2.0,
|
border_radius: 2.0.into(),
|
||||||
},
|
},
|
||||||
ProgressBar::Success => progress_bar::Appearance {
|
ProgressBar::Success => progress_bar::Appearance {
|
||||||
background: Color::from(theme.background.divider).into(),
|
background: Color::from(theme.background.divider).into(),
|
||||||
bar: Color::from(theme.success.base).into(),
|
bar: Color::from(theme.success.base).into(),
|
||||||
border_radius: 2.0,
|
border_radius: 2.0.into(),
|
||||||
},
|
},
|
||||||
ProgressBar::Danger => progress_bar::Appearance {
|
ProgressBar::Danger => progress_bar::Appearance {
|
||||||
background: Color::from(theme.background.divider).into(),
|
background: Color::from(theme.background.divider).into(),
|
||||||
bar: Color::from(theme.destructive.base).into(),
|
bar: Color::from(theme.destructive.base).into(),
|
||||||
border_radius: 2.0,
|
border_radius: 2.0.into(),
|
||||||
},
|
},
|
||||||
ProgressBar::Custom(f) => f(self),
|
ProgressBar::Custom(f) => f(self),
|
||||||
}
|
}
|
||||||
|
|
@ -845,19 +866,19 @@ impl rule::StyleSheet for Theme {
|
||||||
Rule::Default => rule::Appearance {
|
Rule::Default => rule::Appearance {
|
||||||
color: self.current_container().divider.into(),
|
color: self.current_container().divider.into(),
|
||||||
width: 1,
|
width: 1,
|
||||||
radius: 0.0,
|
radius: 0.0.into(),
|
||||||
fill_mode: rule::FillMode::Full,
|
fill_mode: rule::FillMode::Full,
|
||||||
},
|
},
|
||||||
Rule::LightDivider => rule::Appearance {
|
Rule::LightDivider => rule::Appearance {
|
||||||
color: self.current_container().divider.into(),
|
color: self.current_container().divider.into(),
|
||||||
width: 1,
|
width: 1,
|
||||||
radius: 0.0,
|
radius: 0.0.into(),
|
||||||
fill_mode: rule::FillMode::Padded(10),
|
fill_mode: rule::FillMode::Padded(10),
|
||||||
},
|
},
|
||||||
Rule::HeavyDivider => rule::Appearance {
|
Rule::HeavyDivider => rule::Appearance {
|
||||||
color: self.current_container().divider.into(),
|
color: self.current_container().divider.into(),
|
||||||
width: 4,
|
width: 4,
|
||||||
radius: 4.0,
|
radius: 4.0.into(),
|
||||||
fill_mode: rule::FillMode::Full,
|
fill_mode: rule::FillMode::Full,
|
||||||
},
|
},
|
||||||
Rule::Custom(f) => f(self),
|
Rule::Custom(f) => f(self),
|
||||||
|
|
@ -876,12 +897,12 @@ impl scrollable::StyleSheet for Theme {
|
||||||
background: Some(Background::Color(
|
background: Some(Background::Color(
|
||||||
self.current_container().component.base.into(),
|
self.current_container().component.base.into(),
|
||||||
)),
|
)),
|
||||||
border_radius: 4.0,
|
border_radius: 4.0.into(),
|
||||||
border_width: 0.0,
|
border_width: 0.0,
|
||||||
border_color: Color::TRANSPARENT,
|
border_color: Color::TRANSPARENT,
|
||||||
scroller: scrollable::Scroller {
|
scroller: scrollable::Scroller {
|
||||||
color: self.current_container().component.divider.into(),
|
color: self.current_container().component.divider.into(),
|
||||||
border_radius: 4.0,
|
border_radius: 4.0.into(),
|
||||||
border_width: 0.0,
|
border_width: 0.0,
|
||||||
border_color: Color::TRANSPARENT,
|
border_color: Color::TRANSPARENT,
|
||||||
},
|
},
|
||||||
|
|
@ -899,12 +920,12 @@ impl scrollable::StyleSheet for Theme {
|
||||||
background: Some(Background::Color(
|
background: Some(Background::Color(
|
||||||
self.current_container().component.hover.into(),
|
self.current_container().component.hover.into(),
|
||||||
)),
|
)),
|
||||||
border_radius: 4.0,
|
border_radius: 4.0.into(),
|
||||||
border_width: 0.0,
|
border_width: 0.0,
|
||||||
border_color: Color::TRANSPARENT,
|
border_color: Color::TRANSPARENT,
|
||||||
scroller: scrollable::Scroller {
|
scroller: scrollable::Scroller {
|
||||||
color: theme.accent.base.into(),
|
color: theme.accent.base.into(),
|
||||||
border_radius: 4.0,
|
border_radius: 4.0.into(),
|
||||||
border_width: 0.0,
|
border_width: 0.0,
|
||||||
border_color: Color::TRANSPARENT,
|
border_color: Color::TRANSPARENT,
|
||||||
},
|
},
|
||||||
|
|
@ -1028,14 +1049,14 @@ impl text_input::StyleSheet for Theme {
|
||||||
match style {
|
match style {
|
||||||
TextInput::Default => text_input::Appearance {
|
TextInput::Default => text_input::Appearance {
|
||||||
background: Color::from(bg).into(),
|
background: Color::from(bg).into(),
|
||||||
border_radius: 8.0,
|
border_radius: 8.0.into(),
|
||||||
border_width: 1.0,
|
border_width: 1.0,
|
||||||
border_color: self.current_container().component.divider.into(),
|
border_color: self.current_container().component.divider.into(),
|
||||||
icon_color: self.current_container().on.into(),
|
icon_color: self.current_container().on.into(),
|
||||||
},
|
},
|
||||||
TextInput::Search => text_input::Appearance {
|
TextInput::Search => text_input::Appearance {
|
||||||
background: Color::from(bg).into(),
|
background: Color::from(bg).into(),
|
||||||
border_radius: 24.0,
|
border_radius: 24.0.into(),
|
||||||
border_width: 0.0,
|
border_width: 0.0,
|
||||||
border_color: Color::TRANSPARENT,
|
border_color: Color::TRANSPARENT,
|
||||||
icon_color: self.current_container().on.into(),
|
icon_color: self.current_container().on.into(),
|
||||||
|
|
@ -1051,14 +1072,14 @@ impl text_input::StyleSheet for Theme {
|
||||||
match style {
|
match style {
|
||||||
TextInput::Default => text_input::Appearance {
|
TextInput::Default => text_input::Appearance {
|
||||||
background: Color::from(bg).into(),
|
background: Color::from(bg).into(),
|
||||||
border_radius: 8.0,
|
border_radius: 8.0.into(),
|
||||||
border_width: 1.0,
|
border_width: 1.0,
|
||||||
border_color: palette.accent.base.into(),
|
border_color: palette.accent.base.into(),
|
||||||
icon_color: self.current_container().on.into(),
|
icon_color: self.current_container().on.into(),
|
||||||
},
|
},
|
||||||
TextInput::Search => text_input::Appearance {
|
TextInput::Search => text_input::Appearance {
|
||||||
background: Color::from(bg).into(),
|
background: Color::from(bg).into(),
|
||||||
border_radius: 24.0,
|
border_radius: 24.0.into(),
|
||||||
border_width: 0.0,
|
border_width: 0.0,
|
||||||
border_color: Color::TRANSPARENT,
|
border_color: Color::TRANSPARENT,
|
||||||
icon_color: self.current_container().on.into(),
|
icon_color: self.current_container().on.into(),
|
||||||
|
|
@ -1074,14 +1095,14 @@ impl text_input::StyleSheet for Theme {
|
||||||
match style {
|
match style {
|
||||||
TextInput::Default => text_input::Appearance {
|
TextInput::Default => text_input::Appearance {
|
||||||
background: Color::from(bg).into(),
|
background: Color::from(bg).into(),
|
||||||
border_radius: 8.0,
|
border_radius: 8.0.into(),
|
||||||
border_width: 1.0,
|
border_width: 1.0,
|
||||||
border_color: palette.accent.base.into(),
|
border_color: palette.accent.base.into(),
|
||||||
icon_color: self.current_container().on.into(),
|
icon_color: self.current_container().on.into(),
|
||||||
},
|
},
|
||||||
TextInput::Search => text_input::Appearance {
|
TextInput::Search => text_input::Appearance {
|
||||||
background: Color::from(bg).into(),
|
background: Color::from(bg).into(),
|
||||||
border_radius: 24.0,
|
border_radius: 24.0.into(),
|
||||||
border_width: 0.0,
|
border_width: 0.0,
|
||||||
border_color: Color::TRANSPARENT,
|
border_color: Color::TRANSPARENT,
|
||||||
icon_color: self.current_container().on.into(),
|
icon_color: self.current_container().on.into(),
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
use crate::widget::segmented_button::{Appearance, ItemAppearance, StyleSheet};
|
use crate::widget::segmented_button::{Appearance, ItemAppearance, StyleSheet};
|
||||||
use crate::{theme::Theme, widget::segmented_button::ItemStatusAppearance};
|
use crate::{theme::Theme, widget::segmented_button::ItemStatusAppearance};
|
||||||
use iced_core::{renderer::BorderRadius, Background};
|
use iced_core::{Background, BorderRadius};
|
||||||
use palette::{rgb::Rgb, Alpha};
|
use palette::{rgb::Rgb, Alpha};
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
|
@ -141,7 +141,7 @@ impl StyleSheet for Theme {
|
||||||
|
|
||||||
mod horizontal {
|
mod horizontal {
|
||||||
use crate::widget::segmented_button::{ItemAppearance, ItemStatusAppearance};
|
use crate::widget::segmented_button::{ItemAppearance, ItemStatusAppearance};
|
||||||
use iced_core::{renderer::BorderRadius, Background};
|
use iced_core::{Background, BorderRadius};
|
||||||
use palette::{rgb::Rgb, Alpha};
|
use palette::{rgb::Rgb, Alpha};
|
||||||
|
|
||||||
pub fn selection_active(cosmic: &cosmic_theme::Theme<Alpha<Rgb, f32>>) -> ItemStatusAppearance {
|
pub fn selection_active(cosmic: &cosmic_theme::Theme<Alpha<Rgb, f32>>) -> ItemStatusAppearance {
|
||||||
|
|
@ -222,7 +222,7 @@ pub fn hover(
|
||||||
|
|
||||||
mod vertical {
|
mod vertical {
|
||||||
use crate::widget::segmented_button::{ItemAppearance, ItemStatusAppearance};
|
use crate::widget::segmented_button::{ItemAppearance, ItemStatusAppearance};
|
||||||
use iced_core::{renderer::BorderRadius, Background};
|
use iced_core::{Background, BorderRadius};
|
||||||
use palette::{rgb::Rgb, Alpha};
|
use palette::{rgb::Rgb, Alpha};
|
||||||
|
|
||||||
pub fn selection_active(cosmic: &cosmic_theme::Theme<Alpha<Rgb, f32>>) -> ItemStatusAppearance {
|
pub fn selection_active(cosmic: &cosmic_theme::Theme<Alpha<Rgb, f32>>) -> ItemStatusAppearance {
|
||||||
|
|
|
||||||
|
|
@ -186,7 +186,7 @@ where
|
||||||
tree: &mut Tree,
|
tree: &mut Tree,
|
||||||
event: Event,
|
event: Event,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: mouse::Cursor,
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
clipboard: &mut dyn Clipboard,
|
clipboard: &mut dyn Clipboard,
|
||||||
shell: &mut Shell<'_, Message>,
|
shell: &mut Shell<'_, Message>,
|
||||||
|
|
@ -206,7 +206,7 @@ where
|
||||||
&self,
|
&self,
|
||||||
tree: &Tree,
|
tree: &Tree,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: mouse::Cursor,
|
||||||
viewport: &Rectangle,
|
viewport: &Rectangle,
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
) -> mouse::Interaction {
|
) -> mouse::Interaction {
|
||||||
|
|
@ -221,7 +221,7 @@ where
|
||||||
theme: &Renderer::Theme,
|
theme: &Renderer::Theme,
|
||||||
renderer_style: &renderer::Style,
|
renderer_style: &renderer::Style,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: mouse::Cursor,
|
||||||
viewport: &Rectangle,
|
viewport: &Rectangle,
|
||||||
) {
|
) {
|
||||||
self.container.draw(
|
self.container.draw(
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,7 @@ where
|
||||||
tree: &mut Tree,
|
tree: &mut Tree,
|
||||||
event: Event,
|
event: Event,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: mouse::Cursor,
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
clipboard: &mut dyn Clipboard,
|
clipboard: &mut dyn Clipboard,
|
||||||
shell: &mut Shell<'_, Message>,
|
shell: &mut Shell<'_, Message>,
|
||||||
|
|
@ -193,7 +193,7 @@ where
|
||||||
&self,
|
&self,
|
||||||
tree: &Tree,
|
tree: &Tree,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: mouse::Cursor,
|
||||||
viewport: &Rectangle,
|
viewport: &Rectangle,
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
) -> mouse::Interaction {
|
) -> mouse::Interaction {
|
||||||
|
|
@ -208,7 +208,7 @@ where
|
||||||
theme: &Renderer::Theme,
|
theme: &Renderer::Theme,
|
||||||
renderer_style: &renderer::Style,
|
renderer_style: &renderer::Style,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: mouse::Cursor,
|
||||||
viewport: &Rectangle,
|
viewport: &Rectangle,
|
||||||
) {
|
) {
|
||||||
let theme = if let Some(layer) = self.layer {
|
let theme = if let Some(layer) = self.layer {
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ where
|
||||||
tree: &mut Tree,
|
tree: &mut Tree,
|
||||||
event: Event,
|
event: Event,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: mouse::Cursor,
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
clipboard: &mut dyn Clipboard,
|
clipboard: &mut dyn Clipboard,
|
||||||
shell: &mut Shell<'_, Message>,
|
shell: &mut Shell<'_, Message>,
|
||||||
|
|
@ -103,7 +103,7 @@ where
|
||||||
&self,
|
&self,
|
||||||
tree: &Tree,
|
tree: &Tree,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: mouse::Cursor,
|
||||||
viewport: &Rectangle,
|
viewport: &Rectangle,
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
) -> mouse::Interaction {
|
) -> mouse::Interaction {
|
||||||
|
|
@ -123,7 +123,7 @@ where
|
||||||
theme: &Renderer::Theme,
|
theme: &Renderer::Theme,
|
||||||
renderer_style: &renderer::Style,
|
renderer_style: &renderer::Style,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: mouse::Cursor,
|
||||||
viewport: &Rectangle,
|
viewport: &Rectangle,
|
||||||
) {
|
) {
|
||||||
self.content.as_widget().draw(
|
self.content.as_widget().draw(
|
||||||
|
|
@ -208,7 +208,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
event: Event,
|
event: Event,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: mouse::Cursor,
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
clipboard: &mut dyn Clipboard,
|
clipboard: &mut dyn Clipboard,
|
||||||
shell: &mut Shell<'_, Message>,
|
shell: &mut Shell<'_, Message>,
|
||||||
|
|
@ -227,7 +227,7 @@ where
|
||||||
fn mouse_interaction(
|
fn mouse_interaction(
|
||||||
&self,
|
&self,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: mouse::Cursor,
|
||||||
viewport: &Rectangle,
|
viewport: &Rectangle,
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
) -> mouse::Interaction {
|
) -> mouse::Interaction {
|
||||||
|
|
@ -246,7 +246,7 @@ where
|
||||||
theme: &Renderer::Theme,
|
theme: &Renderer::Theme,
|
||||||
style: &renderer::Style,
|
style: &renderer::Style,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: mouse::Cursor,
|
||||||
) {
|
) {
|
||||||
let bounds = layout.bounds();
|
let bounds = layout.bounds();
|
||||||
self.content.borrow().as_widget().draw(
|
self.content.borrow().as_widget().draw(
|
||||||
|
|
|
||||||
|
|
@ -185,7 +185,7 @@ where
|
||||||
tree: &mut Tree,
|
tree: &mut Tree,
|
||||||
event: Event,
|
event: Event,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: mouse::Cursor,
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
clipboard: &mut dyn Clipboard,
|
clipboard: &mut dyn Clipboard,
|
||||||
shell: &mut Shell<'_, Message>,
|
shell: &mut Shell<'_, Message>,
|
||||||
|
|
@ -205,7 +205,7 @@ where
|
||||||
&self,
|
&self,
|
||||||
tree: &Tree,
|
tree: &Tree,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: mouse::Cursor,
|
||||||
viewport: &Rectangle,
|
viewport: &Rectangle,
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
) -> mouse::Interaction {
|
) -> mouse::Interaction {
|
||||||
|
|
@ -220,7 +220,7 @@ where
|
||||||
theme: &Renderer::Theme,
|
theme: &Renderer::Theme,
|
||||||
renderer_style: &renderer::Style,
|
renderer_style: &renderer::Style,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: mouse::Cursor,
|
||||||
viewport: &Rectangle,
|
viewport: &Rectangle,
|
||||||
) {
|
) {
|
||||||
let _ = self.tx.unbounded_send((self.id, layout.bounds()));
|
let _ = self.tx.unbounded_send((self.id, layout.bounds()));
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright 2022 System76 <info@system76.com>
|
// Copyright 2022 System76 <info@system76.com>
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
use iced_core::{renderer::BorderRadius, Background, Color};
|
use iced_core::{Background, BorderRadius, Color};
|
||||||
|
|
||||||
/// Appearance of the segmented button.
|
/// Appearance of the segmented button.
|
||||||
#[derive(Default, Clone, Copy)]
|
#[derive(Default, Clone, Copy)]
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,9 @@ use iced::{
|
||||||
alignment, event, keyboard, mouse, touch, Background, Color, Command, Element, Event, Length,
|
alignment, event, keyboard, mouse, touch, Background, Color, Command, Element, Event, Length,
|
||||||
Point, Rectangle, Size,
|
Point, Rectangle, Size,
|
||||||
};
|
};
|
||||||
use iced_core::renderer::BorderRadius;
|
|
||||||
use iced_core::text::{LineHeight, Shaping};
|
use iced_core::text::{LineHeight, Shaping};
|
||||||
use iced_core::widget::{self, operation, tree};
|
use iced_core::widget::{self, operation, tree};
|
||||||
|
use iced_core::BorderRadius;
|
||||||
use iced_core::{layout, renderer, widget::Tree, Clipboard, Layout, Shell, Widget};
|
use iced_core::{layout, renderer, widget::Tree, Clipboard, Layout, Shell, Widget};
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
|
@ -303,7 +303,7 @@ where
|
||||||
tree: &mut Tree,
|
tree: &mut Tree,
|
||||||
event: Event,
|
event: Event,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: mouse::Cursor,
|
||||||
_renderer: &Renderer,
|
_renderer: &Renderer,
|
||||||
_clipboard: &mut dyn Clipboard,
|
_clipboard: &mut dyn Clipboard,
|
||||||
shell: &mut Shell<'_, Message>,
|
shell: &mut Shell<'_, Message>,
|
||||||
|
|
@ -311,10 +311,10 @@ where
|
||||||
let bounds = layout.bounds();
|
let bounds = layout.bounds();
|
||||||
let state = tree.state.downcast_mut::<LocalState>();
|
let state = tree.state.downcast_mut::<LocalState>();
|
||||||
|
|
||||||
if bounds.contains(cursor_position) {
|
if cursor_position.is_over(bounds) {
|
||||||
for (nth, key) in self.model.order.iter().copied().enumerate() {
|
for (nth, key) in self.model.order.iter().copied().enumerate() {
|
||||||
let bounds = self.variant_button_bounds(bounds, nth);
|
let bounds = self.variant_button_bounds(bounds, nth);
|
||||||
if bounds.contains(cursor_position) {
|
if cursor_position.is_over(bounds) {
|
||||||
if self.model.items[key].enabled {
|
if self.model.items[key].enabled {
|
||||||
// Record that the mouse is hovering over this button.
|
// Record that the mouse is hovering over this button.
|
||||||
state.hovered = key;
|
state.hovered = key;
|
||||||
|
|
@ -322,13 +322,11 @@ where
|
||||||
// If marked as closable, show a close icon.
|
// If marked as closable, show a close icon.
|
||||||
if self.model.items[key].closable {
|
if self.model.items[key].closable {
|
||||||
if let Some(on_close) = self.on_close.as_ref() {
|
if let Some(on_close) = self.on_close.as_ref() {
|
||||||
if close_bounds(
|
if cursor_position.is_over(close_bounds(
|
||||||
bounds,
|
bounds,
|
||||||
f32::from(self.icon_size),
|
f32::from(self.icon_size),
|
||||||
self.button_padding,
|
self.button_padding,
|
||||||
)
|
)) {
|
||||||
.contains(cursor_position)
|
|
||||||
{
|
|
||||||
if let Event::Mouse(mouse::Event::ButtonReleased(
|
if let Event::Mouse(mouse::Event::ButtonReleased(
|
||||||
mouse::Button::Left,
|
mouse::Button::Left,
|
||||||
))
|
))
|
||||||
|
|
@ -404,18 +402,15 @@ where
|
||||||
&self,
|
&self,
|
||||||
_tree: &Tree,
|
_tree: &Tree,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: iced::Point,
|
cursor_position: mouse::Cursor,
|
||||||
_viewport: &iced::Rectangle,
|
_viewport: &iced::Rectangle,
|
||||||
_renderer: &Renderer,
|
_renderer: &Renderer,
|
||||||
) -> iced_core::mouse::Interaction {
|
) -> iced_core::mouse::Interaction {
|
||||||
let bounds = layout.bounds();
|
let bounds = layout.bounds();
|
||||||
|
|
||||||
if bounds.contains(cursor_position) {
|
if cursor_position.is_over(bounds) {
|
||||||
for (nth, key) in self.model.order.iter().copied().enumerate() {
|
for (nth, key) in self.model.order.iter().copied().enumerate() {
|
||||||
if self
|
if cursor_position.is_over(self.variant_button_bounds(bounds, nth)) {
|
||||||
.variant_button_bounds(bounds, nth)
|
|
||||||
.contains(cursor_position)
|
|
||||||
{
|
|
||||||
return if self.model.items[key].enabled {
|
return if self.model.items[key].enabled {
|
||||||
iced_core::mouse::Interaction::Pointer
|
iced_core::mouse::Interaction::Pointer
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -436,7 +431,7 @@ where
|
||||||
theme: &<Renderer as iced_core::Renderer>::Theme,
|
theme: &<Renderer as iced_core::Renderer>::Theme,
|
||||||
_style: &renderer::Style,
|
_style: &renderer::Style,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
_cursor_position: iced::Point,
|
_cursor_position: mouse::Cursor,
|
||||||
_viewport: &iced::Rectangle,
|
_viewport: &iced::Rectangle,
|
||||||
) {
|
) {
|
||||||
let state = tree.state.downcast_ref::<LocalState>();
|
let state = tree.state.downcast_ref::<LocalState>();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue