Skip to content

Commit

Permalink
Fix dropzone hightlight for node and component
Browse files Browse the repository at this point in the history
  • Loading branch information
amolenaar committed Apr 27, 2020
1 parent a0eb1ea commit cc05039
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
4 changes: 3 additions & 1 deletion gaphor/UML/components/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from gaphor import UML
from gaphor.core.modeling.properties import attribute
from gaphor.diagram.presentation import Classified, ElementPresentation
from gaphor.diagram.shapes import Box, EditableText, Text, VerticalAlign
from gaphor.diagram.shapes import Box, EditableText, Text, VerticalAlign, draw_highlight
from gaphor.diagram.support import represents
from gaphor.diagram.text import FontWeight
from gaphor.UML.classes.stereotype import stereotype_compartments
Expand Down Expand Up @@ -83,6 +83,8 @@ def draw_node(box, context, bounding_box):

cr.rectangle(0, 0, w, h)

draw_highlight(context)

cr.move_to(0, 0)
cr.line_to(d, -d)
cr.line_to(w + d, -d)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_draw_on_canvas():
exec_spec = ExecutionSpecificationItem()
canvas.add(exec_spec)
cr = instant_cairo_context()
exec_spec.draw(Context(cairo=cr))
exec_spec.draw(Context(cairo=cr, dropzone=False))


def test_allow_execution_specification_to_lifeline(diagram):
Expand Down
12 changes: 8 additions & 4 deletions gaphor/diagram/shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ def draw_border(box, context, bounding_box):
cr.set_source_rgb(1, 1, 1) # white
cr.fill_preserve()
cr.set_source(color)

draw_highlight(context)

cr.stroke()


Expand All @@ -87,14 +90,15 @@ def draw_top_separator(box, context, bounding_box):


def draw_highlight(context):
if not context.dropzone:
return
highlight_color = (0, 0, 1, 0.4)
cr = context.cairo
cr.save()
try:
if context.dropzone:
cr.set_source_rgba(*highlight_color)
cr.set_line_width(cr.get_line_width() * 3.141)
cr.stroke_preserve()
cr.set_source_rgba(*highlight_color)
cr.set_line_width(cr.get_line_width() * 3.141)
cr.stroke_preserve()
finally:
cr.restore()

Expand Down

0 comments on commit cc05039

Please sign in to comment.