MUSX Document Model
Loading...
Searching...
No Matches
Layout.h
1/*
2 * Copyright (C) 2026, 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 <functional>
25
26#include "musx/dom/DocumentElement.h"
27#include "musx/dom/MusxInstance.h"
28
29namespace musx::util {
30
39
41enum class StaffOriginOffsetResolverDecision
42{
43 NotHandled,
44 Unavailable,
45 Offset
46};
47
50{
51 StaffOriginOffsetResolverDecision decision{StaffOriginOffsetResolverDecision::NotHandled};
53};
54
56using StaffOriginOffsetResolver = std::function<StaffOriginOffsetResolverResult(
57 const dom::DocumentPtr& document,
58 dom::Cmper partId,
59 const StaffOriginOffsetRequest& request)>;
60
62[[nodiscard]]
63dom::MusxInstanceList<dom::others::StaffUsed> calcSystemStavesOrScrollView(
64 const dom::DocumentPtr& document,
65 dom::Cmper partId,
66 dom::MeasCmper measureId);
67
71[[nodiscard]]
72StaffOriginOffsetResolverResult calcStaffOriginOffsetUsingSystemStaffProxy(
73 const dom::DocumentPtr& document,
74 dom::Cmper partId,
75 const StaffOriginOffsetRequest& request);
76
79[[nodiscard]]
80StaffOriginOffsetResolverResult calcStaffOriginOffsetUsingScrollViewProxy(
81 const dom::DocumentPtr& document,
82 dom::Cmper partId,
83 const StaffOriginOffsetRequest& request);
84
85} // namespace musx::util
Provides optional per-type extension methods for MusxInstanceList.
Definition MusxInstance.h:118
int16_t MeasCmper
Enigma meas Cmper (may be negative when not applicable)
Definition Fundamentals.h:64
uint16_t Cmper
Enigma "comperator" key type.
Definition Fundamentals.h:55
int32_t Edu
"Enigma Durational Units" value (1024 per quarter note)
Definition Fundamentals.h:61
std::shared_ptr< Document > DocumentPtr
Shared Document pointer.
Definition DocumentElement.h:35
int16_t StaffCmper
Enigma staff (staffId) Cmper (may be negative when not applicable)
Definition Fundamentals.h:65
Request for resolving one staff origin relative to another staff origin.
Definition Layout.h:33
dom::StaffCmper targetStaffId
Staff whose vertical origin is requested.
Definition Layout.h:35
dom::StaffCmper sourceStaffId
Staff whose vertical origin is the zero point for the returned offset.
Definition Layout.h:34
dom::MeasCmper measureId
Measure at which the staff origins are needed.
Definition Layout.h:36
dom::Edu eduPosition
EDU position within measureId at which the staff origins are needed.
Definition Layout.h:37
Result returned by a staff origin offset resolver.
Definition Layout.h:50
StaffOriginOffsetResolverDecision decision
Resolver decision.
Definition Layout.h:51
double targetOriginOffsetEvpu
Target staff origin offset in EVPU when decision is StaffOriginOffsetResolverDecision::Offset.
Definition Layout.h:52