diff --git a/src/gui/mod.rs b/src/gui/mod.rs index 782a15e..e1eca89 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -1,6 +1,5 @@ use std::path::PathBuf; -use iced::theme::Text; use iced::widget::text; use iced::widget::text_input; use iced::widget::Column; @@ -10,7 +9,7 @@ mod file_dialog; mod theme; pub use elements::menu_bar; -use theme::{Theme, Element}; +use theme::{Element, Theme}; #[derive(Debug, Clone)] pub enum Message { diff --git a/src/gui/theme/mod.rs b/src/gui/theme/mod.rs index fc7714a..e888588 100644 --- a/src/gui/theme/mod.rs +++ b/src/gui/theme/mod.rs @@ -1,9 +1,8 @@ use iced::widget::{button, text, text_input}; -use iced::{application, color, Color, Background}; +use iced::{application, color, Background, Color}; use iced_aw::menu; use iced_aw::style::tab_bar; //FIXME https://github.com/iced-rs/iced_aw/issues/151 - pub type Renderer = iced::Renderer; pub type Element<'msg, Message> = iced::Element<'msg, Message, Renderer>; @@ -53,7 +52,6 @@ impl tab_bar::StyleSheet for Theme { fn hovered(&self, style: Self::Style, is_active: bool) -> tab_bar::Appearance { Default::default() } - } impl text::StyleSheet for Theme { diff --git a/src/gui/theme/palette.rs b/src/gui/theme/palette.rs index be92dc7..aef1fba 100644 --- a/src/gui/theme/palette.rs +++ b/src/gui/theme/palette.rs @@ -1,4 +1,43 @@ +use iced::Color; + /// raw hex colors from the theme files pub struct Palette { - -} \ No newline at end of file + accent: Color, + background: Color, + primary: Color, + secondary: Color, + text: Color, +} + +impl Default for Palette { + fn default() -> Palette { + Palette { + accent: hex_to_color("#000000").unwrap(), + background: hex_to_color("#ffffff").unwrap(), + primary: hex_to_color("#4685ff").unwrap(), + secondary: hex_to_color("#f2f2f2").unwrap(), + text: hex_to_color("#ffb084").unwrap(), + } + } +} + +fn hex_to_color(hex: &str) -> Option { + if hex.len() == 7 { + let hash = &hex[0..1]; + let r = u8::from_str_radix(&hex[1..3], 16); + let g = u8::from_str_radix(&hex[3..5], 16); + let b = u8::from_str_radix(&hex[5..7], 16); + + return match (hash, r, g, b) { + ("#", Ok(r), Ok(g), Ok(b)) => Some(Color { + r: r as f32 / 255.0, + g: g as f32 / 255.0, + b: b as f32 / 255.0, + a: 1.0, + }), + _ => None, + }; + } + + None +}