X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fstep_entry.cc;h=855766b1c8ea9983dac0ff8227afd0d0905bb81f;hb=cf52d6e4b40111eb04b244ec054055a4ec15dbe0;hp=af439ea26fd1fb0d2cc2250ef68551048b88866f;hpb=d08e3b94c5ef75ce5d4d28f3636faa8af4661e17;p=ardour.git diff --git a/gtk2_ardour/step_entry.cc b/gtk2_ardour/step_entry.cc index af439ea26f..855766b1c8 100644 --- a/gtk2_ardour/step_entry.cc +++ b/gtk2_ardour/step_entry.cc @@ -19,23 +19,21 @@ #include -#include "pbd/filesystem.h" #include "pbd/file_utils.h" -#include "gtkmm2ext/keyboard.h" #include "gtkmm2ext/actions.h" -#include "gtkmm2ext/bindings.h" +#include "gtkmm2ext/keyboard.h" #include "ardour/filesystem_paths.h" -#include "ardour_ui.h" #include "midi_channel_selector.h" #include "midi_time_axis.h" #include "step_editor.h" #include "step_entry.h" +#include "tooltips.h" #include "utils.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace std; using namespace Gtk; @@ -43,6 +41,7 @@ using namespace Glib; using namespace Gtkmm2ext; using namespace PBD; using namespace ARDOUR; +using namespace ARDOUR_UI_UTILS; static void _note_off_event_handler (GtkWidget* /*widget*/, int note, gpointer arg) @@ -57,7 +56,7 @@ _rest_event_handler (GtkWidget* /*widget*/, gpointer arg) } StepEntry::StepEntry (StepEditor& seditor) - : ArdourDialog (string_compose (_("Step Entry: %1"), seditor.name())) + : ArdourWindow (string_compose (_("Step Entry: %1"), seditor.name())) , _current_note_length (1.0) , _current_note_velocity (64) , triplet_button ("3") @@ -69,7 +68,7 @@ StepEntry::StepEntry (StepEditor& seditor) , rest_button (_("rest")) , grid_rest_button (_("g-rest")) , back_button (_("back")) - , channel_adjustment (1, 1, 16, 1, 4) + , channel_adjustment (1, 1, 16, 1, 4) , channel_spinner (channel_adjustment) , octave_adjustment (4, 0, 10, 1, 4) // start in octave 4 , octave_spinner (octave_adjustment) @@ -86,6 +85,7 @@ StepEntry::StepEntry (StepEditor& seditor) , _piano (0) , piano (0) , se (&seditor) + , myactions (X_("step entry")) { register_actions (); load_bindings (); @@ -97,7 +97,7 @@ StepEntry::StepEntry (StepEditor& seditor) */ uint16_t chn_mask = se->channel_selector().get_selected_channels(); - + for (uint32_t i = 0; i < 16; ++i) { if (chn_mask & (1<set_tip (&length_1_button, _("Set note length to a whole note"), ""); - ARDOUR_UI::instance()->set_tip (&length_2_button, _("Set note length to a half note"), ""); - ARDOUR_UI::instance()->set_tip (&length_4_button, _("Set note length to a quarter note"), ""); - ARDOUR_UI::instance()->set_tip (&length_8_button, _("Set note length to a eighth note"), ""); - ARDOUR_UI::instance()->set_tip (&length_16_button, _("Set note length to a sixteenth note"), ""); - ARDOUR_UI::instance()->set_tip (&length_32_button, _("Set note length to a thirty-second note"), ""); - ARDOUR_UI::instance()->set_tip (&length_64_button, _("Set note length to a sixty-fourth note"), ""); + set_tooltip (&length_1_button, _("Set note length to a whole note"), ""); + set_tooltip (&length_2_button, _("Set note length to a half note"), ""); + set_tooltip (&length_4_button, _("Set note length to a quarter note"), ""); + set_tooltip (&length_8_button, _("Set note length to a eighth note"), ""); + set_tooltip (&length_16_button, _("Set note length to a sixteenth note"), ""); + set_tooltip (&length_32_button, _("Set note length to a thirty-second note"), ""); + set_tooltip (&length_64_button, _("Set note length to a sixty-fourth note"), ""); RadioButtonGroup velocity_group = velocity_ppp_button.get_group(); velocity_pp_button.set_group (velocity_group); @@ -273,14 +273,14 @@ StepEntry::StepEntry (StepEditor& seditor) velocity_ff_button.property_draw_indicator() = false; velocity_fff_button.property_draw_indicator() = false; - ARDOUR_UI::instance()->set_tip (&velocity_ppp_button, _("Set volume (velocity) to pianississimo"), ""); - ARDOUR_UI::instance()->set_tip (&velocity_pp_button, _("Set volume (velocity) to pianissimo"), ""); - ARDOUR_UI::instance()->set_tip (&velocity_p_button, _("Set volume (velocity) to piano"), ""); - ARDOUR_UI::instance()->set_tip (&velocity_mp_button, _("Set volume (velocity) to mezzo-piano"), ""); - ARDOUR_UI::instance()->set_tip (&velocity_mf_button, _("Set volume (velocity) to mezzo-forte"), ""); - ARDOUR_UI::instance()->set_tip (&velocity_f_button, _("Set volume (velocity) to forte"), ""); - ARDOUR_UI::instance()->set_tip (&velocity_ff_button, _("Set volume (velocity) to forteissimo"), ""); - ARDOUR_UI::instance()->set_tip (&velocity_fff_button, _("Set volume (velocity) to forteississimo"), ""); + set_tooltip (&velocity_ppp_button, _("Set volume (velocity) to pianississimo"), ""); + set_tooltip (&velocity_pp_button, _("Set volume (velocity) to pianissimo"), ""); + set_tooltip (&velocity_p_button, _("Set volume (velocity) to piano"), ""); + set_tooltip (&velocity_mp_button, _("Set volume (velocity) to mezzo-piano"), ""); + set_tooltip (&velocity_mf_button, _("Set volume (velocity) to mezzo-forte"), ""); + set_tooltip (&velocity_f_button, _("Set volume (velocity) to forte"), ""); + set_tooltip (&velocity_ff_button, _("Set volume (velocity) to fortissimo"), ""); + set_tooltip (&velocity_fff_button, _("Set volume (velocity) to fortississimo"), ""); note_velocity_box.pack_start (velocity_ppp_button, false, false); note_velocity_box.pack_start (velocity_pp_button, false, false); @@ -328,20 +328,20 @@ StepEntry::StepEntry (StepEditor& seditor) resync_box.pack_start (bar_resync_button, true, false); resync_box.pack_start (resync_button, true, false); - ARDOUR_UI::instance()->set_tip (&chord_button, _("Stack inserted notes to form a chord"), ""); - ARDOUR_UI::instance()->set_tip (&sustain_button, _("Extend selected notes by note length"), ""); - ARDOUR_UI::instance()->set_tip (&dot0_button, _("Use undotted note lengths"), ""); - ARDOUR_UI::instance()->set_tip (&dot1_button, _("Use dotted (* 1.5) note lengths"), ""); - ARDOUR_UI::instance()->set_tip (&dot2_button, _("Use double-dotted (* 1.75) note lengths"), ""); - ARDOUR_UI::instance()->set_tip (&dot3_button, _("Use triple-dotted (* 1.875) note lengths"), ""); - ARDOUR_UI::instance()->set_tip (&rest_button, _("Insert a note-length's rest"), ""); - ARDOUR_UI::instance()->set_tip (&grid_rest_button, _("Insert a grid-unit's rest"), ""); - ARDOUR_UI::instance()->set_tip (&beat_resync_button, _("Insert a rest until the next beat"), ""); - ARDOUR_UI::instance()->set_tip (&bar_resync_button, _("Insert a rest until the next bar"), ""); - ARDOUR_UI::instance()->set_tip (&bank_button, _("Insert a bank change message"), ""); - ARDOUR_UI::instance()->set_tip (&program_button, _("Insert a program change message"), ""); - ARDOUR_UI::instance()->set_tip (&back_button, _("Move Insert Position Back by Note Length"), ""); - ARDOUR_UI::instance()->set_tip (&resync_button, _("Move Insert Position to Edit Point"), ""); + set_tooltip (&chord_button, _("Stack inserted notes to form a chord"), ""); + set_tooltip (&sustain_button, _("Extend selected notes by note length"), ""); + set_tooltip (&dot0_button, _("Use undotted note lengths"), ""); + set_tooltip (&dot1_button, _("Use dotted (* 1.5) note lengths"), ""); + set_tooltip (&dot2_button, _("Use double-dotted (* 1.75) note lengths"), ""); + set_tooltip (&dot3_button, _("Use triple-dotted (* 1.875) note lengths"), ""); + set_tooltip (&rest_button, _("Insert a note-length's rest"), ""); + set_tooltip (&grid_rest_button, _("Insert a grid-unit's rest"), ""); + set_tooltip (&beat_resync_button, _("Insert a rest until the next beat"), ""); + set_tooltip (&bar_resync_button, _("Insert a rest until the next bar"), ""); + set_tooltip (&bank_button, _("Insert a bank change message"), ""); + set_tooltip (&program_button, _("Insert a program change message"), ""); + set_tooltip (&back_button, _("Move Insert Position Back by Note Length"), ""); + set_tooltip (&resync_button, _("Move Insert Position to Edit Point"), ""); act = myactions.find_action ("StepEditing/back"); gtk_activatable_set_use_action_appearance (GTK_ACTIVATABLE (back_button.gobj()), false); @@ -376,7 +376,7 @@ StepEntry::StepEntry (StepEditor& seditor) act = myactions.find_action ("StepEditing/sustain"); gtk_activatable_set_use_action_appearance (GTK_ACTIVATABLE (sustain_button.gobj()), false); gtk_activatable_set_related_action (GTK_ACTIVATABLE (sustain_button.gobj()), act->gobj()); - + upper_box.set_spacing (6); upper_box.pack_start (chord_button, false, false); upper_box.pack_start (note_length_box, false, false, 12); @@ -445,7 +445,7 @@ StepEntry::StepEntry (StepEditor& seditor) g_signal_connect(G_OBJECT(_piano), "note-off", G_CALLBACK(_note_off_event_handler), this); g_signal_connect(G_OBJECT(_piano), "rest", G_CALLBACK(_rest_event_handler), this); - + program_button.signal_clicked().connect (sigc::mem_fun (*this, &StepEntry::program_click)); bank_button.signal_clicked().connect (sigc::mem_fun (*this, &StepEntry::bank_click)); beat_resync_button.signal_clicked().connect (sigc::mem_fun (*this, &StepEntry::beat_resync_click)); @@ -458,7 +458,19 @@ StepEntry::StepEntry (StepEditor& seditor) packer.pack_start (*piano, false, false); packer.show_all (); - get_vbox()->add (packer); + add (packer); + + /* initial settings: quarter note and mezzo forte */ + + act = myactions.find_action ("StepEditing/note-length-quarter"); + RefPtr r = RefPtr::cast_dynamic (act); + assert (r); + r->set_active (true); + + act = myactions.find_action ("StepEditing/note-velocity-mf"); + r = RefPtr::cast_dynamic (act); + assert (r); + r->set_active (true); } StepEntry::~StepEntry() @@ -483,29 +495,21 @@ StepEntry::on_key_press_event (GdkEventKey* ev) /* focus widget gets first shot, then bindings, otherwise forward to main window */ - - if (!gtk_window_propagate_key_event (GTK_WINDOW(gobj()), ev)) { - KeyboardKey k (ev->state, ev->keyval); - if (bindings.activate (k, Bindings::Press)) { - return true; - } + if (gtk_window_propagate_key_event (GTK_WINDOW(gobj()), ev)) { + return true; } - return forward_key_press (ev); + return relay_key_press (ev, this); } bool StepEntry::on_key_release_event (GdkEventKey* ev) { - if (!gtk_window_propagate_key_event (GTK_WINDOW(gobj()), ev)) { - KeyboardKey k (ev->state, ev->keyval); - - if (bindings.activate (k, Bindings::Release)) { - return true; - } + if (gtk_window_propagate_key_event (GTK_WINDOW(gobj()), ev)) { + return true; } - + /* don't forward releases */ return true; @@ -514,14 +518,14 @@ StepEntry::on_key_release_event (GdkEventKey* ev) void StepEntry::rest_event_handler () { - se->step_edit_rest (0.0); + se->step_edit_rest (Evoral::Beats()); } -Evoral::MusicalTime +Evoral::Beats StepEntry::note_length () { - Evoral::MusicalTime base_time = 1.0 / (Evoral::MusicalTime) length_divisor_adjustment.get_value(); - + double base_time = 4.0 / (double) length_divisor_adjustment.get_value(); + RefPtr act = myactions.find_action ("StepEditing/toggle-triplet"); RefPtr tact = RefPtr::cast_dynamic (act); bool triplets = tact->get_active (); @@ -537,16 +541,16 @@ StepEntry::note_length () base_time *= 1 + ((dots - 1.0)/dots); } - return base_time; + return Evoral::Beats(base_time); } uint8_t StepEntry::note_velocity () const { - return (Evoral::MusicalTime) velocity_adjustment.get_value(); + return velocity_adjustment.get_value(); } -uint8_t +uint8_t StepEntry::note_channel() const { return channel_adjustment.get_value() - 1; @@ -562,7 +566,7 @@ StepEntry::note_off_event_handler (int note) void StepEntry::on_show () { - ArdourDialog::on_show (); + ArdourWindow::on_show (); //piano->grab_focus (); } @@ -581,127 +585,117 @@ StepEntry::bar_resync_click () void StepEntry::register_actions () { - /* add named actions for the editor */ - - myactions.register_action ("StepEditing", "insert-a", _("Insert Note A"), sigc::mem_fun (*this, &StepEntry::insert_a)); - myactions.register_action ("StepEditing", "insert-asharp", _("Insert Note A-sharp"), sigc::mem_fun (*this, &StepEntry::insert_asharp)); - myactions.register_action ("StepEditing", "insert-b", _("Insert Note B"), sigc::mem_fun (*this, &StepEntry::insert_b)); - myactions.register_action ("StepEditing", "insert-c", _("Insert Note C"), sigc::mem_fun (*this, &StepEntry::insert_c)); - myactions.register_action ("StepEditing", "insert-csharp", _("Insert Note C-sharp"), sigc::mem_fun (*this, &StepEntry::insert_csharp)); - myactions.register_action ("StepEditing", "insert-d", _("Insert Note D"), sigc::mem_fun (*this, &StepEntry::insert_d)); - myactions.register_action ("StepEditing", "insert-dsharp", _("Insert Note D-sharp"), sigc::mem_fun (*this, &StepEntry::insert_dsharp)); - myactions.register_action ("StepEditing", "insert-e", _("Insert Note E"), sigc::mem_fun (*this, &StepEntry::insert_e)); - myactions.register_action ("StepEditing", "insert-f", _("Insert Note F"), sigc::mem_fun (*this, &StepEntry::insert_f)); - myactions.register_action ("StepEditing", "insert-fsharp", _("Insert Note F-sharp"), sigc::mem_fun (*this, &StepEntry::insert_fsharp)); - myactions.register_action ("StepEditing", "insert-g", _("Insert Note G"), sigc::mem_fun (*this, &StepEntry::insert_g)); - myactions.register_action ("StepEditing", "insert-gsharp", _("Insert Note G-sharp"), sigc::mem_fun (*this, &StepEntry::insert_gsharp)); - - myactions.register_action ("StepEditing", "insert-rest", _("Insert a Note-length Rest"), sigc::mem_fun (*this, &StepEntry::insert_rest)); - myactions.register_action ("StepEditing", "insert-snap-rest", _("Insert a Snap-length Rest"), sigc::mem_fun (*this, &StepEntry::insert_grid_rest)); - - myactions.register_action ("StepEditing", "next-octave", _("Move to next octave"), sigc::mem_fun (*this, &StepEntry::next_octave)); - myactions.register_action ("StepEditing", "prev-octave", _("Move to next octave"), sigc::mem_fun (*this, &StepEntry::prev_octave)); - - myactions.register_action ("StepEditing", "next-note-length", _("Move to Next Note Length"), sigc::mem_fun (*this, &StepEntry::next_note_length)); - myactions.register_action ("StepEditing", "prev-note-length", _("Move to Previous Note Length"), sigc::mem_fun (*this, &StepEntry::prev_note_length)); - - myactions.register_action ("StepEditing", "inc-note-length", _("Increase Note Length"), sigc::mem_fun (*this, &StepEntry::inc_note_length)); - myactions.register_action ("StepEditing", "dec-note-length", _("Decrease Note Length"), sigc::mem_fun (*this, &StepEntry::dec_note_length)); - - myactions.register_action ("StepEditing", "next-note-velocity", _("Move to Next Note Velocity"), sigc::mem_fun (*this, &StepEntry::next_note_velocity)); - myactions.register_action ("StepEditing", "prev-note-velocity", _("Move to Previous Note Velocity"), sigc::mem_fun (*this, &StepEntry::prev_note_velocity)); - - myactions.register_action ("StepEditing", "inc-note-velocity", _("Increase Note Velocity"), sigc::mem_fun (*this, &StepEntry::inc_note_velocity)); - myactions.register_action ("StepEditing", "dec-note-velocity", _("Decrease Note Velocity"), sigc::mem_fun (*this, &StepEntry::dec_note_velocity)); - - myactions.register_action ("StepEditing", "octave-0", _("Switch to the 1st octave"), sigc::mem_fun (*this, &StepEntry::octave_0)); - myactions.register_action ("StepEditing", "octave-1", _("Switch to the 2nd octave"), sigc::mem_fun (*this, &StepEntry::octave_1)); - myactions.register_action ("StepEditing", "octave-2", _("Switch to the 3rd octave"), sigc::mem_fun (*this, &StepEntry::octave_2)); - myactions.register_action ("StepEditing", "octave-3", _("Switch to the 4th octave"), sigc::mem_fun (*this, &StepEntry::octave_3)); - myactions.register_action ("StepEditing", "octave-4", _("Switch to the 5th octave"), sigc::mem_fun (*this, &StepEntry::octave_4)); - myactions.register_action ("StepEditing", "octave-5", _("Switch to the 6th octave"), sigc::mem_fun (*this, &StepEntry::octave_5)); - myactions.register_action ("StepEditing", "octave-6", _("Switch to the 7th octave"), sigc::mem_fun (*this, &StepEntry::octave_6)); - myactions.register_action ("StepEditing", "octave-7", _("Switch to the 8th octave"), sigc::mem_fun (*this, &StepEntry::octave_7)); - myactions.register_action ("StepEditing", "octave-8", _("Switch to the 9th octave"), sigc::mem_fun (*this, &StepEntry::octave_8)); - myactions.register_action ("StepEditing", "octave-9", _("Switch to the 10th octave"), sigc::mem_fun (*this, &StepEntry::octave_9)); - myactions.register_action ("StepEditing", "octave-10", _("Switch to the 11th octave"), sigc::mem_fun (*this, &StepEntry::octave_10)); + /* add named actions for the step editor */ + + Glib::RefPtr group = myactions.create_action_group (X_("StepEditing")); + + myactions.register_action (group, "insert-a", _("Insert Note A"), sigc::mem_fun (*this, &StepEntry::insert_a)); + myactions.register_action (group, "insert-asharp", _("Insert Note A-sharp"), sigc::mem_fun (*this, &StepEntry::insert_asharp)); + myactions.register_action (group, "insert-b", _("Insert Note B"), sigc::mem_fun (*this, &StepEntry::insert_b)); + myactions.register_action (group, "insert-c", _("Insert Note C"), sigc::mem_fun (*this, &StepEntry::insert_c)); + myactions.register_action (group, "insert-csharp", _("Insert Note C-sharp"), sigc::mem_fun (*this, &StepEntry::insert_csharp)); + myactions.register_action (group, "insert-d", _("Insert Note D"), sigc::mem_fun (*this, &StepEntry::insert_d)); + myactions.register_action (group, "insert-dsharp", _("Insert Note D-sharp"), sigc::mem_fun (*this, &StepEntry::insert_dsharp)); + myactions.register_action (group, "insert-e", _("Insert Note E"), sigc::mem_fun (*this, &StepEntry::insert_e)); + myactions.register_action (group, "insert-f", _("Insert Note F"), sigc::mem_fun (*this, &StepEntry::insert_f)); + myactions.register_action (group, "insert-fsharp", _("Insert Note F-sharp"), sigc::mem_fun (*this, &StepEntry::insert_fsharp)); + myactions.register_action (group, "insert-g", _("Insert Note G"), sigc::mem_fun (*this, &StepEntry::insert_g)); + myactions.register_action (group, "insert-gsharp", _("Insert Note G-sharp"), sigc::mem_fun (*this, &StepEntry::insert_gsharp)); + + myactions.register_action (group, "insert-rest", _("Insert a Note-length Rest"), sigc::mem_fun (*this, &StepEntry::insert_rest)); + myactions.register_action (group, "insert-snap-rest", _("Insert a Snap-length Rest"), sigc::mem_fun (*this, &StepEntry::insert_grid_rest)); + + myactions.register_action (group, "next-octave", _("Move to next octave"), sigc::mem_fun (*this, &StepEntry::next_octave)); + myactions.register_action (group, "prev-octave", _("Move to next octave"), sigc::mem_fun (*this, &StepEntry::prev_octave)); + + myactions.register_action (group, "next-note-length", _("Move to Next Note Length"), sigc::mem_fun (*this, &StepEntry::next_note_length)); + myactions.register_action (group, "prev-note-length", _("Move to Previous Note Length"), sigc::mem_fun (*this, &StepEntry::prev_note_length)); + + myactions.register_action (group, "inc-note-length", _("Increase Note Length"), sigc::mem_fun (*this, &StepEntry::inc_note_length)); + myactions.register_action (group, "dec-note-length", _("Decrease Note Length"), sigc::mem_fun (*this, &StepEntry::dec_note_length)); + + myactions.register_action (group, "next-note-velocity", _("Move to Next Note Velocity"), sigc::mem_fun (*this, &StepEntry::next_note_velocity)); + myactions.register_action (group, "prev-note-velocity", _("Move to Previous Note Velocity"), sigc::mem_fun (*this, &StepEntry::prev_note_velocity)); + + myactions.register_action (group, "inc-note-velocity", _("Increase Note Velocity"), sigc::mem_fun (*this, &StepEntry::inc_note_velocity)); + myactions.register_action (group, "dec-note-velocity", _("Decrease Note Velocity"), sigc::mem_fun (*this, &StepEntry::dec_note_velocity)); + + myactions.register_action (group, "octave-0", _("Switch to the 1st octave"), sigc::mem_fun (*this, &StepEntry::octave_0)); + myactions.register_action (group, "octave-1", _("Switch to the 2nd octave"), sigc::mem_fun (*this, &StepEntry::octave_1)); + myactions.register_action (group, "octave-2", _("Switch to the 3rd octave"), sigc::mem_fun (*this, &StepEntry::octave_2)); + myactions.register_action (group, "octave-3", _("Switch to the 4th octave"), sigc::mem_fun (*this, &StepEntry::octave_3)); + myactions.register_action (group, "octave-4", _("Switch to the 5th octave"), sigc::mem_fun (*this, &StepEntry::octave_4)); + myactions.register_action (group, "octave-5", _("Switch to the 6th octave"), sigc::mem_fun (*this, &StepEntry::octave_5)); + myactions.register_action (group, "octave-6", _("Switch to the 7th octave"), sigc::mem_fun (*this, &StepEntry::octave_6)); + myactions.register_action (group, "octave-7", _("Switch to the 8th octave"), sigc::mem_fun (*this, &StepEntry::octave_7)); + myactions.register_action (group, "octave-8", _("Switch to the 9th octave"), sigc::mem_fun (*this, &StepEntry::octave_8)); + myactions.register_action (group, "octave-9", _("Switch to the 10th octave"), sigc::mem_fun (*this, &StepEntry::octave_9)); + myactions.register_action (group, "octave-10", _("Switch to the 11th octave"), sigc::mem_fun (*this, &StepEntry::octave_10)); + + myactions.register_toggle_action (group, "toggle-triplet", _("Toggle Triple Notes"), + sigc::mem_fun (*this, &StepEntry::toggle_triplet)); + + myactions.register_toggle_action (group, "toggle-chord", _("Toggle Chord Entry"), + sigc::mem_fun (*this, &StepEntry::toggle_chord)); + myactions.register_action (group, "sustain", _("Sustain Selected Notes by Note Length"), + sigc::mem_fun (*this, &StepEntry::do_sustain)); + myactions.register_action (group, "sync-to-edit-point", _("Move Insert Position to Edit Point"), + sigc::mem_fun (*this, &StepEntry::sync_to_edit_point)); + myactions.register_action (group, "back", _("Move Insert Position Back by Note Length"), + sigc::mem_fun (*this, &StepEntry::back)); RadioAction::Group note_length_group; - myactions.register_radio_action ("StepEditing", note_length_group, "note-length-whole", + myactions.register_radio_action (group, note_length_group, "note-length-whole", _("Set Note Length to Whole"), sigc::mem_fun (*this, &StepEntry::note_length_change), 1); - myactions.register_radio_action ("StepEditing", note_length_group, "note-length-half", + myactions.register_radio_action (group, note_length_group, "note-length-half", _("Set Note Length to 1/2"), sigc::mem_fun (*this, &StepEntry::note_length_change), 2); - myactions.register_radio_action ("StepEditing", note_length_group, "note-length-third", + myactions.register_radio_action (group, note_length_group, "note-length-third", _("Set Note Length to 1/3"), sigc::mem_fun (*this, &StepEntry::note_length_change), 3); - myactions.register_radio_action ("StepEditing", note_length_group, "note-length-quarter", + myactions.register_radio_action (group, note_length_group, "note-length-quarter", _("Set Note Length to 1/4"), sigc::mem_fun (*this, &StepEntry::note_length_change), 4); - myactions.register_radio_action ("StepEditing", note_length_group, "note-length-eighth", + myactions.register_radio_action (group, note_length_group, "note-length-eighth", _("Set Note Length to 1/8"), sigc::mem_fun (*this, &StepEntry::note_length_change), 8); - myactions.register_radio_action ("StepEditing", note_length_group, "note-length-sixteenth", + myactions.register_radio_action (group, note_length_group, "note-length-sixteenth", _("Set Note Length to 1/16"), sigc::mem_fun (*this, &StepEntry::note_length_change), 16); - myactions.register_radio_action ("StepEditing", note_length_group, "note-length-thirtysecond", + myactions.register_radio_action (group, note_length_group, "note-length-thirtysecond", _("Set Note Length to 1/32"), sigc::mem_fun (*this, &StepEntry::note_length_change), 32); - myactions.register_radio_action ("StepEditing", note_length_group, "note-length-sixtyfourth", + myactions.register_radio_action (group, note_length_group, "note-length-sixtyfourth", _("Set Note Length to 1/64"), sigc::mem_fun (*this, &StepEntry::note_length_change), 64); RadioAction::Group note_velocity_group; - myactions.register_radio_action ("StepEditing", note_velocity_group, "note-velocity-ppp", + myactions.register_radio_action (group, note_velocity_group, "note-velocity-ppp", _("Set Note Velocity to Pianississimo"), sigc::mem_fun (*this, &StepEntry::note_velocity_change), 1); - myactions.register_radio_action ("StepEditing", note_velocity_group, "note-velocity-pp", + myactions.register_radio_action (group, note_velocity_group, "note-velocity-pp", _("Set Note Velocity to Pianissimo"), sigc::mem_fun (*this, &StepEntry::note_velocity_change), 16); - myactions.register_radio_action ("StepEditing", note_velocity_group, "note-velocity-p", + myactions.register_radio_action (group, note_velocity_group, "note-velocity-p", _("Set Note Velocity to Piano"), sigc::mem_fun (*this, &StepEntry::note_velocity_change), 32); - myactions.register_radio_action ("StepEditing", note_velocity_group, "note-velocity-mp", + myactions.register_radio_action (group, note_velocity_group, "note-velocity-mp", _("Set Note Velocity to Mezzo-Piano"), sigc::mem_fun (*this, &StepEntry::note_velocity_change), 64); - myactions.register_radio_action ("StepEditing", note_velocity_group, "note-velocity-mf", + myactions.register_radio_action (group, note_velocity_group, "note-velocity-mf", _("Set Note Velocity to Mezzo-Forte"), sigc::mem_fun (*this, &StepEntry::note_velocity_change), 80); - myactions.register_radio_action ("StepEditing", note_velocity_group, "note-velocity-f", + myactions.register_radio_action (group, note_velocity_group, "note-velocity-f", _("Set Note Velocity to Forte"), sigc::mem_fun (*this, &StepEntry::note_velocity_change), 96); - myactions.register_radio_action ("StepEditing", note_velocity_group, "note-velocity-ff", + myactions.register_radio_action (group, note_velocity_group, "note-velocity-ff", _("Set Note Velocity to Fortississimo"), sigc::mem_fun (*this, &StepEntry::note_velocity_change), 112); - myactions.register_radio_action ("StepEditing", note_velocity_group, "note-velocity-fff", + myactions.register_radio_action (group, note_velocity_group, "note-velocity-fff", _("Set Note Velocity to Fortississimo"), sigc::mem_fun (*this, &StepEntry::note_velocity_change), 127); - myactions.register_toggle_action ("StepEditing", "toggle-triplet", _("Toggle Triple Notes"), - sigc::mem_fun (*this, &StepEntry::toggle_triplet)); RadioAction::Group dot_group; - myactions.register_radio_action ("StepEditing", dot_group, "no-dotted", _("No Dotted Notes"), - sigc::mem_fun (*this, &StepEntry::dot_change), 0); - myactions.register_radio_action ("StepEditing", dot_group, "toggle-dotted", _("Toggled Dotted Notes"), - sigc::mem_fun (*this, &StepEntry::dot_change), 1); - myactions.register_radio_action ("StepEditing", dot_group, "toggle-double-dotted", _("Toggled Double-Dotted Notes"), - sigc::mem_fun (*this, &StepEntry::dot_change), 2); - myactions.register_radio_action ("StepEditing", dot_group, "toggle-triple-dotted", _("Toggled Triple-Dotted Notes"), - sigc::mem_fun (*this, &StepEntry::dot_change), 3); - - myactions.register_toggle_action ("StepEditing", "toggle-chord", _("Toggle Chord Entry"), - sigc::mem_fun (*this, &StepEntry::toggle_chord)); - myactions.register_action ("StepEditing", "sustain", _("Sustain Selected Notes by Note Length"), - sigc::mem_fun (*this, &StepEntry::do_sustain)); - - myactions.register_action ("StepEditing", "sync-to-edit-point", _("Move Insert Position to Edit Point"), - sigc::mem_fun (*this, &StepEntry::sync_to_edit_point)); - myactions.register_action ("StepEditing", "back", _("Move Insert Position Back by Note Length"), - sigc::mem_fun (*this, &StepEntry::back)); + myactions.register_radio_action (group, dot_group, "no-dotted", _("No Dotted Notes"), sigc::mem_fun (*this, &StepEntry::dot_change), 0); + myactions.register_radio_action (group, dot_group, "toggle-dotted", _("Toggled Dotted Notes"), sigc::mem_fun (*this, &StepEntry::dot_change), 1); + myactions.register_radio_action (group, dot_group, "toggle-double-dotted", _("Toggled Double-Dotted Notes"), sigc::mem_fun (*this, &StepEntry::dot_change), 2); + myactions.register_radio_action (group, dot_group, "toggle-triple-dotted", _("Toggled Triple-Dotted Notes"), sigc::mem_fun (*this, &StepEntry::dot_change), 3); } void StepEntry::load_bindings () { - /* XXX move this to a better place */ - - bindings.set_action_map (myactions); - - sys::path binding_file; - SearchPath spath = ardour_search_path() + user_config_directory() + system_config_search_path(); - - if (find_file_in_search_path (spath, "step_editing.bindings", binding_file)) { - bindings.load (binding_file.to_string()); - } + bindings = Bindings::get_bindings (X_("Step Editing"), myactions); + set_data ("ardour-bindings", bindings); } void @@ -742,11 +736,11 @@ StepEntry::dot_value_change () for (vector::iterator i = dot_actions.begin(); i != dot_actions.end(); ++i) { act = myactions.find_action (*i); - + if (act) { ract = RefPtr::cast_dynamic (act); - if (ract) { + if (ract) { if (ract->property_value() == val) { ract->set_active (true); inconsistent = false; @@ -755,7 +749,7 @@ StepEntry::dot_value_change () } } } - + dot1_button.set_inconsistent (inconsistent); dot2_button.set_inconsistent (inconsistent); dot3_button.set_inconsistent (inconsistent); @@ -784,12 +778,16 @@ StepEntry::insert_rest () void StepEntry::insert_grid_rest () { - se->step_edit_rest (0.0); + se->step_edit_rest (Evoral::Beats()); } void StepEntry::insert_note (uint8_t note) { + if (note > 127) { + return; + } + se->step_add_note (note_channel(), note, note_velocity(), note_length()); } void @@ -865,7 +863,7 @@ StepEntry::note_length_change (GtkAction* act) becaome "active". so ... only bother to actually change the value when this is called for the "active" action. */ - + if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION(act))) { gint v = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (act)); length_divisor_adjustment.set_value (v); @@ -882,7 +880,7 @@ StepEntry::note_velocity_change (GtkAction* act) becaome "active". so ... only bother to actually change the value when this is called for the "active" action. */ - + if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION(act))) { gint v = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (act)); velocity_adjustment.set_value (v); @@ -910,11 +908,11 @@ StepEntry::velocity_value_change () for (vector::iterator i = velocity_actions.begin(); i != velocity_actions.end(); ++i) { act = myactions.find_action (*i); - + if (act) { ract = RefPtr::cast_dynamic (act); - if (ract) { + if (ract) { if (ract->property_value() == val) { ract->set_active (true); inconsistent = false; @@ -954,11 +952,11 @@ StepEntry::length_value_change () for (vector::iterator i = length_actions.begin(); i != length_actions.end(); ++i) { act = myactions.find_action (*i); - + if (act) { ract = RefPtr::cast_dynamic (act); - if (ract) { + if (ract) { if (ract->property_value() == val) { ract->set_active (true); inconsistent = false; @@ -984,7 +982,7 @@ StepEntry::radio_button_press (GdkEventButton* ev) { if (ev->button == 1) { return true; - } + } return false; } @@ -994,13 +992,13 @@ StepEntry::radio_button_release (GdkEventButton* ev, RadioButton* btn, int v) { if (ev->button == 1) { GtkAction* act = gtk_activatable_get_related_action (GTK_ACTIVATABLE (btn->gobj())); - + if (act) { gtk_radio_action_set_current_value (GTK_RADIO_ACTION(act), v); } - + return true; - } + } return false; } @@ -1097,7 +1095,7 @@ StepEntry::next_note_velocity () } else if (l < 127) { l = 127; } - + velocity_adjustment.set_value (l); } @@ -1123,7 +1121,7 @@ StepEntry::prev_note_velocity () } else { l = 1; } - + velocity_adjustment.set_value (l); }