Move time converters only to the region views that actually need them.

A step towards sorting out time issues more solidly, the time situation of MIDI
region views and automation region views is slightly different.
This commit is contained in:
David Robillard 2014-11-20 17:36:09 -05:00
parent 2966dd4a9f
commit 41a9060df9
6 changed files with 82 additions and 55 deletions

View file

@ -39,14 +39,16 @@
#include "i18n.h" #include "i18n.h"
AutomationRegionView::AutomationRegionView (ArdourCanvas::Container* parent, AutomationRegionView::AutomationRegionView (ArdourCanvas::Container* parent,
AutomationTimeAxisView& time_axis, AutomationTimeAxisView& time_axis,
boost::shared_ptr<ARDOUR::Region> region, boost::shared_ptr<ARDOUR::Region> region,
const Evoral::Parameter& param, const Evoral::Parameter& param,
boost::shared_ptr<ARDOUR::AutomationList> list, boost::shared_ptr<ARDOUR::AutomationList> list,
double spu, double spu,
uint32_t basic_color) uint32_t basic_color)
: RegionView(parent, time_axis, region, spu, basic_color, true) : RegionView(parent, time_axis, region, spu, basic_color, true)
, _region_relative_time_converter(region->session().tempo_map(), region->position())
, _source_relative_time_converter(region->session().tempo_map(), region->position() - region->start())
, _parameter(param) , _parameter(param)
{ {
if (list) { if (list) {
@ -251,6 +253,15 @@ AutomationRegionView::region_resized (const PBD::PropertyChange& what_changed)
{ {
RegionView::region_resized (what_changed); RegionView::region_resized (what_changed);
if (what_changed.contains (ARDOUR::Properties::position)) {
_region_relative_time_converter.set_origin_b(_region->position());
}
if (what_changed.contains (ARDOUR::Properties::start) ||
what_changed.contains (ARDOUR::Properties::position)) {
_source_relative_time_converter.set_origin_b (_region->position() - _region->start());
}
if (!_line) { if (!_line) {
return; return;
} }

View file

@ -54,6 +54,14 @@ public:
float times, float times,
boost::shared_ptr<const ARDOUR::AutomationList> slist); boost::shared_ptr<const ARDOUR::AutomationList> slist);
ARDOUR::BeatsFramesConverter const & region_relative_time_converter () const {
return _region_relative_time_converter;
}
ARDOUR::BeatsFramesConverter const & source_relative_time_converter () const {
return _source_relative_time_converter;
}
inline AutomationTimeAxisView* automation_view() const inline AutomationTimeAxisView* automation_view() const
{ return dynamic_cast<AutomationTimeAxisView*>(&trackview); } { return dynamic_cast<AutomationTimeAxisView*>(&trackview); }
@ -75,6 +83,8 @@ protected:
void exited(); void exited();
private: private:
ARDOUR::BeatsFramesConverter _region_relative_time_converter;
ARDOUR::BeatsFramesConverter _source_relative_time_converter;
Evoral::Parameter _parameter; Evoral::Parameter _parameter;
boost::shared_ptr<AutomationLine> _line; boost::shared_ptr<AutomationLine> _line;
}; };

View file

@ -91,11 +91,16 @@ PBD::Signal1<void, MidiRegionView *> MidiRegionView::SelectionCleared;
#define MIDI_BP_ZERO ((Config->get_first_midi_bank_is_zero())?0:1) #define MIDI_BP_ZERO ((Config->get_first_midi_bank_is_zero())?0:1)
MidiRegionView::MidiRegionView (ArdourCanvas::Container *parent, RouteTimeAxisView &tv, MidiRegionView::MidiRegionView (ArdourCanvas::Container* parent,
boost::shared_ptr<MidiRegion> r, double spu, uint32_t basic_color) RouteTimeAxisView& tv,
boost::shared_ptr<MidiRegion> r,
double spu,
uint32_t basic_color)
: RegionView (parent, tv, r, spu, basic_color) : RegionView (parent, tv, r, spu, basic_color)
, _current_range_min(0) , _current_range_min(0)
, _current_range_max(0) , _current_range_max(0)
, _region_relative_time_converter(r->session().tempo_map(), r->position())
, _source_relative_time_converter(r->session().tempo_map(), r->position() - r->start())
, _active_notes(0) , _active_notes(0)
, _note_group (new ArdourCanvas::Container (group)) , _note_group (new ArdourCanvas::Container (group))
, _note_diff_command (0) , _note_diff_command (0)
@ -128,12 +133,17 @@ MidiRegionView::MidiRegionView (ArdourCanvas::Container *parent, RouteTimeAxisVi
SelectionCleared.connect (_selection_cleared_connection, invalidator (*this), boost::bind (&MidiRegionView::selection_cleared, this, _1), gui_context ()); SelectionCleared.connect (_selection_cleared_connection, invalidator (*this), boost::bind (&MidiRegionView::selection_cleared, this, _1), gui_context ());
} }
MidiRegionView::MidiRegionView (ArdourCanvas::Container *parent, RouteTimeAxisView &tv, MidiRegionView::MidiRegionView (ArdourCanvas::Container* parent,
boost::shared_ptr<MidiRegion> r, double spu, uint32_t basic_color, RouteTimeAxisView& tv,
TimeAxisViewItem::Visibility visibility) boost::shared_ptr<MidiRegion> r,
double spu,
uint32_t basic_color,
TimeAxisViewItem::Visibility visibility)
: RegionView (parent, tv, r, spu, basic_color, false, visibility) : RegionView (parent, tv, r, spu, basic_color, false, visibility)
, _current_range_min(0) , _current_range_min(0)
, _current_range_max(0) , _current_range_max(0)
, _region_relative_time_converter(r->session().tempo_map(), r->position())
, _source_relative_time_converter(r->session().tempo_map(), r->position() - r->start())
, _active_notes(0) , _active_notes(0)
, _note_group (new ArdourCanvas::Container (parent)) , _note_group (new ArdourCanvas::Container (parent))
, _note_diff_command (0) , _note_diff_command (0)
@ -181,6 +191,8 @@ MidiRegionView::MidiRegionView (const MidiRegionView& other)
, RegionView (other) , RegionView (other)
, _current_range_min(0) , _current_range_min(0)
, _current_range_max(0) , _current_range_max(0)
, _region_relative_time_converter(other.region_relative_time_converter())
, _source_relative_time_converter(other.source_relative_time_converter())
, _active_notes(0) , _active_notes(0)
, _note_group (new ArdourCanvas::Container (get_canvas_group())) , _note_group (new ArdourCanvas::Container (get_canvas_group()))
, _note_diff_command (0) , _note_diff_command (0)
@ -210,6 +222,8 @@ MidiRegionView::MidiRegionView (const MidiRegionView& other, boost::shared_ptr<M
: RegionView (other, boost::shared_ptr<Region> (region)) : RegionView (other, boost::shared_ptr<Region> (region))
, _current_range_min(0) , _current_range_min(0)
, _current_range_max(0) , _current_range_max(0)
, _region_relative_time_converter(other.region_relative_time_converter())
, _source_relative_time_converter(other.source_relative_time_converter())
, _active_notes(0) , _active_notes(0)
, _note_group (new ArdourCanvas::Container (get_canvas_group())) , _note_group (new ArdourCanvas::Container (get_canvas_group()))
, _note_diff_command (0) , _note_diff_command (0)
@ -1353,11 +1367,17 @@ MidiRegionView::region_resized (const PropertyChange& what_changed)
RegionView::region_resized(what_changed); RegionView::region_resized(what_changed);
if (what_changed.contains (ARDOUR::Properties::position)) { if (what_changed.contains (ARDOUR::Properties::position)) {
_region_relative_time_converter.set_origin_b(_region->position());
set_duration(_region->length(), 0); set_duration(_region->length(), 0);
if (_enable_display) { if (_enable_display) {
redisplay_model(); redisplay_model();
} }
} }
if (what_changed.contains (ARDOUR::Properties::start) ||
what_changed.contains (ARDOUR::Properties::position)) {
_source_relative_time_converter.set_origin_b (_region->position() - _region->start());
}
} }
void void

