Mercurial > libervia-desktop-kivy
diff 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 |
line wrap: on
line diff
--- a/cagou/core/common_widgets.py Wed Feb 26 16:42:22 2020 +0100 +++ b/cagou/core/common_widgets.py Wed Feb 26 16:43:48 2020 +0100 @@ -19,15 +19,16 @@ """common advanced widgets, which can be reused everywhere.""" -from sat.core.i18n import _ -from kivy.uix.label import Label -from kivy.uix.boxlayout import BoxLayout -from .behaviors import TouchMenuItemBehavior +from kivy.clock import Clock from kivy import properties from kivy.metrics import dp -from kivy.clock import Clock +from kivy.uix.scatterlayout import ScatterLayout +from kivy.uix.boxlayout import BoxLayout +from kivy.uix.label import Label +from sat.core.i18n import _ +from sat.core import log as logging from cagou import G -from sat.core import log as logging +from .behaviors import TouchMenuItemBehavior log = logging.getLogger(__name__) @@ -127,3 +128,35 @@ class CategorySeparator(Label): pass + + +class ImageViewer(ScatterLayout): + source = properties.StringProperty() + + +class ImagesGallery(BoxLayout): + """Show list of images in a Carousel, with some controls to downloads""" + sources = properties.ListProperty() + carousel = properties.ObjectProperty() + + def on_kv_post(self, __): + self.on_sources(None, self.sources) + + def on_parent(self, __, parent): + # we hide the head widget to have full screen + G.host.app.showHeadWidget(not bool(parent), animation=False) + + def on_sources(self, __, sources): + if not sources or not self.carousel: + return + self.carousel.clear_widgets() + for source in sources: + img = ImageViewer( + source=source, + ) + self.carousel.add_widget(img) + + def key_input(self, window, key, scancode, codepoint, modifier): + if key == 27: + G.host.closeUI() + return True