-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Lyrics revamp and new options #22434
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
Changes from all commits
fe4c087
b4df4af
f474701
ce060a0
2c7d509
b5fbd42
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4503,7 +4503,7 @@ ChordRest* Score::findCR(Fraction tick, track_idx_t track) const | |
// find last chord/rest on staff that ends before tick | ||
//--------------------------------------------------------- | ||
|
||
ChordRest* Score::findCRinStaff(const Fraction& tick, staff_idx_t staffIdx) const | ||
ChordRest* Score::findChordRestEndingBeforeTickInStaff(const Fraction& tick, staff_idx_t staffIdx) const | ||
{ | ||
Fraction ptick = tick - Fraction::fromTicks(1); | ||
Measure* m = tick2measureMM(ptick); | ||
|
@@ -4545,6 +4545,28 @@ ChordRest* Score::findCRinStaff(const Fraction& tick, staff_idx_t staffIdx) cons | |
return 0; | ||
} | ||
|
||
ChordRest* Score::findChordRestEndingBeforeTickInTrack(const Fraction& tick, track_idx_t trackIdx) const | ||
{ | ||
Measure* measure = tick2measureMM(tick - Fraction::eps()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please explain why we need to subtract eps() here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because when tick falls exactly in-between two measures (meaning that one measure ends at tick and the next one starts at tick) tick2Measure returns the next one (which is what we want in 99% of cases). I'm subtracting eps() to make sure that I get the previous one in this case |
||
if (!measure) { | ||
LOGD("findCRinStaff: no measure for tick %d", tick.ticks()); | ||
return nullptr; | ||
} | ||
|
||
for (const Segment* segment = measure->last(); segment; segment = segment->prev()) { | ||
EngravingItem* item = segment->elementAt(trackIdx); | ||
if (!segment->isChordRestType() || !item) { | ||
continue; | ||
} | ||
ChordRest* chordRest = toChordRest(item); | ||
if (segment->tick() + chordRest->actualTicks() <= tick) { | ||
return chordRest; | ||
} | ||
} | ||
|
||
return nullptr; | ||
} | ||
|
||
//--------------------------------------------------------- | ||
// cmdNextPrevSystem | ||
//--------------------------------------------------------- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2306,6 +2306,30 @@ RectF TextBase::pageRectangle() const | |
return abbox(); | ||
} | ||
|
||
void TextBase::computeHighResShape(const FontMetrics& fontMetrics) | ||
{ | ||
Shape& highResShape = mutldata()->highResShape.mut_value(); | ||
highResShape.clear(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's better to call clear() before reserve() |
||
highResShape.elements().reserve(m_text.size()); | ||
|
||
for (const TextBlock& block : ldata()->blocks) { | ||
double x = 0; | ||
for (const TextFragment& fragment : block.fragments()) { | ||
x += fragment.pos.x(); | ||
size_t textSize = fragment.text.size(); | ||
for (int i = 0; i < textSize; ++i) { | ||
Char character = fragment.text.at(i); | ||
RectF characterBoundingRect = fontMetrics.tightBoundingRect(fragment.text.at(i)); | ||
characterBoundingRect.translate(x, 0.0); | ||
highResShape.add(characterBoundingRect); | ||
if (i + 1 < textSize) { | ||
x += fontMetrics.horizontalAdvance(character); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
//--------------------------------------------------------- | ||
// dragTo | ||
//--------------------------------------------------------- | ||
|
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.
Shouldn't it return multdata()->posY() instead?
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.
Yes it should, but because of this issue, I need this function to return the position including offset, hence why I need to use pos() instead of mutldata()->pos()