1 /* 2 * Copyright (C) 2010-2018 Paul Davis <paul@linuxaudiosystems.com> 3 * Copyright (C) 2011-2015 David Robillard <d@drobilla.net> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License along 16 * with this program; if not, write to the Free Software Foundation, Inc., 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 */ 19 20 #ifndef __gtk2_ardour_step_editor_h__ 21 #define __gtk2_ardour_step_editor_h__ 22 23 #include <string> 24 25 #include <gdk/gdk.h> 26 #include <sigc++/trackable.h> 27 28 #include "pbd/signals.h" 29 30 #include "temporal/beats.h" 31 32 namespace ARDOUR { 33 class MidiTrack; 34 class MidiRegion; 35 } 36 37 class MidiRegionView; 38 class MidiTimeAxisView; 39 class PublicEditor; 40 class StepEntry; 41 42 /** A StepEditor is an object which understands how to interact with the 43 * MidiTrack and MidiTimeAxisView APIs to make the changes required during step 44 * editing. However, it defers all GUI matters to the StepEntry class, which 45 * presents an interface to the user, and then calls StepEditor methods to make 46 * changes. 47 * 48 * The StepEntry is a singleton, used over and over each time the user wants to 49 * step edit; the StepEditor is owned by a MidiTimeAxisView and re-used for any 50 * step editing in the MidiTrack for which the MidiTimeAxisView is a view. 51 */ 52 53 class StepEditor : public PBD::ScopedConnectionList, public sigc::trackable 54 { 55 public: 56 StepEditor (PublicEditor&, boost::shared_ptr<ARDOUR::MidiTrack>, MidiTimeAxisView&); 57 virtual ~StepEditor (); 58 59 void step_entry_done (); 60 61 void check_step_edit (); 62 void step_edit_rest (Temporal::Beats beats); 63 void step_edit_beat_sync (); 64 void step_edit_bar_sync (); 65 int step_add_bank_change (uint8_t channel, uint8_t bank); 66 int step_add_program_change (uint8_t channel, uint8_t program); 67 int step_add_note (uint8_t channel, uint8_t pitch, uint8_t velocity, 68 Temporal::Beats beat_duration); 69 void step_edit_sustain (Temporal::Beats beats); 70 bool step_edit_within_triplet () const; 71 void step_edit_toggle_triplet (); 72 bool step_edit_within_chord () const; 73 void step_edit_toggle_chord (); 74 void reset_step_edit_beat_pos (); 75 void resync_step_edit_to_edit_point (); 76 void move_step_edit_beat_pos (Temporal::Beats beats); 77 void set_step_edit_cursor_width (Temporal::Beats beats); 78 79 std::string name () const; 80 81 void start_step_editing (); 82 void stop_step_editing (); 83 84 private: 85 ARDOUR::samplepos_t step_edit_insert_position; 86 Temporal::Beats step_edit_beat_pos; 87 boost::shared_ptr<ARDOUR::MidiRegion> step_edit_region; 88 MidiRegionView* step_edit_region_view; 89 uint8_t _step_edit_triplet_countdown; 90 bool _step_edit_within_chord; 91 Temporal::Beats _step_edit_chord_duration; 92 PBD::ScopedConnection step_edit_region_connection; 93 PublicEditor& _editor; 94 boost::shared_ptr<ARDOUR::MidiTrack> _track; 95 MidiTimeAxisView& _mtv; 96 int8_t last_added_pitch; 97 Temporal::Beats last_added_end; 98 99 sigc::connection delete_connection; 100 sigc::connection hide_connection; 101 102 void region_removed (boost::weak_ptr<ARDOUR::Region>); 103 void playlist_changed (); 104 bool step_entry_hidden (GdkEventAny*); 105 void resync_step_edit_position (); 106 void prepare_step_edit_region (); 107 }; 108 109 #endif /* __gtk2_ardour_step_editor_h__ */ 110