darken selected cross
This commit is contained in:
parent
e1960f631f
commit
8f1d841f14
23
cross.py
23
cross.py
@ -20,8 +20,9 @@ class Cross():
|
||||
self.pos.x=x
|
||||
self.pos.y=y
|
||||
|
||||
def draw(self):
|
||||
Color(*(self.color))
|
||||
def draw(self,**kwargs):
|
||||
# override color
|
||||
Color(*(kwargs.get("color",self.color)))
|
||||
Rectangle(pos=((self.pos.x-1.5)*self.size,(self.pos.y-0.5)*self.size),size=(3*self.size,self.size))
|
||||
Rectangle(pos=((self.pos.x-0.5)*self.size,(self.pos.y-1.5)*self.size),size=(self.size,3*self.size))
|
||||
|
||||
@ -234,7 +235,13 @@ class Cross_painter(Widget):
|
||||
self.canvas.clear()
|
||||
with self.canvas:
|
||||
for cross in self.crosses:
|
||||
cross.draw()
|
||||
if cross!=self.selected:
|
||||
cross.draw()
|
||||
# color selected
|
||||
else:
|
||||
(r,g,b)=cross.color
|
||||
# darken
|
||||
cross.draw(color=(r/2,g/2,b/2))
|
||||
|
||||
|
||||
# respond to mouse down
|
||||
@ -252,15 +259,9 @@ class Cross_painter(Widget):
|
||||
|
||||
# select cross
|
||||
if touch.button=="left":
|
||||
# unselect
|
||||
if self.selected!=None:
|
||||
self.selected.selected=False
|
||||
|
||||
# find cross under touch
|
||||
# select cross under touch
|
||||
self.selected=self.find_cross(Point(touch.x/Cross.size,touch.y/Cross.size))
|
||||
# select
|
||||
if self.selected!=None:
|
||||
self.selected.selected=True
|
||||
self.draw()
|
||||
|
||||
|
||||
# respond to drag
|
||||
|
Loading…
Reference in New Issue
Block a user