Offset items from aligned & centred position#33177
Offset items from aligned & centred position#33177miiizen wants to merge 1 commit intomusescore:masterfrom
Conversation
📝 WalkthroughWalkthroughThis 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)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (4)
src/engraving/compat/engravingcompat.cppsrc/engraving/rendering/score/alignmentlayout.cppsrc/engraving/rendering/score/dynamicslayout.cppsrc/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()) { |
There was a problem hiding this comment.
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.
Resolves: #31518
Also allows avoidance of barlines by offset text