Skip to main content

EditorState

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: usize

Total entity count in the world.

§search_filter: String

Scene tree search / filter text.

§ctrl_held: bool

Whether 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: String

Buffer 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: StatusBarData

Status bar data (FPS, entity count, memory).

§asset_entries: Vec<AssetEntry>

Asset entries for the asset browser (populated from the VFS).

§viewport_hovered: bool

Whether 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: GizmoMode

The 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: Option<String>

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: bool

Whether the asset browser should open a folder picker next frame.

§play_mode: PlayMode

Current 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: EditorMode

Currently active editing workspace (scene / control plane / …).

§command_palette_open: bool

Whether 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.

§hidden_entities: HashSet<EntityId>

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: u64

Bumped 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

pub fn is_selected(&self, entity: EntityId) -> bool

Returns true if the entity is currently selected.

pub fn select(&mut self, entity: EntityId)

Select a single entity (clears previous selection).

pub fn toggle_select(&mut self, entity: EntityId)

Toggle an entity in the selection (Ctrl+click behavior).

pub fn clear_selection(&mut self)

Clear the selection entirely.

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>

Returns the single selected entity, if exactly one is selected.

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>

Drain all pending edits (called by Application::update()).

Trait Implementations§

§

impl Clone for EditorState

§

fn clone(&self) -> EditorState

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for EditorState

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Default for EditorState

§

fn default() -> EditorState

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AppLifecycle for T
where T: ?Sized,

§

fn on_start(&mut self, ctx: &mut dyn AppContext)

Called once after the backend is up but before the first update. Apps install their theme / fonts here.
§

fn on_exit(&mut self)

Called once when the window is closing. Persist state here.
§

impl<T> AsAny for T
where T: Any,

§

fn as_any(&self) -> &(dyn Any + 'static)

Returns a reference to the inner value as &dyn Any.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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 T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts 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>

Converts 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)

Converts &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)

Converts &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
where T: Any + Send,

§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 F
where T: FromSample<F>,

§

fn into_sample(self) -> T

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(value: T, _simd: S) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,