summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2011-10-20 00:05:31 +0000
committerCarl Hetherington <carl@carlh.net>2011-10-20 00:05:31 +0000
commitabedf1fae33bb1215d4e2f2c3b84e1ced80a6e9d (patch)
tree828c6814006549cdaffe3c6ff3b9dee54b6ae1dc /gtk2_ardour
parent0bc8832e208154a0f172d34182ed6b0bc8bba52f (diff)
Save marker selection state in instant.xml (#4203).
git-svn-id: svn://localhost/ardour2/branches/3.0@10245 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/editor.cc71
-rw-r--r--gtk2_ardour/editor.h1
-rw-r--r--gtk2_ardour/editor_markers.cc12
-rw-r--r--gtk2_ardour/public_editor.h3
-rw-r--r--gtk2_ardour/selection.cc25
5 files changed, 79 insertions, 33 deletions
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index 08099c2972..67e89e9e3c 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -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);
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index d2c626cb78..8114559fa8 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -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;
diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc
index 4ccacecbbd..f66b7d02c6 100644
--- a/gtk2_ardour/editor_markers.cc
+++ b/gtk2_ardour/editor_markers.cc
@@ -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;
+}
diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h
index 0a927c5921..f5d7dad522 100644
--- a/gtk2_ardour/public_editor.h
+++ b/gtk2_ardour/public_editor.h
@@ -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;
diff --git a/gtk2_ardour/selection.cc b/gtk2_ardour/selection.cc
index 35998a2a1d..5b7a88c81e 100644
--- a/gtk2_ardour/selection.cc
+++ b/gtk2_ardour/selection.cc
@@ -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;