mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2024-12-14 12:08:40 +00:00
Move nav back button outside of ReceiverView.
This commit is contained in:
parent
029a44e24c
commit
15800eea33
@ -40,14 +40,29 @@ namespace ui {
|
|||||||
|
|
||||||
SystemStatusView::SystemStatusView() {
|
SystemStatusView::SystemStatusView() {
|
||||||
add_children({ {
|
add_children({ {
|
||||||
|
&button_back,
|
||||||
&portapack,
|
&portapack,
|
||||||
&sd_card_status_view,
|
&sd_card_status_view,
|
||||||
} });
|
} });
|
||||||
sd_card_status_view.set_parent_rect({ 28 * 8, 0 * 16, 2 * 8, 1 * 16 });
|
sd_card_status_view.set_parent_rect({ 28 * 8, 0 * 16, 2 * 8, 1 * 16 });
|
||||||
|
|
||||||
|
button_back.on_select = [this](Button&){
|
||||||
|
if( this->on_back ) {
|
||||||
|
this->on_back();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void SystemStatusView::set_back_visible(bool new_value) {
|
||||||
|
button_back.hidden(!new_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Navigation ************************************************************/
|
/* Navigation ************************************************************/
|
||||||
|
|
||||||
|
bool NavigationView::is_top() const {
|
||||||
|
return view_stack.size() == 1;
|
||||||
|
}
|
||||||
|
|
||||||
View* NavigationView::push_view(std::unique_ptr<View> new_view) {
|
View* NavigationView::push_view(std::unique_ptr<View> new_view) {
|
||||||
free_view();
|
free_view();
|
||||||
|
|
||||||
@ -80,6 +95,10 @@ void NavigationView::update_view() {
|
|||||||
new_view->set_parent_rect({ {0, 0}, size() });
|
new_view->set_parent_rect({ {0, 0}, size() });
|
||||||
focus();
|
focus();
|
||||||
set_dirty();
|
set_dirty();
|
||||||
|
|
||||||
|
if( on_view_changed ) {
|
||||||
|
on_view_changed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget* NavigationView::view() const {
|
Widget* NavigationView::view() const {
|
||||||
@ -148,12 +167,18 @@ SystemView::SystemView(
|
|||||||
{ 0, 0 },
|
{ 0, 0 },
|
||||||
{ parent_rect.width(), status_view_height }
|
{ parent_rect.width(), status_view_height }
|
||||||
});
|
});
|
||||||
|
status_view.on_back = [this]() {
|
||||||
|
this->navigation_view.pop();
|
||||||
|
};
|
||||||
|
|
||||||
add_child(&navigation_view);
|
add_child(&navigation_view);
|
||||||
navigation_view.set_parent_rect({
|
navigation_view.set_parent_rect({
|
||||||
{ 0, status_view_height },
|
{ 0, status_view_height },
|
||||||
{ parent_rect.width(), static_cast<ui::Dim>(parent_rect.height() - status_view_height) }
|
{ parent_rect.width(), static_cast<ui::Dim>(parent_rect.height() - status_view_height) }
|
||||||
});
|
});
|
||||||
|
navigation_view.on_view_changed = [this]() {
|
||||||
|
this->status_view.set_back_visible(!this->navigation_view.is_top());
|
||||||
|
};
|
||||||
|
|
||||||
// Initial view.
|
// Initial view.
|
||||||
// TODO: Restore from non-volatile memory?
|
// TODO: Restore from non-volatile memory?
|
||||||
|
@ -39,11 +39,20 @@ namespace ui {
|
|||||||
|
|
||||||
class SystemStatusView : public View {
|
class SystemStatusView : public View {
|
||||||
public:
|
public:
|
||||||
|
std::function<void(void)> on_back;
|
||||||
|
|
||||||
SystemStatusView();
|
SystemStatusView();
|
||||||
|
|
||||||
|
void set_back_visible(bool new_value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Button button_back {
|
||||||
|
{ 0 * 8, 0 * 16, 3 * 8, 16 },
|
||||||
|
" < ",
|
||||||
|
};
|
||||||
|
|
||||||
Text portapack {
|
Text portapack {
|
||||||
{ 0, 0, 9 * 8, 1 * 16 },
|
{ 3 * 8, 0, 9 * 8, 1 * 16 },
|
||||||
"PortaPack",
|
"PortaPack",
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -52,11 +61,15 @@ private:
|
|||||||
|
|
||||||
class NavigationView : public View {
|
class NavigationView : public View {
|
||||||
public:
|
public:
|
||||||
|
std::function<void(void)> on_view_changed;
|
||||||
|
|
||||||
NavigationView() { }
|
NavigationView() { }
|
||||||
|
|
||||||
NavigationView(const NavigationView&) = delete;
|
NavigationView(const NavigationView&) = delete;
|
||||||
NavigationView(NavigationView&&) = delete;
|
NavigationView(NavigationView&&) = delete;
|
||||||
|
|
||||||
|
bool is_top() const;
|
||||||
|
|
||||||
template<class T, class... Args>
|
template<class T, class... Args>
|
||||||
T* push(Args&&... args) {
|
T* push(Args&&... args) {
|
||||||
return reinterpret_cast<T*>(push_view(std::unique_ptr<View>(new T(*this, std::forward<Args>(args)...))));
|
return reinterpret_cast<T*>(push_view(std::unique_ptr<View>(new T(*this, std::forward<Args>(args)...))));
|
||||||
|
@ -369,7 +369,6 @@ ReceiverView::ReceiverView(
|
|||||||
&rssi,
|
&rssi,
|
||||||
&channel,
|
&channel,
|
||||||
&audio,
|
&audio,
|
||||||
&button_done,
|
|
||||||
&field_frequency,
|
&field_frequency,
|
||||||
&field_lna,
|
&field_lna,
|
||||||
//&options_baseband_bandwidth,
|
//&options_baseband_bandwidth,
|
||||||
@ -381,10 +380,6 @@ ReceiverView::ReceiverView(
|
|||||||
&view_rf_gain_options,
|
&view_rf_gain_options,
|
||||||
} });
|
} });
|
||||||
|
|
||||||
button_done.on_select = [&nav](Button&){
|
|
||||||
nav.pop();
|
|
||||||
};
|
|
||||||
|
|
||||||
field_frequency.set_value(receiver_model.tuning_frequency());
|
field_frequency.set_value(receiver_model.tuning_frequency());
|
||||||
field_frequency.set_step(receiver_model.frequency_step());
|
field_frequency.set_step(receiver_model.frequency_step());
|
||||||
field_frequency.on_change = [this](rf::Frequency f) {
|
field_frequency.on_change = [this](rf::Frequency f) {
|
||||||
@ -480,7 +475,7 @@ void ReceiverView::on_hide() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ReceiverView::focus() {
|
void ReceiverView::focus() {
|
||||||
button_done.focus();
|
field_frequency.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReceiverView::on_tuning_frequency_changed(rf::Frequency f) {
|
void ReceiverView::on_tuning_frequency_changed(rf::Frequency f) {
|
||||||
|
@ -375,11 +375,6 @@ private:
|
|||||||
{ 19 * 8, 10, 11 * 8, 4 },
|
{ 19 * 8, 10, 11 * 8, 4 },
|
||||||
};
|
};
|
||||||
|
|
||||||
Button button_done {
|
|
||||||
{ 0 * 8, 0 * 16, 3 * 8, 16 },
|
|
||||||
" < ",
|
|
||||||
};
|
|
||||||
|
|
||||||
FrequencyField field_frequency {
|
FrequencyField field_frequency {
|
||||||
{ 0 * 8, 1 * 16 },
|
{ 0 * 8, 1 * 16 },
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user