Move panner bypass state up to the PannerShell so that it is preserved even when...
[ardour2.git] / libs / ardour / tempo_map_importer.cc
blobb170aea8ea9a2bfb2389f227e383369335aafb4c
1 /*
2 Copyright (C) 2008 Paul Davis
3 Author: Sakari Bergen
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "ardour/tempo_map_importer.h"
23 #include <sstream>
25 #include "ardour/session.h"
26 #include "pbd/failed_constructor.h"
27 #include "pbd/compose.h"
28 #include "pbd/error.h"
30 #include "i18n.h"
32 using namespace std;
33 using namespace PBD;
34 using namespace ARDOUR;
36 /**** Handler ***/
37 TempoMapImportHandler::TempoMapImportHandler (XMLTree const & source, Session & session) :
38 ElementImportHandler (source, session)
40 XMLNode const * root = source.root();
41 XMLNode const * tempo_map;
43 if (!(tempo_map = root->child (X_("TempoMap")))) {
44 throw failed_constructor();
47 elements.push_back (ElementPtr ( new TempoMapImporter (source, session, *tempo_map)));
50 string
51 TempoMapImportHandler::get_info () const
53 return _("Tempo map");
56 /*** TempoMapImporter ***/
57 TempoMapImporter::TempoMapImporter (XMLTree const & source, Session & session, XMLNode const & node) :
58 ElementImporter (source, session),
59 xml_tempo_map (node)
61 name = _("Tempo Map");
64 string
65 TempoMapImporter::get_info () const
67 std::ostringstream oss;
68 unsigned int tempos = 0;
69 unsigned int meters = 0;
70 XMLNodeList children = xml_tempo_map.children();
72 for (XMLNodeIterator it = children.begin(); it != children.end(); it++) {
73 if ((*it)->name() == "Tempo") {
74 tempos++;
75 } else if ((*it)->name() == "Meters") {
76 meters++;
80 // return info
81 oss << _("Tempo marks: ") << tempos << _("\nMeter marks: ") << meters;
83 return oss.str();
86 bool
87 TempoMapImporter::_prepare_move ()
89 // Prompt user for verification
90 boost::optional<bool> replace = Prompt (_("This will replace the current tempo map!\nAre you shure you want to do this?"));
91 return replace.get_value_or (false);
94 void
95 TempoMapImporter::_cancel_move ()
99 void
100 TempoMapImporter::_move ()
102 session.tempo_map().set_state (xml_tempo_map, Stateful::current_state_version);