mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
View::add_children: Use std::list_initializer as argument.
Improvement in code size -- 944 bytes. Some day I will understand C++11 well enough to do the right thing the first time.
This commit is contained in:
parent
298324d6e4
commit
8a69b0523e
@ -204,9 +204,9 @@ void RecentEntriesTable<AISRecentEntries>::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);
|
||||
|
||||
|
@ -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());
|
||||
|
@ -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());
|
||||
|
@ -97,13 +97,13 @@ void RecentEntriesTable<ERTRecentEntries>::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,
|
||||
|
@ -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); } };
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ void RecentEntriesTable<TPMSRecentEntries>::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(),
|
||||
|
@ -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) {
|
||||
|
@ -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<uint32_t(const size_t register_number)>&& 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();
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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 **********************************************************/
|
||||
|
@ -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() });
|
||||
|
||||
|
@ -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(); };
|
||||
|
@ -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<int8_t>(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(); };
|
||||
|
||||
|
@ -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(); };
|
||||
|
@ -232,9 +232,11 @@ void View::add_child(Widget* const widget) {
|
||||
}
|
||||
}
|
||||
|
||||
void View::add_children(const std::vector<Widget*>& children) {
|
||||
void View::add_children(const std::initializer_list<Widget*> children) {
|
||||
children_.insert(std::end(children_), children);
|
||||
for(auto child : children) {
|
||||
add_child(child);
|
||||
child->set_parent(this);
|
||||
child->set_dirty();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ public:
|
||||
void paint(Painter& painter) override;
|
||||
|
||||
void add_child(Widget* const widget);
|
||||
void add_children(const std::vector<Widget*>& children);
|
||||
void add_children(const std::initializer_list<Widget*> children);
|
||||
void remove_child(Widget* const widget);
|
||||
const std::vector<Widget*>& children() const override;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user