# HG changeset patch # User Goffi # Date 1582731828 -3600 # Node ID 027fad764864b9ed0a4d395a150b4b86aa842c2d # Parent f8ba934ea462b9a0ac8e0c239997489d20d37124 common widgets: ImagesGallery first draft: This widget handle the fullscreen display of images. Some features like sharing or download are planned in the future. diff -r f8ba934ea462 -r 027fad764864 cagou/core/common_widgets.py --- 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 diff -r f8ba934ea462 -r 027fad764864 cagou/kv/common_widgets.kv --- a/cagou/kv/common_widgets.kv Wed Feb 26 16:42:22 2020 +0100 +++ b/cagou/kv/common_widgets.kv Wed Feb 26 16:43:48 2020 +0100 @@ -45,3 +45,21 @@ bold: True font_size: sp(20) color: app.c_sec + +: + do_rotation: False + AsyncImage: + source: root.source + allow_stretch: True, + + +: + carousel: carousel + canvas.before: + Color: + rgba: 0, 0, 0, 1 + Rectangle: + pos: self.pos + size: self.size + Carousel: + id: carousel