Verovio
Source code documentation
lyricelement.h
1 // Name: lyricelement.h
3 // Author: Simon Waloschek
4 // Copyright (c) Authors and others. All rights reserved.
6 
7 #ifndef __VRV_LYRICELEMENT_H__
8 #define __VRV_LYRICELEMENT_H__
9 
10 #include "atts_shared.h"
11 #include "layerelement.h"
12 #include "offsetinterface.h"
13 
14 #include <algorithm>
15 #include <utility>
16 
17 namespace vrv {
18 
19 class Syl;
20 class Volta;
21 
22 //----------------------------------------------------------------------------
23 // LyricElement
24 //----------------------------------------------------------------------------
25 
27 class LyricElement : public LayerElement,
28  public OffsetInterface,
29  public AttColor,
30  public AttLang,
31  public AttPlacementRelStaff,
32  public AttTypography,
33  public AttVoltaGroupingSym {
34 public:
35  virtual ~LyricElement();
36  void Reset() override;
37 
39  bool IsSupportedChild(ClassId classId) override;
40 
41  OffsetInterface *GetOffsetInterface() override { return vrv_cast<OffsetInterface *>(this); }
42  const OffsetInterface *GetOffsetInterface() const override { return vrv_cast<const OffsetInterface *>(this); }
43 
45  int GetVoltaCount() const;
47  std::pair<int, int> GetVoltaDrawingRange() const;
49  bool HasDirectSyl() const;
51  bool HasDrawingDirectSylTrack() const { return m_drawingDirectSylTrack || this->HasDirectSyl(); }
52  void SetDrawingDirectSylTrack() const { m_drawingDirectSylTrack = true; }
53  void ResetDrawingDirectSylTrack() { m_drawingDirectSylTrack = false; }
55  int GetLyricLineCount() const;
57  int GetVoltaLineN(const Volta *volta) const;
58 
60  int GetDrawingVerseN() const { return m_drawingVerseN; }
61  void SetDrawingVerseN(int verseN) const { m_drawingVerseN = std::max(verseN, 1); }
63  int GetDrawingLyricGroupN() const { return m_drawingLyricGroupN; }
64  void SetDrawingLyricGroupN(int groupN) const { m_drawingLyricGroupN = std::max(groupN, 1); }
65  void ResetDrawingLyricGroup()
66  {
67  m_drawingVerseN = 1;
68  m_drawingLyricGroupN = 1;
69  m_drawingDirectSylTrack = false;
70  }
71 
73  int AdjustPosition(int &overlap, int freeSpace, const Doc *doc);
74 
75 protected:
76  explicit LyricElement(ClassId classId);
77 
78 private:
79  mutable int m_drawingVerseN;
80  mutable int m_drawingLyricGroupN;
81  mutable bool m_drawingDirectSylTrack;
82 };
83 
84 } // namespace vrv
85 
86 #endif
This class is a hold the data and corresponds to the model of a MVC design pattern.
Definition: doc.h:41
This class is a base class for the Layer (<layer>) content.
Definition: layerelement.h:51
Shared implementation for note-attached verse and refrain lyrics.
Definition: lyricelement.h:33
std::pair< int, int > GetVoltaDrawingRange() const
Return the lowest and highest document-wide drawing tracks used by this container's volta children.
int GetVoltaLineN(const Volta *volta) const
Return the one-based lyric row occupied by a volta alternative.
void Reset() override
Virtual reset method.
bool HasDrawingDirectSylTrack() const
Return whether the document-wide lyric group has a direct-syllable track.
Definition: lyricelement.h:51
bool IsSupportedChild(ClassId classId) override
Add sung text or an editorial wrapper to a lyric container.
int AdjustPosition(int &overlap, int freeSpace, const Doc *doc)
Calculate and apply a horizontal lyric-overlap adjustment.
int GetLyricLineCount() const
Return the total number of lyric rows, including a separate direct-syllable row.
int GetDrawingLyricGroupN() const
Stable processing group used to isolate connectors and horizontal spacing.
Definition: lyricelement.h:63
int GetDrawingVerseN() const
Drawing slot used for vertical lyric alignment.
Definition: lyricelement.h:60
bool HasDirectSyl() const
Return whether the container also has syllables outside volta containers.
int GetVoltaCount() const
Return the number of alternative lyric rows represented by volta children.
This class is an interface for elements having a single visual offset, such as arpeg,...
Definition: offsetinterface.h:28
Sung text for a specific iteration of a repeated section of music.
Definition: volta.h:26