#pragma once #include #include #include "SpiralDisplay.hpp" #include "CustomSlider.hpp" namespace Amuencha { struct Model::ui { using enum halp::colors; using enum halp::layouts; halp_meta(name, "Amuencha") halp_meta(layout, hbox) halp_meta(background, dark) struct { halp_meta(layout, vbox) halp::custom_control min; halp::custom_control max; halp::item<&ins::periods> periods; } controls; halp::custom_actions_item spiral{.x = 0, .y = 0}; // Define the communication between UI and processor. struct bus { // Set up connections void init(ui& self) { self.controls.min.on_changed = [&] (int min) { self.spiral.set_min_max_notes(min, self.controls.max.value); }; self.controls.max.on_changed = [&] (int max) { self.spiral.set_min_max_notes(self.controls.min.value, max); }; } // Receive a message on the UI thread from the processing thread static void process_message(ui& self, const processor_to_ui& msg) { if (msg.power_spectrum.empty() || msg.reassigned_frequencies.empty()) return; self.spiral.power_handler(msg.reassigned_frequencies, msg.power_spectrum); } }; }; }