Coarse grain mouse input with lattice
This commit is contained in:
parent
a152af6bac
commit
5864dc5c06
@ -315,6 +315,9 @@ class Painter(Widget):
|
||||
# record relative position of click with respect to reference
|
||||
if self.undermouse!=None:
|
||||
self.offset=Point(touchx,touchy)-self.undermouse.elements[0].pos
|
||||
# snap to lattice
|
||||
if self.lattice!=None:
|
||||
self.offset=self.lattice.nearest(self.offset)
|
||||
|
||||
# no modifiers
|
||||
if self.modifiers==[]:
|
||||
@ -361,13 +364,17 @@ class Painter(Widget):
|
||||
# only respond to touch in drawing area
|
||||
if self.collide_point(*touch.pos):
|
||||
# convert to logical
|
||||
touchx=self.coord_topos_x(touch.x)
|
||||
touchy=self.coord_topos_y(touch.y)
|
||||
touchc=Point(self.coord_topos_x(touch.x),self.coord_topos_y(touch.y))
|
||||
|
||||
# snap to lattice
|
||||
if self.lattice!=None:
|
||||
touchc=self.lattice.nearest(touchc)
|
||||
|
||||
# only move on left click
|
||||
if touch.button=="left" and self.modifiers==[] and self.undermouse!=None:
|
||||
# attempted move determined by the relative position to the relative position of click within self.undermouse
|
||||
delta=self.adjust_move(Point(touchx,touchy)-(self.offset+self.undermouse.elements[0].pos),0)
|
||||
delta=self.adjust_move(touchc-(self.offset+self.undermouse.elements[0].pos),0)
|
||||
|
||||
|
||||
# snap to lattice
|
||||
if self.lattice!=None:
|
||||
|
Loading…
Reference in New Issue
Block a user