mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-12-28 08:49:45 -05:00
Set Navigation title with View.title() if not empty.
This commit is contained in:
parent
dc42525dcb
commit
7fe8288737
@ -41,7 +41,7 @@ namespace ui {
|
||||
SystemStatusView::SystemStatusView() {
|
||||
add_children({ {
|
||||
&button_back,
|
||||
&portapack,
|
||||
&title,
|
||||
&sd_card_status_view,
|
||||
} });
|
||||
sd_card_status_view.set_parent_rect({ 28 * 8, 0 * 16, 2 * 8, 1 * 16 });
|
||||
@ -57,6 +57,14 @@ void SystemStatusView::set_back_visible(bool new_value) {
|
||||
button_back.hidden(!new_value);
|
||||
}
|
||||
|
||||
void SystemStatusView::set_title(const std::string new_value) {
|
||||
if( new_value.empty() ) {
|
||||
title.set(default_title);
|
||||
} else {
|
||||
title.set(new_value);
|
||||
}
|
||||
}
|
||||
|
||||
/* Navigation ************************************************************/
|
||||
|
||||
bool NavigationView::is_top() const {
|
||||
@ -97,7 +105,7 @@ void NavigationView::update_view() {
|
||||
set_dirty();
|
||||
|
||||
if( on_view_changed ) {
|
||||
on_view_changed();
|
||||
on_view_changed(*new_view);
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,8 +184,9 @@ SystemView::SystemView(
|
||||
{ 0, status_view_height },
|
||||
{ parent_rect.width(), static_cast<ui::Dim>(parent_rect.height() - status_view_height) }
|
||||
});
|
||||
navigation_view.on_view_changed = [this]() {
|
||||
navigation_view.on_view_changed = [this](const View& new_view) {
|
||||
this->status_view.set_back_visible(!this->navigation_view.is_top());
|
||||
this->status_view.set_title(new_view.title());
|
||||
};
|
||||
|
||||
// Initial view.
|
||||
|
@ -44,16 +44,19 @@ public:
|
||||
SystemStatusView();
|
||||
|
||||
void set_back_visible(bool new_value);
|
||||
void set_title(const std::string new_value);
|
||||
|
||||
private:
|
||||
static constexpr auto default_title = "PortaPack";
|
||||
|
||||
Button button_back {
|
||||
{ 0 * 8, 0 * 16, 3 * 8, 16 },
|
||||
" < ",
|
||||
};
|
||||
|
||||
Text portapack {
|
||||
{ 3 * 8, 0, 9 * 8, 1 * 16 },
|
||||
"PortaPack",
|
||||
Text title {
|
||||
{ 3 * 8, 0, 16 * 8, 1 * 16 },
|
||||
default_title,
|
||||
};
|
||||
|
||||
SDCardStatusView sd_card_status_view;
|
||||
@ -61,7 +64,7 @@ private:
|
||||
|
||||
class NavigationView : public View {
|
||||
public:
|
||||
std::function<void(void)> on_view_changed;
|
||||
std::function<void(const View&)> on_view_changed;
|
||||
|
||||
NavigationView() { }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user