[hamster-applet] the clicking logick was too pro-clicky. added spatial constraint.
- From: Toms Baugis <tbaugis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hamster-applet] the clicking logick was too pro-clicky. added spatial constraint.
- Date: Sat, 10 Apr 2010 19:21:35 +0000 (UTC)
commit 93381cda06e79944df85e13091c47e7b4582753e
Author: Toms Bauģis <toms baugis gmail com>
Date: Sat Apr 10 20:14:42 2010 +0100
the clicking logick was too pro-clicky. added spatial constraint.
src/hamster/graphics.py | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/src/hamster/graphics.py b/src/hamster/graphics.py
index fff343a..c0e2b12 100644
--- a/src/hamster/graphics.py
+++ b/src/hamster/graphics.py
@@ -382,6 +382,15 @@ class Sprite(gtk.Object):
self.sprites = sorted(self.sprites, key=lambda sprite:sprite.z_order)
+ def remove_child(self, *sprites):
+ """Add child sprite. Child will be nested within parent"""
+ for sprite in sprites:
+ if sprite in self.sprites:
+ self.sprites.remove(sprite)
+ sprite.parent = None
+
+ self.sprites = sorted(self.sprites, key=lambda sprite:sprite.z_order)
+
def _draw(self, context, opacity = 1):
if self.visible is False:
return
@@ -632,6 +641,16 @@ class Scene(gtk.DrawingArea):
self.sprites = sorted(self.sprites, key=lambda sprite:sprite.z_order)
+
+ def remove_child(self, *sprites):
+ """Add child sprite. Child will be nested within parent"""
+ for sprite in sprites:
+ if sprite in self.sprites:
+ self.sprites.remove(sprite)
+ sprite.parent = None
+
+ self.sprites = sorted(self.sprites, key=lambda sprite:sprite.z_order)
+
def clear(self):
"""Remove all sprites from scene"""
self.sprites = []
@@ -864,7 +883,10 @@ class Scene(gtk.DrawingArea):
def __on_button_release(self, area, event):
#if the drag is less than 5 pixles, then we have a click
- click = self._button_press_time and (dt.datetime.now() - self._button_press_time) < dt.timedelta(milliseconds = 300)
+ click = self._button_press_time \
+ and (dt.datetime.now() - self._button_press_time) < dt.timedelta(milliseconds = 200) \
+ and (event.x - self._mouse_drag[0]) ** 2 + (event.y - self._mouse_drag[1]) ** 2 < 60
+
self._button_press_time = None
self._mouse_drag = None
self._drag_x, self._drag_y = None, None
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]