From cb643ab9652d08a85802ce2a94c5bd57ca31256e Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 16 Apr 2011 13:31:27 +0000 Subject: [PATCH] Remove some calls to process_updates() which I think prevent GTK coalescing redraw requests. Remove some debugging code. Suspend update of MIDI regions during scroomer drag to speed things up (#3954). git-svn-id: svn://localhost/ardour2/branches/3.0@9357 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/midi_streamview.cc | 38 ++++++++++++++++++++++++++--- gtk2_ardour/midi_streamview.h | 6 +++++ gtk2_ardour/midi_time_axis.cc | 4 +++ gtk2_ardour/piano_roll_header.cc | 7 ------ libs/gtkmm2ext/gtkmm2ext/scroomer.h | 4 +-- libs/gtkmm2ext/scroomer.cc | 27 +++----------------- 6 files changed, 49 insertions(+), 37 deletions(-) diff --git a/gtk2_ardour/midi_streamview.cc b/gtk2_ardour/midi_streamview.cc index b79a6dc6d0..fd3d5383aa 100644 --- a/gtk2_ardour/midi_streamview.cc +++ b/gtk2_ardour/midi_streamview.cc @@ -65,6 +65,7 @@ MidiStreamView::MidiStreamView (MidiTimeAxisView& tv) , _data_note_min(60) , _data_note_max(71) , _note_lines (0) + , _updates_suspended (false) { /* use a group dedicated to MIDI underlays. Audio underlays are not in this group. */ midi_underlay_group = new ArdourCanvas::Group (*_canvas_group); @@ -310,7 +311,7 @@ MidiStreamView::update_contents_height () void MidiStreamView::draw_note_lines() { - if (!_note_lines) { + if (!_note_lines || _updates_suspended) { return; } @@ -371,7 +372,7 @@ MidiStreamView::apply_note_range(uint8_t lowest, uint8_t highest, bool to_region { _highest_note = highest; _lowest_note = lowest; - + int const range = _highest_note - _lowest_note; int const pixels_per_note = floor (child_height () / range); @@ -405,12 +406,20 @@ MidiStreamView::apply_note_range(uint8_t lowest, uint8_t highest, bool to_region draw_note_lines(); if (to_region_views) { + apply_note_range_to_regions (); + } + + NoteRangeChanged(); +} + +void +MidiStreamView::apply_note_range_to_regions () +{ + if (!_updates_suspended) { for (list::iterator i = region_views.begin(); i != region_views.end(); ++i) { ((MidiRegionView*)(*i))->apply_note_range(_lowest_note, _highest_note); } } - - NoteRangeChanged(); } void @@ -649,3 +658,24 @@ MidiStreamView::y_to_note (double y) const return n; } + +/** Suspend updates to the regions' note ranges and our + * note lines until resume_updates() is called. + */ +void +MidiStreamView::suspend_updates () +{ + _updates_suspended = true; +} + +/** Resume updates to region note ranges and note lines, + * and update them now. + */ +void +MidiStreamView::resume_updates () +{ + _updates_suspended = false; + + draw_note_lines (); + apply_note_range_to_regions (); +} diff --git a/gtk2_ardour/midi_streamview.h b/gtk2_ardour/midi_streamview.h index a939d8ea7d..aceb59e69f 100644 --- a/gtk2_ardour/midi_streamview.h +++ b/gtk2_ardour/midi_streamview.h @@ -97,6 +97,9 @@ class MidiStreamView : public StreamView void apply_note_range(uint8_t lowest, uint8_t highest, bool to_region_views); + void suspend_updates (); + void resume_updates (); + private: void setup_rec_box (); void update_rec_box (); @@ -118,6 +121,7 @@ class MidiStreamView : public StreamView void color_handler (); void note_range_adjustment_changed(); + void apply_note_range_to_regions (); bool _range_dirty; double _range_sum_cache; @@ -126,6 +130,8 @@ class MidiStreamView : public StreamView uint8_t _data_note_min; ///< in data uint8_t _data_note_max; ///< in data ArdourCanvas::LineSet* _note_lines; + /** true if updates to the note lines and regions are currently suspended */ + bool _updates_suspended; }; #endif /* __ardour_midi_streamview_h__ */ diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc index bf0adfd361..2f809ce2e1 100644 --- a/gtk2_ardour/midi_time_axis.cc +++ b/gtk2_ardour/midi_time_axis.cc @@ -154,6 +154,10 @@ MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session* sess, _range_scroomer = new MidiScroomer(midi_view()->note_range_adjustment); + /* Suspend updates of the StreamView during scroomer drags to speed things up */ + _range_scroomer->DragStarting.connect (sigc::mem_fun (*midi_view(), &MidiStreamView::suspend_updates)); + _range_scroomer->DragFinishing.connect (sigc::mem_fun (*midi_view(), &MidiStreamView::resume_updates)); + controls_hbox.pack_start(*_range_scroomer); controls_hbox.pack_start(*_piano_roll_header); diff --git a/gtk2_ardour/piano_roll_header.cc b/gtk2_ardour/piano_roll_header.cc index 28398678a1..4bb8250fea 100644 --- a/gtk2_ardour/piano_roll_header.cc +++ b/gtk2_ardour/piano_roll_header.cc @@ -587,14 +587,7 @@ void PianoRollHeader::note_range_changed() { _note_height = floor(_view.note_height()) + 0.5f; - queue_draw(); - - Glib::RefPtr win = get_window(); - - if (win) { - win->process_updates(false); - } } void diff --git a/libs/gtkmm2ext/gtkmm2ext/scroomer.h b/libs/gtkmm2ext/gtkmm2ext/scroomer.h index 34d5e309ae..b5c93f7f9f 100644 --- a/libs/gtkmm2ext/gtkmm2ext/scroomer.h +++ b/libs/gtkmm2ext/gtkmm2ext/scroomer.h @@ -57,8 +57,8 @@ public: inline int position_of(Component comp) { return position[comp]; } - // debug - std::string get_comp_name(Component); + sigc::signal0 DragStarting; + sigc::signal0 DragFinishing; protected: Gtk::Adjustment& adj; diff --git a/libs/gtkmm2ext/scroomer.cc b/libs/gtkmm2ext/scroomer.cc index 3009449c91..7ad99c0756 100644 --- a/libs/gtkmm2ext/scroomer.cc +++ b/libs/gtkmm2ext/scroomer.cc @@ -241,6 +241,8 @@ Scroomer::on_button_press_event (GdkEventButton* ev) } else { pinch = false; } + + DragStarting (); /* EMIT SIGNAL */ } return false; @@ -281,6 +283,7 @@ Scroomer::on_button_release_event (GdkEventButton* ev) grab_comp = None; remove_modal_grab(); + DragFinishing (); /* EMIT SIGNAL */ return true; } @@ -391,29 +394,5 @@ Scroomer::adjustment_changed() rect.set_height(position[BottomBase] - old_pos[Handle2]); win->invalidate_rect(rect, false); } - - win->process_updates(false); } -std::string -Scroomer::get_comp_name(Component c) -{ - switch (c) { - case TopBase: - return "TopBase"; - case Handle1: - return "Handle1"; - case Slider: - return "Slider"; - case Handle2: - return "Handle2"; - case BottomBase: - return "BottomBase"; - case Total: - return "Total"; - case None: - return "None"; - default: - return "ERROR"; - } -} -- 2.30.2