Skip to content

Commit

Permalink
Rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
lpugin committed Jul 18, 2024
1 parent a38baf6 commit 89715f3
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 3 deletions.
3 changes: 3 additions & 0 deletions include/vrv/rest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -34,6 +35,7 @@ enum RestNotePlace { RNP_UNSET = -1, RNP_noteInSpace, RNP_noteOnLine };
* This class models the MEI <rest> element.
*/
class Rest : public LayerElement,
public AltSymInterface,
public DurationInterface,
public PositionInterface,
public AttColor,
Expand Down Expand Up @@ -69,6 +71,7 @@ class Rest : public LayerElement,
* @name Getter to interfaces
*/
///@{
AltSymInterface *GetAltSymInterface() override { return vrv_cast<AltSymInterface *>(this); }
PositionInterface *GetPositionInterface() override { return vrv_cast<PositionInterface *>(this); }
const PositionInterface *GetPositionInterface() const override { return vrv_cast<const PositionInterface *>(this); }
DurationInterface *GetDurationInterface() override { return vrv_cast<DurationInterface *>(this); }
Expand Down
5 changes: 5 additions & 0 deletions src/iomei.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down
21 changes: 21 additions & 0 deletions src/rest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -153,6 +154,7 @@ static const ClassRegistrar<Rest> s_factory("rest", REST);

Rest::Rest()
: LayerElement(REST, "rest-")
, AltSymInterface()
, DurationInterface()
, PositionInterface()
, AttColor()
Expand All @@ -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);
Expand All @@ -176,6 +179,7 @@ Rest::~Rest() {}
void Rest::Reset()
{
LayerElement::Reset();
AltSymInterface::Reset();
DurationInterface::Reset();
PositionInterface::Reset();
this->ResetColor();
Expand Down Expand Up @@ -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<const Symbol *>(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) {
Expand Down
4 changes: 4 additions & 0 deletions src/tabgrp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "editorial.h"
#include "functor.h"
#include "note.h"
#include "rest.h"
#include "tabdursym.h"

namespace vrv {
Expand Down Expand Up @@ -46,6 +47,9 @@ bool TabGrp::IsSupportedChild(Object *child)
if (child->Is(NOTE)) {
assert(dynamic_cast<Note *>(child));
}
else if (child->Is(REST)) {
assert(dynamic_cast<Rest *>(child));
}
else if (child->Is(TABDURSYM)) {
assert(dynamic_cast<TabDurSym *>(child));
}
Expand Down
17 changes: 14 additions & 3 deletions src/view_element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<TabGrp *>(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);

Expand Down

0 comments on commit 89715f3

Please sign in to comment.