Jazz2::Editor::EventSelection class

Selected events, of the event grid by their tiles and off the grid by their indices.

Both kinds can be selected together, any number of each. An event off the grid is known by its index in LevelDocument::OffGridEvents. A change that adds or removes some of them, as an undo, moves the indices of the others, so DropEmpty() finds the selected ones again by the events they were before the change, and drops those that are gone. The selection is changed only while the indices are of the events as they are, so those that change them call DropEmpty() before they change the selection.

Public functions

auto GetRevision() const -> std::uint32_t
Returns a number that changes whenever the selection changes.
auto IsEmpty() const -> bool
Returns true if nothing is selected, neither on the grid nor off it.
auto HasCells() const -> bool
Returns true if an event of the grid is selected.
auto HasOffGrid() const -> bool
Returns true if an event off the grid is selected.
auto GetCells() const -> ArrayView<const std::uint32_t>
Returns the selected tiles of the event grid as.
auto GetOffGrid() const -> ArrayView<const std::int32_t>
Returns the indices of the selected events off the grid, sorted.
auto GetCellCount() const -> std::int32_t
Returns the number of selected events of the grid.
auto GetTotalCount() const -> std::int32_t
Returns the number of all selected events, on the grid and off it.
auto Contains(std::uint32_t cell) const -> bool
Returns true if a tile is selected.
auto ContainsOffGrid(std::int32_t index) const -> bool
Returns true if an event off the grid is selected.
void Clear()
Clears the selection.
void Set(std::uint32_t cell)
Selects a tile, replacing what was selected.
void SetOffGrid(std::int32_t index)
Selects an event off the grid, replacing what was selected.
void Add(std::uint32_t cell)
Adds a tile to the selection.
void AddOffGrid(std::int32_t index)
Adds an event off the grid to the selection.
void Remove(std::uint32_t cell)
Removes a tile from the selection.
void RemoveOffGrid(std::int32_t index)
Removes an event off the grid from the selection.
void Assign(SmallVectorImpl<std::uint32_t>&& cells)
Replaces the selection by the given tiles, in any order, no event off the grid stays selected.
void AssignOffGrid(SmallVectorImpl<std::int32_t>&& indices)
Replaces the selected events off the grid by the given ones, in any order, the tiles stay selected.
void DropEmpty(const LevelDocument& document)
Drops tiles that have no event anymore, as after an undo, and finds the selected events off the grid again.

Function documentation

ArrayView<const std::uint32_t> Jazz2::Editor::EventSelection::GetCells() const

Returns the selected tiles of the event grid as.

x + y * width, sorted

void Jazz2::Editor::EventSelection::DropEmpty(const LevelDocument& document)

Drops tiles that have no event anymore, as after an undo, and finds the selected events off the grid again.

Called after every change of the events. Events off the grid added or removed since the last call move the indices of the others, the selected ones are found again by what they were then, those that are gone are dropped.