Skip to content

Commit

Permalink
make sure SelectionRemove case is handled for selection ops
Browse files Browse the repository at this point in the history
Also fix formatting for switch/case statements
  • Loading branch information
pauldavisthefirst committed Aug 6, 2024
1 parent 15912fe commit 2161001
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 97 deletions.
110 changes: 56 additions & 54 deletions gtk2_ardour/editor_drag.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4390,50 +4390,51 @@ MarkerDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
SelectionOperation op = ArdourKeyboard::selection_type (event->button.state);

switch (op) {
case SelectionToggle:
/* we toggle on the button release */
break;
case SelectionSet:
if (!_editor->selection->selected (_marker)) {
_editor->selection->set (_marker);
_selection_changed = true;
}
break;
case SelectionExtend: {
Locations::LocationList ll;
list<ArdourMarker*> to_add;
timepos_t s, e;
_editor->selection->markers.range (s, e);
s = min (_marker->position (), s);
e = max (_marker->position (), e);
s = min (s, e);
e = max (s, e);
if (e < timepos_t::max (e.time_domain ())) {
e = e.increment ();
}
_editor->session ()->locations ()->find_all_between (s, e, ll, Location::Flags (0));
for (Locations::LocationList::iterator i = ll.begin (); i != ll.end (); ++i) {
Editor::LocationMarkers* lm = _editor->find_location_markers (*i);
if (lm) {
if (lm->start) {
to_add.push_back (lm->start);
}
if (lm->end) {
to_add.push_back (lm->end);
}
case SelectionToggle:
/* we toggle on the button release */
break;
case SelectionSet:
if (!_editor->selection->selected (_marker)) {
_editor->selection->set (_marker);
_selection_changed = true;
}
break;
case SelectionExtend: {
Locations::LocationList ll;
list<ArdourMarker*> to_add;
timepos_t s, e;
_editor->selection->markers.range (s, e);
s = min (_marker->position (), s);
e = max (_marker->position (), e);
s = min (s, e);
e = max (s, e);
if (e < timepos_t::max (e.time_domain ())) {
e = e.increment ();
}
_editor->session ()->locations ()->find_all_between (s, e, ll, Location::Flags (0));
for (Locations::LocationList::iterator i = ll.begin (); i != ll.end (); ++i) {
Editor::LocationMarkers* lm = _editor->find_location_markers (*i);
if (lm) {
if (lm->start) {
to_add.push_back (lm->start);
}
if (lm->end) {
to_add.push_back (lm->end);
}
}
if (!to_add.empty ()) {
_editor->selection->add (to_add);
_selection_changed = true;
}
break;
}
case SelectionAdd:
_editor->selection->add (_marker);
if (!to_add.empty ()) {
_editor->selection->add (to_add);
_selection_changed = true;

break;
}
break;
}
case SelectionAdd:
_editor->selection->add (_marker);
_selection_changed = true;
break;
default:
break;
}

/* Set up copies for us to manipulate during the drag
Expand Down Expand Up @@ -4645,23 +4646,24 @@ MarkerDrag::finished (GdkEvent* event, bool movement_occurred)

SelectionOperation op = ArdourKeyboard::selection_type (event->button.state);
switch (op) {
case SelectionSet:
if (_editor->selection->selected (_marker) && _editor->selection->markers.size () > 1) {
_editor->selection->set (_marker);
_selection_changed = true;
}
break;

case SelectionToggle:
/* we toggle on the button release, click only */
_editor->selection->toggle (_marker);
case SelectionSet:
if (_editor->selection->selected (_marker) && _editor->selection->markers.size () > 1) {
_editor->selection->set (_marker);
_selection_changed = true;
}
break;

break;
case SelectionToggle:
/* we toggle on the button release, click only */
_editor->selection->toggle (_marker);
_selection_changed = true;

case SelectionExtend:
case SelectionAdd:
break;
break;

case SelectionExtend:
case SelectionAdd:
case SelectionRemove:
break;
}

if (_selection_changed) {
Expand Down
91 changes: 48 additions & 43 deletions gtk2_ardour/editor_mouse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -632,28 +632,31 @@ Editor::button_selection (ArdourCanvas::Item* item, GdkEvent* event, ItemType it
selectables.push_back (argl->nth (after));

switch (op) {
case SelectionSet:
if (press) {
selection->set (selectables);
_mouse_changed_selection = true;
}
break;
case SelectionAdd:
if (press) {
selection->add (selectables);
_mouse_changed_selection = true;
}
break;
case SelectionToggle:
if (press) {
selection->toggle (selectables);
_mouse_changed_selection = true;
}
break;
case SelectionSet:
if (press) {
selection->set (selectables);
_mouse_changed_selection = true;
}
break;
case SelectionAdd:
if (press) {
selection->add (selectables);
_mouse_changed_selection = true;
}
break;
case SelectionToggle:
if (press) {
selection->toggle (selectables);
_mouse_changed_selection = true;
}
break;

case SelectionExtend:
/* XXX */
break;
case SelectionExtend:
/* XXX */
break;
case SelectionRemove:
/* XXX */
break;
}
}
break;
Expand All @@ -678,28 +681,30 @@ Editor::button_selection (ArdourCanvas::Item* item, GdkEvent* event, ItemType it
selectables.push_back (al->nth (after));

switch (op) {
case SelectionSet:
if (press) {
selection->set (selectables);
_mouse_changed_selection = true;
}
break;
case SelectionAdd:
if (press) {
selection->add (selectables);
_mouse_changed_selection = true;
}
break;
case SelectionToggle:
if (press) {
selection->toggle (selectables);
_mouse_changed_selection = true;
}
break;

case SelectionExtend:
/* XXX */
break;
case SelectionSet:
if (press) {
selection->set (selectables);
_mouse_changed_selection = true;
}
break;
case SelectionAdd:
if (press) {
selection->add (selectables);
_mouse_changed_selection = true;
}
break;
case SelectionToggle:
if (press) {
selection->toggle (selectables);
_mouse_changed_selection = true;
}
break;
case SelectionExtend:
/* XXX */
break;
case SelectionRemove:
/* not relevant */
break;
}
}
break;
Expand Down

0 comments on commit 2161001

Please sign in to comment.