Make NavigationView an implicit first argument to any instance pushed onto nav stack.

This commit is contained in:
Jared Boone 2015-12-14 11:18:59 -08:00
parent 0828c66b8a
commit a340cbb74b
5 changed files with 20 additions and 20 deletions

View File

@ -108,22 +108,22 @@ void RegistersWidget::draw_values(
DebugMenuView::DebugMenuView(NavigationView& nav) {
add_items<7>({ {
{ "Memory", [&nav](){ nav.push<DebugMemoryView>(nav); } },
{ "Radio State", [&nav](){ nav.push<NotImplementedView>(nav); } },
{ "SD Card", [&nav](){ nav.push<NotImplementedView>(nav); } },
{ "Memory", [&nav](){ nav.push<DebugMemoryView>(); } },
{ "Radio State", [&nav](){ nav.push<NotImplementedView>(); } },
{ "SD Card", [&nav](){ nav.push<NotImplementedView>(); } },
{ "RFFC5072", [&nav](){ nav.push<RegistersView>(
nav, "RFFC5072", RegistersWidgetConfig { 31, 2, 4, 4 },
"RFFC5072", RegistersWidgetConfig { 31, 2, 4, 4 },
[](const size_t register_number) { return radio::first_if.read(register_number); }
); } },
{ "MAX2837", [&nav](){ nav.push<RegistersView>(
nav, "MAX2837", RegistersWidgetConfig { 32, 2, 3, 4 },
"MAX2837", RegistersWidgetConfig { 32, 2, 3, 4 },
[](const size_t register_number) { return radio::second_if.read(register_number); }
); } },
{ "Si5351C", [&nav](){ nav.push<RegistersView>(
nav, "Si5351C", RegistersWidgetConfig { 96, 2, 2, 8 },
"Si5351C", RegistersWidgetConfig { 96, 2, 2, 8 },
[](const size_t register_number) { return portapack::clock_generator.read_register(register_number); }
); } },
{ "WM8731", [&nav](){ nav.push<NotImplementedView>(nav); } },
{ "WM8731", [&nav](){ nav.push<NotImplementedView>(); } },
} });
on_left = [&nav](){ nav.pop(); };
}

View File

@ -92,13 +92,13 @@ void NavigationView::focus() {
SystemMenuView::SystemMenuView(NavigationView& nav) {
add_items<7>({ {
{ "Receiver", [&nav](){ nav.push<ReceiverView>(nav, portapack::receiver_model); } },
{ "Capture", [&nav](){ nav.push<NotImplementedView>(nav); } },
{ "Analyze", [&nav](){ nav.push<NotImplementedView>(nav); } },
{ "Setup", [&nav](){ nav.push<SetupMenuView>(nav); } },
{ "About", [&nav](){ nav.push<AboutView>(nav); } },
{ "Debug", [&nav](){ nav.push<DebugMenuView>(nav); } },
{ "HackRF", [&nav](){ nav.push<HackRFFirmwareView>(nav); } },
{ "Receiver", [&nav](){ nav.push<ReceiverView>(portapack::receiver_model); } },
{ "Capture", [&nav](){ nav.push<NotImplementedView>(); } },
{ "Analyze", [&nav](){ nav.push<NotImplementedView>(); } },
{ "Setup", [&nav](){ nav.push<SetupMenuView>(); } },
{ "About", [&nav](){ nav.push<AboutView>(); } },
{ "Debug", [&nav](){ nav.push<DebugMenuView>(); } },
{ "HackRF", [&nav](){ nav.push<HackRFFirmwareView>(); } },
} });
}
@ -134,7 +134,7 @@ SystemView::SystemView(
// Initial view.
// TODO: Restore from non-volatile memory?
navigation_view.push<SystemMenuView>(navigation_view);
navigation_view.push<SystemMenuView>();
}
Context& SystemView::context() const {

View File

@ -59,7 +59,7 @@ public:
template<class T, class... Args>
T* push(Args&&... args) {
return reinterpret_cast<T*>(push_view(std::unique_ptr<View>(new T(std::forward<Args>(args)...))));
return reinterpret_cast<T*>(push_view(std::unique_ptr<View>(new T(*this, std::forward<Args>(args)...))));
}
void pop();

View File

@ -423,7 +423,7 @@ ReceiverView::ReceiverView(
};
field_frequency.on_edit = [this, &nav]() {
// TODO: Provide separate modal method/scheme?
auto new_view = nav.push<FrequencyKeypadView>(nav, this->receiver_model.tuning_frequency());
auto new_view = nav.push<FrequencyKeypadView>(this->receiver_model.tuning_frequency());
new_view->on_changed = [this](rf::Frequency f) {
this->on_tuning_frequency_changed(f);
this->field_frequency.set_value(f);

View File

@ -159,9 +159,9 @@ void AboutView::focus() {
SetupMenuView::SetupMenuView(NavigationView& nav) {
add_items<3>({ {
{ "Date/Time", [&nav](){ nav.push<SetDateTimeView>(nav); } },
{ "Frequency Correction", [&nav](){ nav.push<SetFrequencyCorrectionView>(nav); } },
{ "Touch", [&nav](){ nav.push<NotImplementedView>(nav); } },
{ "Date/Time", [&nav](){ nav.push<SetDateTimeView>(); } },
{ "Frequency Correction", [&nav](){ nav.push<SetFrequencyCorrectionView>(); } },
{ "Touch", [&nav](){ nav.push<NotImplementedView>(); } },
} });
on_left = [&nav](){ nav.pop(); };
}