diff --git a/src/trezor/ui/confirm.py b/src/trezor/ui/confirm.py index 9bdc30a28..8899e48e5 100644 --- a/src/trezor/ui/confirm.py +++ b/src/trezor/ui/confirm.py @@ -66,6 +66,11 @@ class HoldToConfirmDialog(Widget): self.button = Button(ui.grid(4, n_x=1), hold, style=button_style) self.loader = Loader(style=loader_style) + def taint(self): + super().taint() + self.button.taint() + self.content.taint() + def render(self): self.button.render() diff --git a/src/trezor/ui/container.py b/src/trezor/ui/container.py index 7ebf462ba..64c0ea860 100644 --- a/src/trezor/ui/container.py +++ b/src/trezor/ui/container.py @@ -5,6 +5,11 @@ class Container(Widget): def __init__(self, *children): self.children = children + def taint(self): + super().taint() + for child in self.children: + child.taint() + def render(self): for child in self.children: child.render() diff --git a/src/trezor/ui/entry_select.py b/src/trezor/ui/entry_select.py index 33dbdca3b..7d1e4a5b6 100644 --- a/src/trezor/ui/entry_select.py +++ b/src/trezor/ui/entry_select.py @@ -14,6 +14,11 @@ class EntrySelector(Widget): self.device = Button(ui.grid(8, n_y=4, n_x=4, cells_x=4), "Device") self.host = Button(ui.grid(12, n_y=4, n_x=4, cells_x=4), "Host") + def taint(self): + super().taint() + self.device.taint() + self.host.taint() + def render(self): self.device.render() self.host.render() diff --git a/src/trezor/ui/mnemonic.py b/src/trezor/ui/mnemonic.py index 75d830e70..22cfe2d69 100644 --- a/src/trezor/ui/mnemonic.py +++ b/src/trezor/ui/mnemonic.py @@ -89,6 +89,13 @@ class MnemonicKeyboard(ui.Widget): self.pbutton = None # pending key button self.pindex = 0 # index of current pending char in pbutton + def taint(self): + super().taint() + self.input.taint() + self.back.taint() + for btn in self.keys: + btn.taint() + def render(self): if self.input.content: # content button and backspace diff --git a/src/trezor/ui/passphrase.py b/src/trezor/ui/passphrase.py index 340b3b406..4d38f6137 100644 --- a/src/trezor/ui/passphrase.py +++ b/src/trezor/ui/passphrase.py @@ -81,19 +81,15 @@ class Input(Button): display.bar(tx + width + 1, ty - 18, 2, 22, fg_color) -class Prompt: +class Prompt(ui.Widget): def __init__(self, text): self.text = text - self.dirty = True - - def taint(self): - self.dirty = True def render(self): - if self.dirty: + if self.tainted: display.bar(0, 0, ui.WIDTH, 48, ui.BG) display.text_center(ui.WIDTH // 2, 32, self.text, ui.BOLD, ui.GREY, ui.BG) - self.dirty = False + self.tainted = False CANCELLED = const(0) @@ -110,6 +106,15 @@ class PassphraseKeyboard(ui.Widget): self.pbutton = None # pending key button self.pindex = 0 # index of current pending char in pbutton + def taint(self): + super().taint() + self.prompt.taint() + self.input.taint() + self.back.taint() + self.done.taint() + for btn in self.keys: + btn.taint() + def render(self): # passphrase or prompt if self.input.content: diff --git a/src/trezor/ui/pin.py b/src/trezor/ui/pin.py index 38b8b9090..00bf61029 100644 --- a/src/trezor/ui/pin.py +++ b/src/trezor/ui/pin.py @@ -34,6 +34,11 @@ class PinMatrix(ui.Widget): ] self.onchange = None + def taint(self): + super().taint() + for btn in self.pin_buttons: + btn.taint() + def render(self): # pin matrix buttons for btn in self.pin_buttons: diff --git a/src/trezor/ui/scroll.py b/src/trezor/ui/scroll.py index 3ca494db5..115079b04 100644 --- a/src/trezor/ui/scroll.py +++ b/src/trezor/ui/scroll.py @@ -75,6 +75,10 @@ class Scrollpage(ui.Widget): self.page = page self.page_count = page_count + def taint(self): + super().taint() + self.content.taint() + def render(self): self.content.render() render_scrollbar(self.page, self.page_count) diff --git a/src/trezor/ui/text.py b/src/trezor/ui/text.py index f57056528..12ad405b6 100644 --- a/src/trezor/ui/text.py +++ b/src/trezor/ui/text.py @@ -121,7 +121,6 @@ class Text(ui.Widget): self.max_lines = max_lines self.new_lines = new_lines self.content = [] - self.tainted = True def normal(self, *content): self.content.append(ui.NORMAL) @@ -143,10 +142,13 @@ class Text(ui.Widget): self.content.append(BR) def render(self): - if not self.tainted: - return - ui.header( - self.header_text, self.header_icon, ui.TITLE_GREY, ui.BG, self.icon_color - ) - render_text(self.content, self.new_lines, self.max_lines) - self.tainted = False + if self.tainted: + ui.header( + self.header_text, + self.header_icon, + ui.TITLE_GREY, + ui.BG, + self.icon_color, + ) + render_text(self.content, self.new_lines, self.max_lines) + self.tainted = False diff --git a/src/trezor/ui/word_select.py b/src/trezor/ui/word_select.py index 995f4ba71..67db8d124 100644 --- a/src/trezor/ui/word_select.py +++ b/src/trezor/ui/word_select.py @@ -26,6 +26,12 @@ class WordSelector(Widget): ui.grid(8, n_y=4, n_x=3, cells_y=2), str(_W24), style=ui.BTN_KEY ) + def taint(self): + super().taint() + self.w12.taint() + self.w18.taint() + self.w24.taint() + def render(self): self.w12.render() self.w18.render()