From 59e7c0bed19e2a4a88e32b4d6124068d52557971 Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 4 Aug 2010 17:57:41 +0000 Subject: [PATCH] extend step-edited region correctly; scroll to keep newly step-edited notes in view git-svn-id: http://subversion.ardour.org/svn/ardour2/ardour2/branches/3.0@7538 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/midi_region_view.cc | 2 +- gtk2_ardour/midi_time_axis.cc | 26 ++++++++++++++++++-------- gtk2_ardour/step_entry.cc | 8 -------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index b09092cd9..d12b7541f 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -1471,7 +1471,7 @@ MidiRegionView::step_add_note (uint8_t channel, uint8_t number, uint8_t velocity nframes64_t region_end = _region->position() + _region->length() - 1; if (end_frame > region_end) { - _region->set_length (end_frame, this); + _region->set_length (end_frame - _region->position(), this); } start_diff_command (_("step add")); diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc index 36ee6ccf9..4a13004a9 100644 --- a/gtk2_ardour/midi_time_axis.cc +++ b/gtk2_ardour/midi_time_axis.cc @@ -968,14 +968,6 @@ MidiTimeAxisView::check_step_edit () int MidiTimeAxisView::step_add_note (uint8_t channel, uint8_t pitch, uint8_t velocity, Evoral::MusicalTime beat_duration) { - MidiStreamView* msv = midi_view(); - - /* make sure its visible on the vertical axis */ - - if (pitch < msv->lowest_note() || pitch > msv->highest_note()) { - msv->update_note_range (pitch); - msv->set_note_range (MidiStreamView::ContentsRange); - } if (step_edit_region == 0) { @@ -1002,6 +994,24 @@ MidiTimeAxisView::step_add_note (uint8_t channel, uint8_t pitch, uint8_t velocit } } + MidiStreamView* msv = midi_view(); + + /* make sure its visible on the vertical axis */ + + if (pitch < msv->lowest_note() || pitch > msv->highest_note()) { + msv->update_note_range (pitch); + msv->set_note_range (MidiStreamView::ContentsRange); + } + + /* make sure its visible on the horizontal axis */ + + nframes64_t fpos = step_edit_region->position() + + step_edit_region_view->beats_to_frames (step_edit_beat_pos + beat_duration); + + if (fpos >= (_editor.leftmost_position() + _editor.current_page_frames())) { + _editor.reset_x_origin (fpos - (_editor.current_page_frames()/4)); + } + step_edit_region_view->step_add_note (channel, pitch, velocity, step_edit_beat_pos, beat_duration); if (_step_edit_triplet_countdown > 0) { diff --git a/gtk2_ardour/step_entry.cc b/gtk2_ardour/step_entry.cc index 0dc47ab8b..d2de0f79e 100644 --- a/gtk2_ardour/step_entry.cc +++ b/gtk2_ardour/step_entry.cc @@ -250,10 +250,6 @@ StepEntry::~StepEntry() bool StepEntry::on_key_press_event (GdkEventKey* ev) { - std::cerr << "Propagate key press, focus widget = " - << gtk_window_get_focus (GTK_WINDOW(gobj())) - << " _piano = " << _piano << std::endl; - if (!gtk_window_propagate_key_event (GTK_WINDOW(gobj()), ev)) { return gtk_window_activate_key (GTK_WINDOW(gobj()), ev); } @@ -263,10 +259,6 @@ StepEntry::on_key_press_event (GdkEventKey* ev) bool StepEntry::on_key_release_event (GdkEventKey* ev) { - std::cerr << "Propagate key release, focus widget = " - << gtk_window_get_focus (GTK_WINDOW(gobj())) - << " _piano = " << _piano << std::endl; - if (!gtk_window_propagate_key_event (GTK_WINDOW(gobj()), ev)) { return gtk_window_activate_key (GTK_WINDOW(gobj()), ev); } -- 2.11.4.GIT