touch to pop splash (#2260)

* 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)
This commit is contained in:
zxkmm 2024-09-24 02:57:15 +08:00 committed by GitHub
parent 572776bb9e
commit 24ab2f29fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 38 additions and 3 deletions

View File

@ -996,11 +996,12 @@ void BMPView::focus() {
button_done.focus(); button_done.focus();
} }
BMPView::BMPView(NavigationView& nav) { BMPView::BMPView(NavigationView& nav)
: nav_(nav) {
add_children({&button_done}); add_children({&button_done});
button_done.on_select = [this, &nav](Button&) { button_done.on_select = [this](Button&) {
nav.pop(); handle_pop();
}; };
} }
@ -1009,6 +1010,36 @@ void BMPView::paint(Painter&) {
portapack::display.drawBMP({(240 - 230) / 2, (320 - 50) / 2 - 10}, splash_bmp, true); 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::NotImplementedView(NavigationView& nav) { /*NotImplementedView::NotImplementedView(NavigationView& nav) {

View File

@ -343,7 +343,11 @@ class BMPView : public View {
void paint(Painter&) override; void paint(Painter&) override;
void focus() override; void focus() override;
bool on_touch(const TouchEvent event) override;
void handle_pop();
private: private:
NavigationView& nav_;
Button button_done{ Button button_done{
{240, 0, 1, 1}, {240, 0, 1, 1},
""}; ""};