Beispiel #1
0
 def do_simple_update(self, cr):
     cr.identity_matrix()
     if self.element.factory:
         self.visible_width = self.nsToPixel(self.element.duration)
         self.bounds = GooCanvas.CanvasBounds(0, 0,
             self.visible_width + KW_LABEL_X_OVERFLOW,
             self.height + KW_LABEL_Y_OVERFLOW)
Beispiel #2
0
    def do_simple_paint(self, cr, bounds):
        cr.identity_matrix()
        if self.interpolator:
            cr.save()
            # set clipping region to the visible portion of the clip
            vis_bounds = intersect(
                GooCanvas.CanvasBounds(
                    self.bounds.x1, self.bounds.y1 + KW_LABEL_Y_OVERFLOW,
                    self.bounds.x2 - KW_LABEL_X_OVERFLOW, self.bounds.y2), bounds)
            vis_width = vis_bounds.x2 - vis_bounds.x1
            vis_height = vis_bounds.y2 - vis_bounds.y1
            cr.rectangle(vis_bounds.x1, vis_bounds.y1, vis_width, vis_height)
            cr.clip()

            self.make_curve(cr)
            cr.set_line_width(self.line_width)
            cr.set_source_rgb(1, 0, 0)
            cr.stroke()
            self.make_keyframes(cr)
            cr.set_line_width(1.0)
            cr.set_source_rgb(1, 1, 1)
            cr.fill_preserve()
            cr.set_source_rgb(1, 0, 0)
            cr.stroke()

            # re-draw the focused keyframe, if it exists, inverted
            if self._focused_kf:

                self._controlPoint(cr, self._focused_kf)
                cr.set_source_rgb(1, 0, 0)
                cr.fill_preserve()
                cr.set_source_rgb(1, 1, 1)
                cr.stroke()

                x, y = self.keyframes[self._focused_kf]
                x += KW_LABEL_X_OFFSET
                y += KW_LABEL_Y_OFFSET
                text = self.interpolator.formatValue(self._focused_kf.value)
                w, h = cr.text_extents("0" * len(text))[2:4]

                # reset clip region to the full bounds of the item
                bounds = intersect(self.bounds, bounds)
                width = bounds.x2 - bounds.x1
                height = bounds.y2 - bounds.y1
                # cr.reset_clip()
                cr.restore()
                cr.rectangle(bounds.x1, bounds.y1, width, height)
                cr.clip()

                # draw the value label
                roundedrec(cr, x - KW_LABEL_HPAD2, y - KW_LABEL_VPAD2,
                    w + KW_LABEL_HPAD, h + KW_LABEL_VPAD, r=10)
                cr.set_source_rgb(1, 1, 1)
                cr.fill()
                cr.set_source_rgb(1, 0, 0)
                cr.move_to(x, y + h)
                cr.show_text(text)
            else:
                cr.restore()
Beispiel #3
0
 def getOverlapedAreas(self, area):
     offset = 2
     start_point = (area.props.x + 5, area.props.y + offset)
     end_point = (area.props.x + area.props.width - offset, area.props.y + area.props.height - offset)
     bounds = GooCanvas.CanvasBounds()
     bounds.x1, bounds.y1, bounds.x2, bounds.y2 = start_point + end_point
     overlaped_items = self.get_items_in_area(bounds, True, True, True)
     if area in overlaped_items:
         overlaped_items.remove(area)
     return overlaped_items
Beispiel #4
0
def intersect(b1, b2):
    return GooCanvas.CanvasBounds(max(b1.x1, b2.x1), max(b1.y1, b2.y1),
        min(b1.x2, b2.x2), min(b1.y2, b2.y2))