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

Fix #15321: Allow Removal of Spanners from Range Selections #20634

Merged

Conversation

22justinl
Copy link
Contributor

Resolves: #15321
Changed so that range selections add both front and back segments of spanners.

  • I signed the CLA
  • The title of the PR describes the problem it addresses
  • Each commit's message describes its purpose and effects, and references the issue it resolves
  • If changes are extensive, there is a sequence of easily reviewable commits
  • The code in the PR follows the coding rules
  • There are no unnecessary changes
  • The code compiles and runs on my machine, preferably after each commit individually
  • I created a unit test or vtest to verify the changes I made (if applicable)

@cbjeukendrup

This comment was marked as resolved.

@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented Dec 22, 2023

Wouldn't changing

SpannerSegment* frontSegment() { return m_segments.front(); }
const SpannerSegment* frontSegment() const { return m_segments.front(); }

in spanner.h to

SpannerSegment* frontSegment() { return m_segment ? m_segments.front(): nullptr; }
const SpannerSegment* frontSegment() const { return m_segment ? m_segments.front(): nullptr; }

be better/safer? Likewise for backSegment(), etc.

@cbjeukendrup
Copy link
Contributor

m_segment ? m_segments.front(): nullptr that doesn't really make sense as m_segments is a vector. I think the problem is that this is nullptr.

@22justinl 22justinl force-pushed the remove_spanners_from_selections branch from 96dc7ec to fc4afa7 Compare December 23, 2023 15:24
@22justinl
Copy link
Contributor Author

22justinl commented Dec 23, 2023

I changed the selection code so that the user can only select Spanners instead of SpannerSegments.
Previously when selecting a single spanner by left click, a SpannerSegment was selected but when selecting using a range a Spanner was selected (so shift-click added Spanner to m_el but trying to deselect attempted to remove a SpannerSegment, which was not added).

Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Dec 23, 2023
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Apr 9, 2024
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Apr 19, 2024
@mike-spa
Copy link
Contributor

I changed the selection code so that the user can only select Spanners instead of SpannerSegments.
Previously when selecting a single spanner by left click, a SpannerSegment was selected but when selecting using a range a Spanner was selected

The fact that a single left-click selects the SpannerSegment is quite important though, cause that is what you are actually editing most of the time. Has anyone tested this? Are we sure that it is safe to make this change?

@22justinl 22justinl force-pushed the remove_spanners_from_selections branch 2 times, most recently from 63744ff to acd2b81 Compare July 27, 2024 15:58
@22justinl
Copy link
Contributor Author

22justinl commented Jul 27, 2024

The fact that a single left-click selects the SpannerSegment is quite important though, cause that is what you are actually editing most of the time. Has anyone tested this? Are we sure that it is safe to make this change?

I see, I have now changed it so that both left-click and range selections selects SpannerSegments instead.

Is it right to assume that we won't need to select the actual Spanner?

@22justinl 22justinl force-pushed the remove_spanners_from_selections branch from acd2b81 to 5ada278 Compare July 27, 2024 16:12
@mike-spa
Copy link
Contributor

Is it right to assume that we won't need to select the actual Spanner?

The Spanner represents the "concept", whereas the SpannerSegment represents the actual graphical item that is drawn on the score (so, for instance, a slur that crosses a system break has one Slur object representing it, but is made of two SlurSegments, representing each of the two graphical arcs). When, say, the user selects and drags a point of the slur, what they are seeing and editing is the slur segment so it makes sense that that is selected. We then have internal logic which passes some of the editing operations to the Spanner when appropriate.

So, this makes more sense to me now. Codewise I think it's all fine, but I personally don't feel comfortable merging this kind of changes right now, because we are very close to release and these changes look small but can be quite consequential. I'm happy to come back and merge this after the release (please shout at me in case I forget).

@mike-spa mike-spa merged commit 968f4e4 into musescore:master Sep 27, 2024
11 checks passed
@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented Sep 27, 2024

It doesn't allow to deselect ties, slurs, hairpins that span a system break, or rather only when (de)selecting all their segments.

It doesn't allow for ottavas, pedal lines, trill lines, staff or system text lines, let ring or palm mute lines at all.

It does however allow to add and remove voltas (why are they not included in a range selection by default?), even if they span system breaks.

Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Sep 27, 2024
@@ -711,14 +713,16 @@ void Selection::updateSelectedElements()
if (sp->isVolta()) {
continue;
}
if (sp->isSlur()) {
if (sp->isSlur() || sp->isHairpin()) {
// ignore if start & end elements not calculated yet
if (!sp->startElement() || !sp->endElement()) {
continue;
}
if ((sp->tick() >= stick && sp->tick() < etick) || (sp->tick2() >= stick && sp->tick2() < etick)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why sp->tick2() < etick here, but sp->tick2() <= etick further down? Smells like an off-by-one error to me

Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Sep 27, 2024
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Nov 8, 2024
ottavas, pedal lines, trill lines, staff and system text lines, let ring and palm mute lines

Follow up to musescore#20634
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Nov 8, 2024
ottavas, pedal lines, trill lines, staff and system text lines, let ring and palm mute lines

Follow up to musescore#20634
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Nov 8, 2024
ottavas, pedal lines, trill lines, staff and system text lines, let ring and palm mute lines

Follow up to musescore#20634

Also fix a Visual Studio warning about a potentially ininitialized variable
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.

Slurs/ties/hairpins/etc cannot be removed from selections made by shift-clicking
4 participants