Timeline: Ctrl/Cmd-click on the time display toggles Timecode / Frames (#370)
The Time Display Style could only be changed in Project Settings. As in
After Effects, Ctrl-click (Cmd-click on macOS) on the current-time
display of the Timeline or the Composition panel now toggles it between
Timecode and Frames (Feet + Frames goes to Timecode). It runs
`file.projectSettings {timeDisplay}`, so it is one undo step.
Under the Timeline's display the other style shows now (frames under
timecode, timecode under frames), as in After Effects; it always showed
frames.
Tests: ctrl_click_on_the_time_display_toggles_timecode_and_frames
(ui_inline_edit).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
fcf3bb5dca
commit
0b2ef8e584
@@ -84,6 +84,18 @@ pub fn timecode(session: &Session, comp: &Comp, t: Tick) -> String {
|
||||
effectcraft_engine::commands::time::display_time(session, comp, t)
|
||||
}
|
||||
|
||||
/// Ctrl/Cmd-click on a current-time display toggles the project's Time Display Style between
|
||||
/// Timecode and Frames, as in After Effects (through Project Settings: one undo step).
|
||||
pub(crate) fn toggle_time_display(app: &mut EffectcraftApp, resp: &egui::Response) {
|
||||
if !(resp.clicked() && resp.ctx.input(|i| i.modifiers.command)) {
|
||||
return;
|
||||
}
|
||||
let timecode = app.session.project.settings.time_display == effectcraft_engine::project::TimeDisplayStyle::Timecode;
|
||||
if let Err(e) = app.session.execute("file.projectSettings", serde_json::json!({"timeDisplay": if timecode { "frames" } else { "timecode" }})) {
|
||||
app.ui.status = e.to_string();
|
||||
}
|
||||
}
|
||||
|
||||
/// Spacebar held outside a text field: the Hand tool (drags pan the viewer and scroll the
|
||||
/// Timeline).
|
||||
pub(crate) fn space_hand(ctx: &egui::Context) -> bool {
|
||||
|
||||
@@ -1156,9 +1156,16 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
let tc_rect = Rect::from_min_size(pos2(rect.min.x + 12.0, top + 6.0), vec2(150.0, 24.0));
|
||||
let tc_resp = ui.interact(tc_rect, egui::Id::new("tl-timecode"), Sense::click_and_drag());
|
||||
p.text(tc_rect.left_center(), Align2::LEFT_CENTER, &tc, Tokens::semibold(16.0), t.timecode);
|
||||
let sub = format!("{:05} ({:.2} fps)", fr.frame_at(time) + app.session.project.settings.frame_start, fr.as_f64());
|
||||
p.text(pos2(tc_rect.min.x, tc_rect.max.y + 8.0), Align2::LEFT_CENTER, sub, Tokens::ui(10.5), t.text_faint);
|
||||
// Under it the other style (frames under timecode, timecode under frames) and the rate.
|
||||
let settings = &app.session.project.settings;
|
||||
let other = if settings.time_display == effectcraft_engine::project::TimeDisplayStyle::Timecode {
|
||||
format!("{:05}", fr.frame_at(time) + settings.frame_start)
|
||||
} else {
|
||||
effectcraft_engine::time::format_timecode_ae(fr.frame_at(time + comp.display_start), fr, false)
|
||||
};
|
||||
p.text(pos2(tc_rect.min.x, tc_rect.max.y + 8.0), Align2::LEFT_CENTER, format!("{other} ({:.2} fps)", fr.as_f64()), Tokens::ui(10.5), t.text_faint);
|
||||
app.auto.add("timeline.timecode", tc_rect, &tc);
|
||||
super::toggle_time_display(app, &tc_resp);
|
||||
if tc_resp.dragged() {
|
||||
let d = tc_resp.drag_delta().x as f64;
|
||||
let f = fr.frame_at(time) + (d * 0.5).round() as i64;
|
||||
|
||||
@@ -733,7 +733,9 @@ pub(crate) fn bottom_bar(app: &mut EffectcraftApp, ui: &mut egui::Ui, bar: Rect,
|
||||
let g = p.layout_no_wrap(tc, Tokens::mono(12.0), t.timecode);
|
||||
let tr = Rect::from_min_size(pos2(x + 4.0, cy - 9.0), g.size() + vec2(8.0, 4.0));
|
||||
p.galley(pos2(tr.min.x + 4.0, tr.min.y + 2.0), g, t.timecode);
|
||||
let resp = ui.interact(tr, egui::Id::new("vw-timecode"), Sense::click());
|
||||
app.auto.add("viewer.timecode", tr, "Current time");
|
||||
crate::panels::toggle_time_display(app, &resp);
|
||||
// Right: render time.
|
||||
let ms = app.frames.last_ms.lock().map(|v| *v).unwrap_or(0.0);
|
||||
if tr.max.x + 50.0 < bar.max.x {
|
||||
|
||||
Reference in New Issue
Block a user