Skip to content
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

Convert LINE_WIDTH property to spatium #23875

Merged
merged 10 commits into from
Aug 12, 2024

Conversation

miiizen
Copy link
Contributor

@miiizen miiizen commented Aug 2, 2024

Resolves: #19367
Resolves: #23040

This PR changes the type of the LINE_WIDTH property to Spatium from Millimetre. The Millimetre type was causing some issues and inconsistencies between the score and parts and with spanners, due to it needing to be rescaled on any spatium change and this being applied inconsistently. It was also in some cases not true to size. For example, text lines set to a thickness of 0.15sp were actually 0.1488sp.

@miiizen miiizen marked this pull request as draft August 2, 2024 13:21
@miiizen miiizen marked this pull request as ready for review August 5, 2024 10:03
@miiizen miiizen requested a review from oktophonie August 7, 2024 08:20
oktophonie
oktophonie previously approved these changes Aug 7, 2024
@oktophonie oktophonie dismissed their stale review August 7, 2024 09:49

Nope, vtests

@oktophonie

This comment was marked as resolved.

Millimetre lineWidth() const { return m_lineWidth; }
double lineWidthMag() const { return m_lineWidth * mag(); }
void setLineWidth(Millimetre lineWidth) { m_lineWidth = lineWidth; }
double point(Spatium sp) const override { return sp.val() * score()->style().spatium(); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should use score()->style().spatium() though, or should it? Cause that returns the score-wide value, but this item may be on a small (or otherwise scaled) staff. We should always use item->spatium().

Also, like Casper, I too prefer these implementations to be in the .cpp file (the idea being that .h files should #include as few other .h files as possible)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gives correct results - scaling is done in lineWidthMag() which scales by mag(). mag() applies both the stave spatium and the chord's scale. But actually maybe there's a UI issue I missed:
If you have a scaled stave, the "Thickness" property appears to the user to be measured in relation to the stave - (eg. by default always 0.1sp which is what we want). If you then make the chord cue size, the stem's thickness is reduced, but the value appears to remain at 0.1sp.
I can change point to use item->spatium and lineWidthMag to use chord()->instrinsicMag to make this more clear. There might have to be some file compatibility changes for reading old files.

Spatium bracketWidth() const { return m_bracketWidth; }
void setBracketWidth(Spatium s) { m_bracketWidth = s; }

double point(Spatium sp) const override { return sp.val() * score()->style().spatium(); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially the same spatium/chord mag confusion. If so, we won't need these overrides at all.

@@ -403,7 +403,7 @@ class EngravingItem : public EngravingObject

bool isPrintable() const;
bool isPlayable() const;
double point(const Spatium sp) const { return sp.val() * spatium(); }
virtual double point(const Spatium sp) const { return sp.val() * spatium(); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like what this method does, but I find the name a bit misleading. "Point" for me is immediately associated to an (x, y) pair of data. Can we think of something a bit clearer? Perhaps something like double absoluteLenFromSpatium(const Spatium), which could have in future a corresponding opposite absoluteLenToSpatium. @cbjeukendrup what do you think?

Also, pure pedantry: the const keyword isn't really necessary when the parameter is passed by copy (as opposed to passing by reference, where const makes a big difference).

Copy link
Contributor

@mike-spa mike-spa Aug 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or even just absoluteFromSpatium, as it's not always necessarily a "length".

@oktophonie oktophonie added the vtests This PR produces approved changes to vtest results label Aug 12, 2024
@RomanPudashkin RomanPudashkin merged commit 1a9fc23 into musescore:master Aug 12, 2024
10 of 11 checks passed
@miiizen miiizen mentioned this pull request Aug 14, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vtests This PR produces approved changes to vtest results
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spatium value is multiplied for long staff text lines glissando line width is different if added from parts
5 participants