diff --git a/include/vrv/rest.h b/include/vrv/rest.h index b737eebc0d7..f860b6b63d2 100644 --- a/include/vrv/rest.h +++ b/include/vrv/rest.h @@ -8,6 +8,7 @@ #ifndef __VRV_REST_H__ #define __VRV_REST_H__ +#include "altsyminterface.h" #include "atts_externalsymbols.h" #include "atts_mensural.h" #include "durationinterface.h" @@ -34,6 +35,7 @@ enum RestNotePlace { RNP_UNSET = -1, RNP_noteInSpace, RNP_noteOnLine }; * This class models the MEI element. */ class Rest : public LayerElement, + public AltSymInterface, public DurationInterface, public PositionInterface, public AttColor, @@ -69,6 +71,7 @@ class Rest : public LayerElement, * @name Getter to interfaces */ ///@{ + AltSymInterface *GetAltSymInterface() override { return vrv_cast(this); } PositionInterface *GetPositionInterface() override { return vrv_cast(this); } const PositionInterface *GetPositionInterface() const override { return vrv_cast(this); } DurationInterface *GetDurationInterface() override { return vrv_cast(this); } diff --git a/src/iomei.cpp b/src/iomei.cpp index 386c011bf74..f85c4840aab 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -2799,6 +2799,7 @@ void MEIOutput::WriteRest(pugi::xml_node currentNode, Rest *rest) assert(rest); this->WriteLayerElement(currentNode, rest); + this->WriteAltSymInterface(currentNode, rest); this->WriteDurationInterface(currentNode, rest); this->WritePositionInterface(currentNode, rest); rest->WriteColor(currentNode); @@ -3819,6 +3820,9 @@ bool MEIInput::IsAllowed(std::string element, Object *filterParent) if (element == "note") { return true; } + if (element == "rest") { + return true; + } else { return false; } @@ -6967,6 +6971,7 @@ bool MEIInput::ReadRest(Object *parent, pugi::xml_node rest) } } + this->ReadAltSymInterface(rest, vrvRest); this->ReadDurationInterface(rest, vrvRest); this->ReadPositionInterface(rest, vrvRest); vrvRest->ReadColor(rest); diff --git a/src/rest.cpp b/src/rest.cpp index c9c3db2903b..f9abe232e86 100644 --- a/src/rest.cpp +++ b/src/rest.cpp @@ -22,6 +22,7 @@ #include "layer.h" #include "smufl.h" #include "staff.h" +#include "symboldef.h" #include "system.h" #include "transposition.h" #include "vrv.h" @@ -153,6 +154,7 @@ static const ClassRegistrar s_factory("rest", REST); Rest::Rest() : LayerElement(REST, "rest-") + , AltSymInterface() , DurationInterface() , PositionInterface() , AttColor() @@ -161,6 +163,7 @@ Rest::Rest() , AttExtSymNames() , AttRestVisMensural() { + this->RegisterInterface(AltSymInterface::GetAttClasses(), AltSymInterface::IsInterface()); this->RegisterInterface(DurationInterface::GetAttClasses(), DurationInterface::IsInterface()); this->RegisterInterface(PositionInterface::GetAttClasses(), PositionInterface::IsInterface()); this->RegisterAttClass(ATT_COLOR); @@ -176,6 +179,7 @@ Rest::~Rest() {} void Rest::Reset() { LayerElement::Reset(); + AltSymInterface::Reset(); DurationInterface::Reset(); PositionInterface::Reset(); this->ResetColor(); @@ -241,6 +245,23 @@ char32_t Rest::GetRestGlyph(const int duration) const char32_t code = resources->GetGlyphCode(this->GetGlyphName()); if (NULL != resources->GetGlyph(code)) return code; } + // If there is @altsym (third priority) + else if (this->HasAltsym() && this->HasAltSymbolDef()) { + const SymbolDef *symbolDef = this->GetAltSymbolDef(); + const Symbol *symbol = vrv_cast(symbolDef->GetFirst(SYMBOL)); + if (symbol != NULL) { + // If there is @glyph.num, return glyph based on it (fourth priority) + if (symbol->HasGlyphNum()) { + const char32_t code = symbol->GetGlyphNum(); + if (NULL != resources->GetGlyph(code)) return code; + } + // If there is @glyph.name (fifth priority) + else if (symbol->HasGlyphName()) { + const char32_t code = resources->GetGlyphCode(symbol->GetGlyphName()); + if (NULL != resources->GetGlyph(code)) return code; + } + } + } if (this->IsMensuralDur()) { switch (duration) { diff --git a/src/tabgrp.cpp b/src/tabgrp.cpp index 72436718d33..d9b668b0733 100644 --- a/src/tabgrp.cpp +++ b/src/tabgrp.cpp @@ -16,6 +16,7 @@ #include "editorial.h" #include "functor.h" #include "note.h" +#include "rest.h" #include "tabdursym.h" namespace vrv { @@ -46,6 +47,9 @@ bool TabGrp::IsSupportedChild(Object *child) if (child->Is(NOTE)) { assert(dynamic_cast(child)); } + else if (child->Is(REST)) { + assert(dynamic_cast(child)); + } else if (child->Is(TABDURSYM)) { assert(dynamic_cast(child)); } diff --git a/src/view_element.cpp b/src/view_element.cpp index eb253fc26fd..77a2ab378e4 100644 --- a/src/view_element.cpp +++ b/src/view_element.cpp @@ -53,6 +53,7 @@ #include "stem.h" #include "syl.h" #include "system.h" +#include "tabgrp.h" #include "tie.h" #include "tuplet.h" #include "verse.h" @@ -1512,10 +1513,20 @@ void View::DrawRest(DeviceContext *dc, LayerElement *element, Layer *layer, Staf const int staffSize = staff->GetDrawingStaffNotationSize(); int drawingDur = rest->GetActualDur(); if (drawingDur == DUR_NONE) { - if (!dc->Is(BBOX_DEVICE_CONTEXT)) { - LogWarning("Missing duration for rest '%s'", rest->GetID().c_str()); + // in tablature the @dur is in the parent TabGrp + if (staff->IsTablature()) { + TabGrp *tabGrp = vrv_cast(rest->GetFirstAncestor(TABGRP)); + if (tabGrp != NULL) { + drawingDur = tabGrp->GetActualDur(); + } + } + + if (drawingDur == DUR_NONE) { + if (!dc->Is(BBOX_DEVICE_CONTEXT)) { + LogWarning("Missing duration for rest '%s'", rest->GetID().c_str()); + } + drawingDur = DUR_4; } - drawingDur = DUR_4; } const char32_t drawingGlyph = rest->GetRestGlyph(drawingDur);