def __init__(self, item_gap, item_height, font_size, color_name): clutter.Group.__init__(self) self._motion_buffer = MotionBuffer() self._items = [] self._item_gap = item_gap self._item_height = item_height self._item_font_size = font_size self._item_color_name = color_name self._selected_index = 1 self._visible_items = 5 self._event_mode = -1 self._animation_progression = 0 self._animation_start_index = 1 self._animation_end_index = 1 self._active = False self._motion_handler = 0 self._timeline = clutter.Timeline(300) self._alpha = clutter.Alpha(self._timeline, clutter.EASE_IN_OUT_SINE) # preparation to pointer events handling self.set_reactive(True) self.connect('scroll-event', self._on_scroll_event) self.connect('button-press-event', self._on_button_press_event) self.connect('button-release-event', self._on_button_release_event)
def __init__(self, x, y, width, height, content): Base.__init__(self) clutter.Group.__init__(self) self._motion_buffer = MotionBuffer() self._offset = 0 # Drives the content motion. self._offset_max = 0 # Maximum value of offset (equal on bottom). self._old_offset = 0 # Stores the old value of offset on motions. self._motion_handler = 0 self._active = None self.step_size = self.get_abs_y(self.STEP_SIZE_PERCENT) # Allowed area for the widget's scrolling content. self.area_width = self.get_abs_x(width) self.area_height = self.get_abs_y(height) # Create content position indicator self.indicator = ListIndicator(3 * width / 4, height, 0.2, 0.045, ListIndicator.VERTICAL) self.indicator.hide_position() self.indicator.set_maximum(2) self.add(self.indicator) # A clipped Group to receive the content. self._fixed_group = clutter.Group() self._fixed_group.set_clip(0, 0, self.area_width, self.area_height) self.add(self._fixed_group) self.content = None self._motion_timeline = clutter.Timeline(500) self._motion_timeline.connect('completed', self._motion_timeline_callback, None) self._motion_alpha = clutter.Alpha(self._motion_timeline, clutter.EASE_OUT_SINE) self._motion_behaviour = LoopedPathBehaviour(self._motion_alpha) self.set_content(content) self.active = None # Preparation to pointer events handling. self.set_reactive(True) self.connect('button-press-event', self._on_button_press_event) self.connect('button-release-event', self._on_button_release_event) self.connect('scroll-event', self._on_scroll_event) self.set_position(self.get_abs_x(x), self.get_abs_y(y))
def __init__(self, stage, width, height): gobject.GObject.__init__(self) self._motion_buffer = MotionBuffer() self._event_mode = self.MODE_NONE self._motion_handler = 0 self.stage = stage # Stage that displays textures # Stage background color when not playing self.bgcolor = stage.get_color() self.stage_width = width # Stage width used for video resizing self.stage_height = height # Stage height used for video resizing self.ratio = MediaPlayer.NATIVE # Video texture ratio self.audio_skip_step = 10 # Audio skip step in seconds self.video_skip_step = 60 # Video skip step in seconds self.playlist = None # Current play list self.media = None # Current media (Playable object) self.shuffle = False # Shuffle mode self.repeat = False # Repeat mode self.is_playing = False # Is media player currently playing self.is_reactive_allowed = False # Is the video_texture reactive self.logger = Logger().getLogger('client.MediaPlayer') self._internal_callback_timeout_key = None self.video_texture = cluttergst.VideoTexture() self.pipeline = self.video_texture.get_pipeline() self.pipeline.set_property("volume", 0.5) self._volume = 10 self.bus = self.pipeline.get_bus() self.bus.add_signal_watch() self.bus.connect('message', self._on_gst_message) self.video_texture.set_reactive(True) self.video_texture.connect('size-change', self._on_size_change) self.video_texture.connect('scroll-event', self._on_scroll_event) self.video_texture.connect('button-press-event', self._on_button_press_event) self.video_texture.connect('button-release-event', self._on_button_release_event)
def __init__(self, x=0, y=0, item_width=0.2, item_height=0.1): Base.__init__(self) clutter.Group.__init__(self) self.motion_duration = 100 # Default duration of animations ms. self.cursor_below = True # Is the cursor below items? self._active = None self._is_vertical = True self.items = [] # Items dimensions variable: relative, absolute, center self._item_width = item_width self._item_height = item_height self._item_width_abs = self.get_abs_x(item_width) self._item_height_abs = self.get_abs_y(item_height) self._dx = int(self._item_width_abs / 2) self._dy = int(self._item_height_abs / 2) # Default cursor's index. self._selected_index = 0 # Grid dimensions: real, visible. self.items_per_row = 10 self.items_per_col = 10 self._visible_rows = 3 self._visible_cols = 5 # The moving_group is a Clutter group containing all the items. self._moving_group_x = 0 self._moving_group_y = 0 self._moving_group = clutter.Group() self.add(self._moving_group) # The moving_group is translated using a `BehaviourPath`. self._moving_group_timeline = clutter.Timeline(200) moving_group_alpha = clutter.Alpha(self._moving_group_timeline, clutter.EASE_IN_OUT_SINE) moving_group_path = clutter.Path() self._moving_group_behaviour = clutter.BehaviourPath( moving_group_alpha, moving_group_path) self._moving_group_behaviour.apply(self._moving_group) # The cursor is an Actor that can be added and moved on the menu. # The cusor is always located in the visible (clipped) area of the menu. self._cursor_x = 0 self._cursor_y = 0 self._cursor = None self._cursor_timeline = clutter.Timeline(200) cursor_alpha = clutter.Alpha(self._cursor_timeline, clutter.EASE_IN_SINE) cursor_path = clutter.Path() self._cursor_behaviour = clutter.BehaviourPath(cursor_alpha, cursor_path) # A MotionBuffer is used to compute useful information about the # cursor's motion. It's used when moving the cursor with a pointer. self._motion_buffer = MotionBuffer() self._event_mode = self.MODE_NONE self._motion_handler = 0 self._seek_step_x = 0 self._seek_step_y = 0 gobject.timeout_add(200, self._internal_timer_callback) #XXX: Samuel Buffet # This rectangle is used to grab events as it turns out that their # might be a bug in clutter 0.8 or python-clutter 0.8. # It may be avoided with next release of clutter. self._event_rect = clutter.Rectangle() self._event_rect.set_opacity(0) self.add(self._event_rect) self._event_rect.set_reactive(True) self._event_rect.connect('button-press-event', self._on_button_press_event) self._event_rect.connect('button-release-event', self._on_button_release_event) self._event_rect.connect('scroll-event', self._on_scroll_event) self.set_position(self.get_abs_x(x), self.get_abs_y(y))
def setUp(self): '''Set up the test.''' EntertainerTest.setUp(self) self.buffer = MotionBuffer()