lincoln's patch that makes us pay attention to region copies w.r.t the region list, PLUS make region list insert drags work again by not insisting that the list of regionviews be non-empty as the drag is constructed PLUS the start of tracking mouse cursor position in MIDI notes PLUS a bit of leftover debugging info

git-svn-id: svn://localhost/ardour2/branches/3.0@7817 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2010-09-21 03:02:30 +00:00
parent ff356beda5
commit 2c80ff4129
7 changed files with 63 additions and 14 deletions

View file

@ -239,6 +239,14 @@ CanvasNoteEvent::on_event(GdkEvent* ev)
_region.note_left (this); _region.note_left (this);
break; break;
case GDK_MOTION_NOTIFY:
double ix, iy;
ix = ev->motion.x;
iy = ev->motion.y;
_item->w2i (ix, iy);
cerr << "note motion at " << ix << ',' << iy << endl;
break;
case GDK_BUTTON_PRESS: case GDK_BUTTON_PRESS:
if (ev->button.button == 3 && Keyboard::no_modifiers_active (ev->button.state)) { if (ev->button.button == 3 && Keyboard::no_modifiers_active (ev->button.state)) {
show_channel_selector(); show_channel_selector();

View file

@ -366,7 +366,8 @@ RegionDrag::RegionDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, list<Re
} }
} }
assert (!v.empty ()); /* the list of views can be empty at this point if this is a region list-insert drag
*/
for (list<RegionView*>::const_iterator i = v.begin(); i != v.end(); ++i) { for (list<RegionView*>::const_iterator i = v.begin(); i != v.end(); ++i) {
_views.push_back (DraggingView (*i, this)); _views.push_back (DraggingView (*i, this));
@ -692,7 +693,7 @@ RegionMoveDrag::motion (GdkEvent* event, bool first_move)
MidiRegionView* mrv = dynamic_cast<MidiRegionView*>(rv); MidiRegionView* mrv = dynamic_cast<MidiRegionView*>(rv);
const boost::shared_ptr<const Region> original = rv->region(); const boost::shared_ptr<const Region> original = rv->region();
boost::shared_ptr<Region> region_copy = RegionFactory::create (original); boost::shared_ptr<Region> region_copy = RegionFactory::create (original, true);
region_copy->set_position (original->position(), this); region_copy->set_position (original->position(), this);
RegionView* nrv; RegionView* nrv;
@ -915,7 +916,7 @@ RegionMoveDrag::finished_no_copy (
/* insert into new playlist */ /* insert into new playlist */
RegionView* new_view = insert_region_into_playlist ( RegionView* new_view = insert_region_into_playlist (
RegionFactory::create (rv->region ()), dest_rtv, dest_layer, where, modified_playlists RegionFactory::create (rv->region (), true), dest_rtv, dest_layer, where, modified_playlists
); );
if (new_view == 0) { if (new_view == 0) {

View file

@ -2218,7 +2218,7 @@ Editor::insert_region_list_drag (boost::shared_ptr<Region> region, int x, int y)
begin_reversible_command (_("insert dragged region")); begin_reversible_command (_("insert dragged region"));
playlist->clear_changes (); playlist->clear_changes ();
playlist->add_region (RegionFactory::create (region), where, 1.0); playlist->add_region (RegionFactory::create (region, true), where, 1.0);
_session->add_command(new StatefulDiffCommand (playlist)); _session->add_command(new StatefulDiffCommand (playlist));
commit_reversible_command (); commit_reversible_command ();
} }
@ -2297,7 +2297,7 @@ Editor::insert_region_list_selection (float times)
begin_reversible_command (_("insert region")); begin_reversible_command (_("insert region"));
playlist->clear_changes (); playlist->clear_changes ();
playlist->add_region ((RegionFactory::create (region)), get_preferred_edit_position(), times); playlist->add_region ((RegionFactory::create (region, true)), get_preferred_edit_position(), times);
_session->add_command(new StatefulDiffCommand (playlist)); _session->add_command(new StatefulDiffCommand (playlist));
commit_reversible_command (); commit_reversible_command ();
} }
@ -3106,7 +3106,7 @@ Editor::region_fill_track ()
} }
pl->clear_changes (); pl->clear_changes ();
pl->add_region (RegionFactory::create (region), region->last_frame(), times); pl->add_region (RegionFactory::create (region, true), region->last_frame(), times);
_session->add_command (new StatefulDiffCommand (pl)); _session->add_command (new StatefulDiffCommand (pl));
} }
@ -3150,7 +3150,7 @@ Editor::region_fill_selection ()
} }
playlist->clear_changes (); playlist->clear_changes ();
playlist->add_region (RegionFactory::create (region), start, times); playlist->add_region (RegionFactory::create (region, true), start, times);
_session->add_command (new StatefulDiffCommand (playlist)); _session->add_command (new StatefulDiffCommand (playlist));
} }

