mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 07:28:10 +00:00
ui/mnemonic: small refactor in input's edit
This commit is contained in:
parent
40d55dfe8b
commit
906013a6d7
@ -27,8 +27,8 @@ class InputButton(Button):
|
|||||||
def __init__(self, area, content, word):
|
def __init__(self, area, content, word):
|
||||||
super().__init__(area, content)
|
super().__init__(area, content)
|
||||||
self.word = word
|
self.word = word
|
||||||
self.pending = False
|
self.pending = False # should we draw the pending marker?
|
||||||
self.icon = None
|
self.icon = None # rendered icon
|
||||||
self.disable()
|
self.disable()
|
||||||
|
|
||||||
def edit(self, content, word, pending):
|
def edit(self, content, word, pending):
|
||||||
@ -57,28 +57,25 @@ class InputButton(Button):
|
|||||||
fg_color = s.fg_color
|
fg_color = s.fg_color
|
||||||
bg_color = s.bg_color
|
bg_color = s.bg_color
|
||||||
|
|
||||||
p = self.pending # should we draw the pending marker?
|
|
||||||
t = self.content # input content
|
|
||||||
w = self.word[len(t) :] # suggested word
|
|
||||||
i = self.icon # rendered icon
|
|
||||||
|
|
||||||
tx = ax + 24 # x-offset of the content
|
tx = ax + 24 # x-offset of the content
|
||||||
ty = ay + ah // 2 + 8 # y-offset of the content
|
ty = ay + ah // 2 + 8 # y-offset of the content
|
||||||
|
|
||||||
# input content and the suggested word
|
# entered content
|
||||||
display.text(tx, ty, t, text_style, fg_color, bg_color)
|
display.text(tx, ty, self.content, text_style, fg_color, bg_color)
|
||||||
width = display.text_width(t, text_style)
|
# word suggestion
|
||||||
display.text(tx + width, ty, w, text_style, ui.GREY, bg_color)
|
suggested_word = self.word[len(self.content) :]
|
||||||
|
width = display.text_width(self.content, text_style)
|
||||||
|
display.text(tx + width, ty, suggested_word, text_style, ui.GREY, bg_color)
|
||||||
|
|
||||||
if p: # pending marker
|
if self.pending:
|
||||||
pw = display.text_width(t[-1:], text_style)
|
pw = display.text_width(self.content[-1:], text_style)
|
||||||
px = tx + width - pw
|
px = tx + width - pw
|
||||||
display.bar(px, ty + 2, pw + 1, 3, fg_color)
|
display.bar(px, ty + 2, pw + 1, 3, fg_color)
|
||||||
|
|
||||||
if i: # icon
|
if self.icon:
|
||||||
ix = ax + aw - 16 * 2
|
ix = ax + aw - 16 * 2
|
||||||
iy = ty - 16
|
iy = ty - 16
|
||||||
display.icon(ix, iy, res.load(i), fg_color, bg_color)
|
display.icon(ix, iy, res.load(self.icon), fg_color, bg_color)
|
||||||
|
|
||||||
|
|
||||||
class Prompt(ui.Control):
|
class Prompt(ui.Control):
|
||||||
|
Loading…
Reference in New Issue
Block a user