The Trunk: Graphics-mt.307.mcz

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

The Trunk: Graphics-mt.307.mcz

commits-2
Marcel Taeumel uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-mt.307.mcz

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

Name: Graphics-mt.307
Author: mt
Time: 26 February 2015, 6:22:20.558 pm
UUID: 15e4bf40-5f71-5f45-a0a4-86179930d6d5
Ancestors: Graphics-kfr.305

No CornerRounder anymore. Depended morphs have to round corners themselves. See Morphic-mt.760.

=============== Diff against Graphics-kfr.305 ===============

Item was removed:
- Object subclass: #CornerRounder
- instanceVariableNames: 'cornerMasks cornerOverlays underBits'
- classVariableNames: 'CR0 CR1 CR2'
- poolDictionaries: ''
- category: 'Graphics-Display Objects'!
-
- !CornerRounder commentStamp: '<historical>' prior: 0!
- This class is a quick hack to support rounded corners in morphic.
-
- Rather than produce rounded rectangles, it tweaks the display of corners.
- Rather than work for any radius, it only supports a radius of 6.
- Rather than work for any border width, it only supports widths 0, 1 and 2.
- The corners, while apparently transparent, still behave opaquely to mouse clicks.
-
- Worse than this, the approach relies on the ability to extract underlying bits from the canvas prior to display.  This ran afoul of top-down display, it seems, in SystemWindow spawnReframeHandle: (qv).  It will also make a postscript printer very unhappy.
-
- But, hey, it's cute.!

Item was removed:
- ----- Method: CornerRounder class>>initialize (in category 'all') -----
- initialize  "CornerRounder initialize"
-
- CR0 := CR1 := self new
- masterMask:
- (Form extent: 6@6
- fromArray: #(2r1e26 2r111e26 2r1111e26 2r11111e26 2r11111e26 2r111111e26)
- offset: 0@0)
- masterOverlay:
- (Form extent: 6@6
- fromArray: #(2r1e26 2r110e26 2r1000e26 2r10000e26 2r10000e26 2r100000e26)
- offset: 0@0).
- CR2 := self new
- masterMask:
- (Form extent: 6@6
- fromArray: #(2r1e26 2r111e26 2r1111e26 2r11111e26 2r11111e26 2r111111e26)
- offset: 0@0)
- masterOverlay:
- (Form extent: 6@6
- fromArray: #(2r1e26 2r111e26 2r1111e26 2r11100e26 2r11000e26 2r111000e26)
- offset: 0@0).
-
- !

Item was removed:
- ----- Method: CornerRounder class>>rectWithinCornersOf: (in category 'all') -----
- rectWithinCornersOf: aRectangle
- "Return a single sub-rectangle that lies entirely inside corners
- that are made by me.
- Used to identify large regions of window that do not need to be redrawn."
-
- ^ aRectangle insetBy: 0@6!

Item was removed:
- ----- Method: CornerRounder class>>roundCornersOf:on:in:displayBlock:borderWidth:corners: (in category 'all') -----
- roundCornersOf: aMorph on: aCanvas in: bounds displayBlock: displayBlock borderWidth: w corners: aList
-
- | rounder |
- rounder := CR0.
- w = 1 ifTrue: [rounder := CR1].
- w = 2 ifTrue: [rounder := CR2].
- rounder := rounder copy.
- rounder saveBitsUnderCornersOf: aMorph on: aCanvas in: bounds corners: aList.
- displayBlock value.
- rounder tweakCornersOf: aMorph on: aCanvas in: bounds borderWidth: w corners: aList!

Item was removed:
- ----- Method: CornerRounder>>masterMask:masterOverlay: (in category 'all') -----
- masterMask: maskForm masterOverlay: overlayForm
-
- cornerMasks := #(none left pi right) collect:
- [:dir | (maskForm rotateBy: dir centerAt: 0@0) offset: 0@0].
- cornerOverlays := #(none left pi right) collect:
- [:dir | (overlayForm rotateBy: dir centerAt: 0@0) offset: 0@0].
- !

Item was removed:
- ----- Method: CornerRounder>>saveBitsUnderCornersOf:on:in:corners: (in category 'all') -----
- saveBitsUnderCornersOf: aMorph on: aCanvas in: bounds corners: cornerList
-
- | corners |
- underBits := Array new: 4.
- corners := bounds corners.
- cornerList do:[:i|
- | offset corner mask form rect |
- mask := cornerMasks at: i.
- corner := corners at: i.
- i = 1 ifTrue: [offset := 0@0].
- i = 2 ifTrue: [offset := 0@mask height negated].
- i = 3 ifTrue: [offset := mask extent negated].
- i = 4 ifTrue: [offset := mask width negated@0].
- rect := corner + offset extent: mask extent.
- (aCanvas isVisible: rect) ifTrue:[
- form := aCanvas contentsOfArea: rect.
- form copyBits: form boundingBox from: mask at: 0@0 clippingBox: form boundingBox rule: Form and fillColor: nil map: (Bitmap with: 16rFFFFFFFF with: 0).
- underBits at: i put: form]].
- !

Item was removed:
- ----- Method: CornerRounder>>tweakCornersOf:on:in:borderWidth:corners: (in category 'all') -----
- tweakCornersOf: aMorph on: aCanvas in: bounds borderWidth: w corners: cornerList
- "This variant has a cornerList argument, to allow some corners to be rounded and others not"
- | fourColors mask shadowColor corners |
- shadowColor := aCanvas shadowColor.
- aCanvas shadowColor: nil. "for tweaking it's essential"
- w > 0 ifTrue:[
- fourColors := shadowColor
- ifNil:[aMorph borderStyle colorsAtCorners]
- ifNotNil:[Array new: 4 withAll: Color transparent]].
- mask := Form extent: cornerMasks first extent depth: aCanvas depth.
- corners := bounds corners.
- cornerList do:[:i|
- | offset corner saveBits outBits |
- corner := corners at: i.
- saveBits := underBits at: i.
- saveBits ifNotNil:[
- i = 1 ifTrue: [offset := 0@0].
- i = 2 ifTrue: [offset := 0@saveBits height negated].
- i = 3 ifTrue: [offset := saveBits extent negated].
- i = 4 ifTrue: [offset := saveBits width negated@0].
-
- "Mask out corner area (painting saveBits won't clear if transparent)."
- mask copyBits: mask boundingBox from: (cornerMasks at: i) at: 0@0 clippingBox: mask boundingBox rule: Form over fillColor: nil map: (Bitmap with: 0 with: 16rFFFFFFFF).
- outBits := aCanvas contentsOfArea: (corner + offset extent: mask extent).
- mask displayOn: outBits at: 0@0 rule: Form and.
- "Paint back corner bits."
- saveBits displayOn: outBits at: 0@0 rule: Form paint.
- "Paint back corner bits."
- aCanvas drawImage: outBits at: corner + offset.
-
- w > 0 ifTrue:[
-
- aCanvas stencil: (cornerOverlays at: i) at: corner + offset
- color: (fourColors at: i)]]].
- aCanvas shadowColor: shadowColor. "restore shadow color"
- !