mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-18 04:18:10 +00:00
ui: properly taint child components
This commit is contained in:
parent
25788e90e8
commit
9da2c9502e
@ -66,6 +66,11 @@ class HoldToConfirmDialog(Widget):
|
|||||||
self.button = Button(ui.grid(4, n_x=1), hold, style=button_style)
|
self.button = Button(ui.grid(4, n_x=1), hold, style=button_style)
|
||||||
self.loader = Loader(style=loader_style)
|
self.loader = Loader(style=loader_style)
|
||||||
|
|
||||||
|
def taint(self):
|
||||||
|
super().taint()
|
||||||
|
self.button.taint()
|
||||||
|
self.content.taint()
|
||||||
|
|
||||||
def render(self):
|
def render(self):
|
||||||
self.button.render()
|
self.button.render()
|
||||||
|
|
||||||
|
@ -5,6 +5,11 @@ class Container(Widget):
|
|||||||
def __init__(self, *children):
|
def __init__(self, *children):
|
||||||
self.children = children
|
self.children = children
|
||||||
|
|
||||||
|
def taint(self):
|
||||||
|
super().taint()
|
||||||
|
for child in self.children:
|
||||||
|
child.taint()
|
||||||
|
|
||||||
def render(self):
|
def render(self):
|
||||||
for child in self.children:
|
for child in self.children:
|
||||||
child.render()
|
child.render()
|
||||||
|
@ -14,6 +14,11 @@ class EntrySelector(Widget):
|
|||||||
self.device = Button(ui.grid(8, n_y=4, n_x=4, cells_x=4), "Device")
|
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")
|
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):
|
def render(self):
|
||||||
self.device.render()
|
self.device.render()
|
||||||
self.host.render()
|
self.host.render()
|
||||||
|
@ -89,6 +89,13 @@ class MnemonicKeyboard(ui.Widget):
|
|||||||
self.pbutton = None # pending key button
|
self.pbutton = None # pending key button
|
||||||
self.pindex = 0 # index of current pending char in pbutton
|
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):
|
def render(self):
|
||||||
if self.input.content:
|
if self.input.content:
|
||||||
# content button and backspace
|
# content button and backspace
|
||||||
|
@ -81,19 +81,15 @@ 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:
|
class Prompt(ui.Widget):
|
||||||
def __init__(self, text):
|
def __init__(self, text):
|
||||||
self.text = text
|
self.text = text
|
||||||
self.dirty = True
|
|
||||||
|
|
||||||
def taint(self):
|
|
||||||
self.dirty = True
|
|
||||||
|
|
||||||
def render(self):
|
def render(self):
|
||||||
if self.dirty:
|
if self.tainted:
|
||||||
display.bar(0, 0, ui.WIDTH, 48, ui.BG)
|
display.bar(0, 0, ui.WIDTH, 48, ui.BG)
|
||||||
display.text_center(ui.WIDTH // 2, 32, self.text, ui.BOLD, ui.GREY, 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)
|
CANCELLED = const(0)
|
||||||
@ -110,6 +106,15 @@ class PassphraseKeyboard(ui.Widget):
|
|||||||
self.pbutton = None # pending key button
|
self.pbutton = None # pending key button
|
||||||
self.pindex = 0 # index of current pending char in pbutton
|
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):
|
def render(self):
|
||||||
# passphrase or prompt
|
# passphrase or prompt
|
||||||
if self.input.content:
|
if self.input.content:
|
||||||
|
@ -34,6 +34,11 @@ class PinMatrix(ui.Widget):
|
|||||||
]
|
]
|
||||||
self.onchange = None
|
self.onchange = None
|
||||||
|
|
||||||
|
def taint(self):
|
||||||
|
super().taint()
|
||||||
|
for btn in self.pin_buttons:
|
||||||
|
btn.taint()
|
||||||
|
|
||||||
def render(self):
|
def render(self):
|
||||||
# pin matrix buttons
|
# pin matrix buttons
|
||||||
for btn in self.pin_buttons:
|
for btn in self.pin_buttons:
|
||||||
|
@ -75,6 +75,10 @@ class Scrollpage(ui.Widget):
|
|||||||
self.page = page
|
self.page = page
|
||||||
self.page_count = page_count
|
self.page_count = page_count
|
||||||
|
|
||||||
|
def taint(self):
|
||||||
|
super().taint()
|
||||||
|
self.content.taint()
|
||||||
|
|
||||||
def render(self):
|
def render(self):
|
||||||
self.content.render()
|
self.content.render()
|
||||||
render_scrollbar(self.page, self.page_count)
|
render_scrollbar(self.page, self.page_count)
|
||||||
|
@ -121,7 +121,6 @@ class Text(ui.Widget):
|
|||||||
self.max_lines = max_lines
|
self.max_lines = max_lines
|
||||||
self.new_lines = new_lines
|
self.new_lines = new_lines
|
||||||
self.content = []
|
self.content = []
|
||||||
self.tainted = True
|
|
||||||
|
|
||||||
def normal(self, *content):
|
def normal(self, *content):
|
||||||
self.content.append(ui.NORMAL)
|
self.content.append(ui.NORMAL)
|
||||||
@ -143,10 +142,13 @@ class Text(ui.Widget):
|
|||||||
self.content.append(BR)
|
self.content.append(BR)
|
||||||
|
|
||||||
def render(self):
|
def render(self):
|
||||||
if not self.tainted:
|
if self.tainted:
|
||||||
return
|
ui.header(
|
||||||
ui.header(
|
self.header_text,
|
||||||
self.header_text, self.header_icon, ui.TITLE_GREY, ui.BG, self.icon_color
|
self.header_icon,
|
||||||
)
|
ui.TITLE_GREY,
|
||||||
render_text(self.content, self.new_lines, self.max_lines)
|
ui.BG,
|
||||||
self.tainted = False
|
self.icon_color,
|
||||||
|
)
|
||||||
|
render_text(self.content, self.new_lines, self.max_lines)
|
||||||
|
self.tainted = False
|
||||||
|
@ -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
|
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):
|
def render(self):
|
||||||
self.w12.render()
|
self.w12.render()
|
||||||
self.w18.render()
|
self.w18.render()
|
||||||
|
Loading…
Reference in New Issue
Block a user