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"
34 #include <boost/shared_ptr.hpp>
36 #include <gtkmm/box.h>
37 #include <gtkmm/checkbutton.h>
38 #include <gtkmm/combobox.h>
39 #include <gtkmm/label.h>
40 #include <gtkmm/liststore.h>
41 #include <gtkmm/scrolledwindow.h>
42 #include <gtkmm/treemodel.h>
43 #include <gtkmm/treestore.h>
44 #include <gtkmm/treeview.h>
46 #include "ardour/types.h"
47 #include "ardour/session_handle.h"
48 #include "ardour/export_profile_manager.h"
56 using ARDOUR::CDMarkerFormat;
57 using ARDOUR::samplecnt_t;
59 /// Timespan Selector base
60 class ExportTimespanSelector : public Gtk::VBox, public ARDOUR::SessionHandlePtr
63 typedef std::list<ARDOUR::Location *> LocationList;
64 typedef boost::shared_ptr<ARDOUR::ExportHandler> HandlerPtr;
65 typedef boost::shared_ptr<ARDOUR::ExportProfileManager> ProfileManagerPtr;
67 typedef std::list<ARDOUR::ExportTimespanPtr> TimespanList;
68 typedef boost::shared_ptr<TimespanList> TimespanListPtr;
69 typedef ARDOUR::ExportProfileManager::TimespanStatePtr TimespanStatePtr;
73 ExportTimespanSelector (ARDOUR::Session * session, ProfileManagerPtr manager, bool multi);
75 virtual ~ExportTimespanSelector ();
77 void sync_with_manager ();
78 virtual void allow_realtime_export (bool);
80 sigc::signal<void> CriticalSelectionChanged;
84 ProfileManagerPtr manager;
85 TimespanStatePtr state;
86 bool _realtime_available;
88 virtual void fill_range_list () = 0;
89 virtual void update_timespans () = 0;
91 void add_range_to_selection (ARDOUR::Location const * loc, bool rt);
92 void set_time_format_from_state ();
93 void toggle_realtime ();
95 void change_time_format ();
97 std::string construct_label (ARDOUR::Location const * location) const;
98 std::string construct_length (ARDOUR::Location const * location) const;
99 std::string bbt_str (samplepos_t samples) const;
100 std::string timecode_str (samplecnt_t samples) const;
101 std::string ms_str (samplecnt_t samples) const;
103 void update_range_name (std::string const & path, std::string const & new_text);
105 void set_selection_state_of_all_timespans (bool);
106 int location_sorter(Gtk::TreeModel::iterator a, Gtk::TreeModel::iterator b);
108 /*** GUI components ***/
110 Gtk::HBox option_hbox;
111 Gtk::Label time_format_label;
112 Gtk::CheckButton realtime_checkbutton;
116 typedef ARDOUR::ExportProfileManager::TimeFormat TimeFormat;
118 struct TimeFormatCols : public Gtk::TreeModelColumnRecord
121 Gtk::TreeModelColumn<TimeFormat> format;
122 Gtk::TreeModelColumn<std::string> label;
124 TimeFormatCols () { add(format); add(label); }
126 TimeFormatCols time_format_cols;
127 Glib::RefPtr<Gtk::ListStore> time_format_list;
128 Gtk::ComboBox time_format_combo;
132 struct RangeCols : public Gtk::TreeModelColumnRecord
135 Gtk::TreeModelColumn<ARDOUR::Location *> location;
136 Gtk::TreeModelColumn<std::string> label;
137 Gtk::TreeModelColumn<bool> selected;
138 Gtk::TreeModelColumn<bool> realtime;
139 Gtk::TreeModelColumn<std::string> name;
140 Gtk::TreeModelColumn<std::string> length;
141 Gtk::TreeModelColumn<std::string> date;
142 Gtk::TreeModelColumn<time_t> timestamp;
144 RangeCols () { add (location); add(label); add(selected); add(realtime); add(name); add(length); add(date); add(timestamp);}
146 RangeCols range_cols;
148 Glib::RefPtr<Gtk::ListStore> range_list;
149 Gtk::TreeView range_view;
151 Gtk::ScrolledWindow range_scroller;
154 /// Allows selecting multiple timespans
155 class ExportTimespanSelectorMultiple : public ExportTimespanSelector
158 ExportTimespanSelectorMultiple (ARDOUR::Session * session, ProfileManagerPtr manager);
160 void allow_realtime_export (bool);
164 virtual void fill_range_list ();
166 void set_selection_from_state ();
167 void update_selection ();
168 void update_timespans ();
171 /// Displays one timespan
172 class ExportTimespanSelectorSingle : public ExportTimespanSelector
175 ExportTimespanSelectorSingle (ARDOUR::Session * session, ProfileManagerPtr manager, std::string range_id);
177 void allow_realtime_export (bool);
181 virtual void fill_range_list ();
182 void update_timespans ();
184 std::string range_id;
188 #endif /* __export_timespan_selector_h__ */