Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
object_selection_system

Zrythm Object Selection System

Core Architecture

Zrythm uses a unified selection system that handles multiple arranger object types through Qt's ItemSelectionModel. The system bridges C++ models with QML views through several key components.

Key Components

Unified Model

UnifiedProxyModel aggregates multiple source models into a single selection context:

  • Maps source indices to unified indices with mapFromSource()
  • Supports mixed object types (regions, markers, notes, automation points)

Selection Tracking

SelectionTracker.qml provides per-object selection state:

  • Tracks isSelected property
  • Connects to global selection model changes
  • Used by all arranger object views

Selection Operator

ArrangerObjectSelectionOperator handles operations on selections:

QML Integration

Object Views

Each arranger object view integrates selection through:

SelectionTracker {
unifiedModelIndex: unifiedObjectsModel.mapFromSource(sourceModel.index(index, 0))
selectionModel: arrangerSelectionModel
}

Mouse Handling

Arranger.qml handles movement:

function moveSelectionsX(ticksDiff) {
selectionOperator.moveByTicks(ticksDiff);
}

Selection Logic

handleObjectSelection() manages selection modes:

  • Single click: Clear and select
  • Ctrl+click: Toggle selection
  • Shift+click: Range selection (TODO)

Movement Implementation

The MoveArrangerObjectsCommand:

  • Stores original positions for undo/redo
  • Applies tick delta to all selected objects
  • Handles mixed object types transparently

Performance

  • Lazy loading with visibility-based activation
  • Efficient index mapping through unified model
  • Batch processing of selected objects

This system provides consistent selection behavior across all arranger object types with full undo/redo support and Qt-native integration.