Refined the hamburger menu
This commit is contained in:
1 parent
c265841334
commit
c778bb1b48
3 files changed
+69
-5
No files matched your search
+18
-4
@@ -49,8 +49,22 @@ fn update(state: &mut Moorly, message: Message) -> Task<Message> {
|
||||
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,
|
||||
|
||||
@@ -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),
|
||||
],
|
||||
};
|
||||
}
|
||||
+4
-1
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user