mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-06 13:45:43 +01:00
refactor zoom focus handling so that all EditingContexts can use the same code
This commit is contained in:
parent
9b22e16bec
commit
0a40b50b86
8 changed files with 115 additions and 82 deletions
|
|
@ -98,6 +98,17 @@ static const gchar *_grid_type_strings[] = {
|
|||
0
|
||||
};
|
||||
|
||||
|
||||
static const gchar *_zoom_focus_strings[] = {
|
||||
N_("Left"),
|
||||
N_("Right"),
|
||||
N_("Center"),
|
||||
N_("Playhead"),
|
||||
N_("Mouse"),
|
||||
N_("Edit point"),
|
||||
0
|
||||
};
|
||||
|
||||
Editing::GridType EditingContext::_draw_length (GridTypeNone);
|
||||
int EditingContext::_draw_velocity (DRAW_VEL_AUTO);
|
||||
int EditingContext::_draw_channel (DRAW_CHAN_AUTO);
|
||||
|
|
@ -174,6 +185,10 @@ EditingContext::EditingContext (std::string const & name)
|
|||
grid_type_strings = I18N (_grid_type_strings);
|
||||
}
|
||||
|
||||
if (zoom_focus_strings.empty()) {
|
||||
zoom_focus_strings = I18N (_zoom_focus_strings);
|
||||
}
|
||||
|
||||
snap_mode_button.set_text (_("Snap"));
|
||||
snap_mode_button.set_name ("mouse mode button");
|
||||
snap_mode_button.signal_button_press_event().connect (sigc::mem_fun (*this, &EditingContext::snap_mode_button_clicked), false);
|
||||
|
|
@ -3157,3 +3172,60 @@ EditingContext::window_event_sample (GdkEvent const * event, double* pcx, double
|
|||
return pixel_to_sample (canvas_to_timeline (d.x));
|
||||
}
|
||||
|
||||
void
|
||||
EditingContext::zoom_focus_selection_done (ZoomFocus f)
|
||||
{
|
||||
RefPtr<RadioAction> ract = zoom_focus_action (f);
|
||||
if (ract) {
|
||||
ract->set_active ();
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<RadioAction>
|
||||
EditingContext::zoom_focus_action (ZoomFocus focus)
|
||||
{
|
||||
const char* action = 0;
|
||||
RefPtr<Action> act;
|
||||
|
||||
switch (focus) {
|
||||
case ZoomFocusLeft:
|
||||
action = X_("zoom-focus-left");
|
||||
break;
|
||||
case ZoomFocusRight:
|
||||
action = X_("zoom-focus-right");
|
||||
break;
|
||||
case ZoomFocusCenter:
|
||||
action = X_("zoom-focus-center");
|
||||
break;
|
||||
case ZoomFocusPlayhead:
|
||||
action = X_("zoom-focus-playhead");
|
||||
break;
|
||||
case ZoomFocusMouse:
|
||||
action = X_("zoom-focus-mouse");
|
||||
break;
|
||||
case ZoomFocusEdit:
|
||||
action = X_("zoom-focus-edit");
|
||||
break;
|
||||
default:
|
||||
fatal << string_compose (_("programming error: %1: %2"), "Editor: impossible focus type", (int) focus) << endmsg;
|
||||
abort(); /*NOTREACHED*/
|
||||
}
|
||||
|
||||
return ActionManager::get_radio_action (X_("Zoom"), action);
|
||||
}
|
||||
|
||||
void
|
||||
EditingContext::zoom_focus_chosen (ZoomFocus focus)
|
||||
{
|
||||
/* this is driven by a toggle on a radio group, and so is invoked twice,
|
||||
once for the item that became inactive and once for the one that became
|
||||
active.
|
||||
*/
|
||||
|
||||
RefPtr<RadioAction> ract = zoom_focus_action (focus);
|
||||
|
||||
if (ract && ract->get_active()) {
|
||||
set_zoom_focus (focus);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue