Most panels lay out their own rows and scrolled only with the mouse wheel: Effect Controls, Effects & Presets, the Media Browser, Ease Presets and the Timeline's layer rows had no scroll bar, Properties and Preview a thin indicator that couldn't be dragged, and Render Queue, History, Markers, Character, Paragraph and Info didn't scroll at all, so a panel shorter than its content cut it off. Without a wheel or a working touchpad there was no way down. The Project panel had the only real scroll bars, hand-rolled, and its vertical one was hit-tested under the rows, so it only dragged where no row was. - widgets::scroll_bar: the Project panel's bars generalised (horizontal or vertical, drag the thumb or press the track to move it there, automation id with "scroll/max"); the Project panel's two bars and the Timeline's column bar use it, drawn over the rows. - widgets::PanelScroll: the wheel offset, its clamping and the bar for a panel's own rows, used by Effect Controls, Properties, Effects & Presets, Media Browser, Ease Presets, Preview, Render Queue, History (which still follows the current state), Markers, Character, Paragraph and Info. The Timeline's layer rows get a bar on the right edge. - Effect Controls: an animated vector's values (a puppet pin's Position) ran under the keyframe navigator in a narrow panel. They now end before it, moving left over the name, which is cut short. Test: ui_scrolling panels_taller_than_their_space_have_a_scroll_bar_to_drag (eleven panels in a short window: a press on the track and a thumb drag scroll them), effect_values_stay_clear_of_the_keyframe_navigator. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
131 lines
6.9 KiB
Rust
131 lines
6.9 KiB
Rust
//! Info panel: colour and position under the pointer, plus the current selection.
|
|
|
|
use egui::{Align2, Color32, Rect, pos2, vec2};
|
|
|
|
use crate::theme::Tokens;
|
|
use crate::{EffectcraftApp, widgets};
|
|
|
|
pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
|
let t = app.tokens;
|
|
let p = ui.painter().with_clip_rect(rect);
|
|
let x0 = rect.min.x + 12.0;
|
|
let scroll = widgets::PanelScroll::begin(ui, egui::Id::new("info-scroll"), rect);
|
|
let mut y = rect.min.y + 14.0 - scroll.offset;
|
|
if app.pointer_comp.is_some() {
|
|
// GPU frames: read the shown frame back for sampling.
|
|
app.viewer_pixels();
|
|
}
|
|
let (rgba, xy) = match (app.pointer_comp, &app.viewer_image) {
|
|
(Some([cx, cy]), Some(img)) => {
|
|
let comp = app.session.active_comp();
|
|
let (cw, ch) = comp.map(|c| (c.width as f32, c.height as f32)).unwrap_or((1.0, 1.0));
|
|
let sx = (cx / cw * img.size[0] as f32) as i64;
|
|
let sy = (cy / ch * img.size[1] as f32) as i64;
|
|
let px = if sx >= 0 && sy >= 0 && (sx as usize) < img.size[0] && (sy as usize) < img.size[1] {
|
|
Some(img.pixels[sy as usize * img.size[0] + sx as usize])
|
|
} else {
|
|
None
|
|
};
|
|
(px, Some((cx, cy)))
|
|
}
|
|
_ => (None, None),
|
|
};
|
|
let row = |p: &egui::Painter, y: f32, k: &str, v: String, col: Color32| {
|
|
p.text(pos2(x0, y), Align2::LEFT_CENTER, k, Tokens::ui(12.0), col);
|
|
p.text(pos2(x0 + 22.0, y), Align2::LEFT_CENTER, v, Tokens::mono(12.0), t.text);
|
|
};
|
|
let unpre = |c: Color32| -> [u8; 4] {
|
|
let a = c.a();
|
|
if a == 0 {
|
|
[0, 0, 0, 0]
|
|
} else {
|
|
let f = |v: u8| ((v as u32 * 255 + a as u32 / 2) / a as u32).min(255) as u8;
|
|
[f(c.r()), f(c.g()), f(c.b()), a]
|
|
}
|
|
};
|
|
let px = rgba.map(unpre).unwrap_or([0, 0, 0, 0]);
|
|
row(&p, y, "R :", format!("{}", px[0]), Color32::from_rgb(0xe0, 0x60, 0x60));
|
|
row(&p, y + 18.0, "G :", format!("{}", px[1]), Color32::from_rgb(0x60, 0xd0, 0x60));
|
|
row(&p, y + 36.0, "B :", format!("{}", px[2]), Color32::from_rgb(0x60, 0x90, 0xf0));
|
|
row(&p, y + 54.0, "A :", format!("{}", px[3]), t.text_dim);
|
|
let cx = rect.min.x + rect.width() * 0.5;
|
|
if let Some((x, yy)) = xy {
|
|
p.text(pos2(cx, y), Align2::LEFT_CENTER, format!("X : {x:.0}"), Tokens::mono(12.0), t.text);
|
|
p.text(pos2(cx, y + 18.0), Align2::LEFT_CENTER, format!("Y : {yy:.0}"), Tokens::mono(12.0), t.text);
|
|
}
|
|
if let Some(c) = rgba {
|
|
let sw = egui::Rect::from_min_size(pos2(cx, y + 34.0), vec2(36.0, 30.0));
|
|
p.rect_filled(sw, 3.0, Color32::from_rgb(px[0], px[1], px[2]));
|
|
let _ = c;
|
|
}
|
|
y += 82.0;
|
|
p.line_segment([pos2(rect.min.x + 8.0, y), pos2(rect.max.x - 8.0, y)], egui::Stroke::new(1.0, t.separator));
|
|
y += 14.0;
|
|
let mut bottom = y;
|
|
let comp = app.session.active_comp_arc();
|
|
if let Some(c) = comp {
|
|
let sel: Vec<String> = app.session.state.selected_layers.iter().filter_map(|id| c.layer(*id)).map(|l| l.name.clone()).collect();
|
|
let tc = crate::panels::timecode(&app.session, &c, app.session.time());
|
|
p.text(pos2(x0, y), Align2::LEFT_CENTER, if sel.is_empty() { "No layer selected".to_string() } else { sel.join(", ") }, Tokens::semibold(12.0), t.text);
|
|
p.text(pos2(x0, y + 18.0), Align2::LEFT_CENTER, format!("Time: {tc}"), Tokens::ui(12.0), t.text_dim);
|
|
// One layer selected: Duration, In and Out like AE's Info panel.
|
|
let mut ly = y + 36.0;
|
|
if let [id] = app.session.state.selected_layers.as_slice()
|
|
&& let Some(l) = c.layer(*id)
|
|
{
|
|
let tc = |t| crate::panels::timecode(&app.session, &c, t);
|
|
let lines = [
|
|
// A length, so no start-timecode offset.
|
|
format!("Duration: {}", {
|
|
let fr = c.frame_rate;
|
|
let n = fr.frame_at(l.out_point) - fr.frame_at(l.in_point);
|
|
let s = effectcraft_engine::time::format_timecode_frames(n, fr, fr.supports_drop_frame());
|
|
if fr.supports_drop_frame() { s } else { s.replace(';', ":") }
|
|
}),
|
|
format!("In: {}, Out: {}", tc(l.in_point), tc(effectcraft_engine::time::Tick(l.out_point.0 - c.frame_duration().0))),
|
|
];
|
|
for line in lines {
|
|
p.text(pos2(x0, ly), Align2::LEFT_CENTER, line, Tokens::ui(12.0), t.text_dim);
|
|
ly += 18.0;
|
|
}
|
|
}
|
|
// While a preview plays: the frame rate it achieves and whether that is real time.
|
|
if let (Some(fps), Some(rt)) = (app.playback.achieved_fps(), app.playback.real_time()) {
|
|
let note = if rt { "real-time" } else { "not real-time" };
|
|
p.text(pos2(x0, ly), Align2::LEFT_CENTER, format!("{fps:.2} fps ({note})"), Tokens::ui(11.5), if rt { t.text_dim } else { t.warning });
|
|
app.auto.add("info.previewFps", Rect::from_min_size(pos2(x0, ly - 8.0), vec2(200.0, 16.0)), &format!("{fps:.2} fps ({note})"));
|
|
ly += 18.0;
|
|
}
|
|
// Settings ▸ Composition ▸ Show Rendering Progress in Info Panel.
|
|
if app.session.prefs.composition.show_rendering_progress {
|
|
let ms = app.frames.last_ms.lock().map(|v| *v).unwrap_or(0.0);
|
|
let rq = app.session.render_job.as_ref().map(|_| " • Rendering queue…").unwrap_or("");
|
|
p.text(pos2(x0, ly), Align2::LEFT_CENTER, format!("Render: {ms:.0} ms • UI {:.0} fps{rq}", app.fps), Tokens::ui(11.5), t.text_faint);
|
|
}
|
|
if !app.session.state.selected_keys.is_empty() {
|
|
// One key: its property, time and value (as After Effects' Info panel shows them).
|
|
let sel = &app.session.state.selected_keys;
|
|
let one = match sel.as_slice() {
|
|
[k] => c.layer(k.layer).and_then(|l| {
|
|
let pr = l.props.find(k.prop)?;
|
|
let key = pr.keys.iter().find(|x| x.time == k.time)?;
|
|
let tc = crate::panels::timecode(&app.session, &c, l.comp_time(k.time));
|
|
let v = match &key.value {
|
|
effectcraft_engine::keyframe::Value::Scalar(v) => format!("{v:.2}"),
|
|
effectcraft_engine::keyframe::Value::Vec2(v) => format!("{:.1}, {:.1}", v[0], v[1]),
|
|
effectcraft_engine::keyframe::Value::Vec3(v) => format!("{:.1}, {:.1}, {:.1}", v[0], v[1], v[2]),
|
|
_ => String::new(),
|
|
};
|
|
Some(format!("{} {tc} {v}", pr.name).trim_end().to_string())
|
|
}),
|
|
_ => None,
|
|
};
|
|
let line = one.unwrap_or_else(|| format!("{} keyframes selected", sel.len()));
|
|
p.text(pos2(x0, ly + 18.0), Align2::LEFT_CENTER, line, Tokens::ui(11.5), t.text_dim);
|
|
}
|
|
bottom = ly + 30.0;
|
|
}
|
|
let content = bottom - (rect.min.y - scroll.offset);
|
|
scroll.end(ui, &mut app.auto, "info.scroll", content, &t);
|
|
}
|