Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/common/Util/ThemeWidgets.py
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2013-01-23 16:03:32 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2013-01-25 22:07:42 (GMT)
commitc2adf88db4df23513e7476e1057275f6b6467bd5 (patch)
tree129141ab0c8e2c411404f4c5c74d2c180690dcb7 /common/Util/ThemeWidgets.py
parent20bf81d221e56080997d8cf60ee8d24b21ed127a (diff)
Partial port drawing operations to cairo
The activity starts but the canvas draw is wrong. The old code used bitmap masks to define non rectangular areas, like in the drum instruments or the loops. Part of this is implemented with cairo, but is not finished. As a final note, this is a too big patch, more work is needed, and probably part of the code can be refactored. Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
Diffstat (limited to 'common/Util/ThemeWidgets.py')
-rw-r--r--common/Util/ThemeWidgets.py25
1 files changed, 4 insertions, 21 deletions
diff --git a/common/Util/ThemeWidgets.py b/common/Util/ThemeWidgets.py
index 5eb6da5..a941ebf 100644
--- a/common/Util/ThemeWidgets.py
+++ b/common/Util/ThemeWidgets.py
@@ -4,15 +4,12 @@ import cairo
import logging
import common.Config as Config
from common.Config import imagefile
+from common.Util import CairoUtil
from sugar3.graphics.combobox import ComboBox
from sugar3.graphics.palette import Palette, WidgetInvoker
-def gdk_color_to_cairo(color):
- return (color.red / 65536.0, color.green / 65536.0, color.blue / 65536.0)
-
-
class ImageVScale(Gtk.VScale):
def __init__(self, image_name, adjustment=None, slider_border=0,
@@ -703,7 +700,7 @@ class RoundFixed(Gtk.Fixed):
# within the dirty rect, but drawing seems to be quite fast compared
# to python code, so just leave it at clipping by each geometry feature
- cr.set_source_rgb(*gdk_color_to_cairo(self.bordercolor))
+ cr.set_source_rgb(*CairoUtil.gdk_color_to_cairo(self.bordercolor))
if self.borderW:
if stopY > self.corner and startY < self.heightMINcorner:
if startX < self.borderW: # draw left border
@@ -1223,30 +1220,16 @@ class keyButton(Gtk.Button):
self.cr = self.window.cairo_create()
self.cr.set_source_rgb(self.fillcolor[0], self.fillcolor[1],
self.fillcolor[2])
- self.draw_round_rect(self.cr, self.drawX - self.width // 2,
+ CairoUtil.draw_round_rect(self.cr, self.drawX - self.width // 2,
self.drawY - self.height // 2, self.width, self.height, 10)
self.cr.fill()
self.cr.set_line_width(3)
self.cr.set_source_rgb(self.strokecolor[0], self.strokecolor[1],
self.strokecolor[2])
- self.draw_round_rect(self.cr, self.drawX - self.width // 2,
+ CairoUtil.draw_round_rect(self.cr, self.drawX - self.width // 2,
self.drawY - self.height // 2, self.width, self.height, 10)
self.cr.stroke()
- def draw_round_rect(self, context, x, y, w, h, r):
- context.move_to(x + r, y) # Move to A
- context.line_to(x + w - r, y) # Straight line to B
- # Curve to C, Control points are both at Q
- context.curve_to(x + w, y, x + w, y, x + w, y + r)
- context.line_to(x + w, y + h - r) # Move to D
- # Curve to E
- context.curve_to(x + w, y + h, x + w, y + h, x + w - r, y + h)
- context.line_to(x + r, y + h) # Line to F
- context.curve_to(x, y + h, x, y + h, x, y + h - r) # Curve to G
- context.line_to(x, y + r) # Line to H
- context.curve_to(x, y, x, y, x + r, y) # Curve to A
- return
-
def set_fillcolor(self, r, g, b):
self.fillcolor = [r, g, b]
self.queue_draw()