From 8d44391f4ba571c4dbcec0a87033c83414f515e8 Mon Sep 17 00:00:00 2001 From: Hans Baier Date: Fri, 9 May 2008 11:28:14 +0000 Subject: * adjusted formatting a bit to style guide * fixed: velocity value left on canvas * fixed: end-of-track problem still showed up sometimes * enabled heaps of debugging output in order to debug MidiModel corruption git-svn-id: svn://localhost/ardour2/branches/3.0@3329 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/canvas-note-event.cc | 22 +++++++++++----- gtk2_ardour/canvas-note.h | 4 +-- gtk2_ardour/midi_channel_selector.cc | 1 + gtk2_ardour/midi_channel_selector.h | 4 +-- gtk2_ardour/midi_region_view.cc | 49 ++++++++++++++++++++---------------- 5 files changed, 49 insertions(+), 31 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/canvas-note-event.cc b/gtk2_ardour/canvas-note-event.cc index 149ad755ac..bd402f8c08 100644 --- a/gtk2_ardour/canvas-note-event.cc +++ b/gtk2_ardour/canvas-note-event.cc @@ -45,8 +45,11 @@ CanvasNoteEvent::CanvasNoteEvent(MidiRegionView& region, Item* item, CanvasNoteEvent::~CanvasNoteEvent() { - if (_text) + cerr << "CanvasNoteEvent::~CanvasNoteEvent() " << int(_note->note()) << " velo " << int(_note->velocity()) << endl; + if (_text) { + _text->hide(); delete _text; + } if (_channel_selector_widget) delete _channel_selector_widget; @@ -56,13 +59,17 @@ void CanvasNoteEvent::move_event(double dx, double dy) { _item->move(dx, dy); - if (_text) + if (_text) { + _text->hide(); _text->move(dx, dy); + _text->show(); + } } void CanvasNoteEvent::show_velocity(void) { + hide_velocity(); _text = new Text(*(_item->property_parent())); _text->property_x() = (x1() + x2()) /2; _text->property_y() = (y1() + y2()) /2; @@ -79,8 +86,11 @@ CanvasNoteEvent::show_velocity(void) void CanvasNoteEvent::hide_velocity(void) { - delete _text; - _text = NULL; + if(_text) { + _text->hide(); + delete _text; + } + _text = 0; } void @@ -91,8 +101,8 @@ CanvasNoteEvent::on_channel_selection_change(uint16_t selection) set_fill_color(ARDOUR_UI::config()->canvasvar_MidiNoteFillInactiveChannel.get()); set_outline_color(ARDOUR_UI::config()->canvasvar_MidiNoteOutlineInactiveChannel.get()); } else { - set_fill_color(note_fill_color(_note->velocity())); - set_outline_color(note_outline_color(_note->velocity())); + // set the color according to the notes selection state + selected(_selected); } // this forces the item to update..... maybe slow... _item->hide(); diff --git a/gtk2_ardour/canvas-note.h b/gtk2_ardour/canvas-note.h index 84791c89ca..97739b4207 100644 --- a/gtk2_ardour/canvas-note.h +++ b/gtk2_ardour/canvas-note.h @@ -36,8 +36,8 @@ public: double x2() { return property_x2(); } double y2() { return property_y2(); } - void set_outline_color(uint32_t c) { property_outline_color_rgba() = c; } - void set_fill_color(uint32_t c) { property_fill_color_rgba() = c; } + void set_outline_color(uint32_t c) { property_outline_color_rgba() = c; hide(); show(); } + void set_fill_color(uint32_t c) { property_fill_color_rgba() = c; hide(); show(); } bool on_event(GdkEvent* ev); diff --git a/gtk2_ardour/midi_channel_selector.cc b/gtk2_ardour/midi_channel_selector.cc index 1b0e9ecfbb..0018c169ab 100644 --- a/gtk2_ardour/midi_channel_selector.cc +++ b/gtk2_ardour/midi_channel_selector.cc @@ -65,6 +65,7 @@ SingleMidiChannelSelector::button_toggled(ToggleButton *button, uint8_t channel) _last_active_button->set_active(false); _active_channel = channel; _last_active_button = button; + channel_selected.emit(channel); } } else { // if not, the user pressed the already active button diff --git a/gtk2_ardour/midi_channel_selector.h b/gtk2_ardour/midi_channel_selector.h index 3562f5febe..9ac95036d6 100644 --- a/gtk2_ardour/midi_channel_selector.h +++ b/gtk2_ardour/midi_channel_selector.h @@ -34,8 +34,8 @@ public: protected: virtual void button_toggled(Gtk::ToggleButton *button, uint8_t button_nr); - Gtk::ToggleButton *_last_active_button; - uint8_t _active_channel; + Gtk::ToggleButton* _last_active_button; + uint8_t _active_channel; }; class MidiMultipleChannelSelector : public MidiChannelSelector diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index 5b0f3070d4..69f756f3ca 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -456,24 +456,22 @@ MidiRegionView::redisplay_model() if (_model) { clear_events(); - begin_write(); - _model->read_lock(); - MidiModel::Notes notes = _model->notes(); cerr << endl << "Model contains " << notes.size() << " Notes:" << endl; for(MidiModel::Notes::iterator i = notes.begin(); i != notes.end(); ++i) { - Note note = *(*i).get(); - cerr << "MODEL: Note time: " << note.time() << " duration: " << note.duration() - << " end-time: " << note.end_time() - << " velocity: " << int(note.velocity()) + cerr << "MODEL: Note time: " << (*i)->time() + << " pitch: " << int((*i)->note()) + << " duration: " << (*i)->duration() + << " end-time: " << (*i)->end_time() + << " velocity: " << int((*i)->velocity()) //<< " Note-on: " << note.on_event(). //<< " Note-off: " << note.off_event() << endl; } - for (size_t i=0; i < _model->n_notes(); ++i) { + for (size_t i = 0; i < _model->n_notes(); ++i) { add_note(_model->note_at(i)); } @@ -495,8 +493,6 @@ MidiRegionView::redisplay_model() } } - end_write(); - // Is this necessary ?????????? /*for (Automatable::Controls::const_iterator i = _model->controls().begin(); i != _model->controls().end(); ++i) { @@ -841,9 +837,11 @@ MidiRegionView::delete_selection() { assert(_delta_command); - for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) - if ((*i)->selected()) + for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) { + if ((*i)->selected()) { _delta_command->remove((*i)->note()); + } + } _selection.clear(); } @@ -851,9 +849,11 @@ MidiRegionView::delete_selection() void MidiRegionView::clear_selection_except(ArdourCanvas::CanvasNoteEvent* ev) { - for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) - if ((*i)->selected() && (*i) != ev) + for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) { + if ((*i)->selected() && (*i) != ev) { (*i)->selected(false); + } + } _selection.clear(); } @@ -861,40 +861,47 @@ MidiRegionView::clear_selection_except(ArdourCanvas::CanvasNoteEvent* ev) void MidiRegionView::unique_select(ArdourCanvas::CanvasNoteEvent* ev) { - for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) - if ((*i) != ev) + for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) { + if ((*i) != ev) { (*i)->selected(false); + } + } _selection.clear(); _selection.insert(ev); - if ( ! ev->selected()) + if ( ! ev->selected()) { ev->selected(true); + } } void MidiRegionView::note_selected(ArdourCanvas::CanvasNoteEvent* ev, bool add) { - if ( ! add) + if ( ! add) { clear_selection_except(ev); + } _selection.insert(ev); - if ( ! ev->selected()) + if ( ! ev->selected()) { ev->selected(true); + } } void MidiRegionView::note_deselected(ArdourCanvas::CanvasNoteEvent* ev, bool add) { - if ( ! add) + if ( ! add) { clear_selection_except(ev); + } _selection.erase(ev); - if (ev->selected()) + if (ev->selected()) { ev->selected(false); + } } -- cgit v1.2.3