Labels: label menus show each label's colour (#290)
The label menus listed the labels' names only, so a label couldn't be picked by its colour. Every place a label is chosen now shows its colour swatch before its name, as After Effects does: the Timeline's label swatch (which now opens its menu on a click too, not only a right-click), the Project panel's label swatch and a new Label submenu in its item menu, Edit > Label, keyframe Label menus and the marker dialog. One shared widget (widgets::label_entry / label_popup) draws them; keyframe labels now show the names set in Settings > Labels. Tests: label_swatch_opens_the_label_menu (ui_project_rows), the_label_swatch_menu_shows_the_label_colours (ui_timeline_switches), edit_label_menu_shows_the_label_colours (ui_panels). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
3174652ce4
commit
2f3a507f8e
@@ -5,7 +5,7 @@ use effectcraft_engine::Session;
|
||||
use effectcraft_engine::color::Label;
|
||||
use effectcraft_engine::project::{ItemId, ItemKind};
|
||||
use effectcraft_ui_egui::EffectcraftApp;
|
||||
use egui::{Event, Modifiers, Pos2, pos2};
|
||||
use egui::{Color32, Event, Modifiers, Pos2, Rect, pos2};
|
||||
use egui_kittest::Harness;
|
||||
use egui_kittest::kittest::Queryable;
|
||||
use serde_json::json;
|
||||
@@ -80,6 +80,18 @@ fn folder_twirl_opens_and_closes_the_folder_on_one_click() {
|
||||
assert!(h.state().ui.project_open_folders.contains(&folder.0), "a double-click on the row opens the folder");
|
||||
}
|
||||
|
||||
/// A swatch (a small rect filled with `col`) painted this frame in the left half of `row`.
|
||||
fn swatch_in(h: &Harness<'_, EffectcraftApp>, row: Rect, col: Color32) -> bool {
|
||||
fn walk(s: &egui::Shape, row: Rect, col: Color32) -> bool {
|
||||
match s {
|
||||
egui::Shape::Rect(r) => r.fill == col && r.rect.width() < 16.0 && row.contains(r.rect.center()) && r.rect.center().x < row.center().x,
|
||||
egui::Shape::Vec(v) => v.iter().any(|s| walk(s, row, col)),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
h.output().shapes.iter().any(|c| walk(&c.shape, row, col))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn label_swatch_opens_the_label_menu() {
|
||||
let (mut h, _, _, solid) = harness();
|
||||
@@ -89,6 +101,8 @@ fn label_swatch_opens_the_label_menu() {
|
||||
click(&mut h, &format!("project.item.{}.label", solid.0));
|
||||
assert!(h.state().session.state.project_selection.is_empty(), "the swatch does not select the row");
|
||||
let entry = h.query_by_label(&green).expect("the label menu is open").rect();
|
||||
// Each entry shows its colour before its name (#290).
|
||||
assert!(swatch_in(&h, entry, h.state().tokens.label(Label::Green)), "no {green} swatch");
|
||||
let undo = h.state().session.history.undo.len();
|
||||
click_at(&mut h, entry.center());
|
||||
assert_eq!(h.state().session.project.item(solid).unwrap().label, Label::Green);
|
||||
|
||||
Reference in New Issue
Block a user