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

Formatting order needs to be rethought #522

Open
Silverwolf90 opened this issue Jan 2, 2017 · 7 comments
Open

Formatting order needs to be rethought #522

Silverwolf90 opened this issue Jan 2, 2017 · 7 comments

Comments

@Silverwolf90
Copy link
Contributor

Silverwolf90 commented Jan 2, 2017

Ok so now that we'll soon have staves set on elements before formatting, we'll be able to freely convert between pixels/staff spaces and do all positioning of elements in Formatter#format and the various formatting hooks.

Unfortunately, we still have some major issues around this:

  1. We can't format modifiers (ie: articulations) vertically until stem tips have been finalized
  2. Stem tips can't be finalized until beam slopes have been calculated
  3. Beams slopes can't be calculated without x positions on the notes
  4. We only have x positions after all modifiers have been formatted, and the tick contexts have been formatted (This is why stem tips are currently calculated in Formatter#postFormat)

I'm fleshing out some thoughts on this, but they'll likely be pretty radical :P

@Silverwolf90 Silverwolf90 changed the title Formatting design needs to be rethought Formatting order needs to be rethought Jan 3, 2017
@Silverwolf90
Copy link
Contributor Author

Silverwolf90 commented Jan 7, 2017

Well here it goes:

How about we rip out all formatting-centric code and start from scratch with a more rigorous set of test cases.

I realize this is not a practical solution, but since formatting is really naive and doesn't correctly consider dependencies between objects, I think it's flawed at a fundamental level and a complete redesign is the ideal solution.

Ignoring this issue of dependencies, it's not like formatting in VexFlow is robust in the first place and it doesn't even include spanning elements (eg: hairpins, tuplets) nor does it include higher-level formatting (ie: multiple staves/measures) . And as I've mentioned before I find the ModifierContext difficult to understand.

@0xfe
Copy link
Owner

0xfe commented Jan 7, 2017

It would be a pretty big effort. Want to write up a rough design proposal in the wiki? (we could iterate on that)

@Silverwolf90
Copy link
Contributor Author

Silverwolf90 commented Jan 13, 2017

Yeah, I'll do that at some point. It seems like it's a lot more work than it actually is. While every element has its own formatting hook, this is unnecessary. Yes, some groups of elements have specialized formatting like dots and accidentals. But after these have been formatted as a group they remain static and the group as a whole can be treated as a single element. As a result, a single formatting algorithm that does advance-by-width or an advance-by-height is probably sufficient for all single-point modifiers (this is a slight oversimplification since positions within the staff might need refinement, but this is just detail).

Basically, we should format by direction (ie: left, right, top, bottom), not by element type. This is simpler, less opinionated, and more flexible, because now the order of elements (ie: if a fermata should appear above or below an annotation) can be arbitrarily different for each direction.

So a really coarse order would be:

  • left modifiers
  • right modifiers
  • notes
  • top modifiers
  • bottom modifiers

@gristow
Copy link
Collaborator

gristow commented Jan 13, 2017

Just a word to say, @Silverwolf90, that your idea of an advance-by-width/advance-by-height algorithm makes a lot of sense and seems promising intuitively to me. (It matches how I was taught to do manuscript by hand in college, anyway!), and I'd be curious to see an idea of how that might be fleshed out.

@0xfe
Copy link
Owner

0xfe commented Jan 13, 2017

The ordering sounds good, though where would the logic for modifier-specific formatting belong? E.g., accidental rules. Part of the reason for the element-specific hooks was so new elements can encode their own internal rules.

@Silverwolf90
Copy link
Contributor Author

Silverwolf90 commented Jan 14, 2017

Good question, not sure. I'd guess that they'll mainly remain as is, just that we hook into them a different way. The formatting hooks for things like Ornament and Annotation, which are nearly identical, are the one's that will get factored out because they can be handled generically.

@SalahAdDin
Copy link

@Silverwolf90 what's about it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants