URI: 
       tkivy: use Clock to improve button responsiveness - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 3568c325eae1aef10d1d2f7d2b1da401951b39b4
   DIR parent 0b1561f4474038e9ca6c29272d78794bba594c57
  HTML Author: ThomasV <thomasv@electrum.org>
       Date:   Mon, 14 Dec 2015 21:34:25 +0100
       
       kivy: use Clock to improve button responsiveness
       
       Diffstat:
         M gui/kivy/main.kv                    |      12 ++++++++++--
         M gui/kivy/main_window.py             |       5 +----
         M gui/kivy/uix/context_menu.py        |      10 ++++++++--
         M gui/kivy/uix/screens.py             |       3 +++
         M gui/kivy/uix/ui_screens/send.kv     |       2 +-
       
       5 files changed, 23 insertions(+), 9 deletions(-)
       ---
   DIR diff --git a/gui/kivy/main.kv b/gui/kivy/main.kv
       t@@ -3,6 +3,8 @@
        #:import _ electrum.i18n._
        
        # Custom Global Widgets
       +<Button>
       +    on_parent: self.MIN_STATE_TIME = 0.1
        
        <VGridLayout@GridLayout>:
            rows: 1
       t@@ -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>
       t@@ -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
        
   DIR diff --git a/gui/kivy/main_window.py b/gui/kivy/main_window.py
       t@@ -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)
   DIR diff --git a/gui/kivy/uix/context_menu.py b/gui/kivy/uix/context_menu.py
       t@@ -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>
       t@@ -33,6 +34,7 @@ class MenuItem(Factory.Button):
            pass
        
        class ContextMenu(Bubble):
       +
            def __init__(self, obj, action_list):
                Bubble.__init__(self)
                self.obj = obj
       t@@ -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()
   DIR diff --git a/gui/kivy/uix/screens.py b/gui/kivy/uix/screens.py
       t@@ -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()
   DIR diff --git a/gui/kivy/uix/ui_screens/send.kv b/gui/kivy/uix/ui_screens/send.kv
       t@@ -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