Created
October 11, 2012 00:51
-
-
Save xaiki/3869489 to your computer and use it in GitHub Desktop.
simple clutter drag_action test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from gi.repository import Clutter | |
def drag_begin_cb (action, actor, event_x, event_y, modifiers, arg = None): | |
print "DRAG START\t", event_x, event_y, arg | |
if arg: | |
action.set_drag_handle (arg) | |
def drag_end_cb (action, actor, event_x, event_y, modifiers): | |
print "DRAG END\t\t", event_x, event_y | |
def drag_progress_cb (action, actor, delta_x, delta_y): | |
print "DRAG:\t", delta_x, delta_y | |
return True | |
if __name__ == '__main__': | |
Clutter.init(None) | |
stage = Clutter.Stage.get_default() | |
stage.set_size(500, 500) | |
stage.set_color(Clutter.Color.new(0,255,0,0)) | |
scroll = Clutter.Group() | |
scroll.set_size(250, 500) | |
scroll.set_position (250, 0) | |
stage.add_actor (scroll) | |
for i in range (10): | |
for j in range (3): | |
actor = Clutter.Rectangle() | |
actor.set_size (30, 30) | |
actor.set_border_width (5) | |
actor.set_color (Clutter.Color.new (255,0,0,200)) | |
actor.set_position (i*30,100 + j*30) | |
action = Clutter.DragAction() | |
action.connect ("drag-begin", drag_begin_cb, scroll) | |
action.connect ("drag-end", drag_end_cb) | |
action.connect ("drag-progress",drag_progress_cb) | |
actor.add_action (action) | |
actor.set_reactive (True) | |
scroll.add_actor (actor) | |
stage.show_all() | |
stage.connect('destroy', Clutter.main_quit) | |
Clutter.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment