2 * Copyright (C) 2014-2015 David Robillard <d@drobilla.net>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #ifndef __transform_dialog_h__
20 #define __transform_dialog_h__
25 #include <gtkmm/combobox.h>
26 #include <gtkmm/liststore.h>
27 #include <gtkmm/treemodel.h>
28 #include <gtkmm/spinbutton.h>
30 #include "ardour/midi_model.h"
31 #include "ardour/transform.h"
32 #include "ardour/types.h"
34 #include "ardour_dialog.h"
36 /** Dialog for building a MIDI note transformation.
38 * This can build transformations with any number of operations, but is limited
39 * in power and can't build arbitrary transformations since there is no way to do
40 * conceptually parenthetical things (i.e. push things to the stack).
42 * With this, it is possible to build transformations that process a single
43 * value in a series of steps starting with a seed, like: "value = seed OP
44 * value OP value ..." where OP is +, -, *, or /, left associative with no
45 * precedence. This is simple and pretty clear to the user what's going to
46 * happen, though a bit limited. It would be nice if the GUI could build
47 * fancier transformations, but it's not obvious how to do this without making
48 * things more confusing.
50 class TransformDialog : public ArdourDialog
55 ARDOUR::Transform::Program get();
58 typedef ARDOUR::MidiModel::NoteDiffCommand::Property Property;
59 typedef ARDOUR::Transform::Value Value;
60 typedef ARDOUR::Transform::Value::Source Source;
61 typedef ARDOUR::Transform::Operation::Operator Operator;
62 typedef ARDOUR::Transform::Operation Operation;
64 struct SourceCols : public Gtk::TreeModelColumnRecord {
65 SourceCols() { add(source); add(label); }
67 Gtk::TreeModelColumn<Source> source;
68 Gtk::TreeModelColumn<std::string> label;
71 struct PropertyCols : public Gtk::TreeModelColumnRecord {
72 PropertyCols() { add(property); add(label); }
74 Gtk::TreeModelColumn<Property> property;
75 Gtk::TreeModelColumn<std::string> label;
78 struct OperatorCols : public Gtk::TreeModelColumnRecord {
79 OperatorCols() { add(op); add(label); }
81 Gtk::TreeModelColumn<Operator> op;
82 Gtk::TreeModelColumn<std::string> label;
88 SourceCols source_cols;
89 Glib::RefPtr<Gtk::ListStore> source_list;
90 PropertyCols property_cols;
91 Glib::RefPtr<Gtk::ListStore> property_list;
92 OperatorCols operator_cols;
93 Glib::RefPtr<Gtk::ListStore> operator_list;
96 struct ValueChooser : public Gtk::HBox {
97 ValueChooser(const Model& model);
99 /** Append code to `ops` that pushes value to stack. */
100 void get(std::list<Operation>& ops);
102 void set_target_property(Property prop);
103 void source_changed();
105 double get_value () const;
106 double get_max () const;
108 const Model& model; ///< Models for combo boxes
109 Property target_property; ///< Property on source
110 Gtk::ComboBox source_combo; ///< Value source chooser
111 Gtk::ComboBox property_combo; ///< Property chooser
112 Gtk::SpinButton value_spinner; ///< Value or minimum for RANDOM
113 Gtk::Label to_label; ///< "to" label for RANDOM
114 Gtk::SpinButton max_spinner; ///< Maximum for RANDOM
117 struct OperationChooser : public Gtk::HBox {
118 OperationChooser(const Model& model);
120 /** Append operations to `ops`. */
121 void get(std::list<Operation>& ops);
123 void remove_clicked();
126 Gtk::ComboBox operator_combo;
127 ValueChooser value_chooser;
128 Gtk::Button remove_button;
131 void property_changed();
135 Gtk::ComboBox _property_combo;
136 ValueChooser* _seed_chooser;
137 Gtk::VBox _operations_box;
138 Gtk::Button _add_button;
141 #endif /* __transform_dialog_h__ */