Merge pull request #1044 from pravdomil/claude/timeline-chevron-expand-tree-93231f
This commit is contained in:
@@ -646,6 +646,27 @@ impl<'a> FxScope<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Twirl `g` closed (it was `open`) or open; with `all` (Alt/Cmd-click) every group under it follows.
|
||||
fn toggle_closed(app: &mut EffectcraftApp, g: &PropGroup, open: bool, all: bool) {
|
||||
fn walk(g: &PropGroup, out: &mut Vec<u64>) {
|
||||
for sg in g.groups() {
|
||||
out.push(sg.uid);
|
||||
walk(sg, out);
|
||||
}
|
||||
}
|
||||
let mut uids = vec![g.uid];
|
||||
if all {
|
||||
walk(g, &mut uids);
|
||||
}
|
||||
for u in uids {
|
||||
if open {
|
||||
app.ui.fx_closed.insert(u);
|
||||
} else {
|
||||
app.ui.fx_closed.remove(&u);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn group_rows(
|
||||
app: &mut EffectcraftApp,
|
||||
@@ -705,11 +726,7 @@ fn group_rows(
|
||||
app.auto.add(&format!("effectControls.row.{}", sg.uid), r, &sg.name);
|
||||
app.auto.add(&format!("effectControls.group.{}.twirl", sg.uid), tw, &sg.name);
|
||||
if widgets::twirl(ui, tw, open, egui::Id::new(("ec-g", sg.uid)), &t).clicked() {
|
||||
if open {
|
||||
app.ui.fx_closed.insert(sg.uid);
|
||||
} else {
|
||||
app.ui.fx_closed.remove(&sg.uid);
|
||||
}
|
||||
toggle_closed(app, sg, open, ui.input(|i| i.modifiers.alt || i.modifiers.command));
|
||||
}
|
||||
let name = p.text(pos2(tw.max.x + 6.0, r.center().y), Align2::LEFT_CENTER, &sg.name, Tokens::ui(12.0), t.text);
|
||||
app.auto.add(&format!("effectControls.group.{}.name", sg.uid), name, &sg.name);
|
||||
@@ -1114,11 +1131,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
app.auto.add(&format!("effectControls.effect.{}.fx", g.uid), fxr, &g.name);
|
||||
let tw = Rect::from_center_size(pos2(r.min.x + 32.0, r.center().y), vec2(12.0, 12.0));
|
||||
if widgets::twirl(ui, tw, open, egui::Id::new(("ec-tw", g.uid)), &t).clicked() {
|
||||
if open {
|
||||
app.ui.fx_closed.insert(g.uid);
|
||||
} else {
|
||||
app.ui.fx_closed.remove(&g.uid);
|
||||
}
|
||||
toggle_closed(app, g, open, ui.input(|i| i.modifiers.alt || i.modifiers.command));
|
||||
}
|
||||
app.auto.add(&format!("effectControls.effect.{}.twirl", g.uid), tw, &g.name);
|
||||
let rename_id = egui::Id::new(("ec-rename", g.uid));
|
||||
|
||||
@@ -579,10 +579,21 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
egui::WidgetInfo::labeled(egui::WidgetType::Button, true, name)
|
||||
});
|
||||
if tresp.clicked() {
|
||||
if open {
|
||||
app.ui.project_open_folders.remove(&id.0);
|
||||
} else {
|
||||
app.ui.project_open_folders.insert(id.0);
|
||||
// Alt/Cmd-click twirls every folder inside it too.
|
||||
let mut ids = vec![*id];
|
||||
if ui.input(|i| i.modifiers.alt || i.modifiers.command) {
|
||||
let mut at = 0;
|
||||
while let Some(f) = ids.get(at).copied() {
|
||||
ids.extend(app.session.project.children(Some(f)).into_iter().filter(|c| c.is_folder()).map(|c| c.id));
|
||||
at += 1;
|
||||
}
|
||||
}
|
||||
for f in ids {
|
||||
if open {
|
||||
app.ui.project_open_folders.remove(&f.0);
|
||||
} else {
|
||||
app.ui.project_open_folders.insert(f.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
app.auto.add(&format!("project.item.{}.twirl", id.0), tw, &it.name);
|
||||
|
||||
@@ -2268,7 +2268,8 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
if *has_children {
|
||||
let tw = Rect::from_center_size(pos2(indent, cy), vec2(13.0, 13.0));
|
||||
if widgets::twirl(ui, tw, *open, egui::Id::new(("gtw", uid)), &t).clicked() {
|
||||
ui_actions.push(UiAct::ToggleGroup(*uid));
|
||||
// Alt/Cmd-click twirls the whole tree under the group (as on a layer).
|
||||
ui_actions.push(UiAct::ToggleGroup(layer.id.0, *uid, ui.input(|i| i.modifiers.alt || i.modifiers.command)));
|
||||
}
|
||||
app.auto.add(&format!("timeline.group.{uid}.twirl"), tw, name);
|
||||
}
|
||||
@@ -2337,7 +2338,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
actions.push(("prop.select".into(), json!({"layer": layer.id.0, "prop": uid, "selectKeys": false})));
|
||||
actions.push(("window.panel".into(), json!({"panel": "EffectControls"})));
|
||||
} else {
|
||||
ui_actions.push(UiAct::ToggleGroup(*uid));
|
||||
ui_actions.push(UiAct::ToggleGroup(layer.id.0, *uid, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3233,9 +3234,22 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
}
|
||||
}
|
||||
}
|
||||
UiAct::ToggleGroup(uid) => {
|
||||
if !app.ui.timeline.open_groups.remove(&uid) {
|
||||
app.ui.timeline.open_groups.insert(uid);
|
||||
UiAct::ToggleGroup(layer, uid, all) => {
|
||||
let tl = &mut app.ui.timeline;
|
||||
let open = !tl.open_groups.remove(&uid);
|
||||
if open {
|
||||
tl.open_groups.insert(uid);
|
||||
}
|
||||
if all && let Some(g) = comp.layer(LayerId(layer)).and_then(|l| find_group(&l.props, uid)) {
|
||||
let mut uids = vec![];
|
||||
walk_groups(g, &mut uids);
|
||||
for u in uids {
|
||||
if open {
|
||||
tl.open_groups.insert(u);
|
||||
} else {
|
||||
tl.open_groups.remove(&u);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
UiAct::SetTime(tt) => app.session.set_time(tt),
|
||||
@@ -3359,7 +3373,8 @@ fn layer_cells(
|
||||
|
||||
enum UiAct {
|
||||
ToggleLayer(u64, bool),
|
||||
ToggleGroup(u64),
|
||||
/// Layer, group uid, and whether the whole tree under the group follows.
|
||||
ToggleGroup(u64, u64, bool),
|
||||
SetTime(Tick),
|
||||
EndMerge,
|
||||
/// Composition Settings on its 3D Renderer tab.
|
||||
@@ -3367,12 +3382,21 @@ enum UiAct {
|
||||
}
|
||||
|
||||
fn walk_groups(g: &PropGroup, out: &mut Vec<u64>) {
|
||||
// Audio's Waveform row is not in the property tree; it twirls along.
|
||||
if g.match_id == "audio" {
|
||||
out.push(WAVE_BIT | g.uid);
|
||||
}
|
||||
for sg in g.groups() {
|
||||
out.push(sg.uid);
|
||||
walk_groups(sg, out);
|
||||
}
|
||||
}
|
||||
|
||||
/// The group `uid` anywhere under `g`.
|
||||
fn find_group(g: &PropGroup, uid: u64) -> Option<&PropGroup> {
|
||||
g.groups().find_map(|sg| if sg.uid == uid { Some(sg) } else { find_group(sg, uid) })
|
||||
}
|
||||
|
||||
/// A stroke's Dashes "+" / "−" buttons (add or remove a Dash/Gap pair).
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn dash_buttons(
|
||||
@@ -3940,6 +3964,21 @@ fn value_editor(
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// Alt/Cmd-click twirls Audio's Waveform row (not in the property tree) with the rest.
|
||||
#[test]
|
||||
fn the_waveform_row_twirls_with_its_tree() {
|
||||
let mut root = PropGroup::new(1, "", "");
|
||||
let mut audio = PropGroup::new(2, "audio", "Audio");
|
||||
audio.children.push(PropGroup::new(3, "x", "X").into());
|
||||
root.children.push(audio.into());
|
||||
let mut uids = vec![];
|
||||
walk_groups(&root, &mut uids);
|
||||
assert_eq!(uids, vec![2, WAVE_BIT | 2, 3]);
|
||||
let mut uids = vec![];
|
||||
walk_groups(find_group(&root, 2).unwrap(), &mut uids);
|
||||
assert_eq!(uids, vec![WAVE_BIT | 2, 3]);
|
||||
}
|
||||
|
||||
/// #710: with Time Display set to Frames the ruler labels are frame numbers (as under the
|
||||
/// CTI, from Start Numbering Frames At); otherwise seconds:frames.
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user