Update libcosmic

This commit is contained in:
Jeremy Soller 2023-03-23 14:20:48 -06:00
parent e788c175ec
commit 31a8427e10
No known key found for this signature in database
GPG key ID: DCFCA852D3906975
4 changed files with 19 additions and 18 deletions

View file

@ -15,9 +15,9 @@ log = "0.4"
[dependencies.libcosmic] [dependencies.libcosmic]
git = "https://github.com/pop-os/libcosmic" git = "https://github.com/pop-os/libcosmic"
rev = "2dde95ee" rev = "24709e9c3b56c49a0af168d1e37ebef85f112c8a"
default-features = false default-features = false
features = ["wgpu", "winit"] features = ["winit_softbuffer"]
#path = "../../../libcosmic" #path = "../../../libcosmic"
[dependencies.rfd] [dependencies.rfd]

View file

@ -7,7 +7,7 @@ use cosmic::{
Alignment, Application, Color, Command, Length, Alignment, Application, Color, Command, Length,
}, },
settings, settings,
theme::{self, Theme}, theme::{self, Theme, ThemeType},
widget::{button, toggler}, widget::{button, toggler},
Element, Element,
}; };
@ -154,7 +154,7 @@ impl Application for Window {
update_attrs(&mut editor, attrs); update_attrs(&mut editor, attrs);
let mut window = Window { let mut window = Window {
theme: Theme::Dark, theme: Theme::dark(),
font_size: FontSize::Body, font_size: FontSize::Body,
path_opt: None, path_opt: None,
attrs, attrs,
@ -261,12 +261,12 @@ impl Application for Window {
} }
Message::ThemeChanged(theme) => { Message::ThemeChanged(theme) => {
self.theme = match theme { self.theme = match theme {
"Dark" => Theme::Dark, "Dark" => Theme::dark(),
"Light" => Theme::Light, "Light" => Theme::light(),
_ => return Command::none(), _ => return Command::none(),
}; };
let Color { r, g, b, a } = self.theme.palette().text; let Color { r, g, b, a } = self.theme.cosmic().on_bg_color().into();
let as_u8 = |component: f32| (component * 255.0) as u8; let as_u8 = |component: f32| (component * 255.0) as u8;
self.attrs = self.attrs.color(cosmic_text::Color::rgba( self.attrs = self.attrs.color(cosmic_text::Color::rgba(
as_u8(r), as_u8(r),
@ -287,9 +287,10 @@ impl Application for Window {
static THEMES: &[&str] = &["Dark", "Light"]; static THEMES: &[&str] = &["Dark", "Light"];
let theme_picker = pick_list( let theme_picker = pick_list(
THEMES, THEMES,
Some(match self.theme { Some(match self.theme.theme_type {
Theme::Dark => THEMES[0], ThemeType::Dark => THEMES[0],
Theme::Light => THEMES[1], ThemeType::Light => THEMES[1],
_ => unreachable!(),
}), }),
Message::ThemeChanged, Message::ThemeChanged,
); );

View file

@ -9,7 +9,7 @@ use cosmic::{
{Color, Element, Length, Point, Rectangle, Size}, {Color, Element, Length, Point, Rectangle, Size},
}, },
iced_winit::renderer::BorderRadius, iced_winit::renderer::BorderRadius,
theme::Theme, theme::{Theme, ThemeType},
}; };
use cosmic_text::{Attrs, AttrsList, BufferLine, Metrics, SwashCache}; use cosmic_text::{Attrs, AttrsList, BufferLine, Metrics, SwashCache};
use std::{cmp, sync::Mutex, time::Instant}; use std::{cmp, sync::Mutex, time::Instant};
@ -27,12 +27,12 @@ pub trait StyleSheet {
impl StyleSheet for Theme { impl StyleSheet for Theme {
fn appearance(&self) -> Appearance { fn appearance(&self) -> Appearance {
match self { match self.theme_type {
Theme::Dark => Appearance { ThemeType::Dark | ThemeType::HighContrastDark => Appearance {
background_color: None, background_color: None,
text_color: Color::from_rgb8(0xFF, 0xFF, 0xFF), text_color: Color::from_rgb8(0xFF, 0xFF, 0xFF),
}, },
Theme::Light => Appearance { ThemeType::Light | ThemeType::HighContrastLight => Appearance {
background_color: None, background_color: None,
text_color: Color::from_rgb8(0x00, 0x00, 0x00), text_color: Color::from_rgb8(0x00, 0x00, 0x00),
}, },

View file

@ -16,7 +16,7 @@ use cosmic::{
Padding, {Color, Element, Length, Point, Rectangle, Shell, Size}, Padding, {Color, Element, Length, Point, Rectangle, Shell, Size},
}, },
iced_winit::renderer::BorderRadius, iced_winit::renderer::BorderRadius,
theme::Theme, theme::{Theme, ThemeType},
}; };
use cosmic_text::{Action, Edit, SwashCache}; use cosmic_text::{Action, Edit, SwashCache};
use std::{cmp, sync::Mutex, time::Instant}; use std::{cmp, sync::Mutex, time::Instant};
@ -32,12 +32,12 @@ pub trait StyleSheet {
impl StyleSheet for Theme { impl StyleSheet for Theme {
fn appearance(&self) -> Appearance { fn appearance(&self) -> Appearance {
match self { match self.theme_type {
Theme::Dark => Appearance { ThemeType::Dark | ThemeType::HighContrastDark => Appearance {
background_color: Some(Color::from_rgb8(0x34, 0x34, 0x34)), background_color: Some(Color::from_rgb8(0x34, 0x34, 0x34)),
text_color: Color::from_rgb8(0xFF, 0xFF, 0xFF), text_color: Color::from_rgb8(0xFF, 0xFF, 0xFF),
}, },
Theme::Light => Appearance { ThemeType::Light | ThemeType::HighContrastLight => Appearance {
background_color: Some(Color::from_rgb8(0xFC, 0xFC, 0xFC)), background_color: Some(Color::from_rgb8(0xFC, 0xFC, 0xFC)),
text_color: Color::from_rgb8(0x00, 0x00, 0x00), text_color: Color::from_rgb8(0x00, 0x00, 0x00),
}, },