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