refactor(menu): update menu declaration.

- Updated libcosmic.
- Updated menu declaration.
This commit is contained in:
Eduardo Flores 2024-03-18 03:00:12 -07:00
parent c7ca83b656
commit 4196135665
5 changed files with 168 additions and 249 deletions

69
Cargo.lock generated
View file

@ -874,8 +874,7 @@ dependencies = [
[[package]]
name = "clipboard_macos"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "145a7f9e9b89453bc0a5e32d166456405d389cea5b578f57f1274b1397588a95"
source = "git+https://github.com/pop-os/window_clipboard.git?tag=pop-mime-types#c3e9e794b94a2e79419517145424dc2035a572da"
dependencies = [
"objc",
"objc-foundation",
@ -885,17 +884,16 @@ dependencies = [
[[package]]
name = "clipboard_wayland"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "003f886bc4e2987729d10c1db3424e7f80809f3fc22dbc16c685738887cb37b8"
source = "git+https://github.com/pop-os/window_clipboard.git?tag=pop-mime-types#c3e9e794b94a2e79419517145424dc2035a572da"
dependencies = [
"mime 0.1.0",
"smithay-clipboard",
]
[[package]]
name = "clipboard_x11"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4274ea815e013e0f9f04a2633423e14194e408a0576c943ce3d14ca56c50031c"
source = "git+https://github.com/pop-os/window_clipboard.git?tag=pop-mime-types#c3e9e794b94a2e79419517145424dc2035a572da"
dependencies = [
"thiserror",
"x11rb",
@ -1066,7 +1064,7 @@ dependencies = [
[[package]]
name = "cosmic-config"
version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
dependencies = [
"atomicwrites",
"cosmic-config-derive",
@ -1083,7 +1081,7 @@ dependencies = [
[[package]]
name = "cosmic-config-derive"
version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
dependencies = [
"quote",
"syn 1.0.109",
@ -1162,7 +1160,7 @@ dependencies = [
[[package]]
name = "cosmic-text"
version = "0.11.2"
source = "git+https://github.com/pop-os/cosmic-text.git#a53a0b3a8c085143470a9d26ac2c2911cc479033"
source = "git+https://github.com/pop-os/cosmic-text.git#18c3d2acec5e7f64a670c6643ee3ab220bc92a89"
dependencies = [
"bitflags 2.4.2",
"cosmic_undo_2",
@ -1187,7 +1185,7 @@ dependencies = [
[[package]]
name = "cosmic-theme"
version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
dependencies = [
"almost",
"cosmic-config",
@ -2619,7 +2617,7 @@ dependencies = [
[[package]]
name = "iced"
version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
dependencies = [
"iced_accessibility",
"iced_core",
@ -2629,12 +2627,13 @@ dependencies = [
"iced_winit",
"image",
"thiserror",
"window_clipboard",
]
[[package]]
name = "iced_accessibility"
version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
dependencies = [
"accesskit",
"accesskit_winit",
@ -2643,7 +2642,7 @@ dependencies = [
[[package]]
name = "iced_core"
version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
dependencies = [
"bitflags 1.3.2",
"log",
@ -2654,13 +2653,14 @@ dependencies = [
"smol_str",
"thiserror",
"web-time",
"window_clipboard",
"xxhash-rust",
]
[[package]]
name = "iced_futures"
version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
dependencies = [
"futures",
"iced_core",
@ -2673,7 +2673,7 @@ dependencies = [
[[package]]
name = "iced_graphics"
version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
dependencies = [
"bitflags 1.3.2",
"bytemuck",
@ -2697,7 +2697,7 @@ dependencies = [
[[package]]
name = "iced_renderer"
version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
dependencies = [
"iced_graphics",
"iced_tiny_skia",
@ -2709,17 +2709,18 @@ dependencies = [
[[package]]
name = "iced_runtime"
version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
dependencies = [
"iced_core",
"iced_futures",
"thiserror",
"window_clipboard",
]
[[package]]
name = "iced_style"
version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
dependencies = [
"iced_core",
"once_cell",
@ -2729,7 +2730,7 @@ dependencies = [
[[package]]
name = "iced_tiny_skia"
version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
dependencies = [
"bytemuck",
"cosmic-text",
@ -2746,7 +2747,7 @@ dependencies = [
[[package]]
name = "iced_wgpu"
version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
dependencies = [
"bitflags 1.3.2",
"bytemuck",
@ -2765,7 +2766,7 @@ dependencies = [
[[package]]
name = "iced_widget"
version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
dependencies = [
"iced_renderer",
"iced_runtime",
@ -2779,7 +2780,7 @@ dependencies = [
[[package]]
name = "iced_winit"
version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
dependencies = [
"iced_graphics",
"iced_runtime",
@ -3131,10 +3132,11 @@ checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
[[package]]
name = "libcosmic"
version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic.git#2b23005fbff5a3d7e218a867e1aadb491abeac55"
source = "git+https://github.com/pop-os/libcosmic.git#171e697738e75cb1992b6ce9a0a728e89c72e119"
dependencies = [
"apply",
"ashpd 0.7.0",
"chrono",
"cosmic-config",
"cosmic-theme",
"css-color",
@ -3392,6 +3394,14 @@ dependencies = [
"paste",
]
[[package]]
name = "mime"
version = "0.1.0"
source = "git+https://github.com/pop-os/window_clipboard.git?tag=pop-mime-types#c3e9e794b94a2e79419517145424dc2035a572da"
dependencies = [
"smithay-clipboard",
]
[[package]]
name = "mime"
version = "0.3.17"
@ -3404,7 +3414,7 @@ version = "2.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef"
dependencies = [
"mime",
"mime 0.3.17",
"unicase",
]
@ -4867,9 +4877,8 @@ dependencies = [
[[package]]
name = "smithay-clipboard"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c091e7354ea8059d6ad99eace06dd13ddeedbb0ac72d40a9a6e7ff790525882d"
version = "0.8.0"
source = "git+https://github.com/pop-os/smithay-clipboard?tag=pop-mime-types#cc0101c1f9ccc937a413bd3af3c0f6217f27e935"
dependencies = [
"libc",
"smithay-client-toolkit",
@ -6005,13 +6014,13 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "window_clipboard"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6d692d46038c433f9daee7ad8757e002a4248c20b0a3fbc991d99521d3bcb6d"
source = "git+https://github.com/pop-os/window_clipboard.git?tag=pop-mime-types#c3e9e794b94a2e79419517145424dc2035a572da"
dependencies = [
"clipboard-win",
"clipboard_macos",
"clipboard_wayland",
"clipboard_x11",
"mime 0.1.0",
"raw-window-handle 0.6.0",
"thiserror",
]
@ -6402,7 +6411,7 @@ checksum = "87bf7b69bb50588d70a36e467be29d3df3e8c32580276d62eded9738c1a797aa"
dependencies = [
"dirs-next",
"glob",
"mime",
"mime 0.3.17",
"nom 5.1.3",
"unicase",
]

View file

@ -58,4 +58,4 @@ wgpu = ["libcosmic/wgpu", "cosmic-files/wgpu"]
[profile.release-with-debug]
inherits = "release"
debug = true
debug = true

View file

@ -1,49 +1,9 @@
use cosmic::{
iced::keyboard::{Key, Modifiers},
iced_core::keyboard::key::Named,
};
use serde::{Deserialize, Serialize};
use std::{collections::HashMap, fmt};
use cosmic::widget::menu::key_bind::{KeyBind, Modifier};
use cosmic::{iced::keyboard::Key, iced_core::keyboard::key::Named};
use std::collections::HashMap;
use crate::Action;
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
pub enum Modifier {
Super,
Ctrl,
Alt,
Shift,
}
#[derive(Clone, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
pub struct KeyBind {
pub modifiers: Vec<Modifier>,
pub key: Key,
}
impl KeyBind {
pub fn matches(&self, modifiers: Modifiers, key: &Key) -> bool {
key == &self.key
&& modifiers.logo() == self.modifiers.contains(&Modifier::Super)
&& modifiers.control() == self.modifiers.contains(&Modifier::Ctrl)
&& modifiers.alt() == self.modifiers.contains(&Modifier::Alt)
&& modifiers.shift() == self.modifiers.contains(&Modifier::Shift)
}
}
impl fmt::Display for KeyBind {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
for modifier in self.modifiers.iter() {
write!(f, "{:?} + ", modifier)?;
}
match &self.key {
Key::Character(c) => write!(f, "{}", c.to_uppercase()),
Key::Named(named) => write!(f, "{:?}", named),
other => write!(f, "{:?}", other),
}
}
}
//TODO: load from config
pub fn key_binds() -> HashMap<KeyBind, Action> {
let mut key_binds = HashMap::new();

View file

@ -1,5 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-only
use cosmic::widget::menu::action::MenuAction;
use cosmic::widget::menu::key_bind::KeyBind;
use cosmic::widget::segmented_button::Entity;
use cosmic::{
app::{message, Command, Core, Settings},
cosmic_config::{self, CosmicConfigEntry},
@ -44,7 +47,7 @@ mod git;
use icon_cache::IconCache;
mod icon_cache;
use key_bind::{key_binds, KeyBind};
use key_bind::key_binds;
mod key_bind;
use line_number::LineNumberCache;
@ -224,8 +227,9 @@ pub enum Action {
Undo,
}
impl Action {
pub fn message(&self) -> Message {
impl MenuAction for Action {
type Message = Message;
fn message(&self, _entity: Option<Entity>) -> Message {
match self {
Self::Todo => Message::Todo,
Self::About => Message::ToggleContextPage(ContextPage::About),
@ -1604,7 +1608,7 @@ impl Application for App {
Message::Key(modifiers, key) => {
for (key_bind, action) in self.key_binds.iter() {
if key_bind.matches(modifiers, &key) {
return self.update(action.message());
return self.update(action.message(None));
}
}
}
@ -2096,7 +2100,7 @@ impl Application for App {
// Close context menu
tab.context_menu = None;
// Run action's message
return self.update(action.message());
return self.update(action.message(None));
}
}
Message::TabContextMenu(entity, position_opt) => {
@ -2418,8 +2422,7 @@ impl Application for App {
diff_widget = diff_widget.push(hunk_widget);
}
tab_column = tab_column.push(widget::scrollable(
widget::cosmic_container::container(diff_widget)
.layer(cosmic_theme::Layer::Primary),
widget::layer_container(diff_widget).layer(cosmic_theme::Layer::Primary),
));
}
None => {}
@ -2517,9 +2520,8 @@ impl Application for App {
column = column.push(replace_widget);
}
tab_column = tab_column.push(
widget::cosmic_container::container(column).layer(cosmic_theme::Layer::Primary),
);
tab_column = tab_column
.push(widget::layer_container(column).layer(cosmic_theme::Layer::Primary));
}
let content: Element<_> = tab_column.into();

View file

@ -1,13 +1,11 @@
// SPDX-License-Identifier: GPL-3.0-only
use cosmic::widget::menu::key_bind::KeyBind;
use cosmic::widget::menu::menu_tree::{menu_items, menu_root, MenuItem};
use cosmic::{
//TODO: export in cosmic::widget
iced::{
widget::{column, horizontal_rule},
Alignment, Background, Length,
},
iced::{widget::column, Alignment, Background, Length},
iced_core::Border,
theme,
menu_button, theme,
widget::{
self, horizontal_space,
menu::{ItemHeight, ItemWidth, MenuBar, MenuTree},
@ -17,22 +15,7 @@ use cosmic::{
};
use std::{collections::HashMap, path::PathBuf};
use crate::{fl, icon_cache_get, Action, Config, ConfigState, KeyBind, Message};
macro_rules! menu_button {
($($x:expr),+ $(,)?) => (
widget::button(
widget::Row::with_children(
vec![$(Element::from($x)),+]
)
.align_items(Alignment::Center)
)
.height(Length::Fixed(32.0))
.padding([4, 16])
.width(Length::Fill)
.style(theme::Button::MenuItem)
);
}
use crate::{fl, Action, Config, ConfigState, Message};
pub fn context_menu<'a>(
key_binds: &HashMap<KeyBind, Action>,
@ -91,61 +74,8 @@ pub fn menu_bar<'a>(
projects: &Vec<(String, PathBuf)>,
) -> Element<'a, Message> {
//TODO: port to libcosmic
let menu_root = |label| {
widget::button(widget::text(label))
.padding([4, 12])
.style(theme::Button::MenuRoot)
};
let menu_folder =
|label| menu_button!(widget::text(label), horizontal_space(Length::Fill), ">");
let find_key = |action: &Action| -> String {
for (key_bind, key_action) in key_binds.iter() {
if action == key_action {
return key_bind.to_string();
}
}
if action == &Action::Todo {
return fl!("todo");
}
String::new()
};
let menu_item = |label, action| {
let key = find_key(&action);
MenuTree::new(
menu_button!(
widget::text(label),
horizontal_space(Length::Fill),
widget::text(key)
)
.on_press(action.message()),
)
};
//TODO: support key lookup?
let menu_checkbox = |label, value, action| {
let check: Element<_> = if value {
icon_cache_get("object-select-symbolic", 16).into()
} else {
widget::Space::with_width(Length::Fixed(16.0)).into()
};
let key = find_key(&action);
MenuTree::new(
menu_button!(
check,
widget::Space::with_width(Length::Fixed(8.0)),
widget::text(label),
horizontal_space(Length::Fill),
widget::text(key)
)
.on_press(action.message()),
)
};
let menu_tab_width = |tab_width: u16| {
menu_checkbox(
MenuItem::CheckBox(
fl!("tab-width", tab_width = tab_width),
config.tab_width == tab_width,
Action::TabWidth(tab_width),
@ -164,114 +94,132 @@ pub fn menu_bar<'a>(
let mut recent_files = Vec::with_capacity(config_state.recent_files.len());
for (i, path) in config_state.recent_files.iter().enumerate() {
recent_files.push(menu_item(format_path(path), Action::OpenRecentFile(i)));
recent_files.push(MenuItem::Button(
format_path(path),
Action::OpenRecentFile(i),
));
}
let mut recent_projects = Vec::with_capacity(config_state.recent_projects.len());
for (i, path) in config_state.recent_projects.iter().enumerate() {
recent_projects.push(menu_item(format_path(path), Action::OpenRecentProject(i)));
recent_projects.push(MenuItem::Button(
format_path(path),
Action::OpenRecentProject(i),
));
}
let mut close_projects = Vec::with_capacity(projects.len());
for (project_i, (name, _path)) in projects.iter().enumerate() {
close_projects.push(menu_item(name.clone(), Action::CloseProject(project_i)));
close_projects.push(MenuItem::Button(
name.clone(),
Action::CloseProject(project_i),
));
}
MenuBar::new(vec![
MenuTree::with_children(
menu_root(fl!("file")),
vec![
menu_item(fl!("new-file"), Action::NewFile),
menu_item(fl!("new-window"), Action::NewWindow),
MenuTree::new(horizontal_rule(1)),
menu_item(fl!("open-file"), Action::OpenFileDialog),
MenuTree::with_children(menu_folder(fl!("open-recent-file")), recent_files),
menu_item(fl!("close-file"), Action::CloseFile),
MenuTree::new(horizontal_rule(1)),
menu_item(fl!("menu-open-project"), Action::OpenProjectDialog),
MenuTree::with_children(menu_folder(fl!("open-recent-project")), recent_projects),
MenuTree::with_children(menu_folder(fl!("close-project")), close_projects),
MenuTree::new(horizontal_rule(1)),
menu_item(fl!("save"), Action::Save),
menu_item(fl!("save-as"), Action::SaveAsDialog),
MenuTree::new(horizontal_rule(1)),
menu_item(fl!("revert-all-changes"), Action::Todo),
MenuTree::new(horizontal_rule(1)),
menu_item(
fl!("menu-document-statistics"),
Action::ToggleDocumentStatistics,
),
//TODO menu_item(fl!("document-type"), Action::Todo),
//TODO menu_item(fl!("encoding"), Action::Todo),
menu_item(fl!("menu-git-management"), Action::ToggleGitManagement),
//TODO menu_item(fl!("print"), Action::Todo),
MenuTree::new(horizontal_rule(1)),
menu_item(fl!("quit"), Action::Quit),
],
menu_items(
key_binds,
vec![
MenuItem::Button(fl!("new-file"), Action::NewFile),
MenuItem::Button(fl!("new-window"), Action::NewWindow),
MenuItem::Divider,
MenuItem::Button(fl!("open-file"), Action::OpenFileDialog),
MenuItem::Folder(fl!("open-recent-file"), recent_files),
MenuItem::Button(fl!("close-file"), Action::CloseFile),
MenuItem::Divider,
MenuItem::Button(fl!("menu-open-project"), Action::OpenProjectDialog),
MenuItem::Folder(fl!("open-recent-project"), recent_projects),
MenuItem::Folder(fl!("close-project"), close_projects),
MenuItem::Divider,
MenuItem::Button(fl!("save"), Action::Save),
MenuItem::Button(fl!("save-as"), Action::SaveAsDialog),
MenuItem::Divider,
MenuItem::Button(fl!("revert-all-changes"), Action::Todo),
MenuItem::Divider,
MenuItem::Button(
fl!("menu-document-statistics"),
Action::ToggleDocumentStatistics,
),
//TODO MenuItem::Button(fl!("document-type"), Action::Todo),
//TODO MenuItem::Button(fl!("encoding"), Action::Todo),
MenuItem::Button(fl!("menu-git-management"), Action::ToggleGitManagement),
//TODO MenuItem::Button(fl!("print"), Action::Todo),
MenuItem::Divider,
MenuItem::Button(fl!("quit"), Action::Quit),
],
),
),
MenuTree::with_children(
menu_root(fl!("edit")),
vec![
menu_item(fl!("undo"), Action::Undo),
menu_item(fl!("redo"), Action::Redo),
MenuTree::new(horizontal_rule(1)),
menu_item(fl!("cut"), Action::Cut),
menu_item(fl!("copy"), Action::Copy),
menu_item(fl!("paste"), Action::Paste),
menu_item(fl!("select-all"), Action::SelectAll),
MenuTree::new(horizontal_rule(1)),
menu_item(fl!("find"), Action::Find),
menu_item(fl!("replace"), Action::FindAndReplace),
menu_item(fl!("find-in-project"), Action::ToggleProjectSearch),
MenuTree::new(horizontal_rule(1)),
menu_item(fl!("spell-check"), Action::Todo),
],
menu_items(
key_binds,
vec![
MenuItem::Button(fl!("undo"), Action::Undo),
MenuItem::Button(fl!("redo"), Action::Redo),
MenuItem::Divider,
MenuItem::Button(fl!("cut"), Action::Cut),
MenuItem::Button(fl!("copy"), Action::Copy),
MenuItem::Button(fl!("paste"), Action::Paste),
MenuItem::Button(fl!("select-all"), Action::SelectAll),
MenuItem::Divider,
MenuItem::Button(fl!("find"), Action::Find),
MenuItem::Button(fl!("replace"), Action::FindAndReplace),
MenuItem::Button(fl!("find-in-project"), Action::ToggleProjectSearch),
MenuItem::Divider,
MenuItem::Button(fl!("spell-check"), Action::Todo),
],
),
),
MenuTree::with_children(
menu_root(fl!("view")),
vec![
MenuTree::with_children(
menu_folder(fl!("indentation")),
vec![
menu_checkbox(
fl!("automatic-indentation"),
config.auto_indent,
Action::ToggleAutoIndent,
),
MenuTree::new(horizontal_rule(1)),
menu_tab_width(1),
menu_tab_width(2),
menu_tab_width(3),
menu_tab_width(4),
menu_tab_width(5),
menu_tab_width(6),
menu_tab_width(7),
menu_tab_width(8),
//TODO MenuTree::new(horizontal_rule(1)),
//TODO menu_item(fl!("convert-indentation-to-spaces"), Action::Todo),
//TODO menu_item(fl!("convert-indentation-to-tabs"), Action::Todo),
],
),
MenuTree::new(horizontal_rule(1)),
menu_checkbox(fl!("word-wrap"), config.word_wrap, Action::ToggleWordWrap),
menu_checkbox(
fl!("show-line-numbers"),
config.line_numbers,
Action::ToggleLineNumbers,
),
menu_checkbox(
fl!("highlight-current-line"),
config.highlight_current_line,
Action::ToggleHighlightCurrentLine,
),
//TODO: menu_item(fl!("syntax-highlighting"), Action::Todo),
MenuTree::new(horizontal_rule(1)),
menu_item(fl!("menu-settings"), Action::ToggleSettingsPage),
//TODO MenuTree::new(horizontal_rule(1)),
//TODO menu_item(fl!("menu-keyboard-shortcuts"), Action::Todo),
MenuTree::new(horizontal_rule(1)),
menu_item(fl!("menu-about"), Action::About),
],
menu_items(
key_binds,
vec![
MenuItem::Folder(
fl!("indentation"),
vec![
MenuItem::CheckBox(
fl!("automatic-indentation"),
config.auto_indent,
Action::ToggleAutoIndent,
),
MenuItem::Divider,
menu_tab_width(1),
menu_tab_width(2),
menu_tab_width(3),
menu_tab_width(4),
menu_tab_width(5),
menu_tab_width(6),
menu_tab_width(7),
menu_tab_width(8),
//TODO MenuItem::Divider,
//TODO MenuItem::Button(fl!("convert-indentation-to-spaces"), Action::Todo),
//TODO MenuItem::Button(fl!("convert-indentation-to-tabs"), Action::Todo),
],
),
MenuItem::Divider,
MenuItem::CheckBox(fl!("word-wrap"), config.word_wrap, Action::ToggleWordWrap),
MenuItem::CheckBox(
fl!("show-line-numbers"),
config.line_numbers,
Action::ToggleLineNumbers,
),
MenuItem::CheckBox(
fl!("highlight-current-line"),
config.highlight_current_line,
Action::ToggleHighlightCurrentLine,
),
//TODO: MenuItem::CheckBox(fl!("syntax-highlighting"), Action::Todo),
MenuItem::Divider,
MenuItem::Button(fl!("menu-settings"), Action::ToggleSettingsPage),
//TODO MenuItem::Divider,
//TODO MenuItem::Button(fl!("menu-keyboard-shortcuts"), Action::Todo),
MenuItem::Divider,
MenuItem::Button(fl!("menu-about"), Action::About),
],
),
),
])
.item_height(ItemHeight::Dynamic(40))