MCP: F1-7 jump to a given view; F8 closes any currently open dialog; in zoom mode, up/down alter vertical track height of all tracks; option-up/down alters selected track heights

git-svn-id: svn://localhost/ardour2/branches/3.0@11858 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2012-04-09 18:53:51 +00:00
parent 0431309f89
commit bef3ea1adc
11 changed files with 309 additions and 190 deletions

View File

@ -714,6 +714,13 @@ Editor::Editor ()
ControlProtocol::ScrollTimeline.connect (*this, invalidator (*this), ui_bind (&Editor::control_scroll, this, _1), gui_context());
ControlProtocol::SelectByRID.connect (*this, invalidator (*this), ui_bind (&Editor::control_select, this, _1), gui_context());
ControlProtocol::UnselectTrack.connect (*this, invalidator (*this), ui_bind (&Editor::control_unselect, this), gui_context());
ControlProtocol::GotoView.connect (*this, invalidator (*this), ui_bind (&Editor::control_view, this, _1), gui_context());
ControlProtocol::CloseDialog.connect (*this, invalidator (*this), Keyboard::close_current_dialog, gui_context());
ControlProtocol::VerticalZoomInAll.connect (*this, invalidator (*this), ui_bind (&Editor::control_vertical_zoom_in_all, this), gui_context());
ControlProtocol::VerticalZoomOutAll.connect (*this, invalidator (*this), ui_bind (&Editor::control_vertical_zoom_out_all, this), gui_context());
ControlProtocol::VerticalZoomInSelected.connect (*this, invalidator (*this), ui_bind (&Editor::control_vertical_zoom_in_selected, this), gui_context());
ControlProtocol::VerticalZoomOutSelected.connect (*this, invalidator (*this), ui_bind (&Editor::control_vertical_zoom_out_selected, this), gui_context());
BasicUI::AccessAction.connect (*this, invalidator (*this), ui_bind (&Editor::access_action, this, _1, _2), gui_context());
/* problematic: has to return a value and thus cannot be x-thread */
@ -922,6 +929,36 @@ Editor::zoom_adjustment_changed ()
temporal_zoom (fpu);
}
void
Editor::control_vertical_zoom_in_all ()
{
tav_zoom_smooth (false, true);
}
void
Editor::control_vertical_zoom_out_all ()
{
tav_zoom_smooth (true, true);
}
void
Editor::control_vertical_zoom_in_selected ()
{
tav_zoom_smooth (false, false);
}
void
Editor::control_vertical_zoom_out_selected ()
{
tav_zoom_smooth (true, false);
}
void
Editor::control_view (uint32_t view)
{
goto_visual_state (view);
}
void
Editor::control_unselect ()
{

View File

@ -318,6 +318,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
void temporal_zoom_step (bool coarser);
void tav_zoom_step (bool coarser);
void tav_zoom_smooth (bool coarser, bool force_all);
/* stuff that AudioTimeAxisView and related classes use */
@ -987,6 +988,11 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
Gtk::VBox edit_controls_vbox;
Gtk::HBox edit_controls_hbox;
void control_vertical_zoom_in_all ();
void control_vertical_zoom_out_all ();
void control_vertical_zoom_in_selected ();
void control_vertical_zoom_out_selected ();
void control_view (uint32_t);
void control_scroll (float);
void control_select (uint32_t rid);
void control_unselect ();

View File

@ -1278,11 +1278,17 @@ Editor::scroll_tracks_up_line ()
void
Editor::tav_zoom_step (bool coarser)
{
ENSURE_GUI_THREAD (*this, &Editor::temporal_zoom_step, coarser)
_routes->suspend_redisplay ();
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
TrackViewList* ts;
if (selection->tracks.empty()) {
ts = &track_views;
} else {
ts = &selection->tracks;
}
for (TrackViewList::iterator i = ts->begin(); i != ts->end(); ++i) {
TimeAxisView *tv = (static_cast<TimeAxisView*>(*i));
tv->step_height (coarser);
}
@ -1290,6 +1296,38 @@ Editor::tav_zoom_step (bool coarser)
_routes->resume_redisplay ();
}
void
Editor::tav_zoom_smooth (bool coarser, bool force_all)
{
_routes->suspend_redisplay ();
TrackViewList* ts;
if (selection->tracks.empty() || force_all) {
ts = &track_views;
} else {
ts = &selection->tracks;
}
for (TrackViewList::iterator i = ts->begin(); i != ts->end(); ++i) {
TimeAxisView *tv = (static_cast<TimeAxisView*>(*i));
uint32_t h = tv->current_height ();
if (coarser) {
if (h > 5) {
h -= 5; // pixels
if (h >= TimeAxisView::preset_height (HeightSmall)) {
tv->set_height (h);
}
}
} else {
tv->set_height (h + 5);
}
}
_routes->resume_redisplay ();
}
void
Editor::temporal_zoom_step (bool coarser)
{

View File

@ -495,16 +495,6 @@ TimeAxisView::step_height (bool coarser)
}
}
void
TimeAxisView::set_heights (uint32_t h)
{
TrackSelection& ts (_editor.get_selection().tracks);
for (TrackSelection::iterator i = ts.begin(); i != ts.end(); ++i) {
(*i)->set_height (h);
}
}
void
TimeAxisView::set_height_enum (Height h, bool apply_to_selection)
{

View File

@ -286,7 +286,6 @@ class TimeAxisView : public virtual AxisView
bool in_destructor;
NamePackingBits name_packing;
void set_heights (uint32_t h);
void color_handler ();
void conditionally_add_to_selection ();

View File

@ -138,6 +138,8 @@ class Keyboard : public sigc::trackable, PBD::Stateful
static void magic_widget_grab_focus ();
static void magic_widget_drop_focus ();
static void close_current_dialog ();
static void keybindings_changed ();
static void save_keybindings ();
static bool load_keybindings (std::string path);

View File

@ -299,11 +299,8 @@ Keyboard::snooper (GtkWidget *widget, GdkEventKey *event)
if (event->type == GDK_KEY_RELEASE && modifier_state_equals (event->state, PrimaryModifier)) {
switch (event->keyval) {
case GDK_w:
if (current_window) {
current_window->hide ();
current_window = 0;
ret = true;
}
close_current_dialog ();
ret = true;
break;
}
}
@ -311,6 +308,15 @@ Keyboard::snooper (GtkWidget *widget, GdkEventKey *event)
return ret;
}
void
Keyboard::close_current_dialog ()
{
if (current_window) {
current_window->hide ();
current_window = 0;
}
}
bool
Keyboard::key_is_down (uint32_t keyval)
{
@ -556,4 +562,3 @@ Keyboard::load_keybindings (string path)
return true;
}

