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

Time Signature simplifications #1513

Merged
merged 4 commits into from
Jan 2, 2023
Merged

Time Signature simplifications #1513

merged 4 commits into from
Jan 2, 2023

Conversation

mscuthbert
Copy link
Collaborator

To the extent possible without breaking backwards compatibility of public interfaces, this PR implements a little bit of my (second) comment on #1498 which @sschmidTU gave a thumbs up to: deemphasizing using structs in favor of objects themselves on TimeSignature and TimeSigNote.

Places line, glyph, num (now "is_numeric") attributes directly on the TimeSignature object (where the crucial .point) already is, rather than on a .info interface. (Note that the name of this struct differs among modifiers. On the Clef object it is ".clef", so changing one type of Modifier without changing all should not break code expecting a standard .info struct.)

TimeSigNote now stores the reference to the TimeSignature object rather than the .info struct, so that it can be modified up until the point it is formatted/drawn.

Feel free to comment if this is the right direction or not. I won't be offended (too much. :-D ) if it's not where the project should go. But class-objects are quite lightweight and as long as we're creating the TimeSignature object anyhow, might as well hang onto it until we're ready.

All visual tests pass.

@mscuthbert mscuthbert added the 4.x label Dec 31, 2022
@mscuthbert
Copy link
Collaborator Author

(if this were a 5.0 PR, I'd get rid of getInfo(), TimeSignatureInfo and unify setTimeSig to setTimeSpec, but those aren't backwards compatible).

src/timesignature.ts Outdated Show resolved Hide resolved
src/timesignature.ts Show resolved Hide resolved
src/timesignature.ts Show resolved Hide resolved
Document everything in timeSignature.ts

Add general documentation for what StaveModifier.placeGlyphOnLine does.

Reset width any time Glyph is changed

Fix one bug in TimeSigGlyph where the `.line` of the TimeSignature was being ignored.
@mscuthbert mscuthbert requested a review from rvilarl January 1, 2023 21:31
@mscuthbert
Copy link
Collaborator Author

Done -- and in fact in fixing setting width on change of glyph, uncovered another bug in the current system:

The two-system StaveModifier tests work by first adding all the modifiers, including addTimeSignature() and then work by calling setTimeSignature() which reuses the current TimeSignature object but changes the timeSpec. Since the width was (previously) set only in the constructor, changing the timeSpec did not change the width. This can most easily been seen when changing the final time signature from 9/8 (a thin TS) to C (a wider TS).

Current master:
StaveModifier Begin___End_StaveModifier_Test Bravura_reference

PR:
StaveModifier Begin___End_StaveModifier_Test Bravura_current

In Petaluma it's even more obvious (again master followed by PR):

StaveModifier Begin___End_StaveModifier_Test Petaluma_reference

StaveModifier Begin___End_StaveModifier_Test Petaluma_current

That there should be a little bit of empty staff between the end TS and the end of the line is confirmed by Gould Behind Bars:
Screenshot 2023-01-01 at 11 28 07

@mscuthbert
Copy link
Collaborator Author

Notice that the last mentioned bug still exists on TimeSigNote since changing the TimeSigNote.timeSig.setGlyph() will only change the width of TimeSigNote.timeSig not of TimeSigNote itself. Will discuss more in the context of mixins.

@rvilarl rvilarl merged commit 54ba908 into master Jan 2, 2023
@mscuthbert mscuthbert deleted the timesig_simplifications branch January 11, 2023 00:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants