1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-06-23 16:38:46 +00:00

fix ui in PinMatrix

This commit is contained in:
Jan Pochyla 2016-06-08 14:59:38 +02:00 committed by Pavol Rusnak
parent ebe9d69a70
commit c6c69ba8c8
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

View File

@ -1,4 +1,4 @@
from . import display from . import display, clear
from trezor import ui, loop from trezor import ui, loop
from trezor.crypto import random from trezor.crypto import random
from .button import Button, BTN_CLICKED from .button import Button, BTN_CLICKED
@ -22,17 +22,25 @@ def generate_digits():
class PinMatrix(): class PinMatrix():
def __init__(self, pin=''): def __init__(self, label='Enter PIN', pin=''):
self.label = label
self.pin = pin self.pin = pin
self.buttons = [Button(digit_area(i), str(d)) self.buttons = [Button(digit_area(i), str(d))
for i, d in enumerate(generate_digits())] for i, d in enumerate(generate_digits())]
def render(self): def render(self):
# input line with placeholder (x, y, text, style, fg-c, bg-c) header = ''.join(['*' for _ in self.pin]) if self.pin else self.label
display.text_center(120, 30, 'Enter PIN', ui.BOLD, ui.GREY, ui.BLACK)
# vertical border bars (x, y, w, h, c) # input line with a header
display.bar(0, 0, 240, 48, ui.BLACK)
display.text_center(120, 30, header, ui.BOLD, ui.GREY, ui.BLACK)
# pin matrix buttons
for btn in self.buttons:
btn.render()
# vertical border bars
display.bar(79, 48, 2, 143, ui.blend(ui.BLACK, ui.WHITE, 0.25)) display.bar(79, 48, 2, 143, ui.blend(ui.BLACK, ui.WHITE, 0.25))
display.bar(158, 48, 2, 143, ui.blend(ui.BLACK, ui.WHITE, 0.25)) display.bar(158, 48, 2, 143, ui.blend(ui.BLACK, ui.WHITE, 0.25))
@ -40,10 +48,6 @@ class PinMatrix():
display.bar(0, 95, 240, 2, ui.blend(ui.BLACK, ui.WHITE, 0.25)) display.bar(0, 95, 240, 2, ui.blend(ui.BLACK, ui.WHITE, 0.25))
display.bar(0, 142, 240, 2, ui.blend(ui.BLACK, ui.WHITE, 0.25)) display.bar(0, 142, 240, 2, ui.blend(ui.BLACK, ui.WHITE, 0.25))
# pin matrix buttons
for btn in self.buttons:
btn.render()
def send(self, event, pos): def send(self, event, pos):
for btn in self.buttons: for btn in self.buttons:
if btn.send(event, pos) == BTN_CLICKED: if btn.send(event, pos) == BTN_CLICKED: