Commit 813ba87c authored by Frank Scholz's avatar Frank Scholz
Browse files

replaced the icon for the "junk" marker and added some indicator for selected and pressed buttons

parent 52a4ad17
data/menu-frame-left.png

6.36 KB | W: | H:

data/menu-frame-left.png

6.89 KB | W: | H:

data/menu-frame-left.png
data/menu-frame-left.png
data/menu-frame-left.png
data/menu-frame-left.png
  • 2-up
  • Swipe
  • Onion skin
data/menu-frame-right.png

6.43 KB | W: | H:

data/menu-frame-right.png

6.91 KB | W: | H:

data/menu-frame-right.png
data/menu-frame-right.png
data/menu-frame-right.png
data/menu-frame-right.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -55,7 +55,8 @@ class MainBackground(object):
self.screen.blit(self.background, (0, 0))
def clear_part(self, rect):
self.screen.blit(self.background, rect)
#print "background clear part", rect
self.screen.blit(self.background, rect, rect)
class Menu(object):
......@@ -65,8 +66,17 @@ class Menu(object):
self.rect = self.image.get_rect()
self.offset = 0
if location == 'right':
self.offset = 720
self.offset = 705
self.rect[0] = self.offset
self.select_frame = pygame.image.load(os.path.join('data','button-selected.png')).convert()
self.select_frame.set_colorkey((255,255,255), pygame.RLEACCEL)
self.unselect_frame = pygame.image.load(os.path.join('data','button-unselected.png')).convert()
self.unselect_frame.set_colorkey((255,255,255), pygame.RLEACCEL)
self.pressed_frame = pygame.image.load(os.path.join('data','button-pressed.png')).convert()
self.pressed_frame.set_colorkey((255,255,255), pygame.RLEACCEL)
self.screen = screen
self.background = background
......@@ -78,23 +88,69 @@ class Menu(object):
self.buttons.append(button)
self.image.blit(button.image,button.rect)
def show(self):
def show(self, pos):
if self.visible == False:
self.visible = True
self.screen.blit(self.image,self.rect)
pygame.display.update(self.rect)
if self.visible == True:
selected = None
for b in self.buttons:
if b.selected == True:
selected = b
#print "selected", selected.rect
for b in self.buttons:
if b.rect.collidepoint(pos[0]-self.rect[0],pos[1]):
if b.action == None:
return
#print "we have a touchdown"
if selected is not b:
#print "selected is not b"
if selected is not None:
#print "remove old select frame"
self.image.blit(self.unselect_frame,(selected.rect[0]-3,selected.rect[1]-3,54,54))
self.screen.blit(self.unselect_frame,(selected.rect[0]+self.offset-3,selected.rect[1]-3,54,54))
pygame.display.update((selected.rect[0]+self.offset-3,selected.rect[1]-3,54,54))
#print "draw new select frame"
self.image.blit(self.select_frame,(b.rect[0]-3,b.rect[1]-3,54,54))
self.screen.blit(self.select_frame,(b.rect[0]+self.offset-3,b.rect[1]-3,54,54))
pygame.display.update((b.rect[0]+self.offset-3,b.rect[1]-3,54,54))
b.selected = True
return
if selected is not None:
#print "clear old select frame"
self.image.blit(self.unselect_frame,(selected.rect[0]-3,selected.rect[1]-3,54,54))
self.screen.blit(self.unselect_frame,(selected.rect[0]+self.offset-3,selected.rect[1]-3,54,54))
pygame.display.update((selected.rect[0]+self.offset-3,selected.rect[1]-3,54,54))
selected.selected = False
def hide(self):
if self.visible == True:
self.visible = False
self.background.clear_part(self.rect)
pygame.display.update(self.rect)
for b in self.buttons:
if b.selected == True:
self.image.blit(self.unselect_frame,(b.rect[0]-3,b.rect[1]-3,54,54))
def check(self, button, pos):
if self.visible == False:
return None
def clear_pressed(pressed):
if pressed.selected == True:
self.image.blit(self.select_frame,(pressed.rect[0]-3,pressed.rect[1]-3,54,54))
self.screen.blit(self.select_frame,(pressed.rect[0]+self.offset-3,pressed.rect[1]-3,54,54))
pygame.display.update((pressed.rect[0]+self.offset-3,pressed.rect[1]-3,54,54))
for b in self.buttons:
if b.rect.collidepoint(pos[0]-self.rect[0],pos[1]):
if( b.rect.collidepoint(pos[0]-self.rect[0],pos[1]) and
b.action is not None):
self.image.blit(self.pressed_frame,(b.rect[0]-3,b.rect[1]-3,54,54))
self.screen.blit(self.pressed_frame,(b.rect[0]+self.offset-3,b.rect[1]-3,54,54))
pygame.display.update((b.rect[0]+self.offset-3,b.rect[1]-3,54,54))
reactor.callLater(2,clear_pressed, b)
b.call()
def toggle(self, image, rect):
......@@ -114,6 +170,7 @@ class Button(object):
self.rect[0] = position[0]
self.rect[1] = position[1]
self.action = action
self.selected = False
if alt_imagefile is not None:
self.alt_image = pygame.image.load(os.path.join('data',alt_imagefile)).convert()
......@@ -148,16 +205,16 @@ class MediaRenderer(object):
self.mainbg = MainBackground(self.screen, SCREENRECT)
self.mainbg.clear_screen()
buttons = (('return.png',(2,50),None,None),
('server-scan.png',(16,216),None,None),
('exit.png',(0,380),self.quit,None))
buttons = (('return.png',(4,50),None,None),
('server-scan.png',(22,216),None,None),
('exit.png',(4,380),self.quit,None))
self.left_menu = Menu('left', buttons,
self.screen, self.mainbg)
buttons = (('save.png',(30,50),None,None),
('backward.png',(16,140),self.proceed_to_previous_image,None),
('pause.png',(16,216),self.pause,'play.png'),
('forward.png',(16,300),self.proceed_to_next_image,None),
('trash.png',(30,380),None,None))
buttons = (('save.png',(44,50),None,None),
('backward.png',(31,140),self.proceed_to_previous_image,None),
('pause.png',(31,216),self.pause,'play.png'),
('forward.png',(31,300),self.proceed_to_next_image,None),
('mark-junk.png',(44,380),None,None))
self.right_menu = Menu('right', buttons, self.screen, self.mainbg)
config = {}
......@@ -195,7 +252,7 @@ class MediaRenderer(object):
else:
self.fullscreen = 1
self.screen = pygame.display.set_mode(SCREENRECT.size, self.fullscreen, self.bestdepth)
self.mainbg.clear_part()
self.mainbg.clear_screen()
pygame.display.update(self.displaying)
self.displaying = self.current_image.get_rect(center=((self.screen.get_width()/2)-1,(self.screen.get_height()/2)-1))
self.screen.blit(self.current_image,self.displaying)
......@@ -260,6 +317,7 @@ class MediaRenderer(object):
if transform is not None:
self.current_image = pygame.transform.scale(self.current_image, transform)
if self.displaying is not None:
#print "clear old image", self.displaying
self.mainbg.clear_part(self.displaying)
pygame.display.update(self.displaying)
self.displaying = self.current_image.get_rect(center=((self.screen.get_width()/2)-1,(self.screen.get_height()/2)-1))
......@@ -348,10 +406,10 @@ class MediaRenderer(object):
if event.type == MOUSEMOTION:
if event.pos[0] <= 70:
"""left hotspot """
self.left_menu.show()
self.left_menu.show(event.pos)
elif event.pos[0] > 730:
"""right hotspot """
self.right_menu.show()
self.right_menu.show(event.pos)
else:
self.right_menu.hide()
self.left_menu.hide()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment