mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-26 19:36:16 +00:00
Merge pull request #9343 from dotCooCoo/fix/cycle-display-sizes-name
Panels: the Cycle Display Sizes button is named by its label
This commit is contained in:
@@ -20,7 +20,7 @@ use std::sync::Arc;
|
||||
|
||||
use craft::behavior::{Axis, DockSide, IconId};
|
||||
use craft::ui::buttons::IconButton;
|
||||
use craft::ui::contract::{Bind, BodyCx, PlainData, Show as _, Tracked};
|
||||
use craft::ui::contract::{Bind, BodyCx, PlainData, Props as _, Show as _, Tracked};
|
||||
use craft::ui::docking::{
|
||||
ColumnCards, DockCommands, DockConfig, DockEvent, DockGrid, DockPanels, DockScene, DockSizes, DockTo, DragUnit, FloatSpace, GroupAt, HidePanels,
|
||||
PanelKey, PanelSpec, PanelSpecs, actions as command_actions, move_actions, request_actions,
|
||||
@@ -1255,7 +1255,10 @@ impl DockPanels<String> for Panels<'_> {
|
||||
|
||||
fn group_header(&mut self, panels: &[String], active: usize, ui: &mut egui::Ui, _cx: &mut BodyCx<'_>) {
|
||||
let Some(panel) = panels.get(active).filter(|p| sizes::has_sizes(p)) else { return };
|
||||
IconButton::command(IconId::new("dc-cycle-sizes"), CommandRef::with_params("window.panel.cycleOptions", json!({"panel": panel}))).show(ui);
|
||||
// The command has no menu item, so its label comes from here: the button and its tooltip are named by it.
|
||||
IconButton::command(IconId::new("dc-cycle-sizes"), CommandRef::with_params("window.panel.cycleOptions", json!({"panel": panel})))
|
||||
.label(tl!("Cycle Display Sizes"))
|
||||
.show(ui);
|
||||
}
|
||||
|
||||
fn panel_rows(&mut self, panel: &String) -> Vec<PanelRow> {
|
||||
|
||||
@@ -911,6 +911,19 @@ fn cycle_options_steps_through_the_sizes_and_returns_to_the_largest() {
|
||||
assert!(!crate::panels::part_hidden(&h.app, "tr-hide-thumbs"), "the largest size shows the thumbnails");
|
||||
}
|
||||
|
||||
/// The tab strip's Cycle Display Sizes button is named by its label, and no button of a panel's tab
|
||||
/// strip is named by a command id.
|
||||
#[test]
|
||||
fn tab_strip_buttons_are_named_by_their_labels() {
|
||||
let mut h = Harness::new();
|
||||
h.app.run("window.panel.activate", json!({"panel": "stroke"})).unwrap();
|
||||
h.frames(3);
|
||||
let buttons: Vec<&str> = h.nodes.iter().filter(|(_, n)| n.role() == egui::accesskit::Role::Button).filter_map(|(_, n)| n.label()).collect();
|
||||
assert!(buttons.contains(&"Cycle Display Sizes"), "{buttons:?}");
|
||||
let ids: Vec<&&str> = buttons.iter().filter(|l| !l.contains(' ') && l.contains('.') && l.starts_with(|c: char| c.is_ascii_lowercase())).collect();
|
||||
assert!(ids.is_empty(), "buttons named by a command id: {ids:?}");
|
||||
}
|
||||
|
||||
/// A panel the Window menu floats opens tall enough for its content: every control of Asset Export,
|
||||
/// and every Image Trace control down to the top of its Advanced section, lies between the body's
|
||||
/// top and bottom, none scrolled or clipped away.
|
||||
|
||||
Reference in New Issue
Block a user