diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2010-07-25 21:19:55 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2010-07-25 21:19:55 +0000 |
commit | 0bbc9144cca18495775cdc8b2050e5141bfcdc12 (patch) | |
tree | 8cdc26e873e77e609d493acccd32816296757d8d | |
parent | 6fa58df7918b3a9fea715bf6c917c144af540f3c (diff) |
(1) extend region if needed BEFORE adding step-edit note, so that the new note ends up in the selection (2) hide the channel selector that shows up on note-right-click after its clicked anywhere, not just if the note(s) channel(s) are changed
git-svn-id: svn://localhost/ardour2/branches/3.0@7492 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r-- | gtk2_ardour/canvas-note-event.cc | 5 | ||||
-rw-r--r-- | gtk2_ardour/midi_channel_selector.cc | 11 | ||||
-rw-r--r-- | gtk2_ardour/midi_channel_selector.h | 2 | ||||
-rw-r--r-- | gtk2_ardour/midi_region_view.cc | 17 | ||||
-rw-r--r-- | gtk2_ardour/midi_region_view.h | 2 | ||||
-rw-r--r-- | gtk2_ardour/midi_time_axis.cc | 2 |
6 files changed, 26 insertions, 13 deletions
diff --git a/gtk2_ardour/canvas-note-event.cc b/gtk2_ardour/canvas-note-event.cc index f660f8e8ba..80275d9362 100644 --- a/gtk2_ardour/canvas-note-event.cc +++ b/gtk2_ardour/canvas-note-event.cc @@ -136,12 +136,14 @@ void CanvasNoteEvent::show_channel_selector(void) { if (_channel_selector_widget == 0) { - cerr << "Note has channel: " << int(_note->channel()) << endl; SingleMidiChannelSelector* _channel_selector = new SingleMidiChannelSelector(_note->channel()); _channel_selector->show_all(); _channel_selector->channel_selected.connect( sigc::mem_fun(this, &CanvasNoteEvent::on_channel_change)); + _channel_selector->clicked.connect ( + sigc::mem_fun (this, &CanvasNoteEvent::hide_channel_selector)); + _channel_selector_widget = new Widget(*(_item->property_parent()), x1(), y2() + 2, @@ -238,7 +240,6 @@ CanvasNoteEvent::on_event(GdkEvent* ev) break; case GDK_BUTTON_PRESS: - cerr << "button press, bton = " << ev->button.button << endl; if (ev->button.button == 3 && Keyboard::no_modifiers_active (ev->button.state)) { show_channel_selector(); return true; diff --git a/gtk2_ardour/midi_channel_selector.cc b/gtk2_ardour/midi_channel_selector.cc index c889602b8c..e5416c81ff 100644 --- a/gtk2_ardour/midi_channel_selector.cc +++ b/gtk2_ardour/midi_channel_selector.cc @@ -53,6 +53,10 @@ MidiChannelSelector::MidiChannelSelector(int n_rows, int n_columns, int start_ro &_buttons[row][column], channel_nr - 1)); + _buttons[row][column].signal_button_release_event().connect( + sigc::mem_fun(this, &MidiChannelSelector::was_clicked), false); + + int table_row = start_row + row; int table_column = start_column + column; attach(_buttons[row][column], table_column, table_column + 1, table_row, table_row + 1); @@ -64,6 +68,13 @@ MidiChannelSelector::~MidiChannelSelector() { } +bool +MidiChannelSelector::was_clicked (GdkEventButton*) +{ + clicked (); + return false; +} + void MidiChannelSelector::set_channel_colors(const uint32_t new_channel_colors[16]) { diff --git a/gtk2_ardour/midi_channel_selector.h b/gtk2_ardour/midi_channel_selector.h index 42c3d55045..2777282e2c 100644 --- a/gtk2_ardour/midi_channel_selector.h +++ b/gtk2_ardour/midi_channel_selector.h @@ -37,6 +37,7 @@ public: virtual ~MidiChannelSelector() = 0; sigc::signal<void, ARDOUR::ChannelMode, uint16_t> mode_changed; + sigc::signal<void> clicked; void set_channel_colors(const uint32_t new_channel_colors[16]); void set_default_channel_color(); @@ -46,6 +47,7 @@ protected: Gtk::Label _button_labels[4][4]; Gtk::ToggleButton _buttons[4][4]; int _recursion_counter; + bool was_clicked (GdkEventButton*); }; class SingleMidiChannelSelector : public MidiChannelSelector diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index 9f67dc89ba..b7fd04765c 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -816,7 +816,6 @@ MidiRegionView::apply_diff () _model->apply_command(*trackview.session(), _diff_command); _diff_command = 0; midi_view()->midi_track()->playlist_modified(); - if (add_or_remove) { _marked_for_selection.clear(); @@ -1435,7 +1434,7 @@ MidiRegionView::add_note(const boost::shared_ptr<NoteType> note, bool visible) if (event) { if (_marked_for_selection.find(note) != _marked_for_selection.end()) { note_selected(event, true); - } + } if (_marked_for_velocity.find(note) != _marked_for_velocity.end()) { event->show_velocity(); @@ -1452,15 +1451,11 @@ MidiRegionView::add_note(const boost::shared_ptr<NoteType> note, bool visible) } void -MidiRegionView::add_note (uint8_t channel, uint8_t number, uint8_t velocity, +MidiRegionView::step_add_note (uint8_t channel, uint8_t number, uint8_t velocity, Evoral::MusicalTime pos, Evoral::MusicalTime len) { boost::shared_ptr<NoteType> new_note (new NoteType (channel, pos, len, number, velocity)); - start_diff_command (_("step add")); - diff_add_note (new_note, true, false); - apply_diff(); - /* potentially extend region to hold new note */ nframes64_t end_frame = _region->position() + beats_to_frames (new_note->end_time()); @@ -1468,9 +1463,13 @@ MidiRegionView::add_note (uint8_t channel, uint8_t number, uint8_t velocity, if (end_frame > region_end) { _region->set_length (end_frame, this); - } else { - redisplay_model (); } + + start_diff_command (_("step add")); + diff_add_note (new_note, true, false); + apply_diff(); + + // last_step_edit_note = new_note; } void diff --git a/gtk2_ardour/midi_region_view.h b/gtk2_ardour/midi_region_view.h index cc9241b0e0..b45d2b532f 100644 --- a/gtk2_ardour/midi_region_view.h +++ b/gtk2_ardour/midi_region_view.h @@ -93,7 +93,7 @@ class MidiRegionView : public RegionView inline MidiStreamView* midi_stream_view() const { return midi_view()->midi_view(); } - void add_note (uint8_t channel, uint8_t number, uint8_t velocity, + void step_add_note (uint8_t channel, uint8_t number, uint8_t velocity, Evoral::MusicalTime pos, Evoral::MusicalTime len); void set_height (double); diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc index cb4eb795bd..7651cff30e 100644 --- a/gtk2_ardour/midi_time_axis.cc +++ b/gtk2_ardour/midi_time_axis.cc @@ -945,7 +945,7 @@ MidiTimeAxisView::check_step_edit () continue; } - step_edit_region_view->add_note (buf[0] & 0xf, buf[1], buf[2], step_edit_beat_pos, beats); + step_edit_region_view->step_add_note (buf[0] & 0xf, buf[1], buf[2], step_edit_beat_pos, beats); step_edit_beat_pos += beats; } } |