Skip to content

EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust

Merge origin/main into #1339

bflatasticeef999788975
diff --cc crates/ui-egui/src/header.rs
index 0807d1a33,3f82c3908..0e6ab3d2b
--- a/crates/ui-egui/src/header.rs
+++ b/crates/ui-egui/src/header.rs
@@@ -218,9 -226,7 +226,9 @@@ fn snapping_toggle(app: &mut Effectcraf
let snap = Rect::from_min_size(pos2(x, cy - 10.0), vec2(20.0, 20.0));
// The engine owns snapping (View ▸ Snapping); the checkbox mirrors it.
app.ui.snapping = app.session.state.snapping;
- if widgets::checkbox(ui, snap, app.ui.snapping, &t, egui::Id::unique("snapping")).changed() {
+ let snap_resp = widgets::checkbox(ui, snap, app.ui.snapping, &t, egui::Id::unique("snapping"));
+ crate::a11y::check_box(&snap_resp, tr("Snapping"), app.ui.snapping, true);
- if snap_resp.clicked() {
++ if snap_resp.changed() {
let _ = app.session.execute("view.snapping", serde_json::json!({}));
app.ui.snapping = app.session.state.snapping;
}
diff --cc crates/ui-egui/src/panels/effects_presets.rs
index 1e9d2f56b,e140e49e1..1ee34b4b1
--- a/crates/ui-egui/src/panels/effects_presets.rs
+++ b/crates/ui-egui/src/panels/effects_presets.rs
@@@ -229,27 -158,24 +230,45 @@@ fn folder_row
open
}
+/// What every row does with the keyboard focus: the focus ring, the panel taking the focus, the
+/// list owning its keys, and moving the focus here when the arrow keys asked for it.
+fn row_focus(app: &mut EffectcraftApp, ui: &egui::Ui, lp: &egui::Painter, resp: &egui::Response, r: Rect, id: egui::Id) {
+ let ctx = ui.ctx();
+ if a11y::take_pending_focus(ctx, "fx", id) {
+ resp.request_focus();
+ }
+ if resp.gained_focus() {
+ app.ui.focused = crate::dock::PanelKind::EffectsPresets;
+ }
+ if resp.has_focus() {
+ lp.rect_stroke(r.shrink(0.5), 0.0, Stroke::new(1.0, app.tokens.accent), egui::StrokeKind::Inside);
+ }
+}
+
+/// A click on a row moves the cursor there and gives the panel the keyboard.
+fn nav_click(ctx: &egui::Context, app: &mut EffectcraftApp, id: egui::Id) {
+ ctx.data_mut(|d| d.insert_temp(cursor_id(), id));
+ app.ui.focused = crate::dock::PanelKind::EffectsPresets;
+}
+
+ /// Number of visible rows before Animation Presets in the current panel state.
+ fn rows_before_presets(favorites: usize, recent: usize, searching: bool, favorites_open: bool, recent_open: bool) -> usize {
+ let mut rows = 0usize;
+ if favorites > 0 {
+ rows = rows.saturating_add(1);
+ if searching || favorites_open {
+ rows = rows.saturating_add(favorites);
+ }
+ }
+ if !searching && recent > 0 {
+ rows = rows.saturating_add(1);
+ if recent_open {
+ rows = rows.saturating_add(recent);
+ }
+ }
+ rows
+ }
+
/// An effect row (fx icon, highlighted name, favourite star, 32 bpc badge).
#[allow(clippy::too_many_arguments)]
fn effect_row(
@@@ -633,17 -397,26 +652,27 @@@ pub fn show(app: &mut EffectcraftApp, u
// Favorites and Recently Used.
let favs: Vec<_> = app.session.prefs.effects_favorites.iter().filter_map(|id| lookup(id)).filter(|e| keep(e)).collect();
+ let recent: Vec<_> = app.ui.effects_recent.iter().filter_map(|id| lookup(id)).filter(|e| keep(e)).collect();
+ let reveal_presets = ctx.data_mut(|data| data.remove_temp::<bool>(egui::Id::unique(REVEAL_PRESETS_ID))).unwrap_or(false);
+ if reveal_presets {
+ // These rows come before Animation Presets. Scroll past expanded lists so the section is
+ // visible even when Favorites or Recently Used is long.
+ let preceding_rows =
+ rows_before_presets(favs.len(), recent.len(), searching, app.ui.effects_open.contains("favorites"), app.ui.effects_open.contains("recent"));
+ scroll.offset = ROW_H * preceding_rows as f32;
+ y = list.min.y - scroll.offset;
++ nav.offset = scroll.offset;
+ }
- if !favs.is_empty() && folder_row(app, ui, &lp, list, &mut y, "favorites", "Favorites", 0.0, searching, Some(Icon::Star)) {
+ if !favs.is_empty() && folder_row(app, ui, &lp, list, &mut y, &mut nav, "favorites", "Favorites", 1, 0.0, searching, Some(Icon::Star)) {
let mut favs = favs;
favs.sort_by_key(|e| e.name);
for e in favs {
- effect_row(app, ui, &lp, list, &mut y, e, 0.0, &query, "effects.favorites", &mut apply);
+ effect_row(app, ui, &lp, list, &mut y, &mut nav, e, 2, 0.0, &query, "effects.favorites", &mut apply);
}
}
- let recent: Vec<_> = app.ui.effects_recent.iter().filter_map(|id| lookup(id)).filter(|e| keep(e)).collect();
- if !recent.is_empty() && !searching && folder_row(app, ui, &lp, list, &mut y, "recent", "Recently Used", 0.0, false, None) {
+ if !recent.is_empty() && !searching && folder_row(app, ui, &lp, list, &mut y, &mut nav, "recent", "Recently Used", 1, 0.0, false, None) {
for e in recent {
- effect_row(app, ui, &lp, list, &mut y, e, 0.0, &query, "effects.recent", &mut apply);
+ effect_row(app, ui, &lp, list, &mut y, &mut nav, e, 2, 0.0, &query, "effects.recent", &mut apply);
}
}
diff --cc crates/ui-egui/src/panels/render_queue.rs
index 41db787b3,46ddc77ff..21dc828ca
--- a/crates/ui-egui/src/panels/render_queue.rs
+++ b/crates/ui-egui/src/panels/render_queue.rs
@@@ -480,18 -494,14 +500,19 @@@ fn current_render_strip(app: &mut Effec
let render_b = Rect::from_min_size(pos2(top.max.x - 12.0 - bw, top.min.y + 34.0), vec2(bw, 26.0));
let stop_b = Rect::from_min_size(pos2(render_b.min.x - 8.0 - bw, render_b.min.y), vec2(bw, 26.0));
let can_render = !rendering && queue.iter().any(RenderQueueItem::is_queued) && !available.is_empty();
- let render_resp = widgets::text_button(ui, render_b, "Render", can_render, &t, egui::Id::unique("rq-render"));
- a11y::button(&render_resp, "Render", can_render);
- if widgets::text_button(ui, render_b, crate::i18n::tr("Render"), can_render, &t, egui::Id::unique("rq-render")).clicked() && can_render {
++ let render_label = tr("Render");
++ let render_resp = widgets::text_button(ui, render_b, render_label, can_render, &t, egui::Id::unique("rq-render"));
++ a11y::button(&render_resp, render_label, can_render);
+ if render_resp.clicked() && can_render {
actions.push(("renderQueue.render", json!({"wait": false})));
}
app.auto.add("renderQueue.render", render_b, "Render");
// Notify (sound + notification when the queue finishes).
let notify = app.session.project.render_prefs.notify;
let nb = Rect::from_min_size(pos2(render_b.min.x - 8.0 - 2.0 * bw - 8.0, render_b.min.y + 4.0), vec2(18.0, 18.0));
- if widgets::checkbox(ui, nb, notify, &t, egui::Id::unique("rq-notify")).changed() {
+ let notify_resp = widgets::checkbox(ui, nb, notify, &t, egui::Id::unique("rq-notify"));
+ a11y::check_box(&notify_resp, tr("Notify"), notify, true);
- if notify_resp.clicked() {
++ if notify_resp.changed() {
actions.push(("renderQueue.setNotify", json!({"notify": !notify})));
}
p.text(pos2(nb.max.x + 5.0, nb.center().y), Align2::LEFT_CENTER, tr("Notify"), Tokens::ui(11.5), t.text_dim);
@@@ -913,9 -797,7 +934,9 @@@ pub fn show(app: &mut EffectcraftApp, u
}
app.auto.add(&aid("twirl"), tw, "Twirl");
let cb = Rect::from_center_size(pos2(cx_render + 20.0, row.center().y), vec2(18.0, 18.0));
- let cb_resp = widgets::checkbox(ui, cb, it.render, &t, egui::Id::unique(("rq-cb", it.id)));
- if ui.add_enabled_ui(!rendering, |ui| widgets::checkbox(ui, cb, it.render, &t, egui::Id::unique(("rq-cb", it.id)))).inner.changed() && !rendering {
++ let cb_resp = ui.add_enabled_ui(!rendering, |ui| widgets::checkbox(ui, cb, it.render, &t, egui::Id::unique(("rq-cb", it.id)))).inner;
+ a11y::check_box(&cb_resp, &format!("{}: {name}", tr("Render")), it.render, !rendering);
- if cb_resp.clicked() && !rendering {
++ if cb_resp.changed() && !rendering {
actions.push(("renderQueue.setRender", json!({"item": it.id, "render": !it.render})));
}
app.auto.add(&aid("render"), cb, if it.render { "Render: on" } else { "Render: off" });