Browse Source

kivy: use Clock to improve button responsiveness

283
ThomasV 9 years ago
parent
commit
3568c325ea
  1. 12
      gui/kivy/main.kv
  2. 5
      gui/kivy/main_window.py
  3. 10
      gui/kivy/uix/context_menu.py
  4. 3
      gui/kivy/uix/screens.py
  5. 2
      gui/kivy/uix/ui_screens/send.kv

12
gui/kivy/main.kv

@ -3,6 +3,8 @@
#:import _ electrum.i18n._
# Custom Global Widgets
<Button>
on_parent: self.MIN_STATE_TIME = 0.1
<VGridLayout@GridLayout>:
rows: 1
@ -219,6 +221,12 @@
height: '40dp'
text_color: self.foreground_color
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>
@ -251,12 +259,12 @@
carousel: carousel
do_default_tab: False
Carousel:
scroll_timeout: 190
scroll_timeout: 250
scroll_distance: '20dp'
anim_type: 'out_quart'
min_move: .05
anim_move_duration: .1
anim_cancel_duration: .54
scroll_distance: '10dp'
on_index: root.on_index(*args)
id: carousel

5
gui/kivy/main_window.py

@ -731,16 +731,13 @@ class ElectrumWindow(App):
d = LabelDialog(_('Enter description'), text, callback)
d.open()
@profiler
def amount_dialog(self, screen, show_max):
from uix.dialogs.amount_dialog import AmountDialog
amount = screen.amount
if amount:
amount, u = str(amount).split()
assert u == self.base_unit
else:
amount = None
def cb(amount):
screen.amount = amount
popup = AmountDialog(show_max, amount, cb)

10
gui/kivy/uix/context_menu.py

@ -6,6 +6,7 @@ from kivy.animation import Animation
from kivy.uix.floatlayout import FloatLayout
from kivy.lang import Builder
from kivy.factory import Factory
from kivy.clock import Clock
Builder.load_string('''
<MenuItem@Button>
@ -33,6 +34,7 @@ class MenuItem(Factory.Button):
pass
class ContextMenu(Bubble):
def __init__(self, obj, action_list):
Bubble.__init__(self)
self.obj = obj
@ -40,7 +42,11 @@ class ContextMenu(Bubble):
l = MenuItem()
l.text = k
def func(f=v):
f(obj)
if self.parent: self.parent.hide_menu()
Clock.schedule_once(lambda dt: self.hide(), 0.1)
Clock.schedule_once(lambda dt: f(obj), 0.15)
l.on_release = func
self.ids.buttons.add_widget(l)
def hide(self):
if self.parent:
self.parent.hide_menu()

3
gui/kivy/uix/screens.py

@ -225,6 +225,9 @@ class SendScreen(CScreen):
self.screen.address = ''
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):
self.payment_request = pr
self.screen.address = pr.get_requestor()

2
gui/kivy/uix/ui_screens/send.kv

@ -53,7 +53,7 @@ SendScreen:
id: amount_e
default_text: _('Amount')
text: s.amount if s.amount else _('Amount')
on_release: app.amount_dialog(s, True)
on_release: s.amount_dialog()
CardSeparator:
opacity: message_selection.opacity
color: blue_bottom.foreground_color

Loading…
Cancel
Save