13
0

start using the now-compilable MidiView

Nothing yet derives from this, but MIDI display items and drags
do use it.
This commit is contained in:
Paul Davis 2024-01-04 19:07:52 -07:00
parent fb1dbb1e9c
commit a550b6482f
24 changed files with 446 additions and 543 deletions

View File

@ -92,8 +92,6 @@ class CueEditor : public EditingContext
} }
VerboseCursor* verbose_cursor () const; VerboseCursor* verbose_cursor () const;
void set_snapped_cursor_position (Temporal::timepos_t const & pos); void set_snapped_cursor_position (Temporal::timepos_t const & pos);
std::vector<MidiRegionView*> filter_to_unique_midi_region_views (RegionSelection const & ms) const; std::vector<MidiRegionView*> filter_to_unique_midi_region_views (RegionSelection const & ms) const;

View File

@ -25,7 +25,7 @@
#include "gtkmm2ext/utils.h" #include "gtkmm2ext/utils.h"
#include "edit_note_dialog.h" #include "edit_note_dialog.h"
#include "midi_region_view.h" #include "midi_view.h"
#include "note_base.h" #include "note_base.h"
#include "pbd/i18n.h" #include "pbd/i18n.h"
@ -41,7 +41,7 @@ using namespace Gtkmm2ext;
* @param n Notes to edit. * @param n Notes to edit.
*/ */
EditNoteDialog::EditNoteDialog (MidiRegionView* rv, set<NoteBase*> n) EditNoteDialog::EditNoteDialog (MidiView* rv, set<NoteBase*> n)
: ArdourDialog (_("Note")) : ArdourDialog (_("Note"))
, _region_view (rv) , _region_view (rv)
, _events (n) , _events (n)
@ -94,12 +94,11 @@ EditNoteDialog::EditNoteDialog (MidiRegionView* rv, set<NoteBase*> n)
table->attach (_time_all, 2, 3, r, r + 1); table->attach (_time_all, 2, 3, r, r + 1);
++r; ++r;
_time_clock.set_session (_region_view->get_time_axis_view().session ()); // XXXX _time_clock.set_session (_region_view->get_time_axis_view().session ());
_time_clock.set_mode (AudioClock::BBT); _time_clock.set_mode (AudioClock::BBT);
/* Calculate absolute position of the event on time timeline */ /* Calculate absolute position of the event on time timeline */
std::shared_ptr<ARDOUR::Region> region (_region_view->region ()); timepos_t const pos = _region_view->current_slice().source_position() + timecnt_t ((*_events.begin())->note()->time ());
timepos_t const pos = region->source_position() + timecnt_t ((*_events.begin())->note()->time ());
_time_clock.set (pos, true); _time_clock.set (pos, true);
@ -109,7 +108,7 @@ EditNoteDialog::EditNoteDialog (MidiRegionView* rv, set<NoteBase*> n)
table->attach (_length_all, 2, 3, r, r + 1); table->attach (_length_all, 2, 3, r, r + 1);
++r; ++r;
_length_clock.set_session (_region_view->get_time_axis_view().session ()); // XXXX _length_clock.set_session (_region_view->get_time_axis_view().session ());
_length_clock.set_mode (AudioClock::BBT); _length_clock.set_mode (AudioClock::BBT);
_length_clock.set_duration (timecnt_t ((*_events.begin())->note()->length()), true); _length_clock.set_duration (timecnt_t ((*_events.begin())->note()->length()), true);
@ -201,10 +200,8 @@ EditNoteDialog::done (int r)
} }
} }
std::shared_ptr<ARDOUR::Region> region (_region_view->region ());
/* convert current clock time into an offset from the start of the source */ /* convert current clock time into an offset from the start of the source */
timecnt_t const time_clock_source_relative = region->source_position ().distance (_time_clock.last_when ()); timecnt_t const time_clock_source_relative = _region_view->current_slice().source_position ().distance (_time_clock.last_when ());
/* convert that into a position in Beats - this will be the new note time (as an offset inside the source) */ /* convert that into a position in Beats - this will be the new note time (as an offset inside the source) */
Beats const new_note_time_source_relative_beats = time_clock_source_relative.beats (); Beats const new_note_time_source_relative_beats = time_clock_source_relative.beats ();

View File

@ -22,18 +22,18 @@
#include "ardour_dialog.h" #include "ardour_dialog.h"
#include "audio_clock.h" #include "audio_clock.h"
class MidiRegionView; class MidiView;
class NoteBase; class NoteBase;
class EditNoteDialog : public ArdourDialog class EditNoteDialog : public ArdourDialog
{ {
public: public:
EditNoteDialog (MidiRegionView* rv, std::set<NoteBase*> n); EditNoteDialog (MidiView* rv, std::set<NoteBase*> n);
void done (int); void done (int);
private: private:
MidiRegionView* _region_view; MidiView* _region_view;
std::set<NoteBase*> _events; std::set<NoteBase*> _events;
Gtk::SpinButton _channel; Gtk::SpinButton _channel;
Gtk::CheckButton _channel_all; Gtk::CheckButton _channel_all;

View File

@ -137,6 +137,7 @@
#include "marker.h" #include "marker.h"
#include "midi_region_view.h" #include "midi_region_view.h"
#include "midi_time_axis.h" #include "midi_time_axis.h"
#include "midi_view.h"
#include "mixer_strip.h" #include "mixer_strip.h"
#include "mixer_ui.h" #include "mixer_ui.h"
#include "mouse_cursors.h" #include "mouse_cursors.h"
@ -6281,7 +6282,7 @@ Editor::popup_note_context_menu (ArdourCanvas::Item* item, GdkEvent* event)
popping up the menu will cause a region leave event which clears popping up the menu will cause a region leave event which clears
entered_regionview. */ entered_regionview. */
MidiRegionView& mrv = note->region_view(); MidiView& mrv = note->region_view();
const RegionSelection rs = get_regions_from_selection_and_entered (); const RegionSelection rs = get_regions_from_selection_and_entered ();
const uint32_t sel_size = mrv.selection_size (); const uint32_t sel_size = mrv.selection_size ();
@ -6290,7 +6291,7 @@ Editor::popup_note_context_menu (ArdourCanvas::Item* item, GdkEvent* event)
if (sel_size > 0) { if (sel_size > 0) {
items.push_back(MenuElem(_("Delete"), items.push_back(MenuElem(_("Delete"),
sigc::mem_fun(mrv, &MidiRegionView::delete_selection))); sigc::mem_fun(mrv, &MidiView::delete_selection)));
} }
items.push_back(MenuElem(_("Edit..."), items.push_back(MenuElem(_("Edit..."),
@ -6508,7 +6509,7 @@ Editor::track_dragging() const
} }
void void
Editor::snap_to_internal (timepos_t& start, Temporal::RoundMode direction, SnapPref pref, bool ensure_snap) Editor::snap_to_internal (timepos_t& start, Temporal::RoundMode direction, SnapPref pref, bool ensure_snap) const
{ {
UIConfiguration const& uic (UIConfiguration::instance ()); UIConfiguration const& uic (UIConfiguration::instance ());
const timepos_t presnap = start; const timepos_t presnap = start;
@ -6545,8 +6546,8 @@ Editor::snap_to_internal (timepos_t& start, Temporal::RoundMode direction, SnapP
if (!region_boundary_cache.empty ()) { if (!region_boundary_cache.empty ()) {
vector<timepos_t>::iterator prev = region_boundary_cache.begin (); auto prev = region_boundary_cache.begin ();
vector<timepos_t>::iterator next = std::upper_bound (region_boundary_cache.begin (), region_boundary_cache.end (), presnap); auto next = std::upper_bound (region_boundary_cache.begin (), region_boundary_cache.end (), presnap);
if (next != region_boundary_cache.begin ()) { if (next != region_boundary_cache.begin ()) {
prev = next; prev = next;
prev--; prev--;

View File

@ -130,6 +130,7 @@ class EditorSummary;
class GUIObjectState; class GUIObjectState;
class ArdourMarker; class ArdourMarker;
class MidiRegionView; class MidiRegionView;
class MidiView;
class MidiExportDialog; class MidiExportDialog;
class MixerStrip; class MixerStrip;
class MouseCursors; class MouseCursors;
@ -1726,7 +1727,7 @@ private:
void edit_meter_marker (MeterMarker&); void edit_meter_marker (MeterMarker&);
void edit_bbt_marker (BBTMarker&); void edit_bbt_marker (BBTMarker&);
void edit_control_point (ArdourCanvas::Item*); void edit_control_point (ArdourCanvas::Item*);
void edit_notes (MidiRegionView*); void edit_notes (MidiView*);
void edit_region (RegionView*); void edit_region (RegionView*);
void edit_current_meter (); void edit_current_meter ();

View File

@ -72,6 +72,7 @@
#include "midi_region_view.h" #include "midi_region_view.h"
#include "midi_selection.h" #include "midi_selection.h"
#include "midi_time_axis.h" #include "midi_time_axis.h"
#include "midi_view.h"
#include "mouse_cursors.h" #include "mouse_cursors.h"
#include "note_base.h" #include "note_base.h"
#include "patch_change.h" #include "patch_change.h"
@ -2384,12 +2385,14 @@ NoteResizeDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*ignored*/)
Drag::start_grab (event, cursor); Drag::start_grab (event, cursor);
#warning paul fix me MRV/MV
#if 0
region = &cnote->region_view (); region = &cnote->region_view ();
double temp; double temp;
temp = region->snap_to_pixel (cnote->x0 (), true); temp = region->snap_to_pixel (cnote->x0 (), true);
_snap_delta = temp - cnote->x0 (); _snap_delta = temp - cnote->x0 ();
#endif
_item->grab (); _item->grab ();
if (event->motion.state & ArdourKeyboard::note_size_relative_modifier ()) { if (event->motion.state & ArdourKeyboard::note_size_relative_modifier ()) {
@ -6157,13 +6160,13 @@ NoteDrag::NoteDrag (EditingContext& ec, ArdourCanvas::Item* i)
_primary = reinterpret_cast<NoteBase*> (_item->get_data ("notebase")); _primary = reinterpret_cast<NoteBase*> (_item->get_data ("notebase"));
assert (_primary); assert (_primary);
_region = &_primary->region_view (); _region = &_primary->region_view ();
_note_height = _region->midi_stream_view ()->note_height (); _note_height = _region->midi_context().note_height ();
} }
void void
NoteDrag::setup_pointer_offset () NoteDrag::setup_pointer_offset ()
{ {
_pointer_offset = _region->region ()->source_beats_to_absolute_time (_primary->note ()->time ()).distance (raw_grab_time ()); _pointer_offset = _region->current_slice().source_beats_to_absolute_time (_primary->note ()->time ()).distance (raw_grab_time ());
} }
void void
@ -6177,7 +6180,7 @@ NoteDrag::start_grab (GdkEvent* event, Gdk::Cursor*)
_copy = false; _copy = false;
} }
setup_snap_delta (_region->region ()->source_beats_to_absolute_time (_primary->note ()->time ())); setup_snap_delta (_region->current_slice().source_beats_to_absolute_time (_primary->note ()->time ()));
if (!(_was_selected = _primary->selected ())) { if (!(_was_selected = _primary->selected ())) {
/* tertiary-click means extend selection - we'll do that on button release, /* tertiary-click means extend selection - we'll do that on button release,
@ -6216,7 +6219,7 @@ NoteDrag::total_dx (GdkEvent* event) const
timecnt_t dx = t2.distance (t1); timecnt_t dx = t2.distance (t1);
/* primary note time in quarter notes */ /* primary note time in quarter notes */
timepos_t const n_qn = _region->region ()->source_beats_to_absolute_time (_primary->note ()->time ()); timepos_t const n_qn = _region->current_slice().source_beats_to_absolute_time (_primary->note ()->time ());
/* prevent (n_qn + dx) from becoming negative */ /* prevent (n_qn + dx) from becoming negative */
if (-dx.distance() > timecnt_t(n_qn).distance ()) { if (-dx.distance() > timecnt_t(n_qn).distance ()) {
@ -6241,8 +6244,8 @@ NoteDrag::total_dx (GdkEvent* event) const
timecnt_t ret (snap.earlier (n_qn).earlier (snap_delta (event->button.state)), n_qn); timecnt_t ret (snap.earlier (n_qn).earlier (snap_delta (event->button.state)), n_qn);
/* prevent the earliest note being dragged earlier than the region's start position */ /* prevent the earliest note being dragged earlier than the region's start position */
if (_earliest + ret < _region->region ()->start ()) { if (_earliest + ret < _region->current_slice().start ()) {
ret -= (ret + _earliest) - _region->region ()->start (); ret -= (ret + _earliest) - _region->current_slice().start ();
} }
return ret; return ret;
@ -6256,13 +6259,13 @@ NoteDrag::total_dy () const
return 0; return 0;
} }
double const y = _region->midi_view ()->y_position (); double const y = _region->midi_context().y_position ();
/* new current note */ /* new current note */
uint8_t n = _region->y_to_note (current_pointer_y () - y); uint8_t n = _region->y_to_note (current_pointer_y () - y);
/* clamp */ /* clamp */
MidiStreamView* msv = _region->midi_stream_view (); MidiViewBackground& mvb = _region->midi_context ();
n = max (msv->lowest_note (), n); n = max (mvb.lowest_note (), n);
n = min (msv->highest_note (), n); n = min (mvb.highest_note (), n);
/* and work out delta */ /* and work out delta */
return n - _region->y_to_note (grab_y () - y); return n - _region->y_to_note (grab_y () - y);
} }
@ -6308,7 +6311,7 @@ NoteDrag::motion (GdkEvent* event, bool first_move)
_region->show_verbose_cursor_for_new_note_value (_primary->note (), new_note); _region->show_verbose_cursor_for_new_note_value (_primary->note (), new_note);
editing_context.set_snapped_cursor_position (_region->region ()->region_beats_to_absolute_time (_primary->note ()->time ()) + dx_qn); editing_context.set_snapped_cursor_position (_region->current_slice().region_beats_to_absolute_time (_primary->note ()->time ()) + dx_qn);
} }
} }
@ -6675,21 +6678,21 @@ DraggingView::DraggingView (RegionView* v, RegionDrag* parent, TimeAxisView* ita
initial_end = v->region ()->position () + v->region ()->length (); initial_end = v->region ()->position () + v->region ()->length ();
} }
PatchChangeDrag::PatchChangeDrag (EditingContext& ec, PatchChange* i, MidiRegionView* r) PatchChangeDrag::PatchChangeDrag (EditingContext& ec, PatchChange* i, MidiView* r)
: Drag (ec, i->canvas_item (), Temporal::BeatTime, true, false) : Drag (ec, i->canvas_item (), Temporal::BeatTime, true, false)
, _region_view (r) , _region_view (r)
, _patch_change (i) , _patch_change (i)
, _cumulative_dx (0) , _cumulative_dx (0)
{ {
DEBUG_TRACE (DEBUG::Drags, string_compose ("New PatchChangeDrag, patch @ %1, grab @ %2\n", DEBUG_TRACE (DEBUG::Drags, string_compose ("New PatchChangeDrag, patch @ %1, grab @ %2\n",
_region_view->region ()->source_beats_to_absolute_time (_patch_change->patch ()->time ()), _region_view->current_slice().source_beats_to_absolute_time (_patch_change->patch ()->time ()),
grab_time ())); grab_time ()));
} }
void void
PatchChangeDrag::motion (GdkEvent* ev, bool) PatchChangeDrag::motion (GdkEvent* ev, bool)
{ {
std::shared_ptr<Region> r = _region_view->region (); std::shared_ptr<Region> r = _region_view->midi_region ();
timepos_t f = adjusted_current_time (ev); timepos_t f = adjusted_current_time (ev);
f = max (f, r->position ()); f = max (f, r->position ());
@ -6713,13 +6716,13 @@ PatchChangeDrag::finished (GdkEvent* ev, bool movement_occurred)
return; return;
} }
std::shared_ptr<Region> r (_region_view->region ()); std::shared_ptr<Region> r (_region_view->midi_region ());
timepos_t f = adjusted_current_time (ev); timepos_t f = adjusted_current_time (ev);
f = max (f, r->position ()); f = max (f, r->position ());
f = min (f, r->nt_last ()); f = min (f, r->nt_last ());
_region_view->move_patch_change (*_patch_change, _region_view->region ()->absolute_time_to_source_beats (f)); _region_view->move_patch_change (*_patch_change, r->absolute_time_to_source_beats (f));
} }
void void
@ -6731,8 +6734,7 @@ PatchChangeDrag::aborted (bool)
void void
PatchChangeDrag::setup_pointer_offset () PatchChangeDrag::setup_pointer_offset ()
{ {
std::shared_ptr<Region> region = _region_view->region (); _pointer_offset = _region_view->current_slice().source_beats_to_absolute_time (_patch_change->patch ()->time ()).distance (raw_grab_time ());
_pointer_offset = region->source_beats_to_absolute_time (_patch_change->patch ()->time ()).distance (raw_grab_time ());
} }
MidiRubberbandSelectDrag::MidiRubberbandSelectDrag (EditingContext& ec, MidiRegionView* rv) MidiRubberbandSelectDrag::MidiRubberbandSelectDrag (EditingContext& ec, MidiRegionView* rv)

View File

@ -77,6 +77,7 @@ class TimeAxisView;
class RouteTimeAxisView; class RouteTimeAxisView;
class RegionSelection; class RegionSelection;
class MidiRegionView; class MidiRegionView;
class MidiView;
class MeterMarker; class MeterMarker;
class ArdourMarker; class ArdourMarker;
class TempoMarker; class TempoMarker;
@ -643,7 +644,7 @@ private:
Temporal::timecnt_t total_dx (GdkEvent * event) const; // total movement in quarter notes Temporal::timecnt_t total_dx (GdkEvent * event) const; // total movement in quarter notes
int8_t total_dy () const; int8_t total_dy () const;
MidiRegionView* _region; MidiView* _region;
NoteBase* _primary; NoteBase* _primary;
Temporal::timecnt_t _cumulative_dx; Temporal::timecnt_t _cumulative_dx;
double _cumulative_dy; double _cumulative_dy;
@ -727,7 +728,7 @@ private:
class PatchChangeDrag : public Drag class PatchChangeDrag : public Drag
{ {
public: public:
PatchChangeDrag (EditingContext&, PatchChange *, MidiRegionView *); PatchChangeDrag (EditingContext&, PatchChange *, MidiView *);
void motion (GdkEvent *, bool); void motion (GdkEvent *, bool);
void finished (GdkEvent *, bool); void finished (GdkEvent *, bool);
@ -744,7 +745,7 @@ public:
void setup_pointer_offset (); void setup_pointer_offset ();
private: private:
MidiRegionView* _region_view; MidiView* _region_view;
PatchChange* _patch_change; PatchChange* _patch_change;
double _cumulative_dx; double _cumulative_dx;
}; };

View File

@ -65,6 +65,7 @@
#include "audio_time_axis.h" #include "audio_time_axis.h"
#include "audio_region_view.h" #include "audio_region_view.h"
#include "midi_region_view.h" #include "midi_region_view.h"
#include "midi_view.h"
#include "marker.h" #include "marker.h"
#include "streamview.h" #include "streamview.h"
#include "region_gain_line.h" #include "region_gain_line.h"
@ -2323,9 +2324,9 @@ Editor::edit_control_point (ArdourCanvas::Item* item)
} }
void void
Editor::edit_notes (MidiRegionView* mrv) Editor::edit_notes (MidiView* mrv)
{ {
MidiRegionView::Selection const & s = mrv->selection(); MidiView::Selection const & s = mrv->selection();
if (s.empty ()) { if (s.empty ()) {
return; return;

View File

@ -29,7 +29,7 @@
using namespace ARDOUR; using namespace ARDOUR;
using namespace ArdourCanvas; using namespace ArdourCanvas;
Hit::Hit (MidiRegionView& region, Item* parent, double size, const std::shared_ptr<NoteType> note, bool with_events) Hit::Hit (MidiView& region, Item* parent, double size, const std::shared_ptr<NoteType> note, bool with_events)
: NoteBase (region, with_events, note) : NoteBase (region, with_events, note)
{ {
_polygon = new ArdourCanvas::Polygon (parent); _polygon = new ArdourCanvas::Polygon (parent);

View File

@ -32,7 +32,7 @@ class Hit : public NoteBase
public: public:
typedef Evoral::Note<Temporal::Beats> NoteType; typedef Evoral::Note<Temporal::Beats> NoteType;
Hit (MidiRegionView& region, Hit (MidiView& region,
ArdourCanvas::Item* parent, ArdourCanvas::Item* parent,
double size, double size,
const std::shared_ptr<NoteType> note = std::shared_ptr<NoteType>(), const std::shared_ptr<NoteType> note = std::shared_ptr<NoteType>(),

View File

@ -168,3 +168,9 @@ MidiCueEditor::apply_midi_note_edit_op_to_region (ARDOUR::MidiOperator& op, Midi
return nullptr; return nullptr;
} }
bool
MidiCueEditor::canvas_note_event (GdkEvent* event, ArdourCanvas::Item*)
{
return false;
}

View File

@ -110,11 +110,11 @@ MidiStreamView::create_region_view (std::shared_ptr<Region> r, bool /*wfd*/, boo
if (recording) { if (recording) {
region_view = new MidiRegionView ( region_view = new MidiRegionView (
_region_group, _trackview.editor(), _trackview, region, _region_group, _trackview.editor(), _trackview, region,
_samples_per_pixel, region_color, recording, _samples_per_pixel, MidiViewBackground::region_color(), recording,
TimeAxisViewItem::Visibility(TimeAxisViewItem::ShowFrame)); TimeAxisViewItem::Visibility(TimeAxisViewItem::ShowFrame));
} else { } else {
region_view = new MidiRegionView (_region_group, _trackview.editor(), _trackview, region, region_view = new MidiRegionView (_region_group, _trackview.editor(), _trackview, region,
_samples_per_pixel, region_color); _samples_per_pixel, MidiViewBackground::region_color());
} }
region_view->init (false); region_view->init (false);
@ -494,3 +494,20 @@ MidiStreamView::get_regions_with_selected_data (RegionSelection& rs)
} }
} }
void
MidiStreamView::set_note_highlight (bool yn)
{
dynamic_cast<MidiTimeAxisView*> (&_trackview)->set_note_highlight (yn);
}
uint8_t
MidiStreamView::get_preferred_midi_channel () const
{
return dynamic_cast<MidiTimeAxisView*> (&_trackview)->get_preferred_midi_channel();
}
void
MidiStreamView::record_layer_check (std::shared_ptr<ARDOUR::Region> r, samplepos_t t)
{
check_record_layers (r, t);
}

View File

@ -85,6 +85,9 @@ public:
ArdourCanvas::Container* region_canvas () const { return _region_group; } ArdourCanvas::Container* region_canvas () const { return _region_group; }
void parameter_changed (std::string const &); void parameter_changed (std::string const &);
uint8_t get_preferred_midi_channel () const;
void record_layer_check (std::shared_ptr<ARDOUR::Region>, samplepos_t);
void set_note_highlight (bool);
protected: protected:
void setup_rec_box (); void setup_rec_box ();

File diff suppressed because it is too large Load Diff

View File

@ -29,9 +29,14 @@
#include <vector> #include <vector>
#include <stdint.h> #include <stdint.h>
#include <boost/unordered_map.hpp>
#include <sigc++/signal.h>
#include "pbd/signals.h" #include "pbd/signals.h"
#include "ardour/midi_model.h" #include "ardour/midi_model.h"
#include "ardour/slice.h"
#include "ardour/types.h" #include "ardour/types.h"
#include "editing.h" #include "editing.h"
@ -44,6 +49,7 @@
namespace ARDOUR { namespace ARDOUR {
class MidiRegion; class MidiRegion;
class MidiModel; class MidiModel;
class MidiTrack;
class Filter; class Filter;
}; };
@ -69,15 +75,16 @@ class ItemCounts;
class CursorContext; class CursorContext;
class VelocityGhostRegion; class VelocityGhostRegion;
class EditingContext; class EditingContext;
class PasteContext;
class MidiView class MidiView : public virtual sigc::trackable
{ {
public: public:
typedef Evoral::Note<Temporal::Beats> NoteType; typedef Evoral::Note<Temporal::Beats> NoteType;
typedef Evoral::Sequence<Temporal::Beats>::Notes Notes; typedef Evoral::Sequence<Temporal::Beats>::Notes Notes;
MidiView (std::shared_ptr<ARDOUR::MidiTrack> mt, MidiView (std::shared_ptr<ARDOUR::MidiTrack> mt,
ArdourCanvas::Container* parent, ArdourCanvas::Container& parent,
EditingContext& ec, EditingContext& ec,
MidiViewBackground& bg, MidiViewBackground& bg,
uint32_t basic_color); uint32_t basic_color);
@ -85,11 +92,12 @@ class MidiView
virtual ~MidiView (); virtual ~MidiView ();
void init (bool wfd); void init (bool wfd);
virtual bool display_enabled() const { return true; }
void step_add_note (uint8_t channel, uint8_t number, uint8_t velocity, void step_add_note (uint8_t channel, uint8_t number, uint8_t velocity,
Temporal::Beats pos, Temporal::Beats len); Temporal::Beats pos, Temporal::Beats len);
void step_sustain (Temporal::Beats beats); void step_sustain (Temporal::Beats beats);
void set_height (double); virtual void set_height (double);
void apply_note_range(uint8_t lowest, uint8_t highest, bool force=false); void apply_note_range(uint8_t lowest, uint8_t highest, bool force=false);
// inline ARDOUR::ColorMode color_mode() const { return _background->color_mode(); } // inline ARDOUR::ColorMode color_mode() const { return _background->color_mode(); }
@ -102,9 +110,11 @@ class MidiView
void hide_step_edit_cursor (); void hide_step_edit_cursor ();
void set_step_edit_cursor_width (Temporal::Beats beats); void set_step_edit_cursor_width (Temporal::Beats beats);
virtual GhostRegion* add_ghost (TimeAxisView&) {} virtual GhostRegion* add_ghost (TimeAxisView&) { return nullptr; }
virtual std::string get_modifier_name() const; virtual std::string get_modifier_name() const;
void set_model (std::shared_ptr<ARDOUR::MidiModel>);
NoteBase* add_note(const std::shared_ptr<NoteType> note, bool visible); NoteBase* add_note(const std::shared_ptr<NoteType> note, bool visible);
void cut_copy_clear (Editing::CutCopyOp); void cut_copy_clear (Editing::CutCopyOp);
@ -310,22 +320,25 @@ class MidiView
*/ */
void clear_selection (); void clear_selection ();
ARDOUR::InstrumentInfo& instrument_info() const;
void note_deleted (NoteBase*); void note_deleted (NoteBase*);
void clear_note_selection (); void clear_note_selection ();
void show_verbose_cursor_for_new_note_value(std::shared_ptr<NoteType> current_note, uint8_t new_note) const; void show_verbose_cursor_for_new_note_value(std::shared_ptr<NoteType> current_note, uint8_t new_note) const;
std::shared_ptr<ARDOUR::MidiRegion> midi_region() const { return _region; }
EditingContext& editing_context() const { return _editing_context; }
MidiViewBackground& midi_context() const { return _midi_context; }
virtual ARDOUR::Slice const & current_slice() const { return _current_slice; }
protected: protected:
void init ();
void region_resized (const PBD::PropertyChange&); void region_resized (const PBD::PropertyChange&);
void set_flags (XMLNode *); void set_flags (XMLNode *);
void store_flags (); void store_flags ();
void reset_width_dependent_items (double pixel_width); virtual void reset_width_dependent_items (double pixel_width);
void parameter_changed (std::string const & p);
void _redisplay (bool view_only); void _redisplay (bool view_only);
protected: protected:
@ -406,6 +419,12 @@ class MidiView
void clear_selection_internal (); void clear_selection_internal ();
void clear_events (); void clear_events ();
virtual void clear_ghost_events() {}
virtual void ghosts_model_changed() {}
virtual void ghosts_view_changed() {}
virtual void ghost_remove_note (NoteBase*) {}
virtual void ghost_add_note (NoteBase*) {}
virtual void ghost_sync_selection (NoteBase*) {}
bool canvas_group_event(GdkEvent* ev); bool canvas_group_event(GdkEvent* ev);
bool note_canvas_event(GdkEvent* ev); bool note_canvas_event(GdkEvent* ev);
@ -443,9 +462,11 @@ class MidiView
typedef std::vector<NoteBase*> CopyDragEvents; typedef std::vector<NoteBase*> CopyDragEvents;
std::shared_ptr<ARDOUR::MidiTrack> _midi_track; std::shared_ptr<ARDOUR::MidiTrack> _midi_track;
EditingContext& editing_context; EditingContext& _editing_context;
MidiViewBackground& _midi_context;
std::shared_ptr<ARDOUR::MidiModel> _model; std::shared_ptr<ARDOUR::MidiModel> _model;
MidiViewBackground& _background; std::shared_ptr<ARDOUR::MidiRegion> _region;
ARDOUR::Slice _current_slice;
Events _events; Events _events;
CopyDragEvents _copy_drag_events; CopyDragEvents _copy_drag_events;
PatchChanges _patch_changes; PatchChanges _patch_changes;
@ -461,6 +482,9 @@ class MidiView
Temporal::Beats _step_edit_cursor_position; Temporal::Beats _step_edit_cursor_position;
NoteBase* _channel_selection_scoped_note; NoteBase* _channel_selection_scoped_note;
uint8_t _current_range_min;
uint8_t _current_range_max;
MouseState _mouse_state; MouseState _mouse_state;
int _pressed_button; int _pressed_button;
@ -508,14 +532,14 @@ class MidiView
void snap_changed (); void snap_changed ();
PBD::ScopedConnection snap_changed_connection; PBD::ScopedConnection snap_changed_connection;
bool motion (GdkEventMotion*); virtual bool motion (GdkEventMotion*);
bool scroll (GdkEventScroll*); virtual bool scroll (GdkEventScroll*);
bool key_press (GdkEventKey*); virtual bool key_press (GdkEventKey*);
bool key_release (GdkEventKey*); virtual bool key_release (GdkEventKey*);
bool button_press (GdkEventButton*); virtual bool button_press (GdkEventButton*);
bool button_release (GdkEventButton*); virtual bool button_release (GdkEventButton*);
bool enter_notify (GdkEventCrossing*); virtual bool enter_notify (GdkEventCrossing*);
bool leave_notify (GdkEventCrossing*); virtual bool leave_notify (GdkEventCrossing*);
void drop_down_keys (); void drop_down_keys ();
void maybe_select_by_position (GdkEventButton* ev, double x, double y); void maybe_select_by_position (GdkEventButton* ev, double x, double y);
@ -533,8 +557,8 @@ class MidiView
void remove_ghost_note (); void remove_ghost_note ();
void mouse_mode_changed (); void mouse_mode_changed ();
void enter_internal (uint32_t state); virtual void enter_internal (uint32_t state);
void leave_internal (); virtual void leave_internal ();
void hide_verbose_cursor (); void hide_verbose_cursor ();
samplecnt_t _last_display_zoom; samplecnt_t _last_display_zoom;
@ -557,7 +581,9 @@ class MidiView
ARDOUR::ChannelMode get_channel_mode() const; ARDOUR::ChannelMode get_channel_mode() const;
uint16_t get_selected_channels () const; uint16_t get_selected_channels () const;
inline double contents_height() const { return _height - 2; } virtual double height() const = 0;
virtual double contents_height() const { return height() - 2; }
inline double contents_note_range () const { return (double)(_current_range_max - _current_range_min + 1); } inline double contents_note_range () const { return (double)(_current_range_max - _current_range_min + 1); }
inline double note_height() const { return contents_height() / contents_note_range(); } inline double note_height() const { return contents_height() / contents_note_range(); }

View File

@ -40,6 +40,8 @@ MidiViewBackground::MidiViewBackground (ArdourCanvas::Item* parent)
, _data_note_min (60) , _data_note_min (60)
, _data_note_max (71) , _data_note_max (71)
, _note_lines (new ArdourCanvas::LineSet (parent, ArdourCanvas::LineSet::Horizontal)) , _note_lines (new ArdourCanvas::LineSet (parent, ArdourCanvas::LineSet::Horizontal))
, _note_mode (ARDOUR::Sustained)
, _color_mode (ARDOUR::MeterColors)
{ {
_note_lines->lower_to_bottom(); _note_lines->lower_to_bottom();

View File

@ -27,13 +27,13 @@
#include <gtkmm/adjustment.h> #include <gtkmm/adjustment.h>
#include "ardour/types.h"
namespace ArdourCanvas { namespace ArdourCanvas {
class Item; class Item;
class LineSet; class LineSet;
} }
class MidiViewBackground class MidiViewBackground
{ {
public: public:
@ -47,6 +47,14 @@ class MidiViewBackground
ContentsRange ContentsRange
}; };
ARDOUR::NoteMode note_mode() const { return _note_mode; }
void set_note_mode (ARDOUR::NoteMode nm);
ARDOUR::ColorMode color_mode() const { return _color_mode; }
void set_color_mode (ARDOUR::ColorMode);
Gtkmm2ext::Color region_color() const { return _region_color; }
void set_note_range (VisibleNoteRange r); void set_note_range (VisibleNoteRange r);
inline uint8_t lowest_note() const { return _lowest_note; } inline uint8_t lowest_note() const { return _lowest_note; }
@ -73,6 +81,13 @@ class MidiViewBackground
sigc::signal<void> NoteRangeChanged; sigc::signal<void> NoteRangeChanged;
void apply_note_range (uint8_t lowest, uint8_t highest, bool to_children); void apply_note_range (uint8_t lowest, uint8_t highest, bool to_children);
/** @return y position, or -1 if hidden */
virtual double y_position () const { return 0.; }
virtual uint8_t get_preferred_midi_channel () const = 0;
virtual void set_note_highlight (bool) = 0;
virtual void record_layer_check (std::shared_ptr<ARDOUR::Region>, samplepos_t) = 0;
protected: protected:
bool _range_dirty; bool _range_dirty;
double _range_sum_cache; double _range_sum_cache;
@ -81,6 +96,9 @@ class MidiViewBackground
uint8_t _data_note_min; ///< in data uint8_t _data_note_min; ///< in data
uint8_t _data_note_max; ///< in data uint8_t _data_note_max; ///< in data
ArdourCanvas::LineSet* _note_lines; ArdourCanvas::LineSet* _note_lines;
ARDOUR::NoteMode _note_mode;
Gtkmm2ext::Color _region_color;
ARDOUR::ColorMode _color_mode;
void color_handler (); void color_handler ();
void parameter_changed (std::string const &); void parameter_changed (std::string const &);

View File

@ -29,8 +29,7 @@ using namespace ARDOUR;
using ArdourCanvas::Coord; using ArdourCanvas::Coord;
using ArdourCanvas::Duple; using ArdourCanvas::Duple;
Note::Note ( Note::Note (MidiView& region, ArdourCanvas::Item* parent, const std::shared_ptr<NoteType> note, bool with_events)
MidiRegionView& region, ArdourCanvas::Item* parent, const std::shared_ptr<NoteType> note, bool with_events)
: NoteBase (region, with_events, note) : NoteBase (region, with_events, note)
, _visual_note (new ArdourCanvas::Note (parent)) , _visual_note (new ArdourCanvas::Note (parent))
{ {

View File

@ -33,7 +33,7 @@ class Note : public NoteBase
public: public:
typedef Evoral::Note<Temporal::Beats> NoteType; typedef Evoral::Note<Temporal::Beats> NoteType;
Note (MidiRegionView& region, Note (MidiView& region,
ArdourCanvas::Item* parent, ArdourCanvas::Item* parent,
const std::shared_ptr<NoteType> note = std::shared_ptr<NoteType>(), const std::shared_ptr<NoteType> note = std::shared_ptr<NoteType>(),
bool with_events = true); bool with_events = true);

View File

@ -28,9 +28,10 @@
#include "canvas/text.h" #include "canvas/text.h"
#include "note_base.h" #include "note_base.h"
#include "public_editor.h" #include "editing_context.h"
#include "editing_syms.h"
#include "keyboard.h" #include "keyboard.h"
#include "midi_region_view.h" #include "midi_view.h"
/* clang-format off */ /* clang-format off */
// Include last, when GRIDTYPE has been defined by editing.h via midi_region_view.h // Include last, when GRIDTYPE has been defined by editing.h via midi_region_view.h
@ -65,7 +66,7 @@ NoteBase::set_colors ()
color_modifier = UIConfiguration::instance().modifier ("midi note"); color_modifier = UIConfiguration::instance().modifier ("midi note");
} }
NoteBase::NoteBase(MidiRegionView& region, bool with_events, const std::shared_ptr<NoteType> note) NoteBase::NoteBase(MidiView& region, bool with_events, const std::shared_ptr<NoteType> note)
: _region(region) : _region(region)
, _item (0) , _item (0)
, _text(0) , _text(0)
@ -187,7 +188,7 @@ NoteBase::set_selected(bool selected)
uint32_t uint32_t
NoteBase::base_color () NoteBase::base_color ()
{ {
return base_color (_note->velocity(), _region.color_mode(), _region.midi_stream_view()->get_region_color(), _note->channel(), selected()); return base_color (_note->velocity(), _region.midi_context().color_mode(), _region.midi_context().region_color(), _note->channel(), selected());
} }
uint32_t uint32_t
@ -292,7 +293,7 @@ NoteBase::set_mouse_fractions (GdkEvent* ev)
bool bool
NoteBase::event_handler (GdkEvent* ev) NoteBase::event_handler (GdkEvent* ev)
{ {
PublicEditor& editor = _region.get_time_axis_view().editor(); EditingContext& editor = _region.editing_context();
if (!editor.internal_editing()) { if (!editor.internal_editing()) {
return false; return false;
} }

View File

@ -33,7 +33,7 @@
#include "ui_config.h" #include "ui_config.h"
class Editor; class Editor;
class MidiRegionView; class MidiView;
namespace Evoral { namespace Evoral {
template<typename T> class Note; template<typename T> class Note;
@ -67,7 +67,7 @@ class NoteBase : public sigc::trackable
public: public:
typedef Evoral::Note<Temporal::Beats> NoteType; typedef Evoral::Note<Temporal::Beats> NoteType;
NoteBase (MidiRegionView& region, bool, const std::shared_ptr<NoteType> note = std::shared_ptr<NoteType>()); NoteBase (MidiView& region, bool, const std::shared_ptr<NoteType> note = std::shared_ptr<NoteType>());
virtual ~NoteBase (); virtual ~NoteBase ();
void set_item (ArdourCanvas::Item *); void set_item (ArdourCanvas::Item *);
@ -115,7 +115,7 @@ class NoteBase : public sigc::trackable
float mouse_y_fraction() const { return _mouse_y_fraction; } float mouse_y_fraction() const { return _mouse_y_fraction; }
const std::shared_ptr<NoteType> note() const { return _note; } const std::shared_ptr<NoteType> note() const { return _note; }
MidiRegionView& region_view() const { return _region; } MidiView& region_view() const { return _region; }
static void set_colors (); static void set_colors ();
@ -139,7 +139,7 @@ class NoteBase : public sigc::trackable
protected: protected:
enum State { None, Pressed, Dragging }; enum State { None, Pressed, Dragging };
MidiRegionView& _region; MidiView& _region;
ArdourCanvas::Item* _item; ArdourCanvas::Item* _item;
ArdourCanvas::Text* _text; ArdourCanvas::Text* _text;
State _state; State _state;

View File

@ -34,7 +34,7 @@
#include "editor.h" #include "editor.h"
#include "editor_drag.h" #include "editor_drag.h"
#include "midi_region_view.h" #include "midi_view.h"
#include "patch_change.h" #include "patch_change.h"
#include "ui_config.h" #include "ui_config.h"
@ -44,8 +44,8 @@ using Gtkmm2ext::Keyboard;
/** @param x x position in pixels. /** @param x x position in pixels.
*/ */
PatchChange::PatchChange (MidiRegionView& region, PatchChange::PatchChange (MidiView& region,
ArdourCanvas::Container* parent, ArdourCanvas::Item* parent,
double height, double height,
double x, double x,
double y, double y,
@ -153,15 +153,15 @@ bool
PatchChange::event_handler (GdkEvent* ev) PatchChange::event_handler (GdkEvent* ev)
{ {
/* XXX: icky dcast */ /* XXX: icky dcast */
Editor* e = dynamic_cast<Editor*> (&_region.get_time_axis_view ().editor ()); EditingContext& e = _region.editing_context();
if (!e->internal_editing ()) { if (!e.internal_editing ()) {
return false; return false;
} }
switch (ev->type) { switch (ev->type) {
case GDK_BUTTON_PRESS: case GDK_BUTTON_PRESS:
if (e->current_mouse_mode () == Editing::MouseContent) { if (e.current_mouse_mode () == Editing::MouseContent) {
if (Gtkmm2ext::Keyboard::is_delete_event (&ev->button)) { if (Gtkmm2ext::Keyboard::is_delete_event (&ev->button)) {
_region.delete_patch_change (this); _region.delete_patch_change (this);
return true; return true;
@ -171,7 +171,7 @@ PatchChange::event_handler (GdkEvent* ev)
return true; return true;
} else if (ev->button.button == 1) { } else if (ev->button.button == 1) {
e->drags ()->set (new PatchChangeDrag (*e, this, &_region), ev); e.drags ()->set (new PatchChangeDrag (e, this, &_region), ev);
return true; return true;
} }
} }

View File

@ -34,8 +34,8 @@ namespace MIDI {
class PatchChange class PatchChange
{ {
public: public:
PatchChange (MidiRegionView& region, PatchChange (MidiView& region,
ArdourCanvas::Container* parent, ArdourCanvas::Item* parent,
double height, double height,
double x, double x,
double y, double y,
@ -65,7 +65,7 @@ public:
private: private:
bool event_handler (GdkEvent*); bool event_handler (GdkEvent*);
MidiRegionView& _region; MidiView& _region;
ARDOUR::InstrumentInfo& _info; ARDOUR::InstrumentInfo& _info;
ARDOUR::MidiModel::PatchChangePtr _patch; ARDOUR::MidiModel::PatchChangePtr _patch;
Gtk::Menu _popup; Gtk::Menu _popup;

View File

@ -96,6 +96,7 @@ class MeterMarker;
class MixerStrip; class MixerStrip;
class MouseCursors; class MouseCursors;
class RegionView; class RegionView;
class MidiView;
class RouteTimeAxisView; class RouteTimeAxisView;
class Selection; class Selection;
class SimpleExport; class SimpleExport;
@ -329,7 +330,7 @@ public:
virtual void add_to_idle_resize (TimeAxisView*, int32_t) = 0; virtual void add_to_idle_resize (TimeAxisView*, int32_t) = 0;
virtual Temporal::timecnt_t get_paste_offset (Temporal::timepos_t const & pos, unsigned paste_count, Temporal::timecnt_t const & duration) = 0; virtual Temporal::timecnt_t get_paste_offset (Temporal::timepos_t const & pos, unsigned paste_count, Temporal::timecnt_t const & duration) = 0;
virtual void edit_notes (MidiRegionView*) = 0; virtual void edit_notes (MidiView*) = 0;
virtual void queue_visual_videotimeline_update () = 0; virtual void queue_visual_videotimeline_update () = 0;
virtual void set_close_video_sensitive (bool) = 0; virtual void set_close_video_sensitive (bool) = 0;
@ -405,8 +406,6 @@ public:
virtual bool canvas_bbt_marker_event (GdkEvent* event, ArdourCanvas::Item*, BBTMarker*) = 0; virtual bool canvas_bbt_marker_event (GdkEvent* event, ArdourCanvas::Item*, BBTMarker*) = 0;
virtual bool canvas_automation_track_event(GdkEvent* event, ArdourCanvas::Item*, AutomationTimeAxisView*) = 0; virtual bool canvas_automation_track_event(GdkEvent* event, ArdourCanvas::Item*, AutomationTimeAxisView*) = 0;
virtual bool canvas_note_event (GdkEvent* event, ArdourCanvas::Item*) = 0;
static const int window_border_width; static const int window_border_width;
static const int container_border_width; static const int container_border_width;
static const int vertical_spacing; static const int vertical_spacing;