Home | Trees | Indices | Help |
---|
|
1 # -*- coding: utf-8 -*- 2 # Elisa - Home multimedia server 3 # Copyright (C) 2006-2008 Fluendo Embedded S.L. (www.fluendo.com). 4 # All rights reserved. 5 # 6 # This file is available under one of two license agreements. 7 # 8 # This file is licensed under the GPL version 3. 9 # See "LICENSE.GPL" in the root of this distribution including a special 10 # exception to use Elisa with Fluendo's plugins. 11 # 12 # The GPL part of Elisa is also available under a commercial licensing 13 # agreement from Fluendo. 14 # See "LICENSE.Elisa" in the root directory of this distribution package 15 # for details on that license. 16 17 from elisa.core import common 18 19 import pgm 20 from pgm.widgets import sliced_image, scrollbar, const 21 22 from raval_widgets.scrolled_list import ScrolledList 23 from raval_widgets.selector import Selector 24 import constants 25 26 from pgm.graph.group import Group 27 from pgm.graph.image import Image 28 from pgm.graph.text import Text 293180 81 plugin_registry = common.application.plugin_registry 82 BaseListView = plugin_registry.get_component_class('raval:list_view') 8333 vspacing = 0.15 34 35 thumbnail_width = 0.3 36 thumbnail_height = 0.4 37 thumbnail_x = 0.05 38 thumbnail_y = 0.055 39 40 self.thumbnail = Image() 41 self.add(self.thumbnail) 42 self.thumbnail.position = (thumbnail_x, thumbnail_y, 0) 43 self.thumbnail.size = (thumbnail_width, thumbnail_height) 44 self.thumbnail.bg_color = (0, 0, 0, 0) 45 self.thumbnail.layout = pgm.IMAGE_SCALED 46 self.thumbnail.visible = True 47 48 text_x = thumbnail_width + vspacing 49 text_y = 0.06 50 text_width = 2.35 51 text_height = 0.5 52 53 self._description = self._create_text() 54 self.add(self._description) 55 self._description.visible = True 56 # FIXME: harcoded absolute value 57 self._description.font_height = 0.13 58 self._description.position = (text_x, text_y, 0) 59 self._description.size = (text_width, text_height)6062 txt = Text() 63 txt.font_family = "Nimbus Sans L" 64 txt.weight = pgm.TEXT_WEIGHT_BOLD 65 txt.bg_color = (0, 0, 0, 0) 66 txt.alignment = pgm.TEXT_ALIGN_LEFT 67 txt.ellipsize = pgm.TEXT_ELLIPSIZE_MIDDLE 68 txt.opacity = 255 69 return txt70 74 7785 87 super(ShadedListView, self).__init__() 88 super(ScrolledList, self).__init__() 89 self._index_set_before = False9092 self._update_preview()9395 self.debug("Selector should become visible: %s" % visible) 96 self._list_selector.visible = visible9799 self.debug("updating the preview") 100 if not hasattr(self, 'preview'): 101 self._create_child_view('preview', 'raval:preview') 102 103 canvas = self.frontend.context.viewport_handle.get_canvas() 104 self.preview.width = canvas.width * 0.37 105 self.preview.height = canvas.height * 0.7 106 x = canvas.width*0.95 - self.preview.width 107 y = (self.height - self.preview.height) / 2.0 + \ 108 self.preview.height/7.0 109 self.preview.position = (x, y, 0.0) 110 self.preview.visible = True 111 112 if self.selected_item >= 0 and len(self.controller.model): 113 self.preview.update()114116 super(ShadedListView, self).frontend_changed(previous_frontend, 117 new_frontend) 118 119 if self.frontend: 120 self._list_selector.loading_image_path = self.frontend.theme.get_media('small_waiting_icon') 121 self._list_selector.action_done_image_path = self.frontend.theme.get_media('action_done_icon') 122 123 #FIXME find a way to remove this 124 if hasattr(self, 'preview'): 125 self.preview.frontend_changed(previous_frontend, new_frontend)126128 BaseListView.clean(self) 129 self.selector.stop_animation() 130 self.canvas = None 131 self.preview.canvas = None132134 super(ShadedListView, self).create_widgets() 135 136 canvas = self.frontend.context.viewport_handle.get_canvas() 137 theme = self.frontend.theme 138 139 gradient_top = theme.get_media("list_mode_gradient_top") 140 gradient_bottom = theme.get_media("list_mode_gradient_bottom") 141 142 self.top_shade = gradient_top 143 self.bottom_shade = gradient_bottom 144 145 list_x = canvas.width / 100. 146 self.visible_range_size = 9 147 148 top_bar_height_px = canvas.height * (constants.status_bar_height + constants.context_bar_height) / 100. 149 margin_px = canvas.height * constants.list_menu_height_margin / 100. 150 back_button_px = canvas.height * constants.back_button_height / 100. 151 top_bar_height_px = canvas.height * (constants.status_bar_height + constants.context_bar_height) / 100. 152 153 self.position = (list_x, top_bar_height_px + margin_px, 0) 154 self.width = canvas.width * 0.45 155 self.height = canvas.height * 0.7 156 self.height = canvas.height - top_bar_height_px - margin_px * 2.0 - back_button_px 157 158 bar_bg = sliced_image.SlicedImage() 159 bar_bg.top_file = theme.get_media("scrollbar_top") 160 bar_bg.bottom_file = theme.get_media("scrollbar_bottom") 161 bar_bg.body_file = theme.get_media("scrollbar_body") 162 163 cursor = sliced_image.SlicedImage() 164 cursor.top_file = theme.get_media("cursor_top") 165 cursor.bottom_file = theme.get_media("cursor_bottom") 166 cursor.body_file = theme.get_media("cursor_body") 167 168 # Vertical scrollbar on the left side of the list 169 bar = scrollbar.Scrollbar(items_number=9, background=bar_bg, 170 cursor=cursor, spacing=0.01, thickness=0.07) 171 self.set_vertical_scrollbar(bar, const.LEFT, spacing=0.05) 172 173 sel_left = theme.get_media("selector_left") 174 sel_right = theme.get_media("selector_right") 175 sel_body = theme.get_media("selector_body") 176 back_sel_left = theme.get_media("back_selector_left") 177 back_sel_right = theme.get_media("back_selector_right") 178 back_sel_body = theme.get_media("back_selector_body") 179 #arrow = theme.get_media("selector_arrow") 180 181 # TODO: make Selector parameters optional 182 sel_pictos = (sel_left, sel_right, sel_body, 183 back_sel_left, back_sel_right, back_sel_body) 184 185 self._list_selector = Selector(orientation=const.HORIZONTAL, *sel_pictos) 186 187 # back button at bottom left corner of the list 188 self._back_img = Image() 189 self._back_img.connect("clicked", self._back_button_clicked) 190 self._back_img.layout = pgm.IMAGE_SCALED 191 self._back_img.set_from_file(theme.get_media('list_mode_back_button')) 192 self._back_img.bg_color = (0, 0, 0, 0) 193 self._back_img.visible = True 194 195 height = canvas.height * constants.back_button_height / 100. 196 width = canvas.width / 8.0 197 y = canvas.height - self.y - height 198 x = -self.x 199 self._back_img.alignment = pgm.IMAGE_BOTTOM_LEFT 200 self._back_img.position = (x, y, 0) 201 self._back_img.size = (width, height) 202 self.add(self._back_img)203 209211 if not self._index_set_before: 212 self._index_set_before = True 213 self.selector_visible = False 214 self.set_selector(self._list_selector) 215 super(ShadedListView, self).selected_item__set(index)216 220222 model = self.controller.model[index] 223 widget = self[index] 224 225 widget.load() 226 227 self.load_from_theme(model.theme_icon, widget.thumbnail) 228 229 text = self.frontend.translate_text(model.text) 230 widget.description = text 231 232 uri = model.thumbnail_source 233 if uri != None: 234 self._thumbnail_source_to_image(uri, widget.thumbnail)235237 widget.unload()238240 # The controller could already have been removed, when we get the 241 # events 242 if self.controller is None or not self.controller.focused: 243 return False 244 245 return super(ShadedListView, self).do_clicked(x, y, z, button, time)246248 old_selected = self.selected_item 249 super(ShadedListView, self).do_child_clicked(index) 250 251 if index == old_selected: 252 # click while selected, activate 253 self.controller.activate_item(self.frontend)254256 if self.controller is None or not self.controller.focused: 257 return False 258 259 return super(ShadedListView, self).do_drag_begin(x, y, z, button, time)260262 if self.controller is None or not self.controller.focused: 263 return False 264 265 return super(ShadedListView, self).do_drag_motion(x, y, z, button, time)266268 if self.controller is None or not self.controller.focused: 269 return False 270 271 return super(ShadedListView, self).do_drag_end(x, y, z, button, time)272 275277 super(ShadedListView, self).element_attribute_set(position, key, 278 old_value, 279 new_value) 280 if key == "text": 281 text = self.frontend.translate_text(new_value) 282 self[position].description = text 283 elif key == "thumbnail_source": 284 if self.is_widget_visible(position): 285 self._thumbnail_source_to_image(new_value, 286 self[position].thumbnail) 287 elif key == "loading": 288 self.selector.loading = new_value289 293
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0beta1 on Wed Jan 16 19:11:01 2008 | http://epydoc.sourceforge.net |