forked from rism-digital/verovio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
syl.cpp
108 lines (86 loc) · 3.12 KB
/
syl.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/////////////////////////////////////////////////////////////////////////////
// Name: syl.cpp
// Author: Laurent Pugin
// Created: 2014
// Copyright (c) Authors and others. All rights reserved.
/////////////////////////////////////////////////////////////////////////////
#include "syl.h"
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
#include "note.h"
#include "verse.h"
#include "staff.h"
namespace vrv {
//----------------------------------------------------------------------------
// Syl
//----------------------------------------------------------------------------
Syl::Syl():
LayerElement("syl-"), TimeSpanningInterface(),
AttTypography(),
AttSylLog()
{
Reset();
}
Syl::~Syl()
{
}
void Syl::Reset()
{
LayerElement::Reset();
TimeSpanningInterface::Reset();
ResetTypography();
ResetSylLog();
m_drawingVerse = 1;
}
//----------------------------------------------------------------------------
// Functors methods
//----------------------------------------------------------------------------
int Syl::PrepareLyrics( ArrayPtrVoid params )
{
// param 0: the current Syl
// param 1: the last Note
// param 2: the last but one Note
Syl **currentSyl = static_cast<Syl**>(params[0]);
Note **lastNote = static_cast<Note**>(params[1]);
Note **lastButOneNote = static_cast<Note**>(params[2]);
Verse *verse = dynamic_cast<Verse*>( this->GetFirstParent( &typeid(Verse), MAX_NOTE_DEPTH ) );
if ( verse ) {
m_drawingVerse = std::max(verse->GetN(), 1);
}
this->SetStart( dynamic_cast<LayerElement*>( this->GetFirstParent( &typeid(Note), MAX_NOTE_DEPTH ) ) );
// At this stage currentSyl is actually the previous one that is ending here
if ((*currentSyl)) {
// The previous syl was an initial or median -> The note we just parsed is the end
if (((*currentSyl)->GetWordpos() == WORDPOS_i) || ((*currentSyl)->GetWordpos() == WORDPOS_m)) {
(*currentSyl)->SetEnd(*lastNote);
}
// The previous syl was a underscore -> the previous but one was the end
else if ((*currentSyl)->GetCon() == CON_u) {
(*currentSyl)->SetEnd(*lastButOneNote);
}
}
// Now decide what to do with the starting syl and check if it has a forward connector
if ((this->GetWordpos() == WORDPOS_i) || (this->GetWordpos() == WORDPOS_m)) {
(*currentSyl) = this;
return FUNCTOR_CONTINUE;
}
else if (this->GetCon() == CON_u) {
(*currentSyl) = this;
return FUNCTOR_CONTINUE;
}
else {
(*currentSyl) = NULL;
}
return FUNCTOR_CONTINUE;
}
int Syl::FillStaffCurrentTimeSpanning( ArrayPtrVoid params )
{
// Pass it to the pseudo functor of the interface
return TimeSpanningInterface::FillStaffCurrentTimeSpanning(params, this);
}
int Syl::ResetDarwing( ArrayPtrVoid params )
{
// Pass it to the pseudo functor of the interface
return TimeSpanningInterface::ResetDrawing(params, this);
};
} // namespace vrv