View File

@ -40,6 +40,12 @@ Signal0<void> ControlProtocol::Redo;
Signal1<void,float> ControlProtocol::ScrollTimeline;
Signal1<void,uint32_t> ControlProtocol::SelectByRID;
Signal0<void> ControlProtocol::UnselectTrack;
Signal1<void,uint32_t> ControlProtocol::GotoView;
Signal0<void> ControlProtocol::CloseDialog;
PBD::Signal0<void> ControlProtocol::VerticalZoomInAll;
PBD::Signal0<void> ControlProtocol::VerticalZoomOutAll;
PBD::Signal0<void> ControlProtocol::VerticalZoomInSelected;
PBD::Signal0<void> ControlProtocol::VerticalZoomOutSelected;
ControlProtocol::ControlProtocol (Session& s, string str, EventLoop* evloop)
: BasicUI (s),

View File

@ -65,6 +65,12 @@ class ControlProtocol : virtual public sigc::trackable, public PBD::Stateful, pu
static PBD::Signal1<void,float> ScrollTimeline;
static PBD::Signal1<void,uint32_t> SelectByRID;
static PBD::Signal0<void> UnselectTrack;
static PBD::Signal1<void,uint32_t> GotoView;
static PBD::Signal0<void> CloseDialog;
static PBD::Signal0<void> VerticalZoomInAll;
static PBD::Signal0<void> VerticalZoomOutAll;
static PBD::Signal0<void> VerticalZoomInSelected;
static PBD::Signal0<void> VerticalZoomOutSelected;
/* the model here is as follows:

View File

@ -1276,176 +1276,6 @@ MackieControlProtocol::notify_transport_state_changed()
mcu_port().write (builder.build_led (*rec, record_release (*rec)));
}
LedState
MackieControlProtocol::left_press (Button &)
{
Sorted sorted = get_sorted_routes();
if (sorted.size() > route_table.size()) {
int new_initial = _current_initial_bank - route_table.size();
if (new_initial < 0) {
new_initial = 0;
}
if (new_initial != int (_current_initial_bank)) {
session->set_dirty();
switch_banks (new_initial);
}
return on;
} else {
return flashing;
}
}
LedState
MackieControlProtocol::left_release (Button &)
{
return off;
}
LedState
MackieControlProtocol::right_press (Button &)
{
return off;
}
LedState
MackieControlProtocol::right_release (Button &)
{
if (_zoom_mode) {
}
return off;
}
LedState
MackieControlProtocol::cursor_left_press (Button& )
{
if (_zoom_mode) {
if (_modifier_state & MODIFIER_OPTION) {
/* reset selected tracks to default vertical zoom */
} else {
ZoomOut (); /* EMIT SIGNAL */
}
}
return off;
}
LedState
MackieControlProtocol::cursor_left_release (Button&)
{
return off;
}
LedState
MackieControlProtocol::cursor_right_press (Button& )
{
if (_zoom_mode) {
if (_modifier_state & MODIFIER_OPTION) {
/* reset selected tracks to default vertical zoom */
} else {
ZoomIn (); /* EMIT SIGNAL */
}
}
return off;
}
LedState
MackieControlProtocol::cursor_right_release (Button&)
{
return off;
}
LedState
MackieControlProtocol::cursor_up_press (Button&)
{
return off;
}
LedState
MackieControlProtocol::cursor_up_release (Button&)
{
return off;
}
LedState
MackieControlProtocol::cursor_down_press (Button&)
{
return off;
}
LedState
MackieControlProtocol::cursor_down_release (Button&)
{
return off;
}
LedState
MackieControlProtocol::channel_left_press (Button &)
{
Sorted sorted = get_sorted_routes();
if (sorted.size() > route_table.size()) {
prev_track();
return on;
} else {
return flashing;
}
}
LedState
MackieControlProtocol::channel_left_release (Button &)
{
return off;
}
LedState
MackieControlProtocol::channel_right_press (Button &)
{
Sorted sorted = get_sorted_routes();
if (sorted.size() > route_table.size()) {
next_track();
return on;
} else {
return flashing;
}
}
LedState
MackieControlProtocol::channel_right_release (Button &)
{
return off;
}
/////////////////////////////////////
// Functions
/////////////////////////////////////
LedState
MackieControlProtocol::marker_press (Button &)
{
// cut'n'paste from LocationUI::add_new_location()
string markername;
framepos_t where = session->audible_frame();
session->locations()->next_available_name(markername,"mcu");
Location *location = new Location (*session, where, where, markername, Location::IsMark);
session->begin_reversible_command (_("add marker"));
XMLNode &before = session->locations()->get_state();
session->locations()->add (location, true);
XMLNode &after = session->locations()->get_state();
session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
session->commit_reversible_command ();
return on;
}
LedState
MackieControlProtocol::marker_release (Button &)
{
return off;
}
void
jog_wheel_state_display (JogWheel::State state, SurfacePort & port)

