13
0

playhead for MIDI clip editor during playback (first steps)

This commit is contained in:
Paul Davis 2024-10-17 15:06:33 -06:00
parent c5c865f589
commit 229506147a
3 changed files with 38 additions and 3 deletions

View File

@ -42,6 +42,7 @@
#include "midi_cue_view.h" #include "midi_cue_view.h"
#include "note_base.h" #include "note_base.h"
#include "prh.h" #include "prh.h"
#include "timers.h"
#include "ui_config.h" #include "ui_config.h"
#include "velocity_ghost_region.h" #include "velocity_ghost_region.h"
#include "verbose_cursor.h" #include "verbose_cursor.h"
@ -308,6 +309,25 @@ MidiCueEditor::bindings_changed ()
_canvas->set_data (X_("ardour-bindings"), midi_bindings); _canvas->set_data (X_("ardour-bindings"), midi_bindings);
} }
void
MidiCueEditor::maybe_update ()
{
if (!_track) {
return;
}
ARDOUR::TriggerPtr trigger = _track->triggerbox()->currently_playing ();
if (!trigger) {
_playhead_cursor->set_position (0);
} else {
if (trigger->active ()) {
_playhead_cursor->set_position (trigger->current_pos().samples());
} else {
_playhead_cursor->set_position (0);
}
}
}
bool bool
MidiCueEditor::canvas_enter_leave (GdkEventCrossing* ev) MidiCueEditor::canvas_enter_leave (GdkEventCrossing* ev)
{ {
@ -487,7 +507,20 @@ MidiCueEditor::rec_enable_change (ARDOUR::TriggerBox* b)
void void
MidiCueEditor::set_track (std::shared_ptr<ARDOUR::MidiTrack> t) MidiCueEditor::set_track (std::shared_ptr<ARDOUR::MidiTrack> t)
{ {
_track = t;
view->set_track (t); view->set_track (t);
_update_connection.disconnect ();
capture_connections.drop_connections ();
if (t) {
set_box (t->triggerbox());
_update_connection = Timers::rapid_connect (sigc::mem_fun (*this, &MidiCueEditor::maybe_update));
_track->DropReferences.connect (track_connection, invalidator (*this), boost::bind (&MidiCueEditor::set_track, this, nullptr), gui_context());
} else {
set_box (nullptr);
}
} }
void void
@ -1711,4 +1744,3 @@ MidiCueEditor::selectable_owners()
return std::list<SelectableOwner*> (); return std::list<SelectableOwner*> ();
} }

View File

@ -137,6 +137,7 @@ class MidiCueEditor : public CueEditor
void on_samples_per_pixel_changed (); void on_samples_per_pixel_changed ();
private: private:
std::shared_ptr<ARDOUR::MidiTrack> _track;
ArdourCanvas::GtkCanvasViewport* _canvas_viewport; ArdourCanvas::GtkCanvasViewport* _canvas_viewport;
ArdourCanvas::GtkCanvas* _canvas; ArdourCanvas::GtkCanvas* _canvas;
@ -203,6 +204,10 @@ class MidiCueEditor : public CueEditor
void start_canvas_autoscroll (bool allow_horiz, bool allow_vert, const ArdourCanvas::Rect& boundary); void start_canvas_autoscroll (bool allow_horiz, bool allow_vert, const ArdourCanvas::Rect& boundary);
void stop_canvas_autoscroll (); void stop_canvas_autoscroll ();
sigc::connection _update_connection;
PBD::ScopedConnection track_connection;
void maybe_update ();
void visual_changer (const VisualChange&); void visual_changer (const VisualChange&);
void bindings_changed (); void bindings_changed ();

View File

@ -466,8 +466,6 @@ TriggerPage::selection_changed ()
_midi_trig_box.set_trigger (ref); _midi_trig_box.set_trigger (ref);
_midi_trig_box.show (); _midi_trig_box.show ();
_midi_editor->set_box (ref.box());
std::shared_ptr<MidiTrack> mt = std::dynamic_pointer_cast<MidiTrack> (entry->strip().stripable()); std::shared_ptr<MidiTrack> mt = std::dynamic_pointer_cast<MidiTrack> (entry->strip().stripable());
assert (mt); assert (mt);
_midi_editor->set_track (mt); _midi_editor->set_track (mt);