Initial work on scaling tool.
This commit is contained in:
parent
a7ee308b71
commit
d4e08afbcd
|
|
@ -159,8 +159,15 @@ def onMouseDragGroup(self, x, y):
|
||||||
elif svlgui.MODE == "p":
|
elif svlgui.MODE == "p":
|
||||||
self.cshape.shapedata.append(["L",x-self.cshape.initx,y-self.cshape.inity])
|
self.cshape.shapedata.append(["L",x-self.cshape.initx,y-self.cshape.inity])
|
||||||
def onMouseDragObj(self, x, y):
|
def onMouseDragObj(self, x, y):
|
||||||
self.x = x-self.initx
|
if svlgui.MODE==" ":
|
||||||
self.y = y-self.inity
|
self.x = x-self.initx
|
||||||
|
self.y = y-self.inity
|
||||||
|
elif svlgui.MODE=="s":
|
||||||
|
print ((self.maxx/2.0+self.minx)-x)/(self.maxx/2.0)
|
||||||
|
self.xscale = ((self.maxx/2.0+self.minx)-x)/(self.maxx/2.0)
|
||||||
|
self.yscale = ((self.maxy/2.0+self.miny)-y)/(self.maxy/2.0)
|
||||||
|
# self.x = (self.x+self.maxx/2)-((self.maxx/2)*self.xscale)
|
||||||
|
# self.yscale = y/100.0
|
||||||
def onMouseDragText(self, x, y):
|
def onMouseDragText(self, x, y):
|
||||||
self.x = x-self.initx
|
self.x = x-self.initx
|
||||||
self.y = y-self.inity
|
self.y = y-self.inity
|
||||||
|
|
|
||||||
|
|
@ -228,7 +228,7 @@ class MainWindowOSX:
|
||||||
self.toolbox.buttons[5][0].onPress = lambda self1: svlgui.ColorSelectionWindow("line")#,linegroup)#,self.linecanvas)
|
self.toolbox.buttons[5][0].onPress = lambda self1: svlgui.ColorSelectionWindow("line")#,linegroup)#,self.linecanvas)
|
||||||
self.toolbox.buttons[5][1].onPress = lambda self1: svlgui.ColorSelectionWindow("fill")#,linegroup)#,self.fillcanvas)
|
self.toolbox.buttons[5][1].onPress = lambda self1: svlgui.ColorSelectionWindow("fill")#,linegroup)#,self.fillcanvas)
|
||||||
self.toolbox.buttons[0][1]._int().enabled = False
|
self.toolbox.buttons[0][1]._int().enabled = False
|
||||||
self.toolbox.buttons[1][0]._int().enabled = False
|
# self.toolbox.buttons[1][0]._int().enabled = False
|
||||||
self.toolbox.buttons[3][0]._int().enabled = False
|
self.toolbox.buttons[3][0]._int().enabled = False
|
||||||
self.toolbox.buttons[4][0]._int().enabled = False
|
self.toolbox.buttons[4][0]._int().enabled = False
|
||||||
self.scriptwindow = svlgui.TextView()
|
self.scriptwindow = svlgui.TextView()
|
||||||
|
|
|
||||||
81
svlgui.py
81
svlgui.py
|
|
@ -67,6 +67,9 @@ EDITING = True
|
||||||
|
|
||||||
CURRENTTEXT = None
|
CURRENTTEXT = None
|
||||||
|
|
||||||
|
#Scaling - whether the user is resizing an object
|
||||||
|
SCALING = False
|
||||||
|
|
||||||
#Library. Contatins all objects whether displayed or not.
|
#Library. Contatins all objects whether displayed or not.
|
||||||
Library = []
|
Library = []
|
||||||
|
|
||||||
|
|
@ -1532,7 +1535,8 @@ class Shape (object):
|
||||||
cr.translate(self.x*math.cos(radrot)-self.y*math.sin(radrot), self.x*math.sin(radrot)+self.y*math.cos(radrot))
|
cr.translate(self.x*math.cos(radrot)-self.y*math.sin(radrot), self.x*math.sin(radrot)+self.y*math.cos(radrot))
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
cr.translate(self.x,self.y)
|
# cr.translate(self.x,self.y)
|
||||||
|
cr.translate(self.x/(self.xscale*1.0),self.y/(self.yscale*1.0))
|
||||||
cr.rotate(self.rotation)
|
cr.rotate(self.rotation)
|
||||||
cr.scale(self.xscale*1.0, self.yscale*1.0)
|
cr.scale(self.xscale*1.0, self.yscale*1.0)
|
||||||
cr.newpath()
|
cr.newpath()
|
||||||
|
|
@ -1593,7 +1597,7 @@ class Shape (object):
|
||||||
def scale(self, width, height):
|
def scale(self, width, height):
|
||||||
try:
|
try:
|
||||||
xfactor = width/self.maxx
|
xfactor = width/self.maxx
|
||||||
yfactor = height/maxy
|
yfactor = height/self.maxy
|
||||||
def scale_section(section):
|
def scale_section(section):
|
||||||
try:
|
try:
|
||||||
if section[0] in ["M", "L"]:
|
if section[0] in ["M", "L"]:
|
||||||
|
|
@ -1842,8 +1846,8 @@ class framewrapper (object):
|
||||||
self.x = obj.x = x
|
self.x = obj.x = x
|
||||||
self.y = obj.y = y
|
self.y = obj.y = y
|
||||||
self.rot = obj.rot = rot
|
self.rot = obj.rot = rot
|
||||||
self.scalex = obj.scalex = scalex
|
self.scalex = self.xscale = obj.scalex = scalex
|
||||||
self.scaley = obj.scaley = scaley
|
self.scaley = self.yscale = obj.scaley = scaley
|
||||||
self.level = False # don't try to descend into a framewrapper
|
self.level = False # don't try to descend into a framewrapper
|
||||||
self.type = obj.__class__.__name__
|
self.type = obj.__class__.__name__
|
||||||
if obj.__class__.__name__=="Shape":
|
if obj.__class__.__name__=="Shape":
|
||||||
|
|
@ -1862,6 +1866,8 @@ class framewrapper (object):
|
||||||
self.obj.rot = self.rot
|
self.obj.rot = self.rot
|
||||||
self.obj.scalex = self.scalex
|
self.obj.scalex = self.scalex
|
||||||
self.obj.scaley = self.scaley
|
self.obj.scaley = self.scaley
|
||||||
|
self.obj.xscale = self.xscale
|
||||||
|
self.obj.yscale = self.yscale
|
||||||
if self.type=="Shape":
|
if self.type=="Shape":
|
||||||
self.obj.filled = self.filled
|
self.obj.filled = self.filled
|
||||||
self.obj.linecolor = self.linecolor
|
self.obj.linecolor = self.linecolor
|
||||||
|
|
@ -1886,6 +1892,7 @@ class framewrapper (object):
|
||||||
return self.obj.maxx
|
return self.obj.maxx
|
||||||
def getmaxy(self):
|
def getmaxy(self):
|
||||||
return self.obj.maxy
|
return self.obj.maxy
|
||||||
|
|
||||||
minx = property(getminx)
|
minx = property(getminx)
|
||||||
miny = property(getminy)
|
miny = property(getminy)
|
||||||
maxx = property(getmaxx)
|
maxx = property(getmaxx)
|
||||||
|
|
@ -1913,7 +1920,7 @@ class frame:
|
||||||
self.type="Group"
|
self.type="Group"
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.actions = ''
|
self.actions = ''
|
||||||
def add(self, obj, x, y, rot=0, scalex=0, scaley=0):
|
def add(self, obj, x, y, rot=0, scalex=1, scaley=1):
|
||||||
self.objs.append(framewrapper(obj, x, y, rot, scalex, scaley, self.objs))
|
self.objs.append(framewrapper(obj, x, y, rot, scalex, scaley, self.objs))
|
||||||
def play(self, group, cr, currentselect,transform,rect):
|
def play(self, group, cr, currentselect,transform,rect):
|
||||||
if SYSTEM=="gtk":
|
if SYSTEM=="gtk":
|
||||||
|
|
@ -1984,6 +1991,19 @@ class frame:
|
||||||
currentselect.maxx+currentselect.x+2,
|
currentselect.maxx+currentselect.x+2,
|
||||||
currentselect.maxy+currentselect.y+2])
|
currentselect.maxy+currentselect.y+2])
|
||||||
cr.stroke()
|
cr.stroke()
|
||||||
|
if MODE=="s":
|
||||||
|
cr.newpath()
|
||||||
|
cr.pencolor = Colors.rgb(1,1,1)
|
||||||
|
cr.fillcolor = Colors.rgb(0,0,0)
|
||||||
|
cr.rect([currentselect.minx-5,currentselect.miny-5,
|
||||||
|
currentselect.minx+5,currentselect.miny+5])
|
||||||
|
cr.rect([currentselect.maxx+currentselect.x-5,currentselect.miny-5,
|
||||||
|
currentselect.maxx+currentselect.x+5,currentselect.miny+5])
|
||||||
|
cr.rect([currentselect.maxx+currentselect.x-5,currentselect.maxy+currentselect.y-5,
|
||||||
|
currentselect.maxx+currentselect.x+5,currentselect.maxy+currentselect.y+5])
|
||||||
|
cr.rect([currentselect.minx-5,currentselect.maxy+currentselect.y-5,
|
||||||
|
currentselect.minx+5,currentselect.maxy+currentselect.y+5])
|
||||||
|
cr.fill_stroke()
|
||||||
cr.grestore()
|
cr.grestore()
|
||||||
cr.grestore()
|
cr.grestore()
|
||||||
elif SYSTEM=="html":
|
elif SYSTEM=="html":
|
||||||
|
|
@ -2104,7 +2124,7 @@ class Layer:
|
||||||
def parse_obj(obj):
|
def parse_obj(obj):
|
||||||
obj.x=obj.x-self.x
|
obj.x=obj.x-self.x
|
||||||
obj.y=obj.y-self.y
|
obj.y=obj.y-self.y
|
||||||
self.frames[self.currentframe].add(obj, obj.x, obj.y, obj.rotation,0,0)
|
self.frames[self.currentframe].add(obj, obj.x, obj.y, obj.rotation,1,1)
|
||||||
self.objs.append(obj)
|
self.objs.append(obj)
|
||||||
[parse_obj(obj) for obj in args]
|
[parse_obj(obj) for obj in args]
|
||||||
def delete(self,*args):
|
def delete(self,*args):
|
||||||
|
|
@ -2147,16 +2167,20 @@ class Layer:
|
||||||
self.currentselect._onMouseDown(self.currentselect, x, y)
|
self.currentselect._onMouseDown(self.currentselect, x, y)
|
||||||
else:
|
else:
|
||||||
if MODE in [" ", "s", "b"]:
|
if MODE in [" ", "s", "b"]:
|
||||||
for i in reversed(self.currentFrame()):
|
if self.currentselect and MODE=="s":
|
||||||
test = False
|
if self.currentselect.minx-5<x<self.currentselect.minx+5:
|
||||||
if i.hitTest(x, y):
|
print "hey!"
|
||||||
if MODE in [" ", "s"]:
|
else:
|
||||||
self.currentselect = i
|
for i in reversed(self.currentFrame()):
|
||||||
i._onMouseDown(x, y)
|
test = False
|
||||||
test=True
|
if i.hitTest(x, y):
|
||||||
break
|
if MODE in [" ", "s"]:
|
||||||
if not test:
|
self.currentselect = i
|
||||||
self.currentselect = None
|
i._onMouseDown(x, y)
|
||||||
|
test=True
|
||||||
|
break
|
||||||
|
if not test:
|
||||||
|
self.currentselect = None
|
||||||
else:
|
else:
|
||||||
self.onMouseDown(self, x, y)
|
self.onMouseDown(self, x, y)
|
||||||
else:
|
else:
|
||||||
|
|
@ -2344,16 +2368,20 @@ class Group (object):
|
||||||
self.activelayer.currentselect._onMouseDown(self.activelayer.currentselect, x, y)
|
self.activelayer.currentselect._onMouseDown(self.activelayer.currentselect, x, y)
|
||||||
else:
|
else:
|
||||||
if MODE in [" ", "s", "b"]:
|
if MODE in [" ", "s", "b"]:
|
||||||
test = False
|
if self.activelayer.currentselect and MODE=="s":
|
||||||
for i in reversed(self.currentFrame()):
|
if self.activelayer.currentselect.minx-5<x<self.activelayer.currentselect.minx+5:
|
||||||
if i.hitTest(x, y):
|
SCALING = True
|
||||||
if MODE in [" ", "s"]:
|
else:
|
||||||
self.activelayer.currentselect = i
|
test = False
|
||||||
test=True
|
for i in reversed(self.currentFrame()):
|
||||||
i._onMouseDown(x, y)
|
if i.hitTest(x, y):
|
||||||
break
|
if MODE in [" ", "s"]:
|
||||||
if not test:
|
self.activelayer.currentselect = i
|
||||||
self.activelayer.currentselect = None
|
test=True
|
||||||
|
i._onMouseDown(x, y)
|
||||||
|
break
|
||||||
|
if not test:
|
||||||
|
self.activelayer.currentselect = None
|
||||||
else:
|
else:
|
||||||
self.onMouseDown(self, x, y)
|
self.onMouseDown(self, x, y)
|
||||||
else:
|
else:
|
||||||
|
|
@ -2361,6 +2389,7 @@ class Group (object):
|
||||||
def onMouseDown(self, self1, x, y):
|
def onMouseDown(self, self1, x, y):
|
||||||
pass
|
pass
|
||||||
def _onMouseUp(self,x,y):
|
def _onMouseUp(self,x,y):
|
||||||
|
SCALING = False
|
||||||
x, y = self.localtransform(x, y)
|
x, y = self.localtransform(x, y)
|
||||||
if self.activelayer.level and MODE in [" ", "s"]:
|
if self.activelayer.level and MODE in [" ", "s"]:
|
||||||
if self.activelayer.currentselect:
|
if self.activelayer.currentselect:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue