StepEditor::StepEditor (PublicEditor& e, boost::shared_ptr<MidiTrack> t, MidiTimeAxisView& mtv)
: _editor (e)
, _track (t)
- , step_editor (0)
, _mtv (mtv)
{
step_edit_insert_position = 0;
StepEditor::~StepEditor()
{
- delete step_editor;
+ StepEntry::instance().set_step_editor (0);
}
void
assert (step_edit_region);
assert (step_edit_region_view);
- if (step_editor == 0) {
- step_editor = new StepEntry (*this);
- step_editor->signal_delete_event().connect (sigc::mem_fun (*this, &StepEditor::step_editor_hidden));
- step_editor->signal_hide().connect (sigc::mem_fun (*this, &StepEditor::step_editor_hide));
- }
+ StepEntry::instance().set_step_editor (this);
+ StepEntry::instance().signal_delete_event().connect (sigc::mem_fun (*this, &StepEditor::step_entry_hidden));
+ StepEntry::instance(). signal_hide().connect (sigc::mem_fun (*this, &StepEditor::step_entry_hide));
step_edit_region_view->show_step_edit_cursor (step_edit_beat_pos);
- step_edit_region_view->set_step_edit_cursor_width (step_editor->note_length());
+ step_edit_region_view->set_step_edit_cursor_width (StepEntry::instance().note_length());
- step_editor->present ();
+ StepEntry::instance().present ();
}
void
}
bool
-StepEditor::step_editor_hidden (GdkEventAny*)
+StepEditor::step_entry_hidden (GdkEventAny*)
{
- step_editor_hide ();
+ step_entry_hide ();
return true; // XXX remember position ?!
}
void
-StepEditor::step_editor_hide ()
+StepEditor::step_entry_hide ()
{
/* everything else will follow the change in the model */
_track->set_step_editing (false);
void
StepEditor::stop_step_editing ()
{
- if (step_editor) {
- step_editor->hide ();
- }
+ StepEntry::instance().hide ();
if (step_edit_region_view) {
step_edit_region_view->hide_step_edit_cursor();
prepare_step_edit_region ();
reset_step_edit_beat_pos ();
step_edit_region_view->show_step_edit_cursor (step_edit_beat_pos);
- step_edit_region_view->set_step_edit_cursor_width (step_editor->note_length());
+ step_edit_region_view->set_step_edit_cursor_width (StepEntry::instance().note_length());
}
assert (step_edit_region);
assert (step_edit_region_view);
- if (beat_duration == 0.0 && step_editor) {
- beat_duration = step_editor->note_length();
+ if (beat_duration == 0.0) {
+ beat_duration = StepEntry::instance().note_length();
} else if (beat_duration == 0.0) {
bool success;
beat_duration = _editor.get_grid_type_as_beats (success, step_edit_insert_position);
_step_edit_chord_duration = max (_step_edit_chord_duration, beat_duration);
}
- step_edit_region_view->set_step_edit_cursor_width (step_editor->note_length());
+ step_edit_region_view->set_step_edit_cursor_width (StepEntry::instance().note_length());
return 0;
}
PBD::ScopedConnection step_edit_region_connection;
PublicEditor& _editor;
boost::shared_ptr<ARDOUR::MidiTrack> _track;
- StepEntry* step_editor;
MidiTimeAxisView& _mtv;
int8_t last_added_pitch;
Temporal::Beats last_added_end;
void region_removed (boost::weak_ptr<ARDOUR::Region>);
void playlist_changed ();
- bool step_editor_hidden (GdkEventAny*);
- void step_editor_hide ();
+ bool step_entry_hidden (GdkEventAny*);
+ void step_entry_hide ();
void resync_step_edit_position ();
void prepare_step_edit_region ();
};
using namespace ArdourWidgets;
Gtkmm2ext::Bindings* StepEntry::bindings = 0;
-StepEntry* StepEntry::_current_step_entry = 0;
+StepEntry* StepEntry::_instance = 0;
static void
_note_off_event_handler (GtkWidget* /*widget*/, int note, gpointer arg)
((StepEntry*)arg)->rest_event_handler ();
}
-StepEntry::StepEntry (StepEditor& seditor)
- : ArdourWindow (string_compose (_("Step Entry: %1"), seditor.name()))
+StepEntry&
+StepEntry::instance()
+{
+ if (!_instance) {
+ _instance = new StepEntry;
+ }
+
+ return *_instance;
+}
+
+StepEntry::StepEntry ()
+ : ArdourWindow (string())
, _current_note_length (1.0)
, _current_note_velocity (64)
, triplet_button ("3")
, program_button (_("+"))
, _piano (0)
, piano (0)
- , se (&seditor)
+ , se (0)
{
set_data ("ardour-bindings", bindings);
-#if 0
- /* set channel selector to first selected channel. if none
- are selected, it will remain at the value set in its
- constructor, above (1)
- */
-
- uint16_t chn_mask = se->channel_selector().get_selected_channels();
-
- for (uint32_t i = 0; i < 16; ++i) {
- if (chn_mask & (1<<i)) {
- channel_adjustment.set_value (i+1);
- break;
- }
- }
-
-#endif
-
RadioButtonGroup length_group = length_1_button.get_group();
length_2_button.set_group (length_group);
length_4_button.set_group (length_group);
{
}
+void
+StepEntry::set_step_editor (StepEditor* seditor)
+{
+ se = seditor;
+
+ if (se) {
+ set_title (string_compose (_("Step Entry: %1"), se->name()));
+#if 0
+ /* set channel selector to first selected channel. if none
+ are selected, it will remain at the value set in its
+ constructor, above (1)
+ */
+
+ uint16_t chn_mask = se->channel_selector().get_selected_channels();
+
+ for (uint32_t i = 0; i < 16; ++i) {
+ if (chn_mask & (1<<i)) {
+ channel_adjustment.set_value (i+1);
+ break;
+ }
+ }
+
+#endif
+ } else {
+ hide ();
+ }
+}
+
+
void
StepEntry::length_changed ()
{
void
StepEntry::rest_event_handler ()
{
- se->step_edit_rest (Temporal::Beats());
+ if (se) {
+ se->step_edit_rest (Temporal::Beats());
+ }
}
Temporal::Beats
void
StepEntry::beat_resync_click ()
{
- se->step_edit_beat_sync ();
+ if (se) {
+ se->step_edit_beat_sync ();
+ }
}
void
StepEntry::bar_resync_click ()
{
- se->step_edit_bar_sync ();
+ if (se) {
+ se->step_edit_bar_sync ();
+ }
}
void
void
StepEntry::toggle_triplet ()
{
- se->set_step_edit_cursor_width (note_length());
+ if (se) {
+ se->set_step_edit_cursor_width (note_length());
+ }
}
void
StepEntry::toggle_chord ()
{
- se->step_edit_toggle_chord ();
+ if (se) {
+ se->step_edit_toggle_chord ();
+ }
}
void
dot2_button.set_inconsistent (inconsistent);
dot3_button.set_inconsistent (inconsistent);
- se->set_step_edit_cursor_width (note_length());
+ if (se) {
+ se->set_step_edit_cursor_width (note_length());
+ }
}
void
StepEntry::program_click ()
{
- se->step_add_program_change (note_channel(), (int8_t) floor (program_adjustment.get_value()));
+ if (se) {
+ se->step_add_program_change (note_channel(), (int8_t) floor (program_adjustment.get_value()));
+ }
}
void
StepEntry::bank_click ()
{
- se->step_add_bank_change (note_channel(), (int8_t) floor (bank_adjustment.get_value()));
+ if (se) {
+ se->step_add_bank_change (note_channel(), (int8_t) floor (bank_adjustment.get_value()));
+ }
}
void
StepEntry::insert_rest ()
{
- se->step_edit_rest (note_length());
+ if (se) {
+ se->step_edit_rest (note_length());
+ }
}
void
StepEntry::insert_grid_rest ()
{
- se->step_edit_rest (Temporal::Beats());
+ if (se) {
+ se->step_edit_rest (Temporal::Beats());
+ }
}
void
return;
}
- se->step_add_note (note_channel(), note, note_velocity(), note_length());
+ if (se) {
+ se->step_add_note (note_channel(), note, note_velocity(), note_length());
+ }
}
void
StepEntry::insert_c ()
{
RefPtr<Action> act;
RefPtr<RadioAction> ract;
- double val = length_divisor_adjustment.get_value();
bool inconsistent = true;
vector<const char*> length_actions;
length_32_button.set_inconsistent (inconsistent);
length_64_button.set_inconsistent (inconsistent);
- se->set_step_edit_cursor_width (note_length());
+ if (se) {
+ se->set_step_edit_cursor_width (note_length());
+ }
}
bool
void
StepEntry::do_sustain ()
{
- se->step_edit_sustain (note_length());
+ if (se) {
+ se->step_edit_sustain (note_length());
+ }
}
void
StepEntry::back ()
{
- se->move_step_edit_beat_pos (-note_length());
+ if (se) {
+ se->move_step_edit_beat_pos (-note_length());
+ }
}
void
StepEntry::sync_to_edit_point ()
{
- se->resync_step_edit_to_edit_point ();
-}
-
-bool
-StepEntry::on_focus_in_event (GdkEventFocus* ev)
-{
- _current_step_entry = this;
- return ArdourWindow::on_focus_in_event (ev);
-}
-
-bool
-StepEntry::on_focus_out_event (GdkEventFocus* ev)
-{
- _current_step_entry = 0;
- return ArdourWindow::on_focus_out_event (ev);
+ if (se) {
+ se->resync_step_edit_to_edit_point ();
+ }
}
class StepEntry : public ArdourWindow
{
public:
- StepEntry (StepEditor&);
+ static StepEntry& instance();
+
~StepEntry ();
+ void set_step_editor (StepEditor*);
+
void note_off_event_handler (int note);
void rest_event_handler ();
static void setup_actions_and_bindings ();
- protected:
- bool on_focus_in_event (GdkEventFocus*);
- bool on_focus_out_event (GdkEventFocus*);
-
private:
+ static StepEntry* _instance;
+ StepEntry ();
+
Temporal::Beats _current_note_length;
uint8_t _current_note_velocity;
having an actual StepEntry object.
*/
- static StepEntry* _current_step_entry;
-
- static void se_insert_rest () { if (_current_step_entry) { _current_step_entry->insert_rest (); } }
- static void se_insert_grid_rest () { if (_current_step_entry) { _current_step_entry->insert_grid_rest (); } }
- static void se_insert_a () { if (_current_step_entry) { _current_step_entry->insert_a (); } }
- static void se_insert_asharp () { if (_current_step_entry) { _current_step_entry->insert_asharp (); } }
- static void se_insert_b () { if (_current_step_entry) { _current_step_entry->insert_b (); } }
- static void se_insert_c () { if (_current_step_entry) { _current_step_entry->insert_c (); } }
- static void se_insert_csharp () { if (_current_step_entry) { _current_step_entry->insert_csharp (); } }
- static void se_insert_d () { if (_current_step_entry) { _current_step_entry->insert_d (); } }
- static void se_insert_dsharp () { if (_current_step_entry) { _current_step_entry->insert_dsharp (); } }
- static void se_insert_e () { if (_current_step_entry) { _current_step_entry->insert_e (); } }
- static void se_insert_f () { if (_current_step_entry) { _current_step_entry->insert_f (); } }
- static void se_insert_fsharp () { if (_current_step_entry) { _current_step_entry->insert_fsharp (); } }
- static void se_insert_g () { if (_current_step_entry) { _current_step_entry->insert_g (); } }
- static void se_insert_gsharp () { if (_current_step_entry) { _current_step_entry->insert_gsharp (); } }
- static void se_note_length_change (GtkAction* act) { if (_current_step_entry) { _current_step_entry->note_length_change (act); } }
- static void se_note_velocity_change (GtkAction* act) { if (_current_step_entry) { _current_step_entry->note_velocity_change (act); } }
- static bool se_radio_button_press (GdkEventButton* ev) { if (_current_step_entry) { return _current_step_entry->radio_button_press (ev); } return false; }
- static bool se_radio_button_release (GdkEventButton* ev, Gtk::RadioButton* rb, int n) { if (_current_step_entry) { return _current_step_entry->radio_button_release (ev, rb, n); } return false; }
- static void se_inc_note_velocity () { if (_current_step_entry) { _current_step_entry->inc_note_velocity (); } }
- static void se_dec_note_velocity () { if (_current_step_entry) { _current_step_entry->dec_note_velocity (); } }
- static void se_next_note_velocity () { if (_current_step_entry) { _current_step_entry->next_note_velocity (); } }
- static void se_prev_note_velocity () { if (_current_step_entry) { _current_step_entry->prev_note_velocity (); } }
- static void se_inc_note_length () { if (_current_step_entry) { _current_step_entry->inc_note_length (); } }
- static void se_dec_note_length () { if (_current_step_entry) { _current_step_entry->dec_note_length (); } }
- static void se_next_note_length () { if (_current_step_entry) { _current_step_entry->next_note_length (); } }
- static void se_prev_note_length () { if (_current_step_entry) { _current_step_entry->prev_note_length (); } }
- static void se_next_octave () { if (_current_step_entry) { _current_step_entry->next_octave (); } }
- static void se_prev_octave () { if (_current_step_entry) { _current_step_entry->prev_octave (); } }
- static void se_octave_n (int n) { if (_current_step_entry) { _current_step_entry->octave_n (n); } }
- static void se_octave_0 () { if (_current_step_entry) { _current_step_entry->octave_0 (); } }
- static void se_octave_1 () { if (_current_step_entry) { _current_step_entry->octave_1 (); } }
- static void se_octave_2 () { if (_current_step_entry) { _current_step_entry->octave_2 (); } }
- static void se_octave_3 () { if (_current_step_entry) { _current_step_entry->octave_3 (); } }
- static void se_octave_4 () { if (_current_step_entry) { _current_step_entry->octave_4 (); } }
- static void se_octave_5 () { if (_current_step_entry) { _current_step_entry->octave_5 (); } }
- static void se_octave_6 () { if (_current_step_entry) { _current_step_entry->octave_6 (); } }
- static void se_octave_7 () { if (_current_step_entry) { _current_step_entry->octave_7 (); } }
- static void se_octave_8 () { if (_current_step_entry) { _current_step_entry->octave_8 (); } }
- static void se_octave_9 () { if (_current_step_entry) { _current_step_entry->octave_9 (); } }
- static void se_octave_10 () { if (_current_step_entry) { _current_step_entry->octave_10 (); } }
- static void se_dot_change (GtkAction* act) { if (_current_step_entry) { _current_step_entry->dot_change (act); } }
- static void se_dot_value_change () { if (_current_step_entry) { _current_step_entry->dot_value_change (); } }
- static void se_toggle_triplet() { if (_current_step_entry) { _current_step_entry->toggle_triplet (); } }
- static void se_toggle_chord() { if (_current_step_entry) { _current_step_entry->toggle_chord (); } }
- static void se_do_sustain () { if (_current_step_entry) { _current_step_entry->do_sustain (); } }
- static void se_back() { if (_current_step_entry) { _current_step_entry->back (); } }
- static void se_sync_to_edit_point () { if (_current_step_entry) { _current_step_entry->sync_to_edit_point (); } }
+ static void se_insert_rest () { if (_instance) { _instance->insert_rest (); } }
+ static void se_insert_grid_rest () { if (_instance) { _instance->insert_grid_rest (); } }
+ static void se_insert_a () { if (_instance) { _instance->insert_a (); } }
+ static void se_insert_asharp () { if (_instance) { _instance->insert_asharp (); } }
+ static void se_insert_b () { if (_instance) { _instance->insert_b (); } }
+ static void se_insert_c () { if (_instance) { _instance->insert_c (); } }
+ static void se_insert_csharp () { if (_instance) { _instance->insert_csharp (); } }
+ static void se_insert_d () { if (_instance) { _instance->insert_d (); } }
+ static void se_insert_dsharp () { if (_instance) { _instance->insert_dsharp (); } }
+ static void se_insert_e () { if (_instance) { _instance->insert_e (); } }
+ static void se_insert_f () { if (_instance) { _instance->insert_f (); } }
+ static void se_insert_fsharp () { if (_instance) { _instance->insert_fsharp (); } }
+ static void se_insert_g () { if (_instance) { _instance->insert_g (); } }
+ static void se_insert_gsharp () { if (_instance) { _instance->insert_gsharp (); } }
+ static void se_note_length_change (GtkAction* act) { if (_instance) { _instance->note_length_change (act); } }
+ static void se_note_velocity_change (GtkAction* act) { if (_instance) { _instance->note_velocity_change (act); } }
+ static bool se_radio_button_press (GdkEventButton* ev) { if (_instance) { return _instance->radio_button_press (ev); } return false; }
+ static bool se_radio_button_release (GdkEventButton* ev, Gtk::RadioButton* rb, int n) { if (_instance) { return _instance->radio_button_release (ev, rb, n); } return false; }
+ static void se_inc_note_velocity () { if (_instance) { _instance->inc_note_velocity (); } }
+ static void se_dec_note_velocity () { if (_instance) { _instance->dec_note_velocity (); } }
+ static void se_next_note_velocity () { if (_instance) { _instance->next_note_velocity (); } }
+ static void se_prev_note_velocity () { if (_instance) { _instance->prev_note_velocity (); } }
+ static void se_inc_note_length () { if (_instance) { _instance->inc_note_length (); } }
+ static void se_dec_note_length () { if (_instance) { _instance->dec_note_length (); } }
+ static void se_next_note_length () { if (_instance) { _instance->next_note_length (); } }
+ static void se_prev_note_length () { if (_instance) { _instance->prev_note_length (); } }
+ static void se_next_octave () { if (_instance) { _instance->next_octave (); } }
+ static void se_prev_octave () { if (_instance) { _instance->prev_octave (); } }
+ static void se_octave_n (int n) { if (_instance) { _instance->octave_n (n); } }
+ static void se_octave_0 () { if (_instance) { _instance->octave_0 (); } }
+ static void se_octave_1 () { if (_instance) { _instance->octave_1 (); } }
+ static void se_octave_2 () { if (_instance) { _instance->octave_2 (); } }
+ static void se_octave_3 () { if (_instance) { _instance->octave_3 (); } }
+ static void se_octave_4 () { if (_instance) { _instance->octave_4 (); } }
+ static void se_octave_5 () { if (_instance) { _instance->octave_5 (); } }
+ static void se_octave_6 () { if (_instance) { _instance->octave_6 (); } }
+ static void se_octave_7 () { if (_instance) { _instance->octave_7 (); } }
+ static void se_octave_8 () { if (_instance) { _instance->octave_8 (); } }
+ static void se_octave_9 () { if (_instance) { _instance->octave_9 (); } }
+ static void se_octave_10 () { if (_instance) { _instance->octave_10 (); } }
+ static void se_dot_change (GtkAction* act) { if (_instance) { _instance->dot_change (act); } }
+ static void se_dot_value_change () { if (_instance) { _instance->dot_value_change (); } }
+ static void se_toggle_triplet() { if (_instance) { _instance->toggle_triplet (); } }
+ static void se_toggle_chord() { if (_instance) { _instance->toggle_chord (); } }
+ static void se_do_sustain () { if (_instance) { _instance->do_sustain (); } }
+ static void se_back() { if (_instance) { _instance->back (); } }
+ static void se_sync_to_edit_point () { if (_instance) { _instance->sync_to_edit_point (); } }
static void load_bindings ();
static Gtkmm2ext::Bindings* bindings;