1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 import pgm
18 from pgm.graph.text import Text
19 from pgm.graph.image import Image
20
21 from progressbar_osd import ProgressBarOsd
22 from dock import Dock
23
24 import time, os
25
26
27
29
30 - def __init__(self, canvas, layer,
31 playing_length,
32 width, height,
33 bar_bg_image, bar_fg_image,
34 background_image):
35
36 Dock.__init__(self, canvas, layer, width, height, background_image)
37
38 self._time_position = 0
39 self._time_string = ""
40
41 inner_width = width * 0.9
42 inner_x = (width - inner_width)/2.0
43
44
45
46 self._title = Text()
47 self._title.label = ""
48
49 self._title.ellipsize = pgm.TEXT_ELLIPSIZE_MIDDLE
50 self._title.fg_color = (220, 220, 220, 255)
51 self._title.bg_color = (0, 0, 0, 0)
52 self.add(self._title)
53 self._title.position = (inner_x, 0.05, 0.0)
54 self._title.size = (inner_width, height*0.33)
55 self._title.font_height = self._title.height
56
57
58 self._timebar = ProgressBarOsd(canvas, layer, playing_length,
59 bar_bg_image, bar_fg_image)
60 self._timebar.bg_color = (0, 0, 0, 0)
61 self.add(self._timebar)
62 self._timebar.position = (inner_x, height*(0.33+0.15), 0.0)
63 self._timebar.size = (inner_width, height*0.2)
64 self._timebar.visible = False
65
66
67 self._time = Text()
68 self._time.label = ""
69
70 self._time.fg_color = (255, 255, 255, 255)
71 self._time.bg_color = (0, 0, 0, 0)
72 self._time.alignment = pgm.TEXT_ALIGN_RIGHT
73 self.add(self._time)
74 self._time.position = (inner_x, height*(0.33+0.2+0.15), 0.001)
75 self._time.size = (inner_width, height*0.2)
76 self._time.font_height = self._time.height
77 self._time.visible = False
78
79 self._title.visible = True
80
81 self.length = playing_length
82
84 """
85 Set the length of the medias
86 """
87 self._timebar.length = length
88 if length > 1:
89 self._timebar.visible = True
90 self._show_position()
91 else:
92 self._timebar.visible = False
93
95 """
96 Get the length of the medias
97 """
98 return self._timebar.length
99
100
102 """
103 Set the title of the dock
104 @param title: the name of a movie or a audio file
105 @type title: string
106 """
107 self._title.label = title
108
109
111 """
112 Get the current title of the dock
113 """
114 return self._title.label
115
124
126 """
127 Get the current position
128 """
129 return self._time_position
130
133