[hamster-applet] graphics lib fixes



commit 1c10f6ef0b753b8a19ead8e7b897a271dad240af
Author: Toms Bauģis <toms baugis gmail com>
Date:   Wed May 12 02:11:00 2010 +0100

    graphics lib fixes

 src/hamster/charting.py        |    9 ++++++---
 src/hamster/widgets/dayline.py |    9 ++++++---
 src/hamster/widgets/tags.py    |    5 +++--
 3 files changed, 15 insertions(+), 8 deletions(-)
---
diff --git a/src/hamster/charting.py b/src/hamster/charting.py
index 419053e..a5b73fe 100644
--- a/src/hamster/charting.py
+++ b/src/hamster/charting.py
@@ -24,22 +24,24 @@ import time
 import graphics
 import locale
 
-class Bar(graphics.Shape):
+class Bar(graphics.Sprite):
     def __init__(self, key, value, normalized, label_color):
-        graphics.Shape.__init__(self)
+        graphics.Sprite.__init__(self)
         self.key, self.value, self.normalized = key, value, normalized
 
         self.height = 0
         self.width = 20
         self.vertical = True
         self.interactive = True
+        self.fill = None
 
         self.label = graphics.Label(value, size=8, color=label_color)
         self.label_background = graphics.Rectangle(self.label.width + 4, self.label.height + 4, 4, visible=False)
         self.add_child(self.label_background)
         self.add_child(self.label)
+        self.connect("on-render", self.on_render)
 
-    def draw_shape(self):
+    def on_render(self, sprite):
         # invisible rectangle for the mouse, covering whole area
         self.graphics.set_color("#000", 0)
         self.graphics.rectangle(0, 0, self.width, self.height)
@@ -49,6 +51,7 @@ class Bar(graphics.Shape):
 
         self.graphics.rectangle(0, 0, size, self.height, 3)
         self.graphics.rectangle(0, 0, min(size, 3), self.height)
+        self.graphics.fill(self.fill)
 
         self.label.y = (self.height - self.label.height) / 2
 
diff --git a/src/hamster/widgets/dayline.py b/src/hamster/widgets/dayline.py
index 3a92e70..5b559aa 100644
--- a/src/hamster/widgets/dayline.py
+++ b/src/hamster/widgets/dayline.py
@@ -28,11 +28,12 @@ from .hamster import graphics, pytweener
 from .hamster.configuration import conf
 
 
-class Selection(graphics.Shape):
+class Selection(graphics.Sprite):
     def __init__(self, start_time = None, end_time = None):
-        graphics.Shape.__init__(self, stroke = "#999", fill = "#999", z_order = 100)
+        graphics.Sprite.__init__(self, z_order = 100)
         self.start_time, self.end_time  = None, None
         self.width, self.height = None, None
+        self.fill = None # will be set to proper theme color on render
         self.fixed = False
 
         self.start_label = graphics.Label("", 8, "#333", visible = False)
@@ -40,8 +41,10 @@ class Selection(graphics.Shape):
         self.duration_label = graphics.Label("", 8, "#FFF", visible = False)
 
         self.add_child(self.start_label, self.end_label, self.duration_label)
+        self.connect("on-render", self.on_render)
 
-    def draw_shape(self):
+
+    def on_render(self, sprite):
         self.graphics.rectangle(0, 0, self.width, self.height)
         self.graphics.fill(self.fill, 0.3)
 
diff --git a/src/hamster/widgets/tags.py b/src/hamster/widgets/tags.py
index 376e711..b29ab3d 100644
--- a/src/hamster/widgets/tags.py
+++ b/src/hamster/widgets/tags.py
@@ -333,13 +333,14 @@ class Tag(graphics.Sprite):
                                          (w, h),
                                          (corner, h),
                                          (0, h - corner)],
-                                        x = 0.5, y = 0.5,
+                                        x = 0.5,
+                                        y = 0.5,
                                         fill = self.color,
                                         stroke = "#b4b4b4",
                                         line_width = 1)
 
         self.add_child(self.tag)
-        self.add_child(graphics.Circle(2, x = 5.5, y = h / 2 - 1.5,
+        self.add_child(graphics.Circle(2, 2, x = 5.5, y = h / 2 - 1.5,
                                        fill = "#fff",
                                        stroke = "#b4b4b4",
                                        line_width = 1))



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]