diff options
author | Manuel Kaufmann <humitos@gmail.com> | 2012-10-18 14:54:46 (GMT) |
---|---|---|
committer | Manuel Kaufmann <humitos@gmail.com> | 2012-10-18 14:54:46 (GMT) |
commit | b9c29bc13b516b7e78aea86667a814b9d8ee9376 (patch) | |
tree | 95898f6ebb6323f070240d34efd4fd10774f4933 | |
parent | 4fbd0469e5440888b4ad9f6f04f28e66aaa3d142 (diff) |
ZoomController scale 1.0 test
'scale-changed' signal is not always called with scale value in 1.0
-rw-r--r-- | tests/zoom_scaled_changed.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/zoom_scaled_changed.py b/tests/zoom_scaled_changed.py new file mode 100644 index 0000000..0307e02 --- /dev/null +++ b/tests/zoom_scaled_changed.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python + +import math + +from gi.repository import Gtk +from gi.repository import Gdk +from gi.repository import SugarGestures + + +class TestTouch(Gtk.DrawingArea): + + def __init__(self): + super(TestTouch, self).__init__() + + self.set_events(Gdk.EventMask.TOUCH_MASK) + self.connect('draw', self.__draw_cb) + + self.touch = None + + zoom = SugarGestures.ZoomController() + zoom.connect('scale-changed', self.__scale_changed_cb) + zoom.attach(self, SugarGestures.EventControllerFlags.NONE) + + def __scale_changed_cb(self, controller, scale): + print 'Scale:', scale + if scale == 1.0: + self.touch = (500, 250) + else: + self.touch = None + self.queue_draw() + + def __draw_cb(self, widget, ctx): + ctx.set_source_rgba(1, 0, 0, 0.7) + if self.touch is not None: + x, y = self.touch + ctx.save() + ctx.arc(x, y, 60, 0., 2 * math.pi) + ctx.fill() + ctx.restore() + + +def main(): + window = Gtk.Window() + test_touch = TestTouch() + + window.add(test_touch) + window.connect("destroy", Gtk.main_quit) + window.show_all() + window.set_size_request(1000, 500) + Gtk.main() + +if __name__ == "__main__": + main() |