#include "crossfade_edit.h"
#include "debug.h"
#include "editing.h"
+#include "editing_convert.h"
#include "editor.h"
#include "editor_cursors.h"
#include "editor_drag.h"
#include "editor_routes.h"
#include "editor_snapshots.h"
#include "editor_summary.h"
+#include "enums_convert.h"
#include "export_report.h"
#include "global_port_matrix.h"
#include "gui_object.h"
location_loop_color = UIConfiguration::instance().color ("location loop");
location_punch_color = UIConfiguration::instance().color ("location punch");
- timebar_height = std::max(12., ceil (15. * ARDOUR_UI::ui_scale));
+ timebar_height = std::max (12., ceil (15. * UIConfiguration::instance().get_ui_scale()));
TimeAxisView::setup_sizes ();
ArdourMarker::setup_sizes (timebar_height);
bottom_hbox.set_border_width (2);
bottom_hbox.set_spacing (3);
+ PresentationInfo::Change.connect (*this, MISSING_INVALIDATOR, boost::bind (&Editor::presentation_info_changed, this, _1), gui_context());
+
_route_groups = new EditorRouteGroups (this);
_routes = new EditorRoutes (this);
_regions = new EditorRegions (this);
/* Pick up some settings we need to cache, early */
XMLNode* settings = ARDOUR_UI::instance()->editor_settings();
- XMLProperty* prop;
- if (settings && (prop = settings->property ("notebook-shrunk"))) {
- _notebook_shrunk = string_is_affirmative (prop->value ());
+ if (settings) {
+ settings->get_property ("notebook-shrunk", _notebook_shrunk);
}
editor_summary_pane.set_check_divider_position (true);
{
LocaleGuard lg;
- if (!settings || ((prop = settings->property ("edit-horizontal-pane-pos")) == 0) || ((fract = atof (prop->value())) > 1.0)) {
+ if (!settings || !settings->get_property ("edit-horizontal-pane-pos", fract) || fract > 1.0) {
/* initial allocation is 90% to canvas, 10% to notebook */
- edit_pane.set_divider (0, 0.90);
- } else {
- edit_pane.set_divider (0, fract);
+ fract = 0.90;
}
+ edit_pane.set_divider (0, fract);
- if (!settings || ((prop = settings->property ("edit-vertical-pane-pos")) == 0) || ((fract = atof (prop->value())) > 1.0)) {
+ if (!settings || !settings->get_property ("edit-vertical-pane-pos", fract) || fract > 1.0) {
/* initial allocation is 90% to canvas, 10% to summary */
- editor_summary_pane.set_divider (0, 0.90);
- } else {
-
- editor_summary_pane.set_divider (0, fract);
+ fract = 0.90;
}
+ editor_summary_pane.set_divider (0, fract);
}
global_vpacker.set_spacing (2);
void
Editor::control_select (boost::shared_ptr<Stripable> s, Selection::Operation op)
{
- TimeAxisView* tav = axis_view_from_stripable (s);
+ TimeAxisView* tav = time_axis_view_from_stripable (s);
if (tav) {
switch (op) {
XMLNode* node = ARDOUR_UI::instance()->editor_settings();
set_state (*node, Stateful::loading_state_version);
+ /* catch up on selection state, etc. */
+
+ PropertyChange sc;
+ sc.add (Properties::selected);
+ presentation_info_changed (sc);
+
/* catch up with the playhead */
_session->request_locate (playhead_cursor->current_frame ());
_session->StepEditStatusChange.connect (_session_connections, invalidator (*this), boost::bind (&Editor::step_edit_status_change, this, _1), gui_context());
_session->TransportStateChange.connect (_session_connections, invalidator (*this), boost::bind (&Editor::map_transport_state, this), gui_context());
+ _session->TransportLooped.connect (_session_connections, invalidator (*this), boost::bind (&Editor::transport_looped, this), gui_context());
_session->PositionChanged.connect (_session_connections, invalidator (*this), boost::bind (&Editor::map_position_change, this, _1), gui_context());
_session->vca_manager().VCAAdded.connect (_session_connections, invalidator (*this), boost::bind (&Editor::add_vcas, this, _1), gui_context());
_session->RouteAdded.connect (_session_connections, invalidator (*this), boost::bind (&Editor::add_routes, this, _1), gui_context());
break;
}
- /* catch up on selection of stripables (other selection state is lost
- * when a session is closed
- */
-
- StripableList sl;
- TrackViewList tl;
- _session->get_stripables (sl);
- for (StripableList::const_iterator s = sl.begin(); s != sl.end(); ++s) {
- if ((*s)->presentation_info().selected()) {
- RouteTimeAxisView* rtav = get_route_view_by_route_id ((*s)->id());
- if (rtav) {
- tl.push_back (rtav);
- }
- }
- }
- if (!tl.empty()) {
- selection->set (tl);
- }
-
/* register for undo history */
_session->register_with_memento_command_factory(id(), this);
_session->register_with_memento_command_factory(_selection_memento->id(), _selection_memento);
int
Editor::set_state (const XMLNode& node, int version)
{
- XMLProperty const * prop;
set_id (node);
PBD::Unwinder<bool> nsi (no_save_instant, true);
LocaleGuard lg;
+ bool yn;
Tabbable::set_state (node, version);
- if (_session && (prop = node.property ("playhead"))) {
- framepos_t pos;
- sscanf (prop->value().c_str(), "%" PRIi64, &pos);
- if (pos >= 0) {
- playhead_cursor->set_position (pos);
+ framepos_t ph_pos;
+ if (_session && node.get_property ("playhead", ph_pos)) {
+ if (ph_pos >= 0) {
+ playhead_cursor->set_position (ph_pos);
} else {
warning << _("Playhead position stored with a negative value - ignored (use zero instead)") << endmsg;
playhead_cursor->set_position (0);
playhead_cursor->set_position (0);
}
- if ((prop = node.property ("mixer-width"))) {
- editor_mixer_strip_width = Width (string_2_enum (prop->value(), editor_mixer_strip_width));
- }
+ node.get_property ("mixer-width", editor_mixer_strip_width);
- if ((prop = node.property ("zoom-focus"))) {
- zoom_focus_selection_done ((ZoomFocus) string_2_enum (prop->value(), zoom_focus));
- } else {
- zoom_focus_selection_done (zoom_focus);
- }
+ node.get_property ("zoom-focus", zoom_focus);
+ zoom_focus_selection_done (zoom_focus);
- if ((prop = node.property ("zoom"))) {
+ double z;
+ if (node.get_property ("zoom", z)) {
/* older versions of ardour used floating point samples_per_pixel */
- double f = PBD::atof (prop->value());
- reset_zoom (llrintf (f));
+ reset_zoom (llrintf (z));
} else {
reset_zoom (samples_per_pixel);
}
- if ((prop = node.property ("visible-track-count"))) {
- set_visible_track_count (PBD::atoi (prop->value()));
+ int32_t cnt;
+ if (node.get_property ("visible-track-count", cnt)) {
+ set_visible_track_count (cnt);
}
- if ((prop = node.property ("snap-to"))) {
- snap_type_selection_done ((SnapType) string_2_enum (prop->value(), _snap_type));
- set_snap_to ((SnapType) string_2_enum (prop->value(), _snap_type));
- } else {
- set_snap_to (_snap_type);
+ SnapType snap_type;
+ if (!node.get_property ("snap-to", snap_type)) {
+ snap_type = _snap_type;
}
+ set_snap_to (snap_type);
- if ((prop = node.property ("snap-mode"))) {
- snap_mode_selection_done((SnapMode) string_2_enum (prop->value(), _snap_mode));
+ SnapMode sm;
+ if (node.get_property ("snap-mode", sm)) {
+ snap_mode_selection_done(sm);
/* set text of Dropdown. in case _snap_mode == SnapOff (default)
* snap_mode_selection_done() will only mark an already active item as active
* which does not trigger set_text().
*/
- set_snap_mode ((SnapMode) string_2_enum (prop->value(), _snap_mode));
+ set_snap_mode (sm);
} else {
set_snap_mode (_snap_mode);
}
- if ((prop = node.property ("internal-snap-to"))) {
- internal_snap_type = (SnapType) string_2_enum (prop->value(), internal_snap_type);
- }
-
- if ((prop = node.property ("internal-snap-mode"))) {
- internal_snap_mode = (SnapMode) string_2_enum (prop->value(), internal_snap_mode);
- }
-
- if ((prop = node.property ("pre-internal-snap-to"))) {
- pre_internal_snap_type = (SnapType) string_2_enum (prop->value(), pre_internal_snap_type);
- }
+ node.get_property ("internal-snap-to", internal_snap_type);
+ node.get_property ("internal-snap-mode", internal_snap_mode);
+ node.get_property ("pre-internal-snap-to", pre_internal_snap_type);
+ node.get_property ("pre-internal-snap-mode", pre_internal_snap_mode);
- if ((prop = node.property ("pre-internal-snap-mode"))) {
- pre_internal_snap_mode = (SnapMode) string_2_enum (prop->value(), pre_internal_snap_mode);
- }
-
- if ((prop = node.property ("mouse-mode"))) {
- MouseMode m = str2mousemode(prop->value());
+ std::string mm_str;
+ if (node.get_property ("mouse-mode", mm_str)) {
+ MouseMode m = str2mousemode(mm_str);
set_mouse_mode (m, true);
} else {
set_mouse_mode (MouseObject, true);
}
- if ((prop = node.property ("left-frame")) != 0) {
- framepos_t pos;
- if (sscanf (prop->value().c_str(), "%" PRId64, &pos) == 1) {
- if (pos < 0) {
- pos = 0;
- }
- reset_x_origin (pos);
+ framepos_t lf_pos;
+ if (node.get_property ("left-frame", lf_pos)) {
+ if (lf_pos < 0) {
+ lf_pos = 0;
}
+ reset_x_origin (lf_pos);
}
- if ((prop = node.property ("y-origin")) != 0) {
- reset_y_origin (atof (prop->value ()));
+ double y_origin;
+ if (node.get_property ("y-origin", y_origin)) {
+ reset_y_origin (y_origin);
}
- if ((prop = node.property ("join-object-range"))) {
+ if (node.get_property ("join-object-range", yn)) {
RefPtr<Action> act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-object-range"));
- bool yn = string_is_affirmative (prop->value());
if (act) {
RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
tact->set_active (!yn);
set_mouse_mode(mouse_mode, true);
}
- if ((prop = node.property ("edit-point"))) {
- set_edit_point_preference ((EditPoint) string_2_enum (prop->value(), _edit_point), true);
+ EditPoint ep;
+ if (node.get_property ("edit-point", ep)) {
+ set_edit_point_preference (ep, true);
} else {
set_edit_point_preference (_edit_point);
}
- if ((prop = node.property ("show-measures"))) {
- bool yn = string_is_affirmative (prop->value());
- _show_measures = yn;
- }
+ node.get_property ("show-measures", _show_measures);
- if ((prop = node.property ("follow-playhead"))) {
- bool yn = string_is_affirmative (prop->value());
+ if (node.get_property ("follow-playhead", yn)) {
set_follow_playhead (yn);
}
- if ((prop = node.property ("stationary-playhead"))) {
- bool yn = string_is_affirmative (prop->value());
+ if (node.get_property ("stationary-playhead", yn)) {
set_stationary_playhead (yn);
}
- if ((prop = node.property ("region-list-sort-type"))) {
- RegionListSortType st;
- _regions->reset_sort_type ((RegionListSortType) string_2_enum (prop->value(), st), true);
+ RegionListSortType sort_type;
+ if (node.get_property ("region-list-sort-type", sort_type)) {
+ _regions->reset_sort_type (sort_type, true);
}
- if ((prop = node.property ("show-editor-mixer"))) {
+ if (node.get_property ("show-editor-mixer", yn)) {
Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
assert (act);
Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
- bool yn = string_is_affirmative (prop->value());
/* do it twice to force the change */
tact->set_active (yn);
}
- if ((prop = node.property ("show-editor-list"))) {
+ if (node.get_property ("show-editor-list", yn)) {
Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-list"));
assert (act);
Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
- bool yn = string_is_affirmative (prop->value());
/* do it twice to force the change */
tact->set_active (yn);
}
- if ((prop = node.property (X_("editor-list-page")))) {
- _the_notebook.set_current_page (atoi (prop->value ()));
+ int32_t el_page;
+ if (node.get_property (X_("editor-list-page"), el_page)) {
+ _the_notebook.set_current_page (el_page);
}
- if ((prop = node.property (X_("show-marker-lines")))) {
+ if (node.get_property (X_("show-marker-lines"), yn)) {
Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-marker-lines"));
assert (act);
Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
- bool yn = string_is_affirmative (prop->value ());
tact->set_active (!yn);
tact->set_active (yn);
_locations->set_state (**i);
}
- if ((prop = node.property ("maximised"))) {
- bool yn = string_is_affirmative (prop->value());
+ if (node.get_property ("maximised", yn)) {
Glib::RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleMaximalEditor"));
assert (act);
Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
}
}
- if ((prop = node.property ("nudge-clock-value"))) {
- framepos_t f;
- sscanf (prop->value().c_str(), "%" PRId64, &f);
- nudge_clock->set (f);
+ framepos_t nudge_clock_value;
+ if (node.get_property ("nudge-clock-value", nudge_clock_value)) {
+ nudge_clock->set (nudge_clock_value);
} else {
nudge_clock->set_mode (AudioClock::Timecode);
nudge_clock->set (_session->frame_rate() * 5, true);
* those that are linked to a private variable may need changing
*/
RefPtr<Action> act;
- bool yn;
act = ActionManager::get_action (X_("Editor"), X_("ToggleMeasureVisibility"));
if (act) {
Editor::get_state ()
{
XMLNode* node = new XMLNode (X_("Editor"));
- char buf[32];
LocaleGuard lg;
- id().print (buf, sizeof (buf));
- node->add_property ("id", buf);
+ node->set_property ("id", id().to_s ());
node->add_child_nocopy (Tabbable::get_state());
- snprintf(buf,sizeof(buf), "%f", edit_pane.get_divider ());
- node->add_property("edit-horizontal-pane-pos", string(buf));
- node->add_property("notebook-shrunk", _notebook_shrunk ? "1" : "0");
- snprintf(buf,sizeof(buf), "%f", editor_summary_pane.get_divider());
- node->add_property("edit-vertical-pane-pos", string(buf));
+ node->set_property("edit-horizontal-pane-pos", edit_pane.get_divider ());
+ node->set_property("notebook-shrunk", _notebook_shrunk);
+ node->set_property("edit-vertical-pane-pos", editor_summary_pane.get_divider());
maybe_add_mixer_strip_width (*node);
- node->add_property ("zoom-focus", enum_2_string (zoom_focus));
-
- snprintf (buf, sizeof(buf), "%" PRId64, samples_per_pixel);
- node->add_property ("zoom", buf);
- node->add_property ("snap-to", enum_2_string (_snap_type));
- node->add_property ("snap-mode", enum_2_string (_snap_mode));
- node->add_property ("internal-snap-to", enum_2_string (internal_snap_type));
- node->add_property ("internal-snap-mode", enum_2_string (internal_snap_mode));
- node->add_property ("pre-internal-snap-to", enum_2_string (pre_internal_snap_type));
- node->add_property ("pre-internal-snap-mode", enum_2_string (pre_internal_snap_mode));
- node->add_property ("edit-point", enum_2_string (_edit_point));
- snprintf (buf, sizeof(buf), "%d", _visible_track_count);
- node->add_property ("visible-track-count", buf);
-
- snprintf (buf, sizeof (buf), "%" PRIi64, playhead_cursor->current_frame ());
- node->add_property ("playhead", buf);
- snprintf (buf, sizeof (buf), "%" PRIi64, leftmost_frame);
- node->add_property ("left-frame", buf);
- snprintf (buf, sizeof (buf), "%f", vertical_adjustment.get_value ());
- node->add_property ("y-origin", buf);
-
- node->add_property ("show-measures", _show_measures ? "yes" : "no");
- node->add_property ("maximised", _maximised ? "yes" : "no");
- node->add_property ("follow-playhead", _follow_playhead ? "yes" : "no");
- node->add_property ("stationary-playhead", _stationary_playhead ? "yes" : "no");
- node->add_property ("region-list-sort-type", enum_2_string (_regions->sort_type ()));
- node->add_property ("mouse-mode", enum2str(mouse_mode));
- node->add_property ("join-object-range", smart_mode_action->get_active () ? "yes" : "no");
+ node->set_property ("zoom-focus", zoom_focus);
+
+ node->set_property ("zoom", samples_per_pixel);
+ node->set_property ("snap-to", _snap_type);
+ node->set_property ("snap-mode", _snap_mode);
+ node->set_property ("internal-snap-to", internal_snap_type);
+ node->set_property ("internal-snap-mode", internal_snap_mode);
+ node->set_property ("pre-internal-snap-to", pre_internal_snap_type);
+ node->set_property ("pre-internal-snap-mode", pre_internal_snap_mode);
+ node->set_property ("edit-point", _edit_point);
+ node->set_property ("visible-track-count", _visible_track_count);
+
+ node->set_property ("playhead", playhead_cursor->current_frame ());
+ node->set_property ("left-frame", leftmost_frame);
+ node->set_property ("y-origin", vertical_adjustment.get_value ());
+
+ node->set_property ("show-measures", _show_measures);
+ node->set_property ("maximised", _maximised);
+ node->set_property ("follow-playhead", _follow_playhead);
+ node->set_property ("stationary-playhead", _stationary_playhead);
+ node->set_property ("region-list-sort-type", _regions->sort_type ());
+ node->set_property ("mouse-mode", mouse_mode);
+ node->set_property ("join-object-range", smart_mode_action->get_active ());
Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
if (act) {
Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
- node->add_property (X_("show-editor-mixer"), tact->get_active() ? "yes" : "no");
+ node->set_property (X_("show-editor-mixer"), tact->get_active());
}
act = ActionManager::get_action (X_("Editor"), X_("show-editor-list"));
if (act) {
Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
- node->add_property (X_("show-editor-list"), tact->get_active() ? "yes" : "no");
+ node->set_property (X_("show-editor-list"), tact->get_active());
}
- snprintf (buf, sizeof (buf), "%d", _the_notebook.get_current_page ());
- node->add_property (X_("editor-list-page"), buf);
+ node->set_property (X_("editor-list-page"), _the_notebook.get_current_page ());
- if (button_bindings) {
- XMLNode* bb = new XMLNode (X_("Buttons"));
- button_bindings->save (*bb);
- node->add_child_nocopy (*bb);
- }
+ if (button_bindings) {
+ XMLNode* bb = new XMLNode (X_("Buttons"));
+ button_bindings->save (*bb);
+ node->add_child_nocopy (*bb);
+ }
- node->add_property (X_("show-marker-lines"), _show_marker_lines ? "yes" : "no");
+ node->set_property (X_("show-marker-lines"), _show_marker_lines);
node->add_child_nocopy (selection->get_state ());
node->add_child_nocopy (_regions->get_state ());
- snprintf (buf, sizeof (buf), "%" PRId64, nudge_clock->current_duration());
- node->add_property ("nudge-clock-value", buf);
+ node->set_property ("nudge-clock-value", nudge_clock->current_duration());
node->add_child_nocopy (LuaInstance::instance()->get_action_state());
node->add_child_nocopy (LuaInstance::instance()->get_hook_state());
update_loop_range_view ();
}
+void
+Editor::transport_looped ()
+{
+ /* reset Playhead position interpolation.
+ * see Editor::super_rapid_screen_update
+ */
+ _last_update_time = 0;
+}
+
/* UNDO/REDO */
void
switch (ep) {
case EditAtPlayhead:
- if (_dragging_playhead) {
+ if (_dragging_playhead && _control_scroll_target) {
where = *_control_scroll_target;
} else {
where = _session->audible_frame();
(*t)->first_idle();
}
+ /* now that all regionviews should exist, setup region selection */
+
+ RegionSelection rs;
+
+ for (list<PBD::ID>::iterator pr = selection->regions.pending.begin (); pr != selection->regions.pending.end (); ++pr) {
+ /* this is cumulative: rs is NOT cleared each time */
+ get_regionviews_by_id (*pr, rs);
+ }
+
+ selection->set (rs);
+
// first idle adds route children (automation tracks), so we need to redisplay here
_routes->redisplay ();
_pending_locate_request = false;
_pending_initial_locate = false;
+ _last_update_time = 0;
}
void
Editor::region_view_added (RegionView * rv)
{
- for (list<PBD::ID>::iterator pr = selection->regions.pending.begin (); pr != selection->regions.pending.end (); ++pr) {
- if (rv->region ()->id () == (*pr)) {
- selection->add (rv);
- selection->regions.pending.erase (pr);
- break;
- }
- }
-
MidiRegionView* mrv = dynamic_cast<MidiRegionView*> (rv);
if (mrv) {
list<pair<PBD::ID const, list<Evoral::event_id_t> > >::iterator rnote;
_summary->set_background_dirty ();
}
-TimeAxisView*
-Editor::axis_view_from_stripable (boost::shared_ptr<Stripable> s) const
+AxisView*
+Editor::axis_view_by_stripable (boost::shared_ptr<Stripable> s) const
{
for (TrackViewList::const_iterator j = track_views.begin (); j != track_views.end(); ++j) {
if ((*j)->stripable() == s) {
return 0;
}
+AxisView*
+Editor::axis_view_by_control (boost::shared_ptr<AutomationControl> c) const
+{
+ for (TrackViewList::const_iterator j = track_views.begin (); j != track_views.end(); ++j) {
+ if ((*j)->control() == c) {
+ return *j;
+ }
+
+ TimeAxisView::Children kids = (*j)->get_child_list ();
+
+ for (TimeAxisView::Children::iterator k = kids.begin(); k != kids.end(); ++k) {
+ if ((*k)->control() == c) {
+ return (*k).get();
+ }
+ }
+ }
+
+ return 0;
+}
TrackViewList
Editor::axis_views_from_routes (boost::shared_ptr<RouteList> r) const
TrackViewList t;
for (RouteList::const_iterator i = r->begin(); i != r->end(); ++i) {
- TimeAxisView* tv = axis_view_from_stripable (*i);
+ TimeAxisView* tv = time_axis_view_from_stripable (*i);
if (tv) {
t.push_back (tv);
}
* 2. if we're not rolling, there's nothing to do here (locates are handled elsewhere).
* 3. if we're still at the same frame that we were last time, there's nothing to do.
*/
- if (_pending_locate_request || _session->transport_speed() == 0) {
+ if (_pending_locate_request || !_session->transport_rolling ()) {
_last_update_time = 0;
return;
}
return;
}
- framepos_t frame = _session->audible_frame();
+ bool latent_locate = false;
+ framepos_t frame = _session->audible_frame (&latent_locate);
const int64_t now = g_get_monotonic_time ();
double err = 0;
_err_screen_engine = 0;
}
- if (err > 8192) {
+ if (err > 8192 || latent_locate) {
// in case of x-runs or freewheeling
_last_update_time = 0;
} else {