2 * Copyright (C) 2008-2011 Sakari Bergen <sakari.bergen@beatwaves.net>
3 * Copyright (C) 2008-2017 Paul Davis <paul@linuxaudiosystems.com>
4 * Copyright (C) 2009-2012 David Robillard <d@drobilla.net>
5 * Copyright (C) 2010-2011 Carl Hetherington <carl@carlh.net>
6 * Copyright (C) 2013-2014 Colin Fletcher <colin.m.fletcher@googlemail.com>
7 * Copyright (C) 2016-2017 Robin Gareus <robin@gareus.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #ifndef __export_timespan_selector_h__
25 #define __export_timespan_selector_h__
27 #include "audio_clock.h"
36 #include <boost/shared_ptr.hpp>
38 #include <gtkmm/box.h>
39 #include <gtkmm/checkbutton.h>
40 #include <gtkmm/combobox.h>
41 #include <gtkmm/label.h>
42 #include <gtkmm/liststore.h>
43 #include <gtkmm/scrolledwindow.h>
44 #include <gtkmm/treemodel.h>
45 #include <gtkmm/treestore.h>
46 #include <gtkmm/treeview.h>
48 #include "ardour/export_profile_manager.h"
49 #include "ardour/session_handle.h"
50 #include "ardour/types.h"
58 using ARDOUR::CDMarkerFormat;
59 using ARDOUR::samplecnt_t;
61 /// Timespan Selector base
62 class ExportTimespanSelector : public Gtk::VBox, public ARDOUR::SessionHandlePtr
65 typedef std::list<ARDOUR::Location*> LocationList;
66 typedef boost::shared_ptr<ARDOUR::ExportHandler> HandlerPtr;
67 typedef boost::shared_ptr<ARDOUR::ExportProfileManager> ProfileManagerPtr;
69 typedef std::list<ARDOUR::ExportTimespanPtr> TimespanList;
70 typedef boost::shared_ptr<TimespanList> TimespanListPtr;
71 typedef ARDOUR::ExportProfileManager::TimespanStatePtr TimespanStatePtr;
74 ExportTimespanSelector (ARDOUR::Session* session, ProfileManagerPtr manager, bool multi);
76 virtual ~ExportTimespanSelector ();
78 void sync_with_manager ();
79 virtual void allow_realtime_export (bool);
81 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 {
120 Gtk::TreeModelColumn<TimeFormat> format;
121 Gtk::TreeModelColumn<std::string> label;
129 TimeFormatCols time_format_cols;
130 Glib::RefPtr<Gtk::ListStore> time_format_list;
131 Gtk::ComboBox time_format_combo;
135 struct RangeCols : public Gtk::TreeModelColumnRecord {
137 Gtk::TreeModelColumn<ARDOUR::Location*> location;
138 Gtk::TreeModelColumn<std::string> label;
139 Gtk::TreeModelColumn<bool> selected;
140 Gtk::TreeModelColumn<bool> realtime;
141 Gtk::TreeModelColumn<std::string> name;
142 Gtk::TreeModelColumn<std::string> length;
143 Gtk::TreeModelColumn<std::string> date;
144 Gtk::TreeModelColumn<time_t> timestamp;
145 Gtk::TreeModelColumn<ARDOUR::samplecnt_t> length_actual;
146 Gtk::TreeModelColumn<ARDOUR::samplecnt_t> start;
162 RangeCols range_cols;
164 Glib::RefPtr<Gtk::ListStore> range_list;
165 Gtk::TreeView range_view;
167 Gtk::ScrolledWindow range_scroller;
170 /// Allows selecting multiple timespans
171 class ExportTimespanSelectorMultiple : public ExportTimespanSelector
174 ExportTimespanSelectorMultiple (ARDOUR::Session* session, ProfileManagerPtr manager);
176 void allow_realtime_export (bool);
179 virtual void fill_range_list ();
181 void set_selection_from_state ();
182 void update_selection ();
183 void update_timespans ();
186 /// Displays one timespan
187 class ExportTimespanSelectorSingle : public ExportTimespanSelector
190 ExportTimespanSelectorSingle (ARDOUR::Session* session, ProfileManagerPtr manager, std::string range_id);
192 void allow_realtime_export (bool);
195 virtual void fill_range_list ();
196 void update_timespans ();
198 std::string range_id;
201 #endif /* __export_timespan_selector_h__ */