2 Copyright (C) 2008 Paul Davis
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 #ifndef __export_timespan_selector_h__
22 #define __export_timespan_selector_h__
24 #include "audio_clock.h"
32 #include <boost/shared_ptr.hpp>
34 #include <gtkmm/box.h>
35 #include <gtkmm/checkbutton.h>
36 #include <gtkmm/combobox.h>
37 #include <gtkmm/label.h>
38 #include <gtkmm/liststore.h>
39 #include <gtkmm/scrolledwindow.h>
40 #include <gtkmm/treemodel.h>
41 #include <gtkmm/treestore.h>
42 #include <gtkmm/treeview.h>
44 #include "ardour/types.h"
45 #include "ardour/session_handle.h"
46 #include "ardour/export_profile_manager.h"
54 using ARDOUR::CDMarkerFormat;
55 using ARDOUR::samplecnt_t;
57 /// Timespan Selector base
58 class ExportTimespanSelector : public Gtk::VBox, public ARDOUR::SessionHandlePtr
61 typedef std::list<ARDOUR::Location *> LocationList;
62 typedef boost::shared_ptr<ARDOUR::ExportHandler> HandlerPtr;
63 typedef boost::shared_ptr<ARDOUR::ExportProfileManager> ProfileManagerPtr;
65 typedef std::list<ARDOUR::ExportTimespanPtr> TimespanList;
66 typedef boost::shared_ptr<TimespanList> TimespanListPtr;
67 typedef ARDOUR::ExportProfileManager::TimespanStatePtr TimespanStatePtr;
71 ExportTimespanSelector (ARDOUR::Session * session, ProfileManagerPtr manager, bool multi);
73 virtual ~ExportTimespanSelector ();
75 void sync_with_manager ();
76 virtual void allow_realtime_export (bool);
78 sigc::signal<void> CriticalSelectionChanged;
82 ProfileManagerPtr manager;
83 TimespanStatePtr state;
84 bool _realtime_available;
86 virtual void fill_range_list () = 0;
87 virtual void update_timespans () = 0;
89 void add_range_to_selection (ARDOUR::Location const * loc, bool rt);
90 void set_time_format_from_state ();
91 void toggle_realtime ();
93 void change_time_format ();
95 std::string construct_label (ARDOUR::Location const * location) const;
96 std::string construct_length (ARDOUR::Location const * location) const;
97 std::string bbt_str (samplepos_t samples) const;
98 std::string timecode_str (samplecnt_t samples) const;
99 std::string ms_str (samplecnt_t samples) const;
101 void update_range_name (std::string const & path, std::string const & new_text);
103 void set_selection_state_of_all_timespans (bool);
104 int location_sorter(Gtk::TreeModel::iterator a, Gtk::TreeModel::iterator b);
106 /*** GUI components ***/
108 Gtk::HBox option_hbox;
109 Gtk::Label time_format_label;
110 Gtk::CheckButton realtime_checkbutton;
114 typedef ARDOUR::ExportProfileManager::TimeFormat TimeFormat;
116 struct TimeFormatCols : public Gtk::TreeModelColumnRecord
119 Gtk::TreeModelColumn<TimeFormat> format;
120 Gtk::TreeModelColumn<std::string> label;
122 TimeFormatCols () { add(format); add(label); }
124 TimeFormatCols time_format_cols;
125 Glib::RefPtr<Gtk::ListStore> time_format_list;
126 Gtk::ComboBox time_format_combo;
130 struct RangeCols : public Gtk::TreeModelColumnRecord
133 Gtk::TreeModelColumn<ARDOUR::Location *> location;
134 Gtk::TreeModelColumn<std::string> label;
135 Gtk::TreeModelColumn<bool> selected;
136 Gtk::TreeModelColumn<bool> realtime;
137 Gtk::TreeModelColumn<std::string> name;
138 Gtk::TreeModelColumn<std::string> length;
140 RangeCols () { add (location); add(label); add(selected); add(realtime); add(name); add(length); }
142 RangeCols range_cols;
144 Glib::RefPtr<Gtk::ListStore> range_list;
145 Gtk::TreeView range_view;
147 Gtk::ScrolledWindow range_scroller;
150 /// Allows selecting multiple timespans
151 class ExportTimespanSelectorMultiple : public ExportTimespanSelector
154 ExportTimespanSelectorMultiple (ARDOUR::Session * session, ProfileManagerPtr manager);
156 void allow_realtime_export (bool);
160 virtual void fill_range_list ();
162 void set_selection_from_state ();
163 void update_selection ();
164 void update_timespans ();
167 /// Displays one timespan
168 class ExportTimespanSelectorSingle : public ExportTimespanSelector
171 ExportTimespanSelectorSingle (ARDOUR::Session * session, ProfileManagerPtr manager, std::string range_id);
173 void allow_realtime_export (bool);
177 virtual void fill_range_list ();
178 void update_timespans ();
180 std::string range_id;
184 #endif /* __export_timespan_selector_h__ */