diff --git a/crates/ui-egui/src/panels/swatches.rs b/crates/ui-egui/src/panels/swatches.rs index cb3ab044d8..6af8860db0 100644 --- a/crates/ui-egui/src/panels/swatches.rs +++ b/crates/ui-egui/src/panels/swatches.rs @@ -14,7 +14,7 @@ use craft::color_ui::palette::{SwatchColor, SwatchEntry, SwatchGroup, SwatchKind use craft::color_ui::ui::{SwatchKey, SwatchesPanel, SwatchesState}; use craft::theme::Srgba; use craft::ui::choice::SwatchFace; -use craft::ui::contract::{Bind, DropPlace, ListDrag, MemoProps, SelectMode}; +use craft::ui::contract::{Bind, DropPlace, ListDrag, MemoProps, PopupKind, SelectMode}; use craft::ui::contract::{Entry, Props as _, Show as _, ShowContainer as _, Trigger}; use craft::ui::menu::{Menu, MenuItem}; use craft::ui::patterns::presets::{PresetEvent, PresetView, ThumbInfo}; @@ -778,8 +778,10 @@ fn footer(app: &mut VectorcraftApp, ui: &mut Ui) { // Libraries, Show Swatch Kinds and the edit action sit at the start edge; Delete at the end edge, then New Swatch // and New Color Group before it. let actions = [ - FooterAction::new(icon("library"), tl!(SwatchLibraries::MENU)).pressed(library_panel::any_open::(&app.ui)), - FooterAction::new(icon("dc-swatch-kinds"), tl!("Show Swatch Kinds")).pressed(kind != Kind::All), + FooterAction::new(icon("library"), tl!(SwatchLibraries::MENU)) + .popup(PopupKind::Menu) + .pressed(library_panel::any_open::(&app.ui)), + FooterAction::new(icon("dc-swatch-kinds"), tl!("Show Swatch Kinds")).popup(PopupKind::Menu).pressed(kind != Kind::All), edit, FooterAction::new(icon("trash-2"), tl!("Delete Swatch")) .enabled(!del.is_empty()) diff --git a/crates/ui-egui/src/panels/swatches/tests.rs b/crates/ui-egui/src/panels/swatches/tests.rs index 084a63f81d..78c4db6fcd 100644 --- a/crates/ui-egui/src/panels/swatches/tests.rs +++ b/crates/ui-egui/src/panels/swatches/tests.rs @@ -170,6 +170,20 @@ fn a_foreign_swatch_row_payload_cannot_move_or_replace_local_swatches() { assert_eq!(doc(&app).swatches, before.swatches); } +#[test] +fn the_footer_menu_buttons_report_that_they_open_a_menu() { + use crate::tests::panel_harness::Panel; + use craft::ui::contract::PopupKind; + + let panel = Panel::new(app(), show); + for name in [SwatchLibraries::MENU, "Show Swatch Kinds"] { + assert_eq!(panel.popup_kind(name), Some(PopupKind::Menu), "{name}"); + } + for name in ["Delete Swatch", "New Swatch", "New Color Group"] { + assert_eq!(panel.popup_kind(name), None, "{name}"); + } +} + /// Art `ids` dragged off the canvas. fn art_drag(app: &VectorcraftApp, ids: Vec) -> PanelDrag { let (document, reverts) = app.session.active().map_or((0, 0), |st| (st.uid, st.reverts)); diff --git a/crates/ui-egui/src/tests/panel_harness.rs b/crates/ui-egui/src/tests/panel_harness.rs index 3ef4774f5b..f1f58c89ad 100644 --- a/crates/ui-egui/src/tests/panel_harness.rs +++ b/crates/ui-egui/src/tests/panel_harness.rs @@ -412,6 +412,11 @@ impl Panel { self.fixture.tree().toggled_of(self.look(name).node) } + /// The kind of popup the control named `name` reports that it opens. + pub(crate) fn popup_kind(&self, name: &str) -> Option { + self.fixture.tree().has_popup_of(self.look(name).node) + } + /// Whether the control named `name` has the focus. pub(crate) fn focused(&self, name: &str) -> bool { self.fixture.tree().focused_key() == self.look(name).node