mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-14 17:35:34 -04:00
Added new toolbar in main menu
This commit is contained in:
parent
bf2a04ab57
commit
9c9021f63b
7 changed files with 174 additions and 5 deletions
|
@ -306,6 +306,56 @@ void SystemStatusView::on_title() {
|
|||
nav_.push<AboutView>();
|
||||
}
|
||||
|
||||
/* Information View *****************************************************/
|
||||
|
||||
InformationView::InformationView(
|
||||
NavigationView& nav
|
||||
) : nav_ (nav)
|
||||
{
|
||||
static constexpr Style style_infobar {
|
||||
.font = font::fixed_8x16,
|
||||
.background = {33, 33, 33},
|
||||
.foreground = Color::white(),
|
||||
};
|
||||
|
||||
add_children({
|
||||
&backdrop,
|
||||
&version,
|
||||
&test,
|
||||
&time
|
||||
});
|
||||
|
||||
test.on_select = [this](ImageButton&){
|
||||
update_time();
|
||||
};
|
||||
|
||||
this->set_focusable(true);
|
||||
this->set_visible(true);
|
||||
time.set_focusable(true);
|
||||
version.set_style(&style_infobar);
|
||||
|
||||
time.on_select = [this](Button&) {
|
||||
this->on_time();
|
||||
};
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
void InformationView::refresh() {
|
||||
update_time();
|
||||
set_dirty();
|
||||
}
|
||||
|
||||
void InformationView::on_time(){
|
||||
update_time();
|
||||
}
|
||||
|
||||
void InformationView::update_time() {
|
||||
rtcGetTime(&RTCD1, &datetime);
|
||||
time.set_text(to_string_datetime(datetime));
|
||||
set_dirty();
|
||||
}
|
||||
|
||||
/* Navigation ************************************************************/
|
||||
|
||||
bool NavigationView::is_top() const {
|
||||
|
@ -502,6 +552,7 @@ SystemMenuView::SystemMenuView(NavigationView& nav) {
|
|||
//{ "About", ui::Color::cyan(), nullptr, [&nav](){ nav.push<AboutView>(); } }
|
||||
});
|
||||
set_max_rows(2); // allow wider buttons
|
||||
set_arrow_enabled(false);
|
||||
//set_highlighted(1); // Startup selection
|
||||
}
|
||||
|
||||
|
@ -522,6 +573,7 @@ SystemView::SystemView(
|
|||
set_style(&style_default);
|
||||
|
||||
constexpr ui::Dim status_view_height = 16;
|
||||
constexpr ui::Dim info_view_height = 16;
|
||||
|
||||
add_child(&status_view);
|
||||
status_view.set_parent_rect({
|
||||
|
@ -532,18 +584,36 @@ SystemView::SystemView(
|
|||
this->navigation_view.pop();
|
||||
};
|
||||
|
||||
add_child(&info_view);
|
||||
info_view.set_parent_rect({
|
||||
{0, 19 * 16},
|
||||
{ parent_rect.width(), info_view_height }
|
||||
});
|
||||
|
||||
add_child(&navigation_view);
|
||||
navigation_view.set_parent_rect({
|
||||
{ 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 - info_view_height) }
|
||||
});
|
||||
navigation_view.on_view_changed = [this](const View& new_view) {
|
||||
|
||||
if(!this->navigation_view.is_top()){
|
||||
remove_child(&info_view);
|
||||
}
|
||||
else{
|
||||
add_child(&info_view);
|
||||
this->info_view.update_time();
|
||||
}
|
||||
|
||||
this->status_view.set_back_enabled(!this->navigation_view.is_top());
|
||||
this->status_view.set_title_image_enabled(this->navigation_view.is_top());
|
||||
this->status_view.set_dirty();
|
||||
this->status_view.set_title(new_view.title());
|
||||
this->status_view.set_dirty();
|
||||
|
||||
|
||||
//this->info_view.focus();
|
||||
};
|
||||
|
||||
|
||||
|
||||
// portapack::persistent_memory::set_playdead_sequence(0x8D1);
|
||||
|
||||
|
@ -559,7 +629,7 @@ SystemView::SystemView(
|
|||
navigation_view.push<BMPView>();
|
||||
status_view.set_back_enabled(false);
|
||||
status_view.set_title_image_enabled(true);
|
||||
this->status_view.set_dirty();
|
||||
status_view.set_dirty();
|
||||
//else
|
||||
// navigation_view.push<SystemMenuView>();
|
||||
|
||||
|
@ -570,6 +640,10 @@ Context& SystemView::context() const {
|
|||
return context_;
|
||||
}
|
||||
|
||||
void SystemView::on_tick_second() {
|
||||
this->info_view.update_time();
|
||||
}
|
||||
|
||||
/* ***********************************************************************/
|
||||
|
||||
void BMPView::focus() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue