return of the location GoTo Button
[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 Location;
42 }
43
44 class ClockGroup;
45
46 class LocationEditRow  : public Gtk::HBox, public ARDOUR::SessionHandlePtr
47 {
48   public:
49         LocationEditRow (ARDOUR::Session *sess=0, ARDOUR::Location *loc=0, int32_t num=-1);
50         virtual ~LocationEditRow();
51
52         void set_location (ARDOUR::Location*);
53         ARDOUR::Location * get_location() { return location; }
54
55         void set_session (ARDOUR::Session *);
56
57         void set_number (int);
58         void focus_name();
59         void set_clock_group (ClockGroup&);
60         void unset_clock_group () { _clock_group = 0; }
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         Gtk::Button   locate_to_start_button;
85
86         Gtk::HBox     end_hbox;
87         AudioClock    end_clock;
88         Gtk::Button   end_to_playhead_button;
89         Gtk::Button   locate_to_end_button;
90
91         AudioClock    length_clock;
92         Gtk::CheckButton cd_check_button;
93         Gtk::CheckButton hide_check_button;
94         Gtk::CheckButton lock_check_button;
95         Gtk::CheckButton glue_check_button;
96
97         Gtk::Button   remove_button;
98
99         Gtk::HBox     cd_track_details_hbox;
100         Gtk::Entry    isrc_entry;
101         Gtk::Label    isrc_label;
102
103
104         Gtk::Label    performer_label;
105         Gtk::Entry    performer_entry;
106         Gtk::Label    composer_label;
107         Gtk::Entry    composer_entry;
108         Gtk::CheckButton   scms_check_button;
109         Gtk::Label         scms_label;
110         Gtk::CheckButton   preemph_check_button;
111         Gtk::Label         preemph_label;
112         ClockGroup* _clock_group;
113
114         guint32 i_am_the_modifier;
115         int   number;
116
117         void name_entry_changed ();
118         void isrc_entry_changed ();
119         void performer_entry_changed ();
120         void composer_entry_changed ();
121
122         void to_playhead_button_pressed (LocationPart part);
123         void locate_button_pressed (LocationPart part);
124
125         void clock_changed (LocationPart part);
126         bool locate_to_clock (GdkEventButton*, AudioClock*);
127
128         void cd_toggled ();
129         void hide_toggled ();
130         void lock_toggled ();
131         void glue_toggled ();
132         void remove_button_pressed ();
133
134         void scms_toggled ();
135         void preemph_toggled ();
136
137         void end_changed ();
138         void start_changed ();
139         void name_changed ();
140         void location_changed ();
141         void flags_changed ();
142         void lock_changed ();
143         void position_lock_style_changed ();
144
145         void set_clock_editable_status ();
146         void show_cd_track_details ();
147
148         PBD::ScopedConnectionList connections;
149 };
150
151 class LocationUI : public Gtk::HBox, public ARDOUR::SessionHandlePtr
152 {
153   public:
154         LocationUI ();
155         ~LocationUI ();
156
157         void set_session (ARDOUR::Session *);
158         void set_clock_mode (AudioClock::Mode);
159
160         void add_new_location();
161         void add_new_range();
162
163         void refresh_location_list ();
164
165         XMLNode & get_state () const;
166
167   private:
168         /** set to the location that has just been created with the LocationUI `add' button
169             (if Config->get_name_new_markers() is true); if it is non-0, the name entry of
170             the location is given the focus by location_added().
171         */
172         ARDOUR::Location *newest_location;
173
174         void session_going_away ();
175
176         LocationEditRow      loop_edit_row;
177         LocationEditRow      punch_edit_row;
178         Gtk::VBox loop_punch_box;
179
180         Gtk::VPaned loc_range_panes;
181
182         Gtk::VBox  loc_frame_box;
183         Gtk::Button add_location_button;
184         Gtk::ScrolledWindow  location_rows_scroller;
185         Gtk::VBox            location_rows;
186
187         Gtk::VBox  range_frame_box;
188         Gtk::Button add_range_button;
189         Gtk::ScrolledWindow  range_rows_scroller;
190         Gtk::VBox            range_rows;
191
192         /* When any location changes it start
193            or end points, it sends a signal that is caught
194            by one of these functions
195         */
196
197         void location_remove_requested (ARDOUR::Location *);
198
199         void location_redraw_ranges ();
200
201         gint do_location_remove (ARDOUR::Location *);
202
203         guint32 i_am_the_modifier;
204
205         void location_removed (ARDOUR::Location *);
206         void location_added (ARDOUR::Location *);
207         void map_locations (const ARDOUR::Locations::LocationList&);
208
209         ClockGroup* _clock_group;
210         AudioClock::Mode clock_mode_from_session_instant_xml () const;
211 };
212
213 class LocationUIWindow : public ArdourWindow
214 {
215   public:
216         LocationUIWindow ();
217         ~LocationUIWindow ();
218
219         void on_map ();
220         void set_session (ARDOUR::Session *);
221
222         LocationUI& ui() { return _ui; }
223
224   protected:
225         LocationUI _ui;
226         bool on_delete_event (GdkEventAny*);
227         void session_going_away();
228 };
229
230 #endif // __ardour_location_ui_h__