Skip to main content

Module asset_browser

Module asset_browser 

Source
Expand description

Asset Browser — folder explorer + grid + per-asset inspection.

Layout:

┌──────────────┬───────────────────────────────────┐
│  Categories  │  ← / breadcrumb / search →        │
│  (filters)   ├───────────────────────────────────┤
├──────────────┤  Tile grid                        │
│  Folder tree │                                   │
│  (real VFS)  │                                   │
└──────────────┴───────────────────────────────────┘

Single-click on a tile sets EditorState::inspected_asset_path so the Inspector switches to asset-metadata mode (Phase 5). Double-click still routes through the handlers::AssetTypeHandler activation — LoadScene for .kscene, OpenExternal for everything else.

Modules§

handlers
AssetTypeHandler — extensibility seam for the Asset Browser.

Structs§

AssetBrowserPanel
FlatAsset 🔒
FolderNode 🔒
One node of the folder tree built from the flat asset list.

Enums§

FolderAction 🔒
A folder-tree context-menu / drag-drop action, collected during the (&self) tree walk and applied afterwards where &mut self is available.

Constants§

ASSET_DRAG_TAG 🔒
High 32 bits of a u64 drag payload that identifies an asset-browser tile — the low 32 bits hold the asset index in EditorState::asset_entries. Every tile is a drag source; the drop sink (viewport / folder tree) dispatches by the asset’s type, so the tag is type-agnostic. Picked so it can’t collide with the EntityId-packed payload used by the scene-tree reparent flow (entity generations are u32 and start at 1, so any value with 0xKHPF in the top half can only mean “asset tile”).
DRAG_EPOCH_BITS 🔒
Number of low bits of EditorState::asset_epoch stamped into a drag payload. Eight is plenty: the stamp only has to survive one drag, and the epoch would have to advance 256 times mid-gesture to alias.
DRAG_INDEX_MASK 🔒
HEADER_HEIGHT 🔒
SIDEBAR_CATEGORIES 🔒
SIDEBAR_ROW_H 🔒
SIDEBAR_WIDTH 🔒
TILE_GAP 🔒
TILE_SIZE 🔒
TOOLBAR_HEIGHT 🔒
TREE_INDENT 🔒

Functions§

ensure_extension 🔒
Re-applies the original file’s extension to a user-edited name when the user omitted one (so renaming crate.png to box yields box.png, but box.jpg is honoured verbatim).
entity_display_name 🔒
Walks a SceneNode forest to find entity’s display name. Used by the asset browser’s drop receiver to compose a default .kprefab filename without a round-trip through the live World.
is_asset_drag 🔒
Whether payload carries the asset tag, regardless of how stale it is.
pack_asset_drag 🔒
Packs an asset-list index plus a stamp of the epoch it was read at.
sanitize_for_filename 🔒
Strips characters that aren’t safe in cross-platform file names (path separators, shell-meta, control chars). Falls back to an underscore for runs of stripped chars so consecutive replacements don’t collapse into nothing.
unpack_asset_drag 🔒
Unpacks an asset drag payload, rejecting it when the asset list changed since the drag started.