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
@@ -1,13 +1,15 @@
|
||||
//! Timeline layer switches with real pointer input (egui_kittest): pressing a switch and
|
||||
//! dragging over other layers gives them all the state the first one got, in one undo step, as
|
||||
//! in After Effects (#227); stopwatches the same way (#284). Also the layer bar past its source
|
||||
//! (#290).
|
||||
//! in After Effects (#227); stopwatches the same way (#284). Also the label swatch's menu and the
|
||||
//! layer bar past its source (#290).
|
||||
|
||||
use effectcraft_engine::Session;
|
||||
use effectcraft_engine::color::Label;
|
||||
use effectcraft_engine::project::LayerId;
|
||||
use effectcraft_ui_egui::EffectcraftApp;
|
||||
use egui::{Event, Modifiers, Pos2, Rect, pos2, vec2};
|
||||
use egui::{Color32, Event, Modifiers, Pos2, Rect, pos2, vec2};
|
||||
use egui_kittest::Harness;
|
||||
use egui_kittest::kittest::Queryable;
|
||||
use serde_json::json;
|
||||
|
||||
/// Comp "Main" with solids A (top) to D (bottom); returns their ids top to bottom.
|
||||
@@ -146,6 +148,38 @@ fn dragging_over_stopwatches_sets_them_all() {
|
||||
assert_eq!(animated(&h), [true; 5], "each drag was one step");
|
||||
}
|
||||
|
||||
/// 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))
|
||||
}
|
||||
|
||||
/// Clicking a layer's label swatch opens the label menu, which shows each label's colour before
|
||||
/// its name, so a label is picked by its colour (#290).
|
||||
#[test]
|
||||
fn the_label_swatch_menu_shows_the_label_colours() {
|
||||
let (mut h, ids) = harness();
|
||||
let green = h.state().session.prefs.label_name(Label::Green);
|
||||
let at = rect(&h, &format!("timeline.layer.{}.label", ids[1])).center();
|
||||
drag(&mut h, at, at, 1);
|
||||
let entry = h.query_by_label(&green).expect("the label menu is open").rect();
|
||||
for l in [Label::Green, Label::SeaFoam, Label::Purple] {
|
||||
let e = h.query_by_label(&h.state().session.prefs.label_name(l)).unwrap().rect();
|
||||
assert!(swatch_in(&h, e, h.state().tokens.label(l)), "no {l:?} swatch");
|
||||
}
|
||||
let undo = h.state().session.history.undo.len();
|
||||
drag(&mut h, entry.center(), entry.center(), 1);
|
||||
assert_eq!(h.state().session.active_comp().unwrap().layer(LayerId(ids[1])).unwrap().label, Label::Green);
|
||||
assert_eq!(h.state().session.history.undo.len(), undo + 1);
|
||||
assert!(h.query_by_label(&green).is_none(), "the menu closed after the choice");
|
||||
}
|
||||
|
||||
/// A layer extended past its source's end (its last frame held) has that part of its bar
|
||||
/// striped, so the source's own span shows (#290); with time remapping it isn't.
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user