2 Copyright (C) 2009-2014 Paul Davis
3 Author: David Robillard
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.
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.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __transform_dialog_h__
21 #define __transform_dialog_h__
26 #include <gtkmm/combobox.h>
27 #include <gtkmm/liststore.h>
28 #include <gtkmm/treemodel.h>
29 #include <gtkmm/spinbutton.h>
31 #include "ardour/midi_model.h"
32 #include "ardour/transform.h"
33 #include "ardour/types.h"
34 #include "evoral/types.hpp"
36 #include "ardour_dialog.h"
38 /** Dialog for building a MIDI note transformation.
40 * This can build transformations with any number of operations, but is limited
41 * in power and can't build arbitrary transformations since there is no way to do
42 * conceptually parenthetical things (i.e. push things to the stack).
44 * With this, it is possible to build transformations that process a single
45 * value in a series of steps starting with a seed, like: "value = seed OP
46 * value OP value ..." where OP is +, -, *, or /, left associative with no
47 * precedence. This is simple and pretty clear to the user what's going to
48 * happen, though a bit limited. It would be nice if the GUI could build
49 * fancier transformations, but it's not obvious how to do this without making
50 * things more confusing.
52 class TransformDialog : public ArdourDialog
57 ARDOUR::Transform::Program get();
60 typedef ARDOUR::MidiModel::NoteDiffCommand::Property Property;
61 typedef ARDOUR::Transform::Value Value;
62 typedef ARDOUR::Transform::Value::Source Source;
63 typedef ARDOUR::Transform::Operation::Operator Operator;
64 typedef ARDOUR::Transform::Operation Operation;
66 struct SourceCols : public Gtk::TreeModelColumnRecord {
67 SourceCols() { add(source); add(label); }
69 Gtk::TreeModelColumn<Source> source;
70 Gtk::TreeModelColumn<std::string> label;
73 struct PropertyCols : public Gtk::TreeModelColumnRecord {
74 PropertyCols() { add(property); add(label); }
76 Gtk::TreeModelColumn<Property> property;
77 Gtk::TreeModelColumn<std::string> label;
80 struct OperatorCols : public Gtk::TreeModelColumnRecord {
81 OperatorCols() { add(op); add(label); }
83 Gtk::TreeModelColumn<Operator> op;
84 Gtk::TreeModelColumn<std::string> label;
90 SourceCols source_cols;
91 Glib::RefPtr<Gtk::ListStore> source_list;
92 PropertyCols property_cols;
93 Glib::RefPtr<Gtk::ListStore> property_list;
94 OperatorCols operator_cols;
95 Glib::RefPtr<Gtk::ListStore> operator_list;
98 struct ValueChooser : public Gtk::HBox {
99 ValueChooser(const Model& model);
101 /** Append code to `ops` that pushes value to stack. */
102 void get(std::list<Operation>& ops);
104 void set_target_property(Property prop);
105 void source_changed();
107 const Model& model; ///< Models for combo boxes
108 Property target_property; ///< Property on source
109 Gtk::ComboBox source_combo; ///< Value source chooser
110 Gtk::ComboBox property_combo; ///< Property chooser
111 Gtk::SpinButton value_spinner; ///< Value or minimum for RANDOM
112 Gtk::Label to_label; ///< "to" label for RANDOM
113 Gtk::SpinButton max_spinner; ///< Maximum for RANDOM
116 struct OperationChooser : public Gtk::HBox {
117 OperationChooser(const Model& model);
119 /** Append operations to `ops`. */
120 void get(std::list<Operation>& ops);
122 void remove_clicked();
125 Gtk::ComboBox operator_combo;
126 ValueChooser value_chooser;
127 Gtk::Button remove_button;
130 void property_changed();
134 Gtk::ComboBox _property_combo;
135 ValueChooser* _seed_chooser;
136 Gtk::VBox _operations_box;
137 Gtk::Button _add_button;
140 #endif /* __transform_dialog_h__ */