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);
if (_text) {
_text->hide();
delete _text;
+ _text = 0;
}
- _text = 0;
}
void
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;
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:
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;
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;
}
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);
if (selected) {
_marked_for_selection.insert(note);
}
+ if (show_velocity) {
+ _marked_for_velocity.insert(note);
+ }
}
void
midi_view()->midi_track()->diskstream()->playlist_modified();
_marked_for_selection.clear();
+ _marked_for_velocity.clear();
}
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());
hit->move(x-hit->x1(), y-hit->y1());
hit->show();
}
- if (event->selected()) {
- event->show_velocity();
- }
}
}
}
delete[] _active_notes;
_active_notes = NULL;
_marked_for_selection.clear();
+ _marked_for_velocity.clear();
}
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)) {
for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) {
if ((*i)->selected() && (*i) != ev) {
(*i)->selected(false);
+ (*i)->hide_velocity();
}
}
for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) {
if ((*i) != ev) {
(*i)->selected(false);
+ (*i)->hide_velocity();
}
}
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);
+ }
}
}
command_remove_note(event);
- command_add_note(copy, event->selected());
+ command_add_note(copy, event->selected(), true);
}
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);
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();
/** 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;
};