*** NEW CODING POLICY ***
[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
30 #include "ardour/location.h"
31 #include "ardour/session.h"
32
33 #include "ardour_dialog.h"
34
35 namespace ARDOUR {
36         class LocationStack;
37         class Session;
38         class Location;
39 }
40
41 class LocationEditRow  : public Gtk::HBox
42 {
43   public:
44         LocationEditRow (ARDOUR::Session *sess=0, ARDOUR::Location *loc=0, int32_t num=-1);
45         virtual ~LocationEditRow();
46
47         void set_location (ARDOUR::Location*);
48         ARDOUR::Location * get_location() { return location; }
49
50         void set_session (ARDOUR::Session *);
51
52         void set_number (int);
53         void focus_name();
54         
55         sigc::signal<void,ARDOUR::Location*> remove_requested;  
56         sigc::signal<void> redraw_ranges;  
57
58   protected:
59
60         enum LocationPart {
61                 LocStart,
62                 LocEnd,
63                 LocLength
64         };
65
66         ARDOUR::Location *location;
67         ARDOUR::Session  *session;
68
69         
70         
71         Gtk::Table    item_table;
72         
73         Gtk::Entry    name_entry;
74         Gtk::Label    name_label;
75         Gtk::Label    number_label;
76         
77         Gtk::HBox     start_hbox;
78         Gtk::Button   start_set_button;
79         Gtk::Button   start_go_button;
80         AudioClock    start_clock;
81
82         Gtk::HBox     end_hbox;
83         Gtk::Button   end_set_button;
84         Gtk::Button   end_go_button;
85         AudioClock    end_clock;
86
87         AudioClock    length_clock;
88         Gtk::CheckButton cd_check_button;
89         Gtk::CheckButton hide_check_button;
90
91         Gtk::Button   remove_button;
92
93         Gtk::HBox     cd_track_details_hbox;
94         Gtk::Entry    isrc_entry;
95         Gtk::Label    isrc_label;
96
97
98         Gtk::Label    performer_label;
99         Gtk::Entry  performer_entry;
100         Gtk::Label    composer_label;
101         Gtk::Entry  composer_entry;
102         Gtk::CheckButton   scms_check_button;
103         Gtk::CheckButton   preemph_check_button;
104
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 remove_button_pressed ();
123
124         void scms_toggled ();
125         void preemph_toggled ();
126
127         void end_changed (ARDOUR::Location *);
128         void start_changed (ARDOUR::Location *);
129         void name_changed (ARDOUR::Location *);
130         void location_changed (ARDOUR::Location *);
131         void flags_changed (ARDOUR::Location *, void *src);
132         
133         sigc::connection start_changed_connection;
134         sigc::connection end_changed_connection;
135         sigc::connection name_changed_connection;
136         sigc::connection changed_connection;
137         sigc::connection flags_changed_connection;
138         
139 };
140
141
142 class LocationUI : public ArdourDialog
143 {
144   public:
145         LocationUI ();
146         ~LocationUI ();
147
148         void set_session (ARDOUR::Session *);
149
150         void on_show();
151
152   private:
153         ARDOUR::LocationStack* locations;
154         ARDOUR::Location *newest_location;
155         
156         void session_gone();
157
158         Gtk::VBox  location_vpacker;
159         Gtk::HBox  location_hpacker;
160
161         LocationEditRow      loop_edit_row;
162         LocationEditRow      punch_edit_row;
163         
164         Gtk::VPaned loc_range_panes;
165         
166         Gtk::Frame loc_frame;
167         Gtk::VBox  loc_frame_box;
168         Gtk::Button add_location_button;
169         Gtk::ScrolledWindow  location_rows_scroller;
170         Gtk::VBox            location_rows;
171
172         Gtk::Frame range_frame;
173         Gtk::VBox  range_frame_box;
174         Gtk::Button add_range_button;
175         Gtk::ScrolledWindow  range_rows_scroller;
176         Gtk::VBox            range_rows;
177
178
179         /* When any location changes it start
180            or end points, it sends a signal that is caught
181            by one of these functions
182         */
183
184         void location_remove_requested (ARDOUR::Location *);
185
186         void location_redraw_ranges ();
187
188         gint do_location_remove (ARDOUR::Location *);
189         
190         guint32 i_am_the_modifier;
191
192         void add_new_location();
193         void add_new_range();
194         
195         void refresh_location_list ();
196         void refresh_location_list_s (ARDOUR::Change);
197         void location_removed (ARDOUR::Location *);
198         void location_added (ARDOUR::Location *);
199         void map_locations (ARDOUR::Locations::LocationList&);
200
201   protected:
202         bool on_delete_event (GdkEventAny*);
203 };
204
205 #endif // __ardour_location_ui_h__