757b2caad222f9797cb860091791873f8815c792
[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 "public_editor.h"
25 #include "audio_clock.h"
26
27 #include <list>
28
29 #include <gtkmm.h>
30 #include <boost/shared_ptr.hpp>
31
32 #include <ardour/types.h>
33 #include <ardour/export_profile_manager.h>
34
35 namespace ARDOUR {
36         class Location;
37         class ExportTimespan;
38         class ExportHandler;
39         class Session;
40 }
41
42 using ARDOUR::CDMarkerFormat;
43
44 /// 
45 class ExportTimespanSelector : public Gtk::VBox {
46   private:
47
48         typedef std::list<ARDOUR::Location *> LocationList;
49         typedef boost::shared_ptr<ARDOUR::ExportHandler> HandlerPtr;
50
51         typedef boost::shared_ptr<ARDOUR::ExportTimespan> TimespanPtr;
52         typedef std::list<TimespanPtr> TimespanList;
53         typedef boost::shared_ptr<TimespanList> TimespanListPtr;
54
55   public:
56
57         ExportTimespanSelector ();
58         ~ExportTimespanSelector ();
59
60         void set_state (ARDOUR::ExportProfileManager::TimespanStatePtr const state_, ARDOUR::Session * session_);
61         
62         void select_one_range (Glib::ustring id);
63         
64         /* Compatibility with other elements */
65         
66         sigc::signal<void> CriticalSelectionChanged;
67
68   private:
69
70         void fill_range_list ();
71         void set_selection_from_state ();
72
73         void update_selection ();
74         void update_timespans ();
75         
76         void change_time_format ();
77         
78         Glib::ustring construct_label (ARDOUR::Location const * location);
79         
80         Glib::ustring bbt_str (nframes_t frames);
81         Glib::ustring smpte_str (nframes_t frames);
82         Glib::ustring ms_str (nframes_t frames);
83
84         void update_range_name (Glib::ustring const & path, Glib::ustring const & new_text);
85
86         ARDOUR::Session * session;
87         
88         ARDOUR::ExportProfileManager::TimespanStatePtr state;
89
90         /*** GUI components ***/
91         
92         Gtk::HBox      option_hbox;
93         Gtk::Label     time_format_label;
94         
95         /* Time format */
96         
97         typedef ARDOUR::ExportProfileManager::TimeFormat TimeFormat;
98         
99         struct TimeFormatCols : public Gtk::TreeModelColumnRecord
100         {
101           public:
102                 Gtk::TreeModelColumn<TimeFormat>      format;
103                 Gtk::TreeModelColumn<Glib::ustring>   label;
104         
105                 TimeFormatCols () { add(format); add(label); }
106         };
107         TimeFormatCols               time_format_cols;
108         Glib::RefPtr<Gtk::ListStore> time_format_list;
109         Gtk::ComboBox                time_format_combo;
110         
111         /* View */
112         
113         struct RangeCols : public Gtk::TreeModelColumnRecord
114         {
115           public:
116                 Gtk::TreeModelColumn<ARDOUR::Location *>  location;
117                 Gtk::TreeModelColumn<Glib::ustring>       label;
118                 Gtk::TreeModelColumn<bool>                selected;
119                 Gtk::TreeModelColumn<Glib::ustring>       name;
120         
121                 RangeCols () { add (location); add(label); add(selected); add(name); }
122         };
123         RangeCols                    range_cols;
124         
125         Glib::RefPtr<Gtk::ListStore> range_list;
126         Gtk::TreeView                range_view;
127         
128         Gtk::ScrolledWindow          range_scroller;
129
130 };
131
132 #endif /* __export_timespan_selector_h__ */