Changeset 75

Show
Ignore:
Timestamp:
03/23/08 03:40:42 (8 months ago)
Author:
steve
Message:

added resize handle, so we don't have the "invisible resize handle" bug

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • mactorii.py

    r74 r75  
    6565 
    6666        root = None 
    67  
     67         
    6868        def on_mouse_motion(self,x,y,dx,dy): 
    6969                self.hoverx = x 
     
    281281                 
    282282                # make a pyglet image out of it 
    283                 im = im.transpose(Image.FLIP_TOP_BOTTOM) 
    284                 psurf=pyglet_image.ImageData(im.size[0],im.size[1],"RGB",im.tostring()) 
     283                psurf = image_to_psurf(im) 
    285284                 
    286285                # add to our dictionary 
     
    299298                win.push_handlers(self.on_mouse_release) 
    300299                win.push_handlers(self.on_mouse_motion) 
    301  
    302  
     300                 
     301                glEnable(GL_BLEND)  
     302                glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)  
     303                 
    303304                return win 
    304305                 
     
    369370                assert ft != None 
    370371                 
     372                # generate our oft used black background 
    371373                image_pattern = pyglet_image.SolidColorImagePattern((0,0,0,1)) 
    372                  
     374         
     375                # load the resizer graphic 
     376                resizer = image_to_psurf(Image.open('resizer.jpg')) 
     377 
     378                # limit fps to reduce cpu usage 
    373379                clock.set_fps_limit(config.fps) 
    374                  
     380         
     381                # start loading files 
    375382                self.win.set_visible() 
    376383                self.unloaded = list(self.files) 
    377                  
    378384                self.update_renderables() 
    379385                print "loading %d files"%(len(self.unloaded)) 
     
    402408                                # raise Exception 
    403409                                pass 
    404                                  
     410                         
     411                        # if we need to display a full image, do so 
    405412                        if self.display_picture != None: 
    406413                                w = self.display_picture.width 
     
    409416                                self.win.flip() 
    410417                                continue 
    411                                  
     418                         
     419                        # adjust the xoffset if required                 
    412420                        if self.xmotion < 0: 
    413421                                if self.strip_width() + self.xoffset > self.win.width: 
     
    417425                                if self.xoffset < 0: 
    418426                                        self.xoffset+=self.xmotion * time_passed / config.xmotion_time  
    419                         if self.xoffset > 0: 
    420                                 self.xoffset = 0 
    421                                                  
     427 
     428                        # clamp xoffset to 0 if xoffset is > 0 
     429                        self.xoffset = min(self.xoffset, 0) 
     430                         
     431                        # render the tiles 
    422432                        x = self.xoffset  
    423433                        y = self.yoffset 
     
    433443                                        img.blit(x,y)                            
    434444                                         
     445                                        # if the cursor is over this tile, render some information 
    435446                                        if self.is_over_image(x,y,self.hoverx, self.hovery) and (not pix_name or filename != pix_name.text): 
    436447                                                # draw some information 
    437448                                                pix_size = font.Text(ft,"%dx%d"%(image[1][0], image[1][1]), x, y+config.text_yoffset) 
    438449                                                pix_name = font.Text(ft, self.to_unicode(os.path.basename(filename)), x, y+config.text_yoffset+int(pix_size.height))                                             
    439  
     450                                                 
     451                                                # calculate the black background required to make text show up 
     452                                                # width needs to be in integer multiples of tile size 
    440453                                                w = max(pix_size.width, pix_name.width) 
    441454                                                w = max(config.crop_size, (w/config.crop_size+1)*config.crop_size) 
     
    446459                                                blit_position=(x, y) 
    447460                                         
     461                                                # remember which image we are hovering over so when a click is seen 
     462                                                # we know which image to display  
    448463                                                self.hovering_over = filename 
    449464 
     
    455470                                        y = self.yoffset 
    456471 
     472                        # everything drawn here is drawn over everything else 
    457473                        if self.fps_display: 
    458474                                self.fps_display.draw() 
     475                         
    459476                        if self.hovering_over: 
    460477                                text_bg.blit(blit_position[0], blit_position[1]) 
    461478                                pix_name.draw() 
    462479                                pix_size.draw() 
    463                                  
     480                 
     481                        w = self.win.width 
     482                        h = 0 
     483                        w = w - resizer.width 
     484                        resizer.blit(w,h) 
     485 
    464486                        self.win.flip() 
    465487         
     488def     image_to_psurf(im): 
     489        im = im.transpose(Image.FLIP_TOP_BOTTOM) 
     490        return pyglet_image.ImageData(im.size[0],im.size[1],"RGB",im.tostring()) 
     491 
    466492if __name__ == '__main__': 
    467493        app = MactoriiApplication() 
  • setup.py

    r74 r75  
    1313 
    1414 
    15 import config 
     15import mactorii 
    1616 
    1717APP = ['mactorii.py'] 
    1818OPTIONS = {'argv_emulation': True, 'iconfile': 'mactorii.icns'} 
     19DATA_FILES = ['resizer.jpg'] 
    1920 
    2021if sys.platform == "darwin": 
     
    2425 
    2526setup( 
    26    version=mactorii.version, 
    27    description='Image browser with sort, cluster ability based on wavelet transforms', 
    28    author='Shu Ning Bian', 
    29    author_email='freespace@gmail.com', 
    30    url='http://trac.pictorii.com/mactorii/', 
    31      
     27       version=mactorii.version, 
     28       description='Image browser with sort, cluster ability based on wavelet transforms', 
     29       author='Shu Ning Bian', 
     30       author_email='freespace@gmail.com', 
     31       url='http://trac.pictorii.com/mactorii/', 
     32       data_files = DATA_FILES,  
    3233    app=APP, 
    3334        name="mactorii",