mark selected in cross object
This commit is contained in:
parent
8f1d841f14
commit
32cfd341be
24
cross.py
24
cross.py
@ -21,8 +21,14 @@ class Cross():
|
||||
self.pos.y=y
|
||||
|
||||
def draw(self,**kwargs):
|
||||
# override color
|
||||
Color(*(kwargs.get("color",self.color)))
|
||||
# set color
|
||||
if not self.selected:
|
||||
Color(*self.color)
|
||||
else:
|
||||
(r,g,b)=self.color
|
||||
# darken selected
|
||||
Color(r/2,g/2,b/2)
|
||||
|
||||
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))
|
||||
|
||||
@ -235,13 +241,7 @@ class Cross_painter(Widget):
|
||||
self.canvas.clear()
|
||||
with self.canvas:
|
||||
for cross in self.crosses:
|
||||
if cross!=self.selected:
|
||||
cross.draw()
|
||||
# color selected
|
||||
else:
|
||||
(r,g,b)=cross.color
|
||||
# darken
|
||||
cross.draw(color=(r/2,g/2,b/2))
|
||||
cross.draw()
|
||||
|
||||
|
||||
# respond to mouse down
|
||||
@ -259,8 +259,14 @@ class Cross_painter(Widget):
|
||||
|
||||
# select cross
|
||||
if touch.button=="left":
|
||||
# unselect
|
||||
if self.selected!=None:
|
||||
self.selected.selected=False
|
||||
|
||||
# select cross under touch
|
||||
self.selected=self.find_cross(Point(touch.x/Cross.size,touch.y/Cross.size))
|
||||
if self.selected!=None:
|
||||
self.selected.selected=True
|
||||
self.draw()
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user