The Trunk: Morphic-nice.537.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Morphic-nice.537.mcz

commits-2
Nicolas Cellier uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-nice.537.mcz

==================== Summary ====================

Name: Morphic-nice.537
Author: nice
Time: 10 May 2011, 11:04:46.511 pm
UUID: 8ab5e615-02ae-4e89-be08-cb23ae0717bc
Ancestors: Morphic-bf.536

Minor refactorings
- when binary is intention revealing
- underscore assignment

=============== Diff against Morphic-bf.536 ===============

Item was changed:
  ----- Method: BalloonCanvas>>fillRoundRect:radius:fillStyle: (in category 'drawing-rectangles') -----
  fillRoundRect: aRectangle radius: radius fillStyle: fillStyle
  | points |
  radius asPoint <= (0@0)
  ifTrue:[^self fillRectangle: aRectangle fillStyle: fillStyle].
  (radius * 2) asPoint >= aRectangle extent
  ifTrue:[^self fillOval: aRectangle fillStyle: fillStyle].
  "decompose aRectangle into bezier form"
  points := self makeRoundRectShape: aRectangle radius: radius.
  "blast the bezier shape out"
  self
  drawBezierShape: points
  color: fillStyle
  borderWidth: 0
  borderColor: nil.
  !

Item was changed:
  ----- Method: BalloonCanvas>>frameRoundRect:radius:width:color: (in category 'drawing-rectangles') -----
  frameRoundRect: aRectangle radius: radius width: borderWidth color: borderColor
  | outerPoints innerRect innerRadius innerPoints |
  (borderWidth isZero or:[borderColor isTransparent])
  ifTrue:[^self].
  radius asPoint <= (0@0)
  ifTrue:[^self frameRectangle: aRectangle width: borderWidth color: borderColor].
  (radius * 2) asPoint >= aRectangle extent
  ifTrue:[^self frameOval: aRectangle width: borderWidth color: borderColor].
  "decompose inner rectangle into bezier shape"
  innerRect := aRectangle insetBy: borderWidth.
  innerRect area <= 0
  ifTrue:[^self fillRoundRect: aRectangle radius: radius fillStyle: borderColor].
  innerRadius := (radius - borderWidth) asPoint.
  innerPoints := self makeRoundRectShape: innerRect radius: innerRadius.
  "decompose outer rectangle into bezier shape"
  outerPoints := self makeRoundRectShape: aRectangle radius: radius.
  self
  drawGeneralBezierShape: (Array with: outerPoints with: innerPoints)
  color: borderColor
  borderWidth: 0
  borderColor: nil.!

Item was changed:
  ----- Method: MorphicModel class>>compileAccessorsFor: (in category 'compilation') -----
  compileAccessorsFor: varName
  self compile: (
  '&var
  "Return the value of &var"
  ^ &var'
  copyReplaceAll: '&var' with: varName)
  classified: 'public access' notifying: nil.
  self compile: (
  '&varPut: newValue
  "Assign newValue to &var.
  Add code below to update related graphics appropriately..."
 
+ &var := newValue.'
- &var _ newValue.'
  copyReplaceAll: '&var' with: varName)
  classified: 'public access' notifying: nil.
  self compile: (
  '&var: newValue
  "Assigns newValue to &var and updates owner"
+ &var := newValue.
- &var _ newValue.
  self propagate: &var as: ''&var:'''
  copyReplaceAll: '&var' with: varName)
  classified: 'private - propagation' notifying: nil.
  !

Item was changed:
  ----- Method: NewParagraph>>fastFindFirstLineSuchThat: (in category 'private') -----
  fastFindFirstLineSuchThat: lineBlock
  "Perform a binary search of the lines array and return the index
  of the first element for which lineBlock evaluates as true.
  This assumes the condition is one that goes from false to true for
  increasing line numbers (as, eg, yval > somey or start char > somex).
  If lineBlock is not true for any element, return size+1."
  | index low high |
  low := 1.
  high := lines size.
+ [low > high]
- [index := high + low // 2.
- low > high]
  whileFalse:
+ [index := high + low // 2.
+ (lineBlock value: (lines at: index))
- [(lineBlock value: (lines at: index))
  ifTrue: [high := index - 1]
  ifFalse: [low := index + 1]].
  ^ low!

Item was changed:
  ----- Method: PolygonMorph>>nudgeForLabel: (in category 'attachments') -----
  nudgeForLabel: aRectangle
  "Try to move the label off me. Prefer labels on the top and right."
 
  | i flags nudge |
  (self bounds intersects: aRectangle) ifFalse: [^ 0 @ 0 ].
  flags := 0.
  nudge := 0 @ 0.
  i := 1.
  aRectangle lineSegmentsDo: [ :rp1 :rp2 | | rectSeg |
  rectSeg := LineSegment from: rp1 to: rp2.
  self straightLineSegmentsDo: [ :lp1 :lp2 | | polySeg int |
  polySeg := LineSegment from: lp1 to: lp2.
  int := polySeg intersectionWith: rectSeg.
  int ifNotNil: [ flags := flags bitOr: i ].
  ].
  i := i * 2.
  ].
  "Now flags has bitflags for which sides"
  nudge := flags caseOf: {
  "no intersection"
+ [ 2r0000 ] -> [ 0 @ 0 ].
- [ 0 ] -> [ 0 @ 0 ].
  "2 adjacent sides only"
+ [ 2r1001 ] -> [ 1 @ 1 ].
+ [ 2r0011 ] -> [ -1 @ 1 ].
+ [ 2r1100 ] -> [ 1 @ -1 ].
+ [ 2r0110 ] -> [ -1 @ -1 ].
- [ 9 ] -> [ 1 @ 1 ].
- [ 3 ] -> [ -1 @ 1 ].
- [ 12 ] -> [ 1 @ -1 ].
- [ 6 ] -> [ -1 @ -1 ].
  "2 opposite sides only"
+ [ 2r1010 ] -> [ 0 @ -1 ].
+ [ 2r0101 ] -> [ 1 @ 0 ].
- [ 10 ] -> [ 0 @ -1 ].
- [ 5 ] -> [ 1 @ 0 ].
  "only 1 side"
+ [ 2r1000 ] -> [ -1 @ 0 ].
+ [ 2r0001 ] -> [ 0 @ -1 ].
+ [ 2r0010 ] -> [ 1 @ 0 ].
+ [ 2r0100 ] -> [ 0 @ 1 ].
- [ 8 ] -> [ -1 @ 0 ].
- [ 1 ] -> [ 0 @ -1 ].
- [ 2 ] -> [ 1 @ 0 ].
- [ 4 ] -> [ 0 @ 1 ].
  "3 sides"
+ [ 2r1011 ] -> [ 0 @ 1 ].
+ [ 2r1101 ] -> [ 1 @ 0 ].
+ [ 2r1110 ] -> [ 0 @ -1 ].
+ [ 2r0111 ] -> [ -1 @ 0 ].
- [ 11 ] -> [ 0 @ 1 ].
- [ 13 ] -> [ 1 @ 0 ].
- [ 14 ] -> [ 0 @ -1 ].
- [ 7 ] -> [ -1 @ 0 ].
   "all sides"
+ [ 2r1111 ] -> [ 1 @ -1 "move up and to the right" ].
- [ 15 ] -> [ 1 @ -1 "move up and to the right" ].
  }.
  ^nudge!