X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=midi_mapping_dialog.h;h=efc770d28a1cc81433bd73cda828acd2e138062e;hb=a94d4fe6192a2f0111515b952dc53f5bda8324db;hp=6d9919bbb93da5a70610f6faeec14632dd1eb5cc;hpb=c93433b2669d3447f8c2e1dfcae0d491b2d3a4dc;p=nageru diff --git a/midi_mapping_dialog.h b/midi_mapping_dialog.h index 6d9919b..efc770d 100644 --- a/midi_mapping_dialog.h +++ b/midi_mapping_dialog.h @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -28,6 +29,8 @@ public: MIDIMappingDialog(MIDIMapper *mapper); ~MIDIMappingDialog(); + bool eventFilter(QObject *obj, QEvent *event) override; + // For use in midi_mapping_dialog.cpp only. struct Control { std::string label; @@ -58,6 +61,7 @@ public: void note_on(unsigned note) override; public slots: + void guess_clicked(); void ok_clicked(); void cancel_clicked(); void save_clicked(); @@ -73,11 +77,22 @@ private: const MIDIMappingProto &mapping_proto, const std::vector &controls); void fill_controls_from_mapping(const MIDIMappingProto &mapping_proto); + // Tries to find a source bus and an offset to it that would give + // a consistent offset for the rest of the mappings in this bus. + // Returns -1 for the bus (the first element) if no consistent offset + // can be found. + std::pair guess_offset(unsigned bus_idx); + bool bus_is_empty(unsigned bus_idx); + + void update_guess_button_state(); + int find_focus_bus(); + std::unique_ptr construct_mapping_proto_from_ui(); Ui::MIDIMappingDialog *ui; MIDIMapper *mapper; ControllerReceiver *old_receiver; + int last_focus_bus_idx{-1}; // All controllers actually laid out on the grid (we need to store them // so that we can move values back and forth between the controls and @@ -94,6 +109,9 @@ private: std::vector controller_spinners; std::vector button_spinners; std::vector bank_combo_boxes; + + // Keyed on bus index, then field number. + std::map> spinners; }; #endif // !defined(_MIDI_MAPPING_DIALOG_H)