diff --git a/examples/editor-libcosmic/Cargo.toml b/examples/editor-libcosmic/Cargo.toml index 004e524..f16b064 100644 --- a/examples/editor-libcosmic/Cargo.toml +++ b/examples/editor-libcosmic/Cargo.toml @@ -15,9 +15,9 @@ log = "0.4" [dependencies.libcosmic] git = "https://github.com/pop-os/libcosmic" -rev = "2dde95ee" +rev = "24709e9c3b56c49a0af168d1e37ebef85f112c8a" default-features = false -features = ["wgpu", "winit"] +features = ["winit_softbuffer"] #path = "../../../libcosmic" [dependencies.rfd] diff --git a/examples/editor-libcosmic/src/main.rs b/examples/editor-libcosmic/src/main.rs index be2f89a..6635067 100644 --- a/examples/editor-libcosmic/src/main.rs +++ b/examples/editor-libcosmic/src/main.rs @@ -7,7 +7,7 @@ use cosmic::{ Alignment, Application, Color, Command, Length, }, settings, - theme::{self, Theme}, + theme::{self, Theme, ThemeType}, widget::{button, toggler}, Element, }; @@ -154,7 +154,7 @@ impl Application for Window { update_attrs(&mut editor, attrs); let mut window = Window { - theme: Theme::Dark, + theme: Theme::dark(), font_size: FontSize::Body, path_opt: None, attrs, @@ -261,12 +261,12 @@ impl Application for Window { } Message::ThemeChanged(theme) => { self.theme = match theme { - "Dark" => Theme::Dark, - "Light" => Theme::Light, + "Dark" => Theme::dark(), + "Light" => Theme::light(), _ => 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; self.attrs = self.attrs.color(cosmic_text::Color::rgba( as_u8(r), @@ -287,9 +287,10 @@ impl Application for Window { static THEMES: &[&str] = &["Dark", "Light"]; let theme_picker = pick_list( THEMES, - Some(match self.theme { - Theme::Dark => THEMES[0], - Theme::Light => THEMES[1], + Some(match self.theme.theme_type { + ThemeType::Dark => THEMES[0], + ThemeType::Light => THEMES[1], + _ => unreachable!(), }), Message::ThemeChanged, ); diff --git a/examples/editor-libcosmic/src/text.rs b/examples/editor-libcosmic/src/text.rs index f0c9c9a..dfc8d13 100644 --- a/examples/editor-libcosmic/src/text.rs +++ b/examples/editor-libcosmic/src/text.rs @@ -9,7 +9,7 @@ use cosmic::{ {Color, Element, Length, Point, Rectangle, Size}, }, iced_winit::renderer::BorderRadius, - theme::Theme, + theme::{Theme, ThemeType}, }; use cosmic_text::{Attrs, AttrsList, BufferLine, Metrics, SwashCache}; use std::{cmp, sync::Mutex, time::Instant}; @@ -27,12 +27,12 @@ pub trait StyleSheet { impl StyleSheet for Theme { fn appearance(&self) -> Appearance { - match self { - Theme::Dark => Appearance { + match self.theme_type { + ThemeType::Dark | ThemeType::HighContrastDark => Appearance { background_color: None, text_color: Color::from_rgb8(0xFF, 0xFF, 0xFF), }, - Theme::Light => Appearance { + ThemeType::Light | ThemeType::HighContrastLight => Appearance { background_color: None, text_color: Color::from_rgb8(0x00, 0x00, 0x00), }, diff --git a/examples/editor-libcosmic/src/text_box.rs b/examples/editor-libcosmic/src/text_box.rs index a5463e6..e1dfd6f 100644 --- a/examples/editor-libcosmic/src/text_box.rs +++ b/examples/editor-libcosmic/src/text_box.rs @@ -16,7 +16,7 @@ use cosmic::{ Padding, {Color, Element, Length, Point, Rectangle, Shell, Size}, }, iced_winit::renderer::BorderRadius, - theme::Theme, + theme::{Theme, ThemeType}, }; use cosmic_text::{Action, Edit, SwashCache}; use std::{cmp, sync::Mutex, time::Instant}; @@ -32,12 +32,12 @@ pub trait StyleSheet { impl StyleSheet for Theme { fn appearance(&self) -> Appearance { - match self { - Theme::Dark => Appearance { + match self.theme_type { + ThemeType::Dark | ThemeType::HighContrastDark => Appearance { background_color: Some(Color::from_rgb8(0x34, 0x34, 0x34)), 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)), text_color: Color::from_rgb8(0x00, 0x00, 0x00), },