diff options
author | Carl Hetherington <carl@carlh.net> | 2010-11-24 01:04:53 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2010-11-24 01:04:53 +0000 |
commit | e131fd391ded68c2a0634f26edb03410b5f46349 (patch) | |
tree | 270931b286ea06a0a9f3d486f333409046bcc940 /gtk2_ardour/midi_region_view.cc | |
parent | d40e61c91490896663d264995fb042d9698441f7 (diff) |
Put MIDI notes into their own canvas group, and reparent this group during start trims to stop the notes moving. Improves the visual display on start trim of a MIDI region.
git-svn-id: svn://localhost/ardour2/branches/3.0@8080 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/midi_region_view.cc')
-rw-r--r-- | gtk2_ardour/midi_region_view.cc | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index a11b038db4..09262bdd19 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -87,13 +87,14 @@ MidiRegionView::MidiRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView & , _model_name(string()) , _custom_device_mode(string()) , _active_notes(0) - , _note_group(new ArdourCanvas::Group(*parent)) + , _note_group(new ArdourCanvas::Group(*group)) , _diff_command(0) , _ghost_note(0) , _drag_rect (0) , _step_edit_cursor (0) , _step_edit_cursor_width (1.0) , _step_edit_cursor_position (0.0) + , _temporary_note_group (0) , _mouse_state(None) , _pressed_button(0) , _sort_needed (true) @@ -126,6 +127,7 @@ MidiRegionView::MidiRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView & , _step_edit_cursor (0) , _step_edit_cursor_width (1.0) , _step_edit_cursor_position (0.0) + , _temporary_note_group (0) , _mouse_state(None) , _pressed_button(0) , _sort_needed (true) @@ -156,6 +158,7 @@ MidiRegionView::MidiRegionView (const MidiRegionView& other) , _step_edit_cursor (0) , _step_edit_cursor_width (1.0) , _step_edit_cursor_position (0.0) + , _temporary_note_group (0) , _mouse_state(None) , _pressed_button(0) , _sort_needed (true) @@ -188,6 +191,7 @@ MidiRegionView::MidiRegionView (const MidiRegionView& other, boost::shared_ptr<M , _step_edit_cursor (0) , _step_edit_cursor_width (1.0) , _step_edit_cursor_position (0.0) + , _temporary_note_group (0) , _mouse_state(None) , _pressed_button(0) , _sort_needed (true) @@ -1134,14 +1138,12 @@ MidiRegionView::display_sysexes() } string text = str.str(); - ArdourCanvas::Group* const group = (ArdourCanvas::Group*)get_canvas_group(); - const double x = trackview.editor().frame_to_pixel(beats_to_frames(time)); double height = midi_stream_view()->contents_height(); boost::shared_ptr<CanvasSysEx> sysex = boost::shared_ptr<CanvasSysEx>( - new CanvasSysEx(*this, *group, text, height, x, 1.0)); + new CanvasSysEx(*this, *_note_group, text, height, x, 1.0)); // Show unless program change is beyond the region bounds if (time - _region->start() >= _region->length() || time < _region->start()) { @@ -1177,6 +1179,7 @@ MidiRegionView::~MidiRegionView () delete _note_group; delete _diff_command; delete _step_edit_cursor; + delete _temporary_note_group; } void @@ -1499,11 +1502,9 @@ MidiRegionView::add_note(const boost::shared_ptr<NoteType> note, bool visible) assert(note->time() >= 0); assert(midi_view()->note_mode() == Sustained || midi_view()->note_mode() == Percussive); - ArdourCanvas::Group* const group = (ArdourCanvas::Group*)get_canvas_group(); - if (midi_view()->note_mode() == Sustained) { - CanvasNote* ev_rect = new CanvasNote(*this, *group, note); + CanvasNote* ev_rect = new CanvasNote(*this, *_note_group, note); update_note (ev_rect); @@ -1521,7 +1522,7 @@ MidiRegionView::add_note(const boost::shared_ptr<NoteType> note, bool visible) const double diamond_size = midi_stream_view()->note_height() / 2.0; - CanvasHit* ev_diamond = new CanvasHit(*this, *group, diamond_size, note); + CanvasHit* ev_diamond = new CanvasHit(*this, *_note_group, diamond_size, note); update_hit (ev_diamond); @@ -1586,13 +1587,12 @@ MidiRegionView::add_pgm_change(PCEvent& program, const string& displaytext) { assert(program.time >= 0); - ArdourCanvas::Group* const group = (ArdourCanvas::Group*)get_canvas_group(); const double x = trackview.editor().frame_to_pixel(beats_to_frames(program.time)); double height = midi_stream_view()->contents_height(); boost::shared_ptr<CanvasProgramChange> pgm_change = boost::shared_ptr<CanvasProgramChange>( - new CanvasProgramChange(*this, *group, + new CanvasProgramChange(*this, *_note_group, displaytext, height, x, 1.0, @@ -2202,7 +2202,7 @@ MidiRegionView::begin_resizing (bool /*at_front*/) // create a new SimpleRect from the note which will be the resize preview SimpleRect *resize_rect = new SimpleRect( - *group, note->x1(), note->y1(), note->x2(), note->y2()); + *_note_group, note->x1(), note->y1(), note->x2(), note->y2()); // calculate the colors: get the color settings uint32_t fill_color = UINT_RGBA_CHANGE_A( @@ -3004,7 +3004,7 @@ MidiRegionView::update_ghost_note (double x, double y) _last_ghost_x = x; _last_ghost_y = y; - group->w2i (x, y); + _note_group->w2i (x, y); framepos_t f = trackview.editor().pixel_to_frame (x) + _region->position (); trackview.editor().snap_to (f); f -= _region->position (); @@ -3033,7 +3033,7 @@ MidiRegionView::create_ghost_note (double x, double y) _ghost_note = 0; boost::shared_ptr<NoteType> g (new NoteType); - _ghost_note = new NoEventCanvasNote (*this, *group, g); + _ghost_note = new NoEventCanvasNote (*this, *_note_group, g); update_ghost_note (x, y); _ghost_note->show (); @@ -3228,3 +3228,22 @@ MidiRegionView::data_recorded (boost::shared_ptr<MidiBuffer> buf, boost::weak_pt midi_stream_view()->check_record_layers (region(), back); } + +void +MidiRegionView::trim_start_starting () +{ + /* Reparent the note group to the region view's parent, so that it doesn't change + when the region view is trimmed. + */ + _temporary_note_group = new ArdourCanvas::Group (*group->property_parent ()); + _temporary_note_group->move (group->property_x(), group->property_y()); + _note_group->reparent (*_temporary_note_group); +} + +void +MidiRegionView::trim_start_ending () +{ + _note_group->reparent (*group); + delete _temporary_note_group; + _temporary_note_group = 0; +} |