Mercurial > libervia-desktop-kivy
comparison cagou/core/common_widgets.py @ 424:027fad764864
common widgets: ImagesGallery first draft:
This widget handle the fullscreen display of images. Some features like sharing or
download are planned in the future.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 26 Feb 2020 16:43:48 +0100 |
parents | f7476818f9fb |
children | 036ff0ed7474 |
comparison
equal
deleted
inserted
replaced
423:f8ba934ea462 | 424:027fad764864 |
---|---|
17 # You should have received a copy of the GNU Affero General Public License | 17 # You should have received a copy of the GNU Affero General Public License |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | 19 |
20 """common advanced widgets, which can be reused everywhere.""" | 20 """common advanced widgets, which can be reused everywhere.""" |
21 | 21 |
22 from sat.core.i18n import _ | 22 from kivy.clock import Clock |
23 from kivy.uix.label import Label | |
24 from kivy.uix.boxlayout import BoxLayout | |
25 from .behaviors import TouchMenuItemBehavior | |
26 from kivy import properties | 23 from kivy import properties |
27 from kivy.metrics import dp | 24 from kivy.metrics import dp |
28 from kivy.clock import Clock | 25 from kivy.uix.scatterlayout import ScatterLayout |
26 from kivy.uix.boxlayout import BoxLayout | |
27 from kivy.uix.label import Label | |
28 from sat.core.i18n import _ | |
29 from sat.core import log as logging | |
29 from cagou import G | 30 from cagou import G |
30 from sat.core import log as logging | 31 from .behaviors import TouchMenuItemBehavior |
31 | 32 |
32 log = logging.getLogger(__name__) | 33 log = logging.getLogger(__name__) |
33 | 34 |
34 | 35 |
35 class DelayedBoxLayout(BoxLayout): | 36 class DelayedBoxLayout(BoxLayout): |
125 pass | 126 pass |
126 | 127 |
127 | 128 |
128 class CategorySeparator(Label): | 129 class CategorySeparator(Label): |
129 pass | 130 pass |
131 | |
132 | |
133 class ImageViewer(ScatterLayout): | |
134 source = properties.StringProperty() | |
135 | |
136 | |
137 class ImagesGallery(BoxLayout): | |
138 """Show list of images in a Carousel, with some controls to downloads""" | |
139 sources = properties.ListProperty() | |
140 carousel = properties.ObjectProperty() | |
141 | |
142 def on_kv_post(self, __): | |
143 self.on_sources(None, self.sources) | |
144 | |
145 def on_parent(self, __, parent): | |
146 # we hide the head widget to have full screen | |
147 G.host.app.showHeadWidget(not bool(parent), animation=False) | |
148 | |
149 def on_sources(self, __, sources): | |
150 if not sources or not self.carousel: | |
151 return | |
152 self.carousel.clear_widgets() | |
153 for source in sources: | |
154 img = ImageViewer( | |
155 source=source, | |
156 ) | |
157 self.carousel.add_widget(img) | |
158 | |
159 def key_input(self, window, key, scancode, codepoint, modifier): | |
160 if key == 27: | |
161 G.host.closeUI() | |
162 return True |