Merge main into M13.7
This commit is contained in:
@@ -204,6 +204,10 @@ pub fn handle(app: &mut EffectcraftApp, ctx: &egui::Context, req: &ControlReques
|
||||
if let Some(b) = p.get("home").and_then(Value::as_bool) {
|
||||
app.ui.start_screen = b;
|
||||
}
|
||||
// Home screen tab: "home" or "learn".
|
||||
if let Some(tab) = p.get("homeTab").and_then(Value::as_str) {
|
||||
app.ui.home_learn = tab == "learn";
|
||||
}
|
||||
ok(Value::Null)
|
||||
}
|
||||
"ui.panel.show" | "ui.panel.close" => {
|
||||
|
||||
@@ -168,7 +168,9 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
app.set_workspace(crate::dock::WORKSPACES[i]);
|
||||
}
|
||||
rx = more.min.x - 6.0;
|
||||
let shown = ["Small Screen", "Standard", "Animation", "Default"];
|
||||
// After Effects 2026's workspace bar order (right to left here): Default, Review, Learn,
|
||||
// Small Screen, Standard.
|
||||
let shown = ["Standard", "Small Screen", "Learn", "Review", "Default"];
|
||||
for name in shown {
|
||||
let g = p.layout_no_wrap(name.to_string(), Tokens::ui(12.0), t.text);
|
||||
let w = g.size().x + 16.0;
|
||||
|
||||
@@ -89,6 +89,8 @@ pub enum Icon {
|
||||
MaskVis,
|
||||
Checker,
|
||||
Region,
|
||||
/// Extended Viewer: a small frame with corner ticks reaching outward.
|
||||
ExtendedViewer,
|
||||
Plus,
|
||||
Minus,
|
||||
Close,
|
||||
@@ -513,6 +515,12 @@ pub fn paint(painter: &Painter, rect: Rect, icon: Icon, color: Color32) {
|
||||
pen.rect(2.5, 2.5, 13.5, 13.5);
|
||||
pen.rect(5.5, 5.5, 10.5, 10.5);
|
||||
}
|
||||
ExtendedViewer => {
|
||||
pen.rect(5.0, 5.0, 11.0, 11.0);
|
||||
for (x, y, dx, dy) in [(2.0, 2.0, 1.0, 1.0), (14.0, 2.0, -1.0, 1.0), (2.0, 14.0, 1.0, -1.0), (14.0, 14.0, -1.0, -1.0)] {
|
||||
pen.line(&[(x + dx * 3.0, y), (x, y), (x, y + dy * 3.0)]);
|
||||
}
|
||||
}
|
||||
Plus => {
|
||||
pen.line(&[(8.0, 3.0), (8.0, 13.0)]);
|
||||
pen.line(&[(3.0, 8.0), (13.0, 8.0)]);
|
||||
|
||||
@@ -289,9 +289,10 @@ impl EffectcraftApp {
|
||||
self.ui.dock = self.ui.saved_workspaces.get(name).cloned().unwrap_or_else(|| dock::workspace(name));
|
||||
self.ui.floating = self.ui.saved_floating.get(name).cloned().unwrap_or_else(|| dock::workspace_floating(name));
|
||||
self.ui.maximized = None;
|
||||
// Learn: the Home screen (community links) in the Composition panel.
|
||||
// Learn: the Home screen's Learn tab (tutorials) in the Composition panel.
|
||||
if name == "Learn" {
|
||||
self.ui.start_screen = true;
|
||||
self.ui.home_learn = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,6 +347,7 @@ impl EffectcraftApp {
|
||||
&& v.channel == effectcraft_engine::viewer::Channel::Rgb
|
||||
&& v.exposure == 0.0
|
||||
&& self.session.state.region_of_interest.is_none()
|
||||
&& self.ui.viewer.extended.is_none()
|
||||
}
|
||||
|
||||
/// Set up the GPU compositor on egui-wgpu's device (once). Without an adapter that runs
|
||||
@@ -441,7 +443,7 @@ impl EffectcraftApp {
|
||||
use std::hash::{Hash, Hasher};
|
||||
let mut h = std::collections::hash_map::DefaultHasher::new();
|
||||
// The region of interest changes what is rendered too.
|
||||
let roi = self.session.state.region_of_interest.filter(|_| self.session.active_comp_id() == Some(comp));
|
||||
let roi = self.viewer_region(comp);
|
||||
if let Some(r) = roi {
|
||||
r.map(f64::to_bits).hash(&mut h);
|
||||
}
|
||||
@@ -456,6 +458,15 @@ impl EffectcraftApp {
|
||||
h.finish() | 1
|
||||
}
|
||||
|
||||
/// The comp-space region viewer frames of `comp` cover: the region of interest, else the
|
||||
/// Extended Viewer's area (frame plus pasteboard), else `None` (the whole frame).
|
||||
pub fn viewer_region(&self, comp: ItemId) -> Option<[f64; 4]> {
|
||||
if self.session.active_comp_id() != Some(comp) {
|
||||
return None;
|
||||
}
|
||||
self.session.state.region_of_interest.or(self.ui.viewer.extended)
|
||||
}
|
||||
|
||||
/// Request a prefetch frame render (no-op if cached/in flight).
|
||||
pub fn request_frame(&self, comp: ItemId, frame: i64, scale: f64) {
|
||||
self.request_frame_with(comp, frame, scale, false);
|
||||
@@ -469,7 +480,7 @@ impl EffectcraftApp {
|
||||
/// Render options of viewer frames of `comp` at `scale`.
|
||||
pub fn frame_opts(&self, comp: ItemId, scale: f64) -> RenderOpts {
|
||||
let (draft, _) = self.session.state.viewer.fast_previews.render(self.ui.viewer.interacting);
|
||||
let roi = self.session.state.region_of_interest.filter(|_| self.session.active_comp_id() == Some(comp));
|
||||
let roi = self.viewer_region(comp);
|
||||
RenderOpts {
|
||||
scale,
|
||||
motion_blur: true,
|
||||
@@ -848,6 +859,7 @@ impl EffectcraftApp {
|
||||
panels::dialogs::show(self, &ctx);
|
||||
panels::scriptui_view::sync_panels(self);
|
||||
panels::scriptui_view::show_windows(self, &ctx);
|
||||
panels::learn::coach(self, &ctx);
|
||||
self.draw_toast(ui, full);
|
||||
}
|
||||
|
||||
|
||||
@@ -173,7 +173,25 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
crate::header::paint_logo(&p, Rect::from_min_size(pos2(x0, y), vec2(40.0, 40.0)));
|
||||
p.text(pos2(x0 + 52.0, y + 12.0), Align2::LEFT_CENTER, "EffectCraft", Tokens::semibold(22.0), Color32::WHITE);
|
||||
p.text(pos2(x0 + 52.0, y + 32.0), Align2::LEFT_CENTER, format!("Version {}", env!("CARGO_PKG_VERSION")), Tokens::ui(11.0), t.text_faint);
|
||||
y += 64.0;
|
||||
y += 56.0;
|
||||
// Home / Learn tabs.
|
||||
for (k, (label, learn)) in [("Home", false), ("Learn", true)].into_iter().enumerate() {
|
||||
let r = Rect::from_min_size(pos2(x0 + k as f32 * 84.0, y), vec2(78.0, 28.0));
|
||||
let resp = ui.interact(r, egui::Id::new(("home-tab", label)), Sense::click());
|
||||
let on = app.ui.home_learn == learn;
|
||||
if on || resp.hovered() {
|
||||
p.rect_filled(r, 6.0, if on { Color32::from_rgb(0x2e, 0x31, 0x3b) } else { t.hover });
|
||||
}
|
||||
p.text(r.center(), Align2::CENTER_CENTER, label, Tokens::medium(13.0), if on { Color32::WHITE } else { t.text_dim });
|
||||
if on {
|
||||
p.line_segment([pos2(r.min.x + 12.0, r.max.y - 1.0), pos2(r.max.x - 12.0, r.max.y - 1.0)], Stroke::new(2.0, t.accent));
|
||||
}
|
||||
app.auto.add(&format!("home.tab.{}", label.to_ascii_lowercase()), r, label);
|
||||
if resp.clicked() {
|
||||
app.ui.home_learn = learn;
|
||||
}
|
||||
}
|
||||
y += 40.0;
|
||||
for (label, id, primary) in [
|
||||
("New Project", "file.newProject", true),
|
||||
("Open Project…", "file.open", false),
|
||||
@@ -239,13 +257,18 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
}
|
||||
let community_bottom = cy + sib.len().div_ceil(per_row) as f32 * 28.0;
|
||||
|
||||
// ---- recent projects.
|
||||
// ---- recent projects (or the Learn tab's tutorials).
|
||||
let (rx, mut ry, rw) = if wide {
|
||||
let rx = x0 + left_w + 40.0;
|
||||
(rx, rect.min.y + pad + 6.0, rect.max.x - pad - rx)
|
||||
} else {
|
||||
(x0, community_bottom + 24.0, left_w)
|
||||
};
|
||||
if app.ui.home_learn {
|
||||
super::learn::home_tab(app, ui, Rect::from_min_max(pos2(rx, ry), pos2(rx + rw, rect.max.y - 8.0)));
|
||||
run_actions(app, &ctx, actions);
|
||||
return;
|
||||
}
|
||||
p.text(pos2(rx, ry + 6.0), Align2::LEFT_CENTER, "Recent", Tokens::semibold(16.0), Color32::WHITE);
|
||||
let entries = recent_entries(&app.session.prefs);
|
||||
if !entries.is_empty() {
|
||||
@@ -304,9 +327,13 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
ry += row_h;
|
||||
}
|
||||
|
||||
run_actions(app, &ctx, actions);
|
||||
}
|
||||
|
||||
fn run_actions(app: &mut EffectcraftApp, ctx: &egui::Context, actions: Vec<(&str, serde_json::Value)>) {
|
||||
for (id, params) in actions {
|
||||
let before = (app.session.path.clone(), app.session.revision);
|
||||
match crate::menus::invoke(app, &ctx, id, params) {
|
||||
match crate::menus::invoke(app, ctx, id, params) {
|
||||
Err(e) => app.ui.status = e,
|
||||
// Leave Home unless only the list changed or a file dialog was cancelled.
|
||||
Ok(_) => {
|
||||
@@ -382,8 +409,46 @@ mod tests {
|
||||
"home.help.discord",
|
||||
"home.help.github",
|
||||
"home.recent.0",
|
||||
"home.tab.home",
|
||||
"home.tab.learn",
|
||||
] {
|
||||
assert!(app.auto.find(id).is_some(), "{id}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn learn_tab_lists_and_starts_tutorials() {
|
||||
let mut app = EffectcraftApp::new(effectcraft_engine::Session::default());
|
||||
app.ui.start_screen = true;
|
||||
app.ui.home_learn = true;
|
||||
let ctx = egui::Context::default();
|
||||
crate::theme::install(&ctx, &app.tokens);
|
||||
let frame = |app: &mut EffectcraftApp| {
|
||||
ctx.run_ui(Default::default(), |ui| {
|
||||
app.auto.begin_frame();
|
||||
show(app, ui, Rect::from_min_size(pos2(0.0, 0.0), vec2(1200.0, 800.0)));
|
||||
crate::panels::learn::coach(app, ui.ctx());
|
||||
})
|
||||
.textures_delta
|
||||
.clear();
|
||||
};
|
||||
frame(&mut app);
|
||||
frame(&mut app);
|
||||
for t in effectcraft_engine::learn::tutorials() {
|
||||
assert!(app.auto.find(&format!("home.learn.{}.start", t.id)).is_some(), "{}", t.id);
|
||||
}
|
||||
assert!(app.auto.find("home.recent.0").is_none());
|
||||
// Start through the session (as the Start button does); the coach card appears.
|
||||
app.session.execute("learn.start", json!({"id": "animate-title"})).unwrap();
|
||||
app.ui.start_screen = false;
|
||||
frame(&mut app);
|
||||
frame(&mut app);
|
||||
for id in ["learn.coach", "learn.showMe", "learn.next", "learn.close"] {
|
||||
assert!(app.auto.find(id).is_some(), "{id}");
|
||||
}
|
||||
// Show me performs the step and the coach moves on.
|
||||
app.session.execute("learn.step", json!({"action": "showMe"})).unwrap();
|
||||
assert_eq!(app.session.learn.as_ref().unwrap().step, 1);
|
||||
assert!(app.session.active_comp().is_some());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,199 @@
|
||||
//! Learn: the Home screen's tutorial list and the coach card that walks through a running
|
||||
//! tutorial (engine model in `effectcraft_engine::learn`). The coach highlights the step's target
|
||||
//! (an automation id) and moves on when the user performs the step's command; "Show me" runs it.
|
||||
|
||||
use egui::{Align2, Color32, Rect, Sense, Stroke, StrokeKind, pos2, vec2};
|
||||
use serde_json::json;
|
||||
|
||||
use crate::theme::Tokens;
|
||||
use crate::{EffectcraftApp, widgets};
|
||||
|
||||
/// The Learn tab of the Home screen: one card per tutorial with its steps and a Start button.
|
||||
pub fn home_tab(app: &mut EffectcraftApp, ui: &mut egui::Ui, area: Rect) {
|
||||
let t = app.tokens;
|
||||
let p = ui.painter().with_clip_rect(area);
|
||||
let (x, mut y, w) = (area.min.x, area.min.y, area.width());
|
||||
p.text(pos2(x, y + 6.0), Align2::LEFT_CENTER, "Learn", Tokens::semibold(16.0), Color32::WHITE);
|
||||
p.text(
|
||||
pos2(x, y + 26.0),
|
||||
Align2::LEFT_CENTER,
|
||||
"Hands-on tutorials that run inside EffectCraft. Do each step yourself, or press Show me.",
|
||||
Tokens::ui(11.5),
|
||||
t.text_faint,
|
||||
);
|
||||
y += 44.0;
|
||||
let tutorials = effectcraft_engine::learn::tutorials();
|
||||
let running = app.session.learn.as_ref().map(|l| l.tutorial.clone());
|
||||
let card_h = 128.0;
|
||||
for tut in &tutorials {
|
||||
let r = Rect::from_min_size(pos2(x, y), vec2(w, card_h - 10.0));
|
||||
if r.min.y > area.max.y {
|
||||
break;
|
||||
}
|
||||
let resp = ui.interact(r, egui::Id::new(("learn-card", &tut.id)), Sense::click());
|
||||
p.rect_filled(r, 8.0, if resp.hovered() { Color32::from_rgb(0x2c, 0x2e, 0x37) } else { Color32::from_rgb(0x24, 0x26, 0x2e) });
|
||||
// A small original badge: the step count in a circle.
|
||||
let badge = Rect::from_min_size(pos2(r.min.x + 16.0, r.min.y + 16.0), vec2(44.0, 44.0));
|
||||
p.circle_filled(badge.center(), 22.0, t.accent.gamma_multiply(0.25));
|
||||
p.circle_stroke(badge.center(), 22.0, Stroke::new(1.5, t.accent));
|
||||
p.text(badge.center() - vec2(0.0, 5.0), Align2::CENTER_CENTER, tut.steps.len().to_string(), Tokens::semibold(15.0), Color32::WHITE);
|
||||
p.text(badge.center() + vec2(0.0, 10.0), Align2::CENTER_CENTER, "steps", Tokens::ui(9.0), t.text_dim);
|
||||
let tx = badge.max.x + 16.0;
|
||||
p.text(pos2(tx, r.min.y + 22.0), Align2::LEFT_CENTER, &tut.title, Tokens::semibold(14.0), Color32::WHITE);
|
||||
p.text(pos2(tx, r.min.y + 40.0), Align2::LEFT_CENTER, format!("{} min", tut.minutes), Tokens::ui(11.0), t.text_faint);
|
||||
let text_w = (r.max.x - tx - 120.0).max(120.0);
|
||||
let g = p.layout(tut.summary.clone(), Tokens::ui(12.0), t.text_dim, text_w);
|
||||
p.galley(pos2(tx, r.min.y + 52.0), g, t.text_dim);
|
||||
let steps: Vec<String> = tut.steps.iter().map(|s| s.title.clone()).collect();
|
||||
let g = p.layout(steps.join(" · "), Tokens::ui(10.5), t.text_faint, text_w);
|
||||
p.galley(pos2(tx, r.min.y + 84.0), g, t.text_faint);
|
||||
let br = Rect::from_min_size(pos2(r.max.x - 104.0, r.min.y + 16.0), vec2(88.0, 28.0));
|
||||
let label = if running.as_deref() == Some(tut.id.as_str()) { "Resume" } else { "Start" };
|
||||
let clicked = widgets::text_button(ui, br, label, true, &t, egui::Id::new(("learn-start", &tut.id))).clicked();
|
||||
app.auto.add(&format!("home.learn.{}", tut.id), r, &tut.title);
|
||||
app.auto.add(&format!("home.learn.{}.start", tut.id), br, label);
|
||||
if clicked || resp.clicked() {
|
||||
if running.as_deref() != Some(tut.id.as_str())
|
||||
&& let Err(e) = app.session.execute("learn.start", json!({"id": tut.id}))
|
||||
{
|
||||
app.ui.status = e.to_string();
|
||||
}
|
||||
app.ui.start_screen = false;
|
||||
}
|
||||
y += card_h;
|
||||
}
|
||||
}
|
||||
|
||||
/// The automation element a step's target pattern points at (last frame's registry).
|
||||
fn target_rect(app: &EffectcraftApp, pattern: &str) -> Option<Rect> {
|
||||
let lid = app.session.state.selected_layers.first().map(|l| l.0);
|
||||
let pat = effectcraft_engine::learn::resolve_target(pattern, lid);
|
||||
app.auto
|
||||
.previous
|
||||
.iter()
|
||||
.find(|e| effectcraft_engine::learn::target_matches(&pat, &e.id) && e.rect[2] > 0.0 && e.rect[3] > 0.0)
|
||||
.map(|e| Rect::from_min_size(pos2(e.rect[0], e.rect[1]), vec2(e.rect[2], e.rect[3])))
|
||||
}
|
||||
|
||||
/// The coach card (bottom right) and the highlight around the current step's target.
|
||||
pub fn coach(app: &mut EffectcraftApp, ctx: &egui::Context) {
|
||||
let Some((tut, i)) = app.session.learn_current() else { return };
|
||||
let t = app.tokens;
|
||||
let n = tut.steps.len();
|
||||
let screen = ctx.content_rect();
|
||||
let step = tut.steps.get(i).cloned();
|
||||
// Highlight the target (pulsing outline over everything but the card).
|
||||
if app.ui.start_screen {
|
||||
// The Home screen covers the panels: just the card.
|
||||
} else if let Some(st) = &step
|
||||
&& let Some(tp) = &st.target
|
||||
&& let Some(r) = target_rect(app, tp)
|
||||
{
|
||||
let time = ctx.input(|i| i.time);
|
||||
let pulse = (0.5 + 0.5 * (time * 4.0).sin()) as f32;
|
||||
let p = ctx.layer_painter(egui::LayerId::new(egui::Order::Foreground, egui::Id::new("learn-highlight")));
|
||||
let hr = r.expand(3.0 + 2.0 * pulse);
|
||||
p.rect_stroke(hr, 5.0, Stroke::new(2.0, t.accent.gamma_multiply(0.6 + 0.4 * pulse)), StrokeKind::Outside);
|
||||
app.auto.add("learn.highlight", hr, tp);
|
||||
ctx.request_repaint_after(std::time::Duration::from_millis(33));
|
||||
}
|
||||
let w = 340.0;
|
||||
let mut action: Option<&str> = None;
|
||||
let area = egui::Area::new(egui::Id::new("learn-coach"))
|
||||
.order(egui::Order::Foreground)
|
||||
.fixed_pos(pos2(screen.max.x - w - 20.0, screen.max.y - 250.0))
|
||||
.show(ctx, |ui| {
|
||||
egui::Frame::new()
|
||||
.fill(Color32::from_rgb(0x26, 0x28, 0x30))
|
||||
.stroke(Stroke::new(1.0, t.accent.gamma_multiply(0.7)))
|
||||
.corner_radius(8.0)
|
||||
.inner_margin(egui::Margin::same(14))
|
||||
.shadow(egui::epaint::Shadow { offset: [0, 4], blur: 16, spread: 0, color: Color32::from_black_alpha(140) })
|
||||
.show(ui, |ui| {
|
||||
ui.set_width(w - 28.0);
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(egui::RichText::new("LEARN").font(Tokens::semibold(10.0)).color(t.accent));
|
||||
ui.label(egui::RichText::new(&tut.title).font(Tokens::ui(11.0)).color(t.text_dim));
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
let (cr, r) = ui.allocate_exact_size(vec2(16.0, 16.0), Sense::click());
|
||||
let r = r.on_hover_text("Close tutorial");
|
||||
crate::icons::paint(ui.painter(), cr, crate::icons::Icon::Close, if r.hovered() { Color32::WHITE } else { t.text_dim });
|
||||
app.auto.add("learn.close", r.rect, "Close tutorial");
|
||||
if r.clicked() {
|
||||
action = Some("close");
|
||||
}
|
||||
});
|
||||
});
|
||||
// Progress dots.
|
||||
let (dr, _) = ui.allocate_exact_size(vec2(w - 28.0, 10.0), Sense::hover());
|
||||
for k in 0..n {
|
||||
let c = pos2(dr.min.x + 4.0 + k as f32 * 12.0, dr.center().y);
|
||||
let col = if k < i {
|
||||
t.accent
|
||||
} else if k == i {
|
||||
Color32::WHITE
|
||||
} else {
|
||||
Color32::from_gray(80)
|
||||
};
|
||||
ui.painter().circle_filled(c, 3.0, col);
|
||||
}
|
||||
ui.add_space(4.0);
|
||||
match &step {
|
||||
Some(st) => {
|
||||
ui.label(egui::RichText::new(format!("Step {} of {n}: {}", i + 1, st.title)).font(Tokens::semibold(13.0)).color(Color32::WHITE));
|
||||
ui.add_space(2.0);
|
||||
ui.label(egui::RichText::new(&st.text).font(Tokens::ui(12.0)).color(t.text));
|
||||
}
|
||||
None => {
|
||||
ui.label(egui::RichText::new("Tutorial complete").font(Tokens::semibold(13.0)).color(Color32::WHITE));
|
||||
ui.label(
|
||||
egui::RichText::new("Nice work. Pick another tutorial on the Home screen's Learn tab.").font(Tokens::ui(12.0)).color(t.text),
|
||||
);
|
||||
}
|
||||
}
|
||||
ui.add_space(8.0);
|
||||
ui.horizontal(|ui| {
|
||||
let back = ui.add_enabled(i > 0, egui::Button::new("Back"));
|
||||
app.auto.add("learn.back", back.rect, "Back");
|
||||
if back.clicked() {
|
||||
action = Some("back");
|
||||
}
|
||||
if step.is_some() {
|
||||
let show = ui.add(egui::Button::new("Show me"));
|
||||
app.auto.add("learn.showMe", show.rect, "Show me");
|
||||
if show.clicked() {
|
||||
action = Some("showMe");
|
||||
}
|
||||
let next = ui.add(egui::Button::new("Next"));
|
||||
app.auto.add("learn.next", next.rect, "Next");
|
||||
if next.clicked() {
|
||||
action = Some("next");
|
||||
}
|
||||
} else {
|
||||
let more = ui.add(egui::Button::new("More tutorials"));
|
||||
app.auto.add("learn.more", more.rect, "More tutorials");
|
||||
if more.clicked() {
|
||||
action = Some("more");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
app.auto.add("learn.coach", area.response.rect, &tut.title);
|
||||
match action {
|
||||
Some("close") => {
|
||||
let _ = app.session.execute("learn.stop", json!({}));
|
||||
}
|
||||
Some("more") => {
|
||||
let _ = app.session.execute("learn.stop", json!({}));
|
||||
app.ui.home_learn = true;
|
||||
app.ui.start_screen = true;
|
||||
}
|
||||
Some(a) => {
|
||||
if let Err(e) = app.session.execute("learn.step", json!({"action": a})) {
|
||||
app.ui.status = e.to_string();
|
||||
}
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ pub mod info;
|
||||
pub mod key_dialogs;
|
||||
pub mod layer_panel;
|
||||
pub mod layer_styles_dialog;
|
||||
pub mod learn;
|
||||
pub mod markers_ui;
|
||||
pub mod media_panels;
|
||||
pub mod misc;
|
||||
|
||||
@@ -14,6 +14,9 @@ use crate::panels::DragPayload;
|
||||
use crate::theme::Tokens;
|
||||
use crate::{EffectcraftApp, widgets};
|
||||
|
||||
/// Item row height (After Effects' Project panel rows are compact, about 19 pt).
|
||||
const ROW_H: f32 = 19.0;
|
||||
|
||||
fn item_icon(it: &Item) -> Icon {
|
||||
match &it.kind {
|
||||
ItemKind::Folder => Icon::Folder,
|
||||
@@ -323,8 +326,8 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
let mut actions: Vec<(String, serde_json::Value)> = vec![];
|
||||
for (i, (id, depth)) in rows.iter().enumerate() {
|
||||
let Some(it) = app.session.project.item(*id).cloned() else { continue };
|
||||
let r = Rect::from_min_size(pos2(list.min.x, y), vec2(list.width(), 22.0));
|
||||
y += 22.0;
|
||||
let r = Rect::from_min_size(pos2(list.min.x, y), vec2(list.width(), ROW_H));
|
||||
y += ROW_H;
|
||||
if r.min.y > list.max.y {
|
||||
break;
|
||||
}
|
||||
@@ -335,14 +338,10 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
lp.rect_filled(
|
||||
r,
|
||||
0.0,
|
||||
if selected {
|
||||
t.row_selected
|
||||
} else if i % 2 == 0 {
|
||||
t.row
|
||||
} else {
|
||||
t.row_alt
|
||||
},
|
||||
// Flat rows like After Effects' Project panel (no stripes).
|
||||
if selected { t.row_selected } else { t.row },
|
||||
);
|
||||
let _ = i;
|
||||
let x0 = r.min.x + 8.0 + 14.0 * *depth as f32;
|
||||
if it.is_folder() {
|
||||
let open = app.ui.project_open_folders.contains(&id.0);
|
||||
@@ -400,12 +399,18 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
true
|
||||
};
|
||||
if !cell_edit(app, ui, &mut actions, "name", name_rect) {
|
||||
// The selected item's name sits in a light cell with dark text.
|
||||
if selected {
|
||||
let g = lp.layout_no_wrap(it.name.clone(), Tokens::ui(12.0), Color32::BLACK);
|
||||
let cell = Rect::from_min_max(pos2(x0 + 27.0, r.min.y + 1.0), pos2((x0 + 33.0 + g.size().x).min(name_clip.max.x), r.max.y - 1.0));
|
||||
lp.with_clip_rect(name_clip.expand2(vec2(3.0, 0.0))).rect_filled(cell, 0.0, Color32::from_rgb(0xa6, 0xa6, 0xa6));
|
||||
}
|
||||
lp.with_clip_rect(name_clip).text(
|
||||
pos2(x0 + 30.0, r.center().y),
|
||||
Align2::LEFT_CENTER,
|
||||
&it.name,
|
||||
Tokens::ui(12.0),
|
||||
if selected { Color32::WHITE } else { t.text },
|
||||
if selected { Color32::from_gray(0x16) } else { t.text },
|
||||
);
|
||||
}
|
||||
// Label swatch: click for the label colour menu.
|
||||
|
||||
@@ -47,6 +47,22 @@ enum RowKind {
|
||||
/// Synthetic group uid for a layer's Audio > Waveform twirl (never a real property uid).
|
||||
const WAVE_BIT: u64 = 1 << 60;
|
||||
|
||||
/// Time navigator's visible-span bar and the work area bar.
|
||||
const NAV_BAR: Color32 = Color32::from_rgb(0x55, 0x55, 0x55);
|
||||
const WORK_AREA_BAR: Color32 = Color32::from_rgb(0x5c, 0x5c, 0x5c);
|
||||
/// Fill of the timeline's switch / A/V boxes (dark wells, as in After Effects).
|
||||
const SWITCH_BOX: Color32 = Color32::from_rgb(0x19, 0x19, 0x19);
|
||||
/// Background of the selected layer's name cell.
|
||||
const SELECTED_NAME_BG: Color32 = Color32::from_rgb(0xa6, 0xa6, 0xa6);
|
||||
|
||||
/// A layer bar's fill: the label colour muted toward grey (a little brighter when selected).
|
||||
pub(crate) fn bar_color(label: Color32, selected: bool) -> Color32 {
|
||||
let k = if selected { 0.62 } else { 0.45 };
|
||||
let g = 0x3a as f32;
|
||||
let mix = |c: u8| (c as f32 * k + g * (1.0 - k)).round() as u8;
|
||||
Color32::from_rgb(mix(label.r()), mix(label.g()), mix(label.b()))
|
||||
}
|
||||
|
||||
/// Row height (expression editors grow with their text).
|
||||
fn row_height(row: &Row, rh: f32) -> f32 {
|
||||
match row.kind {
|
||||
@@ -756,7 +772,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
let tc = crate::panels::timecode(&app.session, &comp, time);
|
||||
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(20.0), t.timecode);
|
||||
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);
|
||||
app.auto.add("timeline.timecode", tc_rect, &tc);
|
||||
@@ -770,7 +786,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
}
|
||||
if let Some(mut buf) = ctx.data(|d| d.get_temp::<String>(egui::Id::new("tl-tc-edit"))) {
|
||||
let mut child = ui.new_child(egui::UiBuilder::new().max_rect(tc_rect));
|
||||
let r = child.add(egui::TextEdit::singleline(&mut buf).font(Tokens::semibold(18.0)).desired_width(150.0));
|
||||
let r = child.add(egui::TextEdit::singleline(&mut buf).font(Tokens::semibold(16.0)).desired_width(150.0));
|
||||
r.request_focus();
|
||||
if r.lost_focus() {
|
||||
let _ = app.session.execute("time.set", json!({"timecode": buf}));
|
||||
@@ -810,14 +826,18 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
|
||||
// ---- ruler (right).
|
||||
let ruler = Rect::from_min_max(pos2(graph_x0, top + header_h - ruler_h), pos2(rect.max.x, top + header_h));
|
||||
let nav = Rect::from_min_max(pos2(graph_x0 + 6.0, top + 6.0), pos2(graph_x1, top + 12.0));
|
||||
// Time navigator.
|
||||
p.rect_filled(nav, 3.0, t.field_bg);
|
||||
let nav = Rect::from_min_max(pos2(graph_x0 + 6.0, top + 6.0), pos2(graph_x1, top + 14.0));
|
||||
// Time navigator: the visible span as a grey bar with blue end handles (as in After
|
||||
// Effects), over a dark track.
|
||||
p.rect_filled(nav, 1.0, t.field_bg);
|
||||
let vis0 = (tm.start / comp.duration.seconds()) as f32;
|
||||
let vis1 = (tm.t(graph_x1) / comp.duration.seconds()) as f32;
|
||||
let nav_vis =
|
||||
Rect::from_min_max(pos2(nav.min.x + nav.width() * vis0.clamp(0.0, 1.0), nav.min.y), pos2(nav.min.x + nav.width() * vis1.clamp(0.0, 1.0), nav.max.y));
|
||||
p.rect_filled(nav_vis, 3.0, t.work_area);
|
||||
p.rect_filled(nav_vis, 0.0, NAV_BAR);
|
||||
for x in [nav_vis.min.x, nav_vis.max.x] {
|
||||
p.rect_filled(Rect::from_min_max(pos2(x - 3.0, nav.min.y - 1.0), pos2(x + 3.0, nav.max.y + 1.0)), 3.0, t.accent);
|
||||
}
|
||||
let nresp = ui.interact(nav, egui::Id::new("tl-nav"), Sense::drag());
|
||||
if nresp.dragged() {
|
||||
let d = nresp.drag_delta().x as f64 / nav.width() as f64 * comp.duration.seconds();
|
||||
@@ -828,12 +848,19 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
}
|
||||
p.rect_filled(ruler, 0.0, t.tl_ruler_bg);
|
||||
app.auto.add("timeline.ruler", ruler, &format!("{},{}", tm.start, tm.pps));
|
||||
// Work area bar.
|
||||
let wa = Rect::from_min_max(pos2(tm.x(comp.work_area.0.seconds()), ruler.min.y + 2.0), pos2(tm.x(comp.work_area.1.seconds()), ruler.min.y + 10.0));
|
||||
p.rect_filled(wa, 2.0, t.work_area);
|
||||
// Work area bar: below the ruler, beside the column headers (After Effects' layout), with
|
||||
// blue begin / end handles; the cache bar runs under it.
|
||||
let wa_row = Rect::from_min_max(pos2(graph_x0, top + header_h), pos2(rect.max.x, top + header_h + colhdr_h));
|
||||
let wa = Rect::from_min_max(pos2(tm.x(comp.work_area.0.seconds()), wa_row.min.y + 3.0), pos2(tm.x(comp.work_area.1.seconds()), wa_row.max.y - 6.0));
|
||||
p.with_clip_rect(wa_row).rect_filled(wa, 0.0, WORK_AREA_BAR);
|
||||
for (hx, set) in [(wa.min.x, "begin"), (wa.max.x, "end")] {
|
||||
let hr = Rect::from_center_size(pos2(hx, wa.center().y), vec2(8.0, 12.0));
|
||||
p.rect_filled(Rect::from_center_size(pos2(hx, wa.center().y), vec2(3.0, 10.0)), 1.0, t.text_dim);
|
||||
let hr = Rect::from_center_size(pos2(hx, wa.center().y), vec2(8.0, 14.0));
|
||||
let handle = if set == "begin" {
|
||||
Rect::from_min_max(pos2(hx - 1.0, wa.min.y), pos2(hx + 4.0, wa.max.y))
|
||||
} else {
|
||||
Rect::from_min_max(pos2(hx - 4.0, wa.min.y), pos2(hx + 1.0, wa.max.y))
|
||||
};
|
||||
p.rect_filled(handle, 2.0, t.accent);
|
||||
let resp = ui.interact(hr, egui::Id::new(("wa", set)), Sense::drag());
|
||||
app.auto.add(&format!("timeline.workArea.{set}"), hr, set);
|
||||
if resp.dragged()
|
||||
@@ -848,7 +875,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
let scale_key = app.viewer_shown.as_ref().map(|(_, k)| k.scale).unwrap_or(1000);
|
||||
let cached = app.frames.cached_frames(app.session.revision, cid.0, scale_key);
|
||||
let fd = comp.frame_duration().seconds();
|
||||
let cy0 = ruler.min.y + 11.0;
|
||||
let cy0 = wa_row.max.y - 4.0;
|
||||
let mut run: Option<(i64, i64)> = None;
|
||||
let draw_run = |a: i64, b: i64| {
|
||||
let x0 = tm.x(a as f64 * fd);
|
||||
@@ -1100,19 +1127,13 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
let cy = r.min.y + rh / 2.0;
|
||||
match &row.kind {
|
||||
RowKind::Layer => {
|
||||
lp.rect_filled(
|
||||
left,
|
||||
0.0,
|
||||
if is_sel {
|
||||
t.row_selected
|
||||
} else if ri % 2 == 0 {
|
||||
t.row
|
||||
} else {
|
||||
t.row_alt
|
||||
},
|
||||
);
|
||||
gp.rect_filled(Rect::from_min_max(pos2(graph_x0, r.min.y), r.max), 0.0, if is_sel { Color32::from_rgb(0x26, 0x26, 0x26) } else { t.tl_bg });
|
||||
lp.line_segment([pos2(rect.min.x, r.max.y), pos2(graph_x0, r.max.y)], Stroke::new(1.0, Color32::from_black_alpha(80)));
|
||||
// After Effects draws layer rows as one flat tone separated by dark hairlines
|
||||
// (outline and time graph alike), not as alternating stripes.
|
||||
let _ = ri;
|
||||
lp.rect_filled(left, 0.0, if is_sel { t.row_selected } else { t.row_alt });
|
||||
gp.rect_filled(Rect::from_min_max(pos2(graph_x0, r.min.y), r.max), 0.0, if is_sel { Color32::from_rgb(0x2a, 0x2a, 0x2a) } else { t.tl_bg });
|
||||
lp.line_segment([pos2(rect.min.x, r.max.y - 0.5), pos2(graph_x0, r.max.y - 0.5)], Stroke::new(1.0, t.app_bg));
|
||||
gp.line_segment([pos2(graph_x0, r.max.y - 0.5), pos2(r.max.x, r.max.y - 0.5)], Stroke::new(1.0, t.app_bg));
|
||||
// A/V features.
|
||||
let sw = &layer.switches;
|
||||
let av_items: [(Icon, bool, &str, bool); 4] = [
|
||||
@@ -1122,11 +1143,11 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
(Icon::Lock, sw.locked, "lock", true),
|
||||
];
|
||||
for (i, (icon, on, name, applicable)) in av_items.into_iter().enumerate() {
|
||||
let br = Rect::from_center_size(pos2(cw.av + 10.0 + 18.0 * i as f32, cy), vec2(17.0, 17.0));
|
||||
let br = Rect::from_center_size(pos2(cw.av + 10.0 + 18.0 * i as f32, cy), vec2(15.0, 15.0));
|
||||
if !applicable || !vis.av {
|
||||
continue;
|
||||
}
|
||||
lp.rect_stroke(br.shrink(1.5), 2.0, Stroke::new(1.0, t.separator), StrokeKind::Inside);
|
||||
lp.rect_filled(br.shrink(0.5), 1.0, SWITCH_BOX);
|
||||
let resp = widgets::icon_toggle(ui, br, icon, on, &t, egui::Id::new(("av", layer.id.0, i)), None);
|
||||
app.auto.add(&format!("timeline.layer.{}.{name}", layer.id.0), br, name);
|
||||
if resp.clicked() {
|
||||
@@ -1176,7 +1197,16 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
ctx.data_mut(|d| d.insert_temp(rename_id, (rl, buf)));
|
||||
}
|
||||
} else {
|
||||
let name_col = if is_sel { Color32::WHITE } else { t.text };
|
||||
// The selected layer's name sits in a light cell with dark text.
|
||||
let name_col = if is_sel { Color32::from_gray(0x16) } else { t.text };
|
||||
if is_sel {
|
||||
let g = lp.layout_no_wrap(display_name(app, layer), Tokens::ui(12.0), name_col);
|
||||
let cell = Rect::from_min_max(
|
||||
pos2(name_rect.min.x - 3.0, r.min.y + 1.0),
|
||||
pos2((name_rect.min.x + g.size().x + 4.0).max(cw.name_end - 4.0).min(cw.name_end - 2.0), r.max.y - 1.0),
|
||||
);
|
||||
lp.rect_filled(cell, 0.0, SELECTED_NAME_BG);
|
||||
}
|
||||
let lpn = lp.with_clip_rect(name_rect.intersect(lp.clip_rect()));
|
||||
lpn.text(pos2(name_rect.min.x, cy), Align2::LEFT_CENTER, display_name(app, layer), Tokens::ui(12.0), name_col);
|
||||
}
|
||||
@@ -1223,7 +1253,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
continue;
|
||||
}
|
||||
let br = Rect::from_center_size(pos2(cw.switches + SW * i as f32 + SW / 2.0, cy), vec2(16.0, 16.0));
|
||||
lp.rect_stroke(br.shrink(1.5), 2.0, Stroke::new(1.0, t.separator), StrokeKind::Inside);
|
||||
lp.rect_filled(br.shrink(1.0), 1.0, SWITCH_BOX);
|
||||
let resp = widgets::icon_toggle(ui, br, icon, on, &t, egui::Id::new(("sw", layer.id.0, i)), None);
|
||||
app.auto.add(&format!("timeline.layer.{}.switch.{name}", layer.id.0), br, name);
|
||||
if resp.clicked() {
|
||||
@@ -1321,12 +1351,12 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
if !graph_on {
|
||||
let x_in = tm.x(layer.in_point.seconds());
|
||||
let x_out = tm.x(layer.out_point.seconds());
|
||||
let bar = Rect::from_min_max(pos2(x_in, r.min.y + 3.0), pos2(x_out, r.max.y - 3.0));
|
||||
let bar = Rect::from_min_max(pos2(x_in, r.min.y + 1.0), pos2(x_out, r.max.y - 1.0));
|
||||
let lc = t.label(layer.label);
|
||||
let fill = if is_sel { lc.gamma_multiply(0.85) } else { lc.gamma_multiply(0.55) };
|
||||
gp.rect_filled(bar, 2.0, fill);
|
||||
let fill = bar_color(lc, is_sel);
|
||||
gp.rect_filled(bar, 0.0, fill);
|
||||
if is_sel {
|
||||
gp.rect_stroke(bar, 2.0, Stroke::new(1.0, Color32::from_white_alpha(120)), StrokeKind::Inside);
|
||||
gp.rect_stroke(bar, 0.0, Stroke::new(1.0, Color32::from_white_alpha(90)), StrokeKind::Inside);
|
||||
}
|
||||
// Source extent (e.g. trimmed footage) shown faint.
|
||||
if let LayerSource::Footage { .. } | LayerSource::Comp { .. } = layer.source
|
||||
@@ -1437,7 +1467,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
}
|
||||
if let Some(en) = eye {
|
||||
// Layer style eye switch in the A/V column, like AE.
|
||||
let er = Rect::from_center_size(pos2(cw.av + 10.0, cy), vec2(17.0, 17.0));
|
||||
let er = Rect::from_center_size(pos2(cw.av + 10.0, cy), vec2(15.0, 15.0));
|
||||
lp.rect_stroke(er.shrink(1.5), 2.0, Stroke::new(1.0, t.separator), StrokeKind::Inside);
|
||||
if widgets::icon_toggle(ui, er, Icon::Eye, *en, &t, egui::Id::new(("geye", uid)), None).clicked() {
|
||||
actions.push(("layer.style.toggle".into(), json!({"layer": layer.id.0, "style": uid})));
|
||||
@@ -2610,4 +2640,17 @@ mod tests {
|
||||
let c = snap_candidates(&comp, &build_rows(&app, &comp));
|
||||
assert!(c.contains(&comp.duration.seconds()) && c.contains(&0.0));
|
||||
}
|
||||
|
||||
/// UI fidelity (M13.5): compact After Effects-like rows and muted label-coloured bars.
|
||||
#[test]
|
||||
fn rows_and_bars_follow_after_effects_proportions() {
|
||||
let t = crate::theme::Tokens::for_kind(crate::theme::ThemeKind::Dark);
|
||||
assert_eq!(t.row_h, 19.0);
|
||||
let red = t.label(effectcraft_engine::color::Label::Red);
|
||||
let bar = bar_color(red, false);
|
||||
// Muted: darker and less saturated than the label, still reddish.
|
||||
assert!(bar.r() < red.r() && bar.r() > bar.g() + 30 && bar.g() >= red.g().min(0x3a) - 1);
|
||||
let sel = bar_color(red, true);
|
||||
assert!(sel.r() > bar.r());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -415,11 +415,14 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
let p = ui.painter().clone();
|
||||
VIEW_CAM.with(|c| c.set(app.session.view_camera(cid)));
|
||||
|
||||
// Navigator bar (open comps as breadcrumbs).
|
||||
let nav = Rect::from_min_size(rect.min, vec2(rect.width(), 24.0));
|
||||
// Navigator bar (open comps as breadcrumbs). After Effects shows a single breadcrumb row:
|
||||
// when the Composition Navigator (nested comp flow) is above the viewer, this row is left
|
||||
// out.
|
||||
let nav_h = if super::precomp::has_flow(app) { 0.0 } else { 24.0 };
|
||||
let nav = Rect::from_min_size(rect.min, vec2(rect.width(), nav_h));
|
||||
p.rect_filled(nav, 0.0, t.panel_bg);
|
||||
let mut x = nav.min.x + 10.0;
|
||||
let open = app.session.state.open_comps.clone();
|
||||
let open = if nav_h > 0.0 { app.session.state.open_comps.clone() } else { vec![] };
|
||||
for oc in open {
|
||||
let name = app.session.project.item(oc).map(|i| i.name.clone()).unwrap_or_default();
|
||||
let g = p.layout_no_wrap(name.clone(), Tokens::ui(11.5), t.text);
|
||||
@@ -472,6 +475,9 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
ctx.data_mut(|d| d.insert_temp(map_id(), map));
|
||||
let comp_rect = Rect::from_min_size(origin, vec2(cw * zoom, ch * zoom));
|
||||
let painter = p.with_clip_rect(area);
|
||||
// Settings ▸ 3D ▸ Extended Viewer: custom 3D views (and Draft 3D) render the visible
|
||||
// pasteboard too, so 3D layers reaching past the comp frame stay visible there.
|
||||
app.ui.viewer.extended = extended_region(app, &comp, cid, map);
|
||||
|
||||
// Frame.
|
||||
let ppp = ctx.pixels_per_point();
|
||||
@@ -502,7 +508,13 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
let ectx = EvalCtx { project: &snap_project, comp_id: cid, comp: &comp, time, expr: snap_expr.as_deref(), footage: None };
|
||||
// The frame (or snapshot) through Show Channel and exposure; ROI frames cover the region.
|
||||
vt::draw_frame(app, &ctx, &painter, comp_rect, cid, &ectx);
|
||||
painter.rect_stroke(comp_rect, 0.0, Stroke::new(1.0, Color32::from_black_alpha(160)), StrokeKind::Outside);
|
||||
if app.ui.viewer.extended.is_some() {
|
||||
// The comp frame outlined over the extended render.
|
||||
painter.rect_stroke(comp_rect, 0.0, Stroke::new(1.0, Color32::from_gray(150)), StrokeKind::Outside);
|
||||
app.auto.add("viewer.extendedArea", rect_of(&map, app.ui.viewer.extended), "Extended Viewer area");
|
||||
} else {
|
||||
painter.rect_stroke(comp_rect, 0.0, Stroke::new(1.0, Color32::from_black_alpha(160)), StrokeKind::Outside);
|
||||
}
|
||||
app.auto.add("viewer.comp", comp_rect, &comp_name);
|
||||
app.auto.add("viewer.area", area, "Composition viewer");
|
||||
|
||||
@@ -1691,6 +1703,34 @@ pub(crate) fn hex_rgb(s: &str) -> Option<[u8; 3]> {
|
||||
Some([p(0)?, p(2)?, p(4)?])
|
||||
}
|
||||
|
||||
/// The Extended Viewer's render region for this frame (see [`ViewerState::extended`]):
|
||||
/// Settings ▸ 3D ▸ Extended Viewer on, the comp has 3D layers and the view is a custom 3D view
|
||||
/// (or Draft 3D is on), and part of the visible viewer lies outside the comp frame.
|
||||
///
|
||||
/// [`ViewerState::extended`]: crate::state::ViewerState::extended
|
||||
pub(crate) fn extended_region(
|
||||
app: &EffectcraftApp,
|
||||
comp: &effectcraft_engine::project::Comp,
|
||||
cid: effectcraft_engine::project::ItemId,
|
||||
map: ViewerMap,
|
||||
) -> Option<[f64; 4]> {
|
||||
if !app.session.prefs.three_d.extended_viewer || !comp.has_3d() || app.session.state.region_of_interest.is_some() {
|
||||
return None;
|
||||
}
|
||||
let view = app.session.state.views3d.get(&cid).map(|v| v.current).unwrap_or_default();
|
||||
if view == View3D::ActiveCamera && !comp.draft_3d {
|
||||
return None;
|
||||
}
|
||||
let a = map.to_comp(map.area.min);
|
||||
let b = map.to_comp(map.area.max);
|
||||
effectcraft_engine::render::extended_region(comp.width, comp.height, [a[0], a[1], b[0], b[1]], 1.0)
|
||||
}
|
||||
|
||||
fn rect_of(map: &ViewerMap, r: Option<[f64; 4]>) -> Rect {
|
||||
let [x, y, w, h] = r.unwrap_or_default();
|
||||
Rect::from_min_max(map.to_screen([x, y]), map.to_screen([x + w, y + h]))
|
||||
}
|
||||
|
||||
/// Put a rendered frame on screen: CPU pixels go into an egui texture; GPU frames are drawn
|
||||
/// straight from their wgpu texture (registered with egui-wgpu, no readback).
|
||||
fn show_frame(app: &mut EffectcraftApp, ctx: &egui::Context, key: crate::frames::FrameKey, img: crate::frames::FrameImage) {
|
||||
@@ -1709,7 +1749,7 @@ fn show_frame(app: &mut EffectcraftApp, ctx: &egui::Context, key: crate::frames:
|
||||
}
|
||||
app.viewer_shown = app.viewer_tex.as_ref().map(|(t, k)| (t.id(), *k));
|
||||
app.viewer_image = Some(img);
|
||||
vt::set_texture_roi(ctx, app.session.state.region_of_interest);
|
||||
vt::set_texture_roi(ctx, app.session.state.region_of_interest.or(app.ui.viewer.extended));
|
||||
}
|
||||
FrameImage::Gpu(f) => {
|
||||
let Some(rs) = &app.wgpu else { return };
|
||||
|
||||
@@ -694,7 +694,13 @@ pub(crate) fn bottom_bar(app: &mut EffectcraftApp, ui: &mut egui::Ui, bar: Rect,
|
||||
if let Some(i) = popup(app, ui, "vw-cam-pop", r, &items, "view3dItem") {
|
||||
let _ = app.session.execute("view.set3DView", json!({"view": View3D::ALL[i].id()}));
|
||||
}
|
||||
x = r.max.x + 6.0;
|
||||
x = r.max.x + 4.0;
|
||||
// Extended Viewer (Settings ▸ 3D): custom views and Draft 3D show past the comp frame.
|
||||
let on = app.session.prefs.three_d.extended_viewer;
|
||||
if tog(ui, &mut app.auto, &mut x, Icon::ExtendedViewer, on, "extendedViewer", "Extended Viewer").0 {
|
||||
let _ = app.session.execute("view.extendedViewer", json!({}));
|
||||
}
|
||||
x += 2.0;
|
||||
}
|
||||
// Current time.
|
||||
let tc = crate::panels::timecode(&app.session, comp, time);
|
||||
|
||||
@@ -299,6 +299,10 @@ pub struct ViewerState {
|
||||
/// The pointer is dragging in the viewer this frame (Adaptive Resolution).
|
||||
#[serde(skip)]
|
||||
pub interacting: bool,
|
||||
/// Extended Viewer: the comp-space region the viewer renders this frame (comp frame plus
|
||||
/// the visible pasteboard), set while a 3D view shows past the frame.
|
||||
#[serde(skip)]
|
||||
pub extended: Option<[f64; 4]>,
|
||||
/// View ▸ Panel Background Color (`None` = theme default).
|
||||
pub pasteboard: Option<[u8; 3]>,
|
||||
pub custom_pasteboard: [u8; 3],
|
||||
@@ -326,6 +330,7 @@ impl Default for ViewerState {
|
||||
ruler_origin: [0.0, 0.0],
|
||||
roi_draw: false,
|
||||
interacting: false,
|
||||
extended: None,
|
||||
pasteboard: None,
|
||||
custom_pasteboard: [0x80, 0x80, 0x80],
|
||||
}
|
||||
@@ -592,6 +597,9 @@ pub struct UiState {
|
||||
#[serde(default = "yes")]
|
||||
pub preview_audio: bool,
|
||||
pub start_screen: bool,
|
||||
/// The Home screen shows its Learn tab (tutorials) instead of the recent projects.
|
||||
#[serde(default)]
|
||||
pub home_learn: bool,
|
||||
/// Composition ▸ Preview ▸ Cache Frames When Idle.
|
||||
pub cache_when_idle: bool,
|
||||
/// Tracker panel ▸ Motion Source chosen without a tracker yet (layer id).
|
||||
@@ -661,6 +669,7 @@ impl Default for UiState {
|
||||
preview_cache_first: false,
|
||||
preview_audio: true,
|
||||
start_screen: false,
|
||||
home_learn: false,
|
||||
cache_when_idle: false,
|
||||
tracker_source: None,
|
||||
layer_panel: None,
|
||||
|
||||
@@ -145,7 +145,7 @@ impl Tokens {
|
||||
radius_sm: 3.0,
|
||||
gap: 4.0,
|
||||
tab_h: 30.0,
|
||||
row_h: 22.0,
|
||||
row_h: 19.0,
|
||||
gradients: true,
|
||||
};
|
||||
match kind {
|
||||
|
||||
@@ -87,7 +87,15 @@ pub fn swatch(ui: &mut Ui, rect: Rect, c: [f32; 4], id: egui::Id, t: &Tokens) ->
|
||||
pub fn twirl(ui: &mut Ui, rect: Rect, open: bool, id: egui::Id, t: &Tokens) -> Response {
|
||||
let resp = ui.interact(rect, id, Sense::click());
|
||||
let col = if resp.hovered() { t.tab_text_active } else { t.text_dim };
|
||||
icons::paint(ui.painter(), rect.shrink(rect.width() * 0.22), if open { Icon::ChevronDown } else { Icon::ChevronRight }, col);
|
||||
// An open chevron (> / v), as After Effects draws its twirl-downs.
|
||||
let c = rect.center();
|
||||
let k = rect.width().min(rect.height()) * 0.2;
|
||||
let pts = if open {
|
||||
vec![c + vec2(-1.6 * k, -0.8 * k), c + vec2(0.0, 0.8 * k), c + vec2(1.6 * k, -0.8 * k)]
|
||||
} else {
|
||||
vec![c + vec2(-0.8 * k, -1.6 * k), c + vec2(0.8 * k, 0.0), c + vec2(-0.8 * k, 1.6 * k)]
|
||||
};
|
||||
ui.painter().add(egui::Shape::line(pts, Stroke::new(1.4, col)));
|
||||
resp
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user