diff options
| author | Aidan Houlihan <aidandhoulihan@gmail.com> | 2020-10-31 20:51:28 (GMT) |
|---|---|---|
| committer | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-11-29 09:12:03 (GMT) |
| commit | 393dfefc86be9b0fe518d4a1421fe642ada9b75e (patch) | |
| tree | fb2f800eeacf7bd2f02adf616355d4e8011ab51e /wasp/widgets.py | |
| parent | 4c0120aa1ea93a280824e96e9221b8dbee82121f (diff) | |
apps: pager: notifications: Added remove all notifications dialog
Signed-off-by: Aidan Houlihan <aidandhoulihan@gmail.com>
[daniel@redfelineninja.org.uk: Minor changes to .gitignore]
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Diffstat (limited to 'wasp/widgets.py')
| -rw-r--r-- | wasp/widgets.py | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/wasp/widgets.py b/wasp/widgets.py index f064c69..39d8b19 100644 --- a/wasp/widgets.py +++ b/wasp/widgets.py @@ -286,3 +286,76 @@ class Slider(): elif v >= self._steps: v = self._steps - 1 self.value = v + + +_message_string_x_coord = const(0) +_message_string_y_coord = const(60) +_yes_button_x_coord = const(20) +_yes_button_y_coord = const(100) +_no_button_x_coord = const(120) +_no_button_y_coord = const(100) + +class ConfirmationView: + "Confirmation widget allowing user confirmation of a setting" + + def __init__(self): + self.active = False + + self.yes_button_bounds = ( + (_yes_button_x_coord, _yes_button_y_coord), + ( + icons.yes_button[0] + _yes_button_x_coord, + icons.yes_button[1] + _yes_button_y_coord, + ), + ) + self.no_button_bounds = ( + (_no_button_x_coord, _no_button_y_coord), + ( + icons.no_button[0] + _no_button_x_coord, + icons.no_button[1] + _no_button_y_coord, + ) + ) + + def draw(self, message): + wasp.watch.drawable.fill(1) + wasp.watch.drawable.string( + message, + _message_string_x_coord, + _message_string_y_coord + ) + wasp.watch.drawable.blit( + icons.yes_button, + _yes_button_x_coord, + _yes_button_y_coord, + ) + wasp.watch.drawable.blit( + icons.no_button, + _no_button_x_coord, + _no_button_y_coord, + ) + self.active = True + + + def touch(self, event): + x_coord = event[1] + y_coord = event[2] + is_yes_button_press = ( + x_coord > self.yes_button_bounds[0][0] + and y_coord > self.yes_button_bounds[0][1] + and x_coord < self.yes_button_bounds[1][0] + and y_coord < self.yes_button_bounds[1][1] + ) + + is_no_button_press = ( + x_coord > self.no_button_bounds[0][0] + and y_coord > self.no_button_bounds[0][1] + and x_coord < self.no_button_bounds[1][0] + and y_coord < self.no_button_bounds[1][1] + ) + + if is_yes_button_press: + return True + elif is_no_button_press: + return False + else: + return None |
