diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 71735af2f9..a30a2236cb 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -1318,10 +1318,10 @@ Editor::set_session (Session *t) _session->history().Changed.connect (_session_connections, invalidator (*this), boost::bind (&Editor::history_changed, this), gui_context()); - _playhead_cursor->track_canvas_item().reparent ((ArdourCanvas::Item*) get_cursor_scroll_group()); + _playhead_cursor->canvas_item().reparent ((ArdourCanvas::Item*) get_cursor_scroll_group()); _playhead_cursor->show (); - _snapped_cursor->track_canvas_item().reparent ((ArdourCanvas::Item*) get_cursor_scroll_group()); + _snapped_cursor->canvas_item().reparent ((ArdourCanvas::Item*) get_cursor_scroll_group()); _snapped_cursor->set_color (UIConfiguration::instance().color ("edit point")); boost::function pc (boost::bind (&Editor::parameter_changed, this, _1)); diff --git a/gtk2_ardour/editor_cursors.cc b/gtk2_ardour/editor_cursors.cc index 609ea0b524..7563633dd5 100644 --- a/gtk2_ardour/editor_cursors.cc +++ b/gtk2_ardour/editor_cursors.cc @@ -37,45 +37,45 @@ using namespace Gtk; EditorCursor::EditorCursor (EditingContext& ed, bool (EditingContext::*callback)(GdkEvent*,ArdourCanvas::Item*), std::string const & name) : _editor (ed) - , _track_canvas_item (new ArdourCanvas::Arrow (_editor.get_cursor_scroll_group())) + , _canvas_item (new ArdourCanvas::Arrow (_editor.get_cursor_scroll_group())) { - CANVAS_DEBUG_NAME (_track_canvas_item, string_compose ("track canvas editor cursor <%1>", name)); + CANVAS_DEBUG_NAME (_canvas_item, string_compose ("track canvas editor cursor <%1>", name)); - _track_canvas_item->set_show_head (0, true); - _track_canvas_item->set_head_height (0, 9); - _track_canvas_item->set_head_width (0, 16); - _track_canvas_item->set_head_outward (0, false); - _track_canvas_item->set_show_head (1, false); // head only - _track_canvas_item->set_data ("cursor", this); + _canvas_item->set_show_head (0, true); + _canvas_item->set_head_height (0, 9); + _canvas_item->set_head_width (0, 16); + _canvas_item->set_head_outward (0, false); + _canvas_item->set_show_head (1, false); // head only + _canvas_item->set_data ("cursor", this); - _track_canvas_item->Event.connect (sigc::bind (sigc::mem_fun (ed, callback), _track_canvas_item)); + _canvas_item->Event.connect (sigc::bind (sigc::mem_fun (ed, callback), _canvas_item)); - _track_canvas_item->set_y1 (ArdourCanvas::COORD_MAX); + _canvas_item->set_y1 (ArdourCanvas::COORD_MAX); - _track_canvas_item->set_x (0); + _canvas_item->set_x (0); _current_sample = 1; /* force redraw at 0 */ } EditorCursor::EditorCursor (EditingContext& ed, std::string const & name) : _editor (ed) - , _track_canvas_item (new ArdourCanvas::Arrow (_editor.get_hscroll_group())) + , _canvas_item (new ArdourCanvas::Arrow (_editor.get_hscroll_group())) { - CANVAS_DEBUG_NAME (_track_canvas_item, string_compose ("track canvas cursor <%1>", name)); + CANVAS_DEBUG_NAME (_canvas_item, string_compose ("track canvas cursor <%1>", name)); - _track_canvas_item->set_show_head (0, false); - _track_canvas_item->set_show_head (1, false); - _track_canvas_item->set_y1 (ArdourCanvas::COORD_MAX); - _track_canvas_item->set_ignore_events (true); + _canvas_item->set_show_head (0, false); + _canvas_item->set_show_head (1, false); + _canvas_item->set_y1 (ArdourCanvas::COORD_MAX); + _canvas_item->set_ignore_events (true); - _track_canvas_item->set_x (0); + _canvas_item->set_x (0); _current_sample = 1; /* force redraw at 0 */ } EditorCursor::~EditorCursor () { - delete _track_canvas_item; + delete _canvas_item; } void @@ -87,8 +87,8 @@ EditorCursor::set_position (samplepos_t sample) const double new_pos = _editor.sample_to_pixel (sample); - if (new_pos != _track_canvas_item->x ()) { - _track_canvas_item->set_x (new_pos); + if (new_pos != _canvas_item->x ()) { + _canvas_item->set_x (new_pos); } _current_sample = sample; @@ -97,23 +97,23 @@ EditorCursor::set_position (samplepos_t sample) void EditorCursor::show () { - _track_canvas_item->show (); + _canvas_item->show (); } void EditorCursor::hide () { - _track_canvas_item->hide (); + _canvas_item->hide (); } void EditorCursor::set_color (Gtkmm2ext::Color color) { - _track_canvas_item->set_color (color); + _canvas_item->set_color (color); } void EditorCursor::set_sensitive (bool yn) { - _track_canvas_item->set_ignore_events (!yn); + _canvas_item->set_ignore_events (!yn); } diff --git a/gtk2_ardour/editor_cursors.h b/gtk2_ardour/editor_cursors.h index 6fd8831a76..e64f8b39f9 100644 --- a/gtk2_ardour/editor_cursors.h +++ b/gtk2_ardour/editor_cursors.h @@ -49,15 +49,15 @@ public: return _current_sample; } - ArdourCanvas::Arrow& track_canvas_item () { - return *_track_canvas_item; + ArdourCanvas::Arrow& canvas_item () { + return *_canvas_item; } PBD::Signal1 PositionChanged; private: EditingContext& _editor; - ArdourCanvas::Arrow* _track_canvas_item; + ArdourCanvas::Arrow* _canvas_item; samplepos_t _current_sample; }; diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 337303960c..c28f71352f 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -378,7 +378,7 @@ Drag::start_grab (GdkEvent* event, Gdk::Cursor* cursor) if (!UIConfiguration::instance ().get_preview_video_frame_on_drag ()) { _preview_video = false; } - if (_hide_snapped_cursor) { + if (_hide_snapped_cursor && editing_context.snapped_cursor()) { editing_context.snapped_cursor ()->hide (); } @@ -3899,7 +3899,7 @@ TempoEndDrag::aborted (bool moved) } CursorDrag::CursorDrag (Editor& e, EditorCursor& c, bool s) - : EditorDrag (e, &c.track_canvas_item (), e.time_domain (), nullptr) + : EditorDrag (e, &c.canvas_item (), e.time_domain (), nullptr) , _cursor (c) , _stop (s) , _grab_zoom (0.0) @@ -3957,7 +3957,7 @@ CursorDrag::start_grab (GdkEvent* event, Gdk::Cursor* c) /* grab the track canvas item as well */ - _cursor.track_canvas_item ().grab (); + _cursor.canvas_item ().grab (); if (s) { if (_was_rolling && _stop) { @@ -4044,7 +4044,7 @@ CursorDrag::finished (GdkEvent* event, bool movement_occurred) { _editor._dragging_playhead = false; - _cursor.track_canvas_item ().ungrab (); + _cursor.canvas_item ().ungrab (); if (!movement_occurred && _stop) { return; @@ -4065,7 +4065,7 @@ CursorDrag::finished (GdkEvent* event, bool movement_occurred) void CursorDrag::aborted (bool) { - _cursor.track_canvas_item ().ungrab (); + _cursor.canvas_item ().ungrab (); if (_editor._dragging_playhead) { editing_context.session ()->request_resume_timecode_transmission (); diff --git a/gtk2_ardour/midi_cue_editor.cc b/gtk2_ardour/midi_cue_editor.cc index 49d667c5d9..2fd6b71960 100644 --- a/gtk2_ardour/midi_cue_editor.cc +++ b/gtk2_ardour/midi_cue_editor.cc @@ -291,6 +291,7 @@ MidiCueEditor::build_canvas () _playhead_cursor = new EditorCursor (*this, X_("playhead")); _playhead_cursor->set_sensitive (UIConfiguration::instance().get_sensitize_playhead()); _playhead_cursor->set_color (UIConfiguration::instance().color ("play head")); + _playhead_cursor->canvas_item().raise_to_top(); _canvas->set_name ("MidiCueCanvas"); _canvas->add_events (Gdk::POINTER_MOTION_HINT_MASK | Gdk::SCROLL_MASK | Gdk::KEY_PRESS_MASK | Gdk::KEY_RELEASE_MASK); @@ -316,6 +317,11 @@ MidiCueEditor::maybe_update () return; } + if (_track->rec_enable_control()->get_value()) { + /* data recorded will handle it */ + return; + } + ARDOUR::TriggerPtr trigger = _track->triggerbox()->currently_playing (); if (!trigger) { _playhead_cursor->set_position (0); @@ -357,8 +363,9 @@ MidiCueEditor::canvas_allocate (Gtk::Allocation alloc) _visible_canvas_height = alloc.get_height(); double timebars = n_timebars * timebar_height; + bg->set_size (alloc.get_width(), alloc.get_height() - timebars); view->set_height (alloc.get_height() - timebars); - bg->set_size (alloc.get_width(), alloc.get_height()); + prh->set (ArdourCanvas::Rect (0, 0, prh->x1(), view->midi_context().height())); } timepos_t @@ -473,6 +480,12 @@ MidiCueEditor::data_captured (timecnt_t total_duration) bool MidiCueEditor::idle_data_captured () { + double where = duration_to_pixels (data_capture_duration); + + if (where > _visible_canvas_width * 0.80) { + set_samples_per_pixel (samples_per_pixel * 1.5); + } + if (view) { view->clip_data_recorded (data_capture_duration); } @@ -533,13 +546,6 @@ MidiCueEditor::set_region (std::shared_ptr r) view->set_region (r); - double w, h; - prh->size_request (w, h); - _timeline_origin = w; - prh->set_position (Duple (0., n_timebars * timebar_height)); - data_group->set_position (ArdourCanvas::Duple (w, timebar_height * n_timebars)); - h_scroll_group->set_position (Duple (w, 0.)); - /* Compute zoom level to show entire source plus some margin if possible */ Temporal::timecnt_t duration = Temporal::timecnt_t (r->midi_source()->length().beats()); @@ -808,7 +814,7 @@ MidiCueEditor::metric_get_bbt (std::vector& marks, sa bool provided = false; std::shared_ptr tmap; - if (view) { + if (view && view->midi_region()) { std::shared_ptr smf (std::dynamic_pointer_cast (view->midi_region()->midi_source())); if (smf) { diff --git a/gtk2_ardour/midi_view.cc b/gtk2_ardour/midi_view.cc index 02f8a5e9ef..84ec2cacc3 100644 --- a/gtk2_ardour/midi_view.cc +++ b/gtk2_ardour/midi_view.cc @@ -182,6 +182,7 @@ MidiView::init (std::shared_ptr mt) _note_group->raise_to_top(); EditingContext::DropDownKeys.connect (sigc::mem_fun (*this, &MidiView::drop_down_keys)); + _midi_context.NoteRangeChanged.connect (sigc::mem_fun (*this, &MidiView::view_changed)); } void @@ -1233,17 +1234,10 @@ MidiView::view_changed() if (_active_notes) { // Currently recording - const samplecnt_t zoom = _editing_context.get_current_zoom(); - if (zoom != _last_display_zoom) { - /* Update resolved canvas notes to reflect changes in zoom without - touching model. Leave active notes (with length max) alone since - they are being extended. */ - for (Events::iterator i = _events.begin(); i != _events.end(); ++i) { - if (i->second->note()->end_time() != std::numeric_limits::max()) { - update_note(i->second); - } + for (Events::iterator i = _events.begin(); i != _events.end(); ++i) { + if (i->second->note()->end_time() != std::numeric_limits::max()) { + update_note (i->second); } - _last_display_zoom = zoom; } return; } @@ -1886,6 +1880,8 @@ MidiView::add_note(const std::shared_ptr note, bool visible) { NoteBase* event = 0; + _midi_context.maybe_extend_note_range (note->note()); + if (_midi_context.note_mode() == Sustained) { Note* ev_rect = new Note (*this, _note_group, note); // XXX may leak @@ -1933,7 +1929,6 @@ MidiView::add_note(const std::shared_ptr note, bool visible) } } - _midi_context.maybe_extend_note_range (note->note()); return event; }