Example #1
0
 def do_simple_update(self, cr):
     cr.identity_matrix()
     if self.element.factory:
         border_width = self.previewer._spacing()
         self.bounds = goocanvas.Bounds(border_width, 4,
         max(0, Zoomable.nsToPixel(self.element.duration) -
             border_width), self.height)
Example #2
0
 def do_simple_update(self, cr):
     cr.identity_matrix()
     if self.element.factory:
         border_width = self.previewer._spacing()
         self.bounds = goocanvas.Bounds(border_width, 4,
         max(0, Zoomable.nsToPixel(self.element.duration) -
             border_width), self.height)
Example #3
0
    def drawBackground(self, allocation):
        self.pixmap.draw_rectangle(self.style.bg_gc[gtk.STATE_NORMAL], True, 0,
                                   0, allocation.width, allocation.height)

        offset = int(Zoomable.nsToPixel(
            self.getShadedDuration())) - self.pixmap_offset
        if offset > 0:
            self.pixmap.draw_rectangle(self.style.bg_gc[gtk.STATE_ACTIVE],
                                       True, 0, 0, offset, allocation.height)
Example #4
0
 def do_size_allocate(self, allocation):
     self.debug("ScaleRuler got %s", list(allocation))
     gtk.Layout.do_size_allocate(self, allocation)
     width = max(self.getMaxDurationWidth(), allocation.width)
     self.debug("Setting layout size to %d x %d", width, allocation.height)
     self.set_size(width, allocation.height)
     new_pos = Zoomable.nsToPixel(self.position) -\
         self.pixel_position_offset
     self.hadj.set_value(new_pos)
     # the size has changed, therefore we want to redo our pixmap
     self.doPixmap()
Example #5
0
 def do_size_allocate(self, allocation):
     self.debug("ScaleRuler got %s", list(allocation))
     gtk.Layout.do_size_allocate(self, allocation)
     width = max(self.getMaxDurationWidth(), allocation.width)
     self.debug("Setting layout size to %d x %d",
                width, allocation.height)
     self.set_size(width, allocation.height)
     new_pos = Zoomable.nsToPixel(self.position) -\
         self.pixel_position_offset
     self.hadj.set_value(new_pos)
     # the size has changed, therefore we want to redo our pixmap
     self.doPixmap()
Example #6
0
    def render_cairo(self, cr, bounds, element, hscroll_pos, y1):
        if not self._view:
            return
        # The idea is to conceptually divide the clip into a sequence of
        # rectangles beginning at the start of the file, and
        # pixelsToNs(twidth) nanoseconds long. The thumbnail within the
        # rectangle is the frame produced from the timestamp corresponding to
        # rectangle's left edge. We speed things up by only drawing the
        # rectangles which intersect the given bounds.  FIXME: how would we
        # handle timestretch?
        height = bounds.y2 - bounds.y1
        width = bounds.x2 - bounds.x1

        # we actually draw the rectangles just to the left of the clip's in
        # point and just to the right of the clip's out-point, so we need to
        # mask off the actual bounds.
        cr.rectangle(bounds.x1, bounds.y1, width, height)
        cr.clip()

        # tdur = duration in ns of thumbnail
        # sof  = start of file in pixel coordinates
        x1 = bounds.x1
        sof = Zoomable.nsToPixel(element.start - element.in_point) +\
            hscroll_pos

        # i = left edge of thumbnail to be drawn. We start with x1 and
        # subtract the distance to the nearest leftward rectangle.
        # Justification of the following:
        #                i = sof + k * twidth
        #                i = x1 - delta
        # sof + k * twidth = x1 - delta
        #           i * tw = (x1 - sof) - delta
        #    <=>     delta = x1 - sof (mod twidth).
        # Fortunately for us, % works on floats in python.

        i = x1 - ((x1 - sof) % (self.twidth + self._spacing()))

        # j = timestamp *within the element* of thumbnail to be drawn. we want
        # timestamps to be numerically stable, but in practice this seems to
        # give good enough results. It might be possible to improve this
        # further, which would result in fewer thumbnails needing to be
        # generated.
        j = Zoomable.pixelToNs(i - sof)
        istep = self.twidth + self._spacing()
        jstep = self.tdur + Zoomable.pixelToNs(self.spacing)

        while i < bounds.x2:
            self._thumbForTime(cr, j, i, y1)
            cr.rectangle(i - 1, y1, self.twidth + 2, self.theight)
            i += istep
            j += jstep
            cr.fill()
