Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Jam/Parasite.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 /Jam/Parasite.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 'Jam/Parasite.py')
-rw-r--r--Jam/Parasite.py42
1 files changed, 27 insertions, 15 deletions
diff --git a/Jam/Parasite.py b/Jam/Parasite.py
index c5ac2ec..f29bee6 100644
--- a/Jam/Parasite.py
+++ b/Jam/Parasite.py
@@ -5,6 +5,7 @@ import common.Config as Config
from common.Util.NoteDB import PARAMETER
from common.Util.CSoundClient import new_csound_client
+from common.Util import CairoUtil
class LoopParasite:
@@ -31,7 +32,6 @@ class LoopParasite:
self.lastDragP = 0
self.lastDragD = 0
- self.gc = self.owner.gc
self.colors = self.owner.colors
self.updateParameter( None, None )
@@ -325,24 +325,36 @@ class LoopParasite:
#=======================================================
# Draw
- def draw( self, win, gc, startX, stopX ):
- if stopX < self.x: return False # we don't need to draw and no one after us will draw
- if startX > self.x + self.width: return True # we don't need to draw, but maybe a later note does
+ def draw(self, ctx, startX, stopX):
+ # we don't need to draw and no one after us will draw
+ if stopX < self.x:
+ return False
+ # we don't need to draw, but maybe a later note does
+ if startX > self.x + self.width:
+ return True
# draw fill
- self.gc.foreground = self.colors["Preview_Note_Fill"]
- self.gc.set_clip_origin( self.x, self.y-self.owner.sampleNoteHeight )
- self.owner.previewBuffer.draw_rectangle( self.gc, True, self.x+1, self.y+1, self.width-2, self.owner.sampleNoteHeight-2 )
+ ctx.save()
+ ctx.set_source_rgb(CairoUtil.gdk_color_to_cairo(
+ self.colors["Preview_Note_Fill"]))
+ ctx.rectangle(self.x + 1, self.y + 1, self.width - 2,
+ self.owner.sampleNoteHeight - 2)
+ ctx.fill()
+
# draw border
if self.selected:
- self.gc.foreground = self.colors["Preview_Note_Selected"]
+ ctx.set_source_rgb(CairoUtil.gdk_color_to_cairo(
+ self.colors["Preview_Note_Selected"]))
else:
- self.gc.foreground = self.colors["Preview_Note_Border"]
- self.gc.set_clip_origin( self.x, self.y )
+ ctx.set_source_rgb(CairoUtil.gdk_color_to_cairo(
+ self.colors["Preview_Note_Border"]))
+ #self.gc.set_clip_origin( self.x, self.y )
endX = self.x + self.width - 3
- self.owner.previewBuffer.draw_rectangle( self.gc, True, self.x, self.y, self.width-3, self.owner.sampleNoteHeight )
- self.gc.set_clip_origin( endX-self.owner.sampleNoteMask.endOffset, self.y )
- self.owner.previewBuffer.draw_rectangle( self.gc, True, endX, self.y, 3, self.owner.sampleNoteHeight )
-
+ ctx.rectangle(self.x, self.y, self.width - 3,
+ self.owner.sampleNoteHeight)
+ ctx.fill()
+ #self.gc.set_clip_origin( endX-self.owner.sampleNoteMask.endOffset, self.y )
+ ctx.rectangle(endX, self.y, 3, self.owner.sampleNoteHeight)
+ ctx.fill()
+ ctx.restore()
return True # we drew something
-