1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-14 03:30:02 +00:00

ui.text: code style, add color support

This commit is contained in:
Jan Pochyla 2016-10-20 15:06:40 +02:00
parent 7a518e9fa4
commit d94dd32816

View File

@ -8,23 +8,27 @@ TEXT_MARGIN_LEFT = const(10)
class Text:
def __init__(self, header, icon, *content):
self.header = header
self.icon = icon
def __init__(self, header_text, header_icon, *content):
self.header_text = header_text
self.header_icon = header_icon
self.content = content
def render(self):
offset = TEXT_LINE_HEIGHT
offset += TEXT_HEADER_HEIGHT
offset_x = TEXT_MARGIN_LEFT
offset_y = TEXT_LINE_HEIGHT + TEXT_HEADER_HEIGHT
style = ui.NORMAL
ui.header(self.header, self.icon, ui.BLACK, ui.LIGHT_GREEN)
fg = ui.WHITE
bg = ui.BLACK
ui.header(self.header_text, self.header_icon, ui.BLACK, ui.LIGHT_GREEN)
for item in self.content:
if isinstance(item, str):
ui.display.text(TEXT_MARGIN_LEFT, offset,
item, style, ui.WHITE, ui.BLACK)
offset += TEXT_LINE_HEIGHT
else:
ui.display.text(offset_x, offset_y, item, style, fg, bg)
offset_y += TEXT_LINE_HEIGHT
elif item == ui.MONO or item == ui.NORMAL or item == ui.BOLD:
style = item
else:
fg = item
def send(self, event, pos):
pass