NO-OP; clean up script spacing and remove goto
[ardour.git] / gtk2_ardour / export_timespan_selector.h
1 /*
2     Copyright (C) 2008 Paul Davis
3     Author: Sakari Bergen
4
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.
9
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.
14
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.
18
19 */
20
21 #ifndef __export_timespan_selector_h__
22 #define __export_timespan_selector_h__
23
24 #include "audio_clock.h"
25
26 #include <list>
27
28 #ifdef interface
29 #undef interface
30 #endif
31
32 #include <gtkmm.h>
33 #include <boost/shared_ptr.hpp>
34
35
36 #include "ardour/types.h"
37 #include "ardour/session_handle.h"
38 #include "ardour/export_profile_manager.h"
39
40 namespace ARDOUR {
41         class Location;
42         class ExportTimespan;
43         class ExportHandler;
44 }
45
46 using ARDOUR::CDMarkerFormat;
47 using ARDOUR::framecnt_t;
48
49 /// Timespan Selector base
50 class ExportTimespanSelector : public Gtk::VBox, public ARDOUR::SessionHandlePtr
51 {
52   protected:
53         typedef std::list<ARDOUR::Location *> LocationList;
54         typedef boost::shared_ptr<ARDOUR::ExportHandler> HandlerPtr;
55         typedef boost::shared_ptr<ARDOUR::ExportProfileManager> ProfileManagerPtr;
56
57         typedef std::list<ARDOUR::ExportTimespanPtr> TimespanList;
58         typedef boost::shared_ptr<TimespanList> TimespanListPtr;
59         typedef ARDOUR::ExportProfileManager::TimespanStatePtr TimespanStatePtr;
60
61   public:
62
63         ExportTimespanSelector (ARDOUR::Session * session, ProfileManagerPtr manager, bool multi);
64
65         virtual ~ExportTimespanSelector ();
66
67         void sync_with_manager ();
68         virtual void allow_realtime_export (bool);
69
70         sigc::signal<void> CriticalSelectionChanged;
71
72   protected:
73
74         ProfileManagerPtr manager;
75         TimespanStatePtr  state;
76         bool _realtime_available;
77
78         virtual void fill_range_list () = 0;
79         virtual void update_timespans () = 0;
80
81         void add_range_to_selection (ARDOUR::Location const * loc, bool rt);
82         void set_time_format_from_state ();
83         void toggle_realtime ();
84
85         void change_time_format ();
86
87         std::string construct_label (ARDOUR::Location const * location) const;
88         std::string construct_length (ARDOUR::Location const * location) const;
89         std::string bbt_str (framepos_t frames) const;
90         std::string timecode_str (framecnt_t frames) const;
91         std::string ms_str (framecnt_t frames) const;
92
93         void update_range_name (std::string const & path, std::string const & new_text);
94
95         void set_selection_state_of_all_timespans (bool);
96         int location_sorter(Gtk::TreeModel::iterator a, Gtk::TreeModel::iterator b);
97
98         /*** GUI components ***/
99
100         Gtk::HBox        option_hbox;
101         Gtk::Label       time_format_label;
102         Gtk::CheckButton realtime_checkbutton;
103
104         /* Time format */
105
106         typedef ARDOUR::ExportProfileManager::TimeFormat TimeFormat;
107
108         struct TimeFormatCols : public Gtk::TreeModelColumnRecord
109         {
110           public:
111                 Gtk::TreeModelColumn<TimeFormat>      format;
112                 Gtk::TreeModelColumn<std::string>   label;
113
114                 TimeFormatCols () { add(format); add(label); }
115         };
116         TimeFormatCols               time_format_cols;
117         Glib::RefPtr<Gtk::ListStore> time_format_list;
118         Gtk::ComboBox                time_format_combo;
119
120         /* View */
121
122         struct RangeCols : public Gtk::TreeModelColumnRecord
123         {
124           public:
125                 Gtk::TreeModelColumn<ARDOUR::Location *>  location;
126                 Gtk::TreeModelColumn<std::string>       label;
127                 Gtk::TreeModelColumn<bool>              selected;
128                 Gtk::TreeModelColumn<bool>              realtime;
129                 Gtk::TreeModelColumn<std::string>       name;
130                 Gtk::TreeModelColumn<std::string>       length;
131
132                 RangeCols () { add (location); add(label); add(selected); add(realtime); add(name); add(length); }
133         };
134         RangeCols                    range_cols;
135
136         Glib::RefPtr<Gtk::ListStore> range_list;
137         Gtk::TreeView                range_view;
138
139         Gtk::ScrolledWindow          range_scroller;
140 };
141
142 /// Allows selecting multiple timespans
143 class ExportTimespanSelectorMultiple : public ExportTimespanSelector
144 {
145   public:
146         ExportTimespanSelectorMultiple (ARDOUR::Session * session, ProfileManagerPtr manager);
147
148         void allow_realtime_export (bool);
149
150   private:
151
152         virtual void fill_range_list ();
153
154         void set_selection_from_state ();
155         void update_selection ();
156         void update_timespans ();
157 };
158
159 /// Displays one timespan
160 class ExportTimespanSelectorSingle : public ExportTimespanSelector
161 {
162   public:
163         ExportTimespanSelectorSingle (ARDOUR::Session * session, ProfileManagerPtr manager, std::string range_id);
164
165         void allow_realtime_export (bool);
166
167   private:
168
169         virtual void fill_range_list ();
170         void update_timespans ();
171
172         std::string range_id;
173
174 };
175
176 #endif /* __export_timespan_selector_h__ */