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

Range selection ending fix #933

Merged

Conversation

BartlomiejLewandowski
Copy link

Removed time signature from selection if not followed by chordrest in selection.
Fixed range box to not include bar lines and time signatures if not followed by a chordrest.

@@ -280,6 +280,10 @@ void Selection::updateSelectedElements()
for (Segment* s = _startSegment; s && (s != _endSegment); s = s->next1MM()) {
if (s->segmentType() == Segment::SegEndBarLine) // do not select end bar line
continue;
if (s->segmentType() == Segment::SegTimeSig) {
Segment* next = s->next1MM();
if(!next || next == _endSegment) continue;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a separate line for "continue" could be better for code readability?

@BartlomiejLewandowski
Copy link
Author

I am not sure if this is the best way to fix the issue. What I have done is added a check in the drawing methods to stop drawing when the current segment is a end barline or a time signature and they are at the end of the selection.

The barline and time signature should not be there to begin with. I am looking now at a way to do this. Closing this issue for now.

@BartlomiejLewandowski
Copy link
Author

This change will make it impossible to select a breath segment. How should we fix this? Maybe allow the user to extend the range selection onto these breath segments by clicking on them?

@BartlomiejLewandowski
Copy link
Author

The current change treats a breath as a part of the previous CR. This way we don't run into the problem of selecting a breath.

@BartlomiejLewandowski BartlomiejLewandowski changed the title fix #25852 range selection time signature Range selection ending fix Aug 7, 2014
@@ -1144,5 +1144,16 @@ void ChordRest::writeBeam(Xml& xml)
#endif
}

Segment* ChordRest::nextSegmentAfterCR(Segment::Type types) const
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a comment before, see all other functions in this file. Explain what the function is really doing. Especially the (s->tick() >= tick() + actualTicks())
Also it needs space after while, after if etc...

Last thing... I'm not a big fan of the while (true), and multiple return in the function.

What about something like this?

Segment* ss = segment();
for (Segment* s = ss; s && (s->tick() < tick() + actualTicks());) {
s = s->next1MM(types);
}
return s;

Choose a reason for hiding this comment

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

The Segment* s is undefined in your snippet at return s.

I don't know if this much clearer. It is a bit more compact. If we are going this way, why not move the loop body to the last part of the for loop? We would remove the need of the body fully.

Segment* s = segment()->next1MM(types);
for (s; s && (s->tick() < tick() + actualTicks()); s = s->next1MM(types));
return s;

Copy link
Contributor

Choose a reason for hiding this comment

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

I was just trying to avoid the while true. The compactness is not really the goal. I would be ok with putting the tick test in the loop if you think it's clearer.

@BartlomiejLewandowski
Copy link
Author

I have rewritten the nextSegmentAfterCR method to be similar to all next1MM methods in segment.cpp

lasconic added a commit that referenced this pull request Aug 9, 2014
@lasconic lasconic merged commit cec67e6 into musescore:master Aug 9, 2014
@BartlomiejLewandowski BartlomiejLewandowski deleted the 25852-range-timesig branch August 10, 2014 10:05
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.

None yet

4 participants