X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fstep_entry.cc;h=ace02c0c68d50678ba6e53fc278d701ab62c4ee9;hb=c912bd61ae49cc79158f3322439c29b27ef51de8;hp=f290f94e10b92e40f2a865d0b1f02382eedd3b65;hpb=3e5d4779895e06fe8b84fd814eab18b32cfe66e1;p=ardour.git diff --git a/gtk2_ardour/step_entry.cc b/gtk2_ardour/step_entry.cc index f290f94e10..ace02c0c68 100644 --- a/gtk2_ardour/step_entry.cc +++ b/gtk2_ardour/step_entry.cc @@ -19,7 +19,6 @@ #include -#include "pbd/filesystem.h" #include "pbd/file_utils.h" #include "gtkmm2ext/keyboard.h" @@ -43,6 +42,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 +57,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,9 +69,9 @@ 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, 1, 11, 1, 4) // start in octave 4 + , octave_adjustment (4, 0, 10, 1, 4) // start in octave 4 , octave_spinner (octave_adjustment) , length_divisor_adjustment (1.0, 1.0, 128, 1.0, 4.0) , length_divisor_spinner (length_divisor_adjustment) @@ -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 (&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"), ""); + ARDOUR_UI::instance()->set_tip (&velocity_ff_button, _("Set volume (velocity) to fortissimo"), ""); + ARDOUR_UI::instance()->set_tip (&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); @@ -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,11 +495,11 @@ 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, KeyboardKey::Press)) { + if (bindings.activate (k, Bindings::Press)) { return true; } } @@ -501,11 +513,11 @@ 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, KeyboardKey::Release)) { + if (bindings.activate (k, Bindings::Release)) { return true; } } - + /* don't forward releases */ return true; @@ -514,14 +526,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 +549,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 +574,7 @@ StepEntry::note_off_event_handler (int note) void StepEntry::on_show () { - ArdourDialog::on_show (); + ArdourWindow::on_show (); //piano->grab_focus (); } @@ -614,25 +626,25 @@ StepEntry::register_actions () 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-1", _("Switch to the 1st octave"), sigc::mem_fun (*this, &StepEntry::octave_1)); - myactions.register_action ("StepEditing", "octave-2", _("Switch to the 2nd octave"), sigc::mem_fun (*this, &StepEntry::octave_2)); - myactions.register_action ("StepEditing", "octave-3", _("Switch to the 3rd octave"), sigc::mem_fun (*this, &StepEntry::octave_3)); - myactions.register_action ("StepEditing", "octave-4", _("Switch to the 4th octave"), sigc::mem_fun (*this, &StepEntry::octave_4)); - myactions.register_action ("StepEditing", "octave-5", _("Switch to the 5th octave"), sigc::mem_fun (*this, &StepEntry::octave_5)); - myactions.register_action ("StepEditing", "octave-6", _("Switch to the 6th octave"), sigc::mem_fun (*this, &StepEntry::octave_6)); - myactions.register_action ("StepEditing", "octave-7", _("Switch to the 7th octave"), sigc::mem_fun (*this, &StepEntry::octave_7)); - myactions.register_action ("StepEditing", "octave-8", _("Switch to the 8th octave"), sigc::mem_fun (*this, &StepEntry::octave_8)); - myactions.register_action ("StepEditing", "octave-9", _("Switch to the 9th octave"), sigc::mem_fun (*this, &StepEntry::octave_9)); - myactions.register_action ("StepEditing", "octave-10", _("Switch to the 10th octave"), sigc::mem_fun (*this, &StepEntry::octave_10)); - myactions.register_action ("StepEditing", "octave-11", _("Switch to the 11th octave"), sigc::mem_fun (*this, &StepEntry::octave_11)); + 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)); RadioAction::Group note_length_group; - myactions.register_radio_action ("StepEditing", note_length_group, "note-length-whole", + myactions.register_radio_action ("StepEditing", 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 ("StepEditing", 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 ("StepEditing", 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", _("Set Note Length to 1/4"), sigc::mem_fun (*this, &StepEntry::note_length_change), 4); @@ -669,13 +681,13 @@ StepEntry::register_actions () RadioAction::Group dot_group; - myactions.register_radio_action ("StepEditing", dot_group, "no-dotted", _("No Dotted Notes"), + 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"), + 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"), + 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"), + 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"), @@ -693,15 +705,13 @@ void StepEntry::load_bindings () { /* XXX move this to a better place */ - KeyboardKey::set_ignored_state (GDK_LOCK_MASK|GDK_MOD2_MASK|GDK_MOD3_MASK); bindings.set_action_map (myactions); - sys::path binding_file; - SearchPath spath = ardour_search_path() + user_config_directory() + system_config_search_path(); + std::string binding_file; - if (find_file_in_search_path (spath, "step_editing.bindings", binding_file)) { - bindings.load (binding_file.to_string()); + if (find_file (ardour_config_search_path(), "step_editing.bindings", binding_file)) { + bindings.load (binding_file); } } @@ -743,11 +753,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; @@ -756,7 +766,7 @@ StepEntry::dot_value_change () } } } - + dot1_button.set_inconsistent (inconsistent); dot2_button.set_inconsistent (inconsistent); dot3_button.set_inconsistent (inconsistent); @@ -785,75 +795,79 @@ 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 StepEntry::insert_c () { - insert_note (0 + ((current_octave() - 1) * 12)); + insert_note (0 + (current_octave() * 12)); } void StepEntry::insert_csharp () { - insert_note (1 + ((current_octave() - 1) * 12)); + insert_note (1 + (current_octave() * 12)); } void StepEntry::insert_d () { - insert_note (2 + ((current_octave() - 1) * 12)); + insert_note (2 + (current_octave() * 12)); } void StepEntry::insert_dsharp () { - insert_note (3 + ((current_octave() - 1) * 12)); + insert_note (3 + (current_octave() * 12)); } void StepEntry::insert_e () { - insert_note (4 + ((current_octave() - 1) * 12)); + insert_note (4 + (current_octave() * 12)); } void StepEntry::insert_f () { - insert_note (5 + ((current_octave() - 1) * 12)); + insert_note (5 + (current_octave() * 12)); } void StepEntry::insert_fsharp () { - insert_note (6 + ((current_octave() - 1) * 12)); + insert_note (6 + (current_octave() * 12)); } void StepEntry::insert_g () { - insert_note (7 + ((current_octave() - 1) * 12)); + insert_note (7 + (current_octave() * 12)); } void StepEntry::insert_gsharp () { - insert_note (8 + ((current_octave() - 1) * 12)); + insert_note (8 + (current_octave() * 12)); } void StepEntry::insert_a () { - insert_note (9 + ((current_octave() - 1) * 12)); + insert_note (9 + (current_octave() * 12)); } void StepEntry::insert_asharp () { - insert_note (10 + ((current_octave() - 1) * 12)); + insert_note (10 + (current_octave() * 12)); } void StepEntry::insert_b () { - insert_note (11 + ((current_octave() - 1) * 12)); + insert_note (11 + (current_octave() * 12)); } void @@ -866,7 +880,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); @@ -883,7 +897,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); @@ -911,11 +925,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; @@ -955,11 +969,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; @@ -985,7 +999,7 @@ StepEntry::radio_button_press (GdkEventButton* ev) { if (ev->button == 1) { return true; - } + } return false; } @@ -995,13 +1009,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; } @@ -1098,7 +1112,7 @@ StepEntry::next_note_velocity () } else if (l < 127) { l = 127; } - + velocity_adjustment.set_value (l); } @@ -1124,7 +1138,7 @@ StepEntry::prev_note_velocity () } else { l = 1; } - + velocity_adjustment.set_value (l); }