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"
35 #include "ardour_dialog.h"
37 /** Dialog for building a MIDI note transformation.
39 * This can build transformations with any number of operations, but is limited
40 * in power and can't build arbitrary transformations since there is no way to do
41 * conceptually parenthetical things (i.e. push things to the stack).
43 * With this, it is possible to build transformations that process a single
44 * value in a series of steps starting with a seed, like: "value = seed OP
45 * value OP value ..." where OP is +, -, *, or /, left associative with no
46 * precedence. This is simple and pretty clear to the user what's going to
47 * happen, though a bit limited. It would be nice if the GUI could build
48 * fancier transformations, but it's not obvious how to do this without making
49 * things more confusing.
51 class TransformDialog : public ArdourDialog
56 ARDOUR::Transform::Program get();
59 typedef ARDOUR::MidiModel::NoteDiffCommand::Property Property;
60 typedef ARDOUR::Transform::Value Value;
61 typedef ARDOUR::Transform::Value::Source Source;
62 typedef ARDOUR::Transform::Operation::Operator Operator;
63 typedef ARDOUR::Transform::Operation Operation;
65 struct SourceCols : public Gtk::TreeModelColumnRecord {
66 SourceCols() { add(source); add(label); }
68 Gtk::TreeModelColumn<Source> source;
69 Gtk::TreeModelColumn<std::string> label;
72 struct PropertyCols : public Gtk::TreeModelColumnRecord {
73 PropertyCols() { add(property); add(label); }
75 Gtk::TreeModelColumn<Property> property;
76 Gtk::TreeModelColumn<std::string> label;
79 struct OperatorCols : public Gtk::TreeModelColumnRecord {
80 OperatorCols() { add(op); add(label); }
82 Gtk::TreeModelColumn<Operator> op;
83 Gtk::TreeModelColumn<std::string> label;
89 SourceCols source_cols;
90 Glib::RefPtr<Gtk::ListStore> source_list;
91 PropertyCols property_cols;
92 Glib::RefPtr<Gtk::ListStore> property_list;
93 OperatorCols operator_cols;
94 Glib::RefPtr<Gtk::ListStore> operator_list;
97 struct ValueChooser : public Gtk::HBox {
98 ValueChooser(const Model& model);
100 /** Append code to `ops` that pushes value to stack. */
101 void get(std::list<Operation>& ops);
103 void set_target_property(Property prop);
104 void source_changed();
106 double get_value () const;
107 double get_max () const;
109 const Model& model; ///< Models for combo boxes
110 Property target_property; ///< Property on source
111 Gtk::ComboBox source_combo; ///< Value source chooser
112 Gtk::ComboBox property_combo; ///< Property chooser
113 Gtk::SpinButton value_spinner; ///< Value or minimum for RANDOM
114 Gtk::Label to_label; ///< "to" label for RANDOM
115 Gtk::SpinButton max_spinner; ///< Maximum for RANDOM
118 struct OperationChooser : public Gtk::HBox {
119 OperationChooser(const Model& model);
121 /** Append operations to `ops`. */
122 void get(std::list<Operation>& ops);
124 void remove_clicked();
127 Gtk::ComboBox operator_combo;
128 ValueChooser value_chooser;
129 Gtk::Button remove_button;
132 void property_changed();
136 Gtk::ComboBox _property_combo;
137 ValueChooser* _seed_chooser;
138 Gtk::VBox _operations_box;
139 Gtk::Button _add_button;
142 #endif /* __transform_dialog_h__ */