Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable takt barlines and import from Volpiano #3743

Merged
merged 7 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/vrv/barline.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define __VRV_BARLINE_H__

#include "atts_shared.h"
#include "atts_visual.h"
#include "layerelement.h"

namespace vrv {
Expand All @@ -27,6 +28,7 @@ enum class BarLinePosition { None, Left, Right };
*/
class BarLine : public LayerElement,
public AttBarLineLog,
public AttBarLineVis,
public AttColor,
public AttNNumberLike,
public AttVisibility {
Expand Down
8 changes: 6 additions & 2 deletions src/barline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,22 @@ namespace vrv {

static const ClassRegistrar<BarLine> s_factory("barLine", BARLINE);

BarLine::BarLine() : LayerElement(BARLINE, "bline-"), AttBarLineLog(), AttColor(), AttNNumberLike(), AttVisibility()
BarLine::BarLine()
: LayerElement(BARLINE, "bline-"), AttBarLineLog(), AttBarLineVis(), AttColor(), AttNNumberLike(), AttVisibility()
{
this->RegisterAttClass(ATT_BARLINELOG);
this->RegisterAttClass(ATT_BARLINEVIS);
this->RegisterAttClass(ATT_COLOR);
this->RegisterAttClass(ATT_VISIBILITY);

this->Reset();
}

BarLine::BarLine(ClassId classId)
: LayerElement(classId, "bline-"), AttBarLineLog(), AttColor(), AttNNumberLike(), AttVisibility()
: LayerElement(classId, "bline-"), AttBarLineLog(), AttBarLineVis(), AttColor(), AttNNumberLike(), AttVisibility()
{
this->RegisterAttClass(ATT_BARLINELOG);
this->RegisterAttClass(ATT_BARLINEVIS);
this->RegisterAttClass(ATT_COLOR);
this->RegisterAttClass(ATT_VISIBILITY);

Expand All @@ -59,6 +62,7 @@ void BarLine::Reset()
LayerElement::Reset();

this->ResetBarLineLog();
this->ResetBarLineVis();
this->ResetColor();
this->ResetVisibility();

Expand Down
2 changes: 2 additions & 0 deletions src/iomei.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2381,6 +2381,7 @@ void MEIOutput::WriteBarLine(pugi::xml_node currentNode, BarLine *barLine)

this->WriteLayerElement(currentNode, barLine);
barLine->WriteBarLineLog(currentNode);
barLine->WriteBarLineVis(currentNode);
barLine->WriteColor(currentNode);
barLine->WriteNNumberLike(currentNode);
barLine->WriteVisibility(currentNode);
Expand Down Expand Up @@ -6428,6 +6429,7 @@ bool MEIInput::ReadBarLine(Object *parent, pugi::xml_node barLine)
this->ReadLayerElement(barLine, vrvBarLine);

vrvBarLine->ReadBarLineLog(barLine);
vrvBarLine->ReadBarLineVis(barLine);
vrvBarLine->ReadColor(barLine);
vrvBarLine->ReadNNumberLike(barLine);
vrvBarLine->ReadVisibility(barLine);
Expand Down
15 changes: 15 additions & 0 deletions src/iovolpiano.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

//----------------------------------------------------------------------------

#include "barline.h"
#include "clef.h"
#include "doc.h"
#include "layer.h"
Expand Down Expand Up @@ -110,6 +111,20 @@ bool VolpianoInput::Import(const std::string &volpiano)
else if (ch == 'I' || ch == 'W' || ch == 'X' || ch == 'Y' || ch == 'Z') {
accidVal = ACCIDENTAL_WRITTEN_n;
}
else if (ch == '3') {
BarLine *single = new BarLine();
layer->AddChild(single);
}
else if (ch == '4') {
BarLine *dbl = new BarLine();
dbl->SetForm(BARRENDITION_dbl);
layer->AddChild(dbl);
}
else if (ch == '7') {
BarLine *takt = new BarLine();
takt->SetMethod(BARMETHOD_takt);
layer->AddChild(takt);
}
}

// add minimal scoreDef
Expand Down
16 changes: 14 additions & 2 deletions src/view_element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,23 @@ void View::DrawBarLine(DeviceContext *dc, LayerElement *element, Layer *layer, S
barLine->SetEmptyBB();
return;
}
StaffDef *drawingStaffDef = staff->m_drawingStaffDef;
// Determine the method
assert(drawingStaffDef);
auto [hasMethod, method] = barLine->GetMethod(drawingStaffDef);
if (barLine->HasMethod()) {
lpugin marked this conversation as resolved.
Show resolved Hide resolved
method = barLine->AttBarLineVis::GetMethod();
}

dc->StartGraphic(element, "", element->GetID());

const int yTop = staff->GetDrawingY();
const int yBottom = yTop - (staff->m_drawingLines - 1) * m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize);
int yTop = staff->GetDrawingY();
int yBottom = yTop - (staff->m_drawingLines - 1) * m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize);

if (method == BARMETHOD_takt) {
yTop += m_doc->GetDrawingUnit(staff->m_drawingStaffSize);
yBottom = yTop - m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize);
}

const int offset = (yTop == yBottom) ? m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) : 0;

Expand Down