This commit is contained in:
1 parent
1ab3886028
commit
c55f34780f
4 files changed
+58
-13
No files matched your search
@@ -563,6 +563,7 @@ fn command_palette_ui(
|
||||
}
|
||||
|
||||
let mut open = palette.open;
|
||||
let mut dismiss_requested = false;
|
||||
let palette_width = (ctx.content_rect().width() - 32.0).clamp(320.0, 520.0);
|
||||
egui::Window::new("Command Palette")
|
||||
.open(&mut open)
|
||||
@@ -611,13 +612,11 @@ fn command_palette_ui(
|
||||
if ui.input_mut(|input| input.consume_key(egui::Modifiers::NONE, egui::Key::Enter)) {
|
||||
if let Some(entry) = filtered_entries.get(palette.selected_index) {
|
||||
palette.pending_run = Some(entry.name.clone());
|
||||
palette.open = false;
|
||||
ui.close();
|
||||
dismiss_requested = true;
|
||||
}
|
||||
}
|
||||
if ui.input_mut(|input| input.consume_key(egui::Modifiers::NONE, egui::Key::Escape)) {
|
||||
palette.open = false;
|
||||
ui.close();
|
||||
dismiss_requested = true;
|
||||
}
|
||||
|
||||
ui.separator();
|
||||
@@ -639,17 +638,20 @@ fn command_palette_ui(
|
||||
if response.clicked() {
|
||||
palette.selected_index = index;
|
||||
palette.pending_run = Some(entry.name.clone());
|
||||
palette.open = false;
|
||||
ui.close();
|
||||
dismiss_requested = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
palette.open = open;
|
||||
palette.open = resolve_palette_open(open, dismiss_requested);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn resolve_palette_open(window_open: bool, dismiss_requested: bool) -> bool {
|
||||
window_open && !dismiss_requested
|
||||
}
|
||||
|
||||
fn filtered_command_entries(
|
||||
registry: &EditorCommandRegistry,
|
||||
filter: &str,
|
||||
@@ -766,6 +768,13 @@ mod tests {
|
||||
assert_eq!(entries[1].name, "scene.reset_lighting");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn command_palette_dismissal_wins_over_stale_window_open_state() {
|
||||
assert!(!resolve_palette_open(true, true));
|
||||
assert!(!resolve_palette_open(false, false));
|
||||
assert!(resolve_palette_open(true, false));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn grouping_dispatch_is_one_history_transaction_and_round_trips() {
|
||||
let mut world = command_world();
|
||||
@@ -824,10 +833,12 @@ mod tests {
|
||||
assert!(committed
|
||||
.iter()
|
||||
.any(|(name, parent, _)| name == "Second" && parent.as_deref() == Some("Group")));
|
||||
assert_group_has_visibility_hierarchy(&mut world);
|
||||
apply_command_undo(&mut world);
|
||||
assert_eq!(hierarchy_projection(&mut world), initial);
|
||||
apply_command_redo(&mut world);
|
||||
assert_eq!(hierarchy_projection(&mut world), committed);
|
||||
assert_group_has_visibility_hierarchy(&mut world);
|
||||
assert!(world.get::<ChildOf>(unselected).is_none());
|
||||
apply_command_undo(&mut world);
|
||||
assert_eq!(hierarchy_projection(&mut world), initial);
|
||||
@@ -836,6 +847,17 @@ mod tests {
|
||||
assert!(world.get::<ChildOf>(unselected).is_none());
|
||||
}
|
||||
|
||||
fn assert_group_has_visibility_hierarchy(world: &mut World) {
|
||||
let group = world
|
||||
.query::<(Entity, &Name)>()
|
||||
.iter(world)
|
||||
.find_map(|(entity, name)| (name.as_str() == "Group").then_some(entity))
|
||||
.expect("group command should spawn the group actor");
|
||||
assert!(world.get::<Visibility>(group).is_some());
|
||||
assert!(world.get::<InheritedVisibility>(group).is_some());
|
||||
assert!(world.get::<ViewVisibility>(group).is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reset_lighting_dispatch_is_one_undoable_group() {
|
||||
let mut world = command_world();
|
||||
|
||||
@@ -198,7 +198,20 @@ fn spawn_snapshot_with_parent(
|
||||
snapshot: &EditorEntitySnapshot,
|
||||
parent: Option<Entity>,
|
||||
) -> Entity {
|
||||
let mut entity_mut = world.spawn((LevelObject, snapshot.actor_kind, snapshot.transform));
|
||||
let visibility = if snapshot.editor_visibility.visible {
|
||||
Visibility::Visible
|
||||
} else {
|
||||
Visibility::Hidden
|
||||
};
|
||||
let mut entity_mut = world.spawn((
|
||||
LevelObject,
|
||||
snapshot.actor_kind,
|
||||
snapshot.transform,
|
||||
snapshot.editor_visibility,
|
||||
visibility,
|
||||
InheritedVisibility::default(),
|
||||
ViewVisibility::default(),
|
||||
));
|
||||
entity_mut.insert(
|
||||
snapshot
|
||||
.actor_id
|
||||
@@ -291,7 +304,6 @@ fn spawn_snapshot_with_parent(
|
||||
entity_mut.insert(link.clone());
|
||||
}
|
||||
entity_mut.insert(HierarchySiblingIndex(snapshot.hierarchy_sibling_index));
|
||||
entity_mut.insert(snapshot.editor_visibility);
|
||||
if let Some(order) = &snapshot.inspector_order {
|
||||
entity_mut.insert(order.clone());
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user