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 from elisa.core.input_event import * 19 from elisa.base_components.controller import Controller 20 21 from raval_widgets import grid_bar 22 23 plugin_registry = common.application.plugin_registry 24 BaseListController = plugin_registry.get_component_class('raval:list_controller') 2527 28 min_lines = 1 29 max_lines = 5 30 lines = 3 31 ratio = 7 / 3. 32 grid_bar_index = grid_bar.NONE_FOCUSED 33 old_grid_bar_index = grid_bar.NONE_FOCUSED 3410936 if input_event.action == EventAction.GO_RIGHT: 37 if self.grid_bar_index != grid_bar.NONE_FOCUSED: 38 new_value = self.grid_bar_index + 1 39 if new_value < grid_bar.ZOOM_IN_FOCUSED + 1: 40 self.grid_bar_index = new_value 41 else: 42 self.old_grid_bar_index = grid_bar.NONE_FOCUSED 43 self.next_item(self.lines) 44 return True 45 46 elif input_event.action == EventAction.GO_LEFT: 47 if self.grid_bar_index != grid_bar.NONE_FOCUSED: 48 new_value = self.grid_bar_index - 1 49 if new_value >= grid_bar.NONE_FOCUSED: 50 self.grid_bar_index = new_value 51 else: 52 self.old_grid_bar_index = grid_bar.NONE_FOCUSED 53 self.previous_item(self.lines) 54 return True 55 56 elif input_event.action == EventAction.GO_UP: 57 if self.grid_bar_index != grid_bar.NONE_FOCUSED: 58 self.old_grid_bar_index = self.grid_bar_index 59 self.grid_bar_index = grid_bar.NONE_FOCUSED 60 else: 61 line = self.current_index % self.lines 62 if line-1 >= 0: 63 self.previous_item() 64 else: 65 # Our Parent should take care of it 66 return False 67 return True 68 69 elif input_event.action == EventAction.GO_DOWN: 70 line = self.current_index % self.lines 71 if (line+1 >= len(self.model)) or \ 72 line+1 >= self.lines or \ 73 self.current_index+1 >= len(self.model): 74 # enter in grid bar 75 self.go_to_grid() 76 else: 77 self.next_item() 78 return True 79 80 else: 81 return super(GridController, self).handle_input(input_event)8284 if self.grid_bar_index != grid_bar.NONE_FOCUSED: 85 idx = self.grid_bar_index 86 if idx == grid_bar.BACK_FOCUSED: 87 self.parent.exit_node() 88 elif idx == grid_bar.ZOOM_IN_FOCUSED: 89 if self.lines > self.min_lines: 90 self.lines -= 1. 91 elif idx == grid_bar.ZOOM_OUT_FOCUSED: 92 if self.lines < self.max_lines: 93 self.lines += 1. 94 else: 95 super(GridController, self).activate_item(origin)9698 if self.old_grid_bar_index != grid_bar.NONE_FOCUSED: 99 self.grid_bar_index = self.old_grid_bar_index 100 else: 101 # calculate the last Item, we want the BACK_FOCUSED on: 102 rows = round( self.ratio * self.lines / 2) 103 all_rows = round(len(self.model) / self.lines) 104 last = (all_rows - rows + 1) * self.lines 105 if self.current_index <= last: 106 self.grid_bar_index = grid_bar.BACK_FOCUSED 107 else: 108 self.grid_bar_index = grid_bar.ZOOM_IN_FOCUSED
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0beta1 on Wed Jan 16 19:10:10 2008 | http://epydoc.sourceforge.net |