mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-04-15 21:53:09 -04:00
Added new toolbar in main menu
This commit is contained in:
parent
bf2a04ab57
commit
9c9021f63b
@ -95,6 +95,15 @@ void BtnGridView::set_parent_rect(const Rect new_parent_rect) {
|
||||
update_items();
|
||||
}
|
||||
|
||||
void BtnGridView::set_arrow_enabled(bool new_value) {
|
||||
if(new_value){
|
||||
add_child(&arrow_more);
|
||||
}
|
||||
else{
|
||||
remove_child(&arrow_more);
|
||||
}
|
||||
};
|
||||
|
||||
void BtnGridView::on_tick_second() {
|
||||
if (more && blink)
|
||||
arrow_more.set_foreground(Color::white());
|
||||
|
@ -62,6 +62,7 @@ public:
|
||||
uint32_t highlighted_index();
|
||||
|
||||
void set_parent_rect(const Rect new_parent_rect) override;
|
||||
void set_arrow_enabled(bool new_value);
|
||||
void on_focus() override;
|
||||
void on_blur() override;
|
||||
bool on_key(const KeyEvent event) override;
|
||||
|
@ -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() {
|
||||
|
@ -110,7 +110,7 @@ public:
|
||||
void set_title(const std::string new_value);
|
||||
|
||||
private:
|
||||
static constexpr auto default_title = " v1.1.1"; // TODO: Move the version somewhere
|
||||
static constexpr auto default_title = "";
|
||||
|
||||
NavigationView& nav_;
|
||||
|
||||
@ -208,6 +208,59 @@ private:
|
||||
};
|
||||
};
|
||||
|
||||
class InformationView : public View {
|
||||
public:
|
||||
InformationView(NavigationView& nav);
|
||||
void update_time();
|
||||
|
||||
|
||||
private:
|
||||
void refresh();
|
||||
static constexpr auto version_string = "v1.1.1";
|
||||
NavigationView& nav_;
|
||||
|
||||
void on_time();
|
||||
|
||||
rtc::RTC datetime;
|
||||
|
||||
Rectangle backdrop {
|
||||
{ 0, 0 * 16, 240, 16 },
|
||||
{33, 33, 33}
|
||||
};
|
||||
|
||||
Text version {
|
||||
{0, 0, 11 * 8, 16},
|
||||
version_string
|
||||
};
|
||||
|
||||
ImageButton test {
|
||||
{80, 0, 16, 16},
|
||||
&bitmap_icon_camera,
|
||||
Color::white(),
|
||||
Color::dark_grey()
|
||||
};
|
||||
|
||||
Button time {
|
||||
{120, 0, 11 * 8, 16},
|
||||
""
|
||||
};
|
||||
/*
|
||||
LiveDateTime ltime {
|
||||
{120, 0, 11 * 8, 16}
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
|
||||
MessageHandlerRegistration message_handler_refresh {
|
||||
Message::ID::InfoRefresh,
|
||||
[this](const Message* const p) {
|
||||
(void)p;
|
||||
this->refresh();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
class BMPView : public View {
|
||||
public:
|
||||
BMPView(NavigationView& nav);
|
||||
@ -261,7 +314,10 @@ public:
|
||||
Context& context() const override;
|
||||
|
||||
private:
|
||||
void on_tick_second();
|
||||
|
||||
SystemStatusView status_view { navigation_view };
|
||||
InformationView info_view { navigation_view };
|
||||
NavigationView navigation_view { };
|
||||
Context& context_;
|
||||
};
|
||||
|
@ -111,6 +111,7 @@ public:
|
||||
AudioLevelReport = 51,
|
||||
CodedSquelch = 52,
|
||||
AudioSpectrum = 53,
|
||||
InfoRefresh = 54,
|
||||
MAX
|
||||
};
|
||||
|
||||
@ -234,6 +235,14 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class InfoRefreshMessage : public Message {
|
||||
public:
|
||||
constexpr InfoRefreshMessage(
|
||||
) : Message { ID::InfoRefresh }
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class AudioStatisticsMessage : public Message {
|
||||
public:
|
||||
constexpr AudioStatisticsMessage(
|
||||
|
@ -1046,6 +1046,16 @@ bool NewButton::on_touch(const TouchEvent event) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/* DateTimeButton ********************************************************/
|
||||
|
||||
DateTimeButton::DateTimeButton(
|
||||
Rect parent_rect,
|
||||
std::string text
|
||||
) : Button { parent_rect , text_}
|
||||
{
|
||||
set_focusable(true);
|
||||
}
|
||||
|
||||
|
||||
/* Image *****************************************************************/
|
||||
|
||||
|
@ -428,6 +428,16 @@ private:
|
||||
const Bitmap* bitmap_;
|
||||
};
|
||||
|
||||
class DateTimeButton : public Button {
|
||||
public:
|
||||
DateTimeButton(Rect parent_rect, std::string text);
|
||||
void paint(Painter& painter) override;
|
||||
private:
|
||||
std::string text_;
|
||||
void on_tick_second();
|
||||
|
||||
};
|
||||
|
||||
class Image : public Widget {
|
||||
public:
|
||||
Image();
|
||||
|
Loading…
x
Reference in New Issue
Block a user