Nicolas Cellier uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-nice.502.mcz ==================== Summary ==================== Name: Morphic-nice.502 Author: nice Time: 29 December 2010, 4:12:44.089 pm UUID: 46f308ec-bfaf-4cca-abeb-ccda9b2c6f4f Ancestors: Morphic-mtf.501 Add a few spaces in order to avoid Transcript warnings about @- ambiguity when recompiling. =============== Diff against Morphic-mtf.501 =============== Item was changed: ----- Method: BalloonCanvas>>makeRoundRectShape:radius: (in category 'private') ----- makeRoundRectShape: aRectangle radius: radius "decompose a rounded rectangle into bezier form" | ovalDiameter rectExtent segments points endPoint seg idx offset rectOffset | ovalDiameter := (radius * 2) asPoint min: aRectangle extent. + (ovalDiameter x <= 0 or: [ovalDiameter y <= 0]) ifTrue: [ - (ovalDiameter x <= 0 or:[ovalDiameter y <= 0]) ifTrue:[ "degenerates into rectangle - just hand back four lines" | topLeft topRight bottomLeft bottomRight | topLeft := aRectangle topLeft. topRight := aRectangle topRight. bottomLeft := aRectangle bottomLeft. bottomRight := aRectangle bottomRight. + points := Array new: 4 * 3. - points := Array new: 4*3. points at: 1 put: topLeft. points at: 2 put: topLeft. points at: 3 put: topRight. points at: 4 put: topRight. points at: 5 put: topRight. points at: 6 put: bottomRight. points at: 7 put: bottomRight. points at: 8 put: bottomRight. points at: 9 put: bottomLeft. points at: 10 put: bottomLeft. points at: 11 put: bottomLeft. points at: 12 put: topLeft. ^points ]. rectExtent := aRectangle extent - ovalDiameter. rectOffset := aRectangle origin. + segments := Bezier2Segment makeEllipseSegments: (0 @ 0 extent: ovalDiameter). - segments := Bezier2Segment makeEllipseSegments: (0@0 extent: ovalDiameter). "patch up the segments to include lines connecting the oval parts. we need: 8*3 points for the oval parts + 4*3 points for the connecting lines" + points := Array new: 12 * 3. - points := Array new: 12*3. idx := 0. "Tweaked offsets to clean up curves. MAD" + endPoint := segments last end + rectOffset + (0 @ -1). + 1 to: 8 by: 2 do: [:i | + i = 1 ifTrue: [offset := rectOffset + (rectExtent x @ 0) + (1 @ -1)]. "top, tr" + i = 3 ifTrue: [offset := rectOffset + rectExtent + (1 @ 1)]. "right, br" + i = 5 ifTrue: [offset := rectOffset + (0 @ rectExtent y) + (0 @ 1)]. "bottom, bl" + i = 7 ifTrue: [offset := rectOffset + (0 @ -1)]."left, tl" - endPoint := segments last end + rectOffset + (0@-1). - 1 to: 8 by: 2 do:[:i| - i = 1 ifTrue:[offset := rectOffset + (rectExtent x @ 0) + (1@-1)]. "top, tr" - i = 3 ifTrue:[offset := rectOffset + rectExtent + (1@1)]. "right, br" - i = 5 ifTrue:[offset := rectOffset + (0 @ rectExtent y) + (0@1)]. "bottom, bl" - i = 7 ifTrue:[offset := rectOffset + (0@-1)]."left, tl" seg := segments at: i. "insert a line segment for the horizontal part of the round rect" + points at: (idx := idx + 1) put: endPoint. + points at: (idx := idx + 1) put: endPoint. + points at: (idx := idx + 1) put: seg start + offset. - points at: (idx := idx+1) put: endPoint. - points at: (idx := idx+1) put: endPoint. - points at: (idx := idx+1) put: seg start + offset. "now the first half-arc" + points at: (idx := idx + 1) put: seg start + offset. + points at: (idx := idx + 1) put: seg via + offset. + points at: (idx := idx + 1) put: seg end + offset. - points at: (idx := idx+1) put: seg start + offset. - points at: (idx := idx+1) put: seg via + offset. - points at: (idx := idx+1) put: seg end + offset. "the second half-arc" + seg := segments at: i + 1. + points at: (idx := idx + 1) put: seg start + offset. + points at: (idx := idx + 1) put: seg via + offset. + points at: (idx := idx + 1) put: seg end + offset. - seg := segments at: i+1. - points at: (idx := idx+1) put: seg start + offset. - points at: (idx := idx+1) put: seg via + offset. - points at: (idx := idx+1) put: seg end + offset. endPoint := seg end + offset. ]. ^points! Item was changed: ----- Method: MorphicProject>>setAsBackground: (in category 'utilities') ----- setAsBackground: aForm "Set aForm as a background image." + | thisWorld newColor | + thisWorld := self currentWorld. - | world newColor | - world := self currentWorld. newColor := InfiniteForm with: aForm. aForm rememberCommand: (Command new cmdWording: 'set background to a picture' translated; + undoTarget: thisWorld selector: #color: argument: thisWorld color; + redoTarget: thisWorld selector: #color: argument: newColor). + thisWorld color: newColor - undoTarget: world selector: #color: argument: world color; - redoTarget: world selector: #color: argument: newColor). - world color: newColor ! 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 ]. - (self bounds intersects: aRectangle) ifFalse: [^ 0@0 ]. flags := 0. + nudge := 0 @ 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" + [ 0 ] -> [ 0 @ 0 ]. - [ 0 ] -> [ 0@0 ]. "2 adjacent sides only" + [ 9 ] -> [ 1 @ 1 ]. + [ 3 ] -> [ -1 @ 1 ]. + [ 12 ] -> [ 1 @ -1 ]. + [ 6 ] -> [ -1 @ -1 ]. - [ 9 ] -> [ 1@1 ]. - [ 3 ] -> [ -1@1 ]. - [ 12 ] -> [ 1@-1 ]. - [ 6 ] -> [ -1@-1 ]. "2 opposite sides only" + [ 10 ] -> [ 0 @ -1 ]. + [ 5 ] -> [ 1 @ 0 ]. - [ 10 ] -> [ 0@-1 ]. - [ 5 ] -> [ 1@0 ]. "only 1 side" + [ 8 ] -> [ -1 @ 0 ]. + [ 1 ] -> [ 0 @ -1 ]. + [ 2 ] -> [ 1 @ 0 ]. + [ 4 ] -> [ 0 @ 1 ]. - [ 8 ] -> [ -1@0 ]. - [ 1 ] -> [ 0@-1 ]. - [ 2 ] -> [ 1@0 ]. - [ 4 ] -> [ 0@1 ]. "3 sides" + [ 11 ] -> [ 0 @ 1 ]. + [ 13 ] -> [ 1 @ 0 ]. + [ 14 ] -> [ 0 @ -1 ]. + [ 7 ] -> [ -1 @ 0 ]. - [ 11 ] -> [ 0@1 ]. - [ 13 ] -> [ 1@0 ]. - [ 14 ] -> [ 0@-1 ]. - [ 7 ] -> [ -1@0 ]. "all sides" + [ 15 ] -> [ 1 @ -1 "move up and to the right" ]. - [ 15 ] -> [ 1@-1 "move up and to the right" ]. }. ^nudge! Item was changed: ----- Method: PreDebugWindow>>adjustBookControls (in category 'as yet unclassified') ----- adjustBookControls | inner | proceedButton ifNil: [^ self]. + proceedButton align: proceedButton topLeft with: (inner := self innerBounds) topLeft + (35 @ -4). + debugButton align: debugButton topRight with: inner topRight - (16 @ 4).! - proceedButton align: proceedButton topLeft with: (inner := self innerBounds) topLeft + (35@-4). - debugButton align: debugButton topRight with: inner topRight - (16@4).! Item was changed: ----- Method: ScrollPane>>vResizeScrollBar (in category 'geometry') ----- vResizeScrollBar | w topLeft borderHeight innerWidth | w := self scrollBarThickness. innerWidth := self flatColoredScrollBarLook ifTrue: [borderHeight := borderWidth. 0] ifFalse: [borderHeight := 0. 1]. topLeft := scrollBarOnLeft ifTrue: [retractableScrollBar ifTrue: [bounds topLeft - ((w - borderWidth) @ (0 - borderHeight))] ifFalse: [bounds topLeft + ((borderWidth - innerWidth) @ borderHeight)]] ifFalse: [retractableScrollBar ifTrue: [bounds topRight - (borderWidth @ (0 - borderHeight))] ifFalse: [bounds topRight - ((w + borderWidth - innerWidth) @ (0 - borderHeight))]]. scrollBar + bounds: (topLeft + ((scrollBarOnLeft ifTrue: [-1] ifFalse: [1]) @ -1) extent: w @ self vScrollBarHeight) - bounds: (topLeft + ((scrollBarOnLeft ifTrue: [-1] ifFalse: [1]) @-1) extent: w @ self vScrollBarHeight) ! Item was changed: ----- Method: TTSampleFontMorph>>drawCharactersOn: (in category 'drawing') ----- drawCharactersOn: aCanvas | glyph origin r offset cy m | + 0 to: 255 do: [:i | - 0 to: 255 do:[:i| glyph := font at: i. origin := font bounds extent * ((i \\ 16) @ (i // 16)). r := origin extent: font bounds extent. offset := r center - glyph bounds center. cy := glyph bounds center y. m := MatrixTransform2x3 withOffset: 0@cy. + m := m composedWithLocal: (MatrixTransform2x3 withScale: 1 @ -1). + m := m composedWithLocal: (MatrixTransform2x3 withOffset: 0 @ cy negated). - m := m composedWithLocal: (MatrixTransform2x3 withScale: 1@-1). - m := m composedWithLocal: (MatrixTransform2x3 withOffset: 0@cy negated). m := m composedWithGlobal: (MatrixTransform2x3 withOffset: offset). + aCanvas asBalloonCanvas preserveStateDuring: [:balloonCanvas | - aCanvas asBalloonCanvas preserveStateDuring:[:balloonCanvas| balloonCanvas transformBy: m. balloonCanvas drawGeneralBezierShape: glyph contours color: color borderWidth: 0 borderColor: Color black. ]. ].! Item was changed: ----- Method: TTSampleStringMorph>>computeTransform (in category 'private') ----- computeTransform | cy | cy := bounds origin y + bounds corner y * 0.5. transform := MatrixTransform2x3 transformFromLocal: (ttBounds insetBy: borderWidth negated) toGlobal: bounds. + transform := transform composedWithGlobal:(MatrixTransform2x3 withOffset: 0 @ cy negated). + transform := transform composedWithGlobal:(MatrixTransform2x3 withScale: 1.0 @ -1.0). + transform := transform composedWithGlobal:(MatrixTransform2x3 withOffset: 0 @ cy). - transform := transform composedWithGlobal:(MatrixTransform2x3 withOffset: 0@cy negated). - transform := transform composedWithGlobal:(MatrixTransform2x3 withScale: 1.0@-1.0). - transform := transform composedWithGlobal:(MatrixTransform2x3 withOffset: 0@cy). ^transform! |
Free forum by Nabble | Edit this page |