Skip to content

Commit

Permalink
resizer is drawn as a "stripy triangle" again, plus some comments and…
Browse files Browse the repository at this point in the history
… renaming in HandleMorph
  • Loading branch information
davidedc committed Jan 10, 2018
1 parent b5af6f2 commit f5360bd
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions src/HandleMorph.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class HandleMorph extends Morph
# of the pixelRatio (i.e. after the restore)
@paintHighlight aContext, al, at, w, h

doPath: (context, leftArrowPoint, rightArrowPoint, arrowPieceLeftUp, arrowPieceLeftDown, arrowPieceRightUp, arrowPieceRightDown) ->
drawArrow: (context, leftArrowPoint, rightArrowPoint, arrowPieceLeftUp, arrowPieceLeftDown, arrowPieceRightUp, arrowPieceRightDown) ->
context.beginPath()
context.moveTo 0.5 + leftArrowPoint.x, 0.5 + leftArrowPoint.y
context.lineTo 0.5 + leftArrowPoint.x + arrowPieceLeftUp.x, 0.5 + leftArrowPoint.y + arrowPieceLeftUp.y
Expand All @@ -166,6 +166,8 @@ class HandleMorph extends Morph
context.stroke()

drawHandle: (context) ->

# horizontal arrow
if @type is "resizeHorizontalHandle" or @type is "moveHandle"
p0 = @bottomLeft().subtract(@position())
p0 = p0.subtract new Point 0, Math.ceil(@height()/2)
Expand All @@ -177,8 +179,9 @@ class HandleMorph extends Morph
arrowPieceLeftDown = new Point Math.ceil(@width()/5),Math.ceil(@height()/5)
arrowPieceRightUp = new Point -Math.ceil(@width()/5),-Math.ceil(@height()/5)
arrowPieceRightDown = new Point -Math.ceil(@width()/5),Math.ceil(@height()/5)
@doPath context, leftArrowPoint, rightArrowPoint, arrowPieceLeftUp, arrowPieceLeftDown, arrowPieceRightUp, arrowPieceRightDown
@drawArrow context, leftArrowPoint, rightArrowPoint, arrowPieceLeftUp, arrowPieceLeftDown, arrowPieceRightUp, arrowPieceRightDown

# vertical arrow
if @type is "resizeVerticalHandle" or @type is "moveHandle"
p0 = @bottomCenter().subtract @position()

Expand All @@ -189,19 +192,30 @@ class HandleMorph extends Morph
arrowPieceLeftDown = new Point Math.ceil(@width()/5), -Math.ceil(@height()/5)
arrowPieceRightUp = new Point -Math.ceil(@width()/5), Math.ceil(@height()/5)
arrowPieceRightDown = new Point Math.ceil(@width()/5), Math.ceil(@height()/5)
@doPath context, leftArrowPoint, rightArrowPoint, arrowPieceLeftUp, arrowPieceLeftDown, arrowPieceRightUp, arrowPieceRightDown
@drawArrow context, leftArrowPoint, rightArrowPoint, arrowPieceLeftUp, arrowPieceLeftDown, arrowPieceRightUp, arrowPieceRightDown


# draw the traditional "striped triangle" resizer
if @type is "resizeBothDimensionsHandle"
leftArrowPoint = @extent().floorDivideBy 7
rightArrowPoint = @bottomRight().subtract(@position()).subtract @extent().floorDivideBy 7

arrowPieceLeftUp = new Point Math.ceil(@width()/4), 0
arrowPieceLeftDown = new Point 0, Math.ceil(@height()/4)
arrowPieceRightUp = new Point 0,-Math.ceil(@width()/4)
arrowPieceRightDown = new Point -Math.ceil(@width()/4),0
bottomLeft = @bottomLeft().subtract(@position())
topRight = @topRight().subtract(@position())

bottomLeftSweep = bottomLeft.copy()
topRightSweep = topRight.copy()

# draw the lines sweeping from long lines
# down to the short ones at the corner
for i in [0..@height()] by 6
# bottomLeftSweep moves right
bottomLeftSweep.x = bottomLeft.x + i
# topRightSweep moves down
topRightSweep.y = topRight.y + i
context.beginPath()
context.moveTo bottomLeftSweep.x, bottomLeftSweep.y
context.lineTo topRightSweep.x, topRightSweep.y
context.closePath()
context.stroke()

@doPath(context, leftArrowPoint, rightArrowPoint, arrowPieceLeftUp, arrowPieceLeftDown, arrowPieceRightUp, arrowPieceRightDown)

handleMorphRenderingHelper: (context, color, shadowColor) ->
context.lineWidth = 1
Expand Down

0 comments on commit f5360bd

Please sign in to comment.