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:
parent
ebe9d69a70
commit
c6c69ba8c8
@ -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
|
||||||
@ -11,7 +11,7 @@ def digit_area(i):
|
|||||||
height = const(48)
|
height = const(48)
|
||||||
x = (i % 3) * width
|
x = (i % 3) * width
|
||||||
y = (i // 3) * height
|
y = (i // 3) * height
|
||||||
return (x, y + 48, width, height) # 48px is offset of input line
|
return (x, y + 48, width, height) # 48px is offset of input line
|
||||||
|
|
||||||
|
|
||||||
def generate_digits():
|
def generate_digits():
|
||||||
@ -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:
|
||||||
|
Loading…
Reference in New Issue
Block a user