kivy: use Clock to improve button responsiveness
This commit is contained in:
parent
0b1561f447
commit
3568c325ea
|
@ -3,6 +3,8 @@
|
||||||
#:import _ electrum.i18n._
|
#:import _ electrum.i18n._
|
||||||
|
|
||||||
# Custom Global Widgets
|
# Custom Global Widgets
|
||||||
|
<Button>
|
||||||
|
on_parent: self.MIN_STATE_TIME = 0.1
|
||||||
|
|
||||||
<VGridLayout@GridLayout>:
|
<VGridLayout@GridLayout>:
|
||||||
rows: 1
|
rows: 1
|
||||||
|
@ -219,6 +221,12 @@
|
||||||
height: '40dp'
|
height: '40dp'
|
||||||
text_color: self.foreground_color
|
text_color: self.foreground_color
|
||||||
foreground_color: 1, 0, 0, 1
|
foreground_color: 1, 0, 0, 1
|
||||||
|
canvas.before:
|
||||||
|
Color:
|
||||||
|
rgba: (0.9, .498, 0.745, 1) if self.state == 'down' else self.background_color
|
||||||
|
Rectangle:
|
||||||
|
size: self.size
|
||||||
|
pos: self.pos
|
||||||
|
|
||||||
|
|
||||||
<TextInputBlue@TextInput>
|
<TextInputBlue@TextInput>
|
||||||
|
@ -251,12 +259,12 @@
|
||||||
carousel: carousel
|
carousel: carousel
|
||||||
do_default_tab: False
|
do_default_tab: False
|
||||||
Carousel:
|
Carousel:
|
||||||
scroll_timeout: 190
|
scroll_timeout: 250
|
||||||
|
scroll_distance: '20dp'
|
||||||
anim_type: 'out_quart'
|
anim_type: 'out_quart'
|
||||||
min_move: .05
|
min_move: .05
|
||||||
anim_move_duration: .1
|
anim_move_duration: .1
|
||||||
anim_cancel_duration: .54
|
anim_cancel_duration: .54
|
||||||
scroll_distance: '10dp'
|
|
||||||
on_index: root.on_index(*args)
|
on_index: root.on_index(*args)
|
||||||
id: carousel
|
id: carousel
|
||||||
|
|
||||||
|
|
|
@ -731,16 +731,13 @@ class ElectrumWindow(App):
|
||||||
d = LabelDialog(_('Enter description'), text, callback)
|
d = LabelDialog(_('Enter description'), text, callback)
|
||||||
d.open()
|
d.open()
|
||||||
|
|
||||||
|
@profiler
|
||||||
def amount_dialog(self, screen, show_max):
|
def amount_dialog(self, screen, show_max):
|
||||||
from uix.dialogs.amount_dialog import AmountDialog
|
from uix.dialogs.amount_dialog import AmountDialog
|
||||||
amount = screen.amount
|
amount = screen.amount
|
||||||
if amount:
|
if amount:
|
||||||
amount, u = str(amount).split()
|
amount, u = str(amount).split()
|
||||||
assert u == self.base_unit
|
assert u == self.base_unit
|
||||||
else:
|
|
||||||
amount = None
|
|
||||||
|
|
||||||
def cb(amount):
|
def cb(amount):
|
||||||
screen.amount = amount
|
screen.amount = amount
|
||||||
popup = AmountDialog(show_max, amount, cb)
|
popup = AmountDialog(show_max, amount, cb)
|
||||||
|
|
|
@ -6,6 +6,7 @@ from kivy.animation import Animation
|
||||||
from kivy.uix.floatlayout import FloatLayout
|
from kivy.uix.floatlayout import FloatLayout
|
||||||
from kivy.lang import Builder
|
from kivy.lang import Builder
|
||||||
from kivy.factory import Factory
|
from kivy.factory import Factory
|
||||||
|
from kivy.clock import Clock
|
||||||
|
|
||||||
Builder.load_string('''
|
Builder.load_string('''
|
||||||
<MenuItem@Button>
|
<MenuItem@Button>
|
||||||
|
@ -33,6 +34,7 @@ class MenuItem(Factory.Button):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class ContextMenu(Bubble):
|
class ContextMenu(Bubble):
|
||||||
|
|
||||||
def __init__(self, obj, action_list):
|
def __init__(self, obj, action_list):
|
||||||
Bubble.__init__(self)
|
Bubble.__init__(self)
|
||||||
self.obj = obj
|
self.obj = obj
|
||||||
|
@ -40,7 +42,11 @@ class ContextMenu(Bubble):
|
||||||
l = MenuItem()
|
l = MenuItem()
|
||||||
l.text = k
|
l.text = k
|
||||||
def func(f=v):
|
def func(f=v):
|
||||||
f(obj)
|
Clock.schedule_once(lambda dt: self.hide(), 0.1)
|
||||||
if self.parent: self.parent.hide_menu()
|
Clock.schedule_once(lambda dt: f(obj), 0.15)
|
||||||
l.on_release = func
|
l.on_release = func
|
||||||
self.ids.buttons.add_widget(l)
|
self.ids.buttons.add_widget(l)
|
||||||
|
|
||||||
|
def hide(self):
|
||||||
|
if self.parent:
|
||||||
|
self.parent.hide_menu()
|
||||||
|
|
|
@ -225,6 +225,9 @@ class SendScreen(CScreen):
|
||||||
self.screen.address = ''
|
self.screen.address = ''
|
||||||
self.payment_request = None
|
self.payment_request = None
|
||||||
|
|
||||||
|
def amount_dialog(self):
|
||||||
|
Clock.schedule_once(lambda dt: self.app.amount_dialog(self, True), .25)
|
||||||
|
|
||||||
def set_request(self, pr):
|
def set_request(self, pr):
|
||||||
self.payment_request = pr
|
self.payment_request = pr
|
||||||
self.screen.address = pr.get_requestor()
|
self.screen.address = pr.get_requestor()
|
||||||
|
|
|
@ -53,7 +53,7 @@ SendScreen:
|
||||||
id: amount_e
|
id: amount_e
|
||||||
default_text: _('Amount')
|
default_text: _('Amount')
|
||||||
text: s.amount if s.amount else _('Amount')
|
text: s.amount if s.amount else _('Amount')
|
||||||
on_release: app.amount_dialog(s, True)
|
on_release: s.amount_dialog()
|
||||||
CardSeparator:
|
CardSeparator:
|
||||||
opacity: message_selection.opacity
|
opacity: message_selection.opacity
|
||||||
color: blue_bottom.foreground_color
|
color: blue_bottom.foreground_color
|
||||||
|
|
Loading…
Reference in New Issue