1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-16 19:38:09 +00:00

src/trezor/ui/passphrase: fix rendering invalidation

This commit is contained in:
Jan Pochyla 2018-02-27 21:49:18 +01:00
parent 2523442eb3
commit 20ca86229c

View File

@ -79,12 +79,27 @@ class Input(Button):
display.bar(tx + width + 1, ty - 18, 2, 22, fg_color) display.bar(tx + width + 1, ty - 18, 2, 22, fg_color)
class Prompt:
def __init__(self, text):
self.text = text
self.dirty = True
def taint(self):
self.dirty = True
def render(self):
if self.dirty:
display.bar(0, 0, 240, 48, ui.BG)
display.text_center(ui.WIDTH // 2, 32, self.text, ui.BOLD, ui.GREY, ui.BG)
self.dirty = False
CANCELLED = const(0) CANCELLED = const(0)
class PassphraseKeyboard(ui.Widget): class PassphraseKeyboard(ui.Widget):
def __init__(self, prompt, page=1): def __init__(self, prompt, page=1):
self.prompt = prompt self.prompt = Prompt(prompt)
self.page = page self.page = page
self.input = Input(ui.grid(0, n_x=1, n_y=6), '') self.input = Input(ui.grid(0, n_x=1, n_y=6), '')
self.back = Button(ui.grid(12), res.load(ui.ICON_BACK), style=ui.BTN_CLEAR) self.back = Button(ui.grid(12), res.load(ui.ICON_BACK), style=ui.BTN_CLEAR)
@ -98,8 +113,7 @@ class PassphraseKeyboard(ui.Widget):
if self.input.content: if self.input.content:
self.input.render() self.input.render()
else: else:
display.bar(0, 0, 240, 48, ui.BG) self.prompt.render()
display.text_center(ui.WIDTH // 2, 32, self.prompt, ui.BOLD, ui.GREY, ui.BG)
render_scrollbar(self.page) render_scrollbar(self.page)
# buttons # buttons
self.back.render() self.back.render()
@ -191,3 +205,5 @@ class PassphraseKeyboard(ui.Widget):
self.keys = key_buttons(KEYBOARD_KEYS[self.page]) self.keys = key_buttons(KEYBOARD_KEYS[self.page])
self.back.taint() self.back.taint()
self.done.taint() self.done.taint()
self.input.taint()
self.prompt.taint()