def _addVisibleThumbnails(self, rect): """Gets the thumbnails for the currently visible clip portion.""" if self.thumb_width is None: return False self.thumbs = {} self.wishlist = [] thumb_duration = self._get_thumb_duration() element_left = self.pixelToNs(rect.x) + self.ges_elem.props.in_point element_right = element_left + self.pixelToNs(rect.width) element_left = quantize(element_left, thumb_duration) for current_time in range(element_left, element_right, thumb_duration): thumb = Thumbnail(self.thumb_width, self.thumb_height) x = Zoomable.nsToPixel(current_time) - self.nsToPixel(self.ges_elem.props.in_point) y = (self.props.height_request - self.thumb_height) / 2 self.put(thumb, x, y) self.thumbs[current_time] = thumb if self.__image_pixbuf: thumb.set_from_pixbuf(self.__image_pixbuf) thumb.set_visible(True) elif current_time in self.thumb_cache: pixbuf = self.thumb_cache[current_time] thumb.set_from_pixbuf(pixbuf) thumb.set_visible(True) else: self.wishlist.append(current_time) return True
def _addVisibleThumbnails(self): """ Get the thumbnails to be displayed in the currently visible clip portion """ self.remove_all_children() old_thumbs = self.thumbs self.thumbs = {} self.wishlist = [] thumb_duration = self._get_thumb_duration() element_left, element_right = self._get_visible_range() element_left = quantize(element_left, thumb_duration) for current_time in range(element_left, element_right, thumb_duration): thumb = Thumbnail(self.thumb_width, self.thumb_height) thumb.set_position(Zoomable.nsToPixel(current_time), self.thumb_margin) self.add_child(thumb) self.thumbs[current_time] = thumb if current_time in self.thumb_cache: gdkpixbuf = self.thumb_cache[current_time] if self._allAnimated or current_time not in old_thumbs: self.thumbs[current_time].set_from_gdkpixbuf_animated(gdkpixbuf) else: self.thumbs[current_time].set_from_gdkpixbuf(gdkpixbuf) else: self.wishlist.append(current_time) self._allAnimated = False
def _addVisibleThumbnails(self): """ Get the thumbnails to be displayed in the currently visible clip portion """ self.remove_all_children() old_thumbs = self.thumbs self.thumbs = {} self.wishlist = [] thumb_duration = self._get_thumb_duration() element_left, element_right = self._get_visible_range() element_left = quantize(element_left, thumb_duration) for current_time in range(element_left, element_right, thumb_duration): thumb = Thumbnail(self.thumb_width, self.thumb_height) thumb.set_position(Zoomable.nsToPixel(current_time), THUMB_MARGIN_PX) self.add_child(thumb) self.thumbs[current_time] = thumb if current_time in self.thumb_cache: gdkpixbuf = self.thumb_cache[current_time] if self._allAnimated or current_time not in old_thumbs: self.thumbs[current_time].set_from_gdkpixbuf_animated(gdkpixbuf) else: self.thumbs[current_time].set_from_gdkpixbuf(gdkpixbuf) else: self.wishlist.append(current_time) self._allAnimated = False
def _update_thumbnails(self): """Updates the thumbnail widgets for the clip at the current zoom.""" if not self.thumb_width: # The __image_pixbuf is not ready yet. return thumbs = {} interval = self.thumb_interval(self.thumb_width) element_left = quantize(self.ges_elem.props.in_point, interval) element_right = self.ges_elem.props.in_point + self.ges_elem.props.duration y = (self.props.height_request - self.thumb_height) / 2 for position in range(element_left, element_right, interval): x = Zoomable.nsToPixel(position) - self.nsToPixel( self.ges_elem.props.in_point) try: thumb = self.thumbs.pop(position) self.move(thumb, x, y) except KeyError: thumb = Thumbnail(self.thumb_width, self.thumb_height) self.put(thumb, x, y) thumbs[position] = thumb thumb.set_from_pixbuf(self.__image_pixbuf) thumb.set_visible(True) for thumb in self.thumbs.values(): self.remove(thumb) self.thumbs = thumbs
def _addVisibleThumbnails(self, rect): """ Get the thumbnails to be displayed in the currently visible clip portion """ if self.thumb_width is None: return False self.thumbs = {} self.wishlist = [] thumb_duration = self._get_thumb_duration() element_left = self.pixelToNs(rect.x) + self.bElement.props.in_point element_right = element_left + self.bElement.props.duration element_left = quantize(element_left, thumb_duration) for current_time in range(element_left, element_right, thumb_duration): thumb = Thumbnail(self.thumb_width, self.thumb_height) self.put(thumb, Zoomable.nsToPixel(current_time) - self.nsToPixel(self.bElement.props.in_point), (self.props.height_request - self.thumb_height) / 2) self.thumbs[current_time] = thumb if current_time in self.thumb_cache: gdkpixbuf = self.thumb_cache[current_time] self.thumbs[current_time].set_from_pixbuf(gdkpixbuf) self.thumbs[current_time].set_visible(True) else: self.wishlist.append(current_time) return True
def _addVisibleThumbnails(self, rect): """Gets the thumbnails for the currently visible clip portion.""" if self.thumb_width is None: return False self.thumbs = {} self.wishlist = [] thumb_duration = self._get_thumb_duration() element_left = self.pixelToNs(rect.x) + self.ges_elem.props.in_point element_right = element_left + self.pixelToNs(rect.width) element_left = quantize(element_left, thumb_duration) for current_time in range(element_left, element_right, thumb_duration): thumb = Thumbnail(self.thumb_width, self.thumb_height) x = Zoomable.nsToPixel(current_time) - self.nsToPixel( self.ges_elem.props.in_point) y = (self.props.height_request - self.thumb_height) / 2 self.put(thumb, x, y) self.thumbs[current_time] = thumb if self.__image_pixbuf: thumb.set_from_pixbuf(self.__image_pixbuf) thumb.set_visible(True) elif current_time in self.thumb_cache: pixbuf = self.thumb_cache[current_time] thumb.set_from_pixbuf(pixbuf) thumb.set_visible(True) else: self.wishlist.append(current_time) return True
def _get_thumb_duration(self): thumb_duration_tmp = Zoomable.pixelToNs(self.thumb_width + self.thumb_margin) # quantize thumb length to thumb_period thumb_duration = quantize(thumb_duration_tmp, self.thumb_period) # make sure that the thumb duration after the quantization isn't smaller than before if thumb_duration < thumb_duration_tmp: thumb_duration += self.thumb_period # make sure that we don't show thumbnails more often than thumb_period return max(thumb_duration, self.thumb_period)
def _get_thumb_duration(self): thumb_duration_tmp = Zoomable.pixelToNs(self.thumb_width + THUMB_MARGIN_PX) # quantize thumb length to thumb_period thumb_duration = quantize(thumb_duration_tmp, self.thumb_period) # make sure that the thumb duration after the quantization isn't smaller than before if thumb_duration < thumb_duration_tmp: thumb_duration += self.thumb_period # make sure that we don't show thumbnails more often than thumb_period return max(thumb_duration, self.thumb_period)
def thumb_interval(self): """Gets the interval for which a thumbnail is displayed. Returns: int: a duration in nanos, multiple of THUMB_PERIOD. """ interval = Zoomable.pixelToNs(self.thumb_width + THUMB_MARGIN_PX) # Make sure the thumb interval is a multiple of THUMB_PERIOD. quantized = quantize(interval, THUMB_PERIOD) # Make sure the quantized thumb interval fits # the thumb and the margin. if quantized < interval: quantized += THUMB_PERIOD # Make sure we don't show thumbs more often than THUMB_PERIOD. return max(THUMB_PERIOD, quantized)
def _update_thumbnails(self): """Updates the thumbnail widgets for the clip at the current zoom.""" if not self.thumb_width: # The thumb_width will be available when pipeline has been started # or the __image_pixbuf is ready. return thumbs = {} queue = [] interval = self.thumb_interval element_left = quantize(self.ges_elem.props.in_point, interval) element_right = self.ges_elem.props.in_point + self.ges_elem.props.duration y = (self.props.height_request - self.thumb_height) / 2 for position in range(element_left, element_right, interval): x = Zoomable.nsToPixel(position) - self.nsToPixel( self.ges_elem.props.in_point) try: thumb = self.thumbs.pop(position) self.move(thumb, x, y) except KeyError: thumb = Thumbnail(self.thumb_width, self.thumb_height) self.put(thumb, x, y) thumbs[position] = thumb if isinstance(self.ges_elem, GES.ImageSource): thumb.set_from_pixbuf(self.__image_pixbuf) thumb.set_visible(True) elif position in self.thumb_cache: pixbuf = self.thumb_cache[position] thumb.set_from_pixbuf(pixbuf) thumb.set_visible(True) else: if position not in self.failures and position != self.position: queue.append(position) for thumb in self.thumbs.values(): self.remove(thumb) self.thumbs = thumbs self.queue = queue if queue: self.become_controlled()
def _update_thumbnails(self): """Updates the thumbnails for the currently visible clip portion.""" if self.thumb_width is None: return False thumbs = {} self.wishlist = [] thumb_duration = self._get_thumb_duration() element_left = quantize(self.ges_elem.props.in_point, thumb_duration) element_right = self.ges_elem.props.in_point + self.ges_elem.props.duration for position in range(element_left, element_right, thumb_duration): x = Zoomable.nsToPixel(position) - self.nsToPixel( self.ges_elem.props.in_point) y = (self.props.height_request - self.thumb_height) / 2 try: thumb = self.thumbs.pop(position) self.move(thumb, x, y) except KeyError: thumb = Thumbnail(self.thumb_width, self.thumb_height) self.put(thumb, x, y) thumbs[position] = thumb if self.__image_pixbuf: # The thumbnail is fixed, probably it's an image clip. thumb.set_from_pixbuf(self.__image_pixbuf) thumb.set_visible(True) elif position in self.thumb_cache: pixbuf = self.thumb_cache[position] thumb.set_from_pixbuf(pixbuf) thumb.set_visible(True) else: self.wishlist.append(position) for thumb in self.thumbs.values(): self.remove(thumb) self.thumbs = thumbs return True
def _update_thumbnails(self): """Updates the thumbnails for the currently visible clip portion.""" if self.thumb_width is None: return False thumbs = {} self.wishlist = [] thumb_duration = self._get_thumb_duration() element_left = quantize(self.ges_elem.props.in_point, thumb_duration) element_right = self.ges_elem.props.in_point + self.ges_elem.props.duration for position in range(element_left, element_right, thumb_duration): x = Zoomable.nsToPixel(position) - self.nsToPixel(self.ges_elem.props.in_point) y = (self.props.height_request - self.thumb_height) / 2 try: thumb = self.thumbs.pop(position) self.move(thumb, x, y) except KeyError: thumb = Thumbnail(self.thumb_width, self.thumb_height) self.put(thumb, x, y) thumbs[position] = thumb if self.__image_pixbuf: # The thumbnail is fixed, probably it's an image clip. thumb.set_from_pixbuf(self.__image_pixbuf) thumb.set_visible(True) elif position in self.thumb_cache: pixbuf = self.thumb_cache[position] thumb.set_from_pixbuf(pixbuf) thumb.set_visible(True) else: self.wishlist.append(position) for thumb in self.thumbs.values(): self.remove(thumb) self.thumbs = thumbs return True