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