13
0

make shift-click (extend) selection operation on track headers etc. work

git-svn-id: svn://localhost/ardour2/trunk@1233 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2006-12-19 20:11:42 +00:00
parent 4bbfb6bffd
commit 58c34fe805
7 changed files with 130 additions and 6 deletions

View File

@ -121,6 +121,7 @@
; (gtk_accel_path "<Actions>/Editor/EditSelectRegionOptions" "")
(gtk_accel_path "<Actions>/Editor/crop" "c")
; (gtk_accel_path "<Actions>/redirectmenu/newsend" "")
; (gtk_accel_path "<Actions>/Editor/ToggleGeneric MIDISurfaceSubMenu" "")
; (gtk_accel_path "<Actions>/Editor/MeterFalloff" "")
; (gtk_accel_path "<Actions>/RegionList/rlRemove" "")
(gtk_accel_path "<Actions>/Transport/GotoStart" "Home")
@ -276,6 +277,7 @@
; (gtk_accel_path "<Actions>/Editor/Subframes80" "")
; (gtk_accel_path "<Actions>/options/FileHeaderFormatCAF" "")
(gtk_accel_path "<Actions>/Common/ToggleLocations" "<Alt>l")
; (gtk_accel_path "<Actions>/Editor/ToggleGeneric MIDISurface" "")
(gtk_accel_path "<Actions>/Editor/editor-delete" "Delete")
; (gtk_accel_path "<Actions>/JACK/JACKLatency256" "")
(gtk_accel_path "<Actions>/Editor/select-all-between-cursors" "u")
@ -298,6 +300,7 @@
; (gtk_accel_path "<Actions>/Snap/snap-to-region-sync" "")
(gtk_accel_path "<Actions>/Editor/edit-cursor-to-previous-region-sync" "apostrophe")
; (gtk_accel_path "<Actions>/redirectmenu/clear" "")
; (gtk_accel_path "<Actions>/Editor/ToggleGeneric MIDISurfaceFeedback" "")
; (gtk_accel_path "<Actions>/Editor/PullupPlus4Minus1" "")
; (gtk_accel_path "<Actions>/JACK/JACKLatency512" "")
(gtk_accel_path "<Actions>/Editor/edit-cursor-to-next-region-end" "<Control>bracketright")

View File

@ -2861,6 +2861,114 @@ Editor::commit_reversible_command ()
}
}
struct TrackViewByPositionSorter
{
bool operator() (const TimeAxisView* a, const TimeAxisView *b) {
return a->y_position < b->y_position;
}
};
bool
Editor::extend_selection_to_track (TimeAxisView& view)
{
if (selection->tracks.empty()) {
if (!selection->selected (&view)) {
selection->set (&view);
return true;
} else {
return false;
}
}
/* something is already selected, so figure out which range of things to add */
TrackViewList to_be_added;
TrackViewList sorted = track_views;
TrackViewByPositionSorter cmp;
bool passed_clicked = false;
bool forwards;
sorted.sort (cmp);
if (!selection->selected (&view)) {
to_be_added.push_back (&view);
}
/* figure out if we should go forward or backwards */
for (TrackViewList::iterator i = sorted.begin(); i != sorted.end(); ++i) {
if ((*i) == &view) {
passed_clicked = true;
}
if (selection->selected (*i)) {
if (passed_clicked) {
forwards = true;
} else {
forwards = false;
}
break;
}
}
passed_clicked = false;
if (forwards) {
for (TrackViewList::iterator i = sorted.begin(); i != sorted.end(); ++i) {
if ((*i) == &view) {
passed_clicked = true;
continue;
}
if (passed_clicked) {
if ((*i)->hidden()) {
continue;
}
if (selection->selected (*i)) {
break;
} else if (!(*i)->hidden()) {
to_be_added.push_back (*i);
}
}
}
} else {
for (TrackViewList::reverse_iterator r = sorted.rbegin(); r != sorted.rend(); ++r) {
if ((*r) == &view) {
passed_clicked = true;
continue;
}
if (passed_clicked) {
if ((*r)->hidden()) {
continue;
}
if (selection->selected (*r)) {
break;
} else if (!(*r)->hidden()) {
to_be_added.push_back (*r);
}
}
}
}
if (!to_be_added.empty()) {
selection->add (to_be_added);
return true;
}
return false;
}
bool
Editor::set_selected_track (TimeAxisView& view, Selection::Operation op, bool no_remove)
{
@ -2889,13 +2997,14 @@ Editor::set_selected_track (TimeAxisView& view, Selection::Operation op, bool no
case Selection::Set:
if (selection->selected (&view) && selection->tracks.size() == 1) {
/* no commit necessary */
}
selection->set (&view);
} else {
selection->set (&view);
commit = true;
}
break;
case Selection::Extend:
/* not defined yet */
commit = extend_selection_to_track (view);
break;
}

View File

@ -217,6 +217,8 @@ class Editor : public PublicEditor
Selection& get_selection() const { return *selection; }
Selection& get_cut_buffer() const { return *cut_buffer; }
bool extend_selection_to_track (TimeAxisView&);
void play_selection ();
void select_all_in_track (Selection::Operation op);
void select_all (Selection::Operation op);

View File

@ -316,6 +316,7 @@ Editor::button_selection (ArdourCanvas::Item* item, GdkEvent* event, ItemType it
switch (item_type) {
case RegionItem:
/* XXX make tying track/region selection optional */
c1 = set_selected_track_from_click (op, true);
c2 = set_selected_regionview_from_click (press, op, true);
commit = (c1 || c2);
@ -323,6 +324,7 @@ Editor::button_selection (ArdourCanvas::Item* item, GdkEvent* event, ItemType it
case RegionViewNameHighlight:
case RegionViewName:
/* XXX make tying track/region selection optional */
c1 = set_selected_track_from_click (op, true);
c2 = set_selected_regionview_from_click (press, op, true);
commit = (c1 || c2);
@ -331,6 +333,7 @@ Editor::button_selection (ArdourCanvas::Item* item, GdkEvent* event, ItemType it
case GainAutomationControlPointItem:
case PanAutomationControlPointItem:
case RedirectAutomationControlPointItem:
/* XXX make tying track/region selection optional */
c1 = set_selected_track_from_click (op, true);
c2 = set_selected_control_point_from_click (op, false);
commit = (c1 || c2);

View File

@ -93,6 +93,7 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulThingWithGoingAway
virtual gulong frame_to_pixel (nframes_t frame) = 0;
virtual Selection& get_selection() const = 0;
virtual Selection& get_cut_buffer() const = 0;
virtual bool extend_selection_to_track (TimeAxisView&) = 0;
virtual void play_selection () = 0;
virtual void set_show_measures (bool yn) = 0;
virtual bool show_measures () const = 0;

View File

@ -1012,7 +1012,13 @@ RouteTimeAxisView::selection_click (GdkEventButton* ev)
break;
case Selection::Extend:
/* not defined yet */
if (tracks->size() > 1) {
/* add each one, do not "extend" */
editor.get_selection().add (*tracks);
} else {
/* extend to the single track */
editor.extend_selection_to_track (*tracks->front());
}
break;
case Selection::Add:

View File

@ -1,4 +1,4 @@
#ifndef __ardour_svn_revision_h__
#define __ardour_svn_revision_h__
static const char* ardour_svn_revision = "1180";
static const char* ardour_svn_revision = "1232";
#endif