diff --git a/firmware/application/ais_app.cpp b/firmware/application/ais_app.cpp index c79f3050..8a53da71 100644 --- a/firmware/application/ais_app.cpp +++ b/firmware/application/ais_app.cpp @@ -204,9 +204,9 @@ void RecentEntriesTable::draw( } AISRecentEntryDetailView::AISRecentEntryDetailView() { - add_children({ { + add_children({ &button_done, - } }); + }); button_done.on_select = [this](const ui::Button&) { if( this->on_close ) { @@ -264,7 +264,7 @@ void AISRecentEntryDetailView::set_entry(const AISRecentEntry& entry) { AISAppView::AISAppView(NavigationView&) { baseband::run_image(portapack::spi_flash::image_tag_ais); - add_children({ { + add_children({ &label_channel, &options_channel, &field_rf_amp, @@ -274,7 +274,7 @@ AISAppView::AISAppView(NavigationView&) { &channel, &recent_entries_view, &recent_entry_detail_view, - } }); + }); recent_entry_detail_view.hidden(true); diff --git a/firmware/application/analog_audio_app.cpp b/firmware/application/analog_audio_app.cpp index 417d1ea1..0a6009ca 100644 --- a/firmware/application/analog_audio_app.cpp +++ b/firmware/application/analog_audio_app.cpp @@ -44,10 +44,10 @@ AMOptionsView::AMOptionsView( { set_style(style); - add_children({ { + add_children({ &label_config, &options_config, - } }); + }); options_config.set_selected_index(receiver_model.am_configuration()); options_config.on_change = [this](size_t n, OptionsField::value_t) { @@ -63,10 +63,10 @@ NBFMOptionsView::NBFMOptionsView( { set_style(style); - add_children({ { + add_children({ &label_config, &options_config, - } }); + }); options_config.set_selected_index(receiver_model.nbfm_configuration()); options_config.on_change = [this](size_t n, OptionsField::value_t) { @@ -79,7 +79,7 @@ NBFMOptionsView::NBFMOptionsView( AnalogAudioView::AnalogAudioView( NavigationView& nav ) { - add_children({ { + add_children({ &rssi, &channel, &audio, @@ -90,7 +90,7 @@ AnalogAudioView::AnalogAudioView( &field_volume, &record_view, &waterfall, - } }); + }); field_frequency.set_value(receiver_model.tuning_frequency()); field_frequency.set_step(receiver_model.frequency_step()); diff --git a/firmware/application/capture_app.cpp b/firmware/application/capture_app.cpp index 6ebcd02f..cd2a3824 100644 --- a/firmware/application/capture_app.cpp +++ b/firmware/application/capture_app.cpp @@ -34,7 +34,7 @@ namespace ui { CaptureAppView::CaptureAppView(NavigationView& nav) { baseband::run_image(portapack::spi_flash::image_tag_capture); - add_children({ { + add_children({ &rssi, &channel, &field_frequency, @@ -44,7 +44,7 @@ CaptureAppView::CaptureAppView(NavigationView& nav) { &field_vga, &record_view, &waterfall, - } }); + }); field_frequency.set_value(target_frequency()); field_frequency.set_step(receiver_model.frequency_step()); diff --git a/firmware/application/ert_app.cpp b/firmware/application/ert_app.cpp index d8d20fa4..5df0f336 100644 --- a/firmware/application/ert_app.cpp +++ b/firmware/application/ert_app.cpp @@ -97,13 +97,13 @@ void RecentEntriesTable::draw( ERTAppView::ERTAppView(NavigationView&) { baseband::run_image(portapack::spi_flash::image_tag_ert); - add_children({ { + add_children({ &field_rf_amp, &field_lna, &field_vga, &rssi, &recent_entries_view, - } }); + }); radio::enable({ initial_target_frequency, diff --git a/firmware/application/recent_entries.hpp b/firmware/application/recent_entries.hpp index 5bfa3e12..e4068270 100644 --- a/firmware/application/recent_entries.hpp +++ b/firmware/application/recent_entries.hpp @@ -264,10 +264,10 @@ public: ) : _header { columns }, _table { recent } { - add_children({ { + add_children({ &_header, &_table, - } }); + }); _table.on_select = [this](const Entry& entry) { if( this->on_select ) { this->on_select(entry); } }; } diff --git a/firmware/application/tpms_app.cpp b/firmware/application/tpms_app.cpp index 989e98d9..7fe5ab6f 100644 --- a/firmware/application/tpms_app.cpp +++ b/firmware/application/tpms_app.cpp @@ -135,7 +135,7 @@ void RecentEntriesTable::draw( TPMSAppView::TPMSAppView(NavigationView&) { baseband::run_image(portapack::spi_flash::image_tag_tpms); - add_children({ { + add_children({ &rssi, &channel, &options_band, @@ -143,7 +143,7 @@ TPMSAppView::TPMSAppView(NavigationView&) { &field_lna, &field_vga, &recent_entries_view, - } }); + }); radio::enable({ tuning_frequency(), diff --git a/firmware/application/ui_baseband_stats_view.cpp b/firmware/application/ui_baseband_stats_view.cpp index 44774465..b6a9525f 100644 --- a/firmware/application/ui_baseband_stats_view.cpp +++ b/firmware/application/ui_baseband_stats_view.cpp @@ -34,9 +34,9 @@ namespace ui { /* BasebandStatsView *****************************************************/ BasebandStatsView::BasebandStatsView() { - add_children({ { + add_children({ &text_stats, - } }); + }); } static std::string ticks_to_percent_string(const uint32_t ticks) { diff --git a/firmware/application/ui_debug.cpp b/firmware/application/ui_debug.cpp index e3d673a0..a5cc61e6 100644 --- a/firmware/application/ui_debug.cpp +++ b/firmware/application/ui_debug.cpp @@ -35,7 +35,7 @@ namespace ui { /* DebugMemoryView *******************************************************/ DebugMemoryView::DebugMemoryView(NavigationView& nav) { - add_children({ { + add_children({ &text_title, &text_label_m0_core_free, &text_label_m0_core_free_value, @@ -44,7 +44,7 @@ DebugMemoryView::DebugMemoryView(NavigationView& nav) { &text_label_m0_heap_fragments, &text_label_m0_heap_fragments_value, &button_done - } }); + }); const auto m0_core_free = chCoreStatus(); text_label_m0_core_free_value.set(to_string_dec_uint(m0_core_free, 5)); @@ -135,11 +135,11 @@ Coord TemperatureWidget::screen_y( /* TemperatureView *******************************************************/ TemperatureView::TemperatureView(NavigationView& nav) { - add_children({ { + add_children({ &text_title, &temperature_widget, &button_done, - } }); + }); button_done.on_select = [&nav](Button&){ nav.pop(); }; } @@ -219,12 +219,12 @@ RegistersView::RegistersView( std::function&& reader ) : registers_widget { std::move(config), std::move(reader) } { - add_children({ { + add_children({ &text_title, ®isters_widget, &button_update, &button_done, - } }); + }); button_update.on_select = [this](Button&){ this->registers_widget.update(); diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index ba8e783c..b8882620 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -43,13 +43,13 @@ namespace ui { /* SystemStatusView ******************************************************/ SystemStatusView::SystemStatusView() { - add_children({ { + add_children({ &button_back, &title, &button_camera, &button_sleep, &sd_card_status_view, - } }); + }); button_back.on_select = [this](Button&){ if( this->on_back ) { @@ -259,7 +259,7 @@ HackRFFirmwareView::HackRFFirmwareView(NavigationView& nav) { nav.pop(); }; - add_children({ { + add_children({ &text_title, &text_description_1, &text_description_2, @@ -267,7 +267,7 @@ HackRFFirmwareView::HackRFFirmwareView(NavigationView& nav) { &text_description_4, &button_yes, &button_no, - } }); + }); } void HackRFFirmwareView::focus() { @@ -281,10 +281,10 @@ NotImplementedView::NotImplementedView(NavigationView& nav) { nav.pop(); }; - add_children({ { + add_children({ &text_title, &button_done, - } }); + }); } void NotImplementedView::focus() { @@ -303,10 +303,10 @@ ModalMessageView::ModalMessageView( nav.pop(); }; - add_children({ { + add_children({ &text_message, &button_done, - } }); + }); text_message.set(message); diff --git a/firmware/application/ui_receiver.cpp b/firmware/application/ui_receiver.cpp index d48917a4..1e7c648d 100644 --- a/firmware/application/ui_receiver.cpp +++ b/firmware/application/ui_receiver.cpp @@ -241,12 +241,12 @@ FrequencyOptionsView::FrequencyOptionsView( this->on_reference_ppm_correction_changed(v); }; - add_children({ { + add_children({ &text_step, &field_step, &field_ppm, &text_ppm, - } }); + }); } void FrequencyOptionsView::set_step(rf::Frequency f) { @@ -297,10 +297,10 @@ RadioGainOptionsView::RadioGainOptionsView( { set_style(style); - add_children({ { + add_children({ &label_rf_amp, &field_rf_amp, - } }); + }); } /* LNAGainField **********************************************************/ diff --git a/firmware/application/ui_record_view.cpp b/firmware/application/ui_record_view.cpp index 71211dfc..01155490 100644 --- a/firmware/application/ui_record_view.cpp +++ b/firmware/application/ui_record_view.cpp @@ -177,13 +177,13 @@ RecordView::RecordView( write_size { write_size }, buffer_count { buffer_count } { - add_children({ { + add_children({ &rect_background, &button_record, &text_record_filename, &text_record_dropped, &text_time_available, - } }); + }); rect_background.set_parent_rect({ { 0, 0 }, size() }); diff --git a/firmware/application/ui_sd_card_debug.cpp b/firmware/application/ui_sd_card_debug.cpp index 22db218c..12dc5293 100644 --- a/firmware/application/ui_sd_card_debug.cpp +++ b/firmware/application/ui_sd_card_debug.cpp @@ -230,7 +230,7 @@ Thread* SDCardTestThread::thread { nullptr }; namespace ui { SDCardDebugView::SDCardDebugView(NavigationView& nav) { - add_children({ { + add_children({ &text_title, &text_csd_title, &text_csd_value_3, @@ -257,7 +257,7 @@ SDCardDebugView::SDCardDebugView(NavigationView& nav) { &text_test_read_rate_value, &button_test, &button_ok, - } }); + }); button_test.on_select = [this](Button&){ this->on_test(); }; button_ok.on_select = [&nav](Button&){ nav.pop(); }; diff --git a/firmware/application/ui_setup.cpp b/firmware/application/ui_setup.cpp index 9bc75389..2beddf7a 100644 --- a/firmware/application/ui_setup.cpp +++ b/firmware/application/ui_setup.cpp @@ -51,7 +51,7 @@ SetDateTimeView::SetDateTimeView( nav.pop(); }, - add_children({ { + add_children({ &text_title, &field_year, &text_slash1, @@ -66,7 +66,7 @@ SetDateTimeView::SetDateTimeView( &text_format, &button_ok, &button_cancel, - } }); + }); rtc::RTC datetime; rtcGetTime(&RTCD1, &datetime); @@ -119,13 +119,13 @@ SetFrequencyCorrectionView::SetFrequencyCorrectionView( nav.pop(); }, - add_children({ { + add_children({ &text_title, &field_ppm, &text_ppm, &button_ok, &button_cancel, - } }); + }); SetFrequencyCorrectionModel model { static_cast(portapack::persistent_memory::correction_ppb() / 1000) @@ -149,7 +149,7 @@ SetFrequencyCorrectionModel SetFrequencyCorrectionView::form_collect() { } AntennaBiasSetupView::AntennaBiasSetupView(NavigationView& nav) { - add_children({ { + add_children({ &text_title, &text_description_1, &text_description_2, @@ -157,7 +157,7 @@ AntennaBiasSetupView::AntennaBiasSetupView(NavigationView& nav) { &text_description_4, &options_bias, &button_done, - } }); + }); options_bias.set_by_value(receiver_model.antenna_bias() ? 1 : 0); options_bias.on_change = [this](size_t, OptionsField::value_t v) { @@ -172,13 +172,13 @@ void AntennaBiasSetupView::focus() { } AboutView::AboutView(NavigationView& nav) { - add_children({ { + add_children({ &text_title, &text_firmware, &text_cpld_hackrf, &text_cpld_hackrf_status, &button_ok, - } }); + }); button_ok.on_select = [&nav](Button&){ nav.pop(); }; diff --git a/firmware/application/ui_touch_calibration.cpp b/firmware/application/ui_touch_calibration.cpp index 6fe20027..37cd0df8 100644 --- a/firmware/application/ui_touch_calibration.cpp +++ b/firmware/application/ui_touch_calibration.cpp @@ -33,7 +33,7 @@ TouchCalibrationView::TouchCalibrationView( ) : nav { nav }, calibration { touch::default_calibration() } { - add_children({ { + add_children({ &image_calibrate_0, &image_calibrate_1, &image_calibrate_2, @@ -46,7 +46,7 @@ TouchCalibrationView::TouchCalibrationView( &label_failure, &button_cancel, &button_ok, - } }); + }); button_cancel.on_select = [this](Button&){ this->on_cancel(); }; button_ok.on_select = [this](Button&){ this->on_ok(); }; diff --git a/firmware/common/ui_widget.cpp b/firmware/common/ui_widget.cpp index 31a71d51..d760faaa 100644 --- a/firmware/common/ui_widget.cpp +++ b/firmware/common/ui_widget.cpp @@ -232,9 +232,11 @@ void View::add_child(Widget* const widget) { } } -void View::add_children(const std::vector& children) { +void View::add_children(const std::initializer_list children) { + children_.insert(std::end(children_), children); for(auto child : children) { - add_child(child); + child->set_parent(this); + child->set_dirty(); } } diff --git a/firmware/common/ui_widget.hpp b/firmware/common/ui_widget.hpp index 2c427249..18a03158 100644 --- a/firmware/common/ui_widget.hpp +++ b/firmware/common/ui_widget.hpp @@ -154,7 +154,7 @@ public: void paint(Painter& painter) override; void add_child(Widget* const widget); - void add_children(const std::vector& children); + void add_children(const std::initializer_list children); void remove_child(Widget* const widget); const std::vector& children() const override;