Separate the Type menu preview and language groups

This commit is contained in:
yoriswind committed 2026-11-30 19:50:05 -08:00
1 parent 59153889bd
commit aeba1971ce
2 files changed
+28

No files matched your search

+6
View File
@@ -468,6 +468,7 @@ pub static CATALOG: &[(&[&str], &str, Option<&str>, &str)] = &[
(&["Type", "Anti-Alias"], "---", None, "---"),
(&["Type", "Anti-Alias"], "Windows LCD", None, "type.antiAlias.windowsLcd"),
(&["Type", "Anti-Alias"], "Windows", None, "type.antiAlias.windows"),
(&["Type"], "---", None, "---"),
(&["Type", "Orientation"], "Horizontal", None, "type.orientation.horizontal"),
(&["Type", "Orientation"], "Vertical", None, "type.orientation.vertical"),
(&["Type", "OpenType"], "Standard Ligatures", None, "type.openType.standardLigatures"),
@@ -524,6 +525,7 @@ pub static CATALOG: &[(&[&str], &str, Option<&str>, &str)] = &[
(&["Type", "Font Preview Size"], "Large", None, "type.fontPreviewSize.large"),
(&["Type", "Font Preview Size"], "Extra Large", None, "type.fontPreviewSize.extraLarge"),
(&["Type", "Font Preview Size"], "Huge", None, "type.fontPreviewSize.huge"),
(&["Type"], "---", None, "---"),
(&["Type", "Language Options"], "Default Features", None, "type.languageOptions.defaultFeatures"),
(&["Type", "Language Options"], "East Asian Features", None, "type.languageOptions.eastAsianFeatures"),
(&["Type", "Language Options"], "Middle Eastern Features", None, "type.languageOptions.middleEasternFeatures"),
@@ -828,3 +830,7 @@ pub const ARRANGE_ICONS: &[(&str, &str)] = &[
("window.arrange.sixUp", "arrange-six-up"),
("window.arrange.consolidateAllToTabs", "arrange-consolidate-all-to-tabs"),
];
#[cfg(test)]
#[path = "menus/type_menu_groups_tests.rs"]
mod type_menu_groups_tests;
@@ -0,0 +1,22 @@
use crate::PhotocraftApp;
use craft::menu::{Node, from_items};
#[test]
fn type_submenus_keep_their_reference_groups() {
let app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default());
let bar = from_items(&["Type"], &crate::menus::menu_rows(&app));
let entries: Vec<_> = bar.menus[0]
.children
.iter()
.map(|node| match node {
Node::Separator => "---",
Node::Submenu { label, .. } | Node::Heading(label) => label.as_str(),
Node::Item(row) => row.command.id.as_str(),
})
.collect();
assert!(entries.windows(6).any(|rows| rows == ["---", "Anti-Alias", "---", "Orientation", "OpenType", "---"]), "{entries:?}");
assert!(entries.windows(6).any(|rows| rows == ["---", "Font Preview Size", "---", "Language Options", "---", "type.updateAllTextLayers"]), "{entries:?}");
let warp = entries.iter().position(|entry| *entry == "type.warpText").unwrap();
let preview = entries.iter().position(|entry| *entry == "Font Preview Size").unwrap();
assert!(warp < preview, "{entries:?}");
}