diff --git a/src/main.rs b/src/main.rs index 978be8c..4bda7c1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -49,8 +49,22 @@ fn update(state: &mut Moorly, message: Message) -> Task { Task::none() } -fn hamburger() -> iced::widget::Button<'static, Message> { - button(text("☰").size(14)) +fn hamburger(open: bool) -> iced::widget::Button<'static, Message> { + let icon: Element<'static, Message> = if open { + stack![ + text("☰").size(14), + container(text("X").size(11).color(theme::DANGER)) + .width(Length::Fill) + .height(Length::Fill) + .align_x(Alignment::End) + .align_y(Alignment::Start), + ] + .into() + } else { + text("☰").size(14).into() + }; + + button(icon) .on_press(Message::ToggleMenu) .padding([2, 8]) .style(button::text) @@ -59,7 +73,7 @@ fn hamburger() -> iced::widget::Button<'static, Message> { fn view(state: &Moorly) -> Element<'_, Message> { let mut bar = row![].align_y(Alignment::Center); if !state.menu_open { - bar = bar.push(hamburger()); + bar = bar.push(hamburger(false)); } let menubar = container(bar) @@ -109,7 +123,7 @@ fn view(state: &Moorly) -> Element<'_, Message> { let menu = container( column![ - container(hamburger()) + container(hamburger(true)) .width(Length::Fill) .align_x(Alignment::End), menu_items, diff --git a/src/terminal.rs b/src/terminal.rs new file mode 100644 index 0000000..21cf664 --- /dev/null +++ b/src/terminal.rs @@ -0,0 +1,47 @@ +//! Terminal appearance is deliberately independent from the application theme. +//! It is stored and configured separately so terminal colors do not change +//! when the GUI switches between light and dark. + +use iced::Color; + +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct Theme { + pub background: Color, + pub foreground: Color, + pub cursor: Color, + pub selection: Color, + pub ansi: [Color; 16], +} + +impl Default for Theme { + fn default() -> Self { + Self::DARK + } +} + +impl Theme { + pub const DARK: Self = Self { + background: Color::from_rgb8(0x1e, 0x1e, 0x1e), + foreground: Color::from_rgb8(0xd4, 0xd4, 0xd4), + cursor: Color::from_rgb8(0xd4, 0xd4, 0xd4), + selection: Color::from_rgb8(0x3a, 0x3a, 0x3a), + ansi: [ + Color::from_rgb8(0x00, 0x00, 0x00), + Color::from_rgb8(0xcd, 0x31, 0x31), + Color::from_rgb8(0x0d, 0xbc, 0x79), + Color::from_rgb8(0xe5, 0xe5, 0x10), + Color::from_rgb8(0x24, 0x72, 0xc8), + Color::from_rgb8(0xbc, 0x3f, 0xbc), + Color::from_rgb8(0x11, 0xa8, 0xcd), + Color::from_rgb8(0xe5, 0xe5, 0xe5), + Color::from_rgb8(0x66, 0x66, 0x66), + Color::from_rgb8(0xf1, 0x4c, 0x4c), + Color::from_rgb8(0x23, 0xd1, 0x8b), + Color::from_rgb8(0xf5, 0xf5, 0x43), + Color::from_rgb8(0x3b, 0x8e, 0xea), + Color::from_rgb8(0xd6, 0x70, 0xd6), + Color::from_rgb8(0x29, 0xb8, 0xdb), + Color::from_rgb8(0xff, 0xff, 0xff), + ], + }; +} diff --git a/src/theme.rs b/src/theme.rs index 7f7f0b1..1e3f5b0 100644 --- a/src/theme.rs +++ b/src/theme.rs @@ -9,7 +9,10 @@ use std::fs; use std::path::PathBuf; use iced::widget::container; -use iced::{Border, Theme}; +use iced::{Border, Color, Theme}; + +/// Accent red used for destructive/close affordances in both themes. +pub const DANGER: Color = Color::from_rgb8(0xff, 0x3b, 0x30); #[derive(Debug, Clone, Copy, Default, PartialEq, Eq)] pub enum Preference {