Merge pull request #210 from jonassneu/fix/blank-panel-context-menus
G2: add context menus to blank Project and Timeline areas
This commit is contained in:
@@ -327,7 +327,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
// a click deselects, a drag draws a selection box, a double-click imports, as in After
|
||||
// Effects (File ▸ Import ▸ File...).
|
||||
let empty = ui.interact(list, egui::Id::new("proj-empty"), Sense::click_and_drag());
|
||||
app.auto.add("project.empty", list, "Double-click to import files; drag to select items");
|
||||
app.auto.add("project.empty", list, "Double-click to import files; drag to select items; right-click for project actions");
|
||||
if overflow > 0.0 && ui.rect_contains_pointer(list) {
|
||||
let (dx, dy, shift) = ui.input(|i| (i.smooth_scroll_delta.x, i.smooth_scroll_delta.y, i.modifiers.shift));
|
||||
let d = if dx.abs() > 0.0 {
|
||||
@@ -721,6 +721,18 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
if empty.double_clicked() {
|
||||
actions.push(("file.import".into(), json!({})));
|
||||
}
|
||||
empty.context_menu(|ui| {
|
||||
for (key, label, command) in
|
||||
[("newComp", "New Composition…", "comp.new"), ("newFolder", "New Folder", "project.newFolder"), ("import", "Import File…", "file.import")]
|
||||
{
|
||||
let response = ui.button(label);
|
||||
app.auto.add(&format!("project.context.{key}"), response.rect, label);
|
||||
if response.clicked() {
|
||||
actions.push((command.into(), json!({})));
|
||||
ui.close();
|
||||
}
|
||||
}
|
||||
});
|
||||
// Selection box over the rows it touches (#203); Shift or Cmd/Ctrl adds to the selection.
|
||||
let adding = ui.input(|i| i.modifiers.shift || i.modifiers.command);
|
||||
if empty.clicked() && !adding {
|
||||
|
||||
@@ -2352,6 +2352,39 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
}
|
||||
}
|
||||
ui.set_clip_rect(full_clip);
|
||||
// The background responses sit below rows, bars and editors, preserving their menus.
|
||||
if !graph_on {
|
||||
app.auto.add("timeline.empty", empty_rect, "Right-click to create a layer");
|
||||
}
|
||||
for (response, area) in [(&outline_empty, "outline"), (&empty, "graph")] {
|
||||
response.context_menu(|ui| {
|
||||
let menu = ui.menu_button("New", |ui| {
|
||||
for (key, label, command, params) in [
|
||||
("text", "Text", "layer.newText", json!({"text": "Text"})),
|
||||
("solid", "Solid…", "layer.newSolid", json!({})),
|
||||
("light", "Light…", "layer.newLight", json!({})),
|
||||
("camera", "Camera…", "layer.newCamera", json!({})),
|
||||
("null", "Null Object", "layer.newNull", json!({})),
|
||||
("shape", "Shape Layer", "layer.newShape", json!({"kind": "none"})),
|
||||
("adjustment", "Adjustment Layer", "layer.newAdjustment", json!({})),
|
||||
] {
|
||||
let response = ui.button(label);
|
||||
app.auto.add(&format!("timeline.context.{area}.{key}"), response.rect, label);
|
||||
if response.clicked() {
|
||||
actions.push((command.into(), params));
|
||||
ui.close();
|
||||
}
|
||||
}
|
||||
});
|
||||
app.auto.add(&format!("timeline.context.{area}.new"), menu.response.rect, "New");
|
||||
let response = ui.button("Composition Settings…");
|
||||
app.auto.add(&format!("timeline.context.{area}.settings"), response.rect, "Composition Settings…");
|
||||
if response.clicked() {
|
||||
actions.push(("comp.settings".into(), json!({})));
|
||||
ui.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
if outline_empty.clicked() && !ui.input(|i| i.modifiers.shift || i.modifiers.command) {
|
||||
actions.push(("layer.select".into(), json!({"layers": []})));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user