(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
This commit is contained in:
Paul Davis
2010-07-25 21:19:55 +00:00
parent 6fa58df791
commit 0bbc9144cc
6 changed files with 26 additions and 13 deletions

View File

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

View File

@@ -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])
{

View File

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

View File

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

View File

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

View File

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