wip rebase updates
This commit is contained in:
parent
86dcf8af6c
commit
e10459fb37
68 changed files with 1776 additions and 1544 deletions
|
|
@ -13,9 +13,8 @@ pub enum Desktop {
|
|||
|
||||
#[cold]
|
||||
pub fn desktop_settings() -> iced_futures::Subscription<Desktop> {
|
||||
iced_futures::Subscription::run_with_id(
|
||||
std::any::TypeId::of::<Desktop>(),
|
||||
stream::channel(10, |mut tx| {
|
||||
iced_futures::Subscription::run(|| {
|
||||
stream::channel(10, |mut tx: futures::channel::mpsc::Sender<Desktop>| {
|
||||
async move {
|
||||
let mut attempts = 0;
|
||||
loop {
|
||||
|
|
@ -99,6 +98,6 @@ pub fn desktop_settings() -> iced_futures::Subscription<Desktop> {
|
|||
}
|
||||
}
|
||||
}
|
||||
}),
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use crate::theme::{CosmicComponent, TRANSPARENT_COMPONENT, Theme};
|
|||
use cosmic_theme::composite::over;
|
||||
use iced::{
|
||||
overlay::menu,
|
||||
theme::Base,
|
||||
widget::{
|
||||
button as iced_button, checkbox as iced_checkbox, combo_box, container as iced_container,
|
||||
pane_grid, pick_list, progress_bar, radio, rule, scrollable,
|
||||
|
|
@ -15,7 +16,7 @@ use iced::{
|
|||
},
|
||||
};
|
||||
use iced_core::{Background, Border, Color, Shadow, Vector};
|
||||
use iced_widget::{pane_grid::Highlight, text_editor, text_input};
|
||||
use iced_widget::{pane_grid::Highlight, scrollable::AutoScroll, text_editor, text_input};
|
||||
use palette::WithAlpha;
|
||||
use std::rc::Rc;
|
||||
|
||||
|
|
@ -36,13 +37,13 @@ pub mod application {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn appearance(theme: &Theme) -> Appearance {
|
||||
pub fn style(theme: &Theme) -> iced::theme::Style {
|
||||
let cosmic = theme.cosmic();
|
||||
|
||||
Appearance {
|
||||
icon_color: cosmic.bg_color().into(),
|
||||
iced::theme::Style {
|
||||
background_color: cosmic.bg_color().into(),
|
||||
text_color: cosmic.on_bg_color().into(),
|
||||
icon_color: cosmic.bg_color().into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -422,6 +423,7 @@ impl<'a> Container<'a> {
|
|||
..Default::default()
|
||||
},
|
||||
shadow: Shadow::default(),
|
||||
snap: true,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -436,6 +438,7 @@ impl<'a> Container<'a> {
|
|||
..Default::default()
|
||||
},
|
||||
shadow: Shadow::default(),
|
||||
snap: true,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -450,6 +453,7 @@ impl<'a> Container<'a> {
|
|||
..Default::default()
|
||||
},
|
||||
shadow: Shadow::default(),
|
||||
snap: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -493,6 +497,7 @@ impl iced_container::Catalog for Theme {
|
|||
..Default::default()
|
||||
},
|
||||
shadow: Shadow::default(),
|
||||
snap: true,
|
||||
},
|
||||
|
||||
Container::List => {
|
||||
|
|
@ -506,6 +511,7 @@ impl iced_container::Catalog for Theme {
|
|||
..Default::default()
|
||||
},
|
||||
shadow: Shadow::default(),
|
||||
snap: true,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -552,6 +558,7 @@ impl iced_container::Catalog for Theme {
|
|||
.into(),
|
||||
..Default::default()
|
||||
},
|
||||
snap: true,
|
||||
shadow: Shadow::default(),
|
||||
}
|
||||
}
|
||||
|
|
@ -582,6 +589,7 @@ impl iced_container::Catalog for Theme {
|
|||
radius: cosmic.corner_radii.radius_s.into(),
|
||||
},
|
||||
shadow: Shadow::default(),
|
||||
snap: true,
|
||||
},
|
||||
|
||||
Container::Tooltip => iced_container::Style {
|
||||
|
|
@ -593,6 +601,7 @@ impl iced_container::Catalog for Theme {
|
|||
..Default::default()
|
||||
},
|
||||
shadow: Shadow::default(),
|
||||
snap: true,
|
||||
},
|
||||
|
||||
Container::Card => {
|
||||
|
|
@ -610,6 +619,7 @@ impl iced_container::Catalog for Theme {
|
|||
..Default::default()
|
||||
},
|
||||
shadow: Shadow::default(),
|
||||
snap: true,
|
||||
},
|
||||
cosmic_theme::Layer::Primary => iced_container::Style {
|
||||
icon_color: Some(Color::from(cosmic.primary.component.on)),
|
||||
|
|
@ -622,6 +632,7 @@ impl iced_container::Catalog for Theme {
|
|||
..Default::default()
|
||||
},
|
||||
shadow: Shadow::default(),
|
||||
snap: true,
|
||||
},
|
||||
cosmic_theme::Layer::Secondary => iced_container::Style {
|
||||
icon_color: Some(Color::from(cosmic.secondary.component.on)),
|
||||
|
|
@ -634,6 +645,7 @@ impl iced_container::Catalog for Theme {
|
|||
..Default::default()
|
||||
},
|
||||
shadow: Shadow::default(),
|
||||
snap: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -652,6 +664,7 @@ impl iced_container::Catalog for Theme {
|
|||
offset: Vector::new(0.0, 4.0),
|
||||
blur_radius: 16.0,
|
||||
},
|
||||
snap: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -791,6 +804,7 @@ impl menu::Catalog for Theme {
|
|||
},
|
||||
selected_text_color: cosmic.accent_text_color().into(),
|
||||
selected_background: Background::Color(cosmic.background.component.hover.into()),
|
||||
shadow: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -830,7 +844,7 @@ impl pick_list::Catalog for Theme {
|
|||
background: Background::Color(cosmic.background.base.into()),
|
||||
..appearance
|
||||
},
|
||||
pick_list::Status::Opened => appearance,
|
||||
pick_list::Status::Opened { is_hovered: _ } => appearance,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -920,6 +934,8 @@ impl toggler::Catalog for Theme {
|
|||
background_border_color: Color::TRANSPARENT,
|
||||
foreground_border_width: 0.0,
|
||||
foreground_border_color: Color::TRANSPARENT,
|
||||
text_color: None,
|
||||
padding_ratio: 0.0,
|
||||
};
|
||||
match status {
|
||||
toggler::Status::Active { is_toggled } => active,
|
||||
|
|
@ -942,9 +958,9 @@ impl toggler::Catalog for Theme {
|
|||
..active
|
||||
}
|
||||
}
|
||||
toggler::Status::Disabled => {
|
||||
active.background.a /= 2.;
|
||||
active.foreground.a /= 2.;
|
||||
toggler::Status::Disabled { is_toggled } => {
|
||||
active.background = active.background.scale_alpha(0.5);
|
||||
active.foreground = active.foreground.scale_alpha(0.5);
|
||||
active
|
||||
}
|
||||
}
|
||||
|
|
@ -1086,21 +1102,21 @@ impl rule::Catalog for Theme {
|
|||
match class {
|
||||
Rule::Default => rule::Style {
|
||||
color: self.current_container().divider.into(),
|
||||
width: 1,
|
||||
radius: 0.0.into(),
|
||||
fill_mode: rule::FillMode::Full,
|
||||
snap: true,
|
||||
},
|
||||
Rule::LightDivider => rule::Style {
|
||||
color: self.current_container().divider.into(),
|
||||
width: 1,
|
||||
radius: 0.0.into(),
|
||||
fill_mode: rule::FillMode::Padded(8),
|
||||
snap: true,
|
||||
},
|
||||
Rule::HeavyDivider => rule::Style {
|
||||
color: self.current_container().divider.into(),
|
||||
width: 4,
|
||||
radius: 2.0.into(),
|
||||
fill_mode: rule::FillMode::Full,
|
||||
snap: true,
|
||||
},
|
||||
Rule::Custom(f) => f(self),
|
||||
}
|
||||
|
|
@ -1126,7 +1142,10 @@ impl scrollable::Catalog for Theme {
|
|||
|
||||
fn style(&self, class: &Self::Class<'_>, status: scrollable::Status) -> scrollable::Style {
|
||||
match status {
|
||||
scrollable::Status::Active => {
|
||||
scrollable::Status::Active {
|
||||
is_horizontal_scrollbar_disabled,
|
||||
is_vertical_scrollbar_disabled,
|
||||
} => {
|
||||
let cosmic = self.cosmic();
|
||||
let neutral_5 = cosmic.palette.neutral_5.with_alpha(0.7);
|
||||
let neutral_6 = cosmic.palette.neutral_6.with_alpha(0.7);
|
||||
|
|
@ -1139,7 +1158,7 @@ impl scrollable::Catalog for Theme {
|
|||
},
|
||||
background: None,
|
||||
scroller: scrollable::Scroller {
|
||||
color: if cosmic.is_dark {
|
||||
background: if cosmic.is_dark {
|
||||
neutral_6.into()
|
||||
} else {
|
||||
neutral_5.into()
|
||||
|
|
@ -1157,7 +1176,7 @@ impl scrollable::Catalog for Theme {
|
|||
},
|
||||
background: None,
|
||||
scroller: scrollable::Scroller {
|
||||
color: if cosmic.is_dark {
|
||||
background: if cosmic.is_dark {
|
||||
neutral_6.into()
|
||||
} else {
|
||||
neutral_5.into()
|
||||
|
|
@ -1169,6 +1188,13 @@ impl scrollable::Catalog for Theme {
|
|||
},
|
||||
},
|
||||
gap: None,
|
||||
// TODO: what is auto scroll?
|
||||
auto_scroll: AutoScroll {
|
||||
background: Color::TRANSPARENT.into(),
|
||||
border: Border::default(),
|
||||
shadow: Shadow::default(),
|
||||
icon: Color::TRANSPARENT.into(),
|
||||
},
|
||||
};
|
||||
let small_widget_container = self.current_container().small_widget.with_alpha(0.7);
|
||||
|
||||
|
|
@ -1200,7 +1226,7 @@ impl scrollable::Catalog for Theme {
|
|||
},
|
||||
background: None,
|
||||
scroller: scrollable::Scroller {
|
||||
color: if cosmic.is_dark {
|
||||
background: if cosmic.is_dark {
|
||||
neutral_6.into()
|
||||
} else {
|
||||
neutral_5.into()
|
||||
|
|
@ -1218,7 +1244,7 @@ impl scrollable::Catalog for Theme {
|
|||
},
|
||||
background: None,
|
||||
scroller: scrollable::Scroller {
|
||||
color: if cosmic.is_dark {
|
||||
background: if cosmic.is_dark {
|
||||
neutral_6.into()
|
||||
} else {
|
||||
neutral_5.into()
|
||||
|
|
@ -1230,6 +1256,13 @@ impl scrollable::Catalog for Theme {
|
|||
},
|
||||
},
|
||||
gap: None,
|
||||
// TODO: what is auto scroll?
|
||||
auto_scroll: AutoScroll {
|
||||
background: Color::TRANSPARENT.into(),
|
||||
border: Border::default(),
|
||||
shadow: Shadow::default(),
|
||||
icon: Color::TRANSPARENT.into(),
|
||||
},
|
||||
};
|
||||
|
||||
if matches!(class, Scrollable::Permanent) {
|
||||
|
|
@ -1400,7 +1433,7 @@ impl text_input::Catalog for Theme {
|
|||
},
|
||||
}
|
||||
}
|
||||
text_input::Status::Focused => {
|
||||
text_input::Status::Focused { is_hovered } => {
|
||||
let bg = self.current_container().small_widget.with_alpha(0.25);
|
||||
|
||||
match class {
|
||||
|
|
@ -1477,7 +1510,8 @@ impl iced_widget::text_editor::Catalog for Theme {
|
|||
let selection = cosmic.accent.base.into();
|
||||
let value = cosmic.palette.neutral_9.into();
|
||||
let placeholder = cosmic.palette.neutral_9.with_alpha(0.7).into();
|
||||
let icon = cosmic.background.on.into();
|
||||
let icon: Color = cosmic.background.on.into();
|
||||
// TODO do we need to add icon color back?
|
||||
|
||||
match status {
|
||||
iced_widget::text_editor::Status::Active
|
||||
|
|
@ -1489,23 +1523,23 @@ impl iced_widget::text_editor::Catalog for Theme {
|
|||
width: f32::from(cosmic.space_xxxs()),
|
||||
color: iced::Color::from(cosmic.bg_divider()),
|
||||
},
|
||||
icon,
|
||||
placeholder,
|
||||
value,
|
||||
selection,
|
||||
},
|
||||
iced_widget::text_editor::Status::Focused => iced_widget::text_editor::Style {
|
||||
background: iced::Color::from(cosmic.bg_color()).into(),
|
||||
border: Border {
|
||||
radius: cosmic.corner_radii.radius_0.into(),
|
||||
width: f32::from(cosmic.space_xxxs()),
|
||||
color: iced::Color::from(cosmic.accent.base),
|
||||
},
|
||||
icon,
|
||||
placeholder,
|
||||
value,
|
||||
selection,
|
||||
},
|
||||
iced_widget::text_editor::Status::Focused { is_hovered } => {
|
||||
iced_widget::text_editor::Style {
|
||||
background: iced::Color::from(cosmic.bg_color()).into(),
|
||||
border: Border {
|
||||
radius: cosmic.corner_radii.radius_0.into(),
|
||||
width: f32::from(cosmic.space_xxxs()),
|
||||
color: iced::Color::from(cosmic.accent.base),
|
||||
},
|
||||
placeholder,
|
||||
value,
|
||||
selection,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1522,6 +1556,21 @@ impl iced_widget::markdown::Catalog for Theme {
|
|||
}
|
||||
}
|
||||
|
||||
impl iced_widget::table::Catalog for Theme {
|
||||
type Class<'a> = iced_widget::table::StyleFn<'a, Self>;
|
||||
|
||||
fn default<'a>() -> Self::Class<'a> {
|
||||
Box::new(|theme| iced_widget::table::Style {
|
||||
separator_x: theme.current_container().divider.into(),
|
||||
separator_y: theme.current_container().divider.into(),
|
||||
})
|
||||
}
|
||||
|
||||
fn style(&self, class: &Self::Class<'_>) -> iced_widget::table::Style {
|
||||
class(self)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "qr_code")]
|
||||
impl iced_widget::qr_code::Catalog for Theme {
|
||||
type Class<'a> = iced_widget::qr_code::StyleFn<'a, Self>;
|
||||
|
|
@ -1539,3 +1588,50 @@ impl iced_widget::qr_code::Catalog for Theme {
|
|||
}
|
||||
|
||||
impl combo_box::Catalog for Theme {}
|
||||
|
||||
impl Base for Theme {
|
||||
fn default(preference: iced::theme::Mode) -> Self {
|
||||
match preference {
|
||||
iced::theme::Mode::Light => Theme::light(),
|
||||
iced::theme::Mode::Dark | iced::theme::Mode::None => Theme::dark(),
|
||||
}
|
||||
}
|
||||
|
||||
fn mode(&self) -> iced::theme::Mode {
|
||||
if self.theme_type.is_dark() {
|
||||
iced::theme::Mode::Dark
|
||||
} else {
|
||||
iced::theme::Mode::Light
|
||||
}
|
||||
}
|
||||
|
||||
fn base(&self) -> iced::theme::Style {
|
||||
iced::theme::Style {
|
||||
background_color: self.cosmic().bg_color().into(),
|
||||
text_color: self.cosmic().on_bg_color().into(),
|
||||
icon_color: self.cosmic().on_bg_color().into(),
|
||||
}
|
||||
}
|
||||
|
||||
fn palette(&self) -> Option<iced::theme::Palette> {
|
||||
Some(iced::theme::Palette {
|
||||
primary: self.cosmic().accent.base.into(),
|
||||
success: self.cosmic().success.base.into(),
|
||||
warning: self.cosmic().warning.base.into(),
|
||||
danger: self.cosmic().destructive.base.into(),
|
||||
background: iced::Color::from(self.cosmic().bg_color()),
|
||||
text: iced::Color::from(self.cosmic().on_bg_color()),
|
||||
})
|
||||
}
|
||||
|
||||
fn name(&self) -> &str {
|
||||
match &self.theme_type {
|
||||
crate::theme::ThemeType::Dark => "Cosmic Dark Theme",
|
||||
crate::theme::ThemeType::Light => "Cosmic Light Theme",
|
||||
crate::theme::ThemeType::HighContrastDark => "Cosmic High Contrast Dark Theme",
|
||||
crate::theme::ThemeType::HighContrastLight => "Cosmic High Contrast Light Theme",
|
||||
crate::theme::ThemeType::Custom(theme) => "Custom Cosmic Theme",
|
||||
crate::theme::ThemeType::System { prefer_dark, theme } => &theme.name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue