Skip to content

Commit

Permalink
Merge pull request rism-digital#1084 from earboxer/lastSystemJustific…
Browse files Browse the repository at this point in the history
…ationWidth

Last System Justification: Use parameter to set minimum width for justification.
  • Loading branch information
lpugin authored May 31, 2019
2 parents 2dd6cc4 + 31a0023 commit 57eea05
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
5 changes: 4 additions & 1 deletion include/vrv/functorparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -1216,25 +1216,28 @@ class GetAlignmentLeftRightParams : public FunctorParams {
* member 2: the non justifiable margin
* member 3: the system full width (without system margins)
* member 4: the functor to be redirected to the MeasureAligner
* member 5: the doc
**/

class JustifyXParams : public FunctorParams {
public:
JustifyXParams(Functor *functor)
JustifyXParams(Functor *functor, Doc *doc)
{
m_measureXRel = 0;
m_justifiableRatio = 1.0;
m_leftBarLineX = 0;
m_rightBarLineX = 0;
m_systemFullWidth = 0;
m_functor = functor;
m_doc = doc;
}
int m_measureXRel;
double m_justifiableRatio;
int m_leftBarLineX;
int m_rightBarLineX;
int m_systemFullWidth;
Functor *m_functor;
Doc *m_doc;
};

//----------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions include/vrv/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ class Options {
OptionBool m_landscape;
OptionBool m_mensuralToMeasure;
OptionDbl m_midiTempoAdjustment;
OptionDbl m_minLastJustification;
OptionBool m_mmOutput;
OptionBool m_noFooter;
OptionBool m_noHeader;
Expand Down
4 changes: 4 additions & 0 deletions src/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,10 @@ Options::Options()
m_midiTempoAdjustment.Init(1.0, 0.2, 4.0);
this->Register(&m_midiTempoAdjustment, "midiTempoAdjustment", &m_generalLayout);

m_minLastJustification.SetInfo("Minimum last-system-justification width", "The last system is only justified if the unjustified width is greater than this percent");
m_minLastJustification.Init(0.8, 0.0, 1.0);
this->Register(&m_minLastJustification, "minLastJustification", &m_general);

m_mmOutput.SetInfo("MM output", "Specify that the output in the SVG is given in mm (default is px)");
m_mmOutput.Init(false);
this->Register(&m_mmOutput, "mmOutput", &m_general);
Expand Down
2 changes: 1 addition & 1 deletion src/page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ void Page::JustifyHorizontally()

// Justify X position
Functor justifyX(&Object::JustifyX);
JustifyXParams justifyXParams(&justifyX);
JustifyXParams justifyXParams(&justifyX, doc);
justifyXParams.m_systemFullWidth
= doc->m_drawingPageWidth - doc->m_drawingPageMarginLeft - doc->m_drawingPageMarginRight;
this->Process(&justifyX, &justifyXParams);
Expand Down
8 changes: 4 additions & 4 deletions src/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,12 +592,12 @@ int System::JustifyX(FunctorParams *functorParams)
LogWarning("\tDrawing justifiable width: %d", m_drawingJustifiableWidth);
}

// Check if we are on the last page and on the last system - do no justify it if ratio > 1.25
// Eventually we should make this a parameter
// Check if we are on the last page and on the last system:
// do not justify it if the non-justified width is less than a specified percent.
if ((parent->GetIdx() == parent->GetParent()->GetChildCount() - 1)
&& (this->GetIdx() == parent->GetChildCount() - 1)) {
// HARDCODED
if (params->m_justifiableRatio > 1.25) {
double minLastJust = params->m_doc->GetOptions()->m_minLastJustification.GetValue();
if ((minLastJust > 0) && (params->m_justifiableRatio > (1/minLastJust))) {
return FUNCTOR_STOP;
}
}
Expand Down

0 comments on commit 57eea05

Please sign in to comment.