Struct EditorState
pub struct EditorState {Show 54 fields
pub scene_roots: Vec<SceneNode>,
pub selection: HashSet<EntityId>,
pub entity_count: usize,
pub search_filter: String,
pub ctrl_held: bool,
pub pending_spawn: Option<String>,
pub pending_delete: Option<EntityId>,
pub pending_duplicate: Option<EntityId>,
pub renaming_entity: Option<EntityId>,
pub rename_buffer: String,
pub pending_rename: Option<(EntityId, String)>,
pub pending_reparent: Option<(EntityId, Option<EntityId>)>,
pub inspected: Option<InspectedEntity>,
pub pending_edits: Vec<PropertyEdit>,
pub log_entries: Vec<LogEntry>,
pub status: StatusBarData,
pub asset_entries: Vec<AssetEntry>,
pub viewport_hovered: bool,
pub viewport_screen_rect: Option<[f32; 4]>,
pub gizmo_mode: GizmoMode,
pub selected_asset: Option<usize>,
pub inspected_asset_path: Option<String>,
pub pending_menu_action: Option<String>,
pub project_folder: Option<String>,
pub project_name: Option<String>,
pub project_engine_version: Option<String>,
pub pending_browse_project_folder: bool,
pub play_mode: PlayMode,
pub scene_snapshot: Option<Vec<u8>>,
pub current_scene_path: Option<String>,
pub pending_scene_load: Option<String>,
pub pending_add_component: Option<(EntityId, String)>,
pub component_domain_registry: HashMap<String, u8>,
pub active_mode: EditorMode,
pub command_palette_open: bool,
pub inspector_card_open: HashMap<String, bool>,
pub inspector_card_enabled: HashMap<String, bool>,
pub current_git_branch: Option<String>,
pub hidden_entities: HashSet<EntityId>,
pub pending_visibility_toggle: Option<EntityId>,
pub pending_save_as_prefab: Option<EntityId>,
pub pending_save_as_prefab_at: Option<(EntityId, String)>,
pub pending_prefab_spawn: Option<(String, Option<EntityId>)>,
pub pending_save_as_material: Option<(EntityId, String)>,
pub pending_assign_material: Option<String>,
pub asset_dirs: Vec<String>,
pub asset_epoch: u64,
pub pending_create_folder: Option<String>,
pub pending_rename_asset: Option<(String, String)>,
pub pending_move_asset: Option<(String, String)>,
pub pending_delete_asset: Option<String>,
pub pending_duplicate_asset: Option<String>,
pub pending_spawn_mesh_asset: Option<(String, [f32; 3], Option<EntityId>)>,
pub pending_assign_texture: Option<(String, EntityId)>,
}Expand description
Shared editor state populated by Application::update() each frame.
Panels read this to display the scene tree, selection highlights, etc. All data is owned (snapshot) — no ECS borrows.
Fields§
§scene_roots: Vec<SceneNode>Root-level scene nodes (entities without a Parent component).
selection: HashSet<EntityId>Currently selected entity IDs.
entity_count: usizeTotal entity count in the world.
search_filter: StringScene tree search / filter text.
ctrl_held: boolWhether the Ctrl key is currently held (for multi-select).
pending_spawn: Option<String>A pending spawn request tag (e.g. “Empty”, “Cube”, “Light”, “Camera”). The application reads and clears this each frame.
pending_delete: Option<EntityId>Pending delete request for a specific entity (from context menu).
pending_duplicate: Option<EntityId>Pending duplicate request for a specific entity (from context menu).
renaming_entity: Option<EntityId>Entity currently being renamed (inline text editing).
rename_buffer: StringBuffer for the rename text input.
pending_rename: Option<(EntityId, String)>Pending rename to apply: (entity, new_name).
pending_reparent: Option<(EntityId, Option<EntityId>)>Pending reparent to apply: (child, new_parent_or_None_for_root).
Set by the scene tree drag-and-drop handler, drained by
process_reparents in the editor’s tick.
inspected: Option<InspectedEntity>Snapshot of the single-selected entity’s components (if any).
pending_edits: Vec<PropertyEdit>Pending property edits to apply back to the ECS world.
log_entries: Vec<LogEntry>Log entries captured by the editor log sink.
status: StatusBarDataStatus bar data (FPS, entity count, memory).
asset_entries: Vec<AssetEntry>Asset entries for the asset browser (populated from the VFS).
viewport_hovered: boolWhether the 3D viewport is currently hovered (for camera controls).
Updated each frame from is_last_item_hovered() after the viewport
image is laid out — only meaningful for the current paint pass; UI
code that reads input handlers should prefer viewport_screen_rect
- the live cursor position.
viewport_screen_rect: Option<[f32; 4]>Screen-space rect of the 3D viewport image ([x, y, w, h] in pixels)
for the current frame. None when the editor isn’t in Scene mode or
the viewport hasn’t been laid out yet. Used by the input pipeline to
decide if a mouse event lives over the viewport — checked against
the live cursor position so it doesn’t suffer from the
frame-of-latency viewport_hovered had.
gizmo_mode: GizmoModeThe active gizmo tool.
selected_asset: Option<usize>Index of the currently selected asset in the asset browser (if any).
inspected_asset_path: Option<String>Forward-slash relative path (under <project>/assets/) of the
asset selected in the browser, or None. When set, the
Inspector switches to asset-metadata mode (Phase 5). Cleared
when an entity selection is made.
Pending menu action (e.g. “new_scene”, “save”, “quit”).
project_folder: Option<String>Currently set project folder (used for asset scanning).
project_name: Option<String>Human-readable project name (read from project.json).
project_engine_version: Option<String>Engine version string read from project.json::engine_version (set
by the hub at project creation time). The status bar and command
palette display this so users see the engine they targeted, not the
editor binary’s own crate version.
pending_browse_project_folder: boolWhether the asset browser should open a folder picker next frame.
play_mode: PlayModeCurrent play mode (Editing / Playing / Paused).
scene_snapshot: Option<Vec<u8>>Serialised snapshot of the scene taken when entering play mode. Restored when the user presses Stop.
current_scene_path: Option<String>Path to the currently open scene file (for Save).
pending_scene_load: Option<String>Pending scene load path (set by asset browser double-click, consumed by update).
pending_add_component: Option<(EntityId, String)>Pending component addition (set by properties panel or scene tree context menu, consumed by update). The String is the component type name (e.g., “Camera”, “RigidBody”).
component_domain_registry: HashMap<String, u8>Registry mapping type_name → domain tag for every component the
engine currently knows about. Populated by extract_inspected once
per frame from the live World. Used by the inspector to bucket
the “+ Add Component” menu by domain without re-querying the world.
active_mode: EditorModeCurrently active editing workspace (scene / control plane / …).
command_palette_open: boolWhether the command palette modal is open.
inspector_card_open: HashMap<String, bool>Inspector card expand/collapse state, keyed by stable card id
(typically "<entity_index>::<title>" to avoid cross-entity bleed).
inspector_card_enabled: HashMap<String, bool>Inspector card on/off toggle state. UI-only for now (no engine wiring).
current_git_branch: Option<String>Current git branch name read from .git/HEAD of the project folder.
None if the project isn’t a git repository or we couldn’t read it.
Entities the user has hidden via the eye icon in the scene tree.
UI-only state today — see pending_visibility_toggle for the engine
hook the editor consumes each frame.
pending_visibility_toggle: Option<EntityId>Pending visibility toggle from the scene tree eye icon. The editor
pops this each frame and applies it to the engine (when an engine
Visible component lands; for now it just flips hidden_entities).
pending_save_as_prefab: Option<EntityId>Set when the user picks “Save as Prefab” in the scene tree
context menu. The editor consumes this next frame, opens a
file dialog, calls serialize_subtree, and writes the resulting
.kprefab file.
pending_save_as_prefab_at: Option<(EntityId, String)>Same payload as pending_save_as_prefab, but with a pre-chosen
destination forward-slash relative path under <project>/assets/
— set by drag-and-drop (e.g. dragging an entity onto the asset
browser’s current folder). The dispatcher writes directly with
no file dialog and reuses the entity name as the file stem when
the path ends in /.
pending_prefab_spawn: Option<(String, Option<EntityId>)>Set when the user drops a .kprefab tile onto the viewport / hierarchy
(or activates one from the asset browser). Holds the forward-slash
relative path under <project>/assets/ plus an optional parent entity
(the hierarchy row it was dropped on) so the instantiated root is
parented under it. Consumed next frame to load the recipe via the asset
service and call instantiate_subtree.
pending_save_as_material: Option<(EntityId, String)>Set when the user picks “Save Material as .kmat” on an entity that
carries a MaterialRef::Inline. Holds the entity plus the chosen
material name (file stem). The editor consumes this next frame:
serializes the inline material to RON under
assets/materials/<name>.kmat, reindexes, and rewrites the entity’s
component to MaterialRef::Asset(uuid) so it now references the
shared, reloadable asset.
pending_assign_material: Option<String>Set when the user assigns a .kmat from the asset browser to the
current selection. Holds the forward-slash relative path of the
.kmat under <project>/assets/. Consumed next frame: each
selected entity’s MaterialRef is set to Asset(uuid).
asset_dirs: Vec<String>Every directory under assets/ (forward-slash, relative), so the asset
browser can show empty folders the file-only VFS can’t. Refreshed with
asset_entries.
asset_epoch: u64Bumped whenever asset_entries/asset_dirs change. The asset browser
rescans its flattened cache on epoch change instead of on entry-count
change (a modified-in-place file used to be missed).
pending_create_folder: Option<String>Create an empty folder at this forward-slash relative path under
assets/. Consumed next frame.
pending_rename_asset: Option<(String, String)>Rename/move an asset: (old_rel, new_rel), both forward-slash under
assets/. The identity registry freezes the UUID so references survive.
pending_move_asset: Option<(String, String)>Move an asset into a folder: (src_rel, dest_dir) (dest_dir "" = root).
pending_delete_asset: Option<String>Send an asset to the OS recycle bin: forward-slash relative path.
pending_duplicate_asset: Option<String>Duplicate an asset next to itself: forward-slash relative path.
pending_spawn_mesh_asset: Option<(String, [f32; 3], Option<EntityId>)>Spawn a mesh asset into the scene: (rel_path, [x,y,z] world point, optional parent entity). Set by dragging a mesh tile onto the viewport
(parent None) or a hierarchy row (parent = that entity); drained into a
MeshRef::Asset entity spawn, parented under the target when present.
pending_assign_texture: Option<(String, EntityId)>Assign a texture/material asset to a specific entity (drag onto an entity
in the viewport): (rel_path, entity).
Implementations§
§impl EditorState
impl EditorState
pub fn is_selected(&self, entity: EntityId) -> bool
pub fn is_selected(&self, entity: EntityId) -> bool
Returns true if the entity is currently selected.
pub fn toggle_select(&mut self, entity: EntityId)
pub fn toggle_select(&mut self, entity: EntityId)
Toggle an entity in the selection (Ctrl+click behavior).
pub fn clear_selection(&mut self)
pub fn clear_selection(&mut self)
Clear the selection entirely.
pub fn clear_entity_references(&mut self)
pub fn clear_entity_references(&mut self)
Drops every piece of state that names an EntityId, for use whenever
the world is replaced wholesale — new scene, scene load, or Stop
restoring the pre-play snapshot.
Those paths rebuild the world with fresh ids, so anything still
holding an old one is not merely stale but actively dangerous: entity
slots are recycled, and an index+generation pair can come back attached
to a different entity. A surviving selection then makes Delete act on
something the user never selected.
Card state is keyed by entity too, so it is cleared here rather than growing without bound across scene changes.
pub fn single_selected(&self) -> Option<EntityId>
pub fn single_selected(&self) -> Option<EntityId>
Returns the single selected entity, if exactly one is selected.
pub fn push_edit(&mut self, edit: PropertyEdit)
pub fn push_edit(&mut self, edit: PropertyEdit)
Push a property edit to be applied back to the ECS world next frame.
pub fn drain_edits(&mut self) -> Vec<PropertyEdit>
pub fn drain_edits(&mut self) -> Vec<PropertyEdit>
Drain all pending edits (called by Application::update()).
Trait Implementations§
§impl Clone for EditorState
impl Clone for EditorState
§fn clone(&self) -> EditorState
fn clone(&self) -> EditorState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for EditorState
impl Debug for EditorState
§impl Default for EditorState
impl Default for EditorState
§fn default() -> EditorState
fn default() -> EditorState
Auto Trait Implementations§
impl Freeze for EditorState
impl RefUnwindSafe for EditorState
impl Send for EditorState
impl Sync for EditorState
impl Unpin for EditorState
impl UnsafeUnpin for EditorState
impl UnwindSafe for EditorState
Blanket Implementations§
§impl<T> AppLifecycle for Twhere
T: ?Sized,
impl<T> AppLifecycle for Twhere
T: ?Sized,
§fn on_start(&mut self, ctx: &mut dyn AppContext)
fn on_start(&mut self, ctx: &mut dyn AppContext)
update. Apps install their theme / fonts here.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().§impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.