1 #ifndef _MIDI_MAPPING_DIALOG_H
2 #define _MIDI_MAPPING_DIALOG_H
13 #include "midi_mapper.h"
19 class MIDIMappingDialog;
22 class MIDIMappingProto;
25 class QTreeWidgetItem;
27 class MIDIMappingDialog : public QDialog, public ControllerReceiver
32 MIDIMappingDialog(MIDIMapper *mapper);
35 // For use in midi_mapping_dialog.cpp only.
38 int field_number; // In MIDIMappingBusProto.
39 int bank_field_number; // In MIDIMappingProto.
42 // ControllerReceiver interface. We only implement the raw events.
43 void preview() override {}
44 void queue() override {}
45 void play() override {}
46 void next() override {}
47 void toggle_lock() override {}
48 void jog(int delta) override {}
49 void switch_camera(unsigned camera_idx) override {}
50 void set_master_speed(float speed) override {}
51 void cue_in() override {}
52 void cue_out() override {}
54 // Raw events; used for the editor dialog only.
55 void controller_changed(unsigned controller) override;
56 void note_on(unsigned note) override;
60 void cancel_clicked();
64 void add_bank_selector(QTreeWidgetItem *item, const MIDIMappingProto &mapping_proto, int bank_field_number);
66 enum class ControlType { CONTROLLER, CONTROLLER_LIGHT, BUTTON, BUTTON_LIGHT, CAMERA_BUTTON, CAMERA_BUTTON_LIGHT };
67 void add_controls(const std::string &heading, ControlType control_type,
68 const MIDIMappingProto &mapping_proto, const std::vector<Control> &controls);
69 void fill_controls_from_mapping(const MIDIMappingProto &mapping_proto);
71 std::unique_ptr<MIDIMappingProto> construct_mapping_proto_from_ui();
73 Ui::MIDIMappingDialog *ui;
75 ControllerReceiver *old_receiver;
77 // All controllers actually laid out on the grid (we need to store them
78 // so that we can move values back and forth between the controls and
79 // the protobuf on save/load).
80 struct InstantiatedSpinner {
82 QSpinBox *spinner2; // Value for button lights, min value for controller lights.
83 QSpinBox *spinner3; // Max value for controller lights.
84 int field_number; // In MIDIMappingBusProto.
86 struct InstantiatedComboBox {
88 int field_number; // In MIDIMappingProto.
90 std::vector<InstantiatedSpinner> controller_spinners;
91 std::vector<InstantiatedSpinner> controller_light_spinners;
92 std::vector<InstantiatedSpinner> button_spinners;
93 std::vector<InstantiatedSpinner> button_light_spinners;
94 std::vector<InstantiatedSpinner> camera_button_spinners; // One per camera.
95 std::vector<InstantiatedSpinner> camera_button_light_spinners; // One per camera.
96 std::vector<InstantiatedComboBox> bank_combo_boxes;
98 // Keyed on field number.
99 std::map<unsigned, QSpinBox *> spinners;
102 #endif // !defined(_MIDI_MAPPING_DIALOG_H)