-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
fix #303756 and #293370: export to pdf/png/svg with the option to use the page color or the wallpaper #5935
Conversation
@@ -112,6 +112,7 @@ | |||
#define PREF_UI_CANVAS_FG_USECOLOR_IN_PALETTES "ui/canvas/foreground/useColorInPalettes" | |||
#define PREF_UI_CANVAS_BG_COLOR "ui/canvas/background/color" | |||
#define PREF_UI_CANVAS_FG_COLOR "ui/canvas/foreground/color" | |||
#define PREF_UI_CANVAS_FG_EXPORT_PDF "ui/canvas/foreground/export/pdf" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't that rather "background"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And why restrict this to PDF and not having it for PNG, SVG, and possibly MusicXML too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that it is "background". The background color is the one behind the page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as MusicXML is concerned, I will probably make some decently sized changes in the MusicXML code, so I'll add png and svg for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forground color is that of notes, staff lines etc, (black by default), background is white by default and your PR allows to change that. And not just for PDF anymore now, it seems
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The background color is dark-blue by default and the paper color is white.
The paper color is called fgColor in prefsdialog.*
You are probably right, but I seem unable to understand my mistake. I am essentially copying the implementation of useTheSameColorInPalettes (I should change the name of my macro).
Added the option for svg and png. |
946ce71
to
9b21805
Compare
Fixed formatting. |
The vtests are not happy. Some ore screwed up pretty badly |
0d1f975
to
7ae13cc
Compare
Hmm, seems the default paper color is #f9f9f9 and not white or #ffffff? |
I might have caused it by changing the way the pages are painted in svg (for uniformity). I reverted those changes and I am waiting for the new vtest. |
@@ -158,6 +158,7 @@ void Preferences::init(bool storeInMemoryOnly) | |||
{PREF_UI_CANVAS_FG_USECOLOR_IN_PALETTES, new BoolPreference(false, false)}, | |||
{PREF_UI_CANVAS_BG_COLOR, new ColorPreference(QColor("#142433"), false)}, | |||
{PREF_UI_CANVAS_FG_COLOR, new ColorPreference(QColor("#f9f9f9"), false)}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we'd need to interpret this color as white?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe not, but why then are the vtests show background color artifacts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vtests are happy now
mscore/file.cpp
Outdated
@@ -2225,6 +2234,13 @@ bool MuseScore::savePdf(QList<Score*> cs_, const QString& saveName) | |||
if (!firstPage) | |||
printer.newPage(); | |||
firstPage = false; | |||
|
|||
if(usePageColor) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
mscore/file.cpp
Outdated
for (int n = 0; n < pages; ++n) { | ||
if (!firstPage) | ||
printer.newPage(); | ||
firstPage = false; | ||
|
||
if(usePageColor) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Awesome that you're taking this up 👍
If it's not too much of a kerfuffle, i would go for that. It seems only logical for preferences to be concerned only with application wide-settings (such as the background color of the viewport), while page-settings ("paper color") would be a score property (as Having said that, it may still be useful to leave it in the preferences as "Default Paper color" that will be used when no individual paper color was defined for the score. I cannot judge the gravity of such a change - it could as well be done as a second iteration. Anyway i'd like to hear what the veterans have to say. |
mscore/file.cpp
Outdated
for (int n = 0; n < pages; ++n) { | ||
if (!firstPage) | ||
printer.newPage(); | ||
firstPage = false; | ||
|
||
if (usePageColor) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I sense a code smell here. The code itself looks fine to me, but the fact that it's is copied and pasted two more times does not (as it contradicts the DRY principle).
Suggestion would be to move those lines into a private subroutine (i.e. something like applyPageColor(Printer, pageNum)
) and just call that.
But i can see why that happened: At first glance it looks to me as if savePdf(Score* cs_, QPrinter& printer)
and savePdf(QList<Score*> cs_, const QString& saveName)
already have a certain amount of code duplication (if i'm not misunderstanding something here and they do something completely different), i'd advise to refactor this at some point in the near future to reduce technical debt and make the code more stable and easier to maintain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken care of :-)
One more thought: The Preferences call it "Paper", the variable used in the pull request under discussion refers to it as "Page" (as we're also discussing whether to move the UI component to "Page(s) Settings", while the Qt IDs refer to it as "Foreground") ;) "Paper" is a nice metaphore, but maybe not the ideal one as we're talking about "virtual" paper at best here... Suggestion: rename the UI setting to "Page Color" to reduce ambiguity? |
That new "Export" checkbox is unnecessary imho: It may introduce confusion, as it deals with exporting and thus would logically belong onto the "Export" tab - which has a similar checkbox for PNG already, which (as pointed out in #303756) currently only gives the option to export in (partially broken) transparency or plain white (a limitation that the PR under discussion fixes). If we get #303760 implemented in a followup increment, i believe that would solve current potential user confusion in their export workflow as it would provide a clearer, less ambiguous way of configuring exports ad-hoc, so right now my suggestion is to have this PR just include 1. + 2. of the following list:
Other variants of 3. would be not removing the preference option but renaming it to either (b) "page display color" or (c) "page default color", where (b) would make it clear that it's just the color it's displayed in, but not the actual page color (which would then be defined in score page settings), or (c) where it would be the default page color for new scores being created. So maybe that would need some discussion and find an agreement in the design chat first. |
fd99d61
to
459d2ac
Compare
Added wallpaper export. |
I would like to keep this PR about adding the functionality and leave the proposed UI changes (with which I agree) for another PR. |
mscore/file.cpp
Outdated
QPixmap* pm = new QPixmap(preferences.getString(PREF_UI_CANVAS_FG_WALLPAPER)); | ||
p.drawTiledPixmap(pl.at(n)->pageBoundingRect(), | ||
*pm, | ||
pl.at(n)->pageBoundingRect().topLeft() - QPoint(lrint(mscore->currentScoreView()->matrix().dx()), lrint(mscore->currentScoreView()->matrix().dy()))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add one more line break there before the 4th arg.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no 4th argument, but I see that it is quite convoluted. It should be clearer now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm... the third argument might be both useless and an obstacle in the future, I'll remove it. But if we want the exported wallpaper to be the same as in MuseScore I'll need to change it back.
mscore/file.cpp
Outdated
QPixmap* pm = new QPixmap(preferences.getString(PREF_UI_CANVAS_FG_WALLPAPER)); | ||
p.drawTiledPixmap(pl.at(n)->pageBoundingRect(), | ||
*pm, | ||
pl.at(n)->pageBoundingRect().topLeft() - QPoint(lrint(mscore->currentScoreView()->matrix().dx()), lrint(mscore->currentScoreView()->matrix().dy()))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dito
mscore/file.cpp
Outdated
QPixmap* pm = new QPixmap(preferences.getString(PREF_UI_CANVAS_FG_WALLPAPER)); | ||
p.drawTiledPixmap(pl.at(pageNumber)->pageBoundingRect(), | ||
*pm, | ||
pl.at(pageNumber)->pageBoundingRect().topLeft() - QPoint(lrint(mscore->currentScoreView()->matrix().dx()), lrint(mscore->currentScoreView()->matrix().dy()))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dito
mscore/file.cpp
Outdated
QPixmap* pm = new QPixmap(preferences.getString(PREF_UI_CANVAS_FG_WALLPAPER)); | ||
p.drawTiledPixmap(pl.at(pageNumber)->pageBoundingRect(), | ||
*pm, | ||
pl.at(pageNumber)->pageBoundingRect().topLeft() - QPoint(lrint(mscore->currentScoreView()->matrix().dx()), lrint(mscore->currentScoreView()->matrix().dy()))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dito
589b52d
to
6271502
Compare
…olor when exporting to pdf/svg/png
Cleanup/refactoring. |
Unfortunately, now not actual |
Resolves: https://musescore.org/en/node/303756 and https://musescore.org/en/node/293370
Added the ability to use the page color when exporting to PDF/PNG/SVG. The page color still is a preference. I could change that and make it part of each Page object (as proposed in the issue). Opinions on whether I should do that, or leave the page color as a preference are welcome :^)
Exporting the wallpaper seems a bit more problematic. The ScoreView changes the size of the displayed wallpaper depending on the paintEvent and zoom level. At the same time, changing the exported file depending on the zoom level in the program seems weird. I decided to use the size of the page which at least leads to consistent behavior when exporting.
Page Color:
![image](https://user-images.githubusercontent.com/21060365/79167818-07392f80-7df1-11ea-9e5c-b394c6840e39.png)
![Screenshot from 2020-04-19 12-36-05](https://user-images.githubusercontent.com/21060365/79684481-60aebd80-823a-11ea-8261-80c558f8f387.png)
Page Wallpaper:
![Screenshot from 2020-04-19 12-15-36](https://user-images.githubusercontent.com/21060365/79684487-6d331600-823a-11ea-9b23-715c621c2d62.png)
![Screenshot from 2020-04-19 12-16-33](https://user-images.githubusercontent.com/21060365/79684490-70c69d00-823a-11ea-8f45-adf9a9ad44a8.png)