1
0
Fork 0

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>
This commit is contained in:
Daniel Thompson 2021-01-10 10:34:37 +00:00
parent b6b30238c6
commit ed242b84a6
7 changed files with 26 additions and 83 deletions

View file

@ -39,7 +39,7 @@ Wasp-os
* [ ] Update icon for Music player
* [ ] Introduce fwd/back/vol+/vol- buttons to the music player
* [X] Update icon for Alarm app
* [ ] Update art work for buttons in Confirmation view
* [X] Update art work for buttons in Confirmation view
* [X] Reduce the size of the battery charge icon slightly (match bell)
* [ ] Widgets

Binary file not shown.

Before

Width:  |  Height:  |  Size: 454 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 500 B

View file

@ -36,8 +36,6 @@ class PagerApp():
def swipe(self, event):
"""Swipe to page up/down."""
mute = wasp.watch.display.mute
if event[0] == wasp.EventType.UP:
if self._page >= self._numpages:
wasp.system.navigate(wasp.EventType.BACK)
@ -48,9 +46,7 @@ class PagerApp():
wasp.watch.vibrator.pulse()
return
self._page -= 1
mute(True)
self._draw()
mute(False)
def _redraw(self):
"""Redraw from scratch (jump to the first page)"""
@ -61,7 +57,11 @@ class PagerApp():
def _draw(self):
"""Draw a page from scratch."""
mute = wasp.watch.display.mute
draw = wasp.watch.drawable
mute(True)
draw.set_color(0xffff)
draw.fill()
page = self._page
@ -77,6 +77,8 @@ class PagerApp():
scroll.down = page < self._numpages
scroll.draw()
mute(False)
class NotificationApp(PagerApp):
NAME = 'Notifications'

View file

@ -11,5 +11,3 @@ settings = 'Default settings icon'
torch = 'Default torch or flashlight icon'
up_arrow = 'Small (16x9) up arrow'
down_arrow = 'Small (16x9) down arrow'
yes_button = b'Yes button'
no_button = b'No button'

View file

@ -286,73 +286,6 @@ pause = (
b'&\xe0)\xdd-\xda1\xd47\xce?\xff\x8f'
)
# 2-bit RLE, generated from res/yes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c5#\xc5\x08\xc1\x03\xc1\x12\xc5\x0f\xc5#\xc5\x08'
b'\xc1\x03\xc1\x12\xc5\x0f\xc5#\xc5\x08\xc1\x03\xc1\x12\xc5\x0f'
b'\xd4\x05\xcf\r\xc1\x03\xc1\x12\xc5\x0f\xd4\x05\xcf\r\xc1\x03'
b'\xc1\x12\xc5\x0f\xd4\x05\xcf\r\xc1\x03\xc1\x12\xc5\x0f\xd4\x05'
b'\xcf\r\xc1\x03\xc1\x12\xc5\x0f\xd4\x05\xcf\r\xc1\x03\xc1?'
b'\x1c\xc1\x03\xc1?\x1c\xc1\x03\xc1?\x1c\xc1\x03\xc1?\x1c'
b'\xc1\x03\xc1?\x1c\xc1\x03\xc1?\x1c\xc1\x03\xc1?\x1c\xc1'
b'\x03\xc1?\x1c\xc1\x03\xc1?\x1c\xc1\x03\xc1?\x1c\xc1\x03'
b'\xc1?\x1c\xc1\x03\xc1?\x1c\xc1\x03\xc1?\x1c\xc1\x03\xc1'
b'?\x1c\xc1\x03\xc1?\x1c\xc1\x03\xff\x1e?\x83'
)
# 2-bit RLE, generated from res/no_button.png, 442 bytes
no_button = (
b'\x02'
b'`<'
b'?"\xff\x1e\x03\xc1?\x1c\xc1\x03\xc1?\x1c\xc1\x03\xc1'
b'?\x1c\xc1\x03\xc1?\x1c\xc1\x03\xc1?\x1c\xc1\x03\xc1?'
b'\x1c\xc1\x03\xc1?\x1c\xc1\x03\xc1?\x1c\xc1\x03\xc1?\x1c'
b'\xc1\x03\xc1?\x1c\xc1\x03\xc1?\x1c\xc1\x03\xc1?\x1c\xc1'
b'\x03\xc1?\x1c\xc1\x03\xc1?\x1c\xc1\x03\xc1\x16\xc5\n\xc5'
b'\n\xca\x1d\xc1\x03\xc1\x16\xc5\n\xc5\n\xca\x1d\xc1\x03\xc1'
b'\x16\xc5\n\xc5\n\xca\x1d\xc1\x03\xc1\x16\xc5\n\xc5\n\xca'
b'\x1d\xc1\x03\xc1\x16\xc5\n\xc5\n\xca\x1d\xc1\x03\xc1\x16\xca'
b'\x05\xc5\x05\xc5\n\xc5\x18\xc1\x03\xc1\x16\xca\x05\xc5\x05\xc5'
b'\n\xc5\x18\xc1\x03\xc1\x16\xca\x05\xc5\x05\xc5\n\xc5\x18\xc1'
b'\x03\xc1\x16\xca\x05\xc5\x05\xc5\n\xc5\x18\xc1\x03\xc1\x16\xca'
b'\x05\xc5\x05\xc5\n\xc5\x18\xc1\x03\xc1\x16\xc5\x05\xca\x05\xc5'
b'\n\xc5\x18\xc1\x03\xc1\x16\xc5\x05\xca\x05\xc5\n\xc5\x18\xc1'
b'\x03\xc1\x16\xc5\x05\xca\x05\xc5\n\xc5\x18\xc1\x03\xc1\x16\xc5'
b'\x05\xca\x05\xc5\n\xc5\x18\xc1\x03\xc1\x16\xc5\x05\xca\x05\xc5'
b'\n\xc5\x18\xc1\x03\xc1\x16\xc5\n\xc5\x05\xc5\n\xc5\x18\xc1'
b'\x03\xc1\x16\xc5\n\xc5\x05\xc5\n\xc5\x18\xc1\x03\xc1\x16\xc5'
b'\n\xc5\x05\xc5\n\xc5\x18\xc1\x03\xc1\x16\xc5\n\xc5\x05\xc5'
b'\n\xc5\x18\xc1\x03\xc1\x16\xc5\n\xc5\x05\xc5\n\xc5\x18\xc1'
b'\x03\xc1\x16\xc5\n\xc5\n\xca\x1d\xc1\x03\xc1\x16\xc5\n\xc5'
b'\n\xca\x1d\xc1\x03\xc1\x16\xc5\n\xc5\n\xca\x1d\xc1\x03\xc1'
b'\x16\xc5\n\xc5\n\xca\x1d\xc1\x03\xc1\x16\xc5\n\xc5\n\xca'
b'\x1d\xc1\x03\xc1?\x1c\xc1\x03\xc1?\x1c\xc1\x03\xc1?\x1c'
b'\xc1\x03\xc1?\x1c\xc1\x03\xc1?\x1c\xc1\x03\xc1?\x1c\xc1'
b'\x03\xc1?\x1c\xc1\x03\xc1?\x1c\xc1\x03\xc1?\x1c\xc1\x03'
b'\xc1?\x1c\xc1\x03\xc1?\x1c\xc1\x03\xc1?\x1c\xc1\x03\xc1'
b'?\x1c\xc1\x03\xc1?\x1c\xc1\x03\xc1?\x1c\xc1\x03\xc1?'
b'\x1c\xc1\x03\xff\x1e?\x83'
)
# 2-bit RLE, generated from res/checkbox.png, 108 bytes
checkbox = (
b'\x02'

View file

@ -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 = x < 120
self.value = True
return True
elif self._no.touch(event):
self.active = False
self.value = False
return True
return False