Panels: every scrolling panel has a scroll bar to drag (#271)
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>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
6d2ef5a830
commit
11f3736025
@@ -23,14 +23,10 @@ pub fn preview(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
let p = ui.painter().with_clip_rect(rect);
|
||||
// The panel scrolls when it is shorter than its controls (the default workspace shows just
|
||||
// the transport row, as in After Effects).
|
||||
let scroll_id = egui::Id::new("preview-scroll");
|
||||
let mut scroll: f32 = ctx.data(|d| d.get_temp(scroll_id).unwrap_or(0.0));
|
||||
if ui.rect_contains_pointer(rect) {
|
||||
scroll = (scroll - ui.input(|i| i.smooth_scroll_delta.y)).max(0.0);
|
||||
}
|
||||
let scroll = widgets::PanelScroll::begin(ui, egui::Id::new("preview-scroll"), rect);
|
||||
let panel_clip = ui.clip_rect();
|
||||
ui.set_clip_rect(rect.intersect(panel_clip));
|
||||
let y = rect.min.y + 12.0 - scroll;
|
||||
let y = rect.min.y + 12.0 - scroll.offset;
|
||||
let bw = 30.0;
|
||||
let total = bw * 5.0 + 16.0;
|
||||
let mut x = rect.center().x - total / 2.0;
|
||||
@@ -231,17 +227,8 @@ pub fn preview(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
p.text(pos2(bar.min.x, bar.max.y + 12.0), Align2::LEFT_CENTER, format!("{cached} / {total} frames cached{status}"), Tokens::ui(11.0), t.text_faint);
|
||||
}
|
||||
ui.set_clip_rect(panel_clip);
|
||||
let content = yy + 30.0 - (rect.min.y - scroll);
|
||||
let max = (content - rect.height()).max(0.0);
|
||||
scroll = scroll.min(max);
|
||||
ctx.data_mut(|d| d.insert_temp(scroll_id, scroll));
|
||||
if max > 0.0 {
|
||||
// A thin scroll indicator on the right edge.
|
||||
let h = (rect.height() * rect.height() / content).max(12.0);
|
||||
let top = rect.min.y + (rect.height() - h) * (scroll / max);
|
||||
p.rect_filled(Rect::from_min_size(pos2(rect.max.x - 5.0, top), vec2(3.0, h)), 1.5, t.text_faint.gamma_multiply(0.6));
|
||||
app.auto.add("preview.scroll", Rect::from_min_size(pos2(rect.max.x - 6.0, rect.min.y), vec2(6.0, rect.height())), "Preview scroll");
|
||||
}
|
||||
let content = yy + 30.0 - (rect.min.y - scroll.offset);
|
||||
scroll.end(ui, &mut app.auto, "preview.scroll", content, &t);
|
||||
}
|
||||
|
||||
fn fmt_rate(r: f64) -> String {
|
||||
@@ -382,12 +369,24 @@ pub fn history(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
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 scroll_id = egui::Id::new("history-scroll");
|
||||
let mut scroll = widgets::PanelScroll::begin(ui, scroll_id, rect);
|
||||
// The current state scrolls into view when it changes (undo, redo, a new step).
|
||||
if ui.data(|d| d.get_temp::<usize>(scroll_id.with("current"))) != Some(cur) {
|
||||
ui.data_mut(|d| d.insert_temp(scroll_id.with("current"), cur));
|
||||
let top = cur as f32 * row_h;
|
||||
if top < scroll.offset {
|
||||
scroll.offset = top;
|
||||
} else if top + row_h + 12.0 > scroll.offset + rect.height() {
|
||||
scroll.offset = top + row_h + 12.0 - rect.height();
|
||||
}
|
||||
}
|
||||
// Only the rows in view are drawn.
|
||||
let first = ((scroll.offset / row_h) as usize).min(nodes.len());
|
||||
let mut y = rect.min.y + 6.0 - (scroll.offset - first as f32 * row_h);
|
||||
let visible = (rect.height() / row_h) as usize + 2;
|
||||
let mut jump: Option<usize> = None;
|
||||
for n in nodes.iter().skip(first).take(visible + 1) {
|
||||
for n in nodes.iter().skip(first).take(visible) {
|
||||
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());
|
||||
@@ -410,6 +409,7 @@ pub fn history(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
jump = Some(n.index);
|
||||
}
|
||||
}
|
||||
scroll.end(ui, &mut app.auto, "history.scroll", nodes.len() as f32 * row_h + 12.0, &t);
|
||||
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})) {
|
||||
@@ -422,13 +422,17 @@ pub fn markers(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
let t = app.tokens;
|
||||
let p = ui.painter().with_clip_rect(rect);
|
||||
let Some(c) = app.session.active_comp_arc() else { return };
|
||||
let mut y = rect.min.y + 8.0;
|
||||
let scroll = widgets::PanelScroll::begin(ui, egui::Id::new("markers-scroll"), rect);
|
||||
let mut y = rect.min.y + 8.0 - scroll.offset;
|
||||
if c.markers.is_empty() {
|
||||
p.text(rect.center(), Align2::CENTER_CENTER, "No composition markers", Tokens::ui(12.0), t.text_faint);
|
||||
}
|
||||
for m in &c.markers {
|
||||
let r = Rect::from_min_size(pos2(rect.min.x, y), vec2(rect.width(), 22.0));
|
||||
y += 22.0;
|
||||
if !r.intersects(rect) {
|
||||
continue;
|
||||
}
|
||||
let tc = crate::panels::timecode(&app.session, &c, m.time);
|
||||
p.text(pos2(r.min.x + 12.0, r.center().y), Align2::LEFT_CENTER, tc, Tokens::mono(11.5), t.timecode);
|
||||
p.text(pos2(r.min.x + 120.0, r.center().y), Align2::LEFT_CENTER, &m.comment, Tokens::ui(12.0), t.text);
|
||||
@@ -436,4 +440,6 @@ pub fn markers(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
app.session.set_time(m.time);
|
||||
}
|
||||
}
|
||||
let content = y + 8.0 - (rect.min.y - scroll.offset);
|
||||
scroll.end(ui, &mut app.auto, "markers.scroll", content, &t);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user