Skip to content

Offset items from aligned & centred position#33177

Open
miiizen wants to merge 1 commit intomusescore:masterfrom
miiizen:fixOffsetAlign
Open

Offset items from aligned & centred position#33177
miiizen wants to merge 1 commit intomusescore:masterfrom
miiizen:fixOffsetAlign

Conversation

@miiizen
Copy link
Copy Markdown
Contributor

@miiizen miiizen commented Apr 28, 2026

Resolves: #31518
Also allows avoidance of barlines by offset text

@miiizen miiizen requested a review from mike-spa April 28, 2026 13:23
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

📝 Walkthrough

Walkthrough

This pull request modifies four layout and compatibility components. In the compatibility layer, offset migration now explicitly disables centered-between-staves behavior before computing adjusted offsets. Alignment calculations are updated to use layout data positions instead of generic positions. Dynamics layout collision detection no longer skips processing when items have offsets. System layout centering logic removes checks that prevented processing manually-moved items and updates positioning calculations to use layout data coordinates.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The PR description is minimal and lacks required sections from the template, including motivation, CLA signature checkbox, and validation checklist items. Complete the PR description by adding a short explanation of changes and motivation, and fill out all checkbox items from the template to confirm CLA signature, code style compliance, testing, and commit message quality.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Offset items from aligned & centred position' accurately describes the main change: allowing items to be offset from their aligned/centered positions.
Linked Issues check ✅ Passed The code changes address the core issue #31518 by removing restrictions that prevented offset application to centered/aligned items, enabling chord symbol vertical position adjustment after system break deletion.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the offset and centering logic affected by issue #31518; no unrelated modifications are present in the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/engraving/rendering/score/dynamicslayout.cpp`:
- Line 155: The collision check currently computes the dynamic bbox using
item->pagePos() - item->offset(), which removes user X nudges; update the
geometry calculation in dynamicslayout (the branch guarded by
item->score()->nstaves() <= 1 || item->anchorToEndOfPrevious() and the checks
around the code paths at the places noted) to respect manual X shifts by using
the rendered X position (e.g., keep pagePos().x() with the user nudged value)
and only subtract the Y component of item->offset() if the intent is to ignore
vertical nudges; specifically, replace uses of item->pagePos() - item->offset()
in the dynamic bbox computation (and the checks at the other two sites) with a
position preserving pagePos().x() and adjusted Y (or equivalent: use pagePos()
directly for X and pagePos().y() - item->offset().y() for Y) so user X nudges
are included in barline collision geometry.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 130a4532-1551-42d1-b208-eba89031c4a0

📥 Commits

Reviewing files that changed from the base of the PR and between c0cabf0 and bf498aa.

📒 Files selected for processing (4)
  • src/engraving/compat/engravingcompat.cpp
  • src/engraving/rendering/score/alignmentlayout.cpp
  • src/engraving/rendering/score/dynamicslayout.cpp
  • src/engraving/rendering/score/systemlayout.cpp

void DynamicsLayout::manageBarlineCollisions(const Dynamic* item, TextBase::LayoutData* ldata)
{
if (item->score()->nstaves() <= 1 || item->anchorToEndOfPrevious() || !item->offset().isNull()) {
if (item->score()->nstaves() <= 1 || item->anchorToEndOfPrevious()) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Respect user X nudges in the barline collision geometry.

Line 155 now lets offset items enter this path, but Lines 211-213 and 231-233 still evaluate the dynamic bbox at item->pagePos() - item->offset(). That strips manual X offsets out of the collision check, so a user-shifted dynamic can still overlap a barline or get pushed the wrong way. Use the rendered X position here, or only strip the Y component if the intent is to ignore vertical nudges.

Suggested fix
-            double rightMargin = e->ldata()->bbox().translated(e->pagePos()).left()
-                                 - referenceBBox.translated(item->pagePos() - item->offset()).right()
+            double rightMargin = e->ldata()->bbox().translated(e->pagePos()).left()
+                                 - referenceBBox.translated(item->pagePos()).right()
                                  - minBarLineDistance;
@@
-            double leftMargin = referenceBBox.translated(item->pagePos() - item->offset()).left()
+            double leftMargin = referenceBBox.translated(item->pagePos()).left()
                                 - e->ldata()->bbox().translated(e->pagePos()).right()
                                 - minBarLineDistance;

Also applies to: 211-213, 231-233

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/engraving/rendering/score/dynamicslayout.cpp` at line 155, The collision
check currently computes the dynamic bbox using item->pagePos() -
item->offset(), which removes user X nudges; update the geometry calculation in
dynamicslayout (the branch guarded by item->score()->nstaves() <= 1 ||
item->anchorToEndOfPrevious() and the checks around the code paths at the places
noted) to respect manual X shifts by using the rendered X position (e.g., keep
pagePos().x() with the user nudged value) and only subtract the Y component of
item->offset() if the intent is to ignore vertical nudges; specifically, replace
uses of item->pagePos() - item->offset() in the dynamic bbox computation (and
the checks at the other two sites) with a position preserving pagePos().x() and
adjusted Y (or equivalent: use pagePos() directly for X and pagePos().y() -
item->offset().y() for Y) so user X nudges are included in barline collision
geometry.

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.

Unable to reduce Chord symbols vertical position after deleting system break

1 participant