def do_simple_update(self, cr): cr.identity_matrix() if self.element.factory: self.visible_width = self.nsToPixel(self.element.duration) self.bounds = goocanvas.Bounds(0, 0, self.visible_width + KW_LABEL_X_OVERFLOW, self.height + KW_LABEL_Y_OVERFLOW)
def getAllAreas(self): bounds = goocanvas.Bounds(*self.get_bounds()) areas = [ area for area in self.get_items_in_area(bounds, True, True, True) if isinstance(area, goocanvas.Rect) ] return areas
def getAllAreas(self): bounds = goocanvas.Bounds(*self.get_bounds()) areas = [ area for area in self.get_items_in_area(bounds, True, True, True) if isinstance(area, Box) and area not in self.frame ] return areas
def do_simple_paint(self, cr, bounds): cr.save() cr.identity_matrix() if self.interpolator: # set clipping region to the visible portion of the clip vis_bounds = intersect( goocanvas.Bounds( 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()
def getOverlapedAreas(area): canvas = area.get_canvas() offset = 2 #print "offset x y ", x0, y0 = offset_parent_position(area.get_parent()) item_position = area.get_simple_transform() print "item position overlaps", item_position sx = item_position[0] sy = item_position[1] ''' start_point = (area.props.x + (x0), area.props.y + (offset+y0)) end_point = (area.props.x + x0+(area.props.width - offset), area.props.y +y0+ (area.props.height - offset)) ''' start_point = (sx + (x0), sy + (offset + y0)) end_point = (sx + x0 + (area.props.width - offset), sy + y0 + (area.props.height - offset)) bounds = goocanvas.Bounds(*(start_point + end_point)) print start_point, end_point overlaped_items = canvas.get_items_in_area(bounds, True, True, True) print len(overlaped_items) found_bg = None for item_over in overlaped_items: itemData = item_over.get_data("itemProp") if itemData is not None: if itemData['main'] == 'Background Rect Item': found_bg = item_over break if found_bg is not None: #Remove item background overlaped_items.remove(found_bg) return overlaped_items
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)
def getItemsInArea(self, x1, y1, x2, y2): ''' Permits to get the Non UI L{Track}/L{TrackObject} in a list of set corresponding to the L{Track}/L{TrackObject} which are in the are @param x1: The horizontal coordinate of the up left corner of the area @type x1: An C{int} @param y1: The vertical coordinate of the up left corner of the area @type y1: An C{int} @param x2: The horizontal coordinate of the down right corner of the area @type x2: An C{int} @param x2: The vertical coordinate of the down right corner of the area @type x2: An C{int} @returns: A list of L{Track}, L{TrackObject} tuples ''' items = self.get_items_in_area(goocanvas.Bounds(x1, y1, x2, y2), True, True, True) if not items: return [], [] tracks = set() track_objects = set() for item in items: if isinstance(item, Track): tracks.add(item.track) elif isinstance(item, TrackObject): track_objects.add(item.element) return tracks, track_objects
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.Bounds(*(start_point + end_point)) overlaped_items = self.get_items_in_area(bounds, True, True, True) return overlaped_items
def _razorReleasedCb(self, unused_canvas, event): self._action.props.active = False x, y = self.convert_from_pixels(event.x, event.y) bounds = goocanvas.Bounds(x, y, x, y) items = self.get_items_in_area(bounds, True, True, True) if items: for item in items: if isinstance(item, TrackObject): self.app.action_log.begin("split object") item.element.split(self._snapToPlayhead(self.pixelToNs(x))) self.app.action_log.commit() return True
def __init__(self, **kwargs): self.bounds = goocanvas.Bounds() self.view = None self.parent = None ## default values for properties #self.title = None #self.description = None #self.can_focus = False #self.visibility = goocanvas.ITEM_VISIBLE #self.visibility_threshold = 0.0 #self.pointer_events = goocanvas.EVENTS_NONE #self.transform = None ## chain to parent constructor gobject.GObject.__init__(self, **kwargs)
class Controller(controller.Controller): __ARROW_COLOR__ = "black" arrow = goocanvas.Polyline(stroke_color=__ARROW_COLOR__) __center = None __prev_pads = [] def enter(self, item, target): self._view.focus() def leave(self, item, target): self._view.unfocus() def drag_start(self): self._canvas.get_root_item().add_child(self.arrow) self.__center = self.center(self._view.socket) points = [self.__center, self.__center] self._mousedown = Point(0, 0) self.arrow.props.points = goocanvas.Points(points) def drag_end(self): self.arrow.remove() for pad in self.__prev_pads: pad.unhilight() if pad.canLink(self._view): pad.linkPads(self._view) def __pads_under_point(self, (x, y)): items = self._canvas.get_items_in_area( goocanvas.Bounds(x - 1, y - 1, x + 1, y + 1), True, True, True) if items: return [ item for item in items if isinstance(item, PadBaseView) ] return []
def intersect(b1, b2): return goocanvas.Bounds(max(b1.x1, b2.x1), max(b1.y1, b2.y1), min(b1.x2, b2.x2), min(b1.y2, b2.y2))
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)
def __init__(self, x1, y1, x2, y2): """ Constructor: x1, y1, x2, y2 : bounding box of the blocker in canvas coordinates (0 - 800 / 0 - 520) """ self.bounds = goocanvas.Bounds(x1, y1, x2, y2)