Changeset 1884

Show
Ignore:
Timestamp:
08/09/07 01:41:19 (1 year ago)
Author:
arj..@yirdis.nl
Message:
  • update !IConnect interface definition
  • Added todos to handle tool.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gaphor/trunk/gaphor/diagram/interfaces.py

    r1519 r1884  
    5858    """ 
    5959 
    60     def connect(self, handle, x, y): 
     60    def connect(self, handle): 
    6161        """ 
    6262        Connect a line's handle to element. 
    63         x and y are translated to the element the handle is connecting to. 
    6463 
    6564        Note that at the moment of the connect, handle.connected_to may point 
     
    7574        """ 
    7675 
    77     def connect_constraint(self, handle, x, y): 
     76    def connect_constraint(self, handle): 
    7877        """ 
    7978        Connect a handle to the element. 
     
    8685        """ 
    8786 
    88     def glue(self, handle, x, y): 
     87    def glue(self, handle): 
    8988        """ 
    9089        Determine if a handle can glue to a specific element. 
     
    10099    interactions contain lifelines and components contain classes objects. 
    101100    """ 
     101 
    102102    def pre_can_contain(self): 
    103103        """ 
     
    105105        class. Method called before item creation. 
    106106        """ 
    107  
    108107 
    109108    def can_contain(self): 
  • gaphor/trunk/gaphor/ui/diagramtools.py

    r1880 r1884  
    147147        item = view.hovered_item 
    148148        if item and item is view.focused_item and isinstance(item, Line): 
    149             h = item.handles() 
     149            handles = item.handles() 
    150150            x, y = context.view.get_matrix_v2i(item).transform_point(event.x, event.y) 
    151             for h1, h2 in zip(h[:-1], h[1:]): 
     151            for h1, h2 in zip(handles[:-1], handles[1:]): 
    152152                xp = (h1.x + h2.x) / 2 
    153153                yp = (h1.y + h2.y) / 2 
    154154                if distance_point_point_fast((x,y), (xp, yp)) <= 4: 
    155                     segment = h.index(h1) 
     155                    segment = handles.index(h1) 
    156156                    item.split_segment(segment) 
    157157                    self.grab_handle(item, item.handles()[segment + 1]) 
     
    165165        if super(ConnectHandleTool, self).on_button_release(context, event): 
    166166            if grabbed_handle and grabbed_item: 
    167                 h = grabbed_item.handles() 
    168                 if h[0] is grabbed_handle or h[-1] is grabbed_handle: 
     167                handles = grabbed_item.handles() 
     168                if handles[0] is grabbed_handle or handles[-1] is grabbed_handle: 
    169169                    return True 
    170                 segment = h.index(grabbed_handle) 
    171                 before = h[segment - 1] 
    172                 after = h[segment + 1] 
     170                segment = handles.index(grabbed_handle) 
     171                before = handles[segment - 1] 
     172                after = handles[segment + 1] 
    173173                d, p = distance_line_point(before.pos, after.pos, grabbed_handle.pos) 
    174174                if d < 2: 
    175175                    grabbed_item.merge_segment(segment) 
     176                    # TODO: ensure constraints are updated 
    176177            return True 
    177178