Setup clock sensitivity with lock correctly.
[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/paned.h>
30 #include <gtkmm/scrolledwindow.h>
31
32 #include "pbd/signals.h"
33
34 #include "ardour/location.h"
35 #include "ardour/session_handle.h"
36
37 #include "ardour_dialog.h"
38 #include "audio_clock.h"
39
40 namespace ARDOUR {
41         class LocationStack;
42         class Location;
43 }
44
45 class LocationEditRow  : public Gtk::HBox, public ARDOUR::SessionHandlePtr
46 {
47   public:
48         LocationEditRow (ARDOUR::Session *sess=0, ARDOUR::Location *loc=0, int32_t num=-1);
49         virtual ~LocationEditRow();
50
51         void set_location (ARDOUR::Location*);
52         ARDOUR::Location * get_location() { return location; }
53
54         void set_session (ARDOUR::Session *);
55
56         void set_number (int);
57         void focus_name();
58
59         sigc::signal<void,ARDOUR::Location*> remove_requested;
60         sigc::signal<void> redraw_ranges;
61
62   protected:
63
64         enum LocationPart {
65                 LocStart,
66                 LocEnd,
67                 LocLength
68         };
69
70         ARDOUR::Location *location;
71
72         Gtk::Table    item_table;
73
74         Gtk::Entry    name_entry;
75         Gtk::Label    name_label;
76         Gtk::Label    number_label;
77
78         Gtk::HBox     start_hbox;
79         Gtk::Button   start_go_button;
80         AudioClock    start_clock;
81
82         Gtk::HBox     end_hbox;
83         Gtk::Button   end_go_button;
84         AudioClock    end_clock;
85
86         AudioClock    length_clock;
87         Gtk::CheckButton cd_check_button;
88         Gtk::CheckButton hide_check_button;
89         Gtk::CheckButton lock_check_button;
90         Gtk::CheckButton glue_check_button;
91
92         Gtk::Button   remove_button;
93
94         Gtk::HBox     cd_track_details_hbox;
95         Gtk::Entry    isrc_entry;
96         Gtk::Label    isrc_label;
97
98
99         Gtk::Label    performer_label;
100         Gtk::Entry  performer_entry;
101         Gtk::Label    composer_label;
102         Gtk::Entry  composer_entry;
103         Gtk::CheckButton   scms_check_button;
104         Gtk::CheckButton   preemph_check_button;
105
106         guint32 i_am_the_modifier;
107         int   number;
108
109         void name_entry_changed ();
110         void isrc_entry_changed ();
111         void performer_entry_changed ();
112         void composer_entry_changed ();
113
114         void set_button_pressed (LocationPart part);
115         void go_button_pressed (LocationPart part);
116
117         void clock_changed (LocationPart part);
118         void change_aborted (LocationPart part);
119
120         void cd_toggled ();
121         void hide_toggled ();
122         void lock_toggled ();
123         void glue_toggled ();
124         void remove_button_pressed ();
125
126         void scms_toggled ();
127         void preemph_toggled ();
128
129         void end_changed (ARDOUR::Location *);
130         void start_changed (ARDOUR::Location *);
131         void name_changed (ARDOUR::Location *);
132         void location_changed (ARDOUR::Location *);
133         void flags_changed (ARDOUR::Location *, void *src);
134         void lock_changed (ARDOUR::Location *);
135         void position_lock_style_changed (ARDOUR::Location *);
136
137         void set_clock_sensitivity ();
138
139         PBD::ScopedConnectionList connections;
140 };
141
142 class LocationUI : public Gtk::HBox, public ARDOUR::SessionHandlePtr
143 {
144   public:
145         LocationUI ();
146         ~LocationUI ();
147         
148         void set_session (ARDOUR::Session *);
149
150         void add_new_location();
151         void add_new_range();
152
153         void refresh_location_list ();
154
155   private:
156         ARDOUR::LocationStack* locations;
157         ARDOUR::Location *newest_location;
158
159         void session_going_away ();
160
161         Gtk::VBox  location_vpacker;
162
163         LocationEditRow      loop_edit_row;
164         LocationEditRow      punch_edit_row;
165         Gtk::VBox loop_punch_box;
166         Gtk::ScrolledWindow loop_punch_scroller;
167
168         Gtk::VPaned loc_range_panes;
169
170         Gtk::Frame loc_frame;
171         Gtk::VBox  loc_frame_box;
172         Gtk::Button add_location_button;
173         Gtk::ScrolledWindow  location_rows_scroller;
174         Gtk::VBox            location_rows;
175
176         Gtk::Frame range_frame;
177         Gtk::VBox  range_frame_box;
178         Gtk::Button add_range_button;
179         Gtk::ScrolledWindow  range_rows_scroller;
180         Gtk::VBox            range_rows;
181
182         /* When any location changes it start
183            or end points, it sends a signal that is caught
184            by one of these functions
185         */
186
187         void location_remove_requested (ARDOUR::Location *);
188
189         void location_redraw_ranges ();
190
191         gint do_location_remove (ARDOUR::Location *);
192
193         guint32 i_am_the_modifier;
194
195         void location_removed (ARDOUR::Location *);
196         void location_added (ARDOUR::Location *);
197         void locations_changed (ARDOUR::Locations::Change);
198         void map_locations (ARDOUR::Locations::LocationList&);
199 };
200
201 class LocationUIWindow : public ArdourDialog
202 {
203   public:
204         LocationUIWindow ();
205         ~LocationUIWindow ();
206
207         void on_show();
208         void set_session (ARDOUR::Session *);
209
210         LocationUI& ui() { return _ui; }
211
212   protected:
213         LocationUI _ui;
214         bool on_delete_event (GdkEventAny*);
215         void session_going_away();
216 };
217
218 #endif // __ardour_location_ui_h__