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"
37 #include <boost/shared_ptr.hpp>
39 #include <gtkmm/box.h>
40 #include <gtkmm/checkbutton.h>
41 #include <gtkmm/combobox.h>
42 #include <gtkmm/label.h>
43 #include <gtkmm/liststore.h>
44 #include <gtkmm/scrolledwindow.h>
45 #include <gtkmm/treemodel.h>
46 #include <gtkmm/treestore.h>
47 #include <gtkmm/treeview.h>
49 #include "ardour/types.h"
50 #include "ardour/session_handle.h"
51 #include "ardour/export_profile_manager.h"
59 using ARDOUR::CDMarkerFormat;
60 using ARDOUR::samplecnt_t;
62 /// Timespan Selector base
63 class ExportTimespanSelector : public Gtk::VBox, public ARDOUR::SessionHandlePtr
66 typedef std::list<ARDOUR::Location *> LocationList;
67 typedef boost::shared_ptr<ARDOUR::ExportHandler> HandlerPtr;
68 typedef boost::shared_ptr<ARDOUR::ExportProfileManager> ProfileManagerPtr;
70 typedef std::list<ARDOUR::ExportTimespanPtr> TimespanList;
71 typedef boost::shared_ptr<TimespanList> TimespanListPtr;
72 typedef ARDOUR::ExportProfileManager::TimespanStatePtr TimespanStatePtr;
76 ExportTimespanSelector (ARDOUR::Session * session, ProfileManagerPtr manager, bool multi);
78 virtual ~ExportTimespanSelector ();
80 void sync_with_manager ();
81 virtual void allow_realtime_export (bool);
83 sigc::signal<void> CriticalSelectionChanged;
87 ProfileManagerPtr manager;
88 TimespanStatePtr state;
89 bool _realtime_available;
91 virtual void fill_range_list () = 0;
92 virtual void update_timespans () = 0;
94 void add_range_to_selection (ARDOUR::Location const * loc, bool rt);
95 void set_time_format_from_state ();
96 void toggle_realtime ();
98 void change_time_format ();
100 std::string construct_label (ARDOUR::Location const * location) const;
101 std::string construct_length (ARDOUR::Location const * location) const;
102 std::string bbt_str (samplepos_t samples) const;
103 std::string timecode_str (samplecnt_t samples) const;
104 std::string ms_str (samplecnt_t samples) const;
106 void update_range_name (std::string const & path, std::string const & new_text);
108 void set_selection_state_of_all_timespans (bool);
109 int location_sorter(Gtk::TreeModel::iterator a, Gtk::TreeModel::iterator b);
111 /*** GUI components ***/
113 Gtk::HBox option_hbox;
114 Gtk::Label time_format_label;
115 Gtk::CheckButton realtime_checkbutton;
119 typedef ARDOUR::ExportProfileManager::TimeFormat TimeFormat;
121 struct TimeFormatCols : public Gtk::TreeModelColumnRecord
124 Gtk::TreeModelColumn<TimeFormat> format;
125 Gtk::TreeModelColumn<std::string> label;
127 TimeFormatCols () { add(format); add(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
138 Gtk::TreeModelColumn<ARDOUR::Location *> location;
139 Gtk::TreeModelColumn<std::string> label;
140 Gtk::TreeModelColumn<bool> selected;
141 Gtk::TreeModelColumn<bool> realtime;
142 Gtk::TreeModelColumn<std::string> name;
143 Gtk::TreeModelColumn<std::string> length;
144 Gtk::TreeModelColumn<std::string> date;
145 Gtk::TreeModelColumn<time_t> timestamp;
147 RangeCols () { add (location); add(label); add(selected); add(realtime); add(name); add(length); add(date); add(timestamp);}
149 RangeCols range_cols;
151 Glib::RefPtr<Gtk::ListStore> range_list;
152 Gtk::TreeView range_view;
154 Gtk::ScrolledWindow range_scroller;
157 /// Allows selecting multiple timespans
158 class ExportTimespanSelectorMultiple : public ExportTimespanSelector
161 ExportTimespanSelectorMultiple (ARDOUR::Session * session, ProfileManagerPtr manager);
163 void allow_realtime_export (bool);
167 virtual void fill_range_list ();
169 void set_selection_from_state ();
170 void update_selection ();
171 void update_timespans ();
174 /// Displays one timespan
175 class ExportTimespanSelectorSingle : public ExportTimespanSelector
178 ExportTimespanSelectorSingle (ARDOUR::Session * session, ProfileManagerPtr manager, std::string range_id);
180 void allow_realtime_export (bool);
184 virtual void fill_range_list ();
185 void update_timespans ();
187 std::string range_id;
191 #endif /* __export_timespan_selector_h__ */