Save marker selection state in instant.xml (#4203).

git-svn-id: svn://localhost/ardour2/branches/3.0@10245 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2011-10-20 00:05:31 +00:00
parent 0bc8832e20
commit abedf1fae3
5 changed files with 79 additions and 33 deletions

View File

@ -1137,6 +1137,44 @@ Editor::set_session (Session *t)
compute_fixed_ruler_scale ();
/* Make sure we have auto loop and auto punch ranges */
Location* loc = _session->locations()->auto_loop_location();
if (loc == 0) {
loc = new Location (*_session, 0, _session->current_end_frame(), _("Loop"),(Location::Flags) (Location::IsAutoLoop | Location::IsHidden));
if (loc->start() == loc->end()) {
loc->set_end (loc->start() + 1);
}
_session->locations()->add (loc, false);
_session->set_auto_loop_location (loc);
} else {
// force name
loc->set_name (_("Loop"));
}
loc = _session->locations()->auto_punch_location();
if (loc == 0) {
loc = new Location (*_session, 0, _session->current_end_frame(), _("Punch"), (Location::Flags) (Location::IsAutoPunch | Location::IsHidden));
if (loc->start() == loc->end()) {
loc->set_end (loc->start() + 1);
}
_session->locations()->add (loc, false);
_session->set_auto_punch_location (loc);
} else {
// force name
loc->set_name (_("Punch"));
}
refresh_location_display ();
/* This must happen after refresh_location_display(), as (amongst other things) we restore
the selected Marker; this needs the LocationMarker list to be available.
*/
XMLNode* node = ARDOUR_UI::instance()->editor_settings();
set_state (*node, Stateful::loading_state_version);
@ -1182,43 +1220,10 @@ Editor::set_session (Session *t)
playhead_cursor->canvas_item.show ();
Location* loc = _session->locations()->auto_loop_location();
if (loc == 0) {
loc = new Location (*_session, 0, _session->current_end_frame(), _("Loop"),(Location::Flags) (Location::IsAutoLoop | Location::IsHidden));
if (loc->start() == loc->end()) {
loc->set_end (loc->start() + 1);
}
_session->locations()->add (loc, false);
_session->set_auto_loop_location (loc);
} else {
// force name
loc->set_name (_("Loop"));
}
loc = _session->locations()->auto_punch_location();
if (loc == 0) {
loc = new Location (*_session, 0, _session->current_end_frame(), _("Punch"), (Location::Flags) (Location::IsAutoPunch | Location::IsHidden));
if (loc->start() == loc->end()) {
loc->set_end (loc->start() + 1);
}
_session->locations()->add (loc, false);
_session->set_auto_punch_location (loc);
} else {
// force name
loc->set_name (_("Punch"));
}
boost::function<void (string)> pc (boost::bind (&Editor::parameter_changed, this, _1));
Config->map_parameters (pc);
_session->config.map_parameters (pc);
refresh_location_display ();
restore_ruler_visibility ();
//tempo_map_changed (PropertyChange (0));
_session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);

View File

@ -590,6 +590,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
LocationMarkers *find_location_markers (ARDOUR::Location *) const;
ARDOUR::Location* find_location_from_marker (Marker *, bool& is_start) const;
Marker* find_marker_from_location_id (PBD::ID const &, bool) const;
Marker* entered_marker;
bool _show_marker_lines;

View File

@ -1505,3 +1505,15 @@ Editor::remove_sorted_marker (Marker* m)
i->second.remove (m);
}
}
Marker *
Editor::find_marker_from_location_id (PBD::ID const & id, bool is_start) const
{
for (LocationMarkerMap::const_iterator i = location_markers.begin(); i != location_markers.end(); ++i) {
if (i->first->id() == id) {
return is_start ? i->second->start : i->second->end;
}
}
return 0;
}

View File

@ -384,6 +384,9 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible {
virtual void get_pointer_position (double &, double &) const = 0;
virtual ARDOUR::Location* find_location_from_marker (Marker *, bool &) const = 0;
virtual Marker* find_marker_from_location_id (PBD::ID const &, bool) const = 0;
/// Singleton instance, set up by Editor::Editor()
static PublicEditor* _instance;

View File

@ -1141,6 +1141,16 @@ Selection::get_state () const
}
}
for (MarkerSelection::const_iterator i = markers.begin(); i != markers.end(); ++i) {
XMLNode* t = node->add_child (X_("Marker"));
bool is_start;
Location* loc = editor->find_location_from_marker (*i, is_start);
t->add_property (X_("id"), atoi (loc->id().to_s().c_str()));
t->add_property (X_("start"), is_start ? X_("yes") : X_("no"));
}
return *node;
}
@ -1186,7 +1196,22 @@ Selection::set_state (XMLNode const & node, int)
add (atv.get());
}
}
} else if ((*i)->name() == X_("Marker")) {
XMLProperty* prop_id = (*i)->property (X_("id"));
XMLProperty* prop_start = (*i)->property (X_("start"));
assert (prop_id);
assert (prop_start);
PBD::ID id (prop_id->value ());
Marker* m = editor->find_marker_from_location_id (id, string_is_affirmative (prop_start->value ()));
if (m) {
add (m);
}
}
}
return 0;