]> git.sesse.net Git - nageru/blobdiff - futatabi/midi_mapping_dialog.cpp
Fix saving of MIDI mappings with camera switch buttons that have no associated lights...
[nageru] / futatabi / midi_mapping_dialog.cpp
index 30d562f41441e56faaacfdd2b4eb8a52f4033841..de393c38dacdbe2002de8c7441aa96d5e7402ddc 100644 (file)
@@ -46,6 +46,8 @@ vector<MIDIMappingDialog::Control> buttons = {
                          MIDIMappingProto::kQueueBankFieldNumber },
        { "Play",         MIDIMappingProto::kPlayFieldNumber,
                          MIDIMappingProto::kPlayBankFieldNumber },
+       { "Next",         MIDIMappingProto::kNextFieldNumber,
+                         MIDIMappingProto::kNextButtonBankFieldNumber },
        { "Lock master speed", MIDIMappingProto::kToggleLockFieldNumber,
                          MIDIMappingProto::kToggleLockBankFieldNumber },
        { "Cue in",       MIDIMappingProto::kCueInFieldNumber,
@@ -66,6 +68,7 @@ vector<MIDIMappingDialog::Control> button_lights = {
         { "Queue button enabled", MIDIMappingProto::kQueueEnabledFieldNumber, 0 },
         { "Playing",              MIDIMappingProto::kPlayingFieldNumber, 0 },
         { "Play ready",           MIDIMappingProto::kPlayReadyFieldNumber, 0 },
+        { "Next ready",           MIDIMappingProto::kNextReadyFieldNumber, 0 },
         { "Master speed locked",  MIDIMappingProto::kLockedFieldNumber, 0 },
         { "Master speed locked (blinking)",
                                  MIDIMappingProto::kLockedBlinkingFieldNumber, 0 },
@@ -290,23 +293,25 @@ unique_ptr<MIDIMappingProto> MIDIMappingDialog::construct_mapping_proto_from_ui(
        
                {       
                        const InstantiatedSpinner &is = camera_button_spinners[camera_idx];
-                       MIDIButtonProto *button_proto =
-                               get_mutable_message<MIDIButtonProto>(camera_proto, is.field_number);
                        int val = is.spinner->value();
                        if (val != -1) {
+                               MIDIButtonProto *button_proto =
+                                       get_mutable_message<MIDIButtonProto>(camera_proto, is.field_number);
                                button_proto->set_note_number(val);
                        }
                }
                {       
                        const InstantiatedSpinner &is = camera_button_light_spinners[camera_idx];
+                       int val = is.spinner->value();
+                       int val2 = is.spinner2->value();
+
+                       if (val == -1 && val2 == -1) continue;
+
                        MIDILightProto *light_proto =
                                get_mutable_message<MIDILightProto>(camera_proto, is.field_number);
-                       int val = is.spinner->value();
                        if (val != -1) {
                                light_proto->set_note_number(val);
                        }
-
-                       int val2 = is.spinner2->value();
                        if (val2 != -1) {
                                light_proto->set_velocity(val2);
                        }
@@ -487,16 +492,20 @@ void MIDIMappingDialog::controller_changed(unsigned controller)
 void MIDIMappingDialog::note_on(unsigned note)
 {
        post_to_main_thread([=]{
-               for (const InstantiatedSpinner &is : button_spinners) {
-                       if (is.spinner->hasFocus()) {
-                               is.spinner->setValue(note);
-                               is.spinner->selectAll();
+               for (const auto &spinners : { button_spinners, camera_button_spinners }) {
+                       for (const InstantiatedSpinner &is : spinners) {
+                               if (is.spinner->hasFocus()) {
+                                       is.spinner->setValue(note);
+                                       is.spinner->selectAll();
+                               }
                        }
                }
-               for (const InstantiatedSpinner &is : button_light_spinners) {
-                       if (is.spinner->hasFocus()) {
-                               is.spinner->setValue(note);
-                               is.spinner->selectAll();
+               for (const auto &light_spinners : { button_light_spinners, camera_button_light_spinners }) {
+                       for (const InstantiatedSpinner &is : light_spinners) {
+                               if (is.spinner->hasFocus()) {
+                                       is.spinner->setValue(note);
+                                       is.spinner->selectAll();
+                               }
                        }
                }
        });