Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/SynthLab
diff options
context:
space:
mode:
authoramartin <olpc@xo-05-28-21.localdomain>2007-08-03 08:14:27 (GMT)
committer amartin <olpc@xo-05-28-21.localdomain>2007-08-03 08:14:27 (GMT)
commitf7b05e213c329ace16e657dd358558cc2844b001 (patch)
treee5a3f3613679eea8b07e44563ce5df6929c2a2b0 /SynthLab
parentdc42845ec154dcbe5347f237ad0b6049068b2932 (diff)
sythlab highlights
Diffstat (limited to 'SynthLab')
-rwxr-xr-xSynthLab/SynthLabConstants.py5
-rw-r--r--SynthLab/SynthLabWindow.py56
2 files changed, 42 insertions, 19 deletions
diff --git a/SynthLab/SynthLabConstants.py b/SynthLab/SynthLabConstants.py
index 550e8ef..2bbd716 100755
--- a/SynthLab/SynthLabConstants.py
+++ b/SynthLab/SynthLabConstants.py
@@ -2,6 +2,7 @@ class SynthLabConstants:
PIC_SIZE = 80
HALF_SIZE = PIC_SIZE // 2
+ PIC_SIZE_HIGHLIGHT = PIC_SIZE + 4
GT_CONTROL_OUTPUT = 0
GT_CONTROL_INPUT = 1
@@ -11,13 +12,13 @@ class SynthLabConstants:
# relative to object center
GATE_POINT = [ [ [ (0,34) ] ],
[ [], [ (-25,-35),(-9,-35),(8,-35),(25,-35) ], [ (0,35) ] ],
- [ [], [ (35,-20),(35,-7),(35,7),(35,20) ], [ (0,34) ], [ (0,-34) ] ],
+ [ [], [ (33,-20),(33,-7),(33,7),(33,20) ], [ (-2,34) ], [ (-2,-34) ] ],
[ [], [], [], [ (0,-35) ] ] ]
# GATE_MAP[objecttype][gatetype][gatenum] = [ sx, sy, ex, ey, (wireX,wireY) ]
# gate locations relative to object center
GATE_MAP = [ [ [ [-6,28,6,40] ] ],
[ [], [[-31,-40,-18,-28], [-16,-40,-3,-28], [2,-40,15,-28], [19,-40,32,-28]], [[-6,28,7,40]] ],
- [ [], [[28,-26,40,-13], [28,-13,40,0], [28,0,40,13], [28,13,40,26]], [[-6,28,7,40]], [[-6,-40,7,-28]] ],
+ [ [], [[26,-26,38,-13], [26,-13,38,0], [26,0,38,13], [26,13,38,26]], [[-8,28,5,40]], [[-8,-40,5,-28]] ],
[ [], [], [], [[-6,-40,7,-28]] ] ]
# insert wire locations into map
GATE_OFFSET = 7
diff --git a/SynthLab/SynthLabWindow.py b/SynthLab/SynthLabWindow.py
index da2f8fa..a1e5461 100644
--- a/SynthLab/SynthLabWindow.py
+++ b/SynthLab/SynthLabWindow.py
@@ -260,6 +260,7 @@ class SynthLabWindow(SubActivity):
colormap = self.drawingArea.get_colormap()
self.bgColor = colormap.alloc_color( Config.PANEL_COLOR, True, True )
self.lineColor = colormap.alloc_color( Config.SL_LINE_COLOR, True, True )
+ self.highlightColor = colormap.alloc_color( Config.SL_HIGHLIGHT_COLOR, True, True )
self.overWireColor = colormap.alloc_color( Config.SL_OVER_WIRE_COLOR, True, True )
self.overGateColor = colormap.alloc_color( Config.SL_OVER_GATE_COLOR, True, True )
self.overGateRejectColor = colormap.alloc_color( Config.SL_OVER_GATE_REJECT_COLOR, True, True )
@@ -289,7 +290,10 @@ class SynthLabWindow(SubActivity):
if i == self.instanceID:
return
self.new = False
+ if self.instanceID > 0:
+ self.invalidate_rect( self.bounds[self.instanceID][0], self.bounds[self.instanceID][1]-2, SynthLabConstants.PIC_SIZE, SynthLabConstants.PIC_SIZE_HIGHLIGHT )
self.instanceID = i
+ self.invalidate_rect( self.bounds[i][0], self.bounds[i][1]-2, SynthLabConstants.PIC_SIZE, SynthLabConstants.PIC_SIZE_HIGHLIGHT )
if self.instanceID / 4 != self.objectType:
self.objectType = self.instanceID / 4
self.objComboBox.remove_all()
@@ -526,11 +530,6 @@ class SynthLabWindow(SubActivity):
self.highlightWire( None )
self.highlightGate( None )
- if event.button == 1 or event.button == 3:
- for i in range(self.objectCount):
- if self.bounds[i][0] < event.x < self.bounds[i][2] and self.bounds[i][1] < event.y < self.bounds[i][3]:
- self.select( i )
-
if self.action == "drag-object":
self.doneAction()
elif self.action == "draw-wire":
@@ -551,7 +550,7 @@ class SynthLabWindow(SubActivity):
self.highlightGate( None )
if event.button == 1:
- for i in range(self.objectCount):
+ for i in range(self.objectCount-1,-1,-1):
if self.bounds[i][0] < event.x < self.bounds[i][2] and self.bounds[i][1] < event.y < self.bounds[i][3]:
gate = self.testGates( i, event.x-self.locations[i][0], event.y-self.locations[i][1] )
if gate:
@@ -565,8 +564,8 @@ class SynthLabWindow(SubActivity):
if i != self.objectCount-1:
#self.select( i )
self.startDragObject( i )
- #else:
- #self.select( i )
+ else:
+ self.select( i )
return
if self.action == "draw-wire": # didn't hit anything
self.doneWire()
@@ -733,7 +732,7 @@ class SynthLabWindow(SubActivity):
self.dragObject = i
self.dragInitialLoc = (self.locations[i][0],self.locations[i][1])
self.potentialDisconnect = False
- self.invalidate_rect( self.bounds[i][0], self.bounds[i][1], SynthLabConstants.PIC_SIZE, SynthLabConstants.PIC_SIZE )
+ self.invalidate_rect( self.bounds[i][0], self.bounds[i][1]-2, SynthLabConstants.PIC_SIZE, SynthLabConstants.PIC_SIZE_HIGHLIGHT )
for i in self.outputMap[self.dragObject]:
self.invalidate_rect( self.cBounds[i][0], self.cBounds[i][1], self.cBounds[i][2], self.cBounds[i][3] )
for i in self.inputMap[self.dragObject]:
@@ -749,7 +748,7 @@ class SynthLabWindow(SubActivity):
if y-SynthLabConstants.HALF_SIZE < 0: y = SynthLabConstants.HALF_SIZE
elif y+SynthLabConstants.HALF_SIZE > self.drawingAreaHeight: y = self.drawingAreaHeight - SynthLabConstants.HALF_SIZE
- self.invalidate_rect(self.bounds[self.dragObject][0], self.bounds[self.dragObject][1], SynthLabConstants.PIC_SIZE, SynthLabConstants.PIC_SIZE, False )
+ self.invalidate_rect(self.bounds[self.dragObject][0], self.bounds[self.dragObject][1]-2, SynthLabConstants.PIC_SIZE, SynthLabConstants.PIC_SIZE_HIGHLIGHT, False )
if not self.potentialDisconnect:
for i in self.outputMap[self.dragObject]:
self.invalidate_rect( self.cBounds[i][0], self.cBounds[i][1], self.cBounds[i][2], self.cBounds[i][3], False )
@@ -763,7 +762,7 @@ class SynthLabWindow(SubActivity):
self.locations[self.dragObject][1] = int( y )
self.updateBounds(self.dragObject)
- self.invalidate_rect(self.bounds[self.dragObject][0], self.bounds[self.dragObject][1], SynthLabConstants.PIC_SIZE, SynthLabConstants.PIC_SIZE, False )
+ self.invalidate_rect(self.bounds[self.dragObject][0], self.bounds[self.dragObject][1]-2, SynthLabConstants.PIC_SIZE, SynthLabConstants.PIC_SIZE_HIGHLIGHT, False )
if not self.potentialDisconnect:
for i in self.outputMap[self.dragObject]:
self.invalidate_rect( self.cBounds[i][0], self.cBounds[i][1], self.cBounds[i][2], self.cBounds[i][3], False )
@@ -772,7 +771,7 @@ class SynthLabWindow(SubActivity):
def doneDragObject( self ):
if self.potentialDisconnect:
- self.invalidate_rect( self.bounds[self.dragObject][0], self.bounds[self.dragObject][1], SynthLabConstants.PIC_SIZE, SynthLabConstants.PIC_SIZE, False )
+ self.invalidate_rect( self.bounds[self.dragObject][0], self.bounds[self.dragObject][1]-2, SynthLabConstants.PIC_SIZE, SynthLabConstants.PIC_SIZE_HIGHLIGHT, False )
m = self.outputMap[self.dragObject][:]
m.sort(reverse=True)
for i in m: self.delConnection( i )
@@ -782,14 +781,17 @@ class SynthLabWindow(SubActivity):
self.locations[self.dragObject][0] = SynthLabConstants.INIT_LOCATIONS[self.dragObject][0]
self.locations[self.dragObject][1] = SynthLabConstants.INIT_LOCATIONS[self.dragObject][1]
self.updateBounds( self.dragObject )
- self.invalidate_rect(self.bounds[self.dragObject][0], self.bounds[self.dragObject][1], SynthLabConstants.PIC_SIZE, SynthLabConstants.PIC_SIZE )
+ #self.invalidate_rect(self.bounds[self.dragObject][0], self.bounds[self.dragObject][1]-2, SynthLabConstants.PIC_SIZE, SynthLabConstants.PIC_SIZE_HIGHLIGHT )
else:
- self.invalidate_rect( self.bounds[self.dragObject][0], self.bounds[self.dragObject][1], SynthLabConstants.PIC_SIZE, SynthLabConstants.PIC_SIZE )
+ #self.invalidate_rect( self.bounds[self.dragObject][0], self.bounds[self.dragObject][1]-2, SynthLabConstants.PIC_SIZE, SynthLabConstants.PIC_SIZE_HIGHLIGHT )
for i in self.outputMap[self.dragObject]:
self.invalidate_rect( self.cBounds[i][0], self.cBounds[i][1], self.cBounds[i][2], self.cBounds[i][3] )
for i in self.inputMap[self.dragObject]:
self.invalidate_rect( self.cBounds[i][0], self.cBounds[i][1], self.cBounds[i][2], self.cBounds[i][3] )
+ # NOTE: select function invalidates the rect so no need to do it above
+ self.select( self.dragObject )
+
self.dragObject = None
self.handleSaveTemp()
@@ -919,13 +921,26 @@ class SynthLabWindow(SubActivity):
# draw objects
self.gc.set_clip_mask( self.clipMask )
for i in range(self.objectCount):
- if i == self.dragObject:
+ if i == self.dragObject or i == self.instanceID:
continue
if startX > self.bounds[i][2] or stopX < self.bounds[i][0] or startY > self.bounds[i][3] or stopY < self.bounds[i][1]:
continue
type = i >> 2
self.gc.set_clip_origin( self.bounds[i][0]-SynthLabConstants.PIC_SIZE*type, self.bounds[i][1] )
buf.draw_drawable( self.gc, self.pixmap[i], 0, 0, self.bounds[i][0], self.bounds[i][1], SynthLabConstants.PIC_SIZE, SynthLabConstants.PIC_SIZE )
+
+ if self.dragObject != self.instanceID:
+ i = self.instanceID
+ type = i >> 2
+ #draw object
+ self.gc.set_clip_origin( self.bounds[i][0]-SynthLabConstants.PIC_SIZE*type, self.bounds[i][1] )
+ buf.draw_drawable( self.gc, self.pixmap[i], 0, 0, self.bounds[i][0], self.bounds[i][1], SynthLabConstants.PIC_SIZE, SynthLabConstants.PIC_SIZE )
+ # draw selectionHighlight
+ self.gc.set_clip_origin( self.bounds[i][0]-SynthLabConstants.PIC_SIZE*type, self.bounds[i][1]-82 )
+ self.gc.foreground = self.highlightColor
+ buf.draw_rectangle( self.gc, True, self.bounds[i][0], self.bounds[i][1]-2, SynthLabConstants.PIC_SIZE, SynthLabConstants.PIC_SIZE_HIGHLIGHT )
+ self.gc.foreground = self.lineColor
+
self.gc.set_clip_rectangle( self.clearMask )
# draw wires
@@ -946,8 +961,6 @@ class SynthLabWindow(SubActivity):
stopX = event.area.x + event.area.width
stopY = event.area.y + event.area.height
- self.gc.foreground = self.lineColor
-
if self.screenBufDirty:
self.predraw( self.screenBuf )
@@ -960,10 +973,18 @@ class SynthLabWindow(SubActivity):
type = self.dragObject >> 2
self.gc.set_clip_origin( self.bounds[self.dragObject][0]-SynthLabConstants.PIC_SIZE*type, self.bounds[self.dragObject][1] )
widget.window.draw_drawable( self.gc, self.pixmap[self.dragObject], 0, 0, self.bounds[self.dragObject][0], self.bounds[self.dragObject][1], SynthLabConstants.PIC_SIZE, SynthLabConstants.PIC_SIZE )
+
+ if self.instanceID == self.dragObject:
+ # draw selectionHighlight
+ self.gc.set_clip_origin( self.bounds[self.dragObject][0]-SynthLabConstants.PIC_SIZE*type, self.bounds[self.dragObject][1]-82 )
+ self.gc.foreground = self.highlightColor
+ widget.window.draw_rectangle( self.gc, True, self.bounds[self.dragObject][0], self.bounds[self.dragObject][1]-2, SynthLabConstants.PIC_SIZE, SynthLabConstants.PIC_SIZE_HIGHLIGHT )
+
self.gc.set_clip_rectangle( self.clearMask )
# draw wires
if not self.potentialDisconnect:
+ self.gc.foreground = self.lineColor
for c in self.outputMap[self.dragObject]:
if startX > self.cBounds[c][4] or stopX < self.cBounds[c][0] or startY > self.cBounds[c][5] or stopY < self.cBounds[c][1]:
continue
@@ -976,6 +997,7 @@ class SynthLabWindow(SubActivity):
self.cPoints[c][2], self.cPoints[c][3] )
elif self.action == "draw-wire":
# draw the wire
+ self.gc.foreground = self.lineColor
widget.window.draw_line( self.gc, self.wirePoint[0][0], self.wirePoint[0][1],
self.wirePoint[1][0], self.wirePoint[1][1] )