Changeset 999
- Timestamp:
- 09/06/06 23:13:25 (2 years ago)
- Files:
-
- gaphas/trunk/ChangeLog (modified) (1 diff)
- gaphas/trunk/README.txt (modified) (2 diffs)
- gaphas/trunk/demo.py (modified) (1 diff)
- gaphas/trunk/gaphas/canvas.py (modified) (1 diff)
- gaphas/trunk/gaphas/item.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gaphas/trunk/ChangeLog
r997 r999 1 2006-09-07 Arjan Molenaar <arjan_at_yirdis_dot_nl> 2 3 * item.py, canvas.py: item removal (with connected handles) solved, 4 use a callback method on the handle. 5 1 6 2006-09-06 Arjan Molenaar <arjan_at_yirdis_dot_nl> 2 7 gaphas/trunk/README.txt
r929 r999 36 36 37 37 Stage 3: 38 -make double and triple click work.39 -text edit tool (gtk.Edit in popup window?)38 v make double and triple click work. 39 v text edit tool (gtk.Edit in popup window?) 40 40 41 41 Stage n: … … 130 130 131 131 132 Interaction 133 ----------- 134 Interaction with the canvas view (visual component) is handled by tools. 135 Although the default tools do a fair amount of work, in most cases you'll 136 see that especially the way items connect with each other is not the way 137 you want it. That's okay. HandleTool provides some hooks (connect, disconnect and glue) to implement custom connection behavior (in fact, the default implementation doesn't do any connecting at all. 138 139 One of the problems you'll face is what to do when an item is removed from the 140 canvas and there are other items (lines) connected to. This problem can be 141 solved by providing a disconnect handler to the handle instance ones it is 142 connected. A callable object (e.g. function) can be assigned to the handle. It 143 is called at the moment the item it's connected to is removed from the canvas. 144 145 132 146 Files 133 147 ===== gaphas/trunk/demo.py
r997 r999 87 87 handle._connect_constraint = LineConstraint(view.canvas, glue_item, glue_item.handles()[s], glue_item.handles()[(s+1)%4], item, handle) 88 88 view.canvas.solver.add_constraint(handle._connect_constraint) 89 def handle_disconnect(): 90 view.canvas.solver.remove_constraint(handle._connect_constraint) 91 handle._connect_constraint = None 92 handle.disconnect = handle_disconnect 89 93 return 90 94 gaphas/trunk/gaphas/canvas.py
r998 r999 95 95 by items, those references are not cleaned up). 96 96 97 So far, this is not the way to do it... 98 """ 99 def disconnect(var): 100 for c in self._solver.constraints_with_variable(var): 101 self._solver.remove_constraint(c) 102 103 #for i, h in self.get_connected_items(item): 104 #for h in item.handles(): 105 # disconnect(h.x) 106 # disconnect(h.y) 107 # h.connected_to = None 97 This method implies the constraint used to keep the handle in place 98 is connected to Handle.connect_constraint. 99 """ 100 for i, h in self.get_connected_items(item): 101 #self._solver.remove_constraint(h.connect_constraint) 102 h.disconnect() 103 # Never mind.. 104 h.connected_to = None 105 h.disconnect = lambda: 0 108 106 109 107 def get_all_items(self): gaphas/trunk/gaphas/item.py
r997 r999 12 12 class Handle(object): 13 13 """Handles are used to support modifications of Items. 14 15 If the handle is connected to an item, the connected_to property should 16 refer to the item. A disconnect handler should be provided that handles 17 all disconnect behavior (e.g. clean up constraints and connected_to). 14 18 """ 15 19 16 20 x = solvable() 17 21 y = solvable() … … 27 31 self.visible = True 28 32 self.connected_to = None 33 # The constraint used to keep the handle visually connected 34 self.disconnect = lambda: 0 29 35 30 36 def _set_pos(self, pos):
