added "separate" as a new bindable editor operation; bound to F4 by default; fixed...
[ardour.git] / gtk2_ardour / editor_actions.cc
1 /*
2     Copyright (C) 2000-2007 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 #include <ardour/ardour.h>
21
22 #include "utils.h"
23 #include "editor.h"
24 #include "editing.h"
25 #include "actions.h"
26 #include "ardour_ui.h"
27 #include "gui_thread.h"
28 #include "i18n.h"
29
30 using namespace Gtk;
31 using namespace Glib;
32 using namespace std;
33 using namespace sigc;
34 using namespace ARDOUR;
35 using namespace PBD;
36 using namespace Editing;
37
38 void
39 Editor::register_actions ()
40 {
41         RefPtr<Action> act;
42
43         editor_actions = ActionGroup::create (X_("Editor"));
44         
45         /* non-operative menu items for menu bar */
46
47         ActionManager::register_action (editor_actions, X_("Edit"), _("Edit"));
48         ActionManager::register_action (editor_actions, X_("Select"), _("Select"));
49         ActionManager::register_action (editor_actions, X_("EditSelectRegionOptions"), _("Select Regions"));
50         ActionManager::register_action (editor_actions, X_("EditSelectRangeOptions"), _("Select Range Operations"));
51         ActionManager::register_action (editor_actions, X_("EditCursorMovementOptions"), _("Move Selected Marker"));
52         ActionManager::register_action (editor_actions, X_("RegionEditOps"), _("Region operations"));
53         ActionManager::register_action (editor_actions, X_("Tools"), _("Tools"));
54         ActionManager::register_action (editor_actions, X_("View"), _("View"));
55         ActionManager::register_action (editor_actions, X_("ZoomFocus"), _("ZoomFocus"));
56         ActionManager::register_action (editor_actions, X_("MeterHold"), _("Meter hold"));
57         ActionManager::register_action (editor_actions, X_("MeterFalloff"), _("Meter falloff"));
58         ActionManager::register_action (editor_actions, X_("Solo"), _("Solo"));
59         ActionManager::register_action (editor_actions, X_("Crossfades"), _("Crossfades"));
60         ActionManager::register_action (editor_actions, X_("Monitoring"), _("Monitoring"));
61         ActionManager::register_action (editor_actions, X_("Autoconnect"), _("Autoconnect"));
62         ActionManager::register_action (editor_actions, X_("Layering"), _("Layering"));
63         ActionManager::register_action (editor_actions, X_("Timecode"), _("Timecode fps"));
64         ActionManager::register_action (editor_actions, X_("Pullup"), _("Pullup / Pulldown"));
65         ActionManager::register_action (editor_actions, X_("Subframes"), _("Subframes"));
66
67         /* add named actions for the editor */
68
69
70         act = ActionManager::register_toggle_action (editor_actions, "show-editor-mixer", _("Show Editor Mixer"), mem_fun (*this, &Editor::editor_mixer_button_toggled));
71         ActionManager::session_sensitive_actions.push_back (act);
72
73         RadioAction::Group crossfade_model_group;
74
75         act = ActionManager::register_radio_action (editor_actions, crossfade_model_group, "CrossfadesFull", _("Span Entire Overlap"), bind (mem_fun(*this, &Editor::set_crossfade_model), FullCrossfade));
76         ActionManager::session_sensitive_actions.push_back (act);
77         act = ActionManager::register_radio_action (editor_actions, crossfade_model_group, "CrossfadesShort", _("Short"), bind (mem_fun(*this, &Editor::set_crossfade_model), ShortCrossfade));
78         ActionManager::session_sensitive_actions.push_back (act);
79
80         act = ActionManager::register_toggle_action (editor_actions, "toggle-xfades-active", _("Active"), mem_fun(*this, &Editor::toggle_xfades_active));
81         ActionManager::session_sensitive_actions.push_back (act);
82         act = ActionManager::register_toggle_action (editor_actions, "toggle-xfades-visible", _("Show"), mem_fun(*this, &Editor::toggle_xfade_visibility));
83         ActionManager::session_sensitive_actions.push_back (act);
84         act = ActionManager::register_toggle_action (editor_actions, "toggle-auto-xfades", _("Created Automatically"), mem_fun(*this, &Editor::toggle_auto_xfade));
85         ActionManager::session_sensitive_actions.push_back (act);
86
87         act = ActionManager::register_action (editor_actions, "playhead-to-next-region-start", _("Playhead to Next Region Start"), bind (mem_fun(*this, &Editor::cursor_to_next_region_point), playhead_cursor, RegionPoint (Start)));
88         ActionManager::session_sensitive_actions.push_back (act);
89         act = ActionManager::register_action (editor_actions, "playhead-to-next-region-end", _("Playhead to Next Region End"), bind (mem_fun(*this, &Editor::cursor_to_next_region_point), playhead_cursor, RegionPoint (End)));
90         ActionManager::session_sensitive_actions.push_back (act);
91         act = ActionManager::register_action (editor_actions, "playhead-to-next-region-sync", _("Playhead to Next Region Sync"), bind (mem_fun(*this, &Editor::cursor_to_next_region_point), playhead_cursor, RegionPoint (SyncPoint)));
92         ActionManager::session_sensitive_actions.push_back (act);
93
94         act = ActionManager::register_action (editor_actions, "playhead-to-previous-region-start", _("Playhead to Previous Region Start"), bind (mem_fun(*this, &Editor::cursor_to_previous_region_point), playhead_cursor, RegionPoint (Start)));
95         ActionManager::session_sensitive_actions.push_back (act);
96         act = ActionManager::register_action (editor_actions, "playhead-to-previous-region-end", _("Playhead to Previous Region End"), bind (mem_fun(*this, &Editor::cursor_to_previous_region_point), playhead_cursor, RegionPoint (End)));
97         ActionManager::session_sensitive_actions.push_back (act);
98         act = ActionManager::register_action (editor_actions, "playhead-to-previous-region-sync", _("Playhead to Previous Region Sync"), bind (mem_fun(*this, &Editor::cursor_to_previous_region_point), playhead_cursor, RegionPoint (SyncPoint)));
99         ActionManager::session_sensitive_actions.push_back (act);
100
101         act = ActionManager::register_action (editor_actions, "edit-cursor-to-next-region-start", _("Edit Cursor to Next Region Start"), bind (mem_fun(*this, &Editor::edit_point_to_next_region_point), RegionPoint (Start)));
102         ActionManager::session_sensitive_actions.push_back (act);
103         act = ActionManager::register_action (editor_actions, "edit-cursor-to-next-region-end", _("Edit Cursor to Next Region End"), bind (mem_fun(*this, &Editor::edit_point_to_next_region_point), RegionPoint (End)));
104         ActionManager::session_sensitive_actions.push_back (act);
105         act = ActionManager::register_action (editor_actions, "edit-cursor-to-next-region-sync", _("Edit Cursor to Next Region Sync"), bind (mem_fun(*this, &Editor::edit_point_to_next_region_point), RegionPoint (SyncPoint)));
106         ActionManager::session_sensitive_actions.push_back (act);
107
108         act = ActionManager::register_action (editor_actions, "edit-cursor-to-previous-region-start", _("Edit Cursor to Previous Region Start"), bind (mem_fun(*this, &Editor::edit_point_to_previous_region_point), RegionPoint (Start)));
109         ActionManager::session_sensitive_actions.push_back (act);
110         act = ActionManager::register_action (editor_actions, "edit-cursor-to-previous-region-end", _("Edit Cursor to Previous Region End"), bind (mem_fun(*this, &Editor::edit_point_to_previous_region_point), RegionPoint (End)));
111         ActionManager::session_sensitive_actions.push_back (act);
112         act = ActionManager::register_action (editor_actions, "edit-cursor-to-previous-region-sync", _("Edit Cursor to Previous Region Sync"), bind (mem_fun(*this, &Editor::edit_point_to_previous_region_point), RegionPoint (SyncPoint)));
113         ActionManager::session_sensitive_actions.push_back (act);
114
115         act = ActionManager::register_action (editor_actions, "edit-cursor-to-range-start", _("Edit Cursor to Range Start"), mem_fun(*this, &Editor::edit_point_to_selection_start));
116         ActionManager::session_sensitive_actions.push_back (act);
117         act = ActionManager::register_action (editor_actions, "edit-cursor-to-range-end", _("Edit Cursor to Range End"), mem_fun(*this, &Editor::edit_point_to_selection_end));
118         ActionManager::session_sensitive_actions.push_back (act);
119
120         act = ActionManager::register_action (editor_actions, "playhead-to-range-start", _("Playhead to Range Start"), bind (mem_fun(*this, &Editor::cursor_to_selection_start), playhead_cursor));
121         ActionManager::session_sensitive_actions.push_back (act);
122         act = ActionManager::register_action (editor_actions, "playhead-to-range-end", _("Playhead to Range End"), bind (mem_fun(*this, &Editor::cursor_to_selection_end), playhead_cursor));
123         ActionManager::session_sensitive_actions.push_back (act);
124
125         act = ActionManager::register_action (editor_actions, "select-all", _("select all"), bind (mem_fun(*this, &Editor::select_all), Selection::Set));
126         ActionManager::session_sensitive_actions.push_back (act);
127         act = ActionManager::register_action (editor_actions, "select-all-after-edit-cursor", _("Select All After Edit Cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_edit), true));
128         ActionManager::session_sensitive_actions.push_back (act);
129         act = ActionManager::register_action (editor_actions, "select-all-before-edit-cursor", _("Select All Before Edit Cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_edit), false));
130         ActionManager::session_sensitive_actions.push_back (act);
131
132         act = ActionManager::register_action (editor_actions, "select-all-after-playhead", _("Select All After Playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true));
133         ActionManager::session_sensitive_actions.push_back (act);
134         act = ActionManager::register_action (editor_actions, "select-all-before-playhead", _("Select All Before Playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false));
135         ActionManager::session_sensitive_actions.push_back (act);
136         act = ActionManager::register_action (editor_actions, "select-all-between-cursors", _("Select All Between Playhead & Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_between), false));
137         ActionManager::session_sensitive_actions.push_back (act);
138         act = ActionManager::register_action (editor_actions, "select-all-within-cursors", _("Select All Between Playhead & Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_between), true));
139         ActionManager::session_sensitive_actions.push_back (act);
140
141         act = ActionManager::register_action (editor_actions, "select-range-between-cursors", _("Select Range Between Playhead & Edit Point"), mem_fun(*this, &Editor::select_range_between));
142         ActionManager::session_sensitive_actions.push_back (act);
143
144         act = ActionManager::register_action (editor_actions, "select-all-in-punch-range", _("Select All in Punch Range"), mem_fun(*this, &Editor::select_all_selectables_using_punch));
145         ActionManager::session_sensitive_actions.push_back (act);
146         act = ActionManager::register_action (editor_actions, "select-all-in-loop-range", _("Select All in Loop Range"), mem_fun(*this, &Editor::select_all_selectables_using_loop));
147         ActionManager::session_sensitive_actions.push_back (act);
148
149         act = ActionManager::register_action (editor_actions, "jump-forward-to-mark", _("Jump Forward to Mark"), mem_fun(*this, &Editor::jump_forward_to_mark));
150         ActionManager::session_sensitive_actions.push_back (act);
151         act = ActionManager::register_action (editor_actions, "jump-backward-to-mark", _("Jump Backward to Mark"), mem_fun(*this, &Editor::jump_backward_to_mark));
152         ActionManager::session_sensitive_actions.push_back (act);
153         act = ActionManager::register_action (editor_actions, "add-location-from-playhead", _("Add Mark from Playhead"), mem_fun(*this, &Editor::add_location_from_playhead_cursor));
154         ActionManager::session_sensitive_actions.push_back (act);
155
156         act = ActionManager::register_action (editor_actions, "nudge-forward", _("Nudge Forward"), bind (mem_fun(*this, &Editor::nudge_forward), false));
157         ActionManager::session_sensitive_actions.push_back (act);
158         act = ActionManager::register_action (editor_actions, "nudge-next-forward", _("Nudge Next Forward"), bind (mem_fun(*this, &Editor::nudge_forward), true));
159         ActionManager::session_sensitive_actions.push_back (act);
160         act = ActionManager::register_action (editor_actions, "nudge-backward", _("Nudge Backward"), bind (mem_fun(*this, &Editor::nudge_backward), false));
161         ActionManager::session_sensitive_actions.push_back (act);
162         act = ActionManager::register_action (editor_actions, "nudge-next-backward", _("Nudge Next Backward"), bind (mem_fun(*this, &Editor::nudge_backward), true));
163         ActionManager::session_sensitive_actions.push_back (act);
164
165         act = ActionManager::register_action (editor_actions, "temporal-zoom-out", _("Zoom Out"), bind (mem_fun(*this, &Editor::temporal_zoom_step), true));
166         ActionManager::session_sensitive_actions.push_back (act);
167         act = ActionManager::register_action (editor_actions, "temporal-zoom-in", _("Zoom In"), bind (mem_fun(*this, &Editor::temporal_zoom_step), false));
168         ActionManager::session_sensitive_actions.push_back (act);
169         act = ActionManager::register_action (editor_actions, "zoom-to-session", _("Zoom to Session"), mem_fun(*this, &Editor::temporal_zoom_session));
170         ActionManager::session_sensitive_actions.push_back (act);
171
172         act = ActionManager::register_action (editor_actions, "scroll-tracks-up", _("Scroll Tracks Up"), mem_fun(*this, &Editor::scroll_tracks_up));
173         ActionManager::session_sensitive_actions.push_back (act);
174         act = ActionManager::register_action (editor_actions, "scroll-tracks-down", _("Scroll Tracks Down"), mem_fun(*this, &Editor::scroll_tracks_down));
175         ActionManager::session_sensitive_actions.push_back (act);
176         act = ActionManager::register_action (editor_actions, "step-tracks-up", _("Step Tracks Up"), mem_fun(*this, &Editor::scroll_tracks_up_line));
177         ActionManager::session_sensitive_actions.push_back (act);
178         act = ActionManager::register_action (editor_actions, "step-tracks-down", _("Step Tracks Down"), mem_fun(*this, &Editor::scroll_tracks_down_line));
179         ActionManager::session_sensitive_actions.push_back (act);
180
181         act = ActionManager::register_action (editor_actions, "scroll-backward", _("Scroll Backward"), bind (mem_fun(*this, &Editor::scroll_backward), 0.8f));
182         ActionManager::session_sensitive_actions.push_back (act);
183         act = ActionManager::register_action (editor_actions, "scroll-forward", _("Scroll Forward"), bind (mem_fun(*this, &Editor::scroll_forward), 0.8f));
184         ActionManager::session_sensitive_actions.push_back (act);
185         act = ActionManager::register_action (editor_actions, "goto", _("goto"), mem_fun(*this, &Editor::goto_frame));
186         ActionManager::session_sensitive_actions.push_back (act);
187         act = ActionManager::register_action (editor_actions, "center-playhead", _("Center Playhead"), mem_fun(*this, &Editor::center_playhead));
188         ActionManager::session_sensitive_actions.push_back (act);
189         act = ActionManager::register_action (editor_actions, "center-edit-cursor", _("Center Edit Point"), mem_fun(*this, &Editor::center_edit_point));
190         ActionManager::session_sensitive_actions.push_back (act);
191
192         act = ActionManager::register_action (editor_actions, "scroll-playhead-forward", _("Playhead forward"), bind (mem_fun(*this, &Editor::scroll_playhead), true));;
193         ActionManager::session_sensitive_actions.push_back (act);
194         act = ActionManager::register_action (editor_actions, "scroll-playhead-backward", _("Playhead Backward"), bind (mem_fun(*this, &Editor::scroll_playhead), false));
195         ActionManager::session_sensitive_actions.push_back (act);
196
197         act = ActionManager::register_action (editor_actions, "playhead-to-edit", _("Playhead to Edit"), bind (mem_fun(*this, &Editor::cursor_align), true));
198         ActionManager::session_sensitive_actions.push_back (act);
199         act = ActionManager::register_action (editor_actions, "edit-to-playhead", _("Edit to Playhead"), bind (mem_fun(*this, &Editor::cursor_align), false));
200         ActionManager::session_sensitive_actions.push_back (act);
201
202
203         act = ActionManager::register_action (editor_actions, "trim-from-start", _("Start to edit point"), mem_fun(*this, &Editor::trim_region_from_edit_point));
204         ActionManager::session_sensitive_actions.push_back (act);
205         act = ActionManager::register_action (editor_actions, "trim-to-end", _("Edit point to end"), mem_fun(*this, &Editor::trim_region_to_edit_point));
206         ActionManager::session_sensitive_actions.push_back (act);
207         act = ActionManager::register_action (editor_actions, "trim-region-to-loop", _("Trim To Loop"), mem_fun(*this, &Editor::trim_region_to_loop));
208         ActionManager::session_sensitive_actions.push_back (act);
209         act = ActionManager::register_action (editor_actions, "trim-region-to-punch", _("Trim To Punch"), mem_fun(*this, &Editor::trim_region_to_punch));
210         ActionManager::session_sensitive_actions.push_back (act);
211         
212         act = ActionManager::register_action (editor_actions, "set-fade-in-length", _("Set Fade In Length"), bind (mem_fun(*this, &Editor::set_fade_length), true));
213         ActionManager::session_sensitive_actions.push_back (act);
214         act = ActionManager::register_action (editor_actions, "set-fade-out-length", _("Set Fade Out Length"), bind (mem_fun(*this, &Editor::set_fade_length), false));
215         ActionManager::session_sensitive_actions.push_back (act);
216
217         act = ActionManager::register_action (editor_actions, "align-regions-start", _("Align Regions Start"), bind (mem_fun(*this, &Editor::align), ARDOUR::Start));
218         ActionManager::session_sensitive_actions.push_back (act);
219         act = ActionManager::register_action (editor_actions, "align-regions-start-relative", _("Align Regions Start Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::Start));
220         ActionManager::session_sensitive_actions.push_back (act);
221         act = ActionManager::register_action (editor_actions, "align-regions-end", _("Align Regions End"), bind (mem_fun(*this, &Editor::align), ARDOUR::End));
222         ActionManager::session_sensitive_actions.push_back (act);
223         act = ActionManager::register_action (editor_actions, "align-regions-end-relative", _("Align Regions End Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::End));
224         ActionManager::session_sensitive_actions.push_back (act);
225
226         act = ActionManager::register_action (editor_actions, "align-regions-sync", _("Align Regions Sync"), bind (mem_fun(*this, &Editor::align), ARDOUR::SyncPoint));
227         ActionManager::session_sensitive_actions.push_back (act);
228         act = ActionManager::register_action (editor_actions, "align-regions-sync-relative", _("Align Regions Sync Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::SyncPoint));
229         ActionManager::session_sensitive_actions.push_back (act);
230         
231         act = ActionManager::register_action (editor_actions, "audition-at-mouse", _("Audition at Mouse"), mem_fun(*this, &Editor::kbd_audition));
232         ActionManager::session_sensitive_actions.push_back (act);
233         act = ActionManager::register_action (editor_actions, "brush-at-mouse", _("Brush at Mouse"), mem_fun(*this, &Editor::kbd_brush));
234         ActionManager::session_sensitive_actions.push_back (act);
235         act = ActionManager::register_action (editor_actions, "mute-unmute-region", _("Mute/Unmute Region"), mem_fun(*this, &Editor::kbd_mute_unmute_region));
236         ActionManager::session_sensitive_actions.push_back (act);
237         act = ActionManager::register_action (editor_actions, "set-region-sync-position", _("Set Region Sync Position"), mem_fun(*this, &Editor::kbd_set_sync_position));
238         ActionManager::session_sensitive_actions.push_back (act);
239
240         act = ActionManager::register_action (editor_actions, "set-playhead", _("Set Playhead"), mem_fun(*this, &Editor::set_playhead_cursor));
241         ActionManager::session_sensitive_actions.push_back (act);
242         act = ActionManager::register_action (editor_actions, "set-edit-point", _("Set Edit Point"), mem_fun(*this, &Editor::set_edit_point));
243         ActionManager::session_sensitive_actions.push_back (act);
244         act = ActionManager::register_action (editor_actions, "split-region", _("Split Region"), mem_fun(*this, &Editor::split));
245         ActionManager::session_sensitive_actions.push_back (act);
246
247         undo_action = act = ActionManager::register_action (editor_actions, "undo", _("Undo"), bind (mem_fun(*this, &Editor::undo), 1U));
248         ActionManager::session_sensitive_actions.push_back (act);
249         redo_action = act = ActionManager::register_action (editor_actions, "redo", _("Redo"), bind (mem_fun(*this, &Editor::redo), 1U));
250         ActionManager::session_sensitive_actions.push_back (act);
251
252         act = ActionManager::register_action (editor_actions, "export-session", _("Export Session"), mem_fun(*this, &Editor::export_session));
253         ActionManager::session_sensitive_actions.push_back (act);
254         act = ActionManager::register_action (editor_actions, "export-range", _("Export Range"), mem_fun(*this, &Editor::export_selection));
255         ActionManager::session_sensitive_actions.push_back (act);
256
257         act = ActionManager::register_action (editor_actions, "editor-separate", _("Separate"), mem_fun(*this, &Editor::separate_region_from_selection));
258         ActionManager::session_sensitive_actions.push_back (act);
259         act = ActionManager::register_action (editor_actions, "editor-cut", _("Cut"), mem_fun(*this, &Editor::cut));
260         ActionManager::session_sensitive_actions.push_back (act);
261         /* Note: for now, editor-delete does the exact same thing as editor-cut */
262         act = ActionManager::register_action (editor_actions, "editor-delete", _("Delete"), mem_fun(*this, &Editor::cut));
263         ActionManager::session_sensitive_actions.push_back (act);
264         act = ActionManager::register_action (editor_actions, "editor-copy", _("Copy"), mem_fun(*this, &Editor::copy));
265         ActionManager::session_sensitive_actions.push_back (act);
266         act = ActionManager::register_action (editor_actions, "editor-paste", _("Paste"), mem_fun(*this, &Editor::keyboard_paste));
267         ActionManager::session_sensitive_actions.push_back (act);
268         act = ActionManager::register_action (editor_actions, "duplicate-region", _("Duplicate Region"), mem_fun(*this, &Editor::keyboard_duplicate_region));
269         ActionManager::session_sensitive_actions.push_back (act);
270         act = ActionManager::register_action (editor_actions, "duplicate-range", _("Duplicate Range"), mem_fun(*this, &Editor::keyboard_duplicate_selection));
271         ActionManager::session_sensitive_actions.push_back (act);
272         act = ActionManager::register_action (editor_actions, "insert-region", _("Insert Region"), mem_fun(*this, &Editor::keyboard_insert_region_list_selection));
273         ActionManager::session_sensitive_actions.push_back (act);
274         act = ActionManager::register_action (editor_actions, "reverse-region", _("Reverse Region"), mem_fun(*this, &Editor::reverse_region));
275         ActionManager::session_sensitive_actions.push_back (act);
276         act = ActionManager::register_action (editor_actions, "normalize-region", _("Normalize Region"), mem_fun(*this, &Editor::normalize_region));
277         ActionManager::session_sensitive_actions.push_back (act);
278         act = ActionManager::register_action (editor_actions, "crop", _("Crop"), mem_fun(*this, &Editor::crop_region_to_selection));
279         ActionManager::session_sensitive_actions.push_back (act);
280         act = ActionManager::register_action (editor_actions, "insert-chunk", _("Insert Chunk"), bind (mem_fun(*this, &Editor::paste_named_selection), 1.0f));
281         ActionManager::session_sensitive_actions.push_back (act);
282
283         act = ActionManager::register_action (editor_actions, "split-at-edit-cursor", _("Split At Edit Point"), mem_fun(*this, &Editor::split_region));
284         ActionManager::edit_point_in_region_sensitive_actions.push_back (act);
285
286         act = ActionManager::register_action (editor_actions, "start-range", _("Start Range"), mem_fun(*this, &Editor::keyboard_selection_begin));
287         ActionManager::session_sensitive_actions.push_back (act);
288         act = ActionManager::register_action (editor_actions, "finish-range", _("Finish Range"), bind (mem_fun(*this, &Editor::keyboard_selection_finish), false));
289         ActionManager::session_sensitive_actions.push_back (act);
290         act = ActionManager::register_action (editor_actions, "finish-add-range", _("Finish add Range"), bind (mem_fun(*this, &Editor::keyboard_selection_finish), true));
291         ActionManager::session_sensitive_actions.push_back (act);
292
293         act = ActionManager::register_action (editor_actions, "extend-range-to-end-of-region", _("Extend Range to End of Region"), bind (mem_fun(*this, &Editor::extend_selection_to_end_of_region), false));
294         ActionManager::session_sensitive_actions.push_back (act);
295         act = ActionManager::register_action (editor_actions, "extend-range-to-start-of-region", _("Extend Range to Start of Region"), bind (mem_fun(*this, &Editor::extend_selection_to_start_of_region), false));
296         ActionManager::session_sensitive_actions.push_back (act);
297
298         act = ActionManager::register_toggle_action (editor_actions, "toggle-follow-playhead", _("Follow Playhead"), (mem_fun(*this, &Editor::toggle_follow_playhead)));
299         ActionManager::session_sensitive_actions.push_back (act);
300         act = ActionManager::register_action (editor_actions, "remove-last-capture", _("Remove Last Capture"), (mem_fun(*this, &Editor::remove_last_capture)));
301         ActionManager::session_sensitive_actions.push_back (act);
302
303         Glib::RefPtr<ActionGroup> zoom_actions = ActionGroup::create (X_("Zoom"));
304         RadioAction::Group zoom_group;
305
306         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-left", _("Zoom Focus Left"), bind (mem_fun(*this, &Editor::zoom_focus_chosen), Editing::ZoomFocusLeft));
307         ActionManager::session_sensitive_actions.push_back (act);
308         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-right", _("Zoom Focus Right"), bind (mem_fun(*this, &Editor::zoom_focus_chosen), Editing::ZoomFocusRight));
309         ActionManager::session_sensitive_actions.push_back (act);
310         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-center", _("Zoom Focus Center"), bind (mem_fun(*this, &Editor::zoom_focus_chosen), Editing::ZoomFocusCenter));
311         ActionManager::session_sensitive_actions.push_back (act);
312         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-playhead", _("Zoom Focus Playhead"), bind (mem_fun(*this, &Editor::zoom_focus_chosen), Editing::ZoomFocusPlayhead));
313         ActionManager::session_sensitive_actions.push_back (act);
314         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-mouse", _("Zoom Focus Mouse"), bind (mem_fun(*this, &Editor::zoom_focus_chosen), Editing::ZoomFocusMouse));
315         ActionManager::session_sensitive_actions.push_back (act);
316         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-edit", _("Zoom Focus Edit"), bind (mem_fun(*this, &Editor::zoom_focus_chosen), Editing::ZoomFocusEdit));
317         ActionManager::session_sensitive_actions.push_back (act);
318
319         Glib::RefPtr<ActionGroup> mouse_mode_actions = ActionGroup::create (X_("MouseMode"));
320         RadioAction::Group mouse_mode_group;
321
322         ActionManager::register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-object", _("Object Tool"), bind (mem_fun(*this, &Editor::set_mouse_mode), Editing::MouseObject, false));
323         ActionManager::register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-range", _("Range Tool"), bind (mem_fun(*this, &Editor::set_mouse_mode), Editing::MouseRange, false));
324         ActionManager::register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-gain", _("Gain Tool"), bind (mem_fun(*this, &Editor::set_mouse_mode), Editing::MouseGain, false));
325         ActionManager::register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-zoom", _("Zoom Tool"), bind (mem_fun(*this, &Editor::set_mouse_mode), Editing::MouseZoom, false));
326         ActionManager::register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-timefx", _("Timefx Tool"), bind (mem_fun(*this, &Editor::set_mouse_mode), Editing::MouseTimeFX, false));
327
328         RadioAction::Group edit_point_group;
329         ActionManager::register_radio_action (editor_actions, edit_point_group, X_("edit-at-playhead"), _("Playhead"), (bind (mem_fun(*this, &Editor::edit_point_chosen), Editing::EditAtPlayhead)));
330         ActionManager::register_radio_action (editor_actions, edit_point_group, X_("edit-at-mouse"), _("Mouse"), (bind (mem_fun(*this, &Editor::edit_point_chosen), Editing::EditAtPlayhead)));
331         ActionManager::register_radio_action (editor_actions, edit_point_group, X_("edit-at-selected-marker"), _("Marker"), (bind (mem_fun(*this, &Editor::edit_point_chosen), Editing::EditAtPlayhead)));
332
333         ActionManager::register_action (editor_actions, X_("SnapTo"), _("Snap To"));
334         ActionManager::register_action (editor_actions, X_("SnapMode"), _("Snap Mode"));
335
336         RadioAction::Group snap_mode_group;
337         ActionManager::register_radio_action (editor_actions, snap_mode_group, X_("snap-normal"), _("Normal"), (bind (mem_fun(*this, &Editor::snap_mode_chosen), Editing::SnapNormal)));
338         ActionManager::register_radio_action (editor_actions, snap_mode_group, X_("snap-magnetic"), _("Magnetic"), (bind (mem_fun(*this, &Editor::snap_mode_chosen), Editing::SnapMagnetic)));
339
340         Glib::RefPtr<ActionGroup> snap_actions = ActionGroup::create (X_("Snap"));
341         RadioAction::Group snap_choice_group;
342
343         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-frame"), _("Snap to frame"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToFrame)));
344         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-cd-frame"), _("Snap to cd frame"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToCDFrame)));
345         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-smpte-frame"), _("Snap to SMPTE frame"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToSMPTEFrame)));
346         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-smpte-seconds"), _("Snap to SMPTE seconds"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToSMPTESeconds)));
347         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-smpte-minutes"), _("Snap to SMPTE minutes"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToSMPTEMinutes)));
348         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-seconds"), _("Snap to seconds"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToSeconds)));
349         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-minutes"), _("Snap to minutes"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToMinutes)));
350         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-thirtyseconds"), _("Snap to thirtyseconds"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToAThirtysecondBeat)));
351         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-asixteenthbeat"), _("Snap to asixteenthbeat"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToASixteenthBeat)));
352         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-eighths"), _("Snap to eighths"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToAEighthBeat)));
353         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-quarters"), _("Snap to quarters"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToAQuarterBeat)));
354         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-thirds"), _("Snap to thirds"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToAThirdBeat)));
355         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-beat"), _("Snap to beat"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToBeat)));
356         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-bar"), _("Snap to bar"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToBar)));
357         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-mark"), _("Snap to mark"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToMark)));
358         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-edit-cursor"), _("Snap to edit point"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToEditPoint)));
359         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-region-start"), _("Snap to region start"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToRegionStart)));
360         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-region-end"), _("Snap to region end"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToRegionEnd)));
361         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-region-sync"), _("Snap to region sync"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToRegionSync)));
362         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-region-boundary"), _("Snap to region boundary"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToRegionBoundary)));
363
364         /* REGION LIST */
365
366         Glib::RefPtr<ActionGroup> rl_actions = ActionGroup::create (X_("RegionList"));
367         RadioAction::Group sort_type_group;
368         RadioAction::Group sort_order_group;
369
370         /* the region list popup menu */
371         ActionManager::register_action (rl_actions, X_("RegionListSort"), _("Sort"));
372
373         act = ActionManager::register_action (rl_actions, X_("rlAudition"), _("Audition"), mem_fun(*this, &Editor::audition_region_from_region_list));
374         ActionManager::region_list_selection_sensitive_actions.push_back (act);
375         act = ActionManager::register_action (rl_actions, X_("rlHide"), _("Hide"), mem_fun(*this, &Editor::hide_region_from_region_list));
376         ActionManager::region_list_selection_sensitive_actions.push_back (act);
377         act = ActionManager::register_action (rl_actions, X_("rlRemove"), _("Remove"), mem_fun (*this, &Editor::remove_region_from_region_list));
378         ActionManager::region_list_selection_sensitive_actions.push_back (act);
379         ActionManager::register_toggle_action (rl_actions, X_("rlShowAll"), _("Show all"), mem_fun(*this, &Editor::toggle_full_region_list));
380         ActionManager::register_toggle_action (rl_actions, X_("rlShowAuto"), _("Show automatic regions"), mem_fun(*this, &Editor::toggle_show_auto_regions));
381
382         ActionManager::register_radio_action (rl_actions, sort_order_group, X_("SortAscending"),  _("Ascending"),
383                                bind (mem_fun(*this, &Editor::reset_region_list_sort_direction), true));
384         ActionManager::register_radio_action (rl_actions, sort_order_group, X_("SortDescending"),   _("Descending"),
385                                bind (mem_fun(*this, &Editor::reset_region_list_sort_direction), false));
386         
387         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionName"),  _("By Region Name"),
388                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), ByName));
389         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionLength"),  _("By Region Length"),
390                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), ByLength));
391         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionPosition"),  _("By Region Position"),
392                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), ByPosition));
393         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionTimestamp"),  _("By Region Timestamp"),
394                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), ByTimestamp));
395         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionStartinFile"),  _("By Region Start in File"),
396                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), ByStartInFile));
397         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionEndinFile"),  _("By Region End in File"),
398                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), ByEndInFile));
399         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortBySourceFileName"),  _("By Source File Name"),
400                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), BySourceFileName));
401         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortBySourceFileLength"),  _("By Source File Length"),
402                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), BySourceFileLength));
403         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortBySourceFileCreationDate"),  _("By Source File Creation Date"),
404                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), BySourceFileCreationDate));
405         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortBySourceFilesystem"),  _("By Source Filesystem"),
406                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), BySourceFileFS));
407
408
409         /* the next two are duplicate items with different names for use in two different contexts */
410
411         ActionManager::register_action (editor_actions, X_("addExistingAudioFiles"), _("Add Existing Audio"), mem_fun (*this, &Editor::external_audio_dialog));
412
413         act = ActionManager::register_action (editor_actions, X_("addExternalAudioToRegionList"), _("Add External Audio"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportAsRegion));
414         ActionManager::session_sensitive_actions.push_back (act);
415
416         ActionManager::register_toggle_action (editor_actions, X_("ToggleWaveformVisibility"), _("Show Waveforms"), mem_fun (*this, &Editor::toggle_waveform_visibility));
417         ActionManager::register_toggle_action (editor_actions, X_("ToggleWaveformsWhileRecording"), _("Show Waveforms While Recording"), mem_fun (*this, &Editor::toggle_waveforms_while_recording));
418         ActionManager::register_toggle_action (editor_actions, X_("ToggleMeasureVisibility"), _("Show Measures"), mem_fun (*this, &Editor::toggle_measure_visibility));
419
420         /* if there is a logo in the editor canvas, its always visible at startup */
421
422         act = ActionManager::register_toggle_action (editor_actions, X_("ToggleLogoVisibility"), _("Show Logo"), mem_fun (*this, &Editor::toggle_logo_visibility));
423         Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
424         tact->set_active (true);
425         
426         RadioAction::Group layer_model_group;
427
428         ActionManager::register_radio_action (editor_actions, layer_model_group,  X_("LayerLaterHigher"), _("Later is Higher"), bind (mem_fun (*this, &Editor::set_layer_model), LaterHigher));
429         ActionManager::register_radio_action (editor_actions, layer_model_group,  X_("LayerMoveAddHigher"), _("Most Recently Moved/Added is Higher"), bind (mem_fun (*this, &Editor::set_layer_model), MoveAddHigher));
430         ActionManager::register_radio_action (editor_actions, layer_model_group,  X_("LayerAddHigher"), _("Most Recently Added is Higher"), bind (mem_fun (*this, &Editor::set_layer_model), AddHigher));
431
432         RadioAction::Group smpte_group;
433
434         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte23976"), _("23.976"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), smpte_23976));
435         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte24"), _("24"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), smpte_24));
436         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte24976"), _("24.976"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), smpte_24976));
437         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte25"), _("25"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), smpte_25));
438         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte2997"), _("29.97"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), smpte_2997));
439         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte2997drop"), _("29.97 drop"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), smpte_2997drop));
440         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte30"), _("30"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), smpte_30));
441         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte30drop"), _("30 drop"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), smpte_30drop));
442         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte5994"), _("59.94"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), smpte_5994));
443         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte60"), _("60"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), smpte_60));
444
445         RadioAction::Group pullup_group;
446
447         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupPlus4Plus1"), _("+4.1667% + 0.1%"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_Plus4Plus1));
448         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupPlus4"), _("+4.1667%"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_Plus4));
449         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupPlus4Minus1"), _("+4.1667% - 0.1%"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_Plus4Minus1));
450         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupPlus1"), _("+ 0.1%"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_Plus1));
451         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupNone"), _("None"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_None));
452         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupMinus1"), _("- 0.1%"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_Minus1));
453         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupMinus4Plus1"), _("-4.1667% + 0.1%"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_Minus4Plus1));
454         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupMinus4"), _("-4.1667%"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_Minus4));
455         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupMinus4Minus1"), _("-4.1667% - 0.1%"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_Minus4Minus1));
456
457         RadioAction::Group subframe_group;
458
459         ActionManager::register_radio_action (editor_actions, subframe_group,  X_("Subframes80"), _("80 per frame"), bind (mem_fun (*this, 
460 &Editor::subframes_per_frame_chosen), 80));
461         ActionManager::register_radio_action (editor_actions, subframe_group,  X_("Subframes100"), _("100 per frame"), bind (mem_fun (*this, 
462 &Editor::subframes_per_frame_chosen), 100));
463
464         ActionManager::add_action_group (rl_actions);
465         ActionManager::add_action_group (zoom_actions);
466         ActionManager::add_action_group (mouse_mode_actions);
467         ActionManager::add_action_group (snap_actions);
468         ActionManager::add_action_group (editor_actions);
469 }
470
471 void
472 Editor::toggle_waveform_visibility ()
473 {
474         Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformVisibility"));
475         if (act) {
476                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
477                 set_show_waveforms (tact->get_active());
478         }
479 }
480
481 void
482 Editor::toggle_waveforms_while_recording ()
483 {
484         Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformsWhileRecording"));
485         if (act) {
486                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
487                 set_show_waveforms_recording (tact->get_active());
488         }
489 }
490
491 void
492 Editor::toggle_measure_visibility ()
493 {
494         Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleMeasureVisibility"));
495         if (act) {
496                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
497                 set_show_measures (tact->get_active());
498         }
499 }
500
501 void
502 Editor::toggle_logo_visibility ()
503 {
504         Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleLogoVisibility"));
505
506         if (act) {
507                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
508                 if (logo_item) {
509                         if (tact->get_active()) {
510                                 logo_item->show ();
511                         } else {
512                                 logo_item->hide ();
513                         }
514                 }
515         }
516 }
517
518 void
519 Editor::set_crossfade_model (CrossfadeModel model)
520 {
521         RefPtr<Action> act;
522
523         /* this is driven by a toggle on a radio group, and so is invoked twice,
524            once for the item that became inactive and once for the one that became
525            active.
526         */
527
528         switch (model) {
529         case FullCrossfade:
530                 act = ActionManager::get_action (X_("Editor"), X_("CrossfadesFull"));
531                 break;
532         case ShortCrossfade:
533                 act = ActionManager::get_action (X_("Editor"), X_("CrossfadesShort"));
534                 break;
535         }
536         
537         if (act) {
538                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
539                 if (ract && ract->get_active()) {
540                         Config->set_xfade_model (model);
541                 }
542         }
543 }
544
545 void
546 Editor::update_crossfade_model ()
547 {
548         RefPtr<Action> act;
549
550         switch (Config->get_xfade_model()) {
551         case FullCrossfade:
552                 act = ActionManager::get_action (X_("Editor"), X_("CrossfadesFull"));
553                 break;
554         case ShortCrossfade:
555                 act = ActionManager::get_action (X_("Editor"), X_("CrossfadesShort"));
556                 break;
557         }
558
559         if (act) {
560                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
561                 if (ract && !ract->get_active()) {
562                         ract->set_active (true);
563                 }
564         }
565 }
566
567 void
568 Editor::update_smpte_mode ()
569 {
570         ENSURE_GUI_THREAD(mem_fun(*this, &Editor::update_smpte_mode));
571
572         RefPtr<Action> act;
573         const char* action = 0;
574
575         switch (Config->get_smpte_format()) {
576         case smpte_23976:
577                 action = X_("Smpte23976");
578                 break;
579         case smpte_24:
580                 action = X_("Smpte24");
581                 break;
582         case smpte_24976:
583                 action = X_("Smpte24976");
584                 break;
585         case smpte_25:
586                 action = X_("Smpte25");
587                 break;
588         case smpte_2997:
589                 action = X_("Smpte2997");
590                 break;
591         case smpte_2997drop:
592                 action = X_("Smpte2997drop");
593                 break;
594         case smpte_30:
595                 action = X_("Smpte30");
596                 break;
597         case smpte_30drop:
598                 action = X_("Smpte30drop");
599                 break;
600         case smpte_5994:
601                 action = X_("Smpte5994");
602                 break;
603         case smpte_60:
604                 action = X_("Smpte60");
605                 break;
606         }
607
608         act = ActionManager::get_action (X_("Editor"), action);
609
610         if (act) {
611                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
612                 if (ract && !ract->get_active()) {
613                         ract->set_active (true);
614                 }
615         }
616 }
617
618 void
619 Editor::update_video_pullup ()
620 {
621         ENSURE_GUI_THREAD (mem_fun(*this, &Editor::update_video_pullup));
622
623         RefPtr<Action> act;
624         const char* action = 0;
625
626         float pullup = Config->get_video_pullup();
627
628         if ( pullup < (-4.1667 - 0.1) * 0.99) {
629                 action = X_("PullupMinus4Minus1");
630         } else if ( pullup < (-4.1667) * 0.99 ) {
631                 action = X_("PullupMinus4");
632         } else if ( pullup < (-4.1667 + 0.1) * 0.99 ) {
633                 action = X_("PullupMinus4Plus1");
634         } else if ( pullup < (-0.1) * 0.99 ) {
635                 action = X_("PullupMinus1");
636         } else if (pullup > (4.1667 + 0.1) * 0.99 ) {
637                 action = X_("PullupPlus4Plus1");
638         } else if ( pullup > (4.1667) * 0.99 ) {
639                 action = X_("PullupPlus4");
640         } else if ( pullup > (4.1667 - 0.1) * 0.99) {
641                 action = X_("PullupPlus4Minus1");
642         } else if ( pullup > (0.1) * 0.99 ) {
643                 action = X_("PullupPlus1");
644         } else {
645                 action = X_("PullupNone");
646         }
647
648         act = ActionManager::get_action (X_("Editor"), action);
649
650         if (act) {
651                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
652                 if (ract && !ract->get_active()) {
653                         ract->set_active (true);
654                 }
655         }
656 }
657
658 void
659 Editor::update_layering_model ()
660 {
661         RefPtr<Action> act;
662
663         switch (Config->get_layer_model()) {
664         case LaterHigher:
665                 act = ActionManager::get_action (X_("Editor"), X_("LayerLaterHigher"));
666                 break;
667         case MoveAddHigher:
668                 act = ActionManager::get_action (X_("Editor"), X_("LayerMoveAddHigher"));
669                 break;
670         case AddHigher:
671                 act = ActionManager::get_action (X_("Editor"), X_("LayerAddHigher"));
672                 break;
673         }
674
675         if (act) {
676                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
677                 if (ract && !ract->get_active()) {
678                         ract->set_active (true);
679                 }
680         }
681 }
682
683 void
684 Editor::set_layer_model (LayerModel model)
685 {
686         /* this is driven by a toggle on a radio group, and so is invoked twice,
687            once for the item that became inactive and once for the one that became
688            active.
689         */
690
691         RefPtr<Action> act;
692
693         switch (model) {
694         case LaterHigher:
695                 act = ActionManager::get_action (X_("Editor"), X_("LayerLaterHigher"));
696                 break;
697         case MoveAddHigher:
698                 act = ActionManager::get_action (X_("Editor"), X_("LayerMoveAddHigher"));
699                 break;
700         case AddHigher:
701                 act = ActionManager::get_action (X_("Editor"), X_("LayerAddHigher"));
702                 break;
703         }
704         
705         if (act) {
706                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
707                 if (ract && ract->get_active() && Config->get_layer_model() != model) {
708                         Config->set_layer_model (model);
709                 }
710         }
711 }
712
713 RefPtr<RadioAction>
714 Editor::snap_type_action (SnapType type)
715 {
716
717         const char* action = 0;
718         RefPtr<Action> act;
719         
720         switch (type) {
721         case Editing::SnapToFrame:
722                 action = "snap-to-frame";
723                 break;
724         case Editing::SnapToCDFrame:
725                 action = "snap-to-cd-frame";
726                 break;
727         case Editing::SnapToSMPTEFrame:
728                 action = "snap-to-smpte-frame";
729                 break;
730         case Editing::SnapToSMPTESeconds:
731                 action = "snap-to-smpte-seconds";
732                 break;
733         case Editing::SnapToSMPTEMinutes:
734                 action = "snap-to-smpte-minutes";
735                 break;
736         case Editing::SnapToSeconds:
737                 action = "snap-to-seconds";
738                 break;
739         case Editing::SnapToMinutes:
740                 action = "snap-to-minutes";
741                 break;
742         case Editing::SnapToAThirtysecondBeat:
743                 action = "snap-to-thirtyseconds";
744                 break;
745         case Editing::SnapToASixteenthBeat:
746                 action = "snap-to-asixteenthbeat";
747                 break;
748         case Editing::SnapToAEighthBeat:
749                 action = "snap-to-eighths";
750                 break;
751         case Editing::SnapToAQuarterBeat:
752                 action = "snap-to-quarters";
753                 break;
754         case Editing::SnapToAThirdBeat:
755                 action = "snap-to-thirds";
756                 break;
757         case Editing::SnapToBeat:
758                 action = "snap-to-beat";
759                 break;
760         case Editing::SnapToBar:
761                 action = "snap-to-bar";
762                 break;
763         case Editing::SnapToMark:
764                 action = "snap-to-mark";
765                 break;
766         case Editing::SnapToEditPoint:
767                 action = "snap-to-edit-cursor";
768                 break;
769         case Editing::SnapToRegionStart:
770                 action = "snap-to-region-start";
771                 break;
772         case Editing::SnapToRegionEnd:
773                 action = "snap-to-region-end";
774                 break;
775         case Editing::SnapToRegionSync:
776                 action = "snap-to-region-sync";
777                 break;
778         case Editing::SnapToRegionBoundary:
779                 action = "snap-to-region-boundary";
780                 break;
781         default:
782                 fatal << string_compose (_("programming error: %1: %2"), "Editor: impossible snap-to type", (int) type) << endmsg;
783                 /*NOTREACHED*/
784         }
785
786         act = ActionManager::get_action (X_("Snap"), action);
787
788         if (act) {
789                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
790                 return ract;
791
792         } else  {
793                 error << string_compose (_("programming error: %1"), "Editor::snap_type_chosen could not find action to match type.") << endmsg;
794                 return RefPtr<RadioAction>();
795         }
796 }
797
798 void
799 Editor::snap_type_chosen (SnapType type)
800 {
801         /* this is driven by a toggle on a radio group, and so is invoked twice,
802            once for the item that became inactive and once for the one that became
803            active.
804         */
805
806         RefPtr<RadioAction> ract = snap_type_action (type);
807
808         if (ract && ract->get_active()) {
809                 set_snap_to (type);
810         }
811 }
812
813 RefPtr<RadioAction>
814 Editor::snap_mode_action (SnapMode mode)
815 {
816         const char* action = 0;
817         RefPtr<Action> act;
818         
819         switch (mode) {
820         case Editing::SnapNormal:
821                 action = X_("snap-normal");
822                 break;
823         case Editing::SnapMagnetic:
824                 action = X_("snap-magnetic");
825                 break;
826         default:
827                 fatal << string_compose (_("programming error: %1: %2"), "Editor: impossible snap mode type", (int) mode) << endmsg;
828                 /*NOTREACHED*/
829         }
830         
831         act = ActionManager::get_action (X_("Editor"), action);
832         
833         if (act) {
834                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
835                 return ract;
836                 
837         } else  {
838                 error << string_compose (_("programming error: %1: %2"), "Editor::snap_mode_chosen could not find action to match mode.", action) << endmsg;
839                 return RefPtr<RadioAction> ();
840         }
841 }
842
843 void
844 Editor::snap_mode_chosen (SnapMode mode)
845 {
846         /* this is driven by a toggle on a radio group, and so is invoked twice,
847            once for the item that became inactive and once for the one that became
848            active.
849         */
850
851         RefPtr<RadioAction> ract = snap_mode_action (mode);
852
853         if (ract && ract->get_active()) {
854                 set_snap_mode (mode);
855         }
856 }
857
858 RefPtr<RadioAction>
859 Editor::edit_point_action (EditPoint ep)
860 {
861         const char* action = 0;
862         RefPtr<Action> act;
863         
864         switch (ep) {
865         case Editing::EditAtPlayhead:
866                 action = X_("edit-at-playhead");
867                 break;
868         case Editing::EditAtSelectedMarker:
869                 action = X_("edit-at-selected-marker");
870                 break;
871         case Editing::EditAtMouse:
872                 action = X_("edit-at-mouse");
873                 break;
874         default:
875                 fatal << string_compose (_("programming error: %1: %2"), "Editor: impossible edit point type", (int) ep) << endmsg;
876                 /*NOTREACHED*/
877         }
878         
879         act = ActionManager::get_action (X_("Editor"), action);
880         
881         if (act) {
882                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
883                 return ract;
884                 
885         } else  {
886                 error << string_compose (_("programming error: %1: %2"), "Editor::edit_point_action could not find action to match edit point.", action) << endmsg;
887                 return RefPtr<RadioAction> ();
888         }
889 }
890
891 void
892 Editor::edit_point_chosen (EditPoint ep)
893 {
894         /* this is driven by a toggle on a radio group, and so is invoked twice,
895            once for the item that became inactive and once for the one that became
896            active.
897         */
898
899         RefPtr<RadioAction> ract = edit_point_action (ep);
900
901         if (ract && ract->get_active()) {
902                 set_edit_point_preference (ep);
903         }
904 }
905
906
907 RefPtr<RadioAction>
908 Editor::zoom_focus_action (ZoomFocus focus)
909 {
910         const char* action = 0;
911         RefPtr<Action> act;
912         
913         switch (focus) {
914         case ZoomFocusLeft:
915                 action = X_("zoom-focus-left");
916                 break;
917         case ZoomFocusRight:
918                 action = X_("zoom-focus-right");
919                 break;
920         case ZoomFocusCenter:
921                 action = X_("zoom-focus-center");
922                 break;
923         case ZoomFocusPlayhead:
924                 action = X_("zoom-focus-playhead");
925                 break;
926         case ZoomFocusMouse:
927                 action = X_("zoom-focus-mouse");
928                 break;
929         case ZoomFocusEdit:
930                 action = X_("zoom-focus-edit");
931                 break;
932         default:
933                 fatal << string_compose (_("programming error: %1: %2"), "Editor: impossible focus type", (int) focus) << endmsg;
934                 /*NOTREACHED*/
935         }
936         
937         act = ActionManager::get_action (X_("Zoom"), action);
938         
939         if (act) {
940                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
941                 return ract;
942         } else {
943                 error << string_compose (_("programming error: %1: %2"), "Editor::zoom_focus_action could not find action to match focus.", action) << endmsg;
944         }
945
946         return RefPtr<RadioAction> ();
947 }
948
949 void
950 Editor::zoom_focus_chosen (ZoomFocus focus)
951 {
952         /* this is driven by a toggle on a radio group, and so is invoked twice,
953            once for the item that became inactive and once for the one that became
954            active.
955         */
956
957         RefPtr<RadioAction> ract = zoom_focus_action (focus);
958
959         if (ract && ract->get_active()) {
960                 set_zoom_focus (focus);
961         }
962 }
963
964 void
965 Editor::smpte_fps_chosen (SmpteFormat format)
966 {
967         /* this is driven by a toggle on a radio group, and so is invoked twice,
968            once for the item that became inactive and once for the one that became
969            active.
970         */
971
972         if (session) {
973
974                 RefPtr<Action> act;
975
976                 switch (format) {
977                         case smpte_23976: 
978                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte23976"));
979                          break;
980                         case smpte_24: 
981                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte24"));
982                          break;
983                         case smpte_24976: 
984                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte24976"));
985                          break;
986                         case smpte_25: 
987                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte25"));
988                          break;
989                         case smpte_2997: 
990                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte2997"));
991                          break;
992                         case smpte_2997drop: 
993                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte2997drop"));
994                          break;
995                         case smpte_30: 
996                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte30"));
997                          break;
998                         case smpte_30drop: 
999                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte30drop"));
1000                          break;
1001                         case smpte_5994: 
1002                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte5994"));
1003                          break;
1004                         case smpte_60: 
1005                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte60"));
1006                          break;
1007                         default:
1008                                 cerr << "Editor received unexpected smpte type" << endl;
1009                 }
1010
1011                 if (act) {
1012                         RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
1013                         if (ract && ract->get_active()) {
1014                                 session->set_smpte_format (format);
1015                         }
1016                 }
1017         }
1018 }
1019
1020 void
1021 Editor::video_pullup_chosen (Session::PullupFormat pullup)
1022 {
1023         /* this is driven by a toggle on a radio group, and so is invoked twice,
1024            once for the item that became inactive and once for the one that became
1025            active.
1026         */
1027
1028         const char* action = 0;
1029
1030         RefPtr<Action> act;
1031         
1032         float pull = 0.0;
1033         
1034         switch (pullup) {
1035         case Session::pullup_Plus4Plus1:
1036                 pull = 4.1667 + 0.1;
1037                 action = X_("PullupPlus4Plus1");
1038                 break;
1039         case Session::pullup_Plus4:
1040                 pull = 4.1667;
1041                 action = X_("PullupPlus4");
1042                 break;
1043         case Session::pullup_Plus4Minus1:
1044                 pull = 4.1667 - 0.1;
1045                 action = X_("PullupPlus4Minus1");
1046                 break;
1047         case Session::pullup_Plus1:
1048                 pull = 0.1;
1049                 action = X_("PullupPlus1");
1050                 break;
1051         case Session::pullup_None:
1052                 pull = 0.0;
1053                 action = X_("PullupNone");
1054                 break;
1055         case Session::pullup_Minus1:
1056                 pull = -0.1;
1057                 action = X_("PullupMinus1");
1058                 break;
1059         case Session::pullup_Minus4Plus1:
1060                 pull = -4.1667 + 0.1;
1061                 action = X_("PullupMinus4Plus1");
1062                 break;
1063         case Session::pullup_Minus4:
1064                 pull = -4.1667;
1065                 action = X_("PullupMinus4");
1066                 break;
1067         case Session::pullup_Minus4Minus1:
1068                 pull = -4.1667 - 0.1;
1069                 action = X_("PullupMinus4Minus1");
1070                 break;
1071         default:
1072                 fatal << string_compose (_("programming error: %1"), "Session received unexpected pullup type") << endmsg;
1073                 /*NOTREACHED*/
1074         }
1075         
1076         act = ActionManager::get_action (X_("Editor"), action);
1077         
1078         if (act) {
1079                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
1080                 if (ract && ract->get_active()) {
1081                         Config->set_video_pullup ( pull );
1082                 }
1083                 
1084         } else  {
1085                 error << string_compose (_("programming error: %1"), "Editor::video_pullup_chosen could not find action to match pullup.") << endmsg;
1086         }
1087 }
1088
1089 void
1090 Editor::update_subframes_per_frame ()
1091 {
1092         ENSURE_GUI_THREAD (mem_fun(*this, &Editor::update_subframes_per_frame));
1093
1094         RefPtr<Action> act;
1095         const char* action = 0;
1096
1097         uint32_t sfpf = Config->get_subframes_per_frame();
1098
1099         if (sfpf == 80) {
1100                 action = X_("Subframes80");
1101         } else if (sfpf == 100) {
1102                 action = X_("Subframes100");
1103         } else {
1104                 warning << string_compose (_("Configuraton is using unhandled subframes per frame value: %1"), sfpf) << endmsg;
1105                 /*NOTREACHED*/
1106                 return;
1107         }
1108
1109         act = ActionManager::get_action (X_("Editor"), action);
1110
1111         if (act) {
1112                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
1113                 if (ract && !ract->get_active()) {
1114                         ract->set_active (true);
1115                 }
1116         }
1117 }
1118
1119 void
1120 Editor::subframes_per_frame_chosen (uint32_t sfpf)
1121 {
1122         /* this is driven by a toggle on a radio group, and so is invoked twice,
1123            once for the item that became inactive and once for the one that became
1124            active.
1125         */
1126
1127         const char* action = 0;
1128
1129         RefPtr<Action> act;
1130         
1131         if (sfpf == 80) {
1132                 action = X_("Subframes80");
1133         } else if (sfpf == 100) {       
1134                 action = X_("Subframes100");
1135         } else {
1136                 fatal << string_compose (_("programming error: %1 %2"), "Session received unexpected subframes per frame value: ", sfpf) << endmsg;
1137                 /*NOTREACHED*/
1138         }
1139         
1140         act = ActionManager::get_action (X_("Editor"), action);
1141         
1142         if (act) {
1143                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
1144                 if (ract && ract->get_active()) {
1145                         Config->set_subframes_per_frame ((uint32_t) rint (sfpf));
1146                 }
1147                 
1148         } else  {
1149                 error << string_compose (_("programming error: %1"), "Editor::subframes_per_frame_chosen could not find action to match value.") << endmsg;
1150         }
1151 }
1152
1153 void
1154 Editor::toggle_auto_xfade ()
1155 {
1156         ActionManager::toggle_config_state ("Editor", "toggle-auto-xfades", &Configuration::set_auto_xfade, &Configuration::get_auto_xfade);
1157 }
1158
1159 void
1160 Editor::toggle_xfades_active ()
1161 {
1162         ActionManager::toggle_config_state ("Editor", "toggle-xfades-active", &Configuration::set_xfades_active, &Configuration::get_xfades_active);
1163 }
1164
1165 void
1166 Editor::toggle_xfade_visibility ()
1167 {
1168         ActionManager::toggle_config_state ("Editor", "toggle-xfades-visible", &Configuration::set_xfades_visible, &Configuration::get_xfades_visible);
1169 }
1170
1171 /** A Configuration parameter has changed.
1172  * @param parameter_name Name of the changed parameter.
1173  */
1174 void
1175 Editor::parameter_changed (const char* parameter_name)
1176 {
1177 #define PARAM_IS(x) (!strcmp (parameter_name, (x)))
1178
1179         ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::parameter_changed), parameter_name));
1180
1181         if (PARAM_IS ("auto-loop")) {
1182                 update_loop_range_view (true);
1183         } else if (PARAM_IS ("punch-in")) {
1184                 update_punch_range_view (true);
1185         } else if (PARAM_IS ("punch-out")) {
1186                 update_punch_range_view (true);
1187         } else if (PARAM_IS ("layer-model")) {
1188                 update_layering_model ();
1189         } else if (PARAM_IS ("smpte-format")) {
1190                 update_smpte_mode ();
1191                 update_just_smpte ();
1192         } else if (PARAM_IS ("video-pullup")) {
1193                 update_video_pullup ();
1194         } else if (PARAM_IS ("xfades-active")) {
1195                 ActionManager::map_some_state ("Editor", "toggle-xfades-active", &Configuration::get_xfades_active);
1196         } else if (PARAM_IS ("xfades-visible")) {
1197                 ActionManager::map_some_state ("Editor", "toggle-xfades-visible", &Configuration::get_xfades_visible);
1198                 update_xfade_visibility ();
1199         } else if (PARAM_IS ("auto-xfade")) {
1200                 ActionManager::map_some_state ("Editor", "toggle-auto-xfades", &Configuration::get_auto_xfade);
1201         } else if (PARAM_IS ("xfade-model")) {
1202                 update_crossfade_model ();
1203         } else if (PARAM_IS ("edit-mode")) {
1204                 edit_mode_selector.set_active_text (edit_mode_to_string (Config->get_edit_mode()));
1205         } else if (PARAM_IS ("subframes-per-frame")) {
1206                 update_subframes_per_frame ();
1207                 update_just_smpte ();
1208         }
1209
1210 #undef PARAM_IS
1211 }
1212
1213 void
1214 Editor::reset_focus ()
1215 {
1216         track_canvas.grab_focus();
1217 }