Mercurial > libervia-desktop-kivy
comparison cagou/core/widgets_handler.py @ 155:a0e486074d91
widget handler: block carousel swiping when there is only one slide
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 27 Apr 2018 16:46:58 +0200 |
parents | a5e8833184c6 |
children | 916af9c1cb9b |
comparison
equal
deleted
inserted
replaced
154:a5e8833184c6 | 155:a0e486074d91 |
---|---|
23 from sat.core import exceptions | 23 from sat.core import exceptions |
24 from sat_frontends.quick_frontend import quick_widgets | 24 from sat_frontends.quick_frontend import quick_widgets |
25 from kivy.graphics import Color, Ellipse | 25 from kivy.graphics import Color, Ellipse |
26 from kivy.uix.layout import Layout | 26 from kivy.uix.layout import Layout |
27 from kivy.uix.boxlayout import BoxLayout | 27 from kivy.uix.boxlayout import BoxLayout |
28 from kivy.uix.stencilview import StencilView | |
28 from kivy.metrics import dp | 29 from kivy.metrics import dp |
29 from kivy import properties | 30 from kivy import properties |
30 from cagou import G | 31 from cagou import G |
31 | 32 |
32 CAROUSEL_SCROLL_DISTANCE = dp(50) | 33 CAROUSEL_SCROLL_DISTANCE = dp(50) |
155 # split area is touched, we activate left split mode | 156 # split area is touched, we activate left split mode |
156 self._split = "left" | 157 self._split = "left" |
157 touch.ud['ori_width'] = self.width | 158 touch.ud['ori_width'] = self.width |
158 self._draw_ellipse() | 159 self._draw_ellipse() |
159 else: | 160 else: |
160 return super(WHWrapper, self).on_touch_down(touch) | 161 if len(self.carousel.slides) == 1: |
162 # we don't want swipe if there is only one slide | |
163 return StencilView.on_touch_down(self.carousel, touch) | |
164 else: | |
165 return super(WHWrapper, self).on_touch_down(touch) | |
161 | 166 |
162 def on_touch_move(self, touch): | 167 def on_touch_move(self, touch): |
163 """handle size change and widget creation on split""" | 168 """handle size change and widget creation on split""" |
164 if self._split == 'None': | 169 if self._split == 'None': |
165 return super(WHWrapper, self).on_touch_move(touch) | 170 return super(WHWrapper, self).on_touch_move(touch) |