Unsynced margins

• Apr 26, 2016 - 01:11
S4 - Minor
PR created

Refer: https://musescore.org/en/node/108196#comment-487686
Comments #3 and #4:
1. new score
2. layout -> page settings
3. switch between mm and in and click 'apply' (not 'ok')
4. repeat 3 a few times

The margins keep changing for me.

Now try the above but with clicking 'ok'.
The margins change a few times, but then stop changing.


Default margins for new score are 10mm except for bottom, which is 20mm
Switching to inch, then back to mm causes the left and right margins to change to 8.5mm from 10mm.
Switching back to inch again displays the correct, original 10mm value in inches = 0.39in
But from now on, no matter how many times you switch back and forth inches to mm, it's 8.5mm for left and right margins, and the inches are correct, but out of sync with the mm.

Seems this affects 2.0.3 and current master 994090f.


More info:
0) I just tested this in v1.3 and it is NOT an issue. Yet the 1.3 code looks identical in updateValues: https://sourceforge.net/p/mscore/code/HEAD/tree/trunk/mscore/mscore/pag…

1) If you choose Landscape first, then change the Units, the 8.5mm problem does not happen.

2) Page Settings units are stored internally in the PageFormat object as inches, then converted as needed to mm by multiplying times the INCH constant. My default page size is Letter, which is 8.5 inches wide.
edit: OK, never mind the left/right margin differences I mentioned in the first draft of this post, those are caused by the way PageFormat calculated right margins: pagewidth minus left margin. It's dynamic.

Here's the relevant code for PageSettings::updateValues:

Yes, widthValue is being applied to set the max on the left/right margins, and that seems like a place where the values could be modified, but widthValue has been properly multiplied by INCH (line 209), so it's the correct value. Note that the PageFormat objects margin values remain constant throughout this, it's the conversion to mm that is screwing it up somehow.

This issue boils down to the way the odd left margin is getting set to the page width value in inches, when the selected units are mm. In class PageFormat, the left margins are stored, the right margins are calculated as pageWidth - printableWidth - leftMargin. The even margins are by default derived from the odd margins.

This branch of mine does not exhibit this issue:

I don't know how it fixed this issue, but it appears to have done so. There is a lot of cleanup in page.cpp and pagesettings.cpp that I did, so I'll have to dig to figure it out.

edit: I had mentioned a right margin issue, but that appears to be a non-issue with my default settings/template file. If I open the blank.mscz template file, my margins are 10mm left and right.

It looks like the reproduction steps are slightly different for 3.X versions. Now one needs exactly to press OK (and not Apply, like in the original steps) in the page settings dialog and reopen it again to see the difference. Then the default 10mm margins change to 9.91mm for me.