replace ::cast_dynamic() with relevant ActionManager::get_*_action() calls
[ardour.git] / gtk2_ardour / location_ui.h
1 /*
2     Copyright (C) 1999-2002 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __ardour_location_ui_h__
21 #define __ardour_location_ui_h__
22
23 #include <gtkmm/box.h>
24 #include <gtkmm/checkbutton.h>
25 #include <gtkmm/button.h>
26 #include <gtkmm/table.h>
27 #include <gtkmm/entry.h>
28 #include <gtkmm/label.h>
29 #include <gtkmm/scrolledwindow.h>
30
31 #include "pbd/signals.h"
32
33 #include "ardour/location.h"
34 #include "ardour/session_handle.h"
35
36 #include "widgets/ardour_button.h"
37 #include "widgets/pane.h"
38
39 #include "ardour_window.h"
40 #include "audio_clock.h"
41
42 namespace ARDOUR {
43         class Location;
44 }
45
46 class ClockGroup;
47
48 class LocationEditRow  : public Gtk::HBox, public ARDOUR::SessionHandlePtr
49 {
50 public:
51         LocationEditRow (ARDOUR::Session *sess=0, ARDOUR::Location *loc=0, int32_t num=-1);
52         virtual ~LocationEditRow();
53
54         void set_location (ARDOUR::Location*);
55         ARDOUR::Location * get_location() { return location; }
56
57         void set_session (ARDOUR::Session *);
58
59         void set_number (int);
60         void focus_name();
61         void set_clock_group (ClockGroup&);
62         void unset_clock_group () { _clock_group = 0; }
63
64         sigc::signal<void,ARDOUR::Location*> remove_requested;
65         sigc::signal<void> redraw_ranges;
66
67 protected:
68
69         enum LocationPart {
70                 LocStart,
71                 LocEnd,
72                 LocLength
73         };
74
75         ARDOUR::Location *location;
76
77         Gtk::Table    item_table;
78
79         Gtk::Entry    name_entry;
80         Gtk::Label    name_label;
81         Gtk::Label    number_label;
82
83         Gtk::HBox     start_hbox;
84         AudioClock    start_clock;
85         ArdourWidgets::ArdourButton start_to_playhead_button;
86         ArdourWidgets::ArdourButton locate_to_start_button;
87
88         Gtk::HBox     end_hbox;
89         AudioClock    end_clock;
90         ArdourWidgets::ArdourButton end_to_playhead_button;
91         ArdourWidgets::ArdourButton locate_to_end_button;
92
93         AudioClock    length_clock;
94         Gtk::CheckButton cd_check_button;
95         Gtk::CheckButton hide_check_button;
96         Gtk::CheckButton lock_check_button;
97         Gtk::CheckButton glue_check_button;
98
99         ArdourWidgets::ArdourButton remove_button;
100
101         Gtk::HBox     cd_track_details_hbox;
102         Gtk::Entry    isrc_entry;
103         Gtk::Label    isrc_label;
104
105
106         Gtk::Label    performer_label;
107         Gtk::Entry    performer_entry;
108         Gtk::Label    composer_label;
109         Gtk::Entry    composer_entry;
110         Gtk::CheckButton   scms_check_button;
111         Gtk::Label         scms_label;
112         Gtk::CheckButton   preemph_check_button;
113         Gtk::Label         preemph_label;
114         ClockGroup* _clock_group;
115
116         guint32 i_am_the_modifier;
117         int   number;
118
119         void name_entry_changed ();
120         void isrc_entry_changed ();
121         void performer_entry_changed ();
122         void composer_entry_changed ();
123
124         void to_playhead_button_pressed (LocationPart part);
125         void locate_button_pressed (LocationPart part);
126
127         void clock_changed (LocationPart part);
128         bool locate_to_clock (GdkEventButton*, AudioClock*);
129
130         void cd_toggled ();
131         void hide_toggled ();
132         void lock_toggled ();
133         void glue_toggled ();
134         void remove_button_pressed ();
135
136         void scms_toggled ();
137         void preemph_toggled ();
138
139         void end_changed ();
140         void start_changed ();
141         void name_changed ();
142         void location_changed ();
143         void flags_changed ();
144         void lock_changed ();
145         void position_lock_style_changed ();
146
147         void set_clock_editable_status ();
148         void show_cd_track_details ();
149
150         PBD::ScopedConnectionList connections;
151 };
152
153 class LocationUI : public Gtk::HBox, public ARDOUR::SessionHandlePtr
154 {
155 public:
156         LocationUI (std::string state_node_name = "LocationUI");
157         ~LocationUI ();
158
159         void set_session (ARDOUR::Session *);
160
161         void add_new_location();
162         void add_new_range();
163
164         void refresh_location_list ();
165
166         XMLNode & get_state () const;
167         int set_state (const XMLNode&);
168
169 private:
170         /** set to the location that has just been created with the LocationUI `add' button
171             (if Config->get_name_new_markers() is true); if it is non-0, the name entry of
172             the location is given the focus by location_added().
173         */
174         ARDOUR::Location *newest_location;
175
176         void session_going_away ();
177
178         LocationEditRow      loop_edit_row;
179         LocationEditRow      punch_edit_row;
180         Gtk::VBox loop_punch_box;
181
182         ArdourWidgets::VPane loc_range_panes;
183
184         Gtk::VBox  loc_frame_box;
185         Gtk::Button add_location_button;
186         Gtk::ScrolledWindow  location_rows_scroller;
187         Gtk::VBox            location_rows;
188
189         Gtk::VBox  range_frame_box;
190         Gtk::Button add_range_button;
191         Gtk::ScrolledWindow  range_rows_scroller;
192         Gtk::VBox            range_rows;
193
194         /* When any location changes it start
195            or end points, it sends a signal that is caught
196            by one of these functions
197         */
198
199         void location_remove_requested (ARDOUR::Location *);
200
201         void location_redraw_ranges ();
202
203         gint do_location_remove (ARDOUR::Location *);
204
205         guint32 i_am_the_modifier;
206
207         void location_removed (ARDOUR::Location *);
208         void location_added (ARDOUR::Location *);
209         void map_locations (const ARDOUR::Locations::LocationList&);
210
211         ClockGroup* _clock_group;
212         AudioClock::Mode clock_mode_from_session_instant_xml ();
213
214         AudioClock::Mode _mode;
215         bool _mode_set;
216
217         std::string _state_node_name;
218 };
219
220 class LocationUIWindow : public ArdourWindow
221 {
222 public:
223         LocationUIWindow ();
224         ~LocationUIWindow ();
225
226         void on_map ();
227         void set_session (ARDOUR::Session *);
228
229         LocationUI& ui() { return _ui; }
230
231 protected:
232         LocationUI _ui;
233         bool on_delete_event (GdkEventAny*);
234         void session_going_away();
235 };
236
237 #endif // __ardour_location_ui_h__