From c6ed52a7c9d8d227a1b0d289f8013f24fb7b4296 Mon Sep 17 00:00:00 2001 From: chren Date: Wed, 8 Jun 2016 16:42:54 +0200 Subject: [PATCH] added remove input line --- src/trezor/ui/pin.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/trezor/ui/pin.py b/src/trezor/ui/pin.py index 285fbd63a..28efa8edf 100644 --- a/src/trezor/ui/pin.py +++ b/src/trezor/ui/pin.py @@ -5,7 +5,6 @@ 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) @@ -25,6 +24,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.buttons = [Button(digit_area(i), str(d)) for i, d in enumerate(generate_digits())] @@ -32,10 +32,16 @@ class PinMatrix(): header = ''.join(['*' for _ in self.pin]) if self.pin else self.label + # clear canvas under input line + display.bar(48, 0, 144, 48, ui.BLACK) + # 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) + # render clear button + if self.pin: + self.clear_button.render() + # pin matrix buttons for btn in self.buttons: btn.render() @@ -49,6 +55,11 @@ class PinMatrix(): display.bar(0, 142, 240, 2, ui.blend(ui.BLACK, ui.WHITE, 0.25)) def send(self, event, pos): + if self.clear_button.send(event, pos) == BTN_CLICKED: + self.pin = '' + self.label = 'Enter PIN' + + for btn in self.buttons: if btn.send(event, pos) == BTN_CLICKED: self.pin += btn.text