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

BeamBase, Beam and TremoloTwoChord refactor #24820

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

miiizen
Copy link
Contributor

@miiizen miiizen commented Sep 19, 2024

I spotted a lot of duplicated code between Beam and TremoloTwoChord. I've unified this in BeamBase. This is mostly completely straightforward, with the exception of clearBeamSegments and setBeamDirection which need overriden methods to deal with the different numbers of chords expected on each beam.

It also looks like there's some leftover dead code from when two note and one note tremolos were a single class. I haven't tackled that in this PR, but we can slim the TremoloTwoChord class down even further in future.

Copy link
Contributor

@cbjeukendrup cbjeukendrup left a comment

Choose a reason for hiding this comment

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

Good work! A few thoughts:

src/engraving/dom/beambase.h Show resolved Hide resolved
Comment on lines 98 to 99
void setDirection(DirectionV val) { m_direction = val; }
virtual void setBeamDirection(DirectionV v) = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

This combination of methods looks potentially confusing. I'd rename setDirection to doSetDirection and make it protected; then rename setBeamDirection to setDirection.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've changed the names but doSetDirection needs to remain public for its use in TremoloLayout::layoutTwoNotesTremolo

Comment on lines +40 to +41
// idx 0 - DirectionV::AUTO or DirectionV::DOWN
// 1 - DirectionV::UP
Copy link
Contributor

Choose a reason for hiding this comment

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

Aside: I've always found "auto/down" vs "up" a strange classification and never understood why we'd ever treat "auto" as "down". But that's probably for another day.

@@ -45,6 +45,7 @@ class TremoloLayout
private:
static void layoutOneNoteTremolo(TremoloSingleChord* item, const LayoutContext& ctx, double x, double y, double h, double spatium);
static void layoutTwoNotesTremolo(TremoloTwoChord* item, const LayoutContext& ctx, double x, double y, double h, double spatium);
static void calcIsUp(TremoloTwoChord* item);
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like there is no implementation for this

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

Successfully merging this pull request may close these issues.

2 participants