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