View File

@ -17,6 +17,8 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "pbd/memento_command.h"
#include "ardour/session.h"
#include "ardour/route.h"
#include "ardour/location.h"
@ -24,12 +26,15 @@
#include "mackie_control_protocol.h"
#include "i18n.h"
/* handlers for all buttons, broken into a separate file to avoid clutter in
* mackie_control_protocol.cc
*/
using namespace Mackie;
using namespace ARDOUR;
using std::string;
LedState
MackieControlProtocol::shift_press (Button &)
@ -80,6 +85,192 @@ MackieControlProtocol::cmd_alt_release (Button &)
return on;
}
LedState
MackieControlProtocol::left_press (Button &)
{
Sorted sorted = get_sorted_routes();
if (sorted.size() > route_table.size()) {
int new_initial = _current_initial_bank - route_table.size();
if (new_initial < 0) {
new_initial = 0;
}
if (new_initial != int (_current_initial_bank)) {
session->set_dirty();
switch_banks (new_initial);
}
return on;
} else {
return flashing;
}
}
LedState
MackieControlProtocol::left_release (Button &)
{
return off;
}
LedState
MackieControlProtocol::right_press (Button &)
{
return off;
}
LedState
MackieControlProtocol::right_release (Button &)
{
if (_zoom_mode) {
}
return off;
}
LedState
MackieControlProtocol::cursor_left_press (Button& )
{
if (_zoom_mode) {
if (_modifier_state & MODIFIER_OPTION) {
/* reset selected tracks to default vertical zoom */
} else {
ZoomOut (); /* EMIT SIGNAL */
}
}
return off;
}
LedState
MackieControlProtocol::cursor_left_release (Button&)
{
return off;
}
LedState
MackieControlProtocol::cursor_right_press (Button& )
{
if (_zoom_mode) {
if (_modifier_state & MODIFIER_OPTION) {
/* reset selected tracks to default vertical zoom */
} else {
ZoomIn (); /* EMIT SIGNAL */
}
}
return off;
}
LedState
MackieControlProtocol::cursor_right_release (Button&)
{
return off;
}
LedState
MackieControlProtocol::cursor_up_press (Button&)
{
if (_zoom_mode) {
if (_modifier_state & MODIFIER_OPTION) {
VerticalZoomOutSelected (); /* EMIT SIGNAL */
} else {
VerticalZoomOutAll (); /* EMIT SIGNAL */
}
}
return off;
}
LedState
MackieControlProtocol::cursor_up_release (Button&)
{
return off;
}
LedState
MackieControlProtocol::cursor_down_press (Button&)
{
if (_zoom_mode) {
if (_modifier_state & MODIFIER_OPTION) {
VerticalZoomInSelected (); /* EMIT SIGNAL */
} else {
VerticalZoomInAll (); /* EMIT SIGNAL */
}
}
return off;
}
LedState
MackieControlProtocol::cursor_down_release (Button&)
{
return off;
}
LedState
MackieControlProtocol::channel_left_press (Button &)
{
Sorted sorted = get_sorted_routes();
if (sorted.size() > route_table.size()) {
prev_track();
return on;
} else {
return flashing;
}
}
LedState
MackieControlProtocol::channel_left_release (Button &)
{
return off;
}
LedState
MackieControlProtocol::channel_right_press (Button &)
{
Sorted sorted = get_sorted_routes();
if (sorted.size() > route_table.size()) {
next_track();
return on;
} else {
return flashing;
}
}
LedState
MackieControlProtocol::channel_right_release (Button &)
{
return off;
}
/////////////////////////////////////
// Functions
/////////////////////////////////////
LedState
MackieControlProtocol::marker_press (Button &)
{
// cut'n'paste from LocationUI::add_new_location()
string markername;
framepos_t where = session->audible_frame();
session->locations()->next_available_name(markername,"mcu");
Location *location = new Location (*session, where, where, markername, Location::IsMark);
session->begin_reversible_command (_("add marker"));
XMLNode &before = session->locations()->get_state();
session->locations()->add (location, true);
XMLNode &after = session->locations()->get_state();
session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
session->commit_reversible_command ();
return on;
}
LedState
MackieControlProtocol::marker_release (Button &)
{
return off;
}
/////////////////////////////////////
// Transport Buttons
/////////////////////////////////////
@ -432,6 +623,7 @@ MackieControlProtocol::name_value_release (Button &)
LedState
MackieControlProtocol::F1_press (Button &)
{
GotoView (0); /* EMIT SIGNAL */
return off;
}
LedState
@ -442,6 +634,7 @@ MackieControlProtocol::F1_release (Button &)
LedState
MackieControlProtocol::F2_press (Button &)
{
GotoView (1); /* EMIT SIGNAL */
return off;
}
LedState
@ -452,6 +645,7 @@ MackieControlProtocol::F2_release (Button &)
LedState
MackieControlProtocol::F3_press (Button &)
{
GotoView (2); /* EMIT SIGNAL */
return off;
}
LedState
@ -462,6 +656,7 @@ MackieControlProtocol::F3_release (Button &)
LedState
MackieControlProtocol::F4_press (Button &)
{
GotoView (3); /* EMIT SIGNAL */
return off;
}
LedState
@ -472,6 +667,7 @@ MackieControlProtocol::F4_release (Button &)
LedState
MackieControlProtocol::F5_press (Button &)
{
GotoView (4); /* EMIT SIGNAL */
return off;
}
LedState
@ -482,6 +678,7 @@ MackieControlProtocol::F5_release (Button &)
LedState
MackieControlProtocol::F6_press (Button &)
{
GotoView (5); /* EMIT SIGNAL */
return off;
}
LedState
@ -492,6 +689,7 @@ MackieControlProtocol::F6_release (Button &)
LedState
MackieControlProtocol::F7_press (Button &)
{
GotoView (6); /* EMIT SIGNAL */
return off;
}
LedState
@ -502,6 +700,7 @@ MackieControlProtocol::F7_release (Button &)
LedState
MackieControlProtocol::F8_press (Button &)
{
CloseDialog (); /* EMIT SIGNAL */
return off;
}
LedState
@ -512,6 +711,7 @@ MackieControlProtocol::F8_release (Button &)
LedState
MackieControlProtocol::F9_press (Button &)
{
GotoView (8); /* EMIT SIGNAL */
return off;
}
LedState