added icons to buttons

This commit is contained in:
Peter Jensen 2017-09-26 17:05:53 +02:00
parent 808317424d
commit 027cc49f47
12 changed files with 17 additions and 10 deletions

BIN
assets/clear.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
assets/confirm.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
assets/lock.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
assets/send.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -1,10 +1,12 @@
from trezor import ui from trezor import ui, res
from trezor import wire from trezor import wire
from trezor.utils import unimport from trezor.utils import unimport
if __debug__: if __debug__:
matrix = None matrix = None
DEFAULT_CANCEL = res.load(ui.ICON_CLEAR)
DEFAULT_LOCK = res.load(ui.ICON_LOCK)
@unimport @unimport
async def request_pin_on_display(ctx: wire.Context, code: int=None) -> str: async def request_pin_on_display(ctx: wire.Context, code: int=None) -> str:
@ -26,9 +28,9 @@ async def request_pin_on_display(ctx: wire.Context, code: int=None) -> str:
def onchange(): def onchange():
c = dialog.cancel c = dialog.cancel
if matrix.pin: if matrix.pin:
c.content = 'Clean' c.content = DEFAULT_CANCEL
else: else:
c.content = 'Cancel' c.content = DEFAULT_LOCK
c.taint() c.taint()
c.render() c.render()

BIN
src/trezor/res/clear.toig Normal file

Binary file not shown.

BIN
src/trezor/res/confirm.toig Normal file

Binary file not shown.

BIN
src/trezor/res/lock.toig Normal file

Binary file not shown.

BIN
src/trezor/res/send.toig Normal file

Binary file not shown.

View File

@ -58,7 +58,7 @@ class Button(Widget):
s['border-color'], s['border-color'],
ui.BG, ui.BG,
s['radius']) s['radius'])
display.bar_radius(ax + 1, ay + 1, aw - 2, ah - 2, display.bar_radius(ax + 4, ay + 4, aw - 8, ah - 8,
s['bg-color'], s['bg-color'],
s['border-color'], s['border-color'],
s['radius']) s['radius'])
@ -70,7 +70,7 @@ class Button(Widget):
s['bg-color']) s['bg-color'])
else: else:
display.icon(ax, ay, self.content, display.icon(tx - 15, ty - 20, self.content,
s['fg-color'], s['fg-color'],
s['bg-color']) s['bg-color'])

View File

@ -1,17 +1,18 @@
from micropython import const from micropython import const
from trezor import loop from trezor import loop
from trezor import ui from trezor import ui, res
from trezor.ui import Widget from trezor.ui import Widget
from trezor.ui.button import Button, BTN_CLICKED, BTN_STARTED from trezor.ui.button import Button, BTN_CLICKED, BTN_STARTED
from trezor.ui.loader import Loader from trezor.ui.loader import Loader
CONFIRMED = const(1) CONFIRMED = const(1)
CANCELLED = const(2) CANCELLED = const(2)
DEFAULT_CONFIRM = res.load(ui.ICON_CONFIRM)
DEFAULT_CANCEL = res.load(ui.ICON_CLEAR)
class ConfirmDialog(Widget): class ConfirmDialog(Widget):
def __init__(self, content, confirm='Confirm', cancel='Cancel'): def __init__(self, content, confirm=DEFAULT_CONFIRM, cancel=DEFAULT_CANCEL):
self.content = content self.content = content
if cancel is not None: if cancel is not None:
self.confirm = Button((121, 240 - 48, 119, 48), confirm, self.confirm = Button((121, 240 - 48, 119, 48), confirm,

View File

@ -48,6 +48,10 @@ FG = WHITE
ICON_RESET = 'trezor/res/header_icons/reset.toig' ICON_RESET = 'trezor/res/header_icons/reset.toig'
ICON_WIPE = 'trezor/res/header_icons/wipe.toig' ICON_WIPE = 'trezor/res/header_icons/wipe.toig'
ICON_RECOVERY = 'trezor/res/header_icons/recovery.toig' ICON_RECOVERY = 'trezor/res/header_icons/recovery.toig'
ICON_CLEAR = 'trezor/res/clear.toig'
ICON_CONFIRM = 'trezor/res/confirm.toig'
ICON_LOCK = 'trezor/res/lock.toig'
ICON_SEND = 'trezor/res/send.toig'
# buttons # buttons
BTN_DEFAULT = { BTN_DEFAULT = {
@ -75,7 +79,7 @@ BTN_CANCEL = {
'bg-color': RED, 'bg-color': RED,
'fg-color': FG, 'fg-color': FG,
'text-style': BOLD, 'text-style': BOLD,
'border-color': RED, 'border-color': BG,
'radius': RADIUS, 'radius': RADIUS,
} }
BTN_CANCEL_ACTIVE = { BTN_CANCEL_ACTIVE = {
@ -89,7 +93,7 @@ BTN_CONFIRM = {
'bg-color': GREEN, 'bg-color': GREEN,
'fg-color': FG, 'fg-color': FG,
'text-style': BOLD, 'text-style': BOLD,
'border-color': GREEN, 'border-color': BG,
'radius': RADIUS, 'radius': RADIUS,
} }
BTN_CONFIRM_ACTIVE = { BTN_CONFIRM_ACTIVE = {