Changeset 75
- Timestamp:
- 03/23/08 03:40:42 (8 months ago)
- Files:
-
- mactorii.py (modified) (10 diffs)
- resizer.jpg (added)
- resizer.xcf (added)
- setup.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
mactorii.py
r74 r75 65 65 66 66 root = None 67 67 68 68 def on_mouse_motion(self,x,y,dx,dy): 69 69 self.hoverx = x … … 281 281 282 282 # 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) 285 284 286 285 # add to our dictionary … … 299 298 win.push_handlers(self.on_mouse_release) 300 299 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 303 304 return win 304 305 … … 369 370 assert ft != None 370 371 372 # generate our oft used black background 371 373 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 373 379 clock.set_fps_limit(config.fps) 374 380 381 # start loading files 375 382 self.win.set_visible() 376 383 self.unloaded = list(self.files) 377 378 384 self.update_renderables() 379 385 print "loading %d files"%(len(self.unloaded)) … … 402 408 # raise Exception 403 409 pass 404 410 411 # if we need to display a full image, do so 405 412 if self.display_picture != None: 406 413 w = self.display_picture.width … … 409 416 self.win.flip() 410 417 continue 411 418 419 # adjust the xoffset if required 412 420 if self.xmotion < 0: 413 421 if self.strip_width() + self.xoffset > self.win.width: … … 417 425 if self.xoffset < 0: 418 426 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 422 432 x = self.xoffset 423 433 y = self.yoffset … … 433 443 img.blit(x,y) 434 444 445 # if the cursor is over this tile, render some information 435 446 if self.is_over_image(x,y,self.hoverx, self.hovery) and (not pix_name or filename != pix_name.text): 436 447 # draw some information 437 448 pix_size = font.Text(ft,"%dx%d"%(image[1][0], image[1][1]), x, y+config.text_yoffset) 438 449 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 440 453 w = max(pix_size.width, pix_name.width) 441 454 w = max(config.crop_size, (w/config.crop_size+1)*config.crop_size) … … 446 459 blit_position=(x, y) 447 460 461 # remember which image we are hovering over so when a click is seen 462 # we know which image to display 448 463 self.hovering_over = filename 449 464 … … 455 470 y = self.yoffset 456 471 472 # everything drawn here is drawn over everything else 457 473 if self.fps_display: 458 474 self.fps_display.draw() 475 459 476 if self.hovering_over: 460 477 text_bg.blit(blit_position[0], blit_position[1]) 461 478 pix_name.draw() 462 479 pix_size.draw() 463 480 481 w = self.win.width 482 h = 0 483 w = w - resizer.width 484 resizer.blit(w,h) 485 464 486 self.win.flip() 465 487 488 def 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 466 492 if __name__ == '__main__': 467 493 app = MactoriiApplication() setup.py
r74 r75 13 13 14 14 15 import config15 import mactorii 16 16 17 17 APP = ['mactorii.py'] 18 18 OPTIONS = {'argv_emulation': True, 'iconfile': 'mactorii.icns'} 19 DATA_FILES = ['resizer.jpg'] 19 20 20 21 if sys.platform == "darwin": … … 24 25 25 26 setup( 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, 32 33 app=APP, 33 34 name="mactorii",
