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
This commit is contained in:
Carl Hetherington 2011-04-16 13:31:27 +00:00
parent 443c51fee2
commit cb643ab965
6 changed files with 49 additions and 37 deletions

View File

@ -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<RegionView*>::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 ();
}

View File

@ -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__ */

View File

@ -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);

View File

@ -587,14 +587,7 @@ void
PianoRollHeader::note_range_changed()
{
_note_height = floor(_view.note_height()) + 0.5f;
queue_draw();
Glib::RefPtr<Gdk::Window> win = get_window();
if (win) {
win->process_updates(false);
}
}
void

View File

@ -57,8 +57,8 @@ public:
inline int position_of(Component comp) { return position[comp]; }
// debug
std::string get_comp_name(Component);
sigc::signal0<void> DragStarting;
sigc::signal0<void> DragFinishing;
protected:
Gtk::Adjustment& adj;

View File

@ -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";
}
}