# HG changeset patch # User Goffi # Date 1583097085 -3600 # Node ID 036ff0ed74744d68fbf8eacb10fdb3a1f9ad4679 # Parent 53bb3886b408fee82611243edca4513e0ad74dc2 common widgets (ImagesGallery): reset image transformation on slide change or double tap. diff -r 53bb3886b408 -r 036ff0ed7474 cagou/core/common_widgets.py --- a/cagou/core/common_widgets.py Sun Mar 01 22:11:25 2020 +0100 +++ b/cagou/core/common_widgets.py Sun Mar 01 22:11:25 2020 +0100 @@ -1,6 +1,5 @@ #!/usr/bin/env python3 - # Cagou: desktop/mobile frontend for Salut à Toi XMPP client # Copyright (C) 2016-2020 Jérôme Poisson (goffi@goffi.org) @@ -133,14 +132,29 @@ class ImageViewer(ScatterLayout): source = properties.StringProperty() + def on_touch_down(self, touch): + if touch.is_double_tap: + self.reset() + return True + return super().on_touch_down(touch) + + def reset(self): + self.rotation = 0 + self.scale = 1 + self.x = 0 + self.y = 0 + class ImagesGallery(BoxLayout): """Show list of images in a Carousel, with some controls to downloads""" sources = properties.ListProperty() carousel = properties.ObjectProperty() + previous_slide = None def on_kv_post(self, __): self.on_sources(None, self.sources) + self.previous_slide = self.carousel.current_slide + self.carousel.bind(current_slide=self.on_slide_change) def on_parent(self, __, parent): # we hide the head widget to have full screen @@ -156,6 +170,12 @@ ) self.carousel.add_widget(img) + def on_slide_change(self, __, slide): + if isinstance(self.previous_slide, ImageViewer): + self.previous_slide.reset() + + self.previous_slide = slide + def key_input(self, window, key, scancode, codepoint, modifier): if key == 27: G.host.closeUI()