e63253af24060760da9fdbb337ad9d3548d3878a
[ardour.git] / gtk2_ardour / route_time_axis.h
1 /*
2     Copyright (C) 2000 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     $Id: audio_time_axis.h 664 2006-07-05 19:47:25Z drobilla $
19 */
20
21 #ifndef __ardour_route_time_axis_h__
22 #define __ardour_route_time_axis_h__
23
24 #include <gtkmm/table.h>
25 #include <gtkmm/button.h>
26 #include <gtkmm/box.h>
27 #include <gtkmm/menu.h>
28 #include <gtkmm/menuitem.h>
29 #include <gtkmm/radiomenuitem.h>
30 #include <gtkmm/checkmenuitem.h>
31
32 #include <gtkmm2ext/selector.h>
33 #include <list>
34
35 #include <ardour/types.h>
36 #include <ardour/region.h>
37
38 #include "ardour_dialog.h"
39 #include "route_ui.h"
40 #include "enums.h"
41 #include "time_axis_view.h"
42 #include "canvas.h"
43 #include "color.h"
44
45 namespace ARDOUR {
46         class Session;
47         class Diskstream;
48         class RouteGroup;
49         class Redirect;
50         class Insert;
51         class Location;
52         class Playlist;
53 }
54
55 class PublicEditor;
56 class RegionView;
57 class StreamView;
58 class Selection;
59 class Selectable;
60 class AutomationLine;
61 class TimeSelection;
62
63 class RouteTimeAxisView : public RouteUI, public TimeAxisView
64 {
65   public:
66         RouteTimeAxisView (PublicEditor&, ARDOUR::Session&, ARDOUR::Route&, ArdourCanvas::Canvas& canvas);
67         virtual ~RouteTimeAxisView ();
68
69         void show_selection (TimeSelection&);
70
71         void set_samples_per_unit (double);
72         void set_height (TimeAxisView::TrackHeight);
73         void show_timestretch (jack_nframes_t start, jack_nframes_t end);
74         void hide_timestretch ();
75         void selection_click (GdkEventButton*);
76         void set_selected_points (PointSelection&);
77         void get_selectables (jack_nframes_t start, jack_nframes_t end, double top, double bot, list<Selectable *>&);
78         void get_inverted_selectables (Selection&, list<Selectable*>&);
79                 
80         ARDOUR::Region* find_next_region (jack_nframes_t pos, ARDOUR::RegionPoint, int32_t dir);
81
82         string name() const;
83
84         ARDOUR::RouteGroup* edit_group() const;
85
86         void build_playlist_menu (Gtk::Menu *);
87         ARDOUR::Playlist* playlist() const;
88
89         StreamView* view() { return _view; }
90
91         /* editing operations */
92         
93         bool cut_copy_clear (Selection&, Editing::CutCopyOp);
94         bool paste (jack_nframes_t, float times, Selection&, size_t nth);
95
96         list<TimeAxisView*> get_child_list();
97
98         /* the editor calls these when mapping an operation across multiple tracks */
99
100         void use_new_playlist (bool prompt);
101         void use_copy_playlist (bool prompt);
102         void clear_playlist ();
103
104   //private:
105         friend class StreamView;
106         
107         StreamView *_view;
108
109         ArdourCanvas::Canvas& parent_canvas;
110
111         bool         no_redraw;
112   
113         Gtk::HBox   other_button_hbox;
114         Gtk::Table  button_table;
115         Gtk::Button redirect_button;
116         Gtk::Button edit_group_button;
117         Gtk::Button playlist_button;
118         Gtk::Button size_button;
119         Gtk::Button automation_button;
120         Gtk::Button hide_button;
121         Gtk::Button visual_button;
122
123         void diskstream_changed (void *src);
124         void update_diskstream_display ();
125         
126         gint edit_click  (GdkEventButton *);
127
128         void build_redirect_window ();
129         void redirect_click ();
130         void redirect_add ();
131         void redirect_remove ();
132         void redirect_edit ();
133         void redirect_relist ();
134         void redirect_row_selected (gint row, gint col, GdkEvent *ev);
135         void add_to_redirect_display (ARDOUR::Redirect *);
136         //void redirects_changed (void *);
137
138         sigc::connection modified_connection;
139         sigc::connection state_changed_connection;
140
141         void take_name_changed (void *);
142         void route_name_changed (void *);
143         void name_entry_changed ();
144
145         void on_area_realize ();
146
147         virtual void label_view ();
148
149         Gtk::Menu edit_group_menu;
150
151         void add_edit_group_menu_item (ARDOUR::RouteGroup *, Gtk::RadioMenuItem::Group*);
152         void set_edit_group_from_menu (ARDOUR::RouteGroup *);
153
154         void reset_samples_per_unit ();
155
156         void select_track_color();
157         
158         virtual void build_display_menu () = 0;
159
160         Gtk::RadioMenuItem* align_existing_item;
161         Gtk::RadioMenuItem* align_capture_item;
162         
163         void align_style_changed ();
164         void set_align_style (ARDOUR::AlignStyle);
165
166         Gtk::Menu     *playlist_menu;
167         Gtk::Menu     *playlist_action_menu;
168         Gtk::MenuItem *playlist_item;
169         
170         /* playlist */
171
172         virtual void set_playlist (ARDOUR::Playlist *);
173         void playlist_click ();
174         void show_playlist_selector ();
175
176         void playlist_changed ();
177         void playlist_state_changed (ARDOUR::Change);
178         void playlist_modified ();
179
180         void add_playlist_to_playlist_menu (ARDOUR::Playlist*);
181         void rename_current_playlist ();
182         
183         Gtk::Menu* automation_action_menu;
184         void automation_click ();
185
186         ArdourCanvas::SimpleRect *timestretch_rect;
187
188         void timestretch (jack_nframes_t start, jack_nframes_t end);
189
190         void visual_click ();
191         void hide_click ();
192         gint when_displayed (GdkEventAny*);
193
194         void speed_changed ();
195         
196         void map_frozen ();
197
198         void color_handler (ColorID, uint32_t);
199         bool select_me (GdkEventButton*);
200         
201         virtual void region_view_added (RegionView*) = 0;
202 };
203
204 #endif /* __ardour_route_time_axis_h__ */
205