Changeset - 115636cca107
[Not reviewed]
default
0 1 0
drewp - 22 years ago 2002-07-07 12:16:03

subeditor begins to work - stage makes the right calls to subeditor now
1 file changed with 14 insertions and 6 deletions:
0 comments (0 inline, 0 general)
light8/stage.py
Show inline comments
 
@@ -52,32 +52,35 @@ class Stage(Canvas):
 
        self.bind("<ButtonPress-1>", self.leftpress)
 
        self.bind("<B1-Motion>", self.leftmotion)
 
        self.bind("<ButtonRelease-1>", self.leftrelease)
 
        
 
        self.halo=11 # search radius for clicked items
 

	
 
        self.lmbstate=None # as you perform with LMB, this goes from None to 'pressed','rectangle','levelchange'
 

	
 
        self.alllights=[]
 
        self.selectedlights=[]
 
        self.alllighttags={} # tag: name lookup
 

	
 
        self.subeditor=None
 

	
 
    def setimage(self,stageimage):
 
        img = Image('photo',file=stageimage)
 
        self.img=img # can't lose this!
 
        print img.width()
 
        self.create_image(0,0,anchor='nw',image=img)
 
        self.config(width=img.width(),height=img.height())
 
        
 

	
 
    def setsubediting(self,subeditor):
 
        self.subeditor = subeditor
 
    #
 
    # selection management
 
    #
 
    def updateselectionboxes(self):
 
        "make selection boxes that match self.selectedlights"
 
        self.delete("selectbox")
 
        for l in self.selectedlights:
 
            for c in self.getlightbboxes(l):
 
               self.create_rectangle(c[0]-2,c[1]-2,c[2]+2,c[3]+2,outline='red',tag="selectbox")            
 
    
 
    def clearselection(self,dyn=0):
 
        self.selectedlights=[]
 
@@ -132,51 +135,52 @@ class Stage(Canvas):
 
            # toggle selection
 
            if touching[0] in self.selectedlights:
 
                if shifted:
 
                    # deselect
 
                    self.select(touching[0],0)
 
                    # and do nothing else
 
                    self.lmbstate=None
 
                else:
 
                    # select only this light
 
                    self.clearselection()
 
                    self.select(touching[0])
 
                    # and adjust its level
 
                    self.lmbstate='levelchange'
 
                    self.startlevelchange()
 
                    
 
            else:
 
                # clicked a light that wasn't selected
 
                if not shifted:
 
                    self.clearselection()
 
                self.select(touching[0])
 
                # and adjust levels now
 
                self.lmbstate='levelchange'
 
                self.startlevelchange()
 
                
 
        if self.lmbstate=='rectangle':
 
            self.markfordynselection()
 
    def leftmotion(self,ev):
 

	
 
        coords=(ev.x,ev.y)
 

	
 
        shifted=ev.state & 1
 
        control=ev.state & 4
 

	
 
        if self.lmbstate=='deselect-or-level':
 
            if (coords[0]-self.lmbstart[0])**2+(coords[1]-self.lmbstart[1])**2>self.halo**2:
 
                # they moved enough, it's a level change
 
                self.lmbstate='levelchange'
 
                self.startlevelchange()
 

	
 
        if self.lmbstate=='levelchange':
 
            delta = self.lmbstart[1]-ev.y
 
            print "change by",delta
 
            delta = (self.lmbstart[1]-ev.y)
 
            if self.subeditor:
 
                self.subeditor.levelchange(self.selectedlights,delta)
 

	
 
        if self.lmbstate=='rectangle':
 
            sr = self.find_withtag('selectrect')
 
            if not sr:
 
                sr=self.create_rectangle( self.lmbstart[0],self.lmbstart[1],coords[0],coords[1],
 
                                          outlinestipple='gray50',outline='yellow',
 
                                          tag='selectrect')
 

	
 
            # move rectangle with mouse
 
            self.coords(sr,*(self.lmbstart+coords))
 

	
 
            # redo the dynselection with the new rectangle
 
@@ -189,24 +193,28 @@ class Stage(Canvas):
 

	
 
            if self.lmbstate=='rectangle':
 
                self.delete('selectrect')
 

	
 
            if self.lmbstate=='deselect-or-level':
 
                # they didn't move enough to promote the mode to level, so it's a deselect click
 
                self.clearselection()
 
            
 
            # all items that were in dynselection join the selection
 
#            self.incorporatedynselection()
 
            
 
        self.lmbstate=None
 
    def startlevelchange(self):
 
        self.lmbstate='levelchange'
 
        if self.subeditor:
 
            self.subeditor.startlevelchange()
 

	
 
    #
 
    # light names vs. canvas object tags
 
    #
 
    def nametag(self,name):
 
        "returns a safe version of the name that won't match other names"
 
        return name.replace(" ","__")
 

	
 
    def tagtoname(self,tag):
 
        "finds the real light name for a tag written by nametag()"
 
        return self.alllighttags[tag]
 

	
0 comments (0 inline, 0 general)