View file

@ -25,7 +25,6 @@
#include "pbd/basename.h" #include "pbd/basename.h"
#include "pbd/enumwriter.h" #include "pbd/enumwriter.h"
#include "pbd/stacktrace.h"
#include "ardour/audioregion.h" #include "ardour/audioregion.h"
#include "ardour/audiofilesource.h" #include "ardour/audiofilesource.h"
@ -346,18 +345,41 @@ EditorRegions::region_changed (boost::shared_ptr<Region> r, const PropertyChange
our_interests.add (ARDOUR::Properties::opaque); our_interests.add (ARDOUR::Properties::opaque);
our_interests.add (ARDOUR::Properties::fade_in); our_interests.add (ARDOUR::Properties::fade_in);
our_interests.add (ARDOUR::Properties::fade_out); our_interests.add (ARDOUR::Properties::fade_out);
if (last_row != NULL){
TreeModel::iterator j = _model->get_iter (last_row.get_path());
boost::shared_ptr<Region> c = (*j)[_columns.region];
if (c == r) {
populate_row (r, (*j));
if (what_changed.contains (ARDOUR::Properties::hidden)) {
redisplay ();
}
return;
}
}
if (what_changed.contains (our_interests)) { if (what_changed.contains (our_interests)) {
/* find the region in our model and update its row */ /* find the region in our model and update its row */
TreeModel::Children rows = _model->children (); TreeModel::Children rows = _model->children ();
TreeModel::iterator i = rows.begin (); TreeModel::iterator i = rows.begin ();
while (i != rows.end ()) { while (i != rows.end ()) {
TreeModel::Children children = (*i)->children (); TreeModel::Children children = (*i)->children ();
TreeModel::iterator j = children.begin (); TreeModel::iterator j = children.begin ();
while (j != children.end()) { while (j != children.end()) {
boost::shared_ptr<Region> c = (*j)[_columns.region]; boost::shared_ptr<Region> c = (*j)[_columns.region];
if (c == r) { if (c == r) {
last_row = TreeRowReference(_model, TreePath(j));
break; break;
} }
++j; ++j;
@ -403,7 +425,6 @@ EditorRegions::region_changed (boost::shared_ptr<Region> r, const PropertyChange
++i; ++i;
} }
} }
if (what_changed.contains (ARDOUR::Properties::hidden)) { if (what_changed.contains (ARDOUR::Properties::hidden)) {
@ -438,8 +459,11 @@ EditorRegions::selection_changed ()
boost::shared_ptr<Region> region = (*iter)[_columns.region]; boost::shared_ptr<Region> region = (*iter)[_columns.region];
// they could have clicked on a row that is just a placeholder, like "Hidden" // they could have clicked on a row that is just a placeholder, like "Hidden"
if (region) { if (region) {
cerr << "Selected region has use count "
<< _session->playlists->region_use_count (region)
<< endl;
if (region->automatic()) { if (region->automatic()) {
@ -464,10 +488,12 @@ EditorRegions::selection_changed ()
void void
EditorRegions::set_selected (RegionSelection& regions) EditorRegions::set_selected (RegionSelection& regions)
{ {
TreeModel::Children rows = _model->children();
for (RegionSelection::iterator iter = regions.begin(); iter != regions.end(); ++iter) { for (RegionSelection::iterator iter = regions.begin(); iter != regions.end(); ++iter) {
TreeModel::iterator i; TreeModel::iterator i;
TreeModel::Children rows = _model->children();
boost::shared_ptr<Region> r ((*iter)->region()); boost::shared_ptr<Region> r ((*iter)->region());
for (i = rows.begin(); i != rows.end(); ++i) { for (i = rows.begin(); i != rows.end(); ++i) {
@ -509,6 +535,7 @@ EditorRegions::set_selected_in_subrow (boost::shared_ptr<Region> region, TreeMod
} }
} }
} }
return false; return false;
} }
@ -550,9 +577,6 @@ EditorRegions::redisplay ()
insert_into_tmp_regionlist (i->second); insert_into_tmp_regionlist (i->second);
} }
stacktrace (cerr, 22);
cerr << "Redisplay with " << tmp_region_list.size() << " regions\n";
for (list<boost::shared_ptr<Region> >::iterator r = tmp_region_list.begin(); r != tmp_region_list.end(); ++r) { for (list<boost::shared_ptr<Region> >::iterator r = tmp_region_list.begin(); r != tmp_region_list.end(); ++r) {
add_region (*r); add_region (*r);
} }

View file

@ -40,16 +40,20 @@ public:
void reset_sort_type (Editing::RegionListSortType, bool); void reset_sort_type (Editing::RegionListSortType, bool);
void set_selected (RegionSelection &); void set_selected (RegionSelection &);
void selection_mapover (sigc::slot<void,boost::shared_ptr<ARDOUR::Region> >); void selection_mapover (sigc::slot<void,boost::shared_ptr<ARDOUR::Region> >);
boost::shared_ptr<ARDOUR::Region> get_dragged_region (); boost::shared_ptr<ARDOUR::Region> get_dragged_region ();
boost::shared_ptr<ARDOUR::Region> get_single_selection (); boost::shared_ptr<ARDOUR::Region> get_single_selection ();
Editing::RegionListSortType sort_type () const { Editing::RegionListSortType sort_type () const {
return _sort_type; return _sort_type;
} }
void redisplay (); void redisplay ();
void suspend_redisplay () { void suspend_redisplay () {
_no_redisplay = true; _no_redisplay = true;
} }
void resume_redisplay () { void resume_redisplay () {
_no_redisplay = false; _no_redisplay = false;
redisplay (); redisplay ();
@ -108,12 +112,17 @@ private:
}; };
Columns _columns; Columns _columns;
Gtk::TreeModel::RowReference last_row;
void region_changed (boost::shared_ptr<ARDOUR::Region>, PBD::PropertyChange const &); void region_changed (boost::shared_ptr<ARDOUR::Region>, PBD::PropertyChange const &);
void selection_changed (); void selection_changed ();
sigc::connection _change_connection; sigc::connection _change_connection;
bool set_selected_in_subrow (boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const &, int); bool set_selected_in_subrow (boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const &, int);
bool selection_filter (const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::Path& path, bool yn); bool selection_filter (const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::Path& path, bool yn);
void name_edit (const std::string&, const std::string&); void name_edit (const std::string&, const std::string&);
void locked_changed (std::string const &); void locked_changed (std::string const &);
void glued_changed (std::string const &); void glued_changed (std::string const &);

View file

@ -2663,6 +2663,12 @@ MidiRegionView::note_left (ArdourCanvas::CanvasNoteEvent* note)
trackview.editor().hide_verbose_canvas_cursor (); trackview.editor().hide_verbose_canvas_cursor ();
} }
void
MidiRegionView::note_motion (float fraction)
{
cerr << "Now at " << fraction << " within note\n";
}
void void
MidiRegionView::switch_source(boost::shared_ptr<Source> src) MidiRegionView::switch_source(boost::shared_ptr<Source> src)
{ {

View file

@ -192,6 +192,7 @@ class MidiRegionView : public RegionView
void note_entered(ArdourCanvas::CanvasNoteEvent* ev); void note_entered(ArdourCanvas::CanvasNoteEvent* ev);
void note_left(ArdourCanvas::CanvasNoteEvent* ev); void note_left(ArdourCanvas::CanvasNoteEvent* ev);
void note_motion (float fraction);
void unique_select(ArdourCanvas::CanvasNoteEvent* ev); void unique_select(ArdourCanvas::CanvasNoteEvent* ev);
void note_selected(ArdourCanvas::CanvasNoteEvent* ev, bool add, bool extend=false); void note_selected(ArdourCanvas::CanvasNoteEvent* ev, bool add, bool extend=false);
void note_deselected(ArdourCanvas::CanvasNoteEvent* ev); void note_deselected(ArdourCanvas::CanvasNoteEvent* ev);