Example #7
0
    def render_cairo(self, cr, bounds, element, hscroll_pos, y1):
        if not self._view:
            return
        # The idea is to conceptually divide the clip into a sequence of
        # rectangles beginning at the start of the file, and
        # pixelsToNs(twidth) nanoseconds long. The thumbnail within the
        # rectangle is the frame produced from the timestamp corresponding to
        # rectangle's left edge. We speed things up by only drawing the
        # rectangles which intersect the given bounds.  FIXME: how would we
        # handle timestretch?
        height = bounds.y2 - bounds.y1
        width = bounds.x2 - bounds.x1

        # we actually draw the rectangles just to the left of the clip's in
        # point and just to the right of the clip's out-point, so we need to
        # mask off the actual bounds.
        cr.rectangle(bounds.x1, bounds.y1, width, height)
        cr.clip()

        # tdur = duration in ns of thumbnail
        # sof  = start of file in pixel coordinates
        x1 = bounds.x1
        sof = Zoomable.nsToPixel(element.start - element.in_point) +\
            hscroll_pos

        # i = left edge of thumbnail to be drawn. We start with x1 and
        # subtract the distance to the nearest leftward rectangle.
        # Justification of the following:
        #                i = sof + k * twidth
        #                i = x1 - delta
        # sof + k * twidth = x1 - delta
        #           i * tw = (x1 - sof) - delta
        #    <=>     delta = x1 - sof (mod twidth).
        # Fortunately for us, % works on floats in python.

        i = x1 - ((x1 - sof) % (self.twidth + self._spacing()))

        # j = timestamp *within the element* of thumbnail to be drawn. we want
        # timestamps to be numerically stable, but in practice this seems to
        # give good enough results. It might be possible to improve this
        # further, which would result in fewer thumbnails needing to be
        # generated.
        j = Zoomable.pixelToNs(i - sof)
        istep = self.twidth + self._spacing()
        jstep = self.tdur + Zoomable.pixelToNs(self.spacing)

        while i < bounds.x2:
            self._thumbForTime(cr, j, i, y1)
            cr.rectangle(i - 1, y1, self.twidth + 2, self.theight)
            i += istep
            j += jstep
            cr.fill()
Example #8
0
    def drawBackground(self, allocation):
        self.pixmap.draw_rectangle(
            self.style.bg_gc[gtk.STATE_NORMAL],
            True,
            0, 0,
            allocation.width, allocation.height)

        offset = int(Zoomable.nsToPixel(self.getShadedDuration())) - self.pixmap_offset
        if offset > 0:
            self.pixmap.draw_rectangle(
                self.style.bg_gc[gtk.STATE_ACTIVE],
                True,
                0, 0,
                int(offset),
                int(allocation.height))
Example #9
0
 def _request_size(self):
     w = Zoomable.nsToPixel(self.max_duration)
     self.set_bounds(0, 0, w, self._height)
     self._razor.props.height = self._height
     self.get_root_item().changed(True)
Example #10
0
 def twidth(self):
     return Zoomable.nsToPixel(self.tdur)
Example #11
0
 def _request_size(self):
     alloc = self.get_allocation()
     w = Zoomable.nsToPixel(self.max_duration)
     h = max(self._height, alloc.height)
     self.set_bounds(0, 0, w, h)
     self._playhead.props.height = h + 10
Example #12
0
 def _hadjValueChangedCb(self, hadj):
     self.pixel_position_offset = Zoomable.nsToPixel(
         self.position) - hadj.get_value()
Example #13
0
 def twidth(self):
     return Zoomable.nsToPixel(self.tdur)
Example #14
0
 def do_simple_update(self, cr):
     cr.identity_matrix()
     if self.element.factory:
         self.bounds = goocanvas.Bounds(
             0, 0, Zoomable.nsToPixel(self.element.duration), self.height)
Example #15
0
 def _hadjValueChangedCb(self, hadj):
     self.pixel_position_offset = Zoomable.nsToPixel(self.position) - hadj.get_value()
Example #16
0
 def _request_size(self):
     alloc = self.get_allocation()
     w = Zoomable.nsToPixel(self.max_duration)
     h = max(self._height, alloc.height)
     self.set_bounds(0, 0, w, h)
     self._playhead.props.height = h + 10