Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

touch to pop splash #2260

Merged
merged 10 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 84 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&) {
nav_.pop();
};
}

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

bool BMPView::on_touch(const TouchEvent event) {
/*
* TODO: since the touch screen detect touching evt policy is kind of bad, with hard-coded threshold it works but not sensitive, i will use single touch firstly
* and it's a waist of space to implement them all and as options in settings.
* the touch screen policy can be better, talked here https://discord.com/channels/719669764804444213/956561375155589192/1198926225897443328
* when that fixed (so the threshold won't make the corner always been touched), just un-comment one of the field and two var in header to make it works.
*/

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

switch (event.type) {
case TouchEvent::Type::Start:
chThdSleep(10);
handle_pop();
return false;

case TouchEvent::Type::End:
zxkmm marked this conversation as resolved.
Show resolved Hide resolved
chThdSleep(10);
handle_pop();
return false;

default:
break;
}

/// drag any direction to pop (like samsung phone)
// switch (event.type) {
// case TouchEvent::Type::Start:
// touch_start = event.point.y();
// return true;
//
// case TouchEvent::Type::End:
// touch_end = event.point.y();
//
// if (abs(touch_start - touch_end) > 100) {
// if (touch_start < touch_end) {
// handle_pop();
// }
// }
// return true;
//
// default:
// break;
// }

/// drag from bottom to pop (like iphone)
// switch (event.type) {
// case TouchEvent::Type::Start:
//
// touch_start = event.point.y();
//
// return true;
//
// case TouchEvent::Type::End:
//
// touch_end = event.point.y();
//
// if (touch_start > screen_height - 20 && // make sure drag from bottom
// touch_end < touch_start - 100) {
// handle_pop();
// }
// return true;
//
// default:
// break;
// }

return false;
}

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

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

/*NotImplementedView::NotImplementedView(NavigationView& nav) {
Expand Down
6 changes: 6 additions & 0 deletions firmware/application/ui_navigation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,16 @@ 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},
""};
// Coord touch_start{0};
// Coord touch_end{0};
};

class ReceiversMenuView : public BtnGridView {
Expand Down
Loading