fix up event handling so that MIDI note drag works in cue editor
This commit is contained in:
parent
2b51e0ec24
commit
5acedc036a
@ -1919,6 +1919,8 @@ EditingContext::apply_midi_note_edit_op_to_region (MidiOperator& op, MidiView& m
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::cerr << "Apply op to " << selected.size() << std::endl;
|
||||
|
||||
std::vector<Evoral::Sequence<Temporal::Beats>::Notes> v;
|
||||
v.push_back (selected);
|
||||
|
||||
|
@ -196,6 +196,8 @@ DragManager::start_grab (GdkEvent* e, Gdk::Cursor* c)
|
||||
bool
|
||||
DragManager::end_grab (GdkEvent* e)
|
||||
{
|
||||
std::cerr << "DM end drag\n";
|
||||
|
||||
_ending = true;
|
||||
|
||||
bool r = false;
|
||||
@ -412,6 +414,7 @@ Drag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
|
||||
bool
|
||||
Drag::end_grab (GdkEvent* event)
|
||||
{
|
||||
std::cerr << "end drag\n";
|
||||
editing_context.stop_canvas_autoscroll ();
|
||||
|
||||
_item->ungrab ();
|
||||
@ -6316,6 +6319,8 @@ NoteDrag::motion (GdkEvent* event, bool first_move)
|
||||
void
|
||||
NoteDrag::finished (GdkEvent* ev, bool moved)
|
||||
{
|
||||
std::cerr << "ND::f (" << moved << ")\n";
|
||||
|
||||
if (!moved) {
|
||||
/* no motion - select note */
|
||||
|
||||
@ -6356,6 +6361,7 @@ NoteDrag::finished (GdkEvent* ev, bool moved)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
std::cerr << "drop it\n";
|
||||
_region->note_dropped (_primary, total_dx (ev), total_dy (), _copy);
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ using namespace Temporal;
|
||||
|
||||
MidiCueEditor::MidiCueEditor()
|
||||
: timebar_height (15.)
|
||||
, n_timebars (2)
|
||||
, n_timebars (3)
|
||||
, view (nullptr)
|
||||
, mouse_mode (Editing::MouseContent)
|
||||
, bbt_metric (*this)
|
||||
@ -81,7 +81,7 @@ MidiCueEditor::get_canvas() const
|
||||
}
|
||||
|
||||
bool
|
||||
MidiCueEditor::canvas_event (GdkEvent* ev)
|
||||
MidiCueEditor::canvas_pre_event (GdkEvent* ev)
|
||||
{
|
||||
switch (ev->type) {
|
||||
case GDK_ENTER_NOTIFY:
|
||||
@ -94,14 +94,9 @@ MidiCueEditor::canvas_event (GdkEvent* ev)
|
||||
break;
|
||||
}
|
||||
|
||||
if (view) {
|
||||
return view->canvas_event (ev);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MidiCueEditor::build_canvas ()
|
||||
{
|
||||
@ -109,7 +104,7 @@ MidiCueEditor::build_canvas ()
|
||||
|
||||
_canvas = _canvas_viewport->canvas ();
|
||||
_canvas->set_background_color (UIConfiguration::instance().color ("arrange base"));
|
||||
_canvas->signal_event().connect (sigc::mem_fun (*this, &MidiCueEditor::canvas_event));
|
||||
_canvas->signal_event().connect (sigc::mem_fun (*this, &MidiCueEditor::canvas_pre_event), false);
|
||||
dynamic_cast<ArdourCanvas::GtkCanvas*>(_canvas)->use_nsglview (UIConfiguration::instance().get_nsgl_view_mode () == NSGLHiRes);
|
||||
|
||||
/* scroll group for items that should not automatically scroll
|
||||
@ -122,8 +117,8 @@ MidiCueEditor::build_canvas ()
|
||||
_canvas->add_scroller (*h_scroll_group);
|
||||
|
||||
hv_scroll_group = new ArdourCanvas::ScrollGroup (_canvas->root(),
|
||||
ArdourCanvas::ScrollGroup::ScrollSensitivity (ArdourCanvas::ScrollGroup::ScrollsVertically|
|
||||
ArdourCanvas::ScrollGroup::ScrollsHorizontally));
|
||||
ArdourCanvas::ScrollGroup::ScrollSensitivity (ArdourCanvas::ScrollGroup::ScrollsVertically|
|
||||
ArdourCanvas::ScrollGroup::ScrollsHorizontally));
|
||||
CANVAS_DEBUG_NAME (hv_scroll_group, "cue canvas hv scroll");
|
||||
_canvas->add_scroller (*hv_scroll_group);
|
||||
|
||||
@ -150,17 +145,27 @@ MidiCueEditor::build_canvas ()
|
||||
rubberband_rect->set_fill_color (UIConfiguration::instance().color_mod ("rubber band rect", "selection rect"));
|
||||
CANVAS_DEBUG_NAME (rubberband_rect, X_("cue rubberband rect"));
|
||||
|
||||
tempo_bar = new ArdourCanvas::Rectangle (time_line_group, ArdourCanvas::Rect (0.0, 0.0, ArdourCanvas::COORD_MAX, timebar_height));
|
||||
meter_bar = new ArdourCanvas::Rectangle (time_line_group, ArdourCanvas::Rect (0., 0, ArdourCanvas::COORD_MAX, timebar_height));
|
||||
CANVAS_DEBUG_NAME (meter_bar, "Meter Bar");
|
||||
meter_bar->set_fill(true);
|
||||
meter_bar->set_outline(true);
|
||||
meter_bar->set_outline_what(ArdourCanvas::Rectangle::BOTTOM);
|
||||
meter_bar->set_fill_color (UIConfiguration::instance().color_mod ("meter bar", "marker bar"));
|
||||
meter_bar->set_outline_color (UIConfiguration::instance().color ("marker bar separator"));
|
||||
meter_bar->set_outline_what (ArdourCanvas::Rectangle::BOTTOM);
|
||||
|
||||
tempo_bar = new ArdourCanvas::Rectangle (time_line_group, ArdourCanvas::Rect (0.0, timebar_height, ArdourCanvas::COORD_MAX, timebar_height * 2));
|
||||
CANVAS_DEBUG_NAME (tempo_bar, "Tempo Bar");
|
||||
tempo_bar->set_fill(true);
|
||||
tempo_bar->set_outline(false);
|
||||
tempo_bar->set_outline(true);
|
||||
tempo_bar->set_outline_what(ArdourCanvas::Rectangle::BOTTOM);
|
||||
// tempo_bar->set_fill_color (UIConfiguration::instance().color_mod ("tempo bar", "marker bar"));
|
||||
tempo_bar->set_fill_color (0xff0000ff);
|
||||
tempo_bar->set_fill_color (UIConfiguration::instance().color_mod ("tempo bar", "marker bar"));
|
||||
tempo_bar->set_outline_color (UIConfiguration::instance().color ("marker bar separator"));
|
||||
meter_bar->set_outline_what (ArdourCanvas::Rectangle::BOTTOM);
|
||||
|
||||
Pango::FontDescription font (UIConfiguration::instance().get_SmallerFont());
|
||||
Pango::FontDescription larger_font (UIConfiguration::instance().get_SmallBoldFont());
|
||||
bbt_ruler = new ArdourCanvas::Ruler (time_line_group, &bbt_metric, ArdourCanvas::Rect (0, timebar_height, ArdourCanvas::COORD_MAX, timebar_height * 2));
|
||||
bbt_ruler = new ArdourCanvas::Ruler (time_line_group, &bbt_metric, ArdourCanvas::Rect (0, timebar_height * 2, ArdourCanvas::COORD_MAX, timebar_height * 3));
|
||||
bbt_ruler->set_font_description (font);
|
||||
bbt_ruler->set_second_font_description (larger_font);
|
||||
Gtkmm2ext::Color base = UIConfiguration::instance().color ("ruler base");
|
||||
@ -193,7 +198,6 @@ MidiCueEditor::canvas_enter_leave (GdkEventCrossing* ev)
|
||||
_canvas_viewport->canvas()->grab_focus ();
|
||||
ActionManager::set_sensitive (_midi_actions, true);
|
||||
EditingContext::push_editing_context (this);
|
||||
std::cerr << "MIDI CUE EDITOR - IN!\n";
|
||||
}
|
||||
break;
|
||||
case GDK_LEAVE_NOTIFY:
|
||||
@ -201,7 +205,6 @@ MidiCueEditor::canvas_enter_leave (GdkEventCrossing* ev)
|
||||
ActionManager::set_sensitive (_midi_actions, false);
|
||||
ARDOUR_UI::instance()->reset_focus (_canvas_viewport);
|
||||
EditingContext::pop_editing_context ();
|
||||
std::cerr << "MIDI CUE EDITOR - OUT!\n";
|
||||
}
|
||||
default:
|
||||
break;
|
||||
@ -216,6 +219,10 @@ MidiCueEditor::canvas_allocate (Gtk::Allocation alloc)
|
||||
_visible_canvas_height = alloc.get_height();
|
||||
|
||||
bg->set_size (alloc.get_width(), alloc.get_height());
|
||||
|
||||
if (view) {
|
||||
view->set_height (alloc.get_height() - (n_timebars * timebar_height));
|
||||
}
|
||||
}
|
||||
|
||||
timepos_t
|
||||
@ -266,8 +273,6 @@ MidiCueEditor::reset_zoom (samplecnt_t spp)
|
||||
view->set_samples_per_pixel (spp);
|
||||
}
|
||||
|
||||
std::cerr << "RZ @ " << spp << " cps " << current_page_samples() << " vcw " << _visible_canvas_width << std::endl;
|
||||
|
||||
bbt_ruler->set_range (0, current_page_samples());
|
||||
compute_bbt_ruler_scale (0, current_page_samples());
|
||||
bbt_metric.units_per_pixel = spp;
|
||||
@ -279,33 +284,6 @@ MidiCueEditor::current_page_samples() const
|
||||
return (samplecnt_t) _visible_canvas_width* samples_per_pixel;
|
||||
}
|
||||
|
||||
void
|
||||
MidiCueEditor::apply_midi_note_edit_op (ARDOUR::MidiOperator& op, const RegionSelection& rs)
|
||||
{
|
||||
}
|
||||
|
||||
PBD::Command*
|
||||
MidiCueEditor::apply_midi_note_edit_op_to_region (ARDOUR::MidiOperator& op, MidiRegionView& mrv)
|
||||
{
|
||||
#if 0
|
||||
Evoral::Sequence<Temporal::Beats>::Notes selected;
|
||||
mrv.selection_as_notelist (selected, true);
|
||||
|
||||
if (selected.empty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
vector<Evoral::Sequence<Temporal::Beats>::Notes> v;
|
||||
v.push_back (selected);
|
||||
|
||||
timepos_t pos = mrv.midi_region()->source_position();
|
||||
|
||||
return op (mrv.midi_region()->model(), pos.beats(), v);
|
||||
#endif
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
MidiCueEditor::canvas_note_event (GdkEvent* event, ArdourCanvas::Item* item)
|
||||
{
|
||||
@ -419,7 +397,23 @@ MidiCueEditor::button_press_handler_2 (ArdourCanvas::Item*, GdkEvent*, ItemType)
|
||||
bool
|
||||
MidiCueEditor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type)
|
||||
{
|
||||
std::cerr << "hey\n";
|
||||
bool were_dragging = false;
|
||||
|
||||
if (!Keyboard::is_context_menu_event (&event->button)) {
|
||||
|
||||
/* see if we're finishing a drag */
|
||||
|
||||
if (_drags->active ()) {
|
||||
|
||||
bool const r = _drags->end_grab (event);
|
||||
if (r) {
|
||||
/* grab dragged, so do nothing else */
|
||||
return true;
|
||||
}
|
||||
|
||||
were_dragging = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (Keyboard::is_context_menu_event (&event->button)) {
|
||||
switch (item_type) {
|
||||
@ -456,8 +450,13 @@ MidiCueEditor::button_release_dispatch (GdkEventButton* ev)
|
||||
}
|
||||
|
||||
bool
|
||||
MidiCueEditor::motion_handler (ArdourCanvas::Item*, GdkEvent*, bool from_autoscroll)
|
||||
MidiCueEditor::motion_handler (ArdourCanvas::Item*, GdkEvent* event, bool from_autoscroll)
|
||||
{
|
||||
if (_drags->active ()) {
|
||||
//drags change the snapped_cursor location, because we are snapping the thing being dragged, not the actual mouse cursor
|
||||
return _drags->motion_handler (event, from_autoscroll);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -61,9 +61,6 @@ class MidiCueEditor : public CueEditor
|
||||
int32_t get_grid_beat_divisions (Editing::GridType gt) const { return 1; }
|
||||
int32_t get_grid_music_divisions (Editing::GridType gt, uint32_t event_state) const { return 1; }
|
||||
|
||||
void apply_midi_note_edit_op (ARDOUR::MidiOperator& op, const RegionSelection& rs);
|
||||
PBD::Command* apply_midi_note_edit_op_to_region (ARDOUR::MidiOperator& op, MidiRegionView& mrv);
|
||||
|
||||
void set_region (std::shared_ptr<ARDOUR::MidiTrack>, std::shared_ptr<ARDOUR::MidiRegion>);
|
||||
|
||||
ArdourCanvas::ScrollGroup* get_hscroll_group () const { return h_scroll_group; }
|
||||
@ -127,6 +124,7 @@ class MidiCueEditor : public CueEditor
|
||||
ArdourCanvas::Container* time_line_group;
|
||||
ArdourCanvas::Ruler* bbt_ruler;
|
||||
ArdourCanvas::Rectangle* tempo_bar;
|
||||
ArdourCanvas::Rectangle* meter_bar;
|
||||
|
||||
ArdourCanvas::Rectangle* transport_loop_range_rect;
|
||||
|
||||
@ -159,7 +157,7 @@ class MidiCueEditor : public CueEditor
|
||||
|
||||
BBTMetric bbt_metric;
|
||||
|
||||
bool canvas_event (GdkEvent*);
|
||||
bool canvas_pre_event (GdkEvent*);
|
||||
};
|
||||
|
||||
|
||||
|
@ -381,6 +381,7 @@ MidiView::button_press (GdkEventButton* ev)
|
||||
|
||||
_pressed_button = ev->button;
|
||||
|
||||
|
||||
if (m == MouseDraw || (m == MouseContent && Keyboard::modifier_state_contains (ev->state, Keyboard::insert_note_modifier()))) {
|
||||
|
||||
if (_midi_context.note_mode() == Percussive) {
|
||||
@ -402,7 +403,7 @@ MidiView::button_press (GdkEventButton* ev)
|
||||
_pressed_button = ev->button;
|
||||
_mouse_changed_selection = false;
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
@ -424,7 +425,6 @@ MidiView::button_release (GdkEventButton* ev)
|
||||
|
||||
switch (_mouse_state) {
|
||||
case Pressed: // Clicked
|
||||
std::cerr << "P\n";
|
||||
switch (_editing_context.current_mouse_mode()) {
|
||||
case MouseRange:
|
||||
/* no motion occurred - simple click */
|
||||
@ -555,8 +555,6 @@ MidiView::motion (GdkEventMotion* ev)
|
||||
bool
|
||||
MidiView::scroll (GdkEventScroll* ev)
|
||||
{
|
||||
std::cerr << "scroll\n";
|
||||
|
||||
if (_editing_context.drags()->active()) {
|
||||
return false;
|
||||
}
|
||||
@ -602,12 +600,10 @@ MidiView::scroll (GdkEventScroll* ev)
|
||||
return true;
|
||||
|
||||
case GDK_SCROLL_LEFT:
|
||||
std::cerr << "left minus\n";
|
||||
_editing_context.set_horizontal_position (_editing_context.horizontal_position() - 20.0);
|
||||
break;
|
||||
|
||||
case GDK_SCROLL_RIGHT:
|
||||
std::cerr << "right plus\n";
|
||||
_editing_context.set_horizontal_position (_editing_context.horizontal_position() + 20.0);
|
||||
break;
|
||||
|
||||
@ -2703,6 +2699,8 @@ MidiView::note_dropped(NoteBase *, timecnt_t const & d_qn, int8_t dnote, bool co
|
||||
_copy_drag_events.clear ();
|
||||
}
|
||||
|
||||
std::cerr << "DROP & EDIT\n";
|
||||
|
||||
apply_note_diff (true /*subcommand, we don't want this to start a new commit*/, copy);
|
||||
_editing_context.commit_reversible_command ();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user