Changeset 1101
- Timestamp:
- 12/08/06 01:56:37 (2 years ago)
- Files:
-
- gaphor/branches/new-canvas/gaphor/actions/tests/test_placementactions.py (modified) (1 diff)
- gaphor/branches/new-canvas/gaphor/adapters/editors.py (modified) (1 diff)
- gaphor/branches/new-canvas/gaphor/diagram/items.py (modified) (1 diff)
- gaphor/branches/new-canvas/gaphor/diagram/objectnode.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gaphor/branches/new-canvas/gaphor/actions/tests/test_placementactions.py
r1100 r1101 104 104 self.do_test_placement(placementactions.FlowFinalNodePlacementAction()) 105 105 106 def test_objectnode_placement(self): 107 self.do_test_placement(placementactions.ObjectNodePlacementAction()) 108 106 109 def test_flow_placement(self): 107 110 self.do_test_placement(placementactions.FlowPlacementAction()) gaphor/branches/new-canvas/gaphor/adapters/editors.py
r1098 r1101 66 66 67 67 component.provideAdapter(NamedItemEditor) 68 69 70 class ObjectNodeItemEditor(NamedItemEditor): 71 component.adapts(items.ObjectNodeItem) 72 73 def is_editable(self, x, y): 74 self.edit_tag = (x, y) in self._item.tag_bounds 75 return True 76 77 def get_text(self): 78 if self.edit_tag: 79 return self._item.subject.upperBound.value 80 else: 81 return super(ObjectNodeItemEditor, self).get_text() 82 83 def update_text(self, text): 84 if self.edit_tag: 85 self._item.subject.upperBound.value = text 86 else: 87 return super(ObjectNodeItemEditor, self).update_text(text) 88 self._item.request_update() 89 90 component.provideAdapter(ObjectNodeItemEditor) 68 91 69 92 gaphor/branches/new-canvas/gaphor/diagram/items.py
r1100 r1101 37 37 from gaphor.diagram.activitynodes import ForkNodeItem 38 38 from gaphor.diagram.flow import FlowItem 39 from gaphor.diagram.objectnode import ObjectNodeItem 39 40 40 41 # Use Cases: gaphor/branches/new-canvas/gaphor/diagram/objectnode.py
r1100 r1101 11 11 #from gaphor.diagram.groupable import GroupBase 12 12 from gaphor.diagram.nameditem import NamedItem 13 from gaphas.util import text_extents, text_multiline 14 from gaphas.geometry import Rectangle, distance_rectangle_point 13 15 14 16 … … 21 23 """ 22 24 23 __uml__ = UML.ObjectNode25 __uml__ = UML.ObjectNode 24 26 25 27 __style__ = { … … 42 44 self._tag = '' #TextElement('value', '{ upperBound = %s }', '*') 43 45 self._tag_bounds = None 44 #self.add(self._upper_bound)45 46 #self._ordering = diacanvas.shape.Text()47 #self._ordering.set_font_description(pango.FontDescription(font.FONT))48 #self._ordering.set_alignment(pango.ALIGN_CENTER)49 #self._ordering.set_markup(False)50 46 51 47 self._show_ordering = False … … 59 55 60 56 ordering = property(lambda s: s.subject.ordering, _set_ordering) 57 58 tag_bounds = property(lambda s: s._tag_bounds) 61 59 62 60 def _set_show_ordering(self, value): … … 100 98 # TODO: format tag properly: 101 99 if self.subject.upperBound: 102 self._tag = '{ upperBound = %s } ' % self.subject.upperBound.value100 self._tag = '{ upperBound = %s }\n' % self.subject.upperBound.value 103 101 104 102 self._tag += '{ ordering = %s }' % self.subject.ordering 105 103 106 w, h = text_extents( self._tag)104 w, h = text_extents(context.cairo, self._tag, multiline=True) 107 105 x = (self.width - w) / 2 108 y = self.height + self.style.margin[ 0]106 y = self.height + self.style.margin[2] 109 107 self._tag_bounds = Rectangle(x, y, width=w, height=h) 108 109 def point(self, x, y): 110 """ 111 Return the distance from (x, y) to the item. 112 """ 113 d1 = super(ObjectNodeItem, self).point(x, y) 114 d2 = distance_rectangle_point(self._tag_bounds, (x, y)) 115 return min(d1, d2) 110 116 111 117 def draw(self, context):