View file

@ -275,6 +275,14 @@ public:
/** Convert a timestamp in absolute frames to beats measured from source start*/ /** Convert a timestamp in absolute frames to beats measured from source start*/
double absolute_frames_to_source_beats(framepos_t) const; double absolute_frames_to_source_beats(framepos_t) const;
ARDOUR::BeatsFramesConverter const & region_relative_time_converter () const {
return _region_relative_time_converter;
}
ARDOUR::BeatsFramesConverter const & source_relative_time_converter () const {
return _source_relative_time_converter;
}
void goto_previous_note (bool add_to_selection); void goto_previous_note (bool add_to_selection);
void goto_next_note (bool add_to_selection); void goto_next_note (bool add_to_selection);
void change_note_lengths (bool, bool, Evoral::MusicalTime beats, bool start, bool end); void change_note_lengths (bool, bool, Evoral::MusicalTime beats, bool start, bool end);
@ -379,26 +387,28 @@ private:
uint8_t _current_range_min; uint8_t _current_range_min;
uint8_t _current_range_max; uint8_t _current_range_max;
typedef std::list<NoteBase*> Events; typedef std::list<NoteBase*> Events;
typedef std::vector< boost::shared_ptr<PatchChange> > PatchChanges; typedef std::vector< boost::shared_ptr<PatchChange> > PatchChanges;
typedef std::vector< boost::shared_ptr<SysEx> > SysExes; typedef std::vector< boost::shared_ptr<SysEx> > SysExes;
ARDOUR::BeatsFramesConverter _region_relative_time_converter;
ARDOUR::BeatsFramesConverter _source_relative_time_converter;
boost::shared_ptr<ARDOUR::MidiModel> _model; boost::shared_ptr<ARDOUR::MidiModel> _model;
Events _events; Events _events;
PatchChanges _patch_changes; PatchChanges _patch_changes;
SysExes _sys_exes; SysExes _sys_exes;
Note** _active_notes; Note** _active_notes;
ArdourCanvas::Container* _note_group; ArdourCanvas::Container* _note_group;
ARDOUR::MidiModel::NoteDiffCommand* _note_diff_command; ARDOUR::MidiModel::NoteDiffCommand* _note_diff_command;
Note* _ghost_note; Note* _ghost_note;
double _last_ghost_x; double _last_ghost_x;
double _last_ghost_y; double _last_ghost_y;
ArdourCanvas::Rectangle* _step_edit_cursor; ArdourCanvas::Rectangle* _step_edit_cursor;
Evoral::MusicalTime _step_edit_cursor_width; Evoral::MusicalTime _step_edit_cursor_width;
Evoral::MusicalTime _step_edit_cursor_position; Evoral::MusicalTime _step_edit_cursor_position;
NoteBase* _channel_selection_scoped_note; NoteBase* _channel_selection_scoped_note;
/** A group used to temporarily reparent _note_group to during start trims, so /** A group used to temporarily reparent _note_group to during start trims, so
* that the notes don't move with the parent region view. * that the notes don't move with the parent region view.

View file

@ -65,12 +65,12 @@ static const int32_t sync_mark_width = 9;
PBD::Signal1<void,RegionView*> RegionView::RegionViewGoingAway; PBD::Signal1<void,RegionView*> RegionView::RegionViewGoingAway;
RegionView::RegionView (ArdourCanvas::Container* parent, RegionView::RegionView (ArdourCanvas::Container* parent,
TimeAxisView& tv, TimeAxisView& tv,
boost::shared_ptr<ARDOUR::Region> r, boost::shared_ptr<ARDOUR::Region> r,
double spu, double spu,
uint32_t basic_color, uint32_t basic_color,
bool automation) bool automation)
: TimeAxisViewItem (r->name(), *parent, tv, spu, basic_color, r->position(), r->length(), false, automation, : TimeAxisViewItem (r->name(), *parent, tv, spu, basic_color, r->position(), r->length(), false, automation,
(automation ? TimeAxisViewItem::ShowFrame : (automation ? TimeAxisViewItem::ShowFrame :
TimeAxisViewItem::Visibility (TimeAxisViewItem::ShowNameText| TimeAxisViewItem::Visibility (TimeAxisViewItem::ShowNameText|
@ -85,9 +85,7 @@ RegionView::RegionView (ArdourCanvas::Container* parent,
, _pixel_width(1.0) , _pixel_width(1.0)
, in_destructor(false) , in_destructor(false)
, wait_for_data(false) , wait_for_data(false)
, _silence_text (0) , _silence_text (0)
, _region_relative_time_converter(r->session().tempo_map(), r->position())
, _source_relative_time_converter(r->session().tempo_map(), r->position() - r->start())
{ {
GhostRegion::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&RegionView::remove_ghost, this, _1), gui_context()); GhostRegion::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&RegionView::remove_ghost, this, _1), gui_context());
} }
@ -95,9 +93,7 @@ RegionView::RegionView (ArdourCanvas::Container* parent,
RegionView::RegionView (const RegionView& other) RegionView::RegionView (const RegionView& other)
: sigc::trackable(other) : sigc::trackable(other)
, TimeAxisViewItem (other) , TimeAxisViewItem (other)
, _silence_text (0) , _silence_text (0)
, _region_relative_time_converter(other.region_relative_time_converter())
, _source_relative_time_converter(other.source_relative_time_converter())
{ {
/* derived concrete type will call init () */ /* derived concrete type will call init () */
@ -112,9 +108,7 @@ RegionView::RegionView (const RegionView& other)
RegionView::RegionView (const RegionView& other, boost::shared_ptr<Region> other_region) RegionView::RegionView (const RegionView& other, boost::shared_ptr<Region> other_region)
: sigc::trackable(other) : sigc::trackable(other)
, TimeAxisViewItem (other) , TimeAxisViewItem (other)
, _silence_text (0) , _silence_text (0)
, _region_relative_time_converter(other_region->session().tempo_map(), other_region->position())
, _source_relative_time_converter(other_region->session().tempo_map(), other_region->position() - other_region->start())
{ {
/* this is a pseudo-copy constructor used when dragging regions /* this is a pseudo-copy constructor used when dragging regions
around on the canvas. around on the canvas.
@ -130,13 +124,13 @@ RegionView::RegionView (const RegionView& other, boost::shared_ptr<Region> other
GhostRegion::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&RegionView::remove_ghost, this, _1), gui_context()); GhostRegion::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&RegionView::remove_ghost, this, _1), gui_context());
} }
RegionView::RegionView (ArdourCanvas::Container* parent, RegionView::RegionView (ArdourCanvas::Container* parent,
TimeAxisView& tv, TimeAxisView& tv,
boost::shared_ptr<ARDOUR::Region> r, boost::shared_ptr<ARDOUR::Region> r,
double spu, double spu,
uint32_t basic_color, uint32_t basic_color,
bool recording, bool recording,
TimeAxisViewItem::Visibility visibility) TimeAxisViewItem::Visibility visibility)
: TimeAxisViewItem (r->name(), *parent, tv, spu, basic_color, r->position(), r->length(), recording, false, visibility) : TimeAxisViewItem (r->name(), *parent, tv, spu, basic_color, r->position(), r->length(), recording, false, visibility)
, _region (r) , _region (r)
, sync_mark(0) , sync_mark(0)
@ -148,9 +142,7 @@ RegionView::RegionView (ArdourCanvas::Container* parent,
, _pixel_width(1.0) , _pixel_width(1.0)
, in_destructor(false) , in_destructor(false)
, wait_for_data(false) , wait_for_data(false)
, _silence_text (0) , _silence_text (0)
, _region_relative_time_converter(r->session().tempo_map(), r->position())
, _source_relative_time_converter(r->session().tempo_map(), r->position() - r->start())
{ {
} }
@ -417,11 +409,6 @@ RegionView::region_resized (const PropertyChange& what_changed)
if (what_changed.contains (ARDOUR::Properties::position)) { if (what_changed.contains (ARDOUR::Properties::position)) {
set_position (_region->position(), 0); set_position (_region->position(), 0);
_region_relative_time_converter.set_origin_b (_region->position());
}
if (what_changed.contains (ARDOUR::Properties::start) || what_changed.contains (ARDOUR::Properties::position)) {
_source_relative_time_converter.set_origin_b (_region->position() - _region->start());
} }
PropertyChange s_and_l; PropertyChange s_and_l;

View file

@ -97,14 +97,6 @@ class RegionView : public TimeAxisViewItem
static PBD::Signal1<void,RegionView*> RegionViewGoingAway; static PBD::Signal1<void,RegionView*> RegionViewGoingAway;
ARDOUR::BeatsFramesConverter const & region_relative_time_converter () const {
return _region_relative_time_converter;
}
ARDOUR::BeatsFramesConverter const & source_relative_time_converter () const {
return _source_relative_time_converter;
}
/** Called when a front trim is about to begin */ /** Called when a front trim is about to begin */
virtual void trim_front_starting () {} virtual void trim_front_starting () {}
@ -192,9 +184,6 @@ class RegionView : public TimeAxisViewItem
/** a text item to display strip silence statistics /** a text item to display strip silence statistics
*/ */
ArdourCanvas::Text* _silence_text; ArdourCanvas::Text* _silence_text;
ARDOUR::BeatsFramesConverter _region_relative_time_converter;
ARDOUR::BeatsFramesConverter _source_relative_time_converter;
}; };
#endif /* __gtk_ardour_region_view_h__ */ #endif /* __gtk_ardour_region_view_h__ */