diff --git a/include/vrv/options.h b/include/vrv/options.h index 0a3d9cda4d..f545882b35 100644 --- a/include/vrv/options.h +++ b/include/vrv/options.h @@ -75,6 +75,8 @@ enum option_FOOTER { FOOTER_none = 0, FOOTER_auto, FOOTER_encoded, FOOTER_always enum option_HEADER { HEADER_none = 0, HEADER_auto, HEADER_encoded }; +enum option_LIGATURE_OBL { LIGATURE_OBL_auto = 0, LIGATURE_OBL_straight, LIGATURE_OBL_curved }; + enum option_MULTIRESTSTYLE { MULTIRESTSTYLE_auto = 0, MULTIRESTSTYLE_default, @@ -148,6 +150,7 @@ class Option { static const std::map s_fontFallback; static const std::map s_footer; static const std::map s_header; + static const std::map s_ligatureOblique; static const std::map s_multiRestStyle; static const std::map s_pedalStyle; static const std::map s_systemDivider; @@ -845,7 +848,7 @@ class Options { OptionIntMap m_durationEquivalence; OptionBool m_ligatureAsBracket; - OptionBool m_ligatureStraight; + OptionIntMap m_ligatureOblique; OptionBool m_mensuralScoreUp; OptionBool m_mensuralResponsiveView; OptionBool m_mensuralToCmn; diff --git a/include/vrv/view.h b/include/vrv/view.h index f73e89492d..d8c9b17b23 100644 --- a/include/vrv/view.h +++ b/include/vrv/view.h @@ -641,7 +641,7 @@ class View { void CalcBrevisPoints( Note *note, Staff *staff, Point *topLeft, Point *bottomRight, int sides[4], int shape, bool isMensuralBlack); void CalcObliquePoints(Note *note1, Note *note2, Staff *staff, Point points[4], int sides[4], int shape, - bool isMensuralBlack, bool firstHalf); + bool isMensuralBlack, bool firstHalf, bool straight); /** * Internal methods for drawing a BeamSegment diff --git a/src/options.cpp b/src/options.cpp index a5346251fa..0745085504 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -44,6 +44,9 @@ const std::map Option::s_footer const std::map Option::s_header = { { HEADER_none, "none" }, { HEADER_auto, "auto" }, { HEADER_encoded, "encoded" } }; +const std::map Option::s_ligatureOblique + = { { LIGATURE_OBL_auto, "auto" }, { LIGATURE_OBL_straight, "straight" }, { LIGATURE_OBL_curved, "curved" } }; + const std::map Option::s_multiRestStyle = { { MULTIRESTSTYLE_auto, "auto" }, { MULTIRESTSTYLE_default, "default" }, { MULTIRESTSTYLE_block, "block" }, { MULTIRESTSTYLE_symbols, "symbols" } }; @@ -1832,9 +1835,9 @@ Options::Options() m_ligatureAsBracket.Init(false); this->Register(&m_ligatureAsBracket, "ligatureAsBracket", &m_mensural); - m_ligatureStraight.SetInfo("Ligature straight", "Render oblique ligatures as straight polygons"); - m_ligatureStraight.Init(false); - this->Register(&m_ligatureStraight, "ligatureStraight", &m_mensural); + m_ligatureOblique.SetInfo("Ligature oblique", "Ligature oblique shape"); + m_ligatureOblique.Init(LIGATURE_OBL_auto, &Option::s_ligatureOblique); + this->Register(&m_ligatureOblique, "ligatureOblique", &m_mensural); m_mensuralResponsiveView.SetInfo( "Mensural reduced view", "Convert mensural content to a more responsive view reduced to the seleceted markup"); diff --git a/src/view_mensural.cpp b/src/view_mensural.cpp index 2888b8370d..c4b5bf28d6 100644 --- a/src/view_mensural.cpp +++ b/src/view_mensural.cpp @@ -350,12 +350,17 @@ void View::DrawLigatureNote(DeviceContext *dc, LayerElement *element, Layer *lay bool oblique = ((shape & LIGATURE_OBLIQUE) || (prevShape & LIGATURE_OBLIQUE)); bool obliqueEnd = (prevShape & LIGATURE_OBLIQUE); bool stackedEnd = (shape & LIGATURE_STACKED); - bool straight = m_doc->GetOptions()->m_ligatureStraight.GetValue(); - int stemWidth = m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize); int strokeWidth = 2.8 * stemWidth; /** end code duplicated */ + bool straight = true; + switch (m_doc->GetOptions()->m_ligatureOblique.GetValue()) { + case LIGATURE_OBL_auto: straight = !isMensuralBlack; break; + case LIGATURE_OBL_straight: straight = true; break; + case LIGATURE_OBL_curved: straight = false; break; + } + Point points[4]; Point *topLeft = &points[0]; Point *bottomLeft = &points[1]; @@ -373,11 +378,11 @@ void View::DrawLigatureNote(DeviceContext *dc, LayerElement *element, Layer *lay // First half of the oblique - checking the nextNote is there just in case, but is should if ((shape & LIGATURE_OBLIQUE) && nextNote) { // return; - CalcObliquePoints(note, nextNote, staff, points, sides, shape, isMensuralBlack, true); + CalcObliquePoints(note, nextNote, staff, points, sides, shape, isMensuralBlack, true, straight); } // Second half of the oblique - checking the prevNote is there just in case, but is should else if ((prevShape & LIGATURE_OBLIQUE) && prevNote) { - CalcObliquePoints(prevNote, note, staff, points, sides, prevShape, isMensuralBlack, false); + CalcObliquePoints(prevNote, note, staff, points, sides, prevShape, isMensuralBlack, false, straight); } else { assert(false); @@ -386,7 +391,7 @@ void View::DrawLigatureNote(DeviceContext *dc, LayerElement *element, Layer *lay // Oblique polygons if (straight) { - if (fillNotehead) { + if (!fillNotehead) { this->DrawObliquePolygon(dc, topLeft->x, topLeft->y, topRight->x, topRight->y, -strokeWidth); this->DrawObliquePolygon(dc, bottomLeft->x, bottomLeft->y, bottomRight->x, bottomRight->y, strokeWidth); } @@ -646,7 +651,7 @@ void View::CalcBrevisPoints( } void View::CalcObliquePoints(Note *note1, Note *note2, Staff *staff, Point points[4], int sides[4], int shape, - bool isMensuralBlack, bool firstHalf) + bool isMensuralBlack, bool firstHalf, bool straight) { assert(note1); assert(note2); @@ -655,7 +660,8 @@ void View::CalcObliquePoints(Note *note1, Note *note2, Staff *staff, Point point const int stemWidth = m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize); const int noteDiff = note1->PitchDifferenceTo(note2); - const int yAdjust = noteDiff * stemWidth / 10; + // Adjustment for end points according to the note diff + const int yAdjust = noteDiff * stemWidth / 5; Point *topLeft = &points[0]; Point *bottomLeft = &points[1]; @@ -686,10 +692,10 @@ void View::CalcObliquePoints(Note *note1, Note *note2, Staff *staff, Point point slope = (double)(bottomRight->y - bottomLeft->y) / (double)(bottomRight->x - bottomLeft->x); int length = (bottomRight->x - bottomLeft->x) / 2; - slope *= 0.85; + if (!straight) slope *= 0.85; if (firstHalf) { - // make sure there are some pixels of overlap + // make sure there is one pixel of overlap length += 1; bottomRight->x = bottomLeft->x + length; topRight->x = bottomRight->x; @@ -710,80 +716,6 @@ void View::CalcObliquePoints(Note *note1, Note *note2, Staff *staff, Point point } } -/* -void View::CalcObliquePoints(Note *note1, Note *note2, Staff *staff, Point points[4], int sides[4], int shape, - bool isMensuralBlack, bool firstHalf) -{ - assert(note1); - assert(note2); - assert(staff); - - const int stemWidth = m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize); - - Point *topLeft = &points[0]; - Point *bottomLeft = &points[1]; - Point *topRight = &points[2]; - Point *bottomRight = &points[3]; - - int sides1[4]; - CalcBrevisPoints(note1, staff, topLeft, bottomLeft, sides1, shape, isMensuralBlack); - // Correct the x of bottomLeft - bottomLeft->x = topLeft->x; - // Copy the left sides - sides[0] = sides1[0]; - sides[1] = sides1[1]; - - int sides2[4]; - // add OBLIQUE shape to make sure sides are shortened in mensural black - CalcBrevisPoints(note2, staff, topRight, bottomRight, sides2, LIGATURE_OBLIQUE, isMensuralBlack); - // Correct the x of topRight; - topRight->x = bottomRight->x; - // Copy the right sides - sides[2] = sides2[2]; - sides[3] = sides2[3]; - - // With oblique it is best visually to move them up / down - more with (white) ligatures with serif - double adjustmentFactor = (isMensuralBlack) ? 2.5 : 1.8; - double slope = 0.0; - slope *= 1.6; - if (bottomRight->x != bottomLeft->x) - slope = (double)(bottomRight->y - bottomLeft->y) / (double)(bottomRight->x - bottomLeft->x); - int adjustment = (int)(slope * stemWidth) * adjustmentFactor; - topLeft->y -= adjustment; - // bottomLeft->y -= adjustment; - if (firstHalf) { - topRight->y -= adjustment; - // bottomRight->y += adjustment; - } - else { - // topRight->y += adjustment; - // bottomRight->y -= adjustment; - } - - slope = 0.0; - // recalculate slope after adjustment - if (bottomRight->x != bottomLeft->x) - slope = (double)(bottomRight->y - bottomLeft->y) / (double)(bottomRight->x - bottomLeft->x); - int length = (bottomRight->x - bottomLeft->x) / 2; - slope *= 1.6; - - if (firstHalf) { - // make sure there are some pixels of overlap - // length += 10; - bottomRight->x = bottomLeft->x + length; - topRight->x = bottomRight->x; - bottomRight->y = bottomLeft->y + (int)(length * slope); - topRight->y = topLeft->y + (int)(length * slope); - } - else { - bottomLeft->x = bottomLeft->x + length; - topLeft->x = bottomLeft->x; - bottomLeft->y = bottomLeft->y + (int)(length * slope); - topLeft->y = topLeft->y + (int)(length * slope); - } -} -*/ - data_STEMDIRECTION View::GetMensuralStemDir(Layer *layer, Note *note, int verticalCenter) { // constants