From 837bfc9af44c5b6c1eeb14e7af8d9ec62c59aac6 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sun, 6 Sep 2009 18:11:55 +0000 Subject: the start (only the start) of MIDI diff commands git-svn-id: svn://localhost/ardour2/branches/3.0@5637 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/midi_model.h | 54 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'libs/ardour/ardour/midi_model.h') diff --git a/libs/ardour/ardour/midi_model.h b/libs/ardour/ardour/midi_model.h index 967372fa9a..46d4cf794c 100644 --- a/libs/ardour/ardour/midi_model.h +++ b/libs/ardour/ardour/midi_model.h @@ -89,10 +89,62 @@ public: NoteList _removed_notes; }; + + /** Change note properties. + * More efficient than DeltaCommand and has the important property that + * it leaves the objects in the MidiModel (Notes) the same, thus + * enabling selection and other state to persist across command + * do/undo/redo. + */ + class DiffCommand : public Command { + public: + enum Property { + NoteNumber, + Velocity, + StartTime, + Length, + Channel + }; + + DiffCommand (boost::shared_ptr m, const std::string& name); + DiffCommand (boost::shared_ptr m, const XMLNode& node); + + const std::string& name() const { return _name; } + + void operator()(); + void undo(); + + int set_state (const XMLNode&); + XMLNode& get_state (); + + void change (const boost::shared_ptr > note, + Property prop, uint8_t new_value); + + private: + boost::shared_ptr _model; + const std::string _name; + + struct NotePropertyChange { + DiffCommand::Property property; + boost::shared_ptr > note; + uint8_t old_value; + uint8_t new_value; + }; + + typedef std::list ChangeList; + ChangeList _changes; + + XMLNode &marshal_change(const NotePropertyChange&); + NotePropertyChange unmarshal_change(XMLNode *xml_note); + }; + MidiModel::DeltaCommand* new_delta_command(const std::string name="midi edit"); + MidiModel::DiffCommand* new_diff_command(const std::string name="midi edit"); void apply_command(Session& session, Command* cmd); void apply_command_as_subcommand(Session& session, Command* cmd); + + bool write_to(boost::shared_ptr source); // MidiModel doesn't use the normal AutomationList serialisation code @@ -104,6 +156,8 @@ public: const MidiSource* midi_source() const { return _midi_source; } void set_midi_source(MidiSource* source) { _midi_source = source; } + + boost::shared_ptr > find_note (boost::shared_ptr >); private: friend class DeltaCommand; -- cgit v1.2.3