Merge main into M13.6
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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" => {
|
||||
|
||||
@@ -36,6 +36,8 @@ pub enum PanelKind {
|
||||
MaskInterpolation,
|
||||
ScriptConsole,
|
||||
EssentialGraphics,
|
||||
/// A dockable ScriptUI panel (a script from the ScriptUI Panels folder), by script window id.
|
||||
ScriptPanel(u32),
|
||||
LumetriScopes,
|
||||
Footage,
|
||||
MediaBrowser,
|
||||
@@ -107,6 +109,7 @@ impl PanelKind {
|
||||
PanelKind::MaskInterpolation => "Mask Interpolation",
|
||||
PanelKind::ScriptConsole => "Script Console",
|
||||
PanelKind::EssentialGraphics => "Essential Graphics",
|
||||
PanelKind::ScriptPanel(_) => "ScriptUI Panel",
|
||||
PanelKind::LumetriScopes => "Lumetri Scopes",
|
||||
PanelKind::Footage => "Footage",
|
||||
PanelKind::MediaBrowser => "Media Browser",
|
||||
|
||||
@@ -18,6 +18,12 @@ impl EffectcraftApp {
|
||||
/// "Effect Controls Title", "Properties: Title", and the Timeline tab named after its comp.
|
||||
fn tab_titles(&self) -> Vec<(PanelKind, String)> {
|
||||
let mut out = Vec::new();
|
||||
// ScriptUI panels are named after their script.
|
||||
for w in self.session.script_ui.windows.iter().filter(|w| w.kind == effectcraft_engine::scriptui::WindowKind::Panel) {
|
||||
if let Some(t) = panels::scriptui_view::panel_title(self, w.id) {
|
||||
out.push((PanelKind::ScriptPanel(w.id), t));
|
||||
}
|
||||
}
|
||||
let Some(comp) = self.session.active_comp() else { return out };
|
||||
let cname = self.session.active_comp_id().and_then(|id| self.session.project.item(id)).map(|i| i.name.clone()).unwrap_or_default();
|
||||
out.push((PanelKind::Composition, format!("Composition {cname}")));
|
||||
@@ -69,6 +75,13 @@ impl EffectcraftApp {
|
||||
|
||||
/// Close a panel wherever it is (docked or floating).
|
||||
pub fn close_panel(&mut self, p: PanelKind) {
|
||||
// Closing a ScriptUI panel closes its script window (its script's onClose runs).
|
||||
if let PanelKind::ScriptPanel(id) = p
|
||||
&& self.session.script_ui.window(id).is_some()
|
||||
&& let Err(e) = self.session.execute("scriptui.close", serde_json::json!({"window": id}))
|
||||
{
|
||||
self.ui.status = e.to_string();
|
||||
}
|
||||
self.ui.dock.close(p);
|
||||
self.edit_layout(|l| l.unfloat(p));
|
||||
if self.ui.maximized == Some(p) {
|
||||
|
||||
@@ -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;
|
||||
@@ -221,7 +223,21 @@ fn puppet_options(app: &mut EffectcraftApp, ui: &mut egui::Ui, p: &egui::Painter
|
||||
}
|
||||
x = r.max.x + 12.0;
|
||||
}
|
||||
x + 4.0
|
||||
// Record Options… (⌘/Ctrl-drag a pin records its motion in real time).
|
||||
let label = "Record Options...";
|
||||
let w = 104.0;
|
||||
let r = Rect::from_min_size(pos2(x, cy - 10.0), vec2(w, 20.0));
|
||||
let resp = ui.interact(r, egui::Id::new("puppet-record-options"), egui::Sense::click()).on_hover_text("⌘/Ctrl-drag a pin to record its motion");
|
||||
p.rect_stroke(r, 3.0, egui::Stroke::new(1.0, if resp.hovered() { t.accent } else { t.field_border }), egui::StrokeKind::Inside);
|
||||
p.text(r.center(), Align2::CENTER_CENTER, label, Tokens::ui(11.5), t.text);
|
||||
app.auto.add("header.puppet.recordOptions", r, label);
|
||||
if resp.clicked() {
|
||||
let ctx = ui.ctx().clone();
|
||||
if let Err(e) = crate::menus::invoke(app, &ctx, "puppet.recordOptions", json!({})) {
|
||||
app.ui.status = e;
|
||||
}
|
||||
}
|
||||
r.max.x + 16.0
|
||||
}
|
||||
|
||||
fn ws_menu(app: &mut EffectcraftApp, ui: &mut egui::Ui) {
|
||||
|
||||
@@ -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)]);
|
||||
|
||||
@@ -74,6 +74,8 @@ pub enum Dialog {
|
||||
Precompose,
|
||||
/// Layer ▸ Layer Styles ▸ Layer Style Options…
|
||||
LayerStyles,
|
||||
/// Edit ▸ Templates ▸ Render Settings… / Output Module….
|
||||
RenderTemplates,
|
||||
}
|
||||
|
||||
/// Host hooks provided by the native app (file pickers etc.).
|
||||
@@ -287,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -344,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
|
||||
@@ -439,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);
|
||||
}
|
||||
@@ -454,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);
|
||||
@@ -467,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,
|
||||
@@ -844,6 +857,9 @@ impl EffectcraftApp {
|
||||
panels::precomp::mini_flowchart(self, &ctx);
|
||||
panels::home::capture_thumbnail(self);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -456,6 +456,12 @@ pub fn frontend(app: &mut EffectcraftApp, ctx: &egui::Context, id: &str, p: Valu
|
||||
app.dialog = Some(crate::Dialog::About);
|
||||
Value::Null
|
||||
}
|
||||
// Window ▸ <ScriptUI panel>: dock (or bring forward) the panel the script built.
|
||||
"window.scriptPanel" => {
|
||||
let id = p.get("window").and_then(Value::as_u64).ok_or("no ScriptUI panel window")? as u32;
|
||||
app.show_panel(PanelKind::ScriptPanel(id));
|
||||
json!({"window": id})
|
||||
}
|
||||
"layer.style.options" => {
|
||||
crate::panels::layer_styles_dialog::open(app, &p)?;
|
||||
Value::Null
|
||||
@@ -506,8 +512,18 @@ pub fn frontend(app: &mut EffectcraftApp, ctx: &egui::Context, id: &str, p: Valu
|
||||
}
|
||||
"app.templates" => {
|
||||
let kind = p.get("kind").and_then(Value::as_str).unwrap_or("renderSettings");
|
||||
let title = if kind == "outputModule" { "Output Module Templates" } else { "Render Settings Templates" };
|
||||
crate::panels::dialogs::info(app, title, "Render and output templates are managed from the Render Queue panel (Window ▸ Render Queue).");
|
||||
crate::panels::rq_templates::open(app, ctx, kind);
|
||||
Value::Null
|
||||
}
|
||||
"renderQueue.notify" => {
|
||||
// Render finished with Notify on: a toast, the dock/taskbar attention request, and the
|
||||
// host's system sound (the desktop app handles `renderQueue.notify`).
|
||||
let msg = p.get("message").and_then(Value::as_str).unwrap_or("Render finished").to_string();
|
||||
app.toast = Some((msg, now));
|
||||
ctx.send_viewport_cmd(egui::ViewportCommand::RequestUserAttention(egui::UserAttentionType::Informational));
|
||||
if let Some(f) = app.hooks.app_action.as_ref() {
|
||||
f("renderQueue.notify");
|
||||
}
|
||||
Value::Null
|
||||
}
|
||||
"app.find" => {
|
||||
@@ -822,7 +838,9 @@ fn file_dialog(app: &mut EffectcraftApp, id: &str, params: &Value) -> Option<Res
|
||||
"file.exportLottie" => ("path", Ask::Save("Animation.json")),
|
||||
"file.importLottie" => ("path", Ask::Open(&["json", "lottie"])),
|
||||
"render.saveCurrentPreview" => ("path", Ask::Save("Preview.mp4")),
|
||||
"file.runScript" => ("path", Ask::Open(&["jsx", "js", "jsonl", "json", "txt"])),
|
||||
"file.runScript" if params.get("name").is_none() => ("path", Ask::Open(&["jsx", "js", "jsonl", "json", "txt"])),
|
||||
"file.installScript" | "file.installScriptUIPanel" => ("path", Ask::Open(&["jsx", "js"])),
|
||||
"effect.plugins.load" if params.get("folder").is_none() => ("path", Ask::Open(&["wasm", "wat"])),
|
||||
"file.replaceFootage" => ("path", Ask::Import),
|
||||
"file.collectFiles" => ("folder", Ask::Save("Collected Files")),
|
||||
"file.saveCopyAsXml" => ("path", Ask::Save("Untitled Project.ecprojx")),
|
||||
|
||||
@@ -38,6 +38,8 @@ struct Active {
|
||||
show_3d: bool,
|
||||
point_size: f64,
|
||||
target_size: f64,
|
||||
/// Undistort Footage is on: points project without the lens distortion.
|
||||
undistort: bool,
|
||||
/// Layer pixels → comp pixels.
|
||||
l2c: Mat3,
|
||||
frame: usize,
|
||||
@@ -66,6 +68,7 @@ fn active(s: &Session, comp: &Comp, ectx: &EvalCtx, l2c: &dyn Fn(&EvalCtx, &Laye
|
||||
let t = tracks.as_ref()?;
|
||||
(t.frame_duration > 0.0).then(|| ((lt - t.start) / t.frame_duration).round().clamp(0.0, t.frames.saturating_sub(1) as f64) as usize)
|
||||
});
|
||||
let undistort = solve.as_ref().is_some_and(|sv| ct::undistorts(¶ms, sv));
|
||||
return Some(Active {
|
||||
layer: *lid,
|
||||
uid: *uid,
|
||||
@@ -74,6 +77,7 @@ fn active(s: &Session, comp: &Comp, ectx: &EvalCtx, l2c: &dyn Fn(&EvalCtx, &Laye
|
||||
show_3d: val("showTrackPoints").map(|v| v.as_enum()).unwrap_or(1) == 1,
|
||||
point_size: val("trackPointSize").map(|v| v.as_f64()).unwrap_or(100.0),
|
||||
target_size: val("targetSize").map(|v| v.as_f64()).unwrap_or(100.0),
|
||||
undistort,
|
||||
l2c: l2c(ectx, l),
|
||||
frame: frame.unwrap_or(0),
|
||||
});
|
||||
@@ -98,18 +102,20 @@ fn l2c_scale(m: &Mat3) -> f32 {
|
||||
|
||||
/// Draw the target disc (concentric rings in perspective) of `t` on frame `k`.
|
||||
fn draw_target(p: &egui::Painter, a: &Active, map: &ViewerMap, sv: &CameraSolve, t: &Target) {
|
||||
let Some(cam) = sv.frames.get(a.frame) else { return };
|
||||
if sv.frames.get(a.frame).is_none() {
|
||||
return;
|
||||
}
|
||||
let r = t.size * 0.5 * a.target_size / 100.0;
|
||||
for (i, frac) in [1.0, 0.66, 0.33].into_iter().enumerate() {
|
||||
let ring = ct::target_circle(t.center, t.normal, r * frac, 48);
|
||||
let pts: Vec<Pos2> = ring.iter().filter_map(|x| cam.project(sv.size, *x)).map(|q| to_screen(a, map, q)).collect();
|
||||
let pts: Vec<Pos2> = ring.iter().filter_map(|x| sv.project(a.frame, *x, a.undistort)).map(|q| to_screen(a, map, q)).collect();
|
||||
if pts.len() < 3 {
|
||||
return;
|
||||
}
|
||||
let fill = if i % 2 == 0 { Color32::from_rgba_unmultiplied(0xd0, 0x30, 0x30, 70) } else { Color32::from_rgba_unmultiplied(0xff, 0xff, 0xff, 50) };
|
||||
p.add(egui::Shape::convex_polygon(pts.clone(), fill, Stroke::new(1.0, Color32::from_rgb(0xe0, 0x40, 0x40))));
|
||||
}
|
||||
if let Some(c) = cam.project(sv.size, t.center) {
|
||||
if let Some(c) = sv.project(a.frame, t.center, a.undistort) {
|
||||
let c = to_screen(a, map, c);
|
||||
p.circle_filled(c, 3.0, Color32::from_rgb(0xff, 0xd0, 0x40));
|
||||
}
|
||||
@@ -168,7 +174,7 @@ pub fn viewer_hook(
|
||||
let mut hits: Vec<Hit> = vec![];
|
||||
match (&a.solve, a.show_3d) {
|
||||
(Some(sv), true) => {
|
||||
let pts = ct::projected(sv, a.frame);
|
||||
let pts = ct::projected_with(sv, a.frame, a.undistort);
|
||||
let med = ct::median_depth(&pts);
|
||||
for (id, q, z) in pts {
|
||||
let sp = to_screen(&a, map, q);
|
||||
|
||||
@@ -129,6 +129,7 @@ pub fn show(app: &mut EffectcraftApp, ctx: &egui::Context) {
|
||||
Dialog::LayerStyles => super::layer_styles_dialog::show(app, ctx, &t),
|
||||
Dialog::TrackTarget => super::tracker::target_dialog(app, ctx, &t),
|
||||
Dialog::TrackApply => super::tracker::apply_dialog(app, ctx, &t),
|
||||
Dialog::RenderTemplates => super::rq_templates::show(app, ctx, &t),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -441,6 +441,37 @@ fn dial_row(app: &mut EffectcraftApp, ui: &mut egui::Ui, layer: &Layer, prop: &P
|
||||
}
|
||||
}
|
||||
|
||||
/// The effect instance a row belongs to, for conditional visibility
|
||||
/// ([`effectcraft_engine::effects::catalog::param_shown`]): effect id, the instance's root
|
||||
/// group and the spec-id path of the group being drawn (`""` or `cameraPosition/`).
|
||||
struct FxScope<'a> {
|
||||
effect: &'a str,
|
||||
root: &'a PropGroup,
|
||||
path: String,
|
||||
}
|
||||
|
||||
impl<'a> FxScope<'a> {
|
||||
fn sub(&self, m: &str) -> FxScope<'a> {
|
||||
FxScope { effect: self.effect, root: self.root, path: format!("{}{m}/", self.path) }
|
||||
}
|
||||
/// Whether child `m` of the current group is shown.
|
||||
fn shown(&self, layer: &Layer, ectx: &EvalCtx, m: &str) -> bool {
|
||||
let root = self.root;
|
||||
let value = |id: &str| -> Option<Value> {
|
||||
let mut g = root;
|
||||
let mut parts = id.split('/').peekable();
|
||||
while let Some(part) = parts.next() {
|
||||
if parts.peek().is_none() {
|
||||
return g.get(part).map(|p| ectx.value(layer, p));
|
||||
}
|
||||
g = g.sub(part)?;
|
||||
}
|
||||
None
|
||||
};
|
||||
effectcraft_engine::effects::catalog::param_shown(self.effect, &format!("{}{m}", self.path), &value)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn group_rows(
|
||||
app: &mut EffectcraftApp,
|
||||
@@ -452,6 +483,7 @@ fn group_rows(
|
||||
rect: Rect,
|
||||
y: &mut f32,
|
||||
depth: usize,
|
||||
fx: &FxScope,
|
||||
actions: &mut Actions,
|
||||
) {
|
||||
let t = app.tokens;
|
||||
@@ -459,7 +491,7 @@ fn group_rows(
|
||||
let r = Rect::from_min_size(pos2(rect.min.x, *y), vec2(rect.width(), ROW));
|
||||
match c {
|
||||
Node::Prop(pr) => {
|
||||
if matches!(pr.ui, ParamUi::Hidden) || pr.three_d_only && !layer.is_3d() {
|
||||
if matches!(pr.ui, ParamUi::Hidden) || pr.three_d_only && !layer.is_3d() || !fx.shown(layer, ectx, &pr.match_id) {
|
||||
continue;
|
||||
}
|
||||
*y += ROW;
|
||||
@@ -486,7 +518,7 @@ fn group_rows(
|
||||
}
|
||||
Node::Group(sg) => {
|
||||
// Paint strokes live in the Timeline only (AE's Paint shows Paint on Transparent).
|
||||
if effectcraft_engine::effects::paint::is_paint(g) {
|
||||
if effectcraft_engine::effects::paint::is_paint(g) || !fx.shown(layer, ectx, &sg.match_id) {
|
||||
continue;
|
||||
}
|
||||
*y += ROW;
|
||||
@@ -503,7 +535,8 @@ fn group_rows(
|
||||
p.text(pos2(tw.max.x + 6.0, r.center().y), Align2::LEFT_CENTER, &sg.name, Tokens::ui(12.0), t.text);
|
||||
}
|
||||
if open {
|
||||
group_rows(app, ui, p, layer, sg, ectx, rect, y, depth + 1, actions);
|
||||
let sub = fx.sub(&sg.match_id);
|
||||
group_rows(app, ui, p, layer, sg, ectx, rect, y, depth + 1, &sub, actions);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -642,12 +675,24 @@ fn channel_popup(
|
||||
fn curves_editor(app: &mut EffectcraftApp, ui: &mut egui::Ui, p: &egui::Painter, layer: &Layer, g: &PropGroup, ectx: &EvalCtx, r: Rect, actions: &mut Actions) {
|
||||
let t = app.tokens;
|
||||
let euid = g.uid;
|
||||
let ch = app.ui.fx_curve_channel.get(&euid).copied().unwrap_or(0).min(4);
|
||||
// The channel lives in the effect's hidden Channel parameter (UI state for instances
|
||||
// saved before it existed).
|
||||
let chan_prop = g.get("channel");
|
||||
let ch = match chan_prop {
|
||||
Some(pr) => ectx.value(layer, pr).as_enum() as usize,
|
||||
None => app.ui.fx_curve_channel.get(&euid).copied().unwrap_or(0),
|
||||
}
|
||||
.min(4);
|
||||
let x0 = r.min.x + 30.0;
|
||||
let cy = r.min.y + 17.0;
|
||||
let names: Vec<&str> = fw::CURVE_CHANNELS.iter().map(|c| c.1).collect();
|
||||
if let Some(n) = channel_popup(app, ui, p, x0, cy, ch, &names, egui::Id::new(("ec-cch", euid)), &format!("effectControls.effect.{euid}.curves.channel")) {
|
||||
app.ui.fx_curve_channel.insert(euid, n);
|
||||
match chan_prop {
|
||||
Some(pr) => actions.push(("prop.set".into(), json!({"layer": layer.id.0, "prop": pr.uid, "value": n}))),
|
||||
None => {
|
||||
app.ui.fx_curve_channel.insert(euid, n);
|
||||
}
|
||||
}
|
||||
}
|
||||
let pencil = app.ui.fx_curve_pencil.contains(&euid);
|
||||
let mr = Rect::from_min_size(pos2(x0 + 146.0, cy - 9.0), vec2(56.0, 18.0));
|
||||
@@ -696,7 +741,7 @@ fn curves_editor(app: &mut EffectcraftApp, ui: &mut egui::Ui, p: &egui::Painter,
|
||||
/// Levels parameter ids for a channel: input black, input white, gamma, output black, output white.
|
||||
fn levels_ids(effect: &str, ch: usize) -> [String; 5] {
|
||||
if effect == "ec.color.levels" {
|
||||
return ["inBlack", "inWhite", "gamma", "outBlack", "outWhite"].map(String::from);
|
||||
return effectcraft_engine::effects::levels_channel_ids(ch);
|
||||
}
|
||||
// Levels (Individual Controls) nests each channel's controls in its twirl-down group.
|
||||
let pre = fw::LEVELS_CHANNELS[ch.min(4)].0;
|
||||
@@ -721,7 +766,13 @@ fn levels_editor(
|
||||
let euid = g.uid;
|
||||
let x0 = r.min.x + 30.0;
|
||||
let cy = r.min.y + 17.0;
|
||||
let ch = if effect == "ec.color.levelsic" { app.ui.fx_levels_channel.get(&euid).copied().unwrap_or(0).min(4) } else { 0 };
|
||||
// Levels keeps its channel in the Channel parameter; Levels (Individual Controls) shows
|
||||
// every channel and the popup only picks the histogram.
|
||||
let ch = if effect == "ec.color.levelsic" {
|
||||
app.ui.fx_levels_channel.get(&euid).copied().unwrap_or(0).min(4)
|
||||
} else {
|
||||
g.get("channel").map(|pr| ectx.value(layer, pr).as_enum() as usize).unwrap_or(0).min(4)
|
||||
};
|
||||
if effect == "ec.color.levelsic" {
|
||||
let names: Vec<&str> = fw::LEVELS_CHANNELS.iter().map(|c| c.1).collect();
|
||||
if let Some(n) = channel_popup(app, ui, p, x0, cy, ch, &names, egui::Id::new(("ec-lch", euid)), &format!("effectControls.effect.{euid}.levels.channel"))
|
||||
@@ -959,7 +1010,8 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
}
|
||||
}
|
||||
}
|
||||
group_rows(app, ui, &bp, &layer, g, &ectx, body, &mut y, 0, &mut actions);
|
||||
let scope = FxScope { effect: effect.as_str(), root: g, path: String::new() };
|
||||
group_rows(app, ui, &bp, &layer, g, &ectx, body, &mut y, 0, &scope, &mut actions);
|
||||
}
|
||||
y += 4.0;
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
let searching = !query.is_empty();
|
||||
let mut y = list.min.y - scroll;
|
||||
let mut apply: Option<Apply> = None;
|
||||
let reg = effectcraft_engine::effects::registry();
|
||||
let reg = effectcraft_engine::effects::all();
|
||||
let keep = |e: &effectcraft_engine::effects::EffectSpec| depth_keeps(&view.depth, e) && (query.is_empty() || e.name.to_lowercase().contains(&query));
|
||||
let lookup = |id: &str| reg.iter().find(|e| e.id == id);
|
||||
|
||||
@@ -381,7 +381,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
effect_row(app, ui, &lp, list, &mut y, e, -16.0, &query, "effects.item", &mut apply);
|
||||
}
|
||||
} else {
|
||||
let mut cats: Vec<&str> = effectcraft_engine::effects::CATEGORIES.to_vec();
|
||||
let mut cats: Vec<&str> = effectcraft_engine::effects::categories();
|
||||
cats.retain(|c| reg.iter().any(|e| e.category == *c));
|
||||
for cat in cats {
|
||||
let items: Vec<_> = reg.iter().filter(|e| e.category == cat && keep(e)).collect();
|
||||
|
||||
@@ -154,6 +154,19 @@ pub fn open_form(app: &mut EffectcraftApp, id: &str, p: &Value) -> bool {
|
||||
Field::num("page", "Page", 1.0),
|
||||
],
|
||||
),
|
||||
// Puppet tool ▸ Record Options.
|
||||
"puppet.recordOptions" if !has(p, &["speed", "smoothing", "useDraftDeformation", "showMesh"]) => {
|
||||
let o = &s.state.puppet;
|
||||
(
|
||||
"Puppet Record Options".into(),
|
||||
vec![
|
||||
Field::num("speed", "Speed (%)", o.record_speed),
|
||||
Field::num("smoothing", "Smoothing", o.record_smoothing),
|
||||
Field::bool("useDraftDeformation", "Use Draft Deformation", o.record_draft),
|
||||
Field::bool("showMesh", "Show Mesh", o.record_show_mesh),
|
||||
],
|
||||
)
|
||||
}
|
||||
"layer.setTransform" if !has(p, &["value"]) => {
|
||||
let prop = p.get("prop").and_then(Value::as_str).unwrap_or("position");
|
||||
let cur = layer.and_then(|l| l.transform()).and_then(|tr| tr.get(if prop == "anchorPoint" { "anchor" } else { prop })).map(|pr| pr.value_at(lt));
|
||||
|
||||
@@ -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 => {}
|
||||
}
|
||||
}
|
||||
@@ -172,34 +172,43 @@ pub fn audio(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
pub fn history(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
let t = app.tokens;
|
||||
let p = ui.painter().with_clip_rect(rect);
|
||||
// The branching history (EffectCraft's History panel): every state, branches indented under
|
||||
// the state they grew from; click any state to go there (`edit.history.goto`).
|
||||
let nodes = app.session.history_tree();
|
||||
let row_h = 22.0;
|
||||
let cur = nodes.iter().position(|n| n.current).unwrap_or(0);
|
||||
// Keep the current state in view.
|
||||
let visible = ((rect.height() - 12.0) / row_h).max(1.0) as usize;
|
||||
let first = (cur + 2).saturating_sub(visible).min(nodes.len().saturating_sub(visible));
|
||||
let mut y = rect.min.y + 6.0;
|
||||
let undo: Vec<String> = app.session.history.undo.iter().map(|u| u.0.clone()).collect();
|
||||
let redo: Vec<String> = app.session.history.redo.iter().rev().map(|u| u.0.clone()).collect();
|
||||
let n = undo.len();
|
||||
let mut jump: Option<i64> = None;
|
||||
for (i, label) in undo.iter().chain(redo.iter()).enumerate() {
|
||||
let r = Rect::from_min_size(pos2(rect.min.x, y), vec2(rect.width(), 22.0));
|
||||
y += 22.0;
|
||||
let current = i + 1 == n;
|
||||
let future = i >= n;
|
||||
let resp = ui.interact(r, egui::Id::new(("hist", i)), Sense::click());
|
||||
if current {
|
||||
let mut jump: Option<usize> = None;
|
||||
for n in nodes.iter().skip(first).take(visible + 1) {
|
||||
let r = Rect::from_min_size(pos2(rect.min.x, y), vec2(rect.width(), row_h));
|
||||
y += row_h;
|
||||
let resp = ui.interact(r, egui::Id::new(("hist", n.id.as_str())), Sense::click());
|
||||
if n.current {
|
||||
p.rect_filled(r, 0.0, t.row_selected);
|
||||
} else if resp.hovered() {
|
||||
p.rect_filled(r, 0.0, t.hover);
|
||||
}
|
||||
p.text(pos2(r.min.x + 12.0, r.center().y), Align2::LEFT_CENTER, label, Tokens::ui(12.0), if future { t.text_faint } else { t.text });
|
||||
let x = r.min.x + 12.0 + n.depth as f32 * 14.0;
|
||||
if n.depth > 0 {
|
||||
// Branch marker.
|
||||
let c = pos2(x - 7.0, r.center().y);
|
||||
p.line_segment([pos2(c.x, r.min.y), c], egui::Stroke::new(1.0, t.text_faint));
|
||||
p.line_segment([c, pos2(c.x + 5.0, c.y)], egui::Stroke::new(1.0, t.text_faint));
|
||||
}
|
||||
let col = if !n.current && (n.future || !n.line) { t.text_faint } else { t.text };
|
||||
p.text(pos2(x, r.center().y), Align2::LEFT_CENTER, &n.label, Tokens::ui(12.0), col);
|
||||
app.auto.add(&format!("history.state.{}", n.index), r, &n.label);
|
||||
if resp.clicked() {
|
||||
jump = Some(i as i64 + 1 - n as i64);
|
||||
jump = Some(n.index);
|
||||
}
|
||||
}
|
||||
if let Some(d) = jump {
|
||||
for _ in 0..d.unsigned_abs() {
|
||||
if d < 0 {
|
||||
app.session.undo();
|
||||
} else {
|
||||
app.session.redo();
|
||||
}
|
||||
if let Some(i) = jump {
|
||||
let ctx = ui.ctx().clone();
|
||||
if let Err(e) = crate::menus::invoke(app, &ctx, "edit.history.goto", serde_json::json!({"index": i})) {
|
||||
app.ui.status = e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -33,8 +34,10 @@ pub mod properties;
|
||||
pub mod puppet_tool;
|
||||
pub mod render_queue;
|
||||
pub mod roto_tool;
|
||||
pub mod rq_templates;
|
||||
pub mod scopes_panel;
|
||||
pub mod script_console;
|
||||
pub mod scriptui_view;
|
||||
pub mod settings;
|
||||
pub mod shortcut_editor;
|
||||
pub mod text_panels;
|
||||
@@ -106,6 +109,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, p: PanelKind, rect: Rec
|
||||
PanelKind::Paint => paint_panels::paint(app, ui, rect),
|
||||
PanelKind::Brushes => paint_panels::brushes(app, ui, rect),
|
||||
PanelKind::EssentialGraphics => essential::show(app, ui, rect),
|
||||
PanelKind::ScriptPanel(id) => scriptui_view::panel(app, ui, rect, id),
|
||||
PanelKind::Flowchart => flowchart::show(app, ui, rect),
|
||||
PanelKind::LumetriScopes => scopes_panel::show(app, ui, rect),
|
||||
PanelKind::Footage => footage_panel::show(app, ui, rect),
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -4,10 +4,18 @@
|
||||
//! Output Module and Output To rows, and a status footer.
|
||||
//!
|
||||
//! Every control dispatches an engine `renderQueue.*` command (so agents can do the same) and
|
||||
//! registers an automation id: `renderQueue.render`, `renderQueue.stop`,
|
||||
//! `renderQueue.item.<n>.{row,twirl,render,renderSettings,outputModule,outputTo,outputPath}`.
|
||||
//! registers an automation id: `renderQueue.render`, `renderQueue.stop`, `renderQueue.notify`,
|
||||
//! `renderQueue.item.<n>.{row,twirl,render,renderSettings,outputModule,outputTo,outputPath,log}`.
|
||||
//!
|
||||
//! The Render Settings and Output Module menus list the templates first (Edit ▸ Templates), then
|
||||
//! every setting; entries needing numbers (custom time span and frame rate, crop, resize, bitrate,
|
||||
//! key frame interval, Make Template) open a form that runs the same command.
|
||||
|
||||
use effectcraft_engine::project::render_queue::{AudioOutput, Channels, OutputFormat, ProResProfile, RenderQuality, RenderQueueItem, RenderStatus, TimeSpan};
|
||||
use effectcraft_engine::project::render_queue::{
|
||||
AlphaMode, AudioFormat, AudioOutput, Channels, ColorDepth, CurrentOrOff, EffectsMode, FieldRender, OutputFormat, PostRenderAction, ProResProfile, Pulldown,
|
||||
RESIZE_PRESETS, RenderLog, RenderQuality, RenderQueueItem, RenderStatus, ResizeQuality, SwitchOverride, TimeSpan,
|
||||
};
|
||||
use effectcraft_engine::project::render_templates::RenderTemplates;
|
||||
use egui::{Align2, Color32, Rect, Sense, Stroke, StrokeKind, pos2, vec2};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
@@ -53,42 +61,82 @@ fn status_color(t: &Tokens, s: &RenderStatus) -> Color32 {
|
||||
}
|
||||
}
|
||||
|
||||
/// Render Settings menu: (label, params).
|
||||
fn settings_menu(it: &RenderQueueItem) -> Vec<(String, Value)> {
|
||||
fn mark(on: bool, l: &str) -> String {
|
||||
if on { format!("✓ {l}") } else { format!(" {l}") }
|
||||
}
|
||||
|
||||
/// Render Settings menu: (label, params). `{"form": …}` entries open a form.
|
||||
fn settings_menu(it: &RenderQueueItem, templates: &RenderTemplates) -> Vec<(String, Value)> {
|
||||
let s = &it.settings;
|
||||
let mark = |on: bool, l: &str| if on { format!("✓ {l}") } else { format!(" {l}") };
|
||||
let mut v = vec![
|
||||
(mark(s.quality == RenderQuality::Best, "Best Settings"), json!({"quality": "best"})),
|
||||
(mark(s.quality == RenderQuality::Draft, "Draft Settings"), json!({"quality": "draft"})),
|
||||
("-".into(), Value::Null),
|
||||
];
|
||||
let mut v = vec![];
|
||||
for t in templates.render_settings_list() {
|
||||
v.push((mark(s.name == t.name, &t.name), json!({"template": t.name})));
|
||||
}
|
||||
v.push((" Make Template…".into(), json!({"form": "makeRenderTemplate"})));
|
||||
v.push(("-".into(), Value::Null));
|
||||
v.push((mark(s.quality == RenderQuality::Best, "Quality: Best"), json!({"quality": "best"})));
|
||||
v.push((mark(s.quality == RenderQuality::Draft, "Quality: Draft"), json!({"quality": "draft"})));
|
||||
for (l, k) in [("Full", "full"), ("Half", "half"), ("Third", "third"), ("Quarter", "quarter")] {
|
||||
v.push((mark(s.resolution_label() == l, &format!("Resolution: {l}")), json!({"resolution": k})));
|
||||
}
|
||||
v.push(("-".into(), Value::Null));
|
||||
for (u, k) in effectcraft_engine::project::render_queue::ProxyUse::ALL.iter().zip(["current", "all", "comp", "none"]) {
|
||||
v.push((mark(s.proxy_use == *u, &format!("Proxy Use: {}", u.label())), json!({"proxyUse": k})));
|
||||
}
|
||||
for (e, k) in EffectsMode::ALL.iter().zip(["current", "allOn", "allOff"]) {
|
||||
v.push((mark(s.effects == *e, &format!("Effects: {}", e.label())), json!({"effects": k})));
|
||||
}
|
||||
for (e, k) in [(CurrentOrOff::Current, "current"), (CurrentOrOff::AllOff, "allOff")] {
|
||||
v.push((mark(s.solo == e, &format!("Solo Switches: {}", e.label())), json!({"solo": k})));
|
||||
}
|
||||
for (e, k) in [(CurrentOrOff::Current, "current"), (CurrentOrOff::AllOff, "allOff")] {
|
||||
v.push((mark(s.guide_layers == e, &format!("Guide Layers: {}", e.label())), json!({"guideLayers": k})));
|
||||
}
|
||||
for (d, k) in ColorDepth::ALL.iter().zip(["current", "8", "16", "32"]) {
|
||||
v.push((mark(s.color_depth == *d, &format!("Color Depth: {}", d.label())), json!({"colorDepth": k})));
|
||||
}
|
||||
v.push(("-".into(), Value::Null));
|
||||
for (m, k) in SwitchOverride::ALL.iter().zip(["current", "onForChecked", "offForAll"]) {
|
||||
v.push((mark(s.frame_blending == *m, &format!("Frame Blending: {}", m.label())), json!({"frameBlending": k})));
|
||||
}
|
||||
for (m, k) in SwitchOverride::ALL.iter().zip(["current", "onForChecked", "offForAll"]) {
|
||||
v.push((mark(s.motion_blur_override() == *m, &format!("Motion Blur: {}", m.label())), json!({"motionBlur": k})));
|
||||
}
|
||||
for (f, k) in FieldRender::ALL.iter().zip(["off", "upper", "lower"]) {
|
||||
v.push((mark(s.field_render == *f, &format!("Field Render: {}", f.label())), json!({"fieldRender": k})));
|
||||
}
|
||||
if s.field_render != FieldRender::Off {
|
||||
for pd in Pulldown::ALL {
|
||||
v.push((mark(s.pulldown == pd, &format!("3:2 Pulldown: {}", pd.label())), json!({"pulldown": pd.label()})));
|
||||
}
|
||||
}
|
||||
v.push(("-".into(), Value::Null));
|
||||
v.push((mark(s.time_span == TimeSpan::WorkArea, "Time Span: Work Area Only"), json!({"timeSpan": "workArea"})));
|
||||
v.push((mark(s.time_span == TimeSpan::LengthOfComp, "Time Span: Length of Comp"), json!({"timeSpan": "comp"})));
|
||||
v.push(("-".into(), Value::Null));
|
||||
v.push((mark(matches!(s.time_span, TimeSpan::Custom { .. }), "Time Span: Custom…"), json!({"form": "timeSpan"})));
|
||||
v.push((mark(s.frame_rate.is_none(), "Frame Rate: Use comp's frame rate"), json!({"frameRate": null})));
|
||||
for fps in [12.0, 15.0, 23.976, 24.0, 25.0, 29.97, 30.0, 50.0, 60.0] {
|
||||
let on = s.frame_rate.is_some_and(|r| (r.as_f64() - fps).abs() < 0.01);
|
||||
v.push((mark(on, &format!("Frame Rate: {fps}")), json!({"frameRate": fps})));
|
||||
}
|
||||
v.push((" Frame Rate: Custom…".into(), json!({"form": "frameRate"})));
|
||||
v.push(("-".into(), Value::Null));
|
||||
v.push((mark(s.motion_blur, "Motion Blur: On for Checked Layers"), json!({"motionBlur": !s.motion_blur})));
|
||||
v.push((mark(s.skip_existing, "Skip Existing Files"), json!({"skipExisting": !s.skip_existing})));
|
||||
v.push(("-".into(), Value::Null));
|
||||
for (u, k) in effectcraft_engine::project::render_queue::ProxyUse::ALL.iter().zip(["current", "all", "comp", "none"]) {
|
||||
v.push((mark(s.proxy_use == *u, &format!("Proxy Use: {}", u.label())), json!({"proxyUse": k})));
|
||||
}
|
||||
v.push((mark(s.storage_overflow, "Use Storage Overflow"), json!({"storageOverflow": !s.storage_overflow})));
|
||||
v
|
||||
}
|
||||
|
||||
/// Output Module menu: (label, params).
|
||||
fn output_menu(it: &RenderQueueItem, available: &[OutputFormat]) -> Vec<(String, Value)> {
|
||||
/// Output Module menu: (label, params). `{"form": …}` entries open a form.
|
||||
fn output_menu(it: &RenderQueueItem, available: &[OutputFormat], templates: &RenderTemplates) -> Vec<(String, Value)> {
|
||||
let o = &it.output;
|
||||
let mark = |on: bool, l: &str| if on { format!("✓ {l}") } else { format!(" {l}") };
|
||||
let mut v = Vec::new();
|
||||
for t in templates.output_module_list() {
|
||||
if available.contains(&t.format) {
|
||||
v.push((mark(o.name == t.name, &t.name), json!({"template": t.name})));
|
||||
}
|
||||
}
|
||||
v.push((" Make Template…".into(), json!({"form": "makeOutputTemplate"})));
|
||||
v.push(("-".into(), Value::Null));
|
||||
for f in OutputFormat::ALL {
|
||||
if available.contains(&f) {
|
||||
v.push((mark(o.format == f, &format!("Format: {}", f.label())), json!({"format": format!("{f:?}")})));
|
||||
@@ -99,6 +147,13 @@ fn output_menu(it: &RenderQueueItem, available: &[OutputFormat]) -> Vec<(String,
|
||||
if o.format.supports_alpha() {
|
||||
v.push((mark(o.channels == Channels::Rgba, "Channels: RGB + Alpha"), json!({"channels": "rgba"})));
|
||||
}
|
||||
if !o.format.is_audio_only() {
|
||||
v.push((mark(o.channels == Channels::Alpha, "Channels: Alpha"), json!({"channels": "alpha"})));
|
||||
}
|
||||
if o.channels == Channels::Rgba {
|
||||
v.push((mark(o.alpha_mode == AlphaMode::Straight, "Color: Straight (Unmatted)"), json!({"color": "straight"})));
|
||||
v.push((mark(o.alpha_mode == AlphaMode::Premultiplied, "Color: Premultiplied (Matted)"), json!({"color": "premultiplied"})));
|
||||
}
|
||||
match o.format {
|
||||
OutputFormat::ProRes => {
|
||||
v.push(("-".into(), Value::Null));
|
||||
@@ -108,14 +163,18 @@ fn output_menu(it: &RenderQueueItem, available: &[OutputFormat]) -> Vec<(String,
|
||||
}
|
||||
OutputFormat::H264 => {
|
||||
v.push(("-".into(), Value::Null));
|
||||
for kbps in [2_000, 5_000, 10_000, 20_000, 40_000] {
|
||||
for kbps in [2_000, 5_000, 10_000, 15_000, 20_000, 40_000] {
|
||||
v.push((mark(o.bitrate_kbps == kbps, &format!("Bitrate: {} Mbps", kbps / 1000)), json!({"bitrate": kbps})));
|
||||
}
|
||||
}
|
||||
OutputFormat::JpegSequence | OutputFormat::WebM => {
|
||||
v.push(("-".into(), Value::Null));
|
||||
for q in [60u8, 80, 90, 100] {
|
||||
v.push((mark(o.quality == q, &format!("Quality: {q}")), json!({"quality": q})));
|
||||
v.push((mark(o.quality == q && !o.webm_bitrate, &format!("Quality: {q}")), json!({"quality": q, "webmBitrate": false})));
|
||||
}
|
||||
if o.format == OutputFormat::WebM {
|
||||
v.push((mark(o.webm_bitrate, &format!("Target Bitrate ({} kbps)…", o.bitrate_kbps)), json!({"form": "bitrate"})));
|
||||
v.push((mark(o.keyframe_interval > 0, "Key Frame Interval…"), json!({"form": "keyframes"})));
|
||||
}
|
||||
}
|
||||
OutputFormat::Gif => {
|
||||
@@ -124,20 +183,131 @@ fn output_menu(it: &RenderQueueItem, available: &[OutputFormat]) -> Vec<(String,
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
if !o.format.is_audio_only() {
|
||||
v.push(("-".into(), Value::Null));
|
||||
v.push((mark(!o.crop.enabled, "Crop: Off"), json!({"crop": false})));
|
||||
v.push((mark(o.crop.enabled && o.crop.use_roi, "Crop: Use Region of Interest"), json!({"crop": {"useRoi": true}})));
|
||||
v.push((mark(o.crop.enabled && !o.crop.use_roi, "Crop: Edges…"), json!({"form": "crop"})));
|
||||
v.push((mark(!o.resize.enabled, "Resize: Off"), json!({"resize": false})));
|
||||
for (n, w, h) in RESIZE_PRESETS {
|
||||
let on = o.resize.enabled && o.resize.width == w && o.resize.height == h && !o.resize.lock_aspect;
|
||||
v.push((mark(on, &format!("Resize to: {n} ({w}×{h})")), json!({"resize": {"preset": n}})));
|
||||
}
|
||||
v.push((mark(o.resize.enabled, "Resize to: Custom…"), json!({"form": "resize"})));
|
||||
v.push((
|
||||
mark(o.resize.lock_aspect, "Resize: Lock Aspect Ratio"),
|
||||
json!({"resize": {"enabled": o.resize.enabled, "lockAspect": !o.resize.lock_aspect}}),
|
||||
));
|
||||
for (q, k) in [(ResizeQuality::Low, "low"), (ResizeQuality::High, "high")] {
|
||||
v.push((mark(o.resize.quality == q, &format!("Resize Quality: {q:?}")), json!({"resize": {"enabled": o.resize.enabled, "quality": k}})));
|
||||
}
|
||||
}
|
||||
v.push(("-".into(), Value::Null));
|
||||
for (a, k) in [
|
||||
(PostRenderAction::None, "none"),
|
||||
(PostRenderAction::Import, "import"),
|
||||
(PostRenderAction::ImportAndReplace, "importAndReplace"),
|
||||
(PostRenderAction::SetProxy, "setProxy"),
|
||||
] {
|
||||
v.push((mark(it.post_render == a, &format!("Post-Render Action: {}", a.label())), json!({"postRenderAction": k})));
|
||||
}
|
||||
v.push((mark(o.include_project_link, "Include Project Link"), json!({"includeProjectLink": !o.include_project_link})));
|
||||
if o.format.supports_audio() {
|
||||
v.push(("-".into(), Value::Null));
|
||||
for (a, l) in [(AudioOutput::Auto, "auto"), (AudioOutput::On, "on"), (AudioOutput::Off, "off")] {
|
||||
let label = match a {
|
||||
AudioOutput::Auto => "Audio Output: Auto",
|
||||
AudioOutput::On => "Audio Output: On (48 kHz stereo)",
|
||||
AudioOutput::On => "Audio Output: On",
|
||||
AudioOutput::Off => "Audio Output: Off",
|
||||
};
|
||||
v.push((mark(o.audio == a, label), json!({"audio": l})));
|
||||
}
|
||||
for sr in [44_100u32, 48_000, 96_000] {
|
||||
v.push((mark(o.audio_sample_rate == sr, &format!("Sample Rate: {:.1} kHz", sr as f64 / 1000.0)), json!({"sampleRate": sr})));
|
||||
}
|
||||
v.push((mark(o.audio_channels == 1, "Audio Channels: Mono"), json!({"audioChannels": "mono"})));
|
||||
v.push((mark(o.audio_channels != 1, "Audio Channels: Stereo"), json!({"audioChannels": "stereo"})));
|
||||
if matches!(o.format, OutputFormat::ProRes | OutputFormat::Wav | OutputFormat::Aiff) {
|
||||
for f in [AudioFormat::S16, AudioFormat::S24, AudioFormat::F32] {
|
||||
v.push((mark(o.audio_format == f, &format!("Sample Format: {}", f.label())), json!({"audioFormat": f.label()})));
|
||||
}
|
||||
}
|
||||
}
|
||||
v
|
||||
}
|
||||
|
||||
/// Open the form behind a `{"form": …}` menu entry.
|
||||
fn open_menu_form(app: &mut EffectcraftApp, it: &RenderQueueItem, form: &str) {
|
||||
use crate::panels::forms::{Field, form as open};
|
||||
let id = it.id;
|
||||
let o = &it.output;
|
||||
match form {
|
||||
"makeRenderTemplate" => open(
|
||||
app,
|
||||
"Make Render Settings Template",
|
||||
"renderQueue.saveTemplate",
|
||||
json!({"kind": "renderSettings", "item": id}),
|
||||
vec![Field::text("name", "Template name", "")],
|
||||
),
|
||||
"makeOutputTemplate" => open(
|
||||
app,
|
||||
"Make Output Module Template",
|
||||
"renderQueue.saveTemplate",
|
||||
json!({"kind": "outputModule", "item": id}),
|
||||
vec![Field::text("name", "Template name", "")],
|
||||
),
|
||||
"timeSpan" => {
|
||||
let comp = app.session.project.comp(it.comp);
|
||||
let (a, b) = comp.map(|c| it.settings.span(c)).unwrap_or_default();
|
||||
open(
|
||||
app,
|
||||
"Custom Time Span",
|
||||
"renderQueue.setRenderSettings",
|
||||
json!({"item": id, "timeSpan": "custom"}),
|
||||
vec![Field::num("start", "Start (s)", a.seconds()), Field::num("duration", "Duration (s)", (b.seconds() - a.seconds()).max(0.04))],
|
||||
)
|
||||
}
|
||||
"frameRate" => {
|
||||
let r = app.session.project.comp(it.comp).map(|c| it.settings.rate(c).as_f64()).unwrap_or(30.0);
|
||||
open(app, "Use This Frame Rate", "renderQueue.setRenderSettings", json!({"item": id}), vec![Field::num("frameRate", "Frames per second", r)])
|
||||
}
|
||||
"crop" => open(
|
||||
app,
|
||||
"Crop",
|
||||
"renderQueue.setOutputModule",
|
||||
json!({"item": id}),
|
||||
vec![
|
||||
Field::num("cropTop", "Top", o.crop.top as f64),
|
||||
Field::num("cropLeft", "Left", o.crop.left as f64),
|
||||
Field::num("cropBottom", "Bottom", o.crop.bottom as f64),
|
||||
Field::num("cropRight", "Right", o.crop.right as f64),
|
||||
],
|
||||
),
|
||||
"resize" => open(
|
||||
app,
|
||||
"Resize to",
|
||||
"renderQueue.setOutputModule",
|
||||
json!({"item": id}),
|
||||
vec![Field::num("resizeWidth", "Width", o.resize.width as f64), Field::num("resizeHeight", "Height", o.resize.height as f64)],
|
||||
),
|
||||
"bitrate" => open(
|
||||
app,
|
||||
"WebM Target Bitrate",
|
||||
"renderQueue.setOutputModule",
|
||||
json!({"item": id, "webmBitrate": true}),
|
||||
vec![Field::num("bitrate", "Bitrate (kbps)", o.bitrate_kbps as f64)],
|
||||
),
|
||||
"keyframes" => open(
|
||||
app,
|
||||
"Key Frame Interval",
|
||||
"renderQueue.setOutputModule",
|
||||
json!({"item": id}),
|
||||
vec![Field::num("keyframeInterval", "Frames between key frames (0 = every 2 s)", o.keyframe_interval as f64)],
|
||||
),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
const OUTPUT_TEMPLATES: [&str; 4] = [
|
||||
"[compName].[fileExtension]",
|
||||
"[compName]_[width]x[height].[fileExtension]",
|
||||
@@ -166,6 +336,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
let rendering = app.session.is_rendering();
|
||||
let available = app.session.exporter.as_ref().map(|e| e.formats()).unwrap_or_default();
|
||||
let mut actions: Vec<(&'static str, Value)> = Vec::new();
|
||||
let mut forms: Vec<(RenderQueueItem, String)> = Vec::new();
|
||||
let state_id = egui::Id::new("rq-ui");
|
||||
let (mut open, mut selected): (Vec<u64>, Option<u64>) = ui.data(|d| d.get_temp(state_id).unwrap_or_default());
|
||||
|
||||
@@ -194,6 +365,14 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
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::new("rq-notify")).clicked() {
|
||||
actions.push(("renderQueue.setNotify", json!({"notify": !notify})));
|
||||
}
|
||||
p.text(pos2(nb.max.x + 5.0, nb.center().y), Align2::LEFT_CENTER, "Notify", Tokens::ui(11.5), t.text_dim);
|
||||
app.auto.add("renderQueue.notify", nb, if notify { "Notify: on" } else { "Notify: off" });
|
||||
if rendering {
|
||||
if widgets::text_button(ui, stop_b, "Stop", false, &t, egui::Id::new("rq-stop")).clicked() {
|
||||
actions.push(("renderQueue.stop", json!({})));
|
||||
@@ -201,8 +380,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
app.auto.add("renderQueue.stop", stop_b, "Stop");
|
||||
}
|
||||
// Progress bar.
|
||||
let bar =
|
||||
Rect::from_min_max(pos2(x0, render_b.min.y + 4.0), pos2(if rendering { stop_b.min.x - 16.0 } else { render_b.min.x - 16.0 }, render_b.max.y - 4.0));
|
||||
let bar = Rect::from_min_max(pos2(x0, render_b.min.y + 4.0), pos2(nb.min.x - 16.0, render_b.max.y - 4.0));
|
||||
p.rect_filled(bar, 3.0, t.field_bg);
|
||||
p.rect_stroke(bar, 3.0, Stroke::new(1.0, t.field_border), StrokeKind::Inside);
|
||||
let frac = progress.as_ref().filter(|p| p.total > 0).map(|p| (p.done as f32 / p.total as f32).clamp(0.0, 1.0)).unwrap_or(0.0);
|
||||
@@ -355,22 +533,28 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
let r = Rect::from_min_size(pos2(list.min.x, y), vec2(list.width(), ROW_H));
|
||||
y += ROW_H;
|
||||
lp.rect_filled(r, 0.0, t.panel_bg);
|
||||
let templates = &app.session.project.render_templates;
|
||||
let (label, summary, key, menu): (&str, String, &str, Vec<(String, Value)>) = if sub == 0 {
|
||||
("Render Settings:", it.settings.summary(), "renderSettings", settings_menu(it))
|
||||
("Render Settings:", it.settings.summary(), "renderSettings", settings_menu(it, templates))
|
||||
} else {
|
||||
("Output Module:", it.output.summary(), "outputModule", output_menu(it, &available))
|
||||
("Output Module:", it.output.summary(), "outputModule", output_menu(it, &available, templates))
|
||||
};
|
||||
lp.text(pos2(cx_num - 6.0, r.center().y), Align2::LEFT_CENTER, label, Tokens::ui(11.5), t.text_dim);
|
||||
let dd = Rect::from_min_size(pos2(ix + 70.0, r.min.y + 3.0), vec2(220.0, ROW_H - 6.0));
|
||||
let did = egui::Id::new(("rq-dd", it.id, sub));
|
||||
if widgets::dropdown(ui, dd, &summary, &t, did).clicked() && !rendering {
|
||||
let shown: String = if summary.chars().count() > 31 { summary.chars().take(30).chain(std::iter::once('…')).collect() } else { summary.clone() };
|
||||
if widgets::dropdown(ui, dd, &shown, &t, did).clicked() && !rendering {
|
||||
widgets::open_popup(ui, did);
|
||||
}
|
||||
let labels: Vec<String> = menu.iter().map(|(l, _)| l.clone()).collect();
|
||||
if let Some(i) = widgets::popup_menu(ui, did, dd.left_bottom(), &labels, None) {
|
||||
let mut params = menu[i].1.clone();
|
||||
params["item"] = json!(it.id);
|
||||
actions.push((if sub == 0 { "renderQueue.setRenderSettings" } else { "renderQueue.setOutputModule" }, params));
|
||||
if let Some(f) = params.get("form").and_then(Value::as_str) {
|
||||
forms.push((it.clone(), f.to_string()));
|
||||
} else {
|
||||
params["item"] = json!(it.id);
|
||||
actions.push((if sub == 0 { "renderQueue.setRenderSettings" } else { "renderQueue.setOutputModule" }, params));
|
||||
}
|
||||
}
|
||||
app.auto.add(&aid(key), dd, &summary);
|
||||
if sub == 0 {
|
||||
@@ -387,6 +571,18 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
);
|
||||
lp.text(pos2(dd.max.x + 14.0, r.center().y), Align2::LEFT_CENTER, info, Tokens::ui(11.0), t.text_faint);
|
||||
}
|
||||
// Log: Errors Only / Plus Settings / Plus Per Frame Info.
|
||||
let ld = Rect::from_min_size(pos2(r.max.x - 190.0, r.min.y + 3.0), vec2(150.0, ROW_H - 6.0));
|
||||
lp.text(pos2(ld.min.x - 6.0, r.center().y), Align2::RIGHT_CENTER, "Log:", Tokens::ui(11.5), t.text_dim);
|
||||
let lid = egui::Id::new(("rq-log", it.id));
|
||||
if widgets::dropdown(ui, ld, it.log.label(), &t, lid).clicked() && !rendering {
|
||||
widgets::open_popup(ui, lid);
|
||||
}
|
||||
let llabels: Vec<String> = RenderLog::ALL.iter().map(|l| mark(it.log == *l, l.label())).collect();
|
||||
if let Some(i) = widgets::popup_menu(ui, lid, ld.left_bottom(), &llabels, None) {
|
||||
actions.push(("renderQueue.setLog", json!({"item": it.id, "log": RenderLog::ALL[i].label()})));
|
||||
}
|
||||
app.auto.add(&aid("log"), ld, it.log.label());
|
||||
continue;
|
||||
}
|
||||
// Output To.
|
||||
@@ -490,6 +686,9 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
open.retain(|id| queue.iter().any(|i| i.id == *id));
|
||||
ui.data_mut(|d| d.insert_temp(state_id, (open, selected)));
|
||||
let ctx = ui.ctx().clone();
|
||||
for (it, f) in forms {
|
||||
open_menu_form(app, &it, &f);
|
||||
}
|
||||
for (id, params) in actions {
|
||||
if let Err(e) = crate::menus::invoke(app, &ctx, id, params) {
|
||||
app.ui.status = e;
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
//! Edit ▸ Templates ▸ Render Settings… / Output Module…: the Defaults (which template new
|
||||
//! Render Queue items, frames, pre-renders and proxies start from) and the template list
|
||||
//! (settings of the selected template; Duplicate, Delete, New from a Render Queue item).
|
||||
//!
|
||||
//! Every action runs a `renderQueue.*Template*` engine command. Automation ids:
|
||||
//! `templates.default.<Slot>`, `templates.select`, `templates.duplicate`, `templates.delete`,
|
||||
//! `templates.newName`, `templates.saveFromItem`, `templates.ok`.
|
||||
|
||||
use effectcraft_engine::project::render_templates::{RenderTemplates, TemplateKind, TemplateSlot};
|
||||
use egui::{Color32, vec2};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use crate::theme::Tokens;
|
||||
use crate::{Dialog, EffectcraftApp};
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
struct State {
|
||||
output: bool,
|
||||
selected: String,
|
||||
new_name: String,
|
||||
}
|
||||
|
||||
fn state_id() -> egui::Id {
|
||||
egui::Id::new("rq-templates-dialog")
|
||||
}
|
||||
|
||||
/// Open the dialog for `kind` (`renderSettings` | `outputModule`).
|
||||
pub fn open(app: &mut EffectcraftApp, ctx: &egui::Context, kind: &str) {
|
||||
let output = TemplateKind::parse(kind) == Some(TemplateKind::OutputModule);
|
||||
let t = &app.session.project.render_templates;
|
||||
let k = if output { TemplateKind::OutputModule } else { TemplateKind::RenderSettings };
|
||||
let selected = t.default_name(k, TemplateSlot::Movie);
|
||||
ctx.data_mut(|d| d.insert_temp(state_id(), State { output, selected, new_name: String::new() }));
|
||||
app.dialog = Some(Dialog::RenderTemplates);
|
||||
}
|
||||
|
||||
fn names(t: &RenderTemplates, output: bool) -> Vec<String> {
|
||||
if output { t.output_module_list().into_iter().map(|m| m.name).collect() } else { t.render_settings_list().into_iter().map(|r| r.name).collect() }
|
||||
}
|
||||
|
||||
pub fn show(app: &mut EffectcraftApp, ctx: &egui::Context, t: &Tokens) {
|
||||
let mut st: State = ctx.data(|d| d.get_temp(state_id())).unwrap_or_default();
|
||||
let kind = if st.output { "outputModule" } else { "renderSettings" };
|
||||
let k = if st.output { TemplateKind::OutputModule } else { TemplateKind::RenderSettings };
|
||||
let templates = app.session.project.render_templates.clone();
|
||||
let list = names(&templates, st.output);
|
||||
if !list.contains(&st.selected) {
|
||||
st.selected = list.first().cloned().unwrap_or_default();
|
||||
}
|
||||
let mut actions: Vec<(&'static str, Value)> = vec![];
|
||||
let mut close = false;
|
||||
let title = if st.output { "Output Module Templates" } else { "Render Settings Templates" };
|
||||
super::dialogs::modal(ctx, title, vec2(600.0, 560.0), t, |ui| {
|
||||
ui.label(egui::RichText::new("Defaults").font(Tokens::semibold(12.5)).color(t.text));
|
||||
egui::Grid::new("tpl-defaults").num_columns(2).spacing(vec2(14.0, 6.0)).show(ui, |ui| {
|
||||
for slot in TemplateSlot::ALL {
|
||||
ui.label(slot.label());
|
||||
let cur = templates.default_name(k, slot);
|
||||
let mut pick = cur.clone();
|
||||
let r = egui::ComboBox::from_id_salt(("tpl-def", slot.label())).selected_text(&cur).width(300.0).show_ui(ui, |ui| {
|
||||
for n in &list {
|
||||
ui.selectable_value(&mut pick, n.clone(), n);
|
||||
}
|
||||
});
|
||||
app.auto.add(&format!("templates.default.{slot:?}"), r.response.rect, &cur);
|
||||
if pick != cur {
|
||||
actions.push(("renderQueue.setTemplateDefault", json!({"kind": kind, "slot": format!("{slot:?}"), "name": pick})));
|
||||
}
|
||||
ui.end_row();
|
||||
}
|
||||
});
|
||||
ui.add_space(12.0);
|
||||
ui.separator();
|
||||
ui.label(egui::RichText::new("Settings").font(Tokens::semibold(12.5)).color(t.text));
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Settings Name:");
|
||||
let r = egui::ComboBox::from_id_salt("tpl-select").selected_text(&st.selected).width(300.0).show_ui(ui, |ui| {
|
||||
for n in &list {
|
||||
ui.selectable_value(&mut st.selected, n.clone(), n);
|
||||
}
|
||||
});
|
||||
app.auto.add("templates.select", r.response.rect, &st.selected);
|
||||
});
|
||||
let builtin = RenderTemplates::is_builtin(k, &st.selected)
|
||||
&& !match k {
|
||||
TemplateKind::RenderSettings => templates.render_settings.iter().any(|r| r.name.eq_ignore_ascii_case(&st.selected)),
|
||||
TemplateKind::OutputModule => templates.output_modules.iter().any(|m| m.name.eq_ignore_ascii_case(&st.selected)),
|
||||
};
|
||||
// The selected template's settings.
|
||||
let lines: Vec<(&'static str, String)> = if st.output {
|
||||
templates.output_module(&st.selected).map(|m| m.describe()).unwrap_or_default()
|
||||
} else {
|
||||
templates.render_settings(&st.selected).map(|r| r.describe(None)).unwrap_or_default()
|
||||
};
|
||||
egui::Frame::new().fill(t.field_bg).inner_margin(egui::Margin::same(8)).show(ui, |ui| {
|
||||
ui.set_min_height(180.0);
|
||||
ui.set_width(ui.available_width());
|
||||
egui::ScrollArea::vertical().max_height(200.0).show(ui, |ui| {
|
||||
egui::Grid::new("tpl-lines").num_columns(2).spacing(vec2(12.0, 2.0)).show(ui, |ui| {
|
||||
for (k, v) in &lines {
|
||||
ui.label(egui::RichText::new(*k).color(t.text_dim).size(11.5));
|
||||
ui.label(egui::RichText::new(v).size(11.5));
|
||||
ui.end_row();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
ui.horizontal(|ui| {
|
||||
let r = ui.button("Duplicate");
|
||||
app.auto.add("templates.duplicate", r.rect, "Duplicate");
|
||||
if r.clicked() {
|
||||
let mut n = format!("{} copy", st.selected);
|
||||
let mut i = 2;
|
||||
while list.iter().any(|x| x.eq_ignore_ascii_case(&n)) {
|
||||
n = format!("{} copy {i}", st.selected);
|
||||
i += 1;
|
||||
}
|
||||
actions.push(("renderQueue.saveTemplate", json!({"kind": kind, "name": n, "from": st.selected})));
|
||||
st.selected = n;
|
||||
}
|
||||
let r = ui.add_enabled(!builtin, egui::Button::new("Delete"));
|
||||
app.auto.add("templates.delete", r.rect, "Delete");
|
||||
if r.clicked() {
|
||||
actions.push(("renderQueue.deleteTemplate", json!({"kind": kind, "name": st.selected})));
|
||||
}
|
||||
if builtin {
|
||||
ui.label(egui::RichText::new("built-in").color(t.text_faint).size(11.0));
|
||||
}
|
||||
});
|
||||
ui.add_space(8.0);
|
||||
ui.separator();
|
||||
// New template from the selected (or only) Render Queue item.
|
||||
let queue = &app.session.project.render_queue;
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("New from Render Queue item:");
|
||||
let r = ui.add(egui::TextEdit::singleline(&mut st.new_name).hint_text("template name").desired_width(180.0));
|
||||
app.auto.add("templates.newName", r.rect, &st.new_name);
|
||||
let item = queue.last().map(|i| i.id);
|
||||
let ok = item.is_some() && !st.new_name.trim().is_empty();
|
||||
let r = ui.add_enabled(ok, egui::Button::new(format!("Save from #{}", queue.len().max(1))));
|
||||
app.auto.add("templates.saveFromItem", r.rect, "Save from item");
|
||||
if r.clicked()
|
||||
&& let Some(id) = item
|
||||
{
|
||||
actions.push(("renderQueue.saveTemplate", json!({"kind": kind, "name": st.new_name.trim(), "item": id})));
|
||||
st.selected = st.new_name.trim().to_string();
|
||||
st.new_name.clear();
|
||||
}
|
||||
});
|
||||
ui.add_space(12.0);
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
let r = ui.add(egui::Button::new(egui::RichText::new(" OK ").color(Color32::WHITE)).fill(t.accent));
|
||||
app.auto.add("templates.ok", r.rect, "OK");
|
||||
close = r.clicked();
|
||||
});
|
||||
});
|
||||
for (id, p) in actions {
|
||||
if let Err(e) = app.session.execute(id, p) {
|
||||
app.ui.status = e.to_string();
|
||||
}
|
||||
}
|
||||
ctx.data_mut(|d| d.insert_temp(state_id(), st));
|
||||
if close || ctx.input(|i| i.key_pressed(egui::Key::Escape)) {
|
||||
app.dialog = None;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,321 @@
|
||||
//! ScriptUI windows: the dialogs, palettes and dockable panels scripts build
|
||||
//! (`Session::script_ui`). Each control is drawn at the bounds the engine's ScriptUI layout
|
||||
//! computed; what the user does goes back through the `scriptui.click` / `scriptui.set` /
|
||||
//! `scriptui.close` commands, which run the script's handlers. Every control registers an
|
||||
//! automation id `scriptui.<window>.<control>` (and `scriptui.<window>.<name>` when the script
|
||||
//! named it).
|
||||
|
||||
use effectcraft_engine::scriptui::{ScriptWindow, Widget, WidgetKind, WindowKind, layout};
|
||||
use egui::{Align2, Color32, Rect, Sense, Stroke, StrokeKind, UiBuilder, pos2, vec2};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use crate::EffectcraftApp;
|
||||
use crate::dock::PanelKind;
|
||||
use crate::theme::Tokens;
|
||||
|
||||
enum Act {
|
||||
Click(u32, u32),
|
||||
Set(u32, u32, Value),
|
||||
Close(u32),
|
||||
}
|
||||
|
||||
fn rect_of(origin: egui::Pos2, b: [f64; 4]) -> Rect {
|
||||
Rect::from_min_size(origin + vec2(b[0] as f32, b[1] as f32), vec2(b[2] as f32, b[3] as f32))
|
||||
}
|
||||
|
||||
fn register(app: &mut EffectcraftApp, win: u32, w: &Widget, rect: Rect) {
|
||||
let label = if w.text.is_empty() { format!("{:?}", w.kind) } else { w.text.clone() };
|
||||
app.auto.add(&format!("scriptui.{win}.{}", w.id), rect, &label);
|
||||
if !w.name.is_empty() {
|
||||
app.auto.add(&format!("scriptui.{win}.{}", w.name), rect, &label);
|
||||
}
|
||||
}
|
||||
|
||||
/// Draw `w`'s children (and, for containers, their children) at `origin` + bounds.
|
||||
fn draw_children(app: &mut EffectcraftApp, ui: &mut egui::Ui, origin: egui::Pos2, win: u32, w: &Widget, acts: &mut Vec<Act>) {
|
||||
let t = app.tokens;
|
||||
if w.kind == WidgetKind::TabbedPanel {
|
||||
// Tab headers, then the active tab only.
|
||||
let r = rect_of(origin, w.bounds);
|
||||
let mut x = r.min.x;
|
||||
for (i, tab) in w.children.iter().enumerate() {
|
||||
let tw = (tab.text.chars().count() as f32 * 7.0 + 20.0).max(48.0);
|
||||
let hr = Rect::from_min_size(pos2(x, r.min.y), vec2(tw, 22.0));
|
||||
let active = i == w.active_tab;
|
||||
let resp = ui.interact(hr, egui::Id::new(("sui-tab", win, tab.id)), Sense::click());
|
||||
ui.painter().rect_filled(
|
||||
hr,
|
||||
3.0,
|
||||
if active {
|
||||
t.row_selected
|
||||
} else if resp.hovered() {
|
||||
t.hover
|
||||
} else {
|
||||
t.field_bg
|
||||
},
|
||||
);
|
||||
ui.painter().text(hr.center(), Align2::CENTER_CENTER, &tab.text, Tokens::ui(12.0), t.text);
|
||||
register(app, win, tab, hr);
|
||||
if resp.clicked() && !active && tab.enabled {
|
||||
acts.push(Act::Click(win, tab.id));
|
||||
}
|
||||
x += tw + 2.0;
|
||||
}
|
||||
ui.painter().rect_stroke(Rect::from_min_max(pos2(r.min.x, r.min.y + 22.0), r.max), 3.0, Stroke::new(1.0, t.field_border), StrokeKind::Inside);
|
||||
if let Some(tab) = w.children.get(w.active_tab) {
|
||||
draw_children(app, ui, origin, win, tab, acts);
|
||||
}
|
||||
return;
|
||||
}
|
||||
for c in w.children.iter().filter(|c| c.visible) {
|
||||
draw_widget(app, ui, origin, win, c, acts);
|
||||
}
|
||||
}
|
||||
|
||||
fn draw_widget(app: &mut EffectcraftApp, ui: &mut egui::Ui, origin: egui::Pos2, win: u32, w: &Widget, acts: &mut Vec<Act>) {
|
||||
let t = app.tokens;
|
||||
let rect = rect_of(origin, w.bounds);
|
||||
register(app, win, w, rect);
|
||||
let id = egui::Id::new(("sui", win, w.id));
|
||||
let tip = |r: egui::Response| if w.help_tip.is_empty() { r } else { r.on_hover_text(&w.help_tip) };
|
||||
match w.kind {
|
||||
WidgetKind::Group | WidgetKind::Tab | WidgetKind::Window | WidgetKind::TabbedPanel => draw_children(app, ui, origin, win, w, acts),
|
||||
WidgetKind::Panel => {
|
||||
let p = ui.painter();
|
||||
p.rect_stroke(rect.shrink(1.0), 4.0, Stroke::new(1.0, t.field_border), StrokeKind::Inside);
|
||||
if !w.text.is_empty() {
|
||||
let g = p.layout_no_wrap(w.text.clone(), Tokens::ui(11.5), t.text_dim);
|
||||
let at = pos2(rect.min.x + 10.0, rect.min.y - 1.0);
|
||||
p.rect_filled(Rect::from_min_size(at - vec2(3.0, 0.0), g.size() + vec2(6.0, 0.0)), 0.0, t.panel_bg);
|
||||
p.galley(at, g, t.text_dim);
|
||||
}
|
||||
draw_children(app, ui, origin, win, w, acts);
|
||||
}
|
||||
WidgetKind::Button | WidgetKind::IconButton => {
|
||||
let r = ui.add_enabled_ui(w.enabled, |ui| ui.put(rect, egui::Button::new(&w.text))).inner;
|
||||
if tip(r).clicked() {
|
||||
acts.push(Act::Click(win, w.id));
|
||||
}
|
||||
}
|
||||
WidgetKind::StaticText => {
|
||||
let col = if w.enabled { t.text } else { t.text_faint };
|
||||
ui.painter().with_clip_rect(rect.expand(2.0)).text(pos2(rect.min.x, rect.min.y + 1.0), Align2::LEFT_TOP, &w.text, Tokens::ui(12.0), col);
|
||||
}
|
||||
WidgetKind::EditText => {
|
||||
// The text being typed lives here until the field loses focus (then onChange).
|
||||
let mut buf: String = ui.data(|d| d.get_temp::<String>(id)).unwrap_or_else(|| w.text.clone());
|
||||
let focused = ui.memory(|m| m.has_focus(id));
|
||||
if !focused {
|
||||
buf = w.text.clone();
|
||||
}
|
||||
let te = if w.multiline { egui::TextEdit::multiline(&mut buf) } else { egui::TextEdit::singleline(&mut buf) };
|
||||
let te = te.id(id).interactive(!w.read_only).font(Tokens::ui(12.0));
|
||||
let r = ui.add_enabled_ui(w.enabled, |ui| ui.put(rect, te)).inner;
|
||||
let r = tip(r);
|
||||
if r.lost_focus() && buf != w.text {
|
||||
acts.push(Act::Set(win, w.id, json!(buf)));
|
||||
}
|
||||
ui.data_mut(|d| d.insert_temp(id, buf));
|
||||
}
|
||||
WidgetKind::Checkbox => {
|
||||
let mut v = w.checked;
|
||||
let r = ui.add_enabled_ui(w.enabled, |ui| ui.put(snug(rect, &w.text), egui::Checkbox::new(&mut v, &w.text))).inner;
|
||||
if tip(r).clicked() {
|
||||
acts.push(Act::Click(win, w.id));
|
||||
}
|
||||
}
|
||||
WidgetKind::RadioButton => {
|
||||
let r = ui.add_enabled_ui(w.enabled, |ui| ui.put(snug(rect, &w.text), egui::RadioButton::new(w.checked, &w.text))).inner;
|
||||
if tip(r).clicked() && !w.checked {
|
||||
acts.push(Act::Click(win, w.id));
|
||||
}
|
||||
}
|
||||
WidgetKind::Slider | WidgetKind::Scrollbar => {
|
||||
// While dragging, the value lives here; the release sends it (onChanging / onChange).
|
||||
let mut v: f64 = ui.data(|d| d.get_temp::<f64>(id)).unwrap_or(w.value);
|
||||
let (lo, hi) = if w.max > w.min { (w.min, w.max) } else { (0.0, 100.0) };
|
||||
let r = ui
|
||||
.add_enabled_ui(w.enabled, |ui| {
|
||||
ui.scope_builder(UiBuilder::new().max_rect(rect), |ui| {
|
||||
ui.spacing_mut().slider_width = rect.width() - 4.0;
|
||||
ui.add(egui::Slider::new(&mut v, lo..=hi).show_value(false))
|
||||
})
|
||||
.inner
|
||||
})
|
||||
.inner;
|
||||
let r = tip(r);
|
||||
if r.dragged() {
|
||||
ui.data_mut(|d| d.insert_temp(id, v));
|
||||
} else {
|
||||
ui.data_mut(|d| d.remove::<f64>(id));
|
||||
if r.drag_stopped() || r.changed() {
|
||||
acts.push(Act::Set(win, w.id, json!(v)));
|
||||
}
|
||||
}
|
||||
}
|
||||
WidgetKind::Progressbar => {
|
||||
let span = if w.max > w.min { w.max - w.min } else { 100.0 };
|
||||
let f = ((w.value - w.min) / span).clamp(0.0, 1.0) as f32;
|
||||
ui.put(rect, egui::ProgressBar::new(f).desired_height(rect.height()));
|
||||
}
|
||||
WidgetKind::DropDownList => {
|
||||
let cur = w.selection.first().and_then(|i| w.items.get(*i)).cloned().unwrap_or_default();
|
||||
let mut pick: Option<usize> = None;
|
||||
ui.add_enabled_ui(w.enabled, |ui| {
|
||||
ui.scope_builder(UiBuilder::new().max_rect(rect), |ui| {
|
||||
egui::ComboBox::from_id_salt(id).selected_text(cur).width(rect.width() - 8.0).show_ui(ui, |ui| {
|
||||
for (i, it) in w.items.iter().enumerate() {
|
||||
if it == "-" {
|
||||
ui.separator();
|
||||
} else if ui.selectable_label(w.selection.contains(&i), it).clicked() {
|
||||
pick = Some(i);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
if let Some(i) = pick
|
||||
&& !w.selection.contains(&i)
|
||||
{
|
||||
acts.push(Act::Set(win, w.id, json!(i)));
|
||||
}
|
||||
}
|
||||
WidgetKind::ListBox => {
|
||||
let mut pick: Option<usize> = None;
|
||||
ui.painter().rect_filled(rect, 2.0, t.field_bg);
|
||||
ui.add_enabled_ui(w.enabled, |ui| {
|
||||
ui.scope_builder(UiBuilder::new().max_rect(rect.shrink(2.0)), |ui| {
|
||||
egui::ScrollArea::vertical().id_salt(id).max_height(rect.height() - 4.0).show(ui, |ui| {
|
||||
ui.set_width(rect.width() - 8.0);
|
||||
for (i, it) in w.items.iter().enumerate() {
|
||||
if ui.selectable_label(w.selection.contains(&i), it).clicked() {
|
||||
pick = Some(i);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
if let Some(i) = pick {
|
||||
acts.push(Act::Set(win, w.id, json!(i)));
|
||||
}
|
||||
}
|
||||
WidgetKind::Image | WidgetKind::Unknown => {
|
||||
ui.painter().rect_stroke(rect, 2.0, Stroke::new(1.0, t.field_border), StrokeKind::Inside);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Checkboxes and radio buttons sit at the left of their (possibly filled) bounds.
|
||||
fn snug(r: Rect, text: &str) -> Rect {
|
||||
let w = (text.chars().count() as f32 * 7.0 + 26.0).min(r.width());
|
||||
Rect::from_min_size(r.min, vec2(w, r.height()))
|
||||
}
|
||||
|
||||
fn perform(app: &mut EffectcraftApp, ctx: &egui::Context, acts: Vec<Act>) {
|
||||
for a in acts {
|
||||
let (cmd, p) = match a {
|
||||
Act::Click(w, id) => ("scriptui.click", json!({"window": w, "widget": id})),
|
||||
Act::Set(w, id, v) => ("scriptui.set", json!({"window": w, "widget": id, "value": v})),
|
||||
Act::Close(w) => ("scriptui.close", json!({"window": w})),
|
||||
};
|
||||
match crate::menus::invoke(app, ctx, cmd, p) {
|
||||
Ok(r) => {
|
||||
if let Some(e) = r.get("error").filter(|e| !e.is_null()) {
|
||||
let msg = e["message"].as_str().unwrap_or("script error").to_string();
|
||||
app.toast = Some((msg, ctx.input(|i| i.time)));
|
||||
} else if let Some(o) = r["output"].as_str().filter(|o| !o.is_empty()) {
|
||||
app.ui.status = o.lines().last().unwrap_or_default().to_string();
|
||||
}
|
||||
}
|
||||
Err(e) => app.ui.status = e,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The floating script windows (dialogs, palettes, windows), drawn over the app.
|
||||
pub fn show_windows(app: &mut EffectcraftApp, ctx: &egui::Context) {
|
||||
let windows: Vec<ScriptWindow> = app.session.script_ui.windows.iter().filter(|w| w.kind != WindowKind::Panel).cloned().collect();
|
||||
if windows.is_empty() {
|
||||
return;
|
||||
}
|
||||
let t = app.tokens;
|
||||
let mut acts = vec![];
|
||||
let screen = ctx.content_rect();
|
||||
if windows.iter().any(|w| w.modal) {
|
||||
// A modal dialog blocks the app behind it, as in After Effects.
|
||||
let r = egui::Area::new(egui::Id::new("scriptui-modal-block")).order(egui::Order::Middle).fixed_pos(screen.min).show(ctx, |ui| {
|
||||
ui.allocate_exact_size(screen.size(), Sense::click_and_drag());
|
||||
ui.painter().rect_filled(screen, 0.0, Color32::from_black_alpha(90));
|
||||
});
|
||||
let _ = r;
|
||||
}
|
||||
for w in &windows {
|
||||
let size = vec2(w.root.bounds[2] as f32, w.root.bounds[3] as f32);
|
||||
let mut open = true;
|
||||
let order = if w.modal { egui::Order::Foreground } else { egui::Order::Middle };
|
||||
let resp = egui::Window::new(if w.title.is_empty() { &w.script } else { &w.title })
|
||||
.id(egui::Id::new(("scriptui-window", w.id)))
|
||||
.order(order)
|
||||
.collapsible(false)
|
||||
.resizable(false)
|
||||
.open(&mut open)
|
||||
.default_pos(screen.center() - size / 2.0)
|
||||
.frame(egui::Frame::window(&ctx.global_style()).fill(t.panel_bg))
|
||||
.show(ctx, |ui| {
|
||||
let (rect, _) = ui.allocate_exact_size(size, Sense::hover());
|
||||
draw_children(app, ui, rect.min, w.id, &w.root, &mut acts);
|
||||
rect
|
||||
});
|
||||
if let Some(r) = resp {
|
||||
app.auto.add(&format!("scriptui.{}", w.id), r.response.rect, &w.title);
|
||||
}
|
||||
if !open {
|
||||
acts.push(Act::Close(w.id));
|
||||
}
|
||||
}
|
||||
perform(app, ctx, acts);
|
||||
}
|
||||
|
||||
/// A dockable ScriptUI panel's content (Window ▸ <panel>.jsx).
|
||||
pub fn panel(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect, id: u32) {
|
||||
let t = app.tokens;
|
||||
let Some(mut w) = app.session.script_ui.window(id).cloned() else {
|
||||
ui.painter().text(rect.center(), Align2::CENTER_CENTER, "This ScriptUI panel has closed", Tokens::ui(12.0), t.text_faint);
|
||||
return;
|
||||
};
|
||||
// Docked panels fill their frame (ScriptUI lays them out at the panel's size).
|
||||
let (pw, ph) = (rect.width() as f64, rect.height() as f64);
|
||||
w.root.fixed_bounds = Some([0.0, 0.0, pw.max(w.root.bounds[2]), ph.max(w.root.bounds[3])]);
|
||||
layout(&mut w);
|
||||
let mut acts = vec![];
|
||||
let content = rect;
|
||||
egui::ScrollArea::both().id_salt(("scriptui-panel", id)).max_width(content.width()).max_height(content.height()).show(ui, |ui| {
|
||||
let (r, _) = ui.allocate_exact_size(vec2(w.root.bounds[2] as f32, w.root.bounds[3] as f32), Sense::hover());
|
||||
draw_children(app, ui, r.min, id, &w.root, &mut acts);
|
||||
});
|
||||
app.auto.add(&format!("scriptui.{id}"), rect, &w.title);
|
||||
let ctx = ui.ctx().clone();
|
||||
perform(app, &ctx, acts);
|
||||
}
|
||||
|
||||
/// Tab title of a script panel.
|
||||
pub fn panel_title(app: &EffectcraftApp, id: u32) -> Option<String> {
|
||||
app.session.script_ui.window(id).map(|w| if w.title.is_empty() { w.script.clone() } else { w.title.clone() })
|
||||
}
|
||||
|
||||
/// Close the dock panels whose script window has gone (the script closed it, or a saved
|
||||
/// workspace from an earlier run).
|
||||
pub fn sync_panels(app: &mut EffectcraftApp) {
|
||||
let mut all = vec![];
|
||||
app.ui.dock.panels(&mut all);
|
||||
for f in &app.ui.floating {
|
||||
all.extend(f.panels.iter().copied());
|
||||
}
|
||||
for p in all {
|
||||
if let PanelKind::ScriptPanel(id) = p
|
||||
&& app.session.script_ui.window(id).is_none()
|
||||
{
|
||||
app.close_panel(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -404,6 +404,27 @@ fn mask_mode(app: &mut EffectcraftApp, ui: &mut egui::Ui, ctx: &egui::Context, p
|
||||
bx += 34.0;
|
||||
}
|
||||
y += 34.0;
|
||||
// Face Tracking (Detailed Features): Extract & Copy Face Measurements.
|
||||
let has_points = app
|
||||
.session
|
||||
.active_comp()
|
||||
.and_then(|c| c.layer(layer))
|
||||
.and_then(|l| l.effects())
|
||||
.is_some_and(|fx| fx.groups().any(|g| g.match_id == effectcraft_engine::effects::face_track::POINTS_ID));
|
||||
if method == MaskMethod::FaceDetailed || has_points {
|
||||
let r = Rect::from_min_size(pos2(x0, y), vec2(w.min(260.0), 24.0));
|
||||
if button(app, ui, r, "Extract & Copy Face Measurements", has_points && !running, "tracker.mask.extractFace") {
|
||||
match crate::menus::invoke(app, ctx, "track.extractFaceMeasurements", json!({"layer": layer.0})) {
|
||||
Ok(v) => {
|
||||
if let Some(text) = v.get("clipboard").and_then(|t| t.as_str()) {
|
||||
ctx.copy_text(text.to_string());
|
||||
}
|
||||
}
|
||||
Err(e) => app.ui.status = e,
|
||||
}
|
||||
}
|
||||
y += 32.0;
|
||||
}
|
||||
if let Some(pr) = app.session.mask_track_progress() {
|
||||
let bar = Rect::from_min_size(pos2(x0, y), vec2(w, 6.0));
|
||||
p.rect_filled(bar, 3.0, t.field_bg);
|
||||
@@ -419,7 +440,12 @@ fn mask_mode(app: &mut EffectcraftApp, ui: &mut egui::Ui, ctx: &egui::Context, p
|
||||
);
|
||||
ctx.request_repaint_after(std::time::Duration::from_millis(50));
|
||||
} else {
|
||||
p.text(pos2(x0, y + 8.0), Align2::LEFT_CENTER, "Tracks the pixels inside the mask and keys its Mask Path.", Tokens::ui(11.0), t.text_faint);
|
||||
let hint = if method.is_face() {
|
||||
"Finds the face inside the mask and keys its outline (and, with Detailed Features, Face Track Points)."
|
||||
} else {
|
||||
"Tracks the pixels inside the mask and keys its Mask Path."
|
||||
};
|
||||
p.text(pos2(x0, y + 8.0), Align2::LEFT_CENTER, hint, Tokens::ui(11.0), t.text_faint);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -121,6 +121,17 @@ enum Gesture {
|
||||
pin: u64,
|
||||
inv: Mat3,
|
||||
},
|
||||
/// Puppet tool Record mode (⌘/Ctrl-drag a pin): the drag is sampled in real time (seconds
|
||||
/// since it began, layer space) and becomes keyframes on release (`puppet.recordPin`); the
|
||||
/// current time runs along while recording.
|
||||
PuppetRecord {
|
||||
layer: LayerId,
|
||||
pin: u64,
|
||||
inv: Mat3,
|
||||
began: f64,
|
||||
cti: Tick,
|
||||
samples: Vec<(f64, [f64; 2])>,
|
||||
},
|
||||
/// Pen tool: pulling the tangents of the vertex just placed.
|
||||
Pen {
|
||||
layer: LayerId,
|
||||
@@ -404,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);
|
||||
@@ -461,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();
|
||||
@@ -491,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");
|
||||
|
||||
@@ -922,7 +945,13 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
t if t.is_shape() => Some(Gesture::Create { tool: t, start: cpt }),
|
||||
t if t.puppet_kind().is_some() => pin_hits.iter().rev().find(|h| h.pos.distance(press) < 8.0).and_then(|h| {
|
||||
let l = comp.layer(h.layer)?;
|
||||
Some(Gesture::PuppetPin { layer: h.layer, pin: h.pin, inv: l2c(&ectx, l).0.inverse()? })
|
||||
let inv = l2c(&ectx, l).0.inverse()?;
|
||||
if mods.command {
|
||||
let lp = inv.apply(gv2(cpt[0], cpt[1]));
|
||||
let began = ui.input(|i| i.time);
|
||||
return Some(Gesture::PuppetRecord { layer: h.layer, pin: h.pin, inv, began, cti: time, samples: vec![(0.0, [lp.x, lp.y])] });
|
||||
}
|
||||
Some(Gesture::PuppetPin { layer: h.layer, pin: h.pin, inv })
|
||||
}),
|
||||
Tool::Orbit | Tool::PanCamera | Tool::Dolly => Some(Gesture::Camera { tool }),
|
||||
Tool::Selection if super::tracker::hit_at(&track_hits, press).is_some() => {
|
||||
@@ -1158,6 +1187,20 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
}
|
||||
let _ = app.session.execute("mask.setVertex", params);
|
||||
}
|
||||
Gesture::PuppetRecord { layer, pin, inv, began, cti, mut samples } => {
|
||||
let lp = inv.apply(gv2(cpt[0], cpt[1]));
|
||||
let now = ui.input(|i| i.time) - began;
|
||||
if samples.last().is_none_or(|s| now > s.0) {
|
||||
samples.push((now, [lp.x, lp.y]));
|
||||
}
|
||||
// The current time runs with the recording (Record Options ▸ Speed).
|
||||
let speed = app.session.state.puppet.record_speed.max(1.0) / 100.0;
|
||||
app.session.set_time(cti + Tick::from_seconds_f64(now / speed));
|
||||
painter.circle_filled(pos, 6.0, Color32::from_rgb(0xe0, 0x30, 0x30));
|
||||
painter.text(pos + vec2(10.0, -10.0), Align2::LEFT_BOTTOM, "Recording", Tokens::ui(11.0), Color32::from_rgb(0xff, 0x60, 0x60));
|
||||
ui.data_mut(|dd| dd.insert_temp(gid, Gesture::PuppetRecord { layer, pin, inv, began, cti, samples }));
|
||||
ui.ctx().request_repaint();
|
||||
}
|
||||
Gesture::PuppetPin { layer, pin, inv } => {
|
||||
let lp = inv.apply(gv2(cpt[0], cpt[1]));
|
||||
if let Err(e) = app.session.execute("puppet.movePin", json!({"layer": layer.0, "pin": pin, "position": [lp.x, lp.y], "merge": merge})) {
|
||||
@@ -1190,6 +1233,12 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
if resp.drag_stopped() {
|
||||
if let (Some(g), Some(pos)) = (gesture, resp.interact_pointer_pos()) {
|
||||
match g {
|
||||
Gesture::PuppetRecord { layer, pin, cti, samples, .. } => {
|
||||
let pts: Vec<serde_json::Value> = samples.iter().map(|(t, p)| json!([t, p[0], p[1]])).collect();
|
||||
if let Err(e) = app.session.execute("puppet.recordPin", json!({"layer": layer.0, "pin": pin, "samples": pts, "start": cti.seconds()})) {
|
||||
app.ui.status = e.to_string();
|
||||
}
|
||||
}
|
||||
Gesture::Create { tool, start } => {
|
||||
let end = map.to_comp(pos);
|
||||
create_shape(app, tool, start, end, mods.shift);
|
||||
@@ -1654,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) {
|
||||
@@ -1672,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