diff options
author | Reinhold Gschweicher <pyro4hell@gmail.com> | 2022-04-03 20:51:53 +0200 |
---|---|---|
committer | Riku Isokoski <riksu9000@gmail.com> | 2022-04-25 15:51:51 +0300 |
commit | 2e42b9000904fe56e2f8cff238a4d911f7648520 (patch) | |
tree | ddd0657be39392e03ddac2e944b72f9cc02882f1 /src/displayapp/screens/Paddle.cpp | |
parent | b6807ee3ca40b19f89369cf159d1794153268b0c (diff) |
Keep the paddle on screen in whole
As suggested in https://github.com/InfiniTimeOrg/InfiniTime/issues/1062
in point 3. The paddle should be kept on screen and not travel out of
the screen boundaries.
Co-authored-by: Riku Isokoski <riksu9000@gmail.com>
Diffstat (limited to 'src/displayapp/screens/Paddle.cpp')
-rw-r--r-- | src/displayapp/screens/Paddle.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/displayapp/screens/Paddle.cpp b/src/displayapp/screens/Paddle.cpp index 79401ff9..2865db08 100644 --- a/src/displayapp/screens/Paddle.cpp +++ b/src/displayapp/screens/Paddle.cpp @@ -85,7 +85,14 @@ bool Paddle::OnTouchEvent(Pinetime::Applications::TouchEvents event) { bool Paddle::OnTouchEvent(uint16_t x, uint16_t y) { // sets the center paddle pos. (30px offset) with the the y_coordinate of the finger - lv_obj_set_pos(paddle, 0, y - 30); + // but clamp it such that the paddle never clips off screen + if (y < 31) { + lv_obj_set_pos(paddle, 0, 1); + } else if (y > LV_VER_RES - 31) { + lv_obj_set_pos(paddle, 0, LV_VER_RES - 61); + } else { + lv_obj_set_pos(paddle, 0, y - 30); + } paddlePos = y; return true; } |