Class SelectionSystem

Class Documentation

class SelectionSystem

Static utility class for managing selection state in the editor.

SelectionSystem provides scoped selection using StringId identifiers, where selections are tied to a scope entity (typically a scene). This allows different scenes or contexts to maintain independent selection states. StringId-based selection generalizes beyond entities to support selecting resources, paths, or any named item.

Selections are additive by default. To replace the current selection, call deselect_all() before select().

Public Static Functions

static void select(StringId id, Entity scope)

Adds an item to the selection within a given scope.

Parameters:
  • id – The StringId of the item to select.

  • scope – The scope entity (e.g., scene) the selection belongs to.

static void select(Entity entity, Entity scope)

Adds an entity to the selection within a given scope (by name).

Parameters:
  • entity – The entity to select.

  • scope – The scope entity (e.g., scene) the selection belongs to.

static void select_all(std::span<const StringId> ids, Entity scope)

Selects multiple items within a given scope, skipping duplicates.

Parameters:
  • ids – The StringIds to select.

  • scope – The scope entity the selection belongs to.

static bool is_selected(const StringId &id, Entity scope)

Checks if an item is selected within a specific scope.

Parameters:
  • id – The StringId to check.

  • scope – The scope to check within.

Returns:

True if the item is selected in the given scope.

static bool is_selected(Entity entity, Entity scope)

Checks if an entity is selected within a specific scope (by name).

Parameters:
  • entity – The entity to check.

  • scope – The scope to check within.

Returns:

True if the entity is selected in the given scope.

static bool has_selection(Entity scope)

Checks if there is any selection within a scope.

Parameters:

scope – The scope to check.

Returns:

True if any item is selected in the scope.

static StringId get_selected(Entity scope)

Gets the first selection in a scope.

Parameters:

scope – The scope to query.

Returns:

The first selected StringId, or an empty StringId if none selected.

static StringId get_selection_by_index(Entity scope, size_t index)
static const std::vector<StringId> &get_selections(Entity scope)

Gets all selections in a scope.

Parameters:

scope – The scope to query.

Returns:

A const reference to the vector of selected StringIds.

static size_t selection_count(Entity scope)

Returns the number of selections in a scope.

Parameters:

scope – The scope to query.

Returns:

The number of selections.

static void deselect(const StringId &id, ecs::Registry &registry)

Deselects an item from all scopes in the given registry.

Parameters:
  • id – The StringId to deselect.

  • registry – The registry to search for selection scopes.

static void deselect(StringId id, Entity scope)

Deselects an item from a specific scope.

Parameters:
  • id – The StringId to deselect.

  • scope – The scope to deselect from.

static void deselect_all(Entity scope)

Clears all selections in a scope.

Parameters:

scope – The scope to clear.

static Entity selection_to_entity(const StringId &id, Entity scope)

Resolves a StringId selection to an Entity via the scope’s registry.

Parameters:
  • id – The StringId to resolve.

  • scope – The scope entity whose registry is used for lookup.

Returns:

The resolved Entity.

static Entity get_selected_entity(Entity scope)

Convenience: gets the first selection as an Entity using the scope’s registry.

Parameters:

scope – The scope to query.

Returns:

The first selected entity, or null_entity if none selected.