more work on fixing pianorule recomposition of objects
This commit is contained in:
parent
3bd2d39d51
commit
549defc068
@ -70,6 +70,11 @@ AudioStreamView::AudioStreamView (AudioTimeAxisView& tv)
|
||||
color_handler ();
|
||||
}
|
||||
|
||||
AudioStreamView::~AudioStreamView ()
|
||||
{
|
||||
undisplay_track ();
|
||||
}
|
||||
|
||||
int
|
||||
AudioStreamView::set_amplitude_above_axis (gdouble app)
|
||||
{
|
||||
|
@ -55,6 +55,7 @@ class AudioStreamView : public StreamView
|
||||
{
|
||||
public:
|
||||
AudioStreamView (AudioTimeAxisView&);
|
||||
~AudioStreamView ();
|
||||
|
||||
int set_amplitude_above_axis (gdouble app);
|
||||
gdouble get_amplitude_above_axis () { return _amplitude_above_axis; }
|
||||
|
@ -148,6 +148,8 @@ AudioTimeAxisView::set_route (std::shared_ptr<Route> rt)
|
||||
|
||||
AudioTimeAxisView::~AudioTimeAxisView ()
|
||||
{
|
||||
delete _view;
|
||||
_view = nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -35,6 +35,7 @@ using namespace Temporal;
|
||||
MidiCueEditor::MidiCueEditor()
|
||||
: vertical_adjustment (0.0, 0.0, 10.0, 400.0)
|
||||
, horizontal_adjustment (0.0, 0.0, 1e16)
|
||||
, view (nullptr)
|
||||
{
|
||||
build_canvas ();
|
||||
|
||||
@ -193,8 +194,8 @@ MidiCueEditor::viewport()
|
||||
void
|
||||
MidiCueEditor::set_region (std::shared_ptr<ARDOUR::MidiTrack> t, std::shared_ptr<ARDOUR::MidiRegion> r)
|
||||
{
|
||||
// delete view;
|
||||
// view = nullptr;
|
||||
delete view;
|
||||
view = nullptr;
|
||||
|
||||
if (!t || !r) {
|
||||
return;
|
||||
|
@ -641,22 +641,7 @@ MidiRegionView::ghosts_view_changed ()
|
||||
MidiRegionView::~MidiRegionView ()
|
||||
{
|
||||
in_destructor = true;
|
||||
|
||||
hide_verbose_cursor ();
|
||||
|
||||
delete _list_editor;
|
||||
|
||||
RegionViewGoingAway (this); /* EMIT_SIGNAL */
|
||||
|
||||
if (_active_notes) {
|
||||
end_write();
|
||||
}
|
||||
_entered_note = 0;
|
||||
clear_events ();
|
||||
|
||||
delete _note_group;
|
||||
delete _note_diff_command;
|
||||
delete _step_edit_cursor;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -89,6 +89,7 @@ MidiStreamView::MidiStreamView (MidiTimeAxisView& tv)
|
||||
|
||||
MidiStreamView::~MidiStreamView ()
|
||||
{
|
||||
undisplay_track ();
|
||||
}
|
||||
|
||||
void
|
||||
@ -159,7 +160,7 @@ MidiStreamView::add_region_view_internal (std::shared_ptr<Region> r, bool wait_f
|
||||
/* fit note range if we are importing */
|
||||
if (_trackview.session()->operation_in_progress (Operations::insert_file)) {
|
||||
/* this will call display_region() */
|
||||
set_note_range (ContentsRange);
|
||||
set_note_visibility_range_style (ContentsRange);
|
||||
}
|
||||
}
|
||||
|
||||
@ -518,3 +519,9 @@ MidiStreamView::record_layer_check (std::shared_ptr<ARDOUR::Region> r, samplepos
|
||||
{
|
||||
check_record_layers (r, t);
|
||||
}
|
||||
|
||||
double
|
||||
MidiStreamView::y_position () const
|
||||
{
|
||||
return _trackview.y_position();
|
||||
}
|
||||
|
@ -75,6 +75,8 @@ public:
|
||||
return (child_height() - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 2);
|
||||
}
|
||||
|
||||
double y_position () const;
|
||||
|
||||
RegionView* create_region_view (std::shared_ptr<ARDOUR::Region>, bool, bool);
|
||||
|
||||
bool paste (Temporal::timepos_t const & pos, const Selection& selection, PasteContext& ctx);
|
||||
|
@ -122,18 +122,18 @@ MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session* sess, ArdourCanva
|
||||
, RouteTimeAxisView (ed, sess, canvas)
|
||||
, _ignore_signals(false)
|
||||
, _asked_all_automation(false)
|
||||
, _piano_roll_header(0)
|
||||
, _piano_roll_header(nullptr)
|
||||
, _note_mode(Sustained)
|
||||
, _note_mode_item(0)
|
||||
, _percussion_mode_item(0)
|
||||
, _percussion_mode_item(nullptr)
|
||||
, _color_mode(MeterColors)
|
||||
, _meter_color_mode_item(0)
|
||||
, _channel_color_mode_item(0)
|
||||
, _meter_color_mode_item(nullptr)
|
||||
, _channel_color_mode_item(nullptr)
|
||||
, _track_color_mode_item(0)
|
||||
, _channel_selector (0)
|
||||
, _step_edit_item (0)
|
||||
, controller_menu (0)
|
||||
, _step_editor (0)
|
||||
, _channel_selector (nullptr)
|
||||
, _step_edit_item (nullptr)
|
||||
, controller_menu (nullptr)
|
||||
, _step_editor (nullptr)
|
||||
, velocity_menu_item (nullptr)
|
||||
{
|
||||
_midnam_model_selector.disable_scrolling();
|
||||
@ -164,7 +164,9 @@ MidiTimeAxisView::parameter_changed (string const & param)
|
||||
void
|
||||
MidiTimeAxisView::set_note_highlight (uint8_t note)
|
||||
{
|
||||
_piano_roll_header->set_note_highlight (note);
|
||||
if (_piano_roll_header) {
|
||||
_piano_roll_header->set_note_highlight (note);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -358,13 +360,20 @@ MidiTimeAxisView::first_idle ()
|
||||
|
||||
MidiTimeAxisView::~MidiTimeAxisView ()
|
||||
{
|
||||
delete _view;
|
||||
_view = nullptr;
|
||||
|
||||
delete _channel_selector;
|
||||
_channel_selector = nullptr;
|
||||
|
||||
delete _piano_roll_header;
|
||||
_piano_roll_header = 0;
|
||||
_piano_roll_header = nullptr;
|
||||
|
||||
delete controller_menu;
|
||||
controller_menu = nullptr;
|
||||
|
||||
delete _step_editor;
|
||||
_step_editor = nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
@ -1324,7 +1333,7 @@ MidiTimeAxisView::set_note_range (MidiStreamView::VisibleNoteRange range, bool a
|
||||
boost::bind (&MidiTimeAxisView::set_note_range, _1, range, false));
|
||||
} else {
|
||||
if (!_ignore_signals) {
|
||||
midi_view()->set_note_range(range);
|
||||
midi_view()->set_note_visibility_range_style (range);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -577,26 +577,26 @@ MidiView::scroll (GdkEventScroll* ev)
|
||||
case GDK_SCROLL_UP:
|
||||
if (just_one_edge) {
|
||||
/* make higher notes visible aka expand higher pitch range */
|
||||
apply_note_range (_midi_context.lowest_note(), min (127, _midi_context.highest_note() + step), true);
|
||||
set_note_range (_midi_context.lowest_note(), min (127, _midi_context.highest_note() + step));
|
||||
} else if (zoom) {
|
||||
/* zoom out to show more higher and lower pitches */
|
||||
apply_note_range (max (0, _midi_context.lowest_note() - step), min (127, _midi_context.highest_note() + step), true);
|
||||
set_note_range (max (0, _midi_context.lowest_note() - step), min (127, _midi_context.highest_note() + step));
|
||||
} else {
|
||||
/* scroll towards higher pitches */
|
||||
apply_note_range (max (0, _midi_context.lowest_note() + step), min (127, _midi_context.highest_note() + step), true);
|
||||
set_note_range (max (0, _midi_context.lowest_note() + step), min (127, _midi_context.highest_note() + step));
|
||||
}
|
||||
return true;
|
||||
|
||||
case GDK_SCROLL_DOWN:
|
||||
if (just_one_edge) {
|
||||
/* make lower notes visible aka expand lower pitch range */
|
||||
apply_note_range (max (0, _midi_context.lowest_note() - step), _midi_context.highest_note(), true);
|
||||
set_note_range (max (0, _midi_context.lowest_note() - step), _midi_context.highest_note());
|
||||
} else if (zoom) {
|
||||
/* zoom in to show less higher and lower pitches */
|
||||
apply_note_range (min (127, _midi_context.lowest_note() + step), max (0, _midi_context.highest_note() - step), true);
|
||||
set_note_range (min (127, _midi_context.lowest_note() + step), max (0, _midi_context.highest_note() - step));
|
||||
} else {
|
||||
/* scroll towards lower pitches */
|
||||
apply_note_range (min (127, _midi_context.lowest_note() - step), max (0, _midi_context.highest_note() - step), true);
|
||||
set_note_range (min (127, _midi_context.lowest_note() - step), max (0, _midi_context.highest_note() - step));
|
||||
}
|
||||
return true;
|
||||
|
||||
@ -768,7 +768,7 @@ MidiView::create_note_at (timepos_t const & t, double y, Temporal::Beats length,
|
||||
return;
|
||||
}
|
||||
|
||||
_midi_context.update_note_range(new_note->note());
|
||||
_midi_context.maybe_extend_note_range (new_note->note());
|
||||
|
||||
start_note_diff_command(_("add note"));
|
||||
note_diff_add_note (new_note, true, false);
|
||||
@ -790,7 +790,6 @@ MidiView::clear_events ()
|
||||
|
||||
clear_ghost_events ();
|
||||
|
||||
|
||||
_note_group->clear (true);
|
||||
_events.clear();
|
||||
_patch_changes.clear();
|
||||
@ -1043,22 +1042,23 @@ MidiView::model_changed()
|
||||
|
||||
NoteBase* cne;
|
||||
|
||||
std::cerr << "drawing " << notes.size() << " notes\n";
|
||||
if (_midi_context.visibility_range_style() == MidiViewBackground::ContentsRange) {
|
||||
|
||||
uint8_t low_note = std::numeric_limits<uint8_t>::max();
|
||||
uint8_t hi_note = std::numeric_limits<uint8_t>::min();
|
||||
uint8_t low_note = std::numeric_limits<uint8_t>::max();
|
||||
uint8_t hi_note = std::numeric_limits<uint8_t>::min();
|
||||
|
||||
for (MidiModel::Notes::iterator n = notes.begin(); n != notes.end(); ++n) {
|
||||
if ((*n)->note() < low_note) {
|
||||
low_note = (*n)->note();
|
||||
}
|
||||
if ((*n)->note() > hi_note) {
|
||||
hi_note = (*n)->note();
|
||||
for (MidiModel::Notes::iterator n = notes.begin(); n != notes.end(); ++n) {
|
||||
if ((*n)->note() < low_note) {
|
||||
low_note = (*n)->note();
|
||||
}
|
||||
if ((*n)->note() > hi_note) {
|
||||
hi_note = (*n)->note();
|
||||
}
|
||||
}
|
||||
|
||||
set_note_range (low_note, hi_note);
|
||||
}
|
||||
|
||||
_midi_context.apply_note_range (low_note, hi_note, true);
|
||||
|
||||
for (MidiModel::Notes::iterator n = notes.begin(); n != notes.end(); ++n) {
|
||||
|
||||
std::shared_ptr<NoteType> note (*n);
|
||||
@ -1437,11 +1437,9 @@ MidiView::reset_width_dependent_items (double pixel_width)
|
||||
void
|
||||
MidiView::set_height (double ht)
|
||||
{
|
||||
double old_height = height();
|
||||
|
||||
apply_note_range (_midi_context.lowest_note(),
|
||||
_midi_context.highest_note(),
|
||||
ht != old_height);
|
||||
if (ht != height()) {
|
||||
view_changed ();
|
||||
}
|
||||
|
||||
for (PatchChanges::iterator x = _patch_changes.begin(); x != _patch_changes.end(); ++x) {
|
||||
(*x).second->set_height (_midi_context.contents_height());
|
||||
@ -1676,7 +1674,6 @@ MidiView::update_hit (Hit* ev, bool update_ghost_regions)
|
||||
const double diamond_size = std::max(1., floor(note_height()) - 2.);
|
||||
const double y = 1.5 + floor(note_to_y(note->note())) + diamond_size * .5;
|
||||
|
||||
// see DnD note in MidiView::apply_note_range() above
|
||||
if (y <= 0 || y >= height()) {
|
||||
ev->hide();
|
||||
} else {
|
||||
@ -1750,7 +1747,7 @@ MidiView::add_note(const std::shared_ptr<NoteType> note, bool visible)
|
||||
}
|
||||
}
|
||||
|
||||
_midi_context.update_note_range (note->note());
|
||||
_midi_context.maybe_extend_note_range (note->note());
|
||||
return event;
|
||||
}
|
||||
|
||||
@ -1769,7 +1766,7 @@ MidiView::step_add_note (uint8_t channel, uint8_t number, uint8_t velocity,
|
||||
_midi_region->set_length (timecnt_t (note_end.earlier (_midi_region->position()), timepos_t()));
|
||||
}
|
||||
|
||||
_midi_context.update_note_range(new_note->note());
|
||||
_midi_context.maybe_extend_note_range (new_note->note());
|
||||
|
||||
_marked_for_selection.clear ();
|
||||
|
||||
@ -2701,7 +2698,7 @@ MidiView::note_dropped(NoteBase *, timecnt_t const & d_qn, int8_t dnote, bool co
|
||||
// care about notes being moved beyond the upper/lower bounds on the canvas
|
||||
if (lowest_note_in_selection < _midi_context.lowest_note() ||
|
||||
highest_note_in_selection > _midi_context.highest_note()) {
|
||||
_midi_context.set_note_range (MidiStreamView::ContentsRange);
|
||||
_midi_context.set_note_visibility_range_style (MidiStreamView::ContentsRange);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3361,9 +3358,8 @@ MidiView::transpose (bool up, bool fine, bool allow_smush)
|
||||
apply_note_diff ();
|
||||
|
||||
if (lowest < _midi_context.lowest_note() || highest > _midi_context.highest_note()) {
|
||||
_midi_context.update_note_range (lowest);
|
||||
_midi_context.update_note_range (highest);
|
||||
apply_note_range (lowest, highest, true);
|
||||
_midi_context.maybe_extend_note_range (lowest);
|
||||
_midi_context.maybe_extend_note_range (highest);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4179,9 +4175,9 @@ MidiView::data_recorded (std::weak_ptr<MidiSource> w)
|
||||
|
||||
/* fix up our note range */
|
||||
if (ev.note() < _midi_context.lowest_note()) {
|
||||
apply_note_range (ev.note(), _midi_context.highest_note(), true);
|
||||
set_note_range (ev.note(), _midi_context.highest_note());
|
||||
} else if (ev.note() > _midi_context.highest_note()) {
|
||||
apply_note_range (_midi_context.lowest_note(), ev.note(), true);
|
||||
set_note_range (_midi_context.lowest_note(), ev.note());
|
||||
}
|
||||
|
||||
} else if (ev.type() == MIDI_CMD_NOTE_OFF) {
|
||||
@ -4665,3 +4661,9 @@ MidiView::height() const
|
||||
{
|
||||
return _midi_context.height();
|
||||
}
|
||||
|
||||
void
|
||||
MidiView::set_note_range (uint8_t low, uint8_t high)
|
||||
{
|
||||
_midi_context.apply_note_range (low, high, true);
|
||||
}
|
||||
|
@ -625,6 +625,8 @@ class MidiView : public virtual sigc::trackable
|
||||
void join_notes_on_channel (int channel);
|
||||
|
||||
void add_split_notes ();
|
||||
|
||||
void set_note_range (uint8_t low, uint8_t high);
|
||||
};
|
||||
|
||||
|
||||
|
@ -97,8 +97,6 @@ MidiViewBackground::note_range_adjustment_changed()
|
||||
//cerr << "note range adjustment changed: " << lowest << " " << highest << endl;
|
||||
//cerr << " val=" << v_zoom_adjustment.get_value() << " page=" << v_zoom_adjustment.get_page_size() << " sum=" << v_zoom_adjustment.get_value() + v_zoom_adjustment.get_page_size() << endl;
|
||||
|
||||
_lowest_note = lowest;
|
||||
_highest_note = highest;
|
||||
apply_note_range (lowest, highest, true);
|
||||
}
|
||||
|
||||
@ -119,19 +117,13 @@ MidiViewBackground::y_to_note (double y) const
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MidiViewBackground::update_note_range(uint8_t note_num)
|
||||
{
|
||||
_data_note_min = min(_data_note_min, note_num);
|
||||
_data_note_max = max(_data_note_max, note_num);
|
||||
}
|
||||
|
||||
void
|
||||
MidiViewBackground::update_contents_height ()
|
||||
{
|
||||
ViewBackground::update_contents_height ();
|
||||
|
||||
_note_lines->set_extent (ArdourCanvas::COORD_MAX);
|
||||
draw_note_lines ();
|
||||
apply_note_range (lowest_note(), highest_note(), true);
|
||||
}
|
||||
|
||||
@ -197,22 +189,46 @@ MidiViewBackground::draw_note_lines()
|
||||
|
||||
prev_y = y;
|
||||
}
|
||||
|
||||
_note_lines->set_extent (ArdourCanvas::COORD_MAX);
|
||||
}
|
||||
|
||||
void
|
||||
MidiViewBackground::set_note_range(VisibleNoteRange r)
|
||||
MidiViewBackground::set_note_visibility_range_style (VisibleNoteRange r)
|
||||
{
|
||||
if (r == FullRange) {
|
||||
_lowest_note = 0;
|
||||
_highest_note = 127;
|
||||
} else {
|
||||
_lowest_note = _data_note_min;
|
||||
_highest_note = _data_note_max;
|
||||
}
|
||||
_visibility_note_range = r;
|
||||
|
||||
apply_note_range(_lowest_note, _highest_note, true);
|
||||
if (_visibility_note_range == FullRange) {
|
||||
apply_note_range (0, 127, true);
|
||||
} else {
|
||||
apply_note_range (_data_note_min, _data_note_max, true);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MidiViewBackground::maybe_extend_note_range (uint8_t note_num)
|
||||
{
|
||||
_data_note_min = min (_data_note_min, note_num);
|
||||
_data_note_max = max (_data_note_max, note_num);
|
||||
|
||||
bool changed = false;
|
||||
|
||||
if (_visibility_note_range == FullRange) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_lowest_note > _data_note_min) {
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (_highest_note < _data_note_max) {
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
apply_note_range (_data_note_min, _data_note_max, true);
|
||||
}
|
||||
}
|
||||
void
|
||||
MidiViewBackground::apply_note_range (uint8_t lowest, uint8_t highest, bool to_children)
|
||||
{
|
||||
|
@ -65,12 +65,13 @@ class MidiViewBackground : public virtual ViewBackground
|
||||
|
||||
Gtkmm2ext::Color region_color() const { return _region_color; }
|
||||
|
||||
void set_note_range (VisibleNoteRange r);
|
||||
void set_note_visibility_range_style (VisibleNoteRange r);
|
||||
VisibleNoteRange visibility_range_style() const { return _visibility_note_range; }
|
||||
|
||||
inline uint8_t lowest_note() const { return _lowest_note; }
|
||||
inline uint8_t highest_note() const { return _highest_note; }
|
||||
|
||||
void update_note_range(uint8_t note_num);
|
||||
void maybe_extend_note_range (uint8_t note_num);
|
||||
|
||||
double note_to_y (uint8_t note) const {
|
||||
return contents_height() - (note + 1 - lowest_note()) * note_height() + 1;
|
||||
@ -107,15 +108,18 @@ class MidiViewBackground : public virtual ViewBackground
|
||||
ARDOUR::NoteMode _note_mode;
|
||||
Gtkmm2ext::Color _region_color;
|
||||
ARDOUR::ColorMode _color_mode;
|
||||
VisibleNoteRange _visibility_note_range;
|
||||
|
||||
void color_handler ();
|
||||
void parameter_changed (std::string const &);
|
||||
void note_range_adjustment_changed();
|
||||
void draw_note_lines();
|
||||
bool update_data_note_range(uint8_t min, uint8_t max);
|
||||
bool update_data_note_range (uint8_t min, uint8_t max);
|
||||
void update_contents_height ();
|
||||
virtual void apply_note_range_to_children () = 0;
|
||||
virtual bool updates_suspended() const { return false; }
|
||||
|
||||
void sync_data_and_visual_range ();
|
||||
};
|
||||
|
||||
|
||||
|
@ -342,9 +342,6 @@ RouteTimeAxisView::~RouteTimeAxisView ()
|
||||
|
||||
delete automation_action_menu;
|
||||
|
||||
delete _view;
|
||||
_view = 0;
|
||||
|
||||
_automation_tracks.clear ();
|
||||
|
||||
delete route_group_menu;
|
||||
|
@ -284,8 +284,8 @@ StepEditor::step_add_note (uint8_t channel, uint8_t pitch, uint8_t velocity, Tem
|
||||
/* make sure its visible on the vertical axis */
|
||||
|
||||
if (pitch < msv->lowest_note() || pitch > msv->highest_note()) {
|
||||
msv->update_note_range (pitch);
|
||||
msv->set_note_range (MidiStreamView::ContentsRange);
|
||||
msv->maybe_extend_note_range (pitch);
|
||||
msv->set_note_visibility_range_style (MidiStreamView::ContentsRange);
|
||||
}
|
||||
|
||||
/* make sure its visible on the horizontal axis */
|
||||
|
@ -95,8 +95,6 @@ StreamView::StreamView (RouteTimeAxisView& tv, ArdourCanvas::Container* canvas_g
|
||||
|
||||
StreamView::~StreamView ()
|
||||
{
|
||||
undisplay_track ();
|
||||
|
||||
delete canvas_rect;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user