Allow rubberband selection of MIDI automation points. Fixes
git-svn-id: svn://localhost/ardour2/branches/3.0@7535 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
aa72da4f9f
commit
cc6016400b
@ -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) {
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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 ();
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user