MNX Document Model
Loading...
Searching...
No Matches
Layout.h
1/*
2 * Copyright (C) 2025, Robert Patterson
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 * THE SOFTWARE.
21 */
22#pragma once
23
24#include "Enumerations.h"
25#include "BaseTypes.h"
26
27namespace mnx {
28
33namespace layout {
34
37{
38public:
39 using mnx::ContentObject::ContentObject;
40};
41
47{
48public:
50 StaffSource(const std::shared_ptr<json>& root, json_pointer pointer)
52 {
53 }
54
59 StaffSource(Base& parent, std::string_view key, std::string& partId)
61 {
62 set_part(partId);
63 }
64
65 MNX_OPTIONAL_PROPERTY(std::string, label);
67 MNX_REQUIRED_PROPERTY(std::string, part);
70 MNX_OPTIONAL_PROPERTY(std::string, voice);
71};
72
77class Staff : public ContentObject
78{
79public:
80 using ContentObject::ContentObject;
81
85 Staff(Base& parent, std::string_view key)
86 : ContentObject(parent, key)
87 {
88 // required children
89 create_sources();
90 }
91
92 MNX_OPTIONAL_PROPERTY(std::string, label);
96
97 inline static constexpr std::string_view ContentTypeValue = "staff";
98};
99
104class Group : public ContentObject
105{
106public:
107 using ContentObject::ContentObject;
108
112 Group(Base& parent, std::string_view key)
113 : ContentObject(parent, key)
114 {
115 // required children
116 create_content();
117 }
118
120 MNX_OPTIONAL_PROPERTY(std::string, label);
122
123 inline static constexpr std::string_view ContentTypeValue = "group";
124};
125
126} // namespace layout
127
133{
134public:
135 using ArrayElementObject::ArrayElementObject;
136
140 Layout(Base& parent, std::string_view key)
142 {
143 // required children
144 create_content();
145 }
146
148
149 inline static constexpr std::string_view JsonSchemaTypeName = "system-layout";
150};
151
152} // namespace mnx
Represents an MNX object that is included as an array element.
Definition BaseTypes.h:631
Represents an MNX array, encapsulating property access.
Definition BaseTypes.h:493
Base class wrapper for all MNX JSON nodes.
Definition BaseTypes.h:212
json_pointer pointer() const
Returns the json_pointer for this node.
Definition BaseTypes.h:274
T parent() const
Returns the parent object for this node.
Definition BaseTypes.h:260
const std::shared_ptr< json > & root() const
Returns the root.
Definition BaseTypes.h:294
Class for content arrays.
Definition BaseTypes.h:716
Base class for objects that are elements of content arrays.
Definition BaseTypes.h:656
Represents the element of the layout array in an MNX document.
Definition Layout.h:133
MNX_REQUIRED_CHILD(ContentArray, content)
Required child containing the layout content (groups and staves).
Layout(Base &parent, std::string_view key)
Creates a new Layout class as a child of a JSON element.
Definition Layout.h:140
static constexpr std::string_view JsonSchemaTypeName
required for mapping
Definition Layout.h:149
Base class for objects that are elements of layout content arrays.
Definition Layout.h:37
Represents a groups of staves within an MNX layout.
Definition Layout.h:105
MNX_OPTIONAL_PROPERTY(LayoutSymbol, symbol)
The symbol down the left side.
Group(Base &parent, std::string_view key)
Creates a new Group class as a child of a JSON element.
Definition Layout.h:112
MNX_REQUIRED_CHILD(ContentArray, content)
Required child containing the layout content (groups and staves).
MNX_OPTIONAL_PROPERTY(std::string, label)
Label to be rendered to the left of the group.
static constexpr std::string_view ContentTypeValue
type value that identifies the type within the content array
Definition Layout.h:123
Represents a staff source for a staff in a layout in a score.
Definition Layout.h:47
MNX_OPTIONAL_PROPERTY(std::string, label)
Text to appear to the left of the staff.
MNX_OPTIONAL_PROPERTY(StemDirection, stem)
The stem direction for this staff source.
MNX_OPTIONAL_PROPERTY(std::string, voice)
The voice id to draw from.
StaffSource(const std::shared_ptr< json > &root, json_pointer pointer)
Constructor for existing staff sources.
Definition Layout.h:50
MNX_OPTIONAL_PROPERTY_WITH_DEFAULT(int, staff, 1)
The staff number within the part.
MNX_OPTIONAL_PROPERTY(LabelRef, labelref)
The labelref to use (rather than label)
MNX_REQUIRED_PROPERTY(std::string, part)
Id of the part to draw from.
StaffSource(Base &parent, std::string_view key, std::string &partId)
Creates a new StaffSource class as a child of a JSON element.
Definition Layout.h:59
Represents a single staff instance within an MNX layout.
Definition Layout.h:78
static constexpr std::string_view ContentTypeValue
type value that identifies the type within the content array
Definition Layout.h:97
MNX_REQUIRED_CHILD(Array< StaffSource >, sources)
The sources for this staff.
Staff(Base &parent, std::string_view key)
Creates a new Staff class as a child of a JSON element.
Definition Layout.h:85
MNX_OPTIONAL_PROPERTY(LabelRef, labelref)
The labelref to use (rather than label)
MNX_OPTIONAL_PROPERTY(LayoutSymbol, symbol)
The symbol down the left side.
MNX_OPTIONAL_PROPERTY(std::string, label)
Label to be rendered to the left of the staff.
object model for MNX format
json::json_pointer json_pointer
JSON pointer class for MNX.
Definition BaseTypes.h:198
LayoutSymbol
The symbols available to bracket a staff group.
Definition Enumerations.h:136
LabelRef
The values available in a labelref.
Definition Enumerations.h:126
StemDirection
The values available in a labelref.
Definition Enumerations.h:277