diff options
author | Eitan Isaacson <eitan@monotonous.org> | 2011-01-04 13:36:18 -0800 |
---|---|---|
committer | Eitan Isaacson <eitan@monotonous.org> | 2011-01-07 13:37:47 -0800 |
commit | c3c4d70a64132ba3ed29d6fd7337de4fb4fe77cd (patch) | |
tree | 417a72259247a79c07827fa3628dbfd4ae67367f /caribou/ui/opacity.py | |
parent | 1788b7a040fcb6074ab2bbf322e2385be5661b28 (diff) | |
download | caribou-c3c4d70a64132ba3ed29d6fd7337de4fb4fe77cd.tar.gz |
Fixed opacity.py for introspection.
Diffstat (limited to 'caribou/ui/opacity.py')
-rw-r--r-- | caribou/ui/opacity.py | 41 |
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) |