13
0

deal with end-of-step-editing in a better way

This commit is contained in:
Paul Davis 2018-12-22 16:48:16 -05:00
parent 933b2b1a9c
commit bc1a7ec9e5
3 changed files with 27 additions and 6 deletions

View File

@ -73,8 +73,8 @@ StepEditor::start_step_editing ()
assert (step_edit_region_view);
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));
delete_connection = StepEntry::instance().signal_delete_event().connect (sigc::mem_fun (*this, &StepEditor::step_entry_hidden));
hide_connection = StepEntry::instance(). signal_hide().connect (sigc::mem_fun (*this, &StepEditor::step_entry_done));
step_edit_region_view->show_step_edit_cursor (step_edit_beat_pos);
step_edit_region_view->set_step_edit_cursor_width (StepEntry::instance().note_length());
@ -148,13 +148,15 @@ StepEditor::reset_step_edit_beat_pos ()
bool
StepEditor::step_entry_hidden (GdkEventAny*)
{
step_entry_hide ();
return true; // XXX remember position ?!
step_entry_done ();
return true;
}
void
StepEditor::step_entry_hide ()
StepEditor::step_entry_done ()
{
hide_connection.disconnect ();
delete_connection.disconnect ();
/* everything else will follow the change in the model */
_track->set_step_editing (false);
}

View File

@ -38,12 +38,25 @@ class MidiTimeAxisView;
class PublicEditor;
class StepEntry;
/** A StepEditor is an object which understands how to interact with the
* MidiTrack and MidiTimeAxisView APIs to make the changes required during step
* editing. However, it defers all GUI matters to the StepEntry class, which
* presents an interface to the user, and then calls StepEditor methods to make
* changes.
*
* The StepEntry is a singleton, used over and over each time the user wants to
* step edit; the StepEditor is owned by a MidiTimeAxisView and re-used for any
* step editing in the MidiTrack for which the MidiTimeAxisView is a view.
*/
class StepEditor : public PBD::ScopedConnectionList, public sigc::trackable
{
public:
StepEditor (PublicEditor&, boost::shared_ptr<ARDOUR::MidiTrack>, MidiTimeAxisView&);
virtual ~StepEditor ();
void step_entry_done ();
void check_step_edit ();
void step_edit_rest (Temporal::Beats beats);
void step_edit_beat_sync ();
@ -82,10 +95,12 @@ private:
int8_t last_added_pitch;
Temporal::Beats last_added_end;
sigc::connection delete_connection;
sigc::connection hide_connection;
void region_removed (boost::weak_ptr<ARDOUR::Region>);
void playlist_changed ();
bool step_entry_hidden (GdkEventAny*);
void step_entry_hide ();
void resync_step_edit_position ();
void prepare_step_edit_region ();
};

View File

@ -469,6 +469,10 @@ StepEntry::~StepEntry()
void
StepEntry::set_step_editor (StepEditor* seditor)
{
if (se) {
se->step_entry_done ();
}
se = seditor;
if (se) {