MNX Document Model
Loading...
Searching...
No Matches
mnx::util::LayoutSpan Struct Reference

Describes a visual span in a flattened MNX layout. More...

#include <LayoutHelpers.h>

Public Types

enum class  Kind { Staff , Group }
 Identifies whether this span represents a staff or a group. More...
 

Public Attributes

Kind kind {}
 The kind of layout element represented by this span.
 
size_t startIndex {}
 Index of the first staff covered by this span.
 
size_t endIndex {}
 Index of the last staff covered by this span.
 
size_t depth {}
 Nesting depth of this span within the layout hierarchy.
 
std::optional< std::string > label
 Optional label text associated with this span.
 
std::optional< LabelReflabelref
 Optional label reference associated with this span.
 
std::optional< LayoutSymbolsymbol
 Optional layout symbol associated with this span.
 
StaffGroupBarlineOverride barlineOverride = StaffGroupBarlineOverride::None
 Resolved barline override associated with this span.
 
std::optional< LayoutStaffKeySet > sources
 Optional staff sources associated with this span.
 

Detailed Description

Describes a visual span in a flattened MNX layout.

A LayoutSpan represents either a single staff or a group of staves after the layout hierarchy has been flattened. Each span records the range of staff indices it covers in the flattened staff list, its nesting depth in the layout hierarchy, and any visual metadata (label, label reference, symbol, and resolved barline override) associated with it.

Spans are typically sorted by ascending startIndex and then by ascending depth, so that outer groups precede inner groups and staff spans appear at the deepest level.

Member Enumeration Documentation

◆ Kind

enum class mnx::util::LayoutSpan::Kind
strong

Identifies whether this span represents a staff or a group.

Enumerator
Staff 

Span represents a single staff.

Group 

Span represents a group of staves.

Member Data Documentation

◆ barlineOverride

StaffGroupBarlineOverride mnx::util::LayoutSpan::barlineOverride = StaffGroupBarlineOverride::None

Resolved barline override associated with this span.

For group spans, this is Group::calcBarlineOverride(). For staff spans, this is StaffGroupBarlineOverride::None.

◆ depth

size_t mnx::util::LayoutSpan::depth {}

Nesting depth of this span within the layout hierarchy.

Depth reflects the layout content tree level: groups live at the container depth, and staff spans are always one level deeper (leaf depth = container depth + 1). This means ungrouped staves in the root content still have depth 1, while root-level groups have depth 0. Example: with root content [Flute, Clarinet, PianoGroup], where PianoGroup contains two staves, the group span for PianoGroup has depth 0, while all staff spans (Flute, Clarinet, and both piano staves) have depth 1. For a given startIndex, group spans always have a smaller depth than the staff span they contain, ensuring staff spans sort last.

◆ endIndex

size_t mnx::util::LayoutSpan::endIndex {}

Index of the last staff covered by this span.

For staff spans, endIndex is equal to startIndex. For group spans, this is the index of the final staff contained anywhere within the group.

◆ label

std::optional<std::string> mnx::util::LayoutSpan::label

Optional label text associated with this span.

For staff spans, this corresponds to Staff::label. For group spans, it corresponds to Group::label.

◆ labelref

std::optional<LabelRef> mnx::util::LayoutSpan::labelref

Optional label reference associated with this span.

When present, this refers to a shared or externally defined label and is used instead of label.

◆ sources

std::optional<LayoutStaffKeySet> mnx::util::LayoutSpan::sources

Optional staff sources associated with this span.

For staff spans, this corresponds to Staff::sources. For group spans, it is std::nullopt.

◆ startIndex

size_t mnx::util::LayoutSpan::startIndex {}

Index of the first staff covered by this span.

This index refers to the position of the staff in the flattened staff sequence produced by depth-first traversal of the layout.

◆ symbol

std::optional<LayoutSymbol> mnx::util::LayoutSpan::symbol

Optional layout symbol associated with this span.

For staff spans, this corresponds to Staff::symbol. For group spans, it corresponds to Group::symbol.