Merge lp:~samuel-buffet/entertainer/more_base_on_widgets into lp:entertainer
- more_base_on_widgets
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Matt Layman |
Approved revision: | 394 |
Merged at revision: | not available |
Proposed branch: | lp:~samuel-buffet/entertainer/more_base_on_widgets |
Merge into: | lp:entertainer |
Diff against target: | None lines |
To merge this branch: | bzr merge lp:~samuel-buffet/entertainer/more_base_on_widgets |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Matt Layman | Approve | ||
Review via email: mp+8092@code.launchpad.net |
Commit message
More widgets now inherit from the Base Class.
Description of the change
Samuel Buffet (samuel-buffet) wrote : | # |
Matt Layman (mblayman) wrote : | # |
Sweet, this is exactly the kind of clean up that I had envisioned doing with the rest of the widgets, but I never got around to it. Thanks for picking up that torch and running with it.
I didn't want to approve this branch immediately because I don't want Tarmac to auto-land it, but my comments that need fixing are very minor. Nice job.
I'm assuming that you've done some visual inspection of your changes to make sure things looked the same before and after your modifications.
GLOBAL:
* Please kill or improve the init docstrings for the widget classes. Some are flat out wrong and most have the @param doxygen stuff that we aren't using.
* What do you think about killing off the creat_indicator type methods that are in many of the screens? Those methods don't seem to do anything special that can't be done in init (especially since you've greatly simplified their creation).
album.py audio_play.py disc.py feed.py movie.py photo_albums.py photographs.py rss.py tv_episodes.py albums_tab.py artists_tab.py lyrics_tab.py movies_tab.py series_tab.py tracks_tab.py video_clips_tab.py arrow_texture.py eyecandy_
* No comments.
list_indicator.py:
* I'm not sure about the modification for the "text_x_pos = width / 3" code. If I remember correctly, I think I set the code that way because the horizontal vs vertical orientation caused different spacing issues. Have you checked both? Have you checked both when there are many values in the indicator (e.g., some amount over 100)? You may have considered all these things and everything may be functioning perfectly, but I just wanted to highlight this because my brained raised a red flag when I saw those lines of code.
loading_
* set_anchor_point in init has incorrect spacing around the / characters.
reflection_
* No comments.
rounded_texture.py:
* Is there a better variable than xx and yy? Those names are pretty vague.
scroll_area.py test_arrowtextu
* No comments.
test_eyecandyte
* Import order is incorrect. os is a core module but gtk is not.
test_listindica
* No comments.
test_reflection
* Import order is incorrect. os is a core module but gtk is not.
- 393. By Samuel Buffet
-
Fixes after Matt's comments.
Samuel Buffet (samuel-buffet) wrote : | # |
Matt,
> I'm assuming that you've done some visual inspection of your changes to make
> sure things looked the same before and after your modifications.
Yes I've checked visually everything. There result is roughly the same but not exactly the same but I think that globally it's slightly improved. I remember to have made the LoadingAnimation on disc.py MUCH bigger.
> GLOBAL:
> * Please kill or improve the init docstrings for the widget classes. Some are
> flat out wrong and most have the @param doxygen stuff that we aren't using.
Removed.
> * What do you think about killing off the creat_indicator type methods that
> are in many of the screens? Those methods don't seem to do anything special
> that can't be done in init (especially since you've greatly simplified their
> creation).
Well I'm all for that. Was about to suggest that to you in fact :)
But I'd prefer to do that in another branch. I don't like to mix everything as you may have noticed. It's MUCH more easy to resolve merge conflicts when a branch does one and only one thing at the same time.
> list_indicator.py:
> * I'm not sure about the modification for the "text_x_pos = width / 3" code.
> If I remember correctly, I think I set the code that way because the
> horizontal vs vertical orientation caused different spacing issues. Have you
> checked both? Have you checked both when there are many values in the
> indicator (e.g., some amount over 100)? You may have considered all these
> things and everything may be functioning perfectly, but I just wanted to
> highlight this because my brained raised a red flag when I saw those lines of
> code.
Well, this modification gives better results on my screen but it may not be the same on yours. Could you please compare and report your result here? Thanks.
> loading_
> * set_anchor_point in init has incorrect spacing around the / characters.
Yeah, /2 is now / 2
> rounded_texture.py:
> * Is there a better variable than xx and yy? Those names are pretty vague.
Those variables were useless. I've simply removed them.
> test_eyecandyte
> * Import order is incorrect. os is a core module but gtk is not.
>
> test_reflection
> * Import order is incorrect. os is a core module but gtk is not.
Fixed.
Thanks for you review Matt.
Samuel-
Samuel Buffet (samuel-buffet) wrote : | # |
incremental diff:
=== modified file 'entertainerlib
--- entertainerlib/
+++ entertainerlib/
@@ -17,14 +17,6 @@
ARC_TO_BEZIER = 0.55228475
def __init__(self, x, y, size, fg_color, bg_color, direction):
- """
- Initialize ArrowTexture
- @param size: Width and height of the texture
- @param fg_color: Foreground color (arrows)
- @param bg_color: Background color (background)
- @param direction: Arrow direction UP,DOWN,RIGHT or LEFT (class
- constant)
- """
abs_size = self.get_
=== modified file 'entertainerlib
--- entertainerlib/
+++ entertainerlib/
@@ -16,10 +16,6 @@
"""
def __init__(self, x, y, width, height, pixbuf):
- """
- Initialize new eye candy texture
- @param imagefile: Absoulte path to PNG file
- """
=== modified file 'entertainerlib
--- entertainerlib/
+++ entertainerlib/
@@ -20,12 +20,6 @@
VERTICAL = 1
def __init__(self, x, y, width, height, direction):
- """
- Initialize actor.
- @param width: Width of the widget in percentage (0-1)
- @param height: Height of the widget in percentage (0-1)
- @param direction: Direction (constant of this class)
- """
@@ -46,7 +40,7 @@
text_x_pos = width / 3
- self.text = Label(height * 0.8, "text", text_x_pos, (height / 2),
+ self.text = Label(height * 0.8, "text", text_x_pos, height / 2,
=== modified file 'entertainerlib
--- entertainerlib/
+++ entertainerlib/
@@ -18,22 +18,13 @@
def __init__(self, x, y, size=0.03, inner_radius=0.25, outter_radius=0.45,
- """
- Initialize LoadingAnimation
- @param size: Width and height of the texture
- @param fg_color: Foreground color
- @param bg_color: Background color
- @param inner_radius: Distance from origo to line start point 0-1
- @param outter_radius: Distance from origo to line end point 0-1
- @param thinkness: Lines thickness 0-1
- """
abs_size = self.get_
- 394. By Samuel Buffet
-
Back to previous behaviour of text_x_pos in list_indicator.py.
Matt Layman (mblayman) wrote : | # |
Things look good now.
Paul Hummer (rockstar) wrote : | # |
`which trial` entertainerlib.
entertainerlib.
ArrowTextureTest
test_bounce ... /home/rockstar/
/home/rockstar/
/home/rockstar/
/home/rockstar/
test_create ... [ERROR]
entertainerlib.
BaseTest
testCreate ... [OK]
testGetAbsX ... [ERROR]
testGetAbsY ... [ERROR]
entertainerlib.
ConfigurationTest
testBorg ... [OK]
testCreate ... [OK]
testGetCfgDir ... [OK]
testGetSlid
testGetStag
testGetStag
testGetThem
testSetStag
testSetStag
testStartAu
testTrayIco
test_create_dir ... [OK]
test_
test_sanitize ... [ERROR]
test_taint ... [OK]
test_
test_
test_
entertainerlib.
ConnectionSer
testPortBinding ... [OK]
entertainerlib.
DatabaseTest
testCreate ... [OK]
testUseExisting ... [OK]
entertainerlib.
EyeCandyTextu
test_create ... [ERROR]
entertainerlib.
FeedConfigTo...
Preview Diff
1 | === modified file 'entertainerlib/frontend/gui/screens/album.py' |
2 | --- entertainerlib/frontend/gui/screens/album.py 2009-05-06 03:40:22 +0000 |
3 | +++ entertainerlib/frontend/gui/screens/album.py 2009-05-10 07:43:27 +0000 |
4 | @@ -39,13 +39,8 @@ |
5 | self.add(self.screen_title) |
6 | |
7 | #List indicator |
8 | - self.li = ListIndicator(0.2, 0.045, ListIndicator.VERTICAL) |
9 | - self.li.set_position(self.config.get_stage_width() - \ |
10 | - self.li.get_width() - self.get_abs_x(0.066), |
11 | - self.config.get_stage_height() - self.get_abs_y(0.11)) |
12 | - self.li.set_delimiter(" | ") |
13 | + self.li = ListIndicator(0.74, 0.8, 0.2, 0.045, ListIndicator.VERTICAL) |
14 | self.li.set_maximum(self.track_menu.get_number_of_items()) |
15 | - self.li.set_current(1) |
16 | self.add(self.li) |
17 | |
18 | def _create_album_cover_texture(self): |
19 | @@ -59,9 +54,7 @@ |
20 | else: |
21 | pixbuf = gtk.gdk.pixbuf_new_from_file( |
22 | self.theme.getImage("default_album_art")) |
23 | - self.art = EyeCandyTexture(pixbuf, self.get_abs_x(0.3148), |
24 | - self.get_abs_y(0.5599)) |
25 | - self.art.set_position(self.get_abs_x(0.1), self.get_abs_y(0.13)) |
26 | + self.art = EyeCandyTexture(0.1, 0.13, 0.3148, 0.5599, pixbuf) |
27 | self.art.set_rotation(clutter.Y_AXIS, 25, 0, 0, 0) |
28 | self.add(self.art) |
29 | |
30 | |
31 | === modified file 'entertainerlib/frontend/gui/screens/audio_play.py' |
32 | --- entertainerlib/frontend/gui/screens/audio_play.py 2009-05-26 17:32:56 +0000 |
33 | +++ entertainerlib/frontend/gui/screens/audio_play.py 2009-05-28 20:23:17 +0000 |
34 | @@ -26,9 +26,7 @@ |
35 | else: |
36 | pixbuf = gtk.gdk.pixbuf_new_from_file( |
37 | self.theme.getImage("default_album_art")) |
38 | - self.art = EyeCandyTexture(pixbuf, self.get_abs_x(0.3148), |
39 | - self.get_abs_y(0.5599)) |
40 | - self.art.set_position(self.get_abs_x(0.1), self.get_abs_y(0.22)) |
41 | + self.art = EyeCandyTexture(0.1, 0.22, 0.3148, 0.5599, pixbuf) |
42 | self.art.set_rotation(clutter.Y_AXIS, 25, 0, 0, 0) |
43 | self.add(self.art) |
44 | |
45 | |
46 | === modified file 'entertainerlib/frontend/gui/screens/disc.py' |
47 | --- entertainerlib/frontend/gui/screens/disc.py 2009-05-06 03:40:22 +0000 |
48 | +++ entertainerlib/frontend/gui/screens/disc.py 2009-05-10 07:43:27 +0000 |
49 | @@ -47,9 +47,7 @@ |
50 | self.add(screen_title) |
51 | |
52 | # Display throbber animation while loading CD metadata |
53 | - self.throbber = LoadingAnimation(40, clutter.Color(255, 255, 255, 255), |
54 | - clutter.Color(128, 128, 128, 128)) |
55 | - self.throbber.set_position(self.get_abs_x(0.5), self.get_abs_y(0.5)) |
56 | + self.throbber = LoadingAnimation(0.5, 0.5, 0.1) |
57 | self.throbber.show() |
58 | self.add(self.throbber) |
59 | |
60 | @@ -145,9 +143,7 @@ |
61 | pixbuf = gtk.gdk.pixbuf_new_from_file(coverfile) |
62 | else: |
63 | pixbuf = gtk.gdk.pixbuf_new_from_file(self.theme.getImage("disc")) |
64 | - self.art = EyeCandyTexture(pixbuf, self.get_abs_x(0.3148), |
65 | - self.get_abs_y(0.5599)) |
66 | - self.art.set_position(self.get_abs_x(0.1), self.get_abs_y(0.13)) |
67 | + self.art = EyeCandyTexture(0.1, 0.13, 0.3148, 0.5599, pixbuf) |
68 | self.art.set_rotation(clutter.Y_AXIS, 25, 0, 0, 0) |
69 | self.add(self.art) |
70 | |
71 | @@ -194,14 +190,8 @@ |
72 | self.add(self.track_menu) |
73 | |
74 | def _create_list_indicator(self): |
75 | - """ |
76 | - Create list indicator widget |
77 | - """ |
78 | - self.li = ListIndicator(0.2, 0.045, ListIndicator.VERTICAL) |
79 | - self.li.set_position(self.config.get_stage_width() - \ |
80 | - self.li.get_width() - self.get_abs_x(0.06589), |
81 | - self.config.get_stage_height() - self.get_abs_y(0.1953)) |
82 | - self.li.set_delimiter(" | ") |
83 | + '''Create list indicator for track list.''' |
84 | + self.li = ListIndicator(0.75, 0.8, 0.2, 0.045, ListIndicator.VERTICAL) |
85 | self.li.set_maximum(self.track_menu.get_number_of_items()) |
86 | self.add(self.li) |
87 | |
88 | |
89 | === modified file 'entertainerlib/frontend/gui/screens/feed.py' |
90 | --- entertainerlib/frontend/gui/screens/feed.py 2009-06-15 03:19:46 +0000 |
91 | +++ entertainerlib/frontend/gui/screens/feed.py 2009-06-25 19:06:28 +0000 |
92 | @@ -55,13 +55,8 @@ |
93 | self.add(date) |
94 | |
95 | #List indicator |
96 | - self.li = ListIndicator(0.2, 0.045, ListIndicator.VERTICAL) |
97 | - self.li.set_position(self.get_abs_x(0.7562) - self.li.get_width(), |
98 | - self.config.get_stage_height() - self.li.get_height() - \ |
99 | - self.get_abs_y(0.03906)) |
100 | - self.li.set_delimiter(" | ") |
101 | + self.li = ListIndicator(0.57, 0.9, 0.2, 0.045, ListIndicator.VERTICAL) |
102 | self.li.set_maximum(self.menu.get_number_of_items()) |
103 | - self.li.set_current(1) |
104 | self.add(self.li) |
105 | |
106 | def _create_entry_menu(self): |
107 | |
108 | === modified file 'entertainerlib/frontend/gui/screens/movie.py' |
109 | --- entertainerlib/frontend/gui/screens/movie.py 2009-06-02 10:24:20 +0000 |
110 | +++ entertainerlib/frontend/gui/screens/movie.py 2009-06-05 05:10:21 +0000 |
111 | @@ -52,9 +52,7 @@ |
112 | else: |
113 | pixbuf = gtk.gdk.pixbuf_new_from_file( |
114 | self.theme.getImage("default_movie_art")) |
115 | - movie_art = EyeCandyTexture(pixbuf, self.get_abs_x(0.1), |
116 | - self.get_abs_y(0.25)) |
117 | - movie_art.set_position(self.get_abs_x(0.33), self.get_abs_y(0.1)) |
118 | + movie_art = EyeCandyTexture(0.33, 0.1, 0.1, 0.25, pixbuf) |
119 | self.add(movie_art) |
120 | |
121 | # Movie title |
122 | |
123 | === modified file 'entertainerlib/frontend/gui/screens/photo_albums.py' |
124 | --- entertainerlib/frontend/gui/screens/photo_albums.py 2009-05-06 03:40:22 +0000 |
125 | +++ entertainerlib/frontend/gui/screens/photo_albums.py 2009-05-10 07:43:27 +0000 |
126 | @@ -114,31 +114,31 @@ |
127 | images = album.get_preview_images(3) |
128 | self.preview_textures = [] |
129 | |
130 | + max_w = 0.4026 |
131 | + max_h = 0.5599 |
132 | + abs_max_w = self.get_abs_x(max_w) |
133 | + abs_max_h = self.get_abs_y(max_h) |
134 | + |
135 | for image in images: |
136 | pix_buffer = gtk.gdk.pixbuf_new_from_file(image.get_thumbnail_url()) |
137 | - texture = EyeCandyTexture(pix_buffer, pix_buffer.get_width(), |
138 | - pix_buffer.get_height()) |
139 | + ratio = float(pix_buffer.get_width()) |
140 | + ratio /= float(pix_buffer.get_height()) |
141 | + |
142 | + # Resize and center preview texture |
143 | + if ratio > 1: |
144 | + texture = EyeCandyTexture(0.0, 0.0, max_w, max_h / ratio, |
145 | + pix_buffer) |
146 | + new_y = int((abs_max_h - abs_max_h / ratio) / 2.0) |
147 | + texture.set_position(0, new_y) |
148 | + else: |
149 | + texture = EyeCandyTexture(0.0, 0.0, max_w * ratio, |
150 | + max_h, pix_buffer) |
151 | + new_x = int((abs_max_w - abs_max_w * ratio) / 2.0) |
152 | + texture.set_position(new_x, 0) |
153 | + |
154 | texture.set_rotation(clutter.Y_AXIS, 25, 0, 0, 0) |
155 | texture.set_opacity(0) |
156 | |
157 | - # Resize and center preview texture |
158 | - max_w = self.get_abs_x(0.4026) |
159 | - max_h = self.get_abs_y(0.5599) |
160 | - width = pix_buffer.get_width() |
161 | - height = pix_buffer.get_height() |
162 | - x_ratio = max_w / float(width) |
163 | - y_ratio = max_h / float(height) |
164 | - if x_ratio > y_ratio: |
165 | - texture.set_scale(max_h /float(height), max_h / float(height)) |
166 | - new_width = int(width * (max_h / float(height))) |
167 | - new_x = int((max_w - new_width) / 2.0) |
168 | - texture.set_position(new_x, 0) |
169 | - else: |
170 | - texture.set_scale(max_w / float(width), max_w / float(width)) |
171 | - new_height = int(height * (max_w/ float(width))) |
172 | - new_y = int((max_h - new_height) / 2.0) |
173 | - texture.set_position(0, new_y) |
174 | - |
175 | self.preview_textures.append(texture) |
176 | group.add(texture) |
177 | self.preview_textures[0].set_opacity(255) |
178 | @@ -244,16 +244,9 @@ |
179 | return True |
180 | |
181 | def _create_list_indicator(self): |
182 | - """ |
183 | - Create list indicator for albums list. |
184 | - """ |
185 | - self.li = ListIndicator(0.2, 0.045, ListIndicator.VERTICAL) |
186 | - self.li.set_position(self.get_abs_x(0.9297) - self.li.get_width(), |
187 | - self.config.get_stage_height() - self.li.get_height() - \ |
188 | - self.get_abs_y(0.03906)) |
189 | - self.li.set_delimiter(" | ") |
190 | + '''Create list indicator for albums list.''' |
191 | + self.li = ListIndicator(0.77, 0.9, 0.2, 0.045, ListIndicator.VERTICAL) |
192 | self.li.set_maximum(self.menu.get_number_of_items()) |
193 | - self.li.set_current(1) |
194 | self.add(self.li) |
195 | |
196 | def _move_menu(self, menu_direction): |
197 | |
198 | === modified file 'entertainerlib/frontend/gui/screens/photographs.py' |
199 | --- entertainerlib/frontend/gui/screens/photographs.py 2009-05-06 03:40:22 +0000 |
200 | +++ entertainerlib/frontend/gui/screens/photographs.py 2009-05-10 07:43:27 +0000 |
201 | @@ -2,7 +2,6 @@ |
202 | '''Photographs - Screen contains a list/grid of photographs''' |
203 | |
204 | import pango |
205 | -import clutter |
206 | import gobject |
207 | |
208 | from entertainerlib.frontend.gui.screens.screen import Screen |
209 | @@ -38,9 +37,7 @@ |
210 | self.add(self.image_desc) |
211 | |
212 | # Display throbber animation while loading photographs |
213 | - self.throbber = LoadingAnimation(40, clutter.Color(255, 255, 255, 255), |
214 | - clutter.Color(128, 128, 128, 128)) |
215 | - self.throbber.set_position(self.get_abs_x(0.9), self.get_abs_y(0.9)) |
216 | + self.throbber = LoadingAnimation(0.9, 0.9) |
217 | self.throbber.show() |
218 | self.add(self.throbber) |
219 | |
220 | @@ -99,15 +96,10 @@ |
221 | self.image_desc.set_size(0.366, 0.0911) |
222 | |
223 | def _create_list_indicator(self): |
224 | - """ |
225 | - Create list indicator for albums list. |
226 | - """ |
227 | - self.li = ListIndicator(0.18, 0.045, ListIndicator.HORIZONTAL) |
228 | - self.li.set_position(self.get_abs_x(0.9297) - self.li.get_width(), |
229 | - self.get_abs_y(0.7943)) |
230 | - self.li.set_delimiter(" | ") |
231 | + '''Create list indicator for albums list.''' |
232 | + self.li = ListIndicator(0.77, 0.8, 0.18, 0.045, |
233 | + ListIndicator.HORIZONTAL) |
234 | self.li.set_maximum(len(self.images)) |
235 | - self.li.set_current(1) |
236 | self.add(self.li) |
237 | |
238 | def _move_menu(self, menu_direction): |
239 | |
240 | === modified file 'entertainerlib/frontend/gui/screens/rss.py' |
241 | --- entertainerlib/frontend/gui/screens/rss.py 2009-06-14 19:55:40 +0000 |
242 | +++ entertainerlib/frontend/gui/screens/rss.py 2009-06-25 19:06:28 +0000 |
243 | @@ -98,13 +98,8 @@ |
244 | self.add(self.menu) |
245 | |
246 | def _create_feed_menu_indicator(self): |
247 | - """ |
248 | - Create a ListIndicator for feed menu. |
249 | - """ |
250 | - self.li = ListIndicator(0.2, 0.045, ListIndicator.VERTICAL) |
251 | - self.li.set_position(self.get_abs_x(0.8858) - self.li.get_width(), |
252 | - self.get_abs_y(0.9)) |
253 | - self.li.set_delimiter(" | ") |
254 | + '''Create a ListIndicator for feed menu.''' |
255 | + self.li = ListIndicator(0.7, 0.9, 0.2, 0.045, ListIndicator.VERTICAL) |
256 | self.li.set_maximum(self.menu.get_number_of_items()) |
257 | self.add(self.li) |
258 | |
259 | |
260 | === modified file 'entertainerlib/frontend/gui/screens/tv_episodes.py' |
261 | --- entertainerlib/frontend/gui/screens/tv_episodes.py 2009-05-06 03:40:22 +0000 |
262 | +++ entertainerlib/frontend/gui/screens/tv_episodes.py 2009-07-01 11:15:57 +0000 |
263 | @@ -39,13 +39,8 @@ |
264 | self._create_episode_info_box() |
265 | |
266 | #List indicator |
267 | - self.li = ListIndicator(0.2, 0.045, ListIndicator.VERTICAL) |
268 | - self.li.set_position(self.config.get_stage_width() - |
269 | - self.li.get_width() - self.get_abs_x(0.06589), |
270 | - self.config.get_stage_height() - self.get_abs_y(0.1953)) |
271 | - self.li.set_delimiter(" | ") |
272 | + self.li = ListIndicator(0.8, 0.9, 0.2, 0.045, ListIndicator.VERTICAL) |
273 | self.li.set_maximum(self.episode_menu.get_number_of_items()) |
274 | - self.li.set_current(1) |
275 | self.add(self.li) |
276 | |
277 | # Add the additional actions that are needed but not handled by default |
278 | @@ -91,15 +86,15 @@ |
279 | thumbnail = menu_item.get_userdata().get_thumbnail_url() |
280 | if(thumbnail is not None): |
281 | pixbuf = gtk.gdk.pixbuf_new_from_file(thumbnail) |
282 | - thumb_width = self.get_abs_x(0.2928) |
283 | - thumb_height = self.get_abs_y(0.2799) |
284 | - thumb_x = self.get_abs_x(0.05) |
285 | - thumb_y = self.get_abs_y(0.2) |
286 | + thumb_width = 0.2928 |
287 | + thumb_height = 0.2799 |
288 | + thumb_x = 0.05 |
289 | + thumb_y = 0.2 |
290 | else: |
291 | - thumb_width = self.get_abs_x(0.1098) |
292 | - thumb_height = self.get_abs_y(0.2799) |
293 | - thumb_x = self.get_abs_x(0.20) |
294 | - thumb_y = self.get_abs_y(0.15) |
295 | + thumb_width = 0.1098 |
296 | + thumb_height = 0.2799 |
297 | + thumb_x = 0.20 |
298 | + thumb_y = 0.15 |
299 | if(self.tv_series.has_cover_art()): |
300 | pixbuf = gtk.gdk.pixbuf_new_from_file( |
301 | self.tv_series.get_cover_art_url()) |
302 | @@ -107,8 +102,8 @@ |
303 | pixbuf = gtk.gdk.pixbuf_new_from_file( |
304 | self.theme.getImage("default_movie_art")) |
305 | |
306 | - self.thumb = EyeCandyTexture(pixbuf, thumb_width, thumb_height) |
307 | - self.thumb.set_position(thumb_x, thumb_y) |
308 | + self.thumb = EyeCandyTexture(thumb_x, thumb_y, thumb_width, |
309 | + thumb_height, pixbuf) |
310 | self.add(self.thumb) |
311 | |
312 | def _create_episode_info_box(self): |
313 | |
314 | === modified file 'entertainerlib/frontend/gui/screens/tv_series.py' |
315 | --- entertainerlib/frontend/gui/screens/tv_series.py 2009-05-06 03:40:22 +0000 |
316 | +++ entertainerlib/frontend/gui/screens/tv_series.py 2009-07-01 11:15:57 +0000 |
317 | @@ -31,13 +31,8 @@ |
318 | self._create_season_menu() |
319 | |
320 | #List indicator |
321 | - self.li = ListIndicator(0.2, 0.045, ListIndicator.VERTICAL) |
322 | - self.li.set_position(self.config.get_stage_width() - |
323 | - self.li.get_width() - self.get_abs_x(0.0659), |
324 | - self.config.get_stage_height() - self.get_abs_y(0.1953)) |
325 | - self.li.set_delimiter(" | ") |
326 | + self.li = ListIndicator(0.8, 0.9, 0.2, 0.045, ListIndicator.VERTICAL) |
327 | self.li.set_maximum(self.season_menu.get_number_of_items()) |
328 | - self.li.set_current(1) |
329 | self.add(self.li) |
330 | |
331 | def _create_season_menu(self): |
332 | @@ -74,9 +69,7 @@ |
333 | else: |
334 | pixbuf = gtk.gdk.pixbuf_new_from_file( |
335 | self.theme.getImage("default_movie_art")) |
336 | - self.art = EyeCandyTexture(pixbuf, self.get_abs_x(0.2196), |
337 | - self.get_abs_y(0.5859)) |
338 | - self.art.set_position(self.get_abs_x(0.16), self.get_abs_y(0.15)) |
339 | + self.art = EyeCandyTexture(0.16, 0.15, 0.2196, 0.5859, pixbuf) |
340 | self.add(self.art) |
341 | |
342 | def _move_menu(self, menu_direction): |
343 | |
344 | === modified file 'entertainerlib/frontend/gui/tabs/albums_tab.py' |
345 | --- entertainerlib/frontend/gui/tabs/albums_tab.py 2009-05-12 06:40:51 +0000 |
346 | +++ entertainerlib/frontend/gui/tabs/albums_tab.py 2009-05-14 03:22:31 +0000 |
347 | @@ -23,10 +23,7 @@ |
348 | Tab.__init__(self, name, tab_title, move_to_new_screen_callback) |
349 | |
350 | # Start the loading animation while the menu is loading |
351 | - self.throbber = LoadingAnimation(40, |
352 | - clutter.Color(255, 255, 255, 255), |
353 | - clutter.Color(128, 128, 128, 128)) |
354 | - self.throbber.set_position(self.get_abs_x(0.1), self.get_abs_y(0.1)) |
355 | + self.throbber = LoadingAnimation(0.6, 0.1) |
356 | self.throbber.show() |
357 | self.add(self.throbber) |
358 | |
359 | @@ -73,12 +70,9 @@ |
360 | |
361 | self.add(self.menu) |
362 | |
363 | - self.li = ListIndicator(0.18, 0.045, ListIndicator.HORIZONTAL) |
364 | - self.li.set_position(self.get_abs_x(0.9297) - self.li.get_width(), |
365 | - self.get_abs_y(0.7943)) |
366 | - self.li.set_delimiter(" | ") |
367 | + self.li = ListIndicator(0.77, 0.8, 0.18, 0.045, |
368 | + ListIndicator.HORIZONTAL) |
369 | self.li.set_maximum(len(albums)) |
370 | - self.li.set_current(1) |
371 | self.li.show() |
372 | self.add(self.li) |
373 | |
374 | |
375 | === modified file 'entertainerlib/frontend/gui/tabs/artists_tab.py' |
376 | --- entertainerlib/frontend/gui/tabs/artists_tab.py 2009-05-12 11:25:32 +0000 |
377 | +++ entertainerlib/frontend/gui/tabs/artists_tab.py 2009-05-14 03:22:31 +0000 |
378 | @@ -23,10 +23,7 @@ |
379 | self.library = music_library |
380 | |
381 | # Start the loading animation while the menu is loading |
382 | - self.throbber = LoadingAnimation(40, |
383 | - clutter.Color(255, 255, 255, 255), |
384 | - clutter.Color(128, 128, 128, 128)) |
385 | - self.throbber.set_position(self.get_abs_x(0.1), self.get_abs_y(0.1)) |
386 | + self.throbber = LoadingAnimation(0.1, 0.1) |
387 | self.throbber.show() |
388 | self.add(self.throbber) |
389 | |
390 | @@ -56,12 +53,9 @@ |
391 | self.add(self.artist_tracks) |
392 | |
393 | # Create artis menu list indicator |
394 | - self.li = ListIndicator(0.18, 0.045, ListIndicator.HORIZONTAL) |
395 | - self.li.set_position(self.get_abs_x(0.929) - self.li.get_width(), |
396 | - self.get_abs_y(0.794)) |
397 | - self.li.set_delimiter(" | ") |
398 | + self.li = ListIndicator(0.77, 0.8, 0.18, 0.045, |
399 | + ListIndicator.HORIZONTAL) |
400 | self.li.set_maximum(len(artists)) |
401 | - self.li.set_current(1) |
402 | self.add(self.li) |
403 | |
404 | self._async_menu_build(artists) |
405 | |
406 | === modified file 'entertainerlib/frontend/gui/tabs/lyrics_tab.py' |
407 | --- entertainerlib/frontend/gui/tabs/lyrics_tab.py 2009-05-11 18:23:38 +0000 |
408 | +++ entertainerlib/frontend/gui/tabs/lyrics_tab.py 2009-05-14 03:22:31 +0000 |
409 | @@ -2,7 +2,6 @@ |
410 | '''Lyrics tab for the audio play screen''' |
411 | |
412 | import pango |
413 | -import clutter |
414 | |
415 | from entertainerlib.frontend.gui.tabs.tab import Tab |
416 | from entertainerlib.frontend.gui.widgets.label import Label |
417 | @@ -34,10 +33,7 @@ |
418 | self.connect('deactivated', self._on_deactivated) |
419 | else: |
420 | # Display throbber animation while searching for lyrics |
421 | - white = clutter.Color(255, 255, 255, 255) |
422 | - gray = clutter.Color(128, 128, 128, 128) |
423 | - self.throbber = LoadingAnimation(50, white, gray) |
424 | - self.throbber.set_position(self.get_abs_x(0.7), self.get_abs_y(0.5)) |
425 | + self.throbber = LoadingAnimation(0.7, 0.5, 0.1) |
426 | self.throbber.show() |
427 | self.add(self.throbber) |
428 | self.track.fetch_lyrics(self._lyrics_search_callback) |
429 | |
430 | === modified file 'entertainerlib/frontend/gui/tabs/movies_tab.py' |
431 | --- entertainerlib/frontend/gui/tabs/movies_tab.py 2009-05-12 10:15:40 +0000 |
432 | +++ entertainerlib/frontend/gui/tabs/movies_tab.py 2009-05-14 03:22:31 +0000 |
433 | @@ -82,8 +82,7 @@ |
434 | if movie.has_cover_art(): |
435 | pix_buffer = gtk.gdk.pixbuf_new_from_file( |
436 | movie.get_cover_art_url()) |
437 | - texture = RoundedTexture(pix_buffer, self.get_abs_x(0.1), |
438 | - self.get_abs_y(0.25)) |
439 | + texture = RoundedTexture(0.0, 0.0, 0.1, 0.25, pix_buffer) |
440 | else: |
441 | texture = clutter.CloneTexture(default_cover) |
442 | item = ImageMenuItem(0.1, 1.41, texture) |
443 | @@ -99,12 +98,9 @@ |
444 | self.add(self.menu) |
445 | |
446 | # Create list indicator |
447 | - self.list_indicator = ListIndicator(0.2, 0.045, ListIndicator.VERTICAL) |
448 | - self.list_indicator.set_position(self.get_abs_x(0.75), |
449 | - self.get_abs_y(0.76)) |
450 | - self.list_indicator.set_delimiter(" | ") |
451 | + self.list_indicator = ListIndicator(0.75, 0.76, 0.2, 0.045, |
452 | + ListIndicator.VERTICAL) |
453 | self.list_indicator.set_maximum(self.menu.get_number_of_items()) |
454 | - self.list_indicator.set_current(1) |
455 | self.show() |
456 | self.add(self.list_indicator) |
457 | |
458 | |
459 | === modified file 'entertainerlib/frontend/gui/tabs/series_tab.py' |
460 | --- entertainerlib/frontend/gui/tabs/series_tab.py 2009-05-11 18:28:52 +0000 |
461 | +++ entertainerlib/frontend/gui/tabs/series_tab.py 2009-05-14 03:22:31 +0000 |
462 | @@ -81,8 +81,7 @@ |
463 | if series.has_cover_art(): |
464 | pix_buffer = gtk.gdk.pixbuf_new_from_file( |
465 | series.get_cover_art_url()) |
466 | - texture = RoundedTexture(pix_buffer, self.get_abs_x(0.1), |
467 | - self.get_abs_y(0.25)) |
468 | + texture = RoundedTexture(0.0, 0.0, 0.1, 0.25, pix_buffer) |
469 | else: |
470 | texture = clutter.CloneTexture(default_cover) |
471 | |
472 | @@ -100,12 +99,9 @@ |
473 | self.add(self.menu) |
474 | |
475 | # Create list indicator |
476 | - self.list_indicator = ListIndicator(0.2, 0.045, ListIndicator.VERTICAL) |
477 | - self.list_indicator.set_position(self.get_abs_x(0.75), |
478 | - self.get_abs_y(0.76)) |
479 | - self.list_indicator.set_delimiter(" | ") |
480 | + self.list_indicator = ListIndicator(0.75, 0.76, 0.2, 0.045, |
481 | + ListIndicator.VERTICAL) |
482 | self.list_indicator.set_maximum(self.menu.get_number_of_items()) |
483 | - self.list_indicator.set_current(1) |
484 | self.list_indicator.show() |
485 | self.add(self.list_indicator) |
486 | |
487 | |
488 | === modified file 'entertainerlib/frontend/gui/tabs/tracks_tab.py' |
489 | --- entertainerlib/frontend/gui/tabs/tracks_tab.py 2009-05-11 10:10:27 +0000 |
490 | +++ entertainerlib/frontend/gui/tabs/tracks_tab.py 2009-05-14 03:22:31 +0000 |
491 | @@ -55,12 +55,9 @@ |
492 | self.track_length = Label(0.037, "subtitle", 0.22, 0.91, "") |
493 | self.add(self.track_length) |
494 | |
495 | - self.li = ListIndicator(0.18, 0.045, ListIndicator.HORIZONTAL) |
496 | - self.li.set_position(self.get_abs_x(0.9297) - self.li.get_width(), |
497 | - self.get_abs_y(0.7943)) |
498 | - self.li.set_delimiter(" | ") |
499 | + self.li = ListIndicator(0.77, 0.8, 0.18, 0.045, |
500 | + ListIndicator.HORIZONTAL) |
501 | self.li.set_maximum(self.menu.get_number_of_items()) |
502 | - self.li.set_current(1) |
503 | self.li.show() |
504 | self.add(self.li) |
505 | |
506 | |
507 | === modified file 'entertainerlib/frontend/gui/tabs/video_clips_tab.py' |
508 | --- entertainerlib/frontend/gui/tabs/video_clips_tab.py 2009-05-11 10:12:11 +0000 |
509 | +++ entertainerlib/frontend/gui/tabs/video_clips_tab.py 2009-05-14 03:22:31 +0000 |
510 | @@ -75,8 +75,7 @@ |
511 | clips = self.video_library.get_video_clips() |
512 | for clip in clips: |
513 | pix_buffer = gtk.gdk.pixbuf_new_from_file(clip.get_thumbnail_url()) |
514 | - texture = RoundedTexture(pix_buffer, self.get_abs_x(0.233), |
515 | - self.get_abs_y(0.25)) |
516 | + texture = RoundedTexture(0.0, 0.0, 0.233, 0.25, pix_buffer) |
517 | item = ImageMenuItem(0.233, 0.5625, texture) |
518 | item.set_userdata(clip) |
519 | self.menu.add_actor(item) |
520 | @@ -90,12 +89,9 @@ |
521 | self.add(self.menu) |
522 | |
523 | # Create list indicator |
524 | - self.list_indicator = ListIndicator(0.2, 0.045, ListIndicator.VERTICAL) |
525 | - self.list_indicator.set_position(self.get_abs_x(0.67), |
526 | - self.get_abs_y(0.76)) |
527 | - self.list_indicator.set_delimiter(" | ") |
528 | + self.list_indicator = ListIndicator(0.7, 0.8, 0.2, 0.045, |
529 | + ListIndicator.VERTICAL) |
530 | self.list_indicator.set_maximum(self.menu.get_number_of_items()) |
531 | - self.list_indicator.set_current(1) |
532 | self.list_indicator.show() |
533 | self.add(self.list_indicator) |
534 | |
535 | |
536 | === modified file 'entertainerlib/frontend/gui/widgets/arrow_texture.py' |
537 | --- entertainerlib/frontend/gui/widgets/arrow_texture.py 2009-05-06 03:40:22 +0000 |
538 | +++ entertainerlib/frontend/gui/widgets/arrow_texture.py 2009-06-30 20:11:01 +0000 |
539 | @@ -4,7 +4,9 @@ |
540 | import clutter |
541 | from cluttercairo import CairoTexture |
542 | |
543 | -class ArrowTexture(CairoTexture): |
544 | +from entertainerlib.frontend.gui.widgets.base import Base |
545 | + |
546 | +class ArrowTexture(Base, CairoTexture): |
547 | """Clutter CairoTexture which represents an arrow.""" |
548 | |
549 | # Arrow direction (One of these should be passed as a paramter) |
550 | @@ -14,7 +16,7 @@ |
551 | LEFT = 3 |
552 | ARC_TO_BEZIER = 0.55228475 |
553 | |
554 | - def __init__(self, size, fg_color, bg_color, direction): |
555 | + def __init__(self, x, y, size, fg_color, bg_color, direction): |
556 | """ |
557 | Initialize ArrowTexture |
558 | @param size: Width and height of the texture |
559 | @@ -23,9 +25,15 @@ |
560 | @param direction: Arrow direction UP,DOWN,RIGHT or LEFT (class |
561 | constant) |
562 | """ |
563 | - CairoTexture.__init__(self, size, size) |
564 | + Base.__init__(self) |
565 | + |
566 | + abs_size = self.get_abs_x(size) |
567 | + |
568 | + CairoTexture.__init__(self, abs_size, abs_size) |
569 | + |
570 | context = self.cairo_create() |
571 | - context.scale(size, size) |
572 | + context.scale(abs_size, abs_size) |
573 | + |
574 | fg_cairo = self._color_to_cairo_color(fg_color) |
575 | bg_cairo = self._color_to_cairo_color(bg_color) |
576 | |
577 | @@ -69,6 +77,8 @@ |
578 | self.behaviour = clutter.BehaviourScale(1.0, 1.0, 1.5, 1.5, self.alpha) |
579 | self.behaviour.apply(self) |
580 | |
581 | + self.set_position(self.get_abs_x(x), self.get_abs_y(y)) |
582 | + |
583 | def bounce(self): |
584 | """ |
585 | Execute bounce effect for this array. |
586 | @@ -116,3 +126,4 @@ |
587 | cr.rel_line_to(0, -height + 2 * radius_y) |
588 | cr.rel_curve_to(0.0, -c2, radius_x - c1, -radius_y, radius_x, -radius_y) |
589 | cr.close_path() |
590 | + |
591 | |
592 | === modified file 'entertainerlib/frontend/gui/widgets/eyecandy_texture.py' |
593 | --- entertainerlib/frontend/gui/widgets/eyecandy_texture.py 2009-05-06 03:40:22 +0000 |
594 | +++ entertainerlib/frontend/gui/widgets/eyecandy_texture.py 2009-05-10 07:43:27 +0000 |
595 | @@ -3,27 +3,33 @@ |
596 | |
597 | import clutter |
598 | |
599 | +from entertainerlib.frontend.gui.widgets.base import Base |
600 | from entertainerlib.frontend.gui.widgets.rounded_texture import RoundedTexture |
601 | from entertainerlib.frontend.gui.widgets.reflection_texture import ( |
602 | ReflectionTexture) |
603 | |
604 | -class EyeCandyTexture(clutter.Group): |
605 | +class EyeCandyTexture(Base, clutter.Group): |
606 | """ |
607 | Just a simple wrapper class for RoundedTexture and ReflectionTexture. |
608 | |
609 | EyeCandyTexture is a texture with rounded corners and reflection below. |
610 | """ |
611 | |
612 | - def __init__(self, pixbuf, width, height): |
613 | + def __init__(self, x, y, width, height, pixbuf): |
614 | """ |
615 | Initialize new eye candy texture |
616 | @param imagefile: Absoulte path to PNG file |
617 | """ |
618 | + Base.__init__(self) |
619 | clutter.Group.__init__(self) |
620 | - rounded = RoundedTexture(pixbuf, width, height) |
621 | - reflection = ReflectionTexture(pixbuf, width, height, |
622 | + |
623 | + rounded = RoundedTexture(0.0, 0.0, width, height, pixbuf) |
624 | + reflection = ReflectionTexture(0.0, 0.0, width, height, pixbuf, |
625 | round_corners=True) |
626 | - reflection.set_position(0, height) |
627 | + |
628 | + reflection.set_position(0, rounded.get_height()) |
629 | + self.set_position(self.get_abs_x(x), self.get_abs_y(y)) |
630 | + |
631 | self.add(rounded) |
632 | self.add(reflection) |
633 | |
634 | |
635 | === modified file 'entertainerlib/frontend/gui/widgets/list_indicator.py' |
636 | --- entertainerlib/frontend/gui/widgets/list_indicator.py 2009-05-06 03:40:22 +0000 |
637 | +++ entertainerlib/frontend/gui/widgets/list_indicator.py 2009-05-10 07:43:27 +0000 |
638 | @@ -4,10 +4,11 @@ |
639 | import clutter |
640 | |
641 | from entertainerlib.frontend.gui.widgets.arrow_texture import ArrowTexture |
642 | +from entertainerlib.frontend.gui.widgets.base import Base |
643 | from entertainerlib.frontend.gui.widgets.label import Label |
644 | from entertainerlib.utils.configuration import Configuration |
645 | |
646 | -class ListIndicator(clutter.Group): |
647 | +class ListIndicator(Base, clutter.Group): |
648 | """ |
649 | ListIndicator displays 'current / maximum' value label and arrows. |
650 | """ |
651 | @@ -18,22 +19,24 @@ |
652 | HORIZONTAL = 0 |
653 | VERTICAL = 1 |
654 | |
655 | - def __init__(self, width, height, direction): |
656 | + def __init__(self, x, y, width, height, direction): |
657 | """ |
658 | Initialize actor. |
659 | @param width: Width of the widget in percentage (0-1) |
660 | @param height: Height of the widget in percentage (0-1) |
661 | @param direction: Direction (constant of this class) |
662 | """ |
663 | + Base.__init__(self) |
664 | clutter.Group.__init__(self) |
665 | + |
666 | self.config = Configuration() |
667 | |
668 | # Size |
669 | - self.width = int(self.config.get_stage_width() * width) |
670 | - self.height = int(self.config.get_stage_height() * height) |
671 | + self.width = self.get_abs_x(width) |
672 | + self.height = self.get_abs_y(height) |
673 | |
674 | self.direction = direction |
675 | - self.delimiter = " / " |
676 | + self.delimiter = " | " |
677 | self.current = 1 |
678 | self.maximum = 1 |
679 | |
680 | @@ -41,10 +44,7 @@ |
681 | self.fg = self.theme.get_color("arrow_foreground") |
682 | self.bg = self.theme.get_color("arrow_background") |
683 | |
684 | - if direction == ListIndicator.VERTICAL: |
685 | - text_x_pos = width / 3 |
686 | - else: |
687 | - text_x_pos = width / 2 |
688 | + text_x_pos = width / 3 |
689 | |
690 | self.text = Label(height * 0.8, "text", text_x_pos, (height / 2), |
691 | str(self.maximum) + self.delimiter + str(self.maximum)) |
692 | @@ -53,30 +53,22 @@ |
693 | |
694 | # Create arrows and calculate positions on screen |
695 | if direction == ListIndicator.VERTICAL: |
696 | - self.arrow1 = ArrowTexture( |
697 | - self.height, self.fg, self.bg, ArrowTexture.UP) |
698 | - self.arrow2 = ArrowTexture( |
699 | - self.height, self.fg, self.bg, ArrowTexture.DOWN) |
700 | - self.arrow1.set_position( |
701 | - int(self.width - self.height / 2.0), int(self.height / 2.0)) |
702 | - self.arrow2.set_position( |
703 | - int(self.width - (self.height * 1.5 + self.height / 6.0)), |
704 | - int(self.height / 2.0)) |
705 | + self.arrow1 = ArrowTexture(5 * width / 7, height / 2, height / 2, |
706 | + self.fg, self.bg, ArrowTexture.UP) |
707 | + self.arrow2 = ArrowTexture(6 * width / 7, height / 2, height / 2, |
708 | + self.fg, self.bg, ArrowTexture.DOWN) |
709 | |
710 | elif direction == ListIndicator.HORIZONTAL: |
711 | - self.arrow1 = ArrowTexture( |
712 | - self.height, self.fg, self.bg, ArrowTexture.LEFT) |
713 | - self.arrow2 = ArrowTexture( |
714 | - self.height, self.fg, self.bg, ArrowTexture.RIGHT) |
715 | - self.arrow1.set_position( |
716 | - int(self.height / 2.0), |
717 | - int(self.height / 2.0)) |
718 | - self.arrow2.set_position( |
719 | - int(self.width - self.height / 2.0), int(self.height / 2.0)) |
720 | + self.arrow1 = ArrowTexture(height / 2, height / 2, height / 2, |
721 | + self.fg, self.bg, ArrowTexture.LEFT) |
722 | + self.arrow2 = ArrowTexture(6 * width / 7, height / 2, height / 2, |
723 | + self.fg, self.bg, ArrowTexture.RIGHT) |
724 | |
725 | self.add(self.arrow1) |
726 | self.add(self.arrow2) |
727 | |
728 | + self.set_position(self.get_abs_x(x), self.get_abs_y(y)) |
729 | + |
730 | def set_current(self, value): |
731 | """ |
732 | Set current value |
733 | |
734 | === modified file 'entertainerlib/frontend/gui/widgets/loading_animation.py' |
735 | --- entertainerlib/frontend/gui/widgets/loading_animation.py 2009-05-06 03:40:22 +0000 |
736 | +++ entertainerlib/frontend/gui/widgets/loading_animation.py 2009-05-10 07:43:27 +0000 |
737 | @@ -7,15 +7,17 @@ |
738 | import gobject |
739 | from cluttercairo import CairoTexture |
740 | |
741 | -class LoadingAnimation(CairoTexture): |
742 | +from entertainerlib.frontend.gui.widgets.base import Base |
743 | + |
744 | +class LoadingAnimation(Base, CairoTexture): |
745 | """ |
746 | Loading animation widget |
747 | |
748 | This widget is used when we want to tell user that Entertainer is loading. |
749 | """ |
750 | |
751 | - def __init__(self, size, fg_color, bg_color, inner_radius = 0.25, |
752 | - outter_radius = 0.45, thickness = 0.08): |
753 | + def __init__(self, x, y, size=0.03, inner_radius=0.25, outter_radius=0.45, |
754 | + thickness=0.08): |
755 | """ |
756 | Initialize LoadingAnimation |
757 | @param size: Width and height of the texture |
758 | @@ -25,14 +27,19 @@ |
759 | @param outter_radius: Distance from origo to line end point 0-1 |
760 | @param thinkness: Lines thickness 0-1 |
761 | """ |
762 | - CairoTexture.__init__(self, size, size) |
763 | - self.set_anchor_point(size /2, size /2) |
764 | - |
765 | - c = self._clutterColorToCairoColor(fg_color) |
766 | - bg = self._clutterColorToCairoColor(bg_color) |
767 | + Base.__init__(self) |
768 | + |
769 | + abs_size = self.get_abs_x(size) |
770 | + |
771 | + CairoTexture.__init__(self, abs_size, abs_size) |
772 | + |
773 | + self.set_anchor_point(abs_size /2, abs_size /2) |
774 | + |
775 | + c = self._clutterColorToCairoColor(clutter.Color(255, 255, 255, 255)) |
776 | + bg = self._clutterColorToCairoColor(clutter.Color(128, 128, 128, 128)) |
777 | |
778 | context = self.cairo_create() |
779 | - context.scale(size, size) |
780 | + context.scale(abs_size, abs_size) |
781 | context.set_line_width (thickness) |
782 | context.set_line_cap(cairo.LINE_CAP_ROUND) |
783 | |
784 | @@ -44,6 +51,8 @@ |
785 | |
786 | self.keep_going = False |
787 | |
788 | + self.set_position(self.get_abs_x(x), self.get_abs_y(y)) |
789 | + |
790 | def _draw_line(self, context, bg_col, fg_col, radius, in_radius, number): |
791 | """Draw one line""" |
792 | if number < 2: |
793 | |
794 | === modified file 'entertainerlib/frontend/gui/widgets/reflection_texture.py' |
795 | --- entertainerlib/frontend/gui/widgets/reflection_texture.py 2009-05-06 03:40:22 +0000 |
796 | +++ entertainerlib/frontend/gui/widgets/reflection_texture.py 2009-07-01 10:52:59 +0000 |
797 | @@ -6,7 +6,9 @@ |
798 | import clutter |
799 | from cluttercairo import CairoTexture |
800 | |
801 | -class ReflectionTexture(CairoTexture): |
802 | +from entertainerlib.frontend.gui.widgets.base import Base |
803 | + |
804 | +class ReflectionTexture(Base, CairoTexture): |
805 | """ |
806 | Reflection texture |
807 | |
808 | @@ -14,7 +16,7 @@ |
809 | is rendered with Cairo. |
810 | """ |
811 | |
812 | - def __init__(self, pixbuf, width, height, ref_height=0.3, opacity=0.3, |
813 | + def __init__(self, x, y, width, height, pixbuf, ref_height=0.3, opacity=0.3, |
814 | round_corners=False, margin=1, radius=15): |
815 | """ |
816 | Create a new reflection texture |
817 | @@ -27,7 +29,13 @@ |
818 | @param margin: number of pixels to cut off from sides |
819 | @param radius: Radius for rounded corners |
820 | """ |
821 | - CairoTexture.__init__(self, width, height) |
822 | + Base.__init__(self) |
823 | + |
824 | + abs_width = self.get_abs_x(width) |
825 | + abs_height = self.get_abs_y(height) |
826 | + |
827 | + CairoTexture.__init__(self, abs_width, abs_height) |
828 | + |
829 | context = self.cairo_create() |
830 | ct = gtk.gdk.CairoContext(context) |
831 | |
832 | @@ -35,13 +43,13 @@ |
833 | if round_corners: |
834 | x = 0 + margin |
835 | y = 0 + margin |
836 | - w1 = width - (margin * 2) |
837 | - h1 = height - (margin * 2) |
838 | + w1 = abs_width - (margin * 2) |
839 | + h1 = abs_height - (margin * 2) |
840 | self.roundedCorners(context, x, y, w1, h1, radius, radius) |
841 | |
842 | # Scale context area |
843 | - wr = width / float(pixbuf.get_width()) |
844 | - hr = height / float(pixbuf.get_height()) |
845 | + wr = abs_width / float(pixbuf.get_width()) |
846 | + hr = abs_height / float(pixbuf.get_height()) |
847 | context.scale(wr, hr) |
848 | |
849 | # Create gradient mask |
850 | @@ -59,6 +67,8 @@ |
851 | self.set_rotation(clutter.Z_AXIS, 180, 0, 0, 0) |
852 | self.set_rotation(clutter.Y_AXIS, 180, 0, 0, 0) |
853 | |
854 | + self.set_position(self.get_abs_x(x), self.get_abs_y(y)) |
855 | + |
856 | def roundedCorners(self, context, x, y, w, h, radius_x, radius_y): |
857 | """ |
858 | Clip cairo texture with rounded rectangle. |
859 | @@ -87,3 +97,4 @@ |
860 | -radius_y) |
861 | context.close_path() |
862 | context.clip() |
863 | + |
864 | |
865 | === modified file 'entertainerlib/frontend/gui/widgets/rounded_texture.py' |
866 | --- entertainerlib/frontend/gui/widgets/rounded_texture.py 2009-05-06 03:40:22 +0000 |
867 | +++ entertainerlib/frontend/gui/widgets/rounded_texture.py 2009-05-10 07:43:27 +0000 |
868 | @@ -4,7 +4,9 @@ |
869 | from cluttercairo import CairoTexture |
870 | import gtk |
871 | |
872 | -class RoundedTexture(CairoTexture): |
873 | +from entertainerlib.frontend.gui.widgets.base import Base |
874 | + |
875 | +class RoundedTexture(Base, CairoTexture): |
876 | """ |
877 | Texture with rounded corners |
878 | |
879 | @@ -12,7 +14,7 @@ |
880 | rounded smooth corners. |
881 | """ |
882 | |
883 | - def __init__(self, pixbuf, width, height, margin=1, radius=15): |
884 | + def __init__(self, x, y, width, height, pixbuf, margin=1, radius=15): |
885 | """ |
886 | Create a new cairo based texture from GDK pixel buffer. This texture is |
887 | similar to clutter.Texture, but this is rendered with cairo and it adds |
888 | @@ -22,26 +24,34 @@ |
889 | @param margin: number of pixels to cut off from sides |
890 | @param radius: Radius for rounded corners |
891 | """ |
892 | - CairoTexture.__init__(self, width, height) |
893 | + Base.__init__(self) |
894 | + |
895 | + abs_width = self.get_abs_x(width) |
896 | + abs_height = self.get_abs_y(height) |
897 | + |
898 | + CairoTexture.__init__(self, abs_width, abs_height) |
899 | + |
900 | context = self.cairo_create() |
901 | ct = gtk.gdk.CairoContext(context) |
902 | |
903 | # Round corners |
904 | - x = 0 + margin |
905 | - y = 0 + margin |
906 | - w1 = width - (margin * 2) |
907 | - h1 = height - (margin * 2) |
908 | - self.roundedCorners(context, x, y, w1, h1, radius, radius) |
909 | + xx = 0 + margin |
910 | + yy = 0 + margin |
911 | + w1 = abs_width - (margin * 2) |
912 | + h1 = abs_height - (margin * 2) |
913 | + self.roundedCorners(context, xx, yy, w1, h1, radius, radius) |
914 | |
915 | # Scale context area |
916 | - wr = width / float(pixbuf.get_width()) |
917 | - hr = height / float(pixbuf.get_height()) |
918 | + wr = abs_width / float(pixbuf.get_width()) |
919 | + hr = abs_height / float(pixbuf.get_height()) |
920 | context.scale(wr, hr) |
921 | ct.set_source_pixbuf(pixbuf, 0, 0) |
922 | context.paint() |
923 | del context # Update texture |
924 | del ct |
925 | |
926 | + self.set_position(self.get_abs_x(x), self.get_abs_y(y)) |
927 | + |
928 | def roundedCorners(self, context, x, y, w, h, radius_x, radius_y): |
929 | """ |
930 | Clip cairo texture with rounded rectangle. |
931 | |
932 | === modified file 'entertainerlib/frontend/gui/widgets/scroll_area.py' |
933 | --- entertainerlib/frontend/gui/widgets/scroll_area.py 2009-05-06 03:40:22 +0000 |
934 | +++ entertainerlib/frontend/gui/widgets/scroll_area.py 2009-05-10 07:43:27 +0000 |
935 | @@ -30,12 +30,9 @@ |
936 | self.get_abs_y(y_pos_percent)) |
937 | |
938 | # Create content position indicator |
939 | - self.indicator = ListIndicator(0.2, 0.045, ListIndicator.VERTICAL) |
940 | + self.indicator = ListIndicator(3 * x_size_percent / 4, y_size_percent, |
941 | + 0.2, 0.045, ListIndicator.VERTICAL) |
942 | self.indicator.hide_position() |
943 | - self.indicator.set_current(1) |
944 | - self.indicator.set_position( |
945 | - self.area_width - self.indicator.get_width(), |
946 | - self.area_height + self.get_abs_y(0.01)) |
947 | self.add(self.indicator) |
948 | |
949 | if active: |
950 | |
951 | === added file 'entertainerlib/tests/test_arrowtexture.py' |
952 | --- entertainerlib/tests/test_arrowtexture.py 1970-01-01 00:00:00 +0000 |
953 | +++ entertainerlib/tests/test_arrowtexture.py 2009-06-30 20:11:01 +0000 |
954 | @@ -0,0 +1,25 @@ |
955 | +# Copyright (c) 2009 Entertainer Developers - See COPYING - GPLv2 |
956 | +'''Tests ArrowTexture.''' |
957 | + |
958 | +from entertainerlib.frontend.gui.widgets.arrow_texture import ArrowTexture |
959 | +from entertainerlib.tests import EntertainerTest |
960 | + |
961 | +class ArrowTextureTest(EntertainerTest): |
962 | + '''Test for entertainerlib.frontend.gui.widgets.arrow_texture.''' |
963 | + |
964 | + def setUp(self): |
965 | + '''Set up the test.''' |
966 | + EntertainerTest.setUp(self) |
967 | + |
968 | + self.arrow = ArrowTexture(0.5, 0.9, 0.40, (21, 45, 83, 255), |
969 | + (255, 0, 0, 255), ArrowTexture.UP) |
970 | + |
971 | + def test_create(self): |
972 | + '''Test correct ArrowTexture initialization.''' |
973 | + self.assertTrue(isinstance(self.arrow, ArrowTexture)) |
974 | + |
975 | + def test_bounce(self): |
976 | + '''Test the bounce method.''' |
977 | + self.arrow.bounce() |
978 | + self.assertTrue(self.arrow.timeline.is_playing()) |
979 | + |
980 | |
981 | === added file 'entertainerlib/tests/test_eyecandytexture.py' |
982 | --- entertainerlib/tests/test_eyecandytexture.py 1970-01-01 00:00:00 +0000 |
983 | +++ entertainerlib/tests/test_eyecandytexture.py 2009-06-30 22:02:55 +0000 |
984 | @@ -0,0 +1,25 @@ |
985 | +# Copyright (c) 2009 Entertainer Developers - See COPYING - GPLv2 |
986 | +'''Tests ArrowTexture.''' |
987 | + |
988 | +import gtk |
989 | +import os |
990 | + |
991 | +from entertainerlib.frontend.gui.widgets.eyecandy_texture import EyeCandyTexture |
992 | +from entertainerlib.tests import EntertainerTest |
993 | + |
994 | +THIS_DIR = os.path.dirname(__file__) |
995 | + |
996 | +class EyeCandyTextureTest(EntertainerTest): |
997 | + '''Test for entertainerlib.frontend.gui.widgets.eyecandy_texture.''' |
998 | + |
999 | + def setUp(self): |
1000 | + '''Set up the test.''' |
1001 | + EntertainerTest.setUp(self) |
1002 | + |
1003 | + filename = os.path.join(THIS_DIR, 'data/ImageThumbnailer/test.jpg') |
1004 | + pix_buffer = gtk.gdk.pixbuf_new_from_file(filename) |
1005 | + self.eyecandy = EyeCandyTexture(0.5, 0.9, 0.40, 0.4, pix_buffer) |
1006 | + |
1007 | + def test_create(self): |
1008 | + '''Test correct EyeCandyTexture initialization.''' |
1009 | + self.assertTrue(isinstance(self.eyecandy, EyeCandyTexture)) |
1010 | |
1011 | === added file 'entertainerlib/tests/test_listindicator.py' |
1012 | --- entertainerlib/tests/test_listindicator.py 1970-01-01 00:00:00 +0000 |
1013 | +++ entertainerlib/tests/test_listindicator.py 2009-06-30 22:18:48 +0000 |
1014 | @@ -0,0 +1,37 @@ |
1015 | +# Copyright (c) 2009 Entertainer Developers - See COPYING - GPLv2 |
1016 | +'''Tests ListIndicator.''' |
1017 | + |
1018 | +from entertainerlib.frontend.gui.widgets.list_indicator import ListIndicator |
1019 | +from entertainerlib.tests import EntertainerTest |
1020 | + |
1021 | +class ListIndicatorTest(EntertainerTest): |
1022 | + '''Test for entertainerlib.frontend.gui.widgets.list_indicator.''' |
1023 | + |
1024 | + def setUp(self): |
1025 | + '''Set up the test.''' |
1026 | + EntertainerTest.setUp(self) |
1027 | + |
1028 | + self.indicator = ListIndicator(0.7, 0.8, 0.2, 0.045, |
1029 | + ListIndicator.HORIZONTAL) |
1030 | + |
1031 | + def test_create(self): |
1032 | + '''Test correct ListIndicator initialization.''' |
1033 | + self.assertTrue(isinstance(self.indicator, ListIndicator)) |
1034 | + |
1035 | + def test_currentmax(self): |
1036 | + '''Test methods to handle the current and maximum attributes.''' |
1037 | + self.indicator.set_current(10) |
1038 | + self.assertEqual(self.indicator.get_current(), 1) |
1039 | + self.indicator.set_current(-99) |
1040 | + self.assertEqual(self.indicator.get_current(), 1) |
1041 | + self.indicator.set_maximum(10) |
1042 | + self.indicator.set_current(5) |
1043 | + self.assertEqual(self.indicator.get_current(), 5) |
1044 | + |
1045 | + def test_setdelimiter(self): |
1046 | + '''Test the set_delimiter method.''' |
1047 | + self.indicator.set_maximum(100) |
1048 | + self.indicator.set_current(50) |
1049 | + self.indicator.set_delimiter(" * ") |
1050 | + self.assertEqual(self.indicator.text.get_text(), "50 * 100") |
1051 | + |
1052 | |
1053 | === added file 'entertainerlib/tests/test_loadinganimation.py' |
1054 | --- entertainerlib/tests/test_loadinganimation.py 1970-01-01 00:00:00 +0000 |
1055 | +++ entertainerlib/tests/test_loadinganimation.py 2009-07-01 11:07:28 +0000 |
1056 | @@ -0,0 +1,28 @@ |
1057 | +# Copyright (c) 2009 Entertainer Developers - See COPYING - GPLv2 |
1058 | +'''Tests LoadingAnimation.''' |
1059 | + |
1060 | +from entertainerlib.frontend.gui.widgets.loading_animation import ( |
1061 | + LoadingAnimation) |
1062 | +from entertainerlib.tests import EntertainerTest |
1063 | + |
1064 | +class LoadingAnimationTest(EntertainerTest): |
1065 | + '''Test for entertainerlib.frontend.gui.widgets.loading_animation.''' |
1066 | + |
1067 | + def setUp(self): |
1068 | + '''Set up the test.''' |
1069 | + EntertainerTest.setUp(self) |
1070 | + |
1071 | + self.animation = LoadingAnimation(0.5, 0.5) |
1072 | + |
1073 | + def test_create(self): |
1074 | + '''Test correct LoadingAnimation initialization.''' |
1075 | + self.assertTrue(isinstance(self.animation, LoadingAnimation)) |
1076 | + |
1077 | + def test_hide(self): |
1078 | + '''Test the hide method.''' |
1079 | + self.assertTrue(self.animation.hide) |
1080 | + |
1081 | + def test_show(self): |
1082 | + '''Test the show method.''' |
1083 | + self.assertTrue(self.animation.show) |
1084 | + |
1085 | |
1086 | === added file 'entertainerlib/tests/test_reflectiontexture.py' |
1087 | --- entertainerlib/tests/test_reflectiontexture.py 1970-01-01 00:00:00 +0000 |
1088 | +++ entertainerlib/tests/test_reflectiontexture.py 2009-07-01 11:07:28 +0000 |
1089 | @@ -0,0 +1,27 @@ |
1090 | +# Copyright (c) 2009 Entertainer Developers - See COPYING - GPLv2 |
1091 | +'''Tests ReflectionTexture.''' |
1092 | + |
1093 | +import gtk |
1094 | +import os |
1095 | + |
1096 | +from entertainerlib.frontend.gui.widgets.reflection_texture import ( |
1097 | + ReflectionTexture) |
1098 | +from entertainerlib.tests import EntertainerTest |
1099 | + |
1100 | +THIS_DIR = os.path.dirname(__file__) |
1101 | + |
1102 | +class ReflectionTextureTest(EntertainerTest): |
1103 | + '''Test for entertainerlib.frontend.gui.widgets.reflection_texture.''' |
1104 | + |
1105 | + def setUp(self): |
1106 | + '''Set up the test.''' |
1107 | + EntertainerTest.setUp(self) |
1108 | + |
1109 | + filename = os.path.join(THIS_DIR, 'data/ImageThumbnailer/test.jpg') |
1110 | + pix_buffer = gtk.gdk.pixbuf_new_from_file(filename) |
1111 | + self.texture = ReflectionTexture(0.5, 0.9, 0.40, 0.4, pix_buffer) |
1112 | + |
1113 | + def test_create(self): |
1114 | + '''Test correct ReflectionTexture initialization.''' |
1115 | + self.assertTrue(isinstance(self.texture, ReflectionTexture)) |
1116 | + |
1117 | |
1118 | === added file 'entertainerlib/tests/test_roundedtexture.py' |
1119 | --- entertainerlib/tests/test_roundedtexture.py 1970-01-01 00:00:00 +0000 |
1120 | +++ entertainerlib/tests/test_roundedtexture.py 2009-07-01 11:16:44 +0000 |
1121 | @@ -0,0 +1,26 @@ |
1122 | +# Copyright (c) 2009 Entertainer Developers - See COPYING - GPLv2 |
1123 | +'''Tests RoundedTexture.''' |
1124 | + |
1125 | +import gtk |
1126 | +import os |
1127 | + |
1128 | +from entertainerlib.frontend.gui.widgets.rounded_texture import RoundedTexture |
1129 | +from entertainerlib.tests import EntertainerTest |
1130 | + |
1131 | +THIS_DIR = os.path.dirname(__file__) |
1132 | + |
1133 | +class RoundedTextureTest(EntertainerTest): |
1134 | + '''Test for entertainerlib.frontend.gui.widgets.rounded_texture.''' |
1135 | + |
1136 | + def setUp(self): |
1137 | + '''Set up the test.''' |
1138 | + EntertainerTest.setUp(self) |
1139 | + |
1140 | + filename = os.path.join(THIS_DIR, 'data/ImageThumbnailer/test.jpg') |
1141 | + pix_buffer = gtk.gdk.pixbuf_new_from_file(filename) |
1142 | + self.texture = RoundedTexture(0.5, 0.9, 0.40, 0.4, pix_buffer) |
1143 | + |
1144 | + def test_create(self): |
1145 | + '''Test correct RoundedTexture initialization.''' |
1146 | + self.assertTrue(isinstance(self.texture, RoundedTexture)) |
1147 | + |
Devs,
This branch is there to continue what Matt started with Labels, Textures etc.
We have now more widgets inheriting from Base. I have excluded some widgets from this branch because either there's a refactoring in progress or an "idea" of refactoring.
Why base?
Not only it allows us to have readable instantiation of or widgets (avoiding the get_abs...) but it now also can be the Base (the name is really good Matt :)) of future work extending the Base Class.
I've also taken the opportunity to do some improvments and to create test for all the modified widgets (even if test is limited to a creation test for some of them).
Good review.
Samuel-