summaryrefslogtreecommitdiff
path: root/libs/ardour/ardour/midi_model.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-12-26 12:22:55 -0500
committerDavid Robillard <d@drobilla.net>2014-12-28 16:06:44 -0500
commite735d4035fd32f9711e5fe3fae51c1761e2b1d14 (patch)
treef146367d4a1da962d72c211d1230ef84a30672b1 /libs/ardour/ardour/midi_model.h
parent31641179f989b51469e61d770e25845aeedd9d1e (diff)
Clean up note delta command code.
Use Variant to store the value and the same code path for all properties. Factor out getting the value of whatever property instead of special casing the handling. Towards using this stuff for some fancy things...
Diffstat (limited to 'libs/ardour/ardour/midi_model.h')
-rw-r--r--libs/ardour/ardour/midi_model.h30
1 files changed, 21 insertions, 9 deletions
diff --git a/libs/ardour/ardour/midi_model.h b/libs/ardour/ardour/midi_model.h
index 1988c1a2d1..52bb5a6b27 100644
--- a/libs/ardour/ardour/midi_model.h
+++ b/libs/ardour/ardour/midi_model.h
@@ -21,17 +21,22 @@
#ifndef __ardour_midi_model_h__
#define __ardour_midi_model_h__
-#include <queue>
#include <deque>
+#include <queue>
#include <utility>
+
#include <boost/utility.hpp>
#include <glibmm/threads.h>
+
#include "pbd/command.h"
-#include "ardour/libardour_visibility.h"
-#include "ardour/types.h"
+
#include "ardour/automatable_sequence.h"
#include "ardour/libardour_visibility.h"
+#include "ardour/libardour_visibility.h"
#include "ardour/types.h"
+#include "ardour/types.h"
+#include "ardour/variant.h"
+
#include "evoral/Note.hpp"
#include "evoral/Sequence.hpp"
@@ -101,8 +106,15 @@ public:
void remove (const NotePtr note);
void side_effect_remove (const NotePtr note);
- void change (const NotePtr note, Property prop, uint8_t new_value);
- void change (const NotePtr note, Property prop, TimeType new_time);
+ void change (const NotePtr note, Property prop, uint8_t new_value) {
+ change(note, prop, Variant(new_value));
+ }
+
+ void change (const NotePtr note, Property prop, TimeType new_time) {
+ change(note, prop, Variant(new_time));
+ }
+
+ void change (const NotePtr note, Property prop, const Variant& new_value);
bool adds_or_removes() const {
return !_added_notes.empty() || !_removed_notes.empty();
@@ -110,15 +122,15 @@ public:
NoteDiffCommand& operator+= (const NoteDiffCommand& other);
+ static Variant get_value (const NotePtr note, Property prop);
+
private:
struct NoteChange {
NoteDiffCommand::Property property;
NotePtr note;
uint32_t note_id;
- uint8_t old_value; // or...
- TimeType old_time; // this
- uint8_t new_value; // or...
- TimeType new_time; // this
+ Variant old_value;
+ Variant new_value;
};
typedef std::list<NoteChange> ChangeList;