More work on Video player display. Now includes relatively completed details panel

This commit is contained in:
noisymime 2007-09-04 23:14:46 +00:00
parent f5869b3dff
commit f844d9e1f4
2 changed files with 92 additions and 13 deletions

View File

@ -64,9 +64,10 @@ class VideoPlayer():
self.cover_viewer.show_all()
self.cover_viewer.show()
self.stage.add(self.cover_viewer)
self.cover_viewer.toggle_details() #Turns the details group on
cover_x = self.stage.get_width() - self.cover_viewer.get_width()
self.cover_viewer.set_position(cover_x, 0)
self.cover_viewer.set_position(cover_x, 40)
self.cover_viewer.toggle_details() #Turns the details group on
self.cover_viewer.select_first()
begin_behaviour.apply(self.cover_viewer)
timeline_begin.start()
@ -131,6 +132,7 @@ class coverViewer(clutter.Group):
self.videoLibrary = []
self.textureLibrary = []
self.current_video_details = video_details_group(width)
self.covers_group = clutter.Group()
self.num_covers = 0
self.cover_gap = 1
@ -145,6 +147,9 @@ class coverViewer(clutter.Group):
self.currentSelection = 0
self.add(self.covers_group)
self.covers_group.show()
#self.stage.add(self.current_video_description)
self.current_video_details.show()
self.current_video_details.show_all()
@ -153,6 +158,12 @@ class coverViewer(clutter.Group):
def toggle_details(self):
if self.current_video_details.get_parent() == None:
self.stage.add(self.current_video_details)
#Set the position of the details group
(pos_x, pos_y) = self.get_abs_position()
#The next two lines are horribly ugly, but all they do is position the details viewer in the middle of the gap between the bottom of the visible cover viewer and the bottom of the stage
viewer_lower_y = int(pos_y + (self.max_visible_rows * self.cover_size))
pos_y = viewer_lower_y + int( (self.stage.get_height() - viewer_lower_y) / 2 - int(self.current_video_details.get_height()/2))
self.current_video_details.set_position(pos_x, pos_y)
else:
self.stage.remove(self.current_video_details)
@ -188,7 +199,8 @@ class coverViewer(clutter.Group):
if self.num_covers > (self.num_columns * self.num_visible_rows)-1:
tempTexture.set_opacity(0)
self.add(tempTexture)
self.covers_group.add(tempTexture)
tempTexture.show()
self.num_covers = self.num_covers +1
def select_item(self, incomingItem, outgoingItem):
@ -196,10 +208,13 @@ class coverViewer(clutter.Group):
self.timeline = clutter.Timeline(20,80)
#Check if the cover is currently not visible
rolling = False
if incomingItem > (self.num_columns * self.max_visible_rows-1):
self.rollViewer(True, self.timeline)
rolling = True
if incomingItem < (self.num_columns * self.min_visible_rows):
self.rollViewer(False, self.timeline)
rolling = True
outgoingTexture = self.textureLibrary[outgoingItem]
incomingTexture = self.textureLibrary[incomingItem]
@ -207,7 +222,11 @@ class coverViewer(clutter.Group):
alpha = clutter.Alpha(self.timeline, clutter.ramp_inc_func)
behaviourNew_scale = clutter.BehaviourScale(alpha, 1, self.scaleFactor, clutter.GRAVITY_CENTER)
behaviourNew_z = clutter.BehaviourDepth(alpha, 1, 2)
behaviourNew_opacity = clutter.BehaviourOpacity(alpha, self.inactiveOpacity, 255)
#If we're performing a roll (See above) then the incoming opacity should start at 0 rather than the normal inactive opacity
if rolling:
behaviourNew_opacity = clutter.BehaviourOpacity(alpha, 0, 255)
else:
behaviourNew_opacity = clutter.BehaviourOpacity(alpha, self.inactiveOpacity, 255)
behaviourOld_scale = clutter.BehaviourScale(alpha, self.scaleFactor, 1, clutter.GRAVITY_CENTER)
behaviourOld_z = clutter.BehaviourDepth(alpha, 2, 1)
@ -224,6 +243,25 @@ class coverViewer(clutter.Group):
self.timeline.start()
def select_first(self):
self.current_video_details.set_video(self.videoLibrary[0])
self.timeline = clutter.Timeline(20,80)
incomingItem = 0
incomingTexture = self.textureLibrary[incomingItem]
alpha = clutter.Alpha(self.timeline, clutter.ramp_inc_func)
behaviourNew_scale = clutter.BehaviourScale(alpha, 1, self.scaleFactor, clutter.GRAVITY_CENTER)
behaviourNew_z = clutter.BehaviourDepth(alpha, 1, 2)
behaviourNew_opacity = clutter.BehaviourOpacity(alpha, self.inactiveOpacity, 255)
behaviourNew_scale.apply(incomingTexture)
behaviourNew_z.apply(incomingTexture)
behaviourNew_opacity.apply(incomingTexture)
self.currentSelection = incomingItem
self.timeline.start()
#This moves the visible row of covers up and down
# moveUp: True if the covers are to come up, false if they're to go down
def rollViewer(self, moveUp, timeline):
@ -299,22 +337,63 @@ class coverViewer(clutter.Group):
class video_details_group(clutter.Group):
font = "Lucida Grande "
header_font_size = 30
main_font_size = 24
title_font_size = 30
main_font_size = 22
plot_font_size = 18
def __init__(self, desired_width):
clutter.Group.__init__(self)
self.width = desired_width
#Add the various labels
self.heading = clutter.Label()
self.heading.set_font_name(self.font + str(self.header_font_size))
self.heading.set_color(clutter.color_parse('White'))
self.heading.set_ellipsize(pango.ELLIPSIZE_END)
self.add(self.heading)
self.title = clutter.Label()
self.title.set_font_name(self.font + str(self.title_font_size))
self.title.set_color(clutter.color_parse('White'))
self.title.set_text("")
self.title.set_ellipsize(pango.ELLIPSIZE_END)
self.add(self.title)
#Not sure how to get the row height before the text is set :(
self.row_gap = self.title.get_height()
self.year = clutter.Label()
self.year.set_font_name(self.font + str(self.main_font_size))
self.year.set_color(clutter.color_parse('White'))
self.year.set_text("")
self.year.set_opacity(220)
self.year.set_ellipsize(pango.ELLIPSIZE_END)
self.year.set_position(0, self.row_gap)
self.add(self.year)
self.director = clutter.Label()
self.director.set_font_name(self.font + str(self.main_font_size))
self.director.set_color(clutter.color_parse('White'))
self.director.set_text("")
self.director.set_opacity(220)
self.director.set_ellipsize(pango.ELLIPSIZE_END)
self.director.set_position(int(self.year.get_width()), self.row_gap)
self.add(self.director)
self.plot = clutter.Label()
self.plot.set_font_name(self.font + str(self.plot_font_size))
self.plot.set_color(clutter.color_parse('White'))
self.plot.set_text("")
self.plot.set_opacity(220)
#self.plot.set_ellipsize(pango.ELLIPSIZE_END)
self.plot.set_position(0, int(self.row_gap*2))
self.add(self.plot)
self.show_all()
def set_video(self, video):
self.heading.set_text(video.title)
self.heading.set_width(self.width)
self.title.set_text(video.title)
self.title.set_width(self.width)
self.year.set_text("Year: " + str(video.year))
self.director.set_text(" Director: " + str(video.director))
self.director.set_position(int(self.year.get_width()), self.row_gap)
self.director.set_width(int(self.width - self.year.get_width()))
self.plot.set_text(video.plot)
self.plot.set_width(self.width)

Binary file not shown.