Skip to content

Commit

Permalink
avoiding a lot of broken rectangles by checking...
Browse files Browse the repository at this point in the history
…whether the morph being changed has a parent or not. Morphs without
parents (apart from Hand and worldMorph) don’t show up.
  • Loading branch information
davidedc committed Feb 19, 2015
1 parent ac62b51 commit 4e0079d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/HandMorph.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class HandMorph extends Morph
changed: ->
if @world?
b = @boundsIncludingChildren()
@world.broken.push @boundsIncludingChildren().spread() unless b.extent().eq(new Point())
if !b.extent().eq(new Point())
@world.broken.push @boundsIncludingChildren().spread()


# HandMorph navigation:
Expand Down
8 changes: 2 additions & 6 deletions src/MenuMorph.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ class MenuMorph extends BoxMorph
@label.borderColor = @borderColor
@label.setExtent text.extent().add(4) # here!
@label.text = text
@add @label

updateRendering: ->
# console.log "menu update rendering"
Expand Down Expand Up @@ -230,17 +229,14 @@ class MenuMorph extends BoxMorph
# previous one.
if world.activeMenu
world.activeMenu = world.activeMenu.destroy()
@setPosition pos
world.add @
# it's better do these movement
# operations after adding to the world
# in general, as a concept.
# Specifically, the @keepWithin method
# the @keepWithin method
# needs to know the extent of the morph
# so it must be called after the world.add
# method. If you call before, there is
# nopainting happening and the morph doesn't
# know its extent.
@setPosition pos
@keepWithin world
if SystemTestsRecorderAndPlayer.state != SystemTestsRecorderAndPlayer.IDLE and SystemTestsRecorderAndPlayer.alignmentOfMorphIDsMechanism
world.alignIDsOfNextMorphsInSystemTests()
Expand Down
12 changes: 9 additions & 3 deletions src/Morph.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ class Morph extends MorphicNode
Math.round(w),
Math.round(h)

if @world().showRedraws
if world.showRedraws
randomR = Math.round(Math.random()*255)
randomG = Math.round(Math.random()*255)
randomB = Math.round(Math.random()*255)
Expand Down Expand Up @@ -870,13 +870,19 @@ class Morph extends MorphicNode
changed: ->
if @trackChanges
w = @root()
w.broken.push @visibleBounds().spread() if w instanceof WorldMorph
# unless we are the main desktop, then if the morph has no parent
# don't add the broken rect since the morph is not visible
if w instanceof WorldMorph and (@ instanceof WorldMorph or @parent?)
w.broken.push @visibleBounds().spread()
@parent.childChanged @ if @parent

fullChanged: ->
if @trackChanges
w = @root()
w.broken.push @boundsIncludingChildren().spread() if w instanceof WorldMorph
# unless we are the main desktop, then if the morph has no parent
# don't add the broken rect since the morph is not visible
if w instanceof WorldMorph and ((@ instanceof WorldMorph or @parent?))
w.broken.push @boundsIncludingChildren().spread()

childChanged: ->
# react to a change in one of my children,
Expand Down
9 changes: 7 additions & 2 deletions src/PenMorph.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ class PenMorph extends Morph
changed: ->
if @isWarped is false
w = @root()
w.broken.push @visibleBounds().spread() if w instanceof WorldMorph
# unless we are the main desktop, then if the morph has no parent
# don't add the broken rect since the morph is not visible
if w instanceof WorldMorph and (@ instanceof WorldMorph or @parent?)
w.broken.push @visibleBounds().spread()
@parent.childChanged @ if @parent


Expand Down Expand Up @@ -116,7 +119,9 @@ class PenMorph extends Morph
context.moveTo from.x, from.y
context.lineTo to.x, to.y
context.stroke()
if @isWarped is false
# unless we are the main desktop, then if the morph has no parent
# don't add the broken rect since the morph is not visible
if @isWarped is false and (@ instanceof WorldMorph or @parent?)
@world().broken.push start.rectangle(dest).expandBy(Math.max(@penSize / 2, 1)).intersect(@parent.visibleBounds()).spread()


Expand Down

0 comments on commit 4e0079d

Please sign in to comment.