summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2010-08-04 15:41:55 +0000
committerCarl Hetherington <carl@carlh.net>2010-08-04 15:41:55 +0000
commitcc6016400bbd903e5d2a1720708ecde8d71f44d3 (patch)
tree41166df0d8ac89193d4b6bc3c45897267d86e36e
parentaa72da4f9ffc2f7011c2e7f801fb5c04ecbfa58f (diff)
Allow rubberband selection of MIDI automation points. Fixes
git-svn-id: svn://localhost/ardour2/branches/3.0@7535 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--gtk2_ardour/automation_line.cc8
-rw-r--r--gtk2_ardour/automation_line.h2
-rw-r--r--gtk2_ardour/automation_region_view.cc17
-rw-r--r--gtk2_ardour/automation_streamview.cc20
-rw-r--r--gtk2_ardour/automation_streamview.h3
-rw-r--r--gtk2_ardour/automation_time_axis.cc13
-rw-r--r--gtk2_ardour/editor_drag.cc2
-rw-r--r--gtk2_ardour/editor_mouse.cc16
-rw-r--r--gtk2_ardour/editor_selection.cc2
9 files changed, 67 insertions, 16 deletions
diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc
index 7d5ca540a8..dd5f11f042 100644
--- a/gtk2_ardour/automation_line.cc
+++ b/gtk2_ardour/automation_line.cc
@@ -948,14 +948,14 @@ AutomationLine::remove_point (ControlPoint& cp)
}
void
-AutomationLine::get_selectables (nframes_t& start, nframes_t& end,
+AutomationLine::get_selectables (nframes_t start, nframes_t end,
double botfrac, double topfrac, list<Selectable*>& results)
{
double top;
double bot;
- double nstart;
- double nend;
+ sframes_t nstart;
+ sframes_t nend;
bool collecting = false;
/* Curse X11 and its inverted coordinate system! */
@@ -967,7 +967,7 @@ AutomationLine::get_selectables (nframes_t& start, nframes_t& end,
nend = 0;
for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
- double when = (*(*i)->model())->when;
+ sframes_t const when = _time_converter.to ((*(*i)->model())->when);
if (when >= start && when <= end) {
diff --git a/gtk2_ardour/automation_line.h b/gtk2_ardour/automation_line.h
index 7fcad9a4f8..0222328634 100644
--- a/gtk2_ardour/automation_line.h
+++ b/gtk2_ardour/automation_line.h
@@ -68,7 +68,7 @@ class AutomationLine : public sigc::trackable, public PBD::StatefulDestructible
std::list<ControlPoint*> point_selection_to_control_points (PointSelection const &);
void set_selected_points (PointSelection&);
- void get_selectables (nframes_t& start, nframes_t& end,
+ void get_selectables (nframes_t start, nframes_t end,
double botfrac, double topfrac,
std::list<Selectable*>& results);
void get_inverted_selectables (Selection&, std::list<Selectable*>& results);
diff --git a/gtk2_ardour/automation_region_view.cc b/gtk2_ardour/automation_region_view.cc
index 21ee6ca38a..a576101048 100644
--- a/gtk2_ardour/automation_region_view.cc
+++ b/gtk2_ardour/automation_region_view.cc
@@ -29,6 +29,8 @@
#include "gui_thread.h"
#include "public_editor.h"
#include "midi_automation_line.h"
+#include "editor_drag.h"
+#include "editor.h"
#include "i18n.h"
@@ -89,18 +91,27 @@ AutomationRegionView::create_line (boost::shared_ptr<ARDOUR::AutomationList> lis
bool
AutomationRegionView::canvas_event(GdkEvent* ev)
{
- if (ev->type == GDK_BUTTON_RELEASE) {
+ if (ev->type == GDK_BUTTON_PRESS) {
+ /* XXX: icky dcast to Editor */
+ trackview.editor().drags()->set (new RubberbandSelectDrag (dynamic_cast<Editor*> (&trackview.editor()), group), ev);
+
+ } else if (ev->type == GDK_BUTTON_RELEASE) {
+
+ if (trackview.editor().drags()->active() && trackview.editor().drags()->end_grab (ev)) {
+ return true;
+ }
+
double x = ev->button.x;
double y = ev->button.y;
-
+
/* convert to item coordinates in the time axis view */
automation_view()->canvas_display()->w2i (x, y);
/* clamp y */
y = max (y, 0.0);
y = min (y, _height - NAME_HIGHLIGHT_SIZE);
-
+
add_automation_event (ev, trackview.editor().pixel_to_frame (x) - _region->position(), y);
}
diff --git a/gtk2_ardour/automation_streamview.cc b/gtk2_ardour/automation_streamview.cc
index 76e565d414..1f07aaaba7 100644
--- a/gtk2_ardour/automation_streamview.cc
+++ b/gtk2_ardour/automation_streamview.cc
@@ -273,3 +273,23 @@ AutomationStreamView::clear ()
arv->line()->clear ();
}
}
+
+void
+AutomationStreamView::get_selectables (nframes_t start, nframes_t end, double botfrac, double topfrac, list<Selectable*>& results)
+{
+ for (list<RegionView*>::iterator i = region_views.begin(); i != region_views.end(); ++i) {
+ AutomationRegionView* arv = dynamic_cast<AutomationRegionView*> (*i);
+ assert (arv);
+ arv->line()->get_selectables (start - (*i)->region()->position(), end - (*i)->region()->position(), botfrac, topfrac, results);
+ }
+}
+
+void
+AutomationStreamView::set_selected_points (PointSelection& ps)
+{
+ for (list<RegionView*>::iterator i = region_views.begin(); i != region_views.end(); ++i) {
+ AutomationRegionView* arv = dynamic_cast<AutomationRegionView*> (*i);
+ assert (arv);
+ arv->line()->set_selected_points (ps);
+ }
+}
diff --git a/gtk2_ardour/automation_streamview.h b/gtk2_ardour/automation_streamview.h
index 0791764a4a..8c5acdcbd1 100644
--- a/gtk2_ardour/automation_streamview.h
+++ b/gtk2_ardour/automation_streamview.h
@@ -61,6 +61,9 @@ class AutomationStreamView : public StreamView
void clear ();
+ void get_selectables (nframes_t, nframes_t, double, double, std::list<Selectable*> &);
+ void set_selected_points (PointSelection &);
+
private:
void setup_rec_box ();
diff --git a/gtk2_ardour/automation_time_axis.cc b/gtk2_ardour/automation_time_axis.cc
index e9cb98ca34..1596abfdf8 100644
--- a/gtk2_ardour/automation_time_axis.cc
+++ b/gtk2_ardour/automation_time_axis.cc
@@ -783,7 +783,11 @@ AutomationTimeAxisView::paste_one (AutomationLine& line, nframes_t pos, float ti
void
AutomationTimeAxisView::get_selectables (nframes_t start, nframes_t end, double top, double bot, list<Selectable*>& results)
{
- if (_line && touched (top, bot)) {
+ if (!_line && !_view) {
+ return;
+ }
+
+ if (touched (top, bot)) {
double topfrac;
double botfrac;
@@ -810,8 +814,11 @@ AutomationTimeAxisView::get_selectables (nframes_t start, nframes_t end, double
botfrac = 1.0 - ((bot - _y_position) / height);
}
- if (_line)
+ if (_line) {
_line->get_selectables (start, end, botfrac, topfrac, results);
+ } else if (_view) {
+ _view->get_selectables (start, end, botfrac, topfrac, results);
+ }
}
}
@@ -827,6 +834,8 @@ AutomationTimeAxisView::set_selected_points (PointSelection& points)
{
if (_line) {
_line->set_selected_points (points);
+ } else if (_view) {
+ _view->set_selected_points (points);
}
}
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc
index 48ddeb55d2..f167ea598f 100644
--- a/gtk2_ardour/editor_drag.cc
+++ b/gtk2_ardour/editor_drag.cc
@@ -3106,6 +3106,8 @@ RubberbandSelectDrag::finished (GdkEvent* event, bool movement_occurred)
_editor->begin_reversible_command (_("rubberband selection"));
+ cout << "RSD finished, selecting all within <fred>\n";
+
if (grab_frame() < last_pointer_frame()) {
committed = _editor->select_all_within (grab_frame(), last_pointer_frame() - 1, y1, y2, _editor->track_views, op);
} else {
diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc
index da2ee66a0f..4febbacb68 100644
--- a/gtk2_ardour/editor_mouse.cc
+++ b/gtk2_ardour/editor_mouse.cc
@@ -53,6 +53,7 @@
#include "rgb_macros.h"
#include "control_point_dialog.h"
#include "editor_drag.h"
+#include "automation_region_view.h"
#include "ardour/types.h"
#include "ardour/profile.h"
@@ -525,10 +526,6 @@ Editor::button_selection (ArdourCanvas::Item* /*item*/, GdkEvent* event, ItemTyp
bool
Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type)
{
- if (_drags->active ()) {
- _drags->abort ();
- }
-
/* single mouse clicks on any of these item types operate
independent of mouse mode, mostly because they are
not on the main track canvas or because we want
@@ -751,6 +748,14 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT
}
case RegionItem:
+ if (dynamic_cast<AutomationRegionView*> (clicked_regionview)) {
+ /* click on an automation region view; do nothing here and let the ARV's signal handler
+ sort it out.
+ */
+ break;
+ }
+
+ /* click on a normal region view */
if (Keyboard::modifier_state_contains (event->button.state, Keyboard::CopyModifier)) {
add_region_copy_drag (item, event, clicked_regionview);
}
@@ -759,7 +764,7 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT
} else {
add_region_drag (item, event, clicked_regionview);
}
-
+
if (_join_object_range_state == JOIN_OBJECT_RANGE_OBJECT && !selection->regions.empty()) {
_drags->add (new SelectionDrag (this, clicked_axisview->get_selection_rect (clicked_selection)->rect, SelectionDrag::SelectionMove));
}
@@ -1926,6 +1931,7 @@ Editor::motion_handler (ArdourCanvas::Item* /*item*/, GdkEvent* event, bool from
if (_drags->active ()) {
handled = _drags->motion_handler (event, from_autoscroll);
}
+
if (!handled) {
return false;
}
diff --git a/gtk2_ardour/editor_selection.cc b/gtk2_ardour/editor_selection.cc
index fdc1fe2ad0..6b15f40599 100644
--- a/gtk2_ardour/editor_selection.cc
+++ b/gtk2_ardour/editor_selection.cc
@@ -993,7 +993,7 @@ Editor::select_all_within (nframes64_t start, nframes64_t end, double top, doubl
(*iter)->get_selectables (start, end, top, bot, found);
}
-
+
if (found.empty()) {
return false;
}