1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 07:28:10 +00:00

added clear input pin button

This commit is contained in:
chren 2016-06-08 18:06:10 +02:00 committed by Pavol Rusnak
parent c6ed52a7c9
commit 1e4556d736
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
5 changed files with 27 additions and 6 deletions

BIN
assets/close-button.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
assets/close-button.toig Normal file

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +1,5 @@
from . import display, in_area, rotate_coords
from trezor import ui, loop
from trezor import ui, loop, res
DEFAULT_BUTTON = {
@ -41,6 +41,19 @@ CONFIRM_BUTTON_ACTIVE = {
'border-color': ui.GREEN,
}
CLEAR_BUTTON = {
'bg-color': ui.BLACK,
'fg-color': ui.WHITE,
'text-style': ui.NORMAL,
'border-color': ui.BLACK,
}
CLEAR_BUTTON_ACTIVE = {
'bg-color': ui.BLACK,
'fg-color': ui.WHITE,
'text-style': ui.NORMAL,
'border-color': ui.BLACK,
}
BTN_CLICKED = const(1)
BTN_STARTED = const(1)
@ -68,10 +81,16 @@ class Button():
ty = ay + ah // 2 + 8
display.bar(ax, ay, aw, ah, style['border-color'])
display.bar(ax + 1, ay + 1, aw - 2, ah - 2, style['bg-color'])
display.text_center(tx, ty, self.text,
style['text-style'],
style['fg-color'],
style['bg-color'])
# How to do this smarter way?
if self.text == 'CLEAR':
ui.display.icon(ax, ay, res.load('trezor/res/close-button.toig'),
ui.blend(ui.BLACK, ui.WHITE, 0.95),
ui.BLACK)
else:
display.text_center(tx, ty, self.text,
style['text-style'],
style['fg-color'],
style['bg-color'])
self.state = state
def send(self, event, pos):

View File

@ -5,6 +5,7 @@ from .button import Button, BTN_CLICKED
from .button import CONFIRM_BUTTON, CONFIRM_BUTTON_ACTIVE
from .button import CANCEL_BUTTON, CANCEL_BUTTON_ACTIVE
def digit_area(i):
width = const(80)
height = const(48)
@ -24,7 +25,7 @@ class PinMatrix():
def __init__(self, label='Enter PIN', pin=''):
self.label = label
self.pin = pin
self.clear_button = Button((240 - 48, 0, 48, 42), 'X')
self.clear_button = Button((240 - 35, 5, 30, 30), 'CLEAR')
self.buttons = [Button(digit_area(i), str(d))
for i, d in enumerate(generate_digits())]
@ -58,6 +59,7 @@ class PinMatrix():
if self.clear_button.send(event, pos) == BTN_CLICKED:
self.pin = ''
self.label = 'Enter PIN'
display.bar(240 - 48, 0, 48, 42, ui.BLACK)
for btn in self.buttons: