Changeset 1886
- Timestamp:
- 08/09/07 01:58:01 (1 year ago)
- Files:
-
- gaphor/trunk/gaphor/ui/diagramtools.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gaphor/trunk/gaphor/ui/diagramtools.py
r1884 r1886 45 45 46 46 47 def glue(self, view, item, handle, x,y):47 def glue(self, view, item, handle, vx, vy): 48 48 """ 49 49 Find the nearest item that the handle may connect to. 50 50 51 This is done by iterating over all items and query for an IConnect52 adapter for (itered_item, @item). If such an adapter exists, the53 glue position is determined. The item with the glue point closest54 to thehandle will be glued to.51 This is done by checking for an IConnect adapter for all items in the 52 proximity of ``(vx, xy)``. If such an adapter exists, the glue 53 position is determined. The item with the glue point closest to the 54 handle will be glued to. 55 55 56 56 view: The view 57 57 item: The item who's about to connect, owner of handle 58 58 handle: the handle to connect 59 cx, cy: handle position in canvascoordinates59 vx, vy: handle position in view coordinates 60 60 """ 61 61 # localize methods … … 70 70 glue_pos = (0, 0) 71 71 glue_item = None 72 for i in view.get_items_in_rectangle(( x - dist,y - dist,72 for i in view.get_items_in_rectangle((vx - dist, vy - dist, 73 73 dist * 2, dist * 2), 74 74 reverse=True): … … 77 77 78 78 b = get_item_bounding_box(i) 79 ix, iy = v2i(i).transform_point( x,y)80 if drp(b, ( x,y)) >= max_dist:79 ix, iy = v2i(i).transform_point(vx, vy) 80 if drp(b, (vx, vy)) >= max_dist: 81 81 continue 82 82 … … 100 100 101 101 102 def connect(self, view, item, handle, x,y):103 """ 104 Find an item near @handle that @itemcan connect to and connect.102 def connect(self, view, item, handle, vx, vy): 103 """ 104 Find an item near ``handle`` that ``item`` can connect to and connect. 105 105 106 106 This is done by attempting a glue() operation. If there is something … … 110 110 connected = False 111 111 try: 112 glue_item = self.glue(view, item, handle, x,y)112 glue_item = self.glue(view, item, handle, vx, vy) 113 113 114 114 if glue_item:
