summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEitan Isaacson <eitan@monotonous.org>2011-01-04 13:36:18 -0800
committerEitan Isaacson <eitan@monotonous.org>2011-01-07 13:37:47 -0800
commitc3c4d70a64132ba3ed29d6fd7337de4fb4fe77cd (patch)
tree417a72259247a79c07827fa3628dbfd4ae67367f
parent1788b7a040fcb6074ab2bbf322e2385be5661b28 (diff)
downloadcaribou-c3c4d70a64132ba3ed29d6fd7337de4fb4fe77cd.tar.gz
Fixed opacity.py for introspection.
-rw-r--r--caribou/ui/opacity.py41
1 files changed, 22 insertions, 19 deletions
diff --git a/caribou/ui/opacity.py b/caribou/ui/opacity.py
index 7214aa4..be742d8 100644
--- a/caribou/ui/opacity.py
+++ b/caribou/ui/opacity.py
@@ -42,9 +42,12 @@ class ProximityWindowBase(object):
glib.timeout_add(80, self._proximity_check)
def _proximity_check(self):
- x, y = self.get_pointer()
-
- distance = self._get_distance_to_bbox(x, y, self.allocation)
+ px, py = self.get_pointer()
+
+ ww = self.get_allocated_width()
+ wh = self.get_allocated_height()
+
+ distance = self._get_distance_to_bbox(px, py, ww, wh)
opacity = (self.max_alpha - self.min_alpha) * \
(1 - min(distance, self.max_distance)/self.max_distance)
@@ -53,28 +56,28 @@ class ProximityWindowBase(object):
self.set_opacity(opacity)
return self.props.visible
- def _get_distance_to_bbox(self, x, y, bbox):
- if x < bbox.x:
- x_distance = bbox.x - x
- elif x > bbox.width + bbox.x:
- x_distance = bbox.width + bbox.x - x
+ def _get_distance_to_bbox(self, px, py, bw, bh):
+ if px < 0:
+ x_distance = float(abs(px))
+ elif px > bw:
+ x_distance = float(px - bw)
else:
- x_distance = 0
+ x_distance = 0.0
- if y < bbox.y:
- y_distance = bbox.y - y
- elif y > bbox.height + bbox.y:
- y_distance = bbox.height + bbox.y - y
+ if py < 0:
+ y_distance = float(abs(px))
+ elif py > bh:
+ y_distance = float(py - bh)
else:
- y_distance = 0
+ y_distance = 0.0
if y_distance == 0 and x_distance == 0:
return 0.0
elif y_distance != 0 and x_distance == 0:
- return abs(float(y_distance))
+ return y_distance
elif y_distance == 0 and x_distance != 0:
- return abs(float(x_distance))
+ return x_distance
else:
- x2 = bbox.x if x_distance > 0 else bbox.x + bbox.width
- y2 = bbox.y if y_distance > 0 else bbox.y + bbox.height
- return sqrt((x - x2)**2 + (y - y2)**2)
+ x2 = 0 if x_distance > 0 else bw
+ y2 = 0 if y_distance > 0 else bh
+ return sqrt((px - x2)**2 + (py - y2)**2)