Merge pull request #9880 from dotCooCoo/fix/swatch-footer-menus

Swatches: Swatch Libraries and Show Swatch Kinds report that they open a menu
This commit is contained in:
.CooCoo authored and GitHub committed 2026-11-28 00:28:19 -08:00
commit 1f9b44c65c
3 files changed
+24 -3

No files matched your search

+5 -3
View File
@@ -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::<SwatchLibraries>(&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::<SwatchLibraries>(&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())
@@ -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<vectorcraft_doc::NodeId>) -> PanelDrag {
let (document, reverts) = app.session.active().map_or((0, 0), |st| (st.uid, st.reverts));
@@ -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<craft::ui::contract::PopupKind> {
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