Make MIDI note editing work somewhat again...
Only show note velocity text when the user is actually editing velocity. git-svn-id: svn://localhost/ardour2/branches/3.0@5047 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
61169434ea
commit
7863c03cfc
|
@ -74,8 +74,9 @@ CanvasNoteEvent::move_event(double dx, double dy)
|
|||
void
|
||||
CanvasNoteEvent::show_velocity()
|
||||
{
|
||||
hide_velocity();
|
||||
_text = new InteractiveText(*(_item->property_parent()), this);
|
||||
if (!_text) {
|
||||
_text = new InteractiveText(*(_item->property_parent()), this);
|
||||
}
|
||||
_text->property_x() = (x1() + x2()) /2;
|
||||
_text->property_y() = (y1() + y2()) /2;
|
||||
ostringstream velo(ios::ate);
|
||||
|
@ -93,8 +94,8 @@ CanvasNoteEvent::hide_velocity()
|
|||
if (_text) {
|
||||
_text->hide();
|
||||
delete _text;
|
||||
_text = 0;
|
||||
}
|
||||
_text = 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -166,11 +167,9 @@ CanvasNoteEvent::selected(bool selected)
|
|||
ARDOUR_UI::config()->canvasvar_MidiNoteSelected.get(), 0.5));
|
||||
set_outline_color(calculate_outline(
|
||||
ARDOUR_UI::config()->canvasvar_MidiNoteSelected.get()));
|
||||
show_velocity();
|
||||
} else {
|
||||
set_fill_color(base_color());
|
||||
set_outline_color(calculate_outline(base_color()));
|
||||
hide_velocity();
|
||||
}
|
||||
|
||||
_selected = selected;
|
||||
|
@ -260,17 +259,17 @@ CanvasNoteEvent::on_event(GdkEvent* ev)
|
|||
|
||||
case GDK_ENTER_NOTIFY:
|
||||
_region.note_entered(this);
|
||||
_item->grab_focus();
|
||||
show_velocity();
|
||||
Keyboard::magic_widget_grab_focus();
|
||||
//_item->grab_focus();
|
||||
//show_velocity();
|
||||
//Keyboard::magic_widget_grab_focus();
|
||||
break;
|
||||
|
||||
case GDK_LEAVE_NOTIFY:
|
||||
Keyboard::magic_widget_drop_focus();
|
||||
//Keyboard::magic_widget_drop_focus();
|
||||
if (! selected()) {
|
||||
hide_velocity();
|
||||
}
|
||||
_region.get_canvas_group()->grab_focus();
|
||||
//_region.get_canvas_group()->grab_focus();
|
||||
break;
|
||||
|
||||
case GDK_BUTTON_PRESS:
|
||||
|
|
|
@ -20,8 +20,7 @@ CanvasNote::on_event(GdkEvent* ev)
|
|||
switch (ev->type) {
|
||||
case GDK_BUTTON_PRESS:
|
||||
if (ev->button.button == 2 ||
|
||||
(ev->button.button == 1 &&
|
||||
edit_mode == Editing::MidiEditResize)) {
|
||||
(ev->button.button == 1 && edit_mode == Editing::MidiEditResize)) {
|
||||
double region_start = _region.get_position_pixels();
|
||||
event_x = ev->button.x;
|
||||
middle_point = region_start + x1() + (x2() - x1()) / 2.0L;
|
||||
|
|
|
@ -66,13 +66,14 @@ protected:
|
|||
class InteractiveRect: public SimpleRect, public InteractiveItem
|
||||
{
|
||||
public:
|
||||
InteractiveRect(Group& parent, InteractiveItem* parent_item, double x1, double y1, double x2, double y2)
|
||||
InteractiveRect(Group& parent, InteractiveItem* parent_item,
|
||||
double x1, double y1, double x2, double y2)
|
||||
: SimpleRect(parent, x1, y1, x2, y2)
|
||||
, _parent_item(parent_item)
|
||||
{}
|
||||
{}
|
||||
|
||||
bool on_event(GdkEvent* ev) {
|
||||
if(_parent_item) {
|
||||
if (_parent_item) {
|
||||
return _parent_item->on_event(ev);
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
@ -499,7 +499,7 @@ MidiRegionView::start_delta_command(string name)
|
|||
}
|
||||
|
||||
void
|
||||
MidiRegionView::command_add_note(const boost::shared_ptr<NoteType> note, bool selected)
|
||||
MidiRegionView::command_add_note(const boost::shared_ptr<NoteType> note, bool selected, bool show_velocity)
|
||||
{
|
||||
if (_delta_command) {
|
||||
_delta_command->add(note);
|
||||
|
@ -507,6 +507,9 @@ MidiRegionView::command_add_note(const boost::shared_ptr<NoteType> note, bool se
|
|||
if (selected) {
|
||||
_marked_for_selection.insert(note);
|
||||
}
|
||||
if (show_velocity) {
|
||||
_marked_for_velocity.insert(note);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -534,6 +537,7 @@ MidiRegionView::apply_command()
|
|||
midi_view()->midi_track()->diskstream()->playlist_modified();
|
||||
|
||||
_marked_for_selection.clear();
|
||||
_marked_for_velocity.clear();
|
||||
}
|
||||
|
||||
|
||||
|
@ -754,7 +758,6 @@ MidiRegionView::apply_note_range (uint8_t min, uint8_t max, bool force)
|
|||
item->show();
|
||||
}
|
||||
|
||||
event->hide_velocity();
|
||||
if (CanvasNote* note = dynamic_cast<CanvasNote*>(event)) {
|
||||
const double y1 = midi_stream_view()->note_to_y(event->note()->note());
|
||||
const double y2 = y1 + floor(midi_stream_view()->note_height());
|
||||
|
@ -772,9 +775,6 @@ MidiRegionView::apply_note_range (uint8_t min, uint8_t max, bool force)
|
|||
hit->move(x-hit->x1(), y-hit->y1());
|
||||
hit->show();
|
||||
}
|
||||
if (event->selected()) {
|
||||
event->show_velocity();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -838,6 +838,7 @@ MidiRegionView::end_write()
|
|||
delete[] _active_notes;
|
||||
_active_notes = NULL;
|
||||
_marked_for_selection.clear();
|
||||
_marked_for_velocity.clear();
|
||||
}
|
||||
|
||||
|
||||
|
@ -998,6 +999,9 @@ MidiRegionView::add_note(const boost::shared_ptr<NoteType> note)
|
|||
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();
|
||||
}
|
||||
event->on_channel_selection_change(_last_channel_selection);
|
||||
_events.push_back(event);
|
||||
if (note_in_visible_range(note)) {
|
||||
|
@ -1163,6 +1167,7 @@ MidiRegionView::clear_selection_except(ArdourCanvas::CanvasNoteEvent* ev)
|
|||
for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) {
|
||||
if ((*i)->selected() && (*i) != ev) {
|
||||
(*i)->selected(false);
|
||||
(*i)->hide_velocity();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1175,6 +1180,7 @@ MidiRegionView::unique_select(ArdourCanvas::CanvasNoteEvent* ev)
|
|||
for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) {
|
||||
if ((*i) != ev) {
|
||||
(*i)->selected(false);
|
||||
(*i)->hide_velocity();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1279,8 +1285,9 @@ MidiRegionView::update_drag_selection(double x1, double x2, double y1, double y2
|
|||
void
|
||||
MidiRegionView::move_selection(double dx, double dy)
|
||||
{
|
||||
for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i)
|
||||
for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) {
|
||||
(*i)->move_event(dx, dy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1550,7 +1557,7 @@ MidiRegionView::change_note_velocity(CanvasNoteEvent* event, int8_t velocity, bo
|
|||
}
|
||||
|
||||
command_remove_note(event);
|
||||
command_add_note(copy, event->selected());
|
||||
command_add_note(copy, event->selected(), true);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1599,8 +1606,8 @@ void
|
|||
MidiRegionView::note_entered(ArdourCanvas::CanvasNoteEvent* ev)
|
||||
{
|
||||
if (ev->note() && _mouse_state == EraseTouchDragging) {
|
||||
start_delta_command(_("note entered"));
|
||||
ev->selected(true);
|
||||
if (!_delta_command)
|
||||
start_delta_command(_("note entered"));
|
||||
_delta_command->remove(ev->note());
|
||||
} else if (_mouse_state == SelectTouchDragging) {
|
||||
note_selected(ev, true);
|
||||
|
|
|
@ -159,7 +159,7 @@ class MidiRegionView : public RegionView
|
|||
void display_model(boost::shared_ptr<ARDOUR::MidiModel> model);
|
||||
|
||||
void start_delta_command(std::string name = "midi edit");
|
||||
void command_add_note(const boost::shared_ptr<NoteType> note, bool selected);
|
||||
void command_add_note(const boost::shared_ptr<NoteType> note, bool selected, bool show_velocity=false);
|
||||
void command_remove_note(ArdourCanvas::CanvasNoteEvent* ev);
|
||||
|
||||
void apply_command();
|
||||
|
@ -333,6 +333,10 @@ class MidiRegionView : public RegionView
|
|||
/** New notes (created in the current command) which should be selected
|
||||
* when they appear after the command is applied. */
|
||||
std::set< boost::shared_ptr<NoteType> > _marked_for_selection;
|
||||
|
||||
/** New notes (created in the current command) which should have visible velocity
|
||||
* when they appear after the command is applied. */
|
||||
std::set< boost::shared_ptr<NoteType> > _marked_for_velocity;
|
||||
|
||||
std::vector<NoteResizeData *> _resize_data;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue