Skip to content

Commit

Permalink
Merge pull request #3469 from rism-digital/develop-text-div
Browse files Browse the repository at this point in the history
Remove pgHead2 and pgFoot2 and add support for div (WIP)
  • Loading branch information
ahankinson authored Jul 3, 2023
2 parents 79f6374 + 0ebb4fe commit fa13013
Show file tree
Hide file tree
Showing 48 changed files with 1,291 additions and 924 deletions.
80 changes: 35 additions & 45 deletions Verovio.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion bindings/iOS/all.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
#import <VerovioFramework/devicecontext.h>
#import <VerovioFramework/devicecontextbase.h>
#import <VerovioFramework/dir.h>
#import <VerovioFramework/div.h>
#import <VerovioFramework/doc.h>
#import <VerovioFramework/docselection.h>
#import <VerovioFramework/dot.h>
Expand Down Expand Up @@ -170,7 +171,6 @@
#import <VerovioFramework/pb.h>
#import <VerovioFramework/pedal.h>
#import <VerovioFramework/pgfoot.h>
#import <VerovioFramework/pgfoot2.h>
#import <VerovioFramework/pghead.h>
#import <VerovioFramework/pghead2.h>
#import <VerovioFramework/phrase.h>
Expand All @@ -186,6 +186,7 @@
#import <VerovioFramework/reg.h>
#import <VerovioFramework/reh.h>
#import <VerovioFramework/rend.h>
#import <VerovioFramework/repeatmark.h>
#import <VerovioFramework/resetfunctor.h>
#import <VerovioFramework/resources.h>
#import <VerovioFramework/rest.h>
Expand Down Expand Up @@ -226,6 +227,7 @@
#import <VerovioFramework/text.h>
#import <VerovioFramework/textdirinterface.h>
#import <VerovioFramework/textelement.h>
#import <VerovioFramework/textlayoutelement.h>
#import <VerovioFramework/tie.h>
#import <VerovioFramework/timeinterface.h>
#import <VerovioFramework/timemap.h>
Expand Down
1 change: 1 addition & 0 deletions include/vrv/adjustyposfunctor.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class AdjustYPosFunctor : public DocFunctor {
* Functor interface
*/
///@{
FunctorCode VisitDiv(Div *div) override;
FunctorCode VisitStaffAlignment(StaffAlignment *staffAlignment) override;
FunctorCode VisitSystem(System *system) override;
///@}
Expand Down
4 changes: 3 additions & 1 deletion include/vrv/alignfunctor.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class AlignMeasuresFunctor : public DocFunctor {
* Functor interface
*/
///@{
FunctorCode VisitDiv(Div *div) override;
FunctorCode VisitMeasure(Measure *measure) override;
FunctorCode VisitScoreDef(ScoreDef *scoreDef) override;
FunctorCode VisitSection(Section *section) override;
Expand Down Expand Up @@ -159,6 +160,7 @@ class AlignVerticallyFunctor : public DocFunctor {
* Functor interface
*/
///@{
FunctorCode VisitDiv(Div *div) override;
FunctorCode VisitFig(Fig *fig) override;
FunctorCode VisitMeasure(Measure *measure) override;
FunctorCode VisitPageEnd(Page *page) override;
Expand Down Expand Up @@ -188,7 +190,7 @@ class AlignVerticallyFunctor : public DocFunctor {
int m_cumulatedShift;
// The sum of justification factors per page
int m_justificationSum;
// The page width
// The page width - used for setting the horizontal position of <rend> withing text layout elements
int m_pageWidth;
};

Expand Down
3 changes: 3 additions & 0 deletions include/vrv/castofffunctor.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class CastOffSystemsFunctor : public DocFunctor {
* Functor interface
*/
///@{
FunctorCode VisitDiv(Div *div) override;
FunctorCode VisitEditorialElement(EditorialElement *editorialElement) override;
FunctorCode VisitEnding(Ending *ending) override;
FunctorCode VisitMeasure(Measure *measure) override;
Expand Down Expand Up @@ -183,6 +184,7 @@ class CastOffEncodingFunctor : public DocFunctor {
* Functor interface
*/
///@{
FunctorCode VisitDiv(Div *div) override;
FunctorCode VisitEditorialElement(EditorialElement *editorialElement) override;
FunctorCode VisitEnding(Ending *ending) override;
FunctorCode VisitMeasure(Measure *measure) override;
Expand Down Expand Up @@ -296,6 +298,7 @@ class CastOffToSelectionFunctor : public DocFunctor {
* Functor interface
*/
///@{
FunctorCode VisitDiv(Div *div) override;
FunctorCode VisitEditorialElement(EditorialElement *editorialElement) override;
FunctorCode VisitMeasure(Measure *measure) override;
FunctorCode VisitPageElement(PageElement *pageElement) override;
Expand Down
26 changes: 26 additions & 0 deletions include/vrv/comparison.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,32 @@ class AttVisibilityComparison : public ClassIdComparison {
data_BOOLEAN m_isVisible;
};

//----------------------------------------------------------------------------
// AttFormeworkComparison
//----------------------------------------------------------------------------

/**
* This class evaluates if the object is of a certain ClassId and has a @func of value func.
*/
class AttFormeworkComparison : public ClassIdComparison {

public:
AttFormeworkComparison(ClassId classId, data_PGFUNC func) : ClassIdComparison(classId) { m_func = func; }

bool operator()(const Object *object) override
{
if (!MatchesType(object)) return false;
// This should not happen, but just in case
if (!object->HasAttClass(ATT_FORMEWORK)) return false;
const AttFormework *element = dynamic_cast<const AttFormework *>(object);
assert(element);
return (element->GetFunc() == m_func);
}

private:
data_PGFUNC m_func;
};

//----------------------------------------------------------------------------
// CrossAlignmentReferenceComparison
//----------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions include/vrv/convertfunctor.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class ConvertToPageBasedFunctor : public Functor {
* Functor interface
*/
///@{
FunctorCode VisitDiv(Div *div) override;
FunctorCode VisitEditorialElement(EditorialElement *editorialElement) override;
FunctorCode VisitEditorialElementEnd(EditorialElement *editorialElement) override;
FunctorCode VisitEnding(Ending *ending) override;
Expand Down
111 changes: 111 additions & 0 deletions include/vrv/div.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/////////////////////////////////////////////////////////////////////////////
// Name: div.h
// Author: Laurent Pugin
// Created: 2023
// Copyright (c) Authors and others. All rights reserved.
/////////////////////////////////////////////////////////////////////////////

#ifndef __VRV_DIV_H__
#define __VRV_DIV_H__

#include "textlayoutelement.h"

namespace vrv {

//----------------------------------------------------------------------------
// Div
//----------------------------------------------------------------------------

/**
* This class represents an MEI Div.
* The current implementation accepts <rend> as child of <div>, which is not valid
* See https://github.com/music-encoding/music-encoding/issues/1189
*/
class Div : public TextLayoutElement {
public:
/**
* @name Constructors, destructors, and other standard methods
* Reset method resets all attribute classes
*/
///@{
Div();
virtual ~Div();
void Reset() override;
std::string GetClassName() const override { return "Div"; }
///@}

/**
* @name Get and set the inline drawing flag
*/
///@{
bool GetDrawingInline() const { return m_drawingInline; }
void SetDrawingInline(bool drawingInline) { m_drawingInline = drawingInline; }
///@}

/**
* @name Get the X and Y drawing position
*/
///@{
int GetDrawingX() const override;
int GetDrawingY() const override;
///@}

/**
* @name Get and set the X and Y drawing relative positions
*/
///@{
int GetDrawingXRel() const { return m_drawingXRel; }
virtual void SetDrawingXRel(int drawingXRel);
void CacheXRel(bool restore = false);
int GetDrawingYRel() const { return m_drawingYRel; }
virtual void SetDrawingYRel(int drawingYRel);
void CacheYRel(bool restore = false);
///@}

/**
* Overriden to get the appropriate margin
*/
int GetTotalHeight(const Doc *doc) const override;

int GetTotalWidth(const Doc *doc) const override;

//----------//
// Functors //
//----------//

/**
* Interface for class functor visitation
*/
///@{
FunctorCode Accept(Functor &functor) override;
FunctorCode Accept(ConstFunctor &functor) const override;
FunctorCode AcceptEnd(Functor &functor) override;
FunctorCode AcceptEnd(ConstFunctor &functor) const override;
///@}

private:
//
public:
//
private:
/**
* The Y drawing relative position of the object.
* It is re-computed everytime the object is drawn and it is not stored in the file.
*/
int m_drawingYRel;

/**
* The X drawing relative position of the object.
* It is re-computed everytime the object is drawn and it is not stored in the file.
*/
int m_drawingXRel;

/**
* A flag indicating that the div should be displayed inline
*/
bool m_drawingInline;
};

} // namespace vrv

#endif
24 changes: 12 additions & 12 deletions include/vrv/functorinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class ControlElement;
class Course;
class Custos;
class Dir;
class Div;
class Dot;
class Dots;
class Doc;
Expand Down Expand Up @@ -94,9 +95,7 @@ class Pages;
class Pb;
class Pedal;
class PgFoot;
class PgFoot2;
class PgHead;
class PgHead2;
class Phrase;
class PitchInflection;
class Plica;
Expand Down Expand Up @@ -131,6 +130,7 @@ class TabGrp;
class Tempo;
class Text;
class TextElement;
class TextLayoutElement;
class Tie;
class TimestampAligner;
class TimestampAttr;
Expand Down Expand Up @@ -224,19 +224,19 @@ class FunctorInterface {
///@}

/**
* @name Visit running elements
* @name Visit text layout elements
*/
///@{
virtual FunctorCode VisitDiv(Div *div);
virtual FunctorCode VisitDivEnd(Div *div);
virtual FunctorCode VisitRunningElement(RunningElement *runningElement);
virtual FunctorCode VisitRunningElementEnd(RunningElement *runningElement);
virtual FunctorCode VisitPgFoot(PgFoot *pgFoot);
virtual FunctorCode VisitPgFootEnd(PgFoot *pgFoot);
virtual FunctorCode VisitPgFoot2(PgFoot2 *pgFoot2);
virtual FunctorCode VisitPgFoot2End(PgFoot2 *pgFoot2);
virtual FunctorCode VisitPgHead(PgHead *pgHead);
virtual FunctorCode VisitPgHeadEnd(PgHead *pgHead);
virtual FunctorCode VisitPgHead2(PgHead2 *pgHead2);
virtual FunctorCode VisitPgHead2End(PgHead2 *pgHead2);
virtual FunctorCode VisitTextLayoutElement(TextLayoutElement *textLayoutElement);
virtual FunctorCode VisitTextLayoutElementEnd(TextLayoutElement *textLayoutElement);
///@}

/**
Expand Down Expand Up @@ -581,19 +581,19 @@ class ConstFunctorInterface {
///@}

/**
* @name Visit running elements
* @name Visit text layout elements
*/
///@{
virtual FunctorCode VisitDiv(const Div *div);
virtual FunctorCode VisitDivEnd(const Div *div);
virtual FunctorCode VisitRunningElement(const RunningElement *runningElement);
virtual FunctorCode VisitRunningElementEnd(const RunningElement *runningElement);
virtual FunctorCode VisitPgFoot(const PgFoot *pgFoot);
virtual FunctorCode VisitPgFootEnd(const PgFoot *pgFoot);
virtual FunctorCode VisitPgFoot2(const PgFoot2 *pgFoot2);
virtual FunctorCode VisitPgFoot2End(const PgFoot2 *pgFoot2);
virtual FunctorCode VisitPgHead(const PgHead *pgHead);
virtual FunctorCode VisitPgHeadEnd(const PgHead *pgHead);
virtual FunctorCode VisitPgHead2(const PgHead2 *pgHead2);
virtual FunctorCode VisitPgHead2End(const PgHead2 *pgHead2);
virtual FunctorCode VisitTextLayoutElement(const TextLayoutElement *textLayoutElement);
virtual FunctorCode VisitTextLayoutElementEnd(const TextLayoutElement *textLayoutElement);
///@}

/**
Expand Down
13 changes: 7 additions & 6 deletions include/vrv/iomei.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class Damage;
class Del;
class Dot;
class Dir;
class Div;
class DurationInterface;
class Dynam;
class Ending;
Expand Down Expand Up @@ -111,9 +112,7 @@ class Pages;
class Pb;
class Pedal;
class PgFoot;
class PgFoot2;
class PgHead;
class PgHead2;
class Phrase;
class PitchInflection;
class PitchInterface;
Expand Down Expand Up @@ -159,6 +158,7 @@ class Tempo;
class Text;
class TextDirInterface;
class TextElement;
class TextLayoutElement;
class Tie;
class TimePointInterface;
class TimeSpanningInterface;
Expand Down Expand Up @@ -357,9 +357,8 @@ class MEIOutput : public Output {
void WriteScoreDef(pugi::xml_node currentNode, ScoreDef *scoreDef);
void WriteGrpSym(pugi::xml_node currentNode, GrpSym *grmSym);
void WritePgFoot(pugi::xml_node currentNode, PgFoot *pgFoot);
void WritePgFoot2(pugi::xml_node currentNode, PgFoot2 *pgFoot2);
void WritePgHead(pugi::xml_node currentNode, PgHead *pgHead);
void WritePgHead2(pugi::xml_node currentNode, PgHead2 *pgHead2);
void WriteDiv(pugi::xml_node currentNode, Div *div);
void WriteStaffGrp(pugi::xml_node currentNode, StaffGrp *staffGrp);
void WriteStaffDef(pugi::xml_node currentNode, StaffDef *staffDef);
void WriteInstrDef(pugi::xml_node currentNode, InstrDef *instrDef);
Expand Down Expand Up @@ -519,6 +518,7 @@ class MEIOutput : public Output {
void WriteControlElement(pugi::xml_node element, ControlElement *object);
void WriteEditorialElement(pugi::xml_node element, EditorialElement *object);
void WriteLayerElement(pugi::xml_node element, LayerElement *object);
void WriteTextLayoutElement(pugi::xml_node element, TextLayoutElement *object);
void WriteRunningElement(pugi::xml_node element, RunningElement *object);
void WriteScoreDefElement(pugi::xml_node element, ScoreDefElement *object);
void WriteSystemElement(pugi::xml_node element, SystemElement *object);
Expand Down Expand Up @@ -655,9 +655,8 @@ class MEIInput : public Input {
bool ReadScoreDefChildren(Object *parent, pugi::xml_node parentNode);
bool ReadGrpSym(Object *parent, pugi::xml_node grpSym);
bool ReadPgFoot(Object *parent, pugi::xml_node pgFoot);
bool ReadPgFoot2(Object *parent, pugi::xml_node pgFoot2);
bool ReadPgHead(Object *parent, pugi::xml_node pgHead);
bool ReadPgHead2(Object *parent, pugi::xml_node pgHead2);
bool ReadDiv(Object *parent, pugi::xml_node div);
bool ReadRunningChildren(Object *parent, pugi::xml_node parentNode, Object *filter = NULL);
bool ReadStaffGrp(Object *parent, pugi::xml_node staffGrp);
bool ReadStaffGrpChildren(Object *parent, pugi::xml_node parentNode);
Expand Down Expand Up @@ -818,6 +817,7 @@ class MEIInput : public Input {
bool ReadControlElement(pugi::xml_node element, ControlElement *object);
bool ReadEditorialElement(pugi::xml_node element, EditorialElement *object);
bool ReadLayerElement(pugi::xml_node element, LayerElement *object);
bool ReadTextLayoutElement(pugi::xml_node element, TextLayoutElement *object);
bool ReadRunningElement(pugi::xml_node element, RunningElement *object);
bool ReadScoreDefElement(pugi::xml_node element, ScoreDefElement *object);
bool ReadSystemElement(pugi::xml_node element, SystemElement *object);
Expand Down Expand Up @@ -888,6 +888,7 @@ class MEIInput : public Input {
// to MEI 5.0.0
void UpgradeKeySigTo_5_0_0(pugi::xml_node keySig);
void UpgradePageTo_5_0_0(Page *page);
void UpgradePgHeadFootTo_5_0_0(pugi::xml_node element);
void UpgradeMeasureTo_5_0_0(pugi::xml_node measure);
void UpgradeMeterSigTo_5_0_0(pugi::xml_node meterSig, MeterSig *vrvMeterSig);
void UpgradeScoreDefElementTo_5_0_0(pugi::xml_node scoreDefElement);
Expand Down
Loading

0 comments on commit fa13013

Please sign in to comment.