mirror of
https://github.com/storytold/filmcraft.git
synced 2026-11-02 18:09:21 +00:00
Integration: adopt egui 0.37 names in code the tracks added (Role, Id::unique, unclamped_offset)
This commit is contained in:
@@ -31,7 +31,7 @@ impl FilmcraftApp {
|
||||
let _ = self.session.execute("trim.cancelDynamic", json!({}));
|
||||
}
|
||||
panels::masks::pen_take_back(self, ctx, text_focused);
|
||||
let fire = ctx.input_mut(|i| self.match_shortcuts(i, text_focused, divider_focused));
|
||||
let fire = ctx.input_mut(|i| self.match_shortcuts(i, text_focused, divider_focused, label_selected));
|
||||
self.fire_shortcuts(ctx, fire);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ impl FilmcraftApp {
|
||||
if self.session.trim_play.dynamic.is_some() && input.consume_key(egui::Modifiers::NONE, egui::Key::Escape) {
|
||||
let _ = self.session.execute("trim.cancelDynamic", json!({}));
|
||||
}
|
||||
let fire = self.match_shortcuts(&mut input, false, false);
|
||||
let fire = self.match_shortcuts(&mut input, false, false, false);
|
||||
self.fire_shortcuts(ctx, fire);
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ impl FilmcraftApp {
|
||||
}
|
||||
|
||||
/// The binding ids the key presses in `i` fire, consuming those presses.
|
||||
fn match_shortcuts(&mut self, i: &mut egui::InputState, text_focused: bool, divider_focused: bool) -> Vec<String> {
|
||||
fn match_shortcuts(&mut self, i: &mut egui::InputState, text_focused: bool, divider_focused: bool, label_selected: bool) -> Vec<String> {
|
||||
// Panel shortcuts of the focused panel override application shortcuts on the same chord.
|
||||
// egui ignores extra Shift and Alt when matching, so the most specific chords go first
|
||||
// across both scopes (the sort is stable, so the panel still wins a tie): otherwise the
|
||||
|
||||
@@ -1298,8 +1298,8 @@ fn menu_entry(ui: &mut egui::Ui, it: &MenuItem, auto: &mut crate::automation::Re
|
||||
pub fn checked_entry(ui: &mut egui::Ui, label: &str, enabled: bool, checked: Option<bool>) -> egui::Response {
|
||||
let r = ui.add_enabled(enabled, egui::Button::new(format!("{GUTTER}{label}")));
|
||||
r.widget_info(|| match checked {
|
||||
Some(checked) => egui::WidgetInfo::selected(egui::WidgetType::Button, enabled, checked, label),
|
||||
None => egui::WidgetInfo::labeled(egui::WidgetType::Button, enabled, label),
|
||||
Some(checked) => egui::WidgetInfo::selected(egui::Role::Button, enabled, checked, label),
|
||||
None => egui::WidgetInfo::labeled(egui::Role::Button, enabled, label),
|
||||
});
|
||||
if checked == Some(true) {
|
||||
paint_check(ui, r.rect);
|
||||
|
||||
@@ -64,7 +64,7 @@ pub fn show(app: &mut FilmcraftApp, ctx: &egui::Context) -> bool {
|
||||
};
|
||||
let t = app.tokens;
|
||||
let mut answer = None;
|
||||
let r = egui::Modal::new(egui::Id::new("clip-mismatch-modal")).frame(super::file_dialogs::modal_frame(&t)).show(ctx, |ui| {
|
||||
let r = egui::Modal::new(egui::Id::unique("clip-mismatch-modal")).frame(super::file_dialogs::modal_frame(&t)).show(ctx, |ui| {
|
||||
ui.set_width(500.0);
|
||||
Frame::new().inner_margin(Margin { left: 28, right: 28, top: 24, bottom: 20 }).show(ui, |ui| {
|
||||
ui.label(RichText::new(tl!("Clip Mismatch Warning")).size(18.0).strong().color(t.text));
|
||||
|
||||
@@ -144,7 +144,7 @@ pub fn show_overwrite(app: &mut FilmcraftApp, ctx: &egui::Context) {
|
||||
let file = path.file_name().map(|n| n.to_string_lossy().into_owned()).unwrap_or_default();
|
||||
let folder = path.parent().and_then(|d| d.file_name()).map(|n| n.to_string_lossy().into_owned()).unwrap_or_default();
|
||||
let mut answer = None;
|
||||
let r = egui::Modal::new(egui::Id::new("overwrite-modal")).frame(modal_frame(&t)).show(ctx, |ui| {
|
||||
let r = egui::Modal::new(egui::Id::unique("overwrite-modal")).frame(modal_frame(&t)).show(ctx, |ui| {
|
||||
ui.set_width(460.0);
|
||||
Frame::new().inner_margin(Margin { left: 28, right: 28, top: 24, bottom: 20 }).show(ui, |ui| {
|
||||
ui.label(RichText::new(tl!("Replace File")).size(18.0).strong().color(t.text));
|
||||
|
||||
@@ -130,9 +130,9 @@ pub fn monitor_overlay(app: &mut FilmcraftApp, ui: &mut egui::Ui, pic: Rect, fra
|
||||
// ---- presses (the left button only: a middle or right drag leaves the layers alone)
|
||||
press(app, ui, &resp, graphics_tool, pic, tool, &views, sel_clip, &sel_layers, &editing, edit_view, drag_id, &mut drag, &mut actions);
|
||||
// ---- drag feedback / commit
|
||||
drag_step(app, ui, &painter, &resp, hover, pic, frame, tool, &views, drag, drag_id, &mut actions);
|
||||
drag_step(app, ui, &painter, &resp, hover, pic, frame, tool, &views, sel_clip, &sel_layers, drag, drag_id, &mut actions);
|
||||
// ---- clicks
|
||||
click(app, ui, &resp, graphics_tool, drag, pic, frame, tool, &views, &editing, edit_view, &mut actions);
|
||||
click(app, ui, &resp, graphics_tool, drag, pic, frame, tool, &views, sel_clip, &sel_layers, &editing, edit_view, &mut actions);
|
||||
// ---- pen path in progress
|
||||
pen_path(app, ui, &painter, pic, frame, tool, hover, accent, &mut actions);
|
||||
// ---- run accepted actions before drawing the caret
|
||||
@@ -311,7 +311,7 @@ fn press(
|
||||
// a layer already selected drags every selected layer along (#2186); Shift
|
||||
// adds the pressed one to the selection first, as Shift-click does
|
||||
if !(Some(v.clip) == sel_clip && sel_layers.contains(&v.layer)) {
|
||||
let mut layers = if shift && Some(v.clip) == sel_clip { sel_layers.clone() } else { Vec::new() };
|
||||
let mut layers = if shift && Some(v.clip) == sel_clip { sel_layers.to_vec() } else { Vec::new() };
|
||||
layers.push(v.layer);
|
||||
actions.push(("graphics.selectLayer".into(), json!({"clip": v.clip.0, "layers": layers})));
|
||||
}
|
||||
@@ -347,6 +347,8 @@ fn drag_step(
|
||||
frame: (u32, u32),
|
||||
tool: Tool,
|
||||
views: &[LayerView],
|
||||
sel_clip: Option<ClipId>,
|
||||
sel_layers: &[usize],
|
||||
drag: Option<DragState>,
|
||||
drag_id: egui::Id,
|
||||
actions: &mut Vec<(String, Value)>,
|
||||
@@ -518,6 +520,8 @@ fn click(
|
||||
frame: (u32, u32),
|
||||
tool: Tool,
|
||||
views: &[LayerView],
|
||||
sel_clip: Option<ClipId>,
|
||||
sel_layers: &[usize],
|
||||
editing: &Option<GfxEdit>,
|
||||
edit_view: Option<&LayerView>,
|
||||
actions: &mut Vec<(String, Value)>,
|
||||
|
||||
@@ -614,7 +614,7 @@ fn list(app: &mut FilmcraftApp, ui: &mut egui::Ui, r: Rect, entries: &[Entry], c
|
||||
let dragging = app.ui.media_browser.column_drag.as_ref().is_some_and(|(d, _)| d == c);
|
||||
if visible || dragging {
|
||||
let resp = ui
|
||||
.interact(if visible { hr.intersect(header) } else { hr }, egui::Id::new(("mb-colsize", c)), Sense::drag())
|
||||
.interact(if visible { hr.intersect(header) } else { hr }, egui::Id::unique(("mb-colsize", c)), Sense::drag())
|
||||
.on_hover_cursor(egui::CursorIcon::ResizeColumn);
|
||||
if visible {
|
||||
app.auto.add(&format!("mediaBrowser.resize.{c}"), hr.intersect(header), "Resize column");
|
||||
|
||||
@@ -212,7 +212,7 @@ pub(crate) fn marker_dialog(app: &mut FilmcraftApp, ctx: &egui::Context) {
|
||||
let mut ok = false;
|
||||
let mut elems: Vec<(String, Rect, String)> = Vec::new();
|
||||
egui::Window::new(tl!("Marker"))
|
||||
.id(egui::Id::new("Edit Marker"))
|
||||
.id(egui::Id::unique("Edit Marker"))
|
||||
.collapsible(false)
|
||||
.resizable(false)
|
||||
.pivot(Align2::CENTER_CENTER)
|
||||
|
||||
@@ -1093,7 +1093,7 @@ pub fn freeform_view(app: &mut FilmcraftApp, ui: &mut egui::Ui, rect: Rect, v: &
|
||||
let extent = cards.iter().fold(vec2(rect.width(), rect.height()), |e, c| vec2(e.x.max(c.x + c.size + 40.0), e.y.max(c.y + c.size * 9.0 / 16.0 + 60.0)));
|
||||
// a middle-button drag anywhere on the canvas pans it, the content following the pointer, as in
|
||||
// the Timeline and the monitors (#579); cards move only with the primary button
|
||||
let (offset_key, pan_key) = (egui::Id::new((&v.prefix, "ff-offset")), egui::Id::new((&v.prefix, "ff-pan")));
|
||||
let (offset_key, pan_key) = (egui::Id::unique((&v.prefix, "ff-offset")), egui::Id::unique((&v.prefix, "ff-pan")));
|
||||
let view = ui.max_rect();
|
||||
let (middle, origin, pos) = ui.input(|i| (i.pointer.middle_down(), i.pointer.press_origin(), i.pointer.latest_pos()));
|
||||
let mut area = egui::ScrollArea::both().id_salt((&v.prefix, "ff-scroll")).auto_shrink([false, false]);
|
||||
@@ -1219,7 +1219,7 @@ pub fn freeform_view(app: &mut FilmcraftApp, ui: &mut egui::Ui, rect: Rect, v: &
|
||||
let bin = Some(v.bin.0);
|
||||
bg.context_menu(|ui| canvas_menu(app, ui, v, bin, actions));
|
||||
});
|
||||
ui.ctx().data_mut(|d| d.insert_temp(offset_key, out.state.offset));
|
||||
ui.ctx().data_mut(|d| d.insert_temp(offset_key, out.state.unclamped_offset()));
|
||||
}
|
||||
|
||||
fn cards_stack(cards: &[Card], item: u64) -> Option<u64> {
|
||||
|
||||
@@ -619,7 +619,7 @@ struct KeyLabel {
|
||||
/// trial layouts (about 60 µs), and the keyboard draws some seventy names every frame.
|
||||
fn remembered_key_label(ui: &egui::Ui, label: &str, space: egui::Vec2, max_fs: f32) -> KeyLabel {
|
||||
type Fits = std::collections::HashMap<(String, [u32; 4]), KeyLabel>;
|
||||
let id = egui::Id::new("shortcuts.keyLabels");
|
||||
let id = egui::Id::unique("shortcuts.keyLabels");
|
||||
let key = (label.to_owned(), [space.x.to_bits(), space.y.to_bits(), max_fs.to_bits(), ui.ctx().pixels_per_point().to_bits()]);
|
||||
if let Some(fit) = ui.data_mut(|d| d.get_temp_mut_or_default::<Fits>(id).get(&key).cloned()) {
|
||||
return fit;
|
||||
|
||||
@@ -984,6 +984,8 @@ mod waveform_drag_anchor_tests {
|
||||
pps: 100.0,
|
||||
scroll: 0.0,
|
||||
split_y: 0.0,
|
||||
v_scroll: 0.0,
|
||||
a_scroll: 0.0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1204,6 +1206,8 @@ mod new_track_tests {
|
||||
pps: 100.0,
|
||||
scroll: 0.0,
|
||||
split_y,
|
||||
v_scroll: 0.0,
|
||||
a_scroll: 0.0,
|
||||
};
|
||||
let at = |y: f32| layout.row_at(y).map(|r| r.track.0);
|
||||
assert_eq!(at(260.0), Some(1), "V1 above the divider");
|
||||
|
||||
@@ -1102,7 +1102,7 @@ fn effect_drop_preview(app: &mut FilmcraftApp, ui: &mut egui::Ui, seq: &Sequence
|
||||
let x = layout.x_of(cut);
|
||||
painter.line_segment([pos2(x, r.top()), pos2(x, r.bottom())], Stroke::new(3.0, app.tokens.accent));
|
||||
// Keep the alignment label readable even when the transition is only a few pixels wide.
|
||||
let label = filmcraft_edit::transitions::alignment(&tr, cut, rate.frame_duration()).label();
|
||||
let label = filmcraft_edit::transitions::alignment(&tr, cut, seq.settings.frame_rate.frame_duration()).label();
|
||||
let shown = crate::i18n::t(label);
|
||||
let label_width = painter.layout_no_wrap(shown.to_string(), Tokens::ui(11.0), app.tokens.accent).size().x + 8.0;
|
||||
let label_rect = Rect::from_center_size(pos2(p.x, row.rect.top() + 10.0), vec2(label_width, 15.0));
|
||||
|
||||
@@ -603,8 +603,8 @@ mod tests {
|
||||
for _ in 0..2 {
|
||||
let mut out = ctx.run_ui(egui::RawInput::default(), |ui| {
|
||||
let r = Rect::from_min_size(pos2(20.0, y), vec2(14.0, 14.0));
|
||||
letter_toggle_clipped(ui, r, clip, "M", false, Color32::WHITE, &t, egui::Id::new("m"));
|
||||
letter_toggle_clipped(ui, r.translate(vec2(20.0, 0.0)), clip, "S", true, Color32::YELLOW, &t, egui::Id::new("s"));
|
||||
letter_toggle_clipped(ui, r, clip, "M", false, Color32::WHITE, &t, egui::Id::unique("m"));
|
||||
letter_toggle_clipped(ui, r.translate(vec2(20.0, 0.0)), clip, "S", true, Color32::YELLOW, &t, egui::Id::unique("s"));
|
||||
});
|
||||
out.textures_delta.clear();
|
||||
assert_eq!(!out.shapes.is_empty(), shows, "button at y {y}");
|
||||
|
||||
Reference in New Issue
Block a user