# Conflicts: # crates/effects/Cargo.toml # crates/ui-egui/src/panels/mod.rs # docs/parity.md
164 lines
6.5 KiB
Rust
164 lines
6.5 KiB
Rust
//! Panel bodies.
|
|
|
|
pub mod anim_tools;
|
|
pub mod comp_settings;
|
|
pub mod dialogs;
|
|
pub mod dialogs_3d;
|
|
pub mod effect_controls;
|
|
pub mod effects_presets;
|
|
pub mod forms;
|
|
pub mod fx_widgets;
|
|
pub mod graph;
|
|
pub mod graph_tools;
|
|
pub mod info;
|
|
pub mod key_dialogs;
|
|
pub mod layer_panel;
|
|
pub mod markers_ui;
|
|
pub mod misc;
|
|
pub mod paint_panels;
|
|
pub mod precomp;
|
|
pub mod project;
|
|
pub mod properties;
|
|
pub mod puppet_tool;
|
|
pub mod render_queue;
|
|
pub mod roto_tool;
|
|
pub mod script_console;
|
|
pub mod settings;
|
|
pub mod shortcut_editor;
|
|
pub mod text_panels;
|
|
pub mod timeline;
|
|
pub mod tracker;
|
|
pub mod viewer;
|
|
pub mod viewer_overlays;
|
|
pub mod viewer_text;
|
|
pub mod viewer_tools;
|
|
pub mod waveform;
|
|
|
|
use effectcraft_engine::Session;
|
|
use effectcraft_engine::project::{Comp, TimeDisplayStyle};
|
|
use effectcraft_engine::time::Tick;
|
|
use egui::Rect;
|
|
|
|
use crate::EffectcraftApp;
|
|
use crate::dock::PanelKind;
|
|
|
|
/// Drag-and-drop payloads between panels.
|
|
#[derive(Clone, Debug)]
|
|
pub enum DragPayload {
|
|
/// A project item (footage, comp, solid).
|
|
Item(u64),
|
|
/// An effect id from Effects & Presets.
|
|
Effect(String),
|
|
}
|
|
|
|
/// The current time formatted per project settings (timecode with `;` for drop-frame, or frames).
|
|
pub fn timecode(session: &Session, comp: &Comp, t: Tick) -> String {
|
|
let fr = comp.frame_rate;
|
|
match session.project.settings.time_display {
|
|
TimeDisplayStyle::Frames => format!("{:05}", fr.frame_at(t) + session.project.settings.frame_start),
|
|
// AE's display: `0:00:02:15` (non-drop-frame counting, as AE shows new comps).
|
|
TimeDisplayStyle::Timecode => effectcraft_engine::time::format_timecode_ae(fr.frame_at(t + comp.display_start), fr, false),
|
|
}
|
|
}
|
|
|
|
pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, p: PanelKind, rect: Rect) {
|
|
match p {
|
|
PanelKind::Composition => {
|
|
if app.ui.start_screen {
|
|
misc::start_screen(app, ui, rect);
|
|
} else {
|
|
viewer::show(app, ui, rect)
|
|
}
|
|
}
|
|
PanelKind::Timeline => timeline::show(app, ui, rect),
|
|
PanelKind::Project => project::show(app, ui, rect),
|
|
PanelKind::EffectControls => effect_controls::show(app, ui, rect),
|
|
PanelKind::EffectsPresets => effects_presets::show(app, ui, rect),
|
|
PanelKind::Info => info::show(app, ui, rect),
|
|
PanelKind::Preview => misc::preview(app, ui, rect),
|
|
PanelKind::Character => text_panels::character(app, ui, rect),
|
|
PanelKind::Paragraph => text_panels::paragraph(app, ui, rect),
|
|
PanelKind::Align => text_panels::align(app, ui, rect),
|
|
PanelKind::Properties => properties::show(app, ui, rect),
|
|
PanelKind::Audio => misc::audio(app, ui, rect),
|
|
PanelKind::History => misc::history(app, ui, rect),
|
|
PanelKind::Markers => misc::markers(app, ui, rect),
|
|
PanelKind::MaskInterpolation => anim_tools::mask_interpolation(app, ui, rect),
|
|
PanelKind::ScriptConsole => script_console::show(app, ui, rect),
|
|
PanelKind::Wiggler => anim_tools::wiggler(app, ui, rect),
|
|
PanelKind::Smoother => anim_tools::smoother(app, ui, rect),
|
|
PanelKind::MotionSketch => anim_tools::motion_sketch(app, ui, rect),
|
|
PanelKind::RenderQueue => render_queue::show(app, ui, rect),
|
|
PanelKind::Tracker => tracker::show(app, ui, rect),
|
|
PanelKind::Layer => layer_panel::show(app, ui, rect),
|
|
PanelKind::Paint => paint_panels::paint(app, ui, rect),
|
|
PanelKind::Brushes => paint_panels::brushes(app, ui, rect),
|
|
other => misc::placeholder(app, ui, rect, other),
|
|
}
|
|
}
|
|
|
|
/// The ≡ panel menu (opened from a tab).
|
|
pub fn panel_menu_popup(app: &mut EffectcraftApp, ui: &mut egui::Ui) {
|
|
let id = egui::Id::new("panel-menu");
|
|
let Some((panel, pos)) = ui.ctx().data(|d| d.get_temp::<(PanelKind, egui::Pos2)>(id)) else { return };
|
|
let mut close = false;
|
|
let area = egui::Area::new(id.with("area")).order(egui::Order::Foreground).fixed_pos(pos).show(ui.ctx(), |ui| {
|
|
egui::Frame::popup(ui.style()).show(ui, |ui| {
|
|
ui.set_min_width(200.0);
|
|
if ui.button("Close Panel").clicked() {
|
|
app.close_panel(panel);
|
|
close = true;
|
|
}
|
|
let floating = app.ui.floating.iter().any(|f| f.panels.contains(&panel));
|
|
if !floating && ui.button("Undock Panel").clicked() {
|
|
let r = crate::dock_ui::default_float_rect(ui.ctx().content_rect());
|
|
app.edit_layout(|l| l.float(panel, r));
|
|
close = true;
|
|
}
|
|
if !floating && ui.button(if app.ui.maximized == Some(panel) { "Restore Panel Size" } else { "Maximize Panel" }).clicked() {
|
|
app.toggle_maximize(panel);
|
|
close = true;
|
|
}
|
|
ui.separator();
|
|
match panel {
|
|
PanelKind::Timeline => {
|
|
for (label, id) in [
|
|
("Hide Shy Layers", "hideShy"),
|
|
("Enable Frame Blending", "frameBlending"),
|
|
("Enable Motion Blur", "motionBlur"),
|
|
("Draft 3D", "draft3d"),
|
|
] {
|
|
if ui.button(label).clicked() {
|
|
let _ = app.session.execute("comp.setSwitch", serde_json::json!({"switch": id}));
|
|
close = true;
|
|
}
|
|
}
|
|
if ui.button("Composition Settings…").clicked() {
|
|
let _ = dialogs::open_comp_settings(app);
|
|
close = true;
|
|
}
|
|
}
|
|
PanelKind::Composition => {
|
|
for (label, cmd) in [
|
|
("Composition Settings…", "app.compSettings"),
|
|
("View Options…", "view.layerControls"),
|
|
("Show Grid", "view.grid"),
|
|
("Title/Action Safe", "view.safeMargins"),
|
|
] {
|
|
if ui.button(label).clicked() {
|
|
let _ = crate::menus::invoke(app, &ui.ctx().clone(), cmd, serde_json::json!({}));
|
|
close = true;
|
|
}
|
|
}
|
|
}
|
|
_ => {
|
|
ui.label(egui::RichText::new(panel.title()).weak());
|
|
}
|
|
}
|
|
});
|
|
});
|
|
if close || (ui.input(|i| i.pointer.any_pressed()) && !area.response.contains_pointer() && !area.response.hovered()) {
|
|
ui.ctx().data_mut(|d| d.remove::<(PanelKind, egui::Pos2)>(id));
|
|
}
|
|
}
|