diff options
| author | Daniel Thompson <daniel@redfelineninja.org.uk> | 2021-01-10 10:34:37 (GMT) |
|---|---|---|
| committer | Daniel Thompson <daniel@redfelineninja.org.uk> | 2021-01-10 10:34:37 (GMT) |
| commit | ed242b84a6e70aff344669559c038348c822413a (patch) | |
| tree | b5b8857e5e84ef1a551444ee5be088eb9c496748 /wasp/widgets.py | |
| parent | b6b30238c6f714986f6b5a54a79bdb5672b534c1 (diff) | |
widgets: ConfirmationView: Adopt the button widget
Replace the pixelated Yes/No buttons with text based alternatives.
This also required changes to the pager to change the way the
redraw after changing view is implemented (improved muting and a reset
of the colours).
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Diffstat (limited to 'wasp/widgets.py')
| -rw-r--r-- | wasp/widgets.py | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/wasp/widgets.py b/wasp/widgets.py index 0fa4a61..e3019bb 100644 --- a/wasp/widgets.py +++ b/wasp/widgets.py @@ -430,24 +430,34 @@ class ConfirmationView: def __init__(self): self.active = False self.value = False + self._yes = Button(20, 140, 90, 45, 'Yes') + self._no = Button(130, 140, 90, 45, 'No') def draw(self, message): + draw = wasp.watch.drawable + mute = wasp.watch.display.mute + + mute(True) + draw.set_color(wasp.system.theme('bright')) + draw.fill() + draw.string(message, 0, 60) + self._yes.draw() + self._no.draw() + mute(False) + self.active = True - wasp.watch.drawable.fill(1) - wasp.watch.drawable.string(message, 0, 60) - wasp.watch.drawable.blit(icons.yes_button, 20, 100) - wasp.watch.drawable.blit(icons.no_button, 120, 100) def touch(self, event): if not self.active: return False - x = event[1] - y = event[2] - - if y >= 80 and y < 180: + if self._yes.touch(event): + self.active = False + self.value = True + return True + elif self._no.touch(event): self.active = False - self.value = x < 120 + self.value = False return True return False |
