Skip to content

Commit

Permalink
touch to pop splash (#2260)
Browse files Browse the repository at this point in the history
* touch to pop

* debug

* have to add another var

* works but since touch screen is laggy, it's tricky

* tune to single touch

* remove debug things

* safer with sleep

* textual

* @htotoo resolved the sleep issue

* use pop handler in another place (button)
  • Loading branch information
zxkmm authored Sep 23, 2024
1 parent 572776b commit 24ab2f2
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
37 changes: 34 additions & 3 deletions firmware/application/ui_navigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -996,11 +996,12 @@ void BMPView::focus() {
button_done.focus();
}

BMPView::BMPView(NavigationView& nav) {
BMPView::BMPView(NavigationView& nav)
: nav_(nav) {
add_children({&button_done});

button_done.on_select = [this, &nav](Button&) {
nav.pop();
button_done.on_select = [this](Button&) {
handle_pop();
};
}

Expand All @@ -1009,6 +1010,36 @@ void BMPView::paint(Painter&) {
portapack::display.drawBMP({(240 - 230) / 2, (320 - 50) / 2 - 10}, splash_bmp, true);
}

bool BMPView::on_touch(const TouchEvent event) {
/* the event thing were resolved by HTotoo, talked here https://discord.com/channels/719669764804444213/956561375155589192/1287756910950486027
* the touch screen policy can be better, talked here https://discord.com/channels/719669764804444213/956561375155589192/1198926225897443328
*/

if (!nav_.is_valid()) {
return false;
}

switch (event.type) {
case TouchEvent::Type::Start:
return true;

case TouchEvent::Type::End:
handle_pop();
return true;

default:
break;
}

return false;
}

void BMPView::handle_pop() {
if (nav_.is_valid()) {
nav_.pop();
}
}

/* NotImplementedView ****************************************************/

/*NotImplementedView::NotImplementedView(NavigationView& nav) {
Expand Down
4 changes: 4 additions & 0 deletions firmware/application/ui_navigation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,11 @@ class BMPView : public View {
void paint(Painter&) override;
void focus() override;

bool on_touch(const TouchEvent event) override;
void handle_pop();

private:
NavigationView& nav_;
Button button_done{
{240, 0, 1, 1},
""};
Expand Down

0 comments on commit 24ab2f2

Please sign in to comment.