[squeak-dev] The Inbox: Graphics-mt.306.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Feb 24 16:35:39 UTC 2015


Marcel Taeumel uploaded a new version of Graphics to project The Inbox:
http://source.squeak.org/inbox/Graphics-mt.306.mcz

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

Name: Graphics-mt.306
Author: mt
Time: 24 February 2015, 5:35:33.139 pm
UUID: 59d79db7-87e0-8c48-945f-67edbd50cbf2
Ancestors: Graphics-kfr.305

Support rounded corners with a radius of 4. Adds a preference to change radius (but still only supports 6 or 4).

Not sure, whether the corner rounder should survive in the long term...

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

Item was changed:
  Object subclass: #CornerRounder
  	instanceVariableNames: 'cornerMasks cornerOverlays underBits'
+ 	classVariableNames: 'CR0 CR1 CR2 PreferredRadius'
- 	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 changed:
  ----- Method: CornerRounder class>>initialize (in category 'all') -----
  initialize  "CornerRounder initialize"
  
+ 	CR0 := self new
- 	CR0 := CR1 := self new
  		masterMask:
+ 			(Form extent: 4 at 4
+ 				fromArray: #(2r1100e26 2r11100e26 2r111100e26 2r111100e26)
+ 				offset: 0 at 0)
+ 		masterOverlay:
+ 			(Form extent: 4 at 4
+ 				fromArray: #(2r1100e26 2r10000e26 2r100000e26 2r100000e26)
+ 				offset: 0 at 0).
+ 	CR1 := self new
+ 		masterMask:
  			(Form extent: 6 at 6
  				fromArray: #(2r1e26 2r111e26 2r1111e26 2r11111e26 2r11111e26 2r111111e26)
  				offset: 0 at 0)
  		masterOverlay:
  			(Form extent: 6 at 6
  				fromArray: #(2r1e26 2r110e26 2r1000e26 2r10000e26 2r10000e26 2r100000e26)
  				offset: 0 at 0).
  	CR2 := self new
  		masterMask:
  			(Form extent: 6 at 6
  				fromArray: #(2r1e26 2r111e26 2r1111e26 2r11111e26 2r11111e26 2r111111e26)
  				offset: 0 at 0)
  		masterOverlay:
  			(Form extent: 6 at 6
  				fromArray: #(2r1e26 2r111e26 2r1111e26 2r11100e26 2r11000e26 2r111000e26)
  				offset: 0 at 0).
  
  !

Item was added:
+ ----- Method: CornerRounder class>>preferredRadius (in category 'preferences') -----
+ preferredRadius
+ 
+ 	<preference: 'Preferred Corner Radius'
+ 		category: 'Graphics'
+ 		description: 'Use appropriate corner rounder if present. Works only if corners are rounded.'
+ 		type: #Number>
+ 	^ PreferredRadius ifNil: [6]!

Item was added:
+ ----- Method: CornerRounder class>>preferredRadius: (in category 'preferences') -----
+ preferredRadius: anInteger
+ 
+ 	PreferredRadius := anInteger.!

Item was changed:
  ----- 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 |
+ 
+ 	{CR0.CR1.CR2}
+ 		detect: [:r | r cornerMasks first width = self preferredRadius]
+ 		ifFound: [:r | rounder := r]
+ 		ifNone: [
+ 			rounder := CR0.
+ 			w = 1 ifTrue: [rounder := CR1].
+ 			w = 2 ifTrue: [rounder := CR2]].
+ 
- 	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 added:
+ ----- Method: CornerRounder>>cornerMasks (in category 'accessing') -----
+ cornerMasks
+ 
+ 	^ cornerMasks!

Item was added:
+ ----- Method: CornerRounder>>cornerOverlays (in category 'accessing') -----
+ cornerOverlays
+ 
+ 	^ cornerOverlays!

Item was added:
+ ----- Method: CornerRounder>>underBits (in category 'accessing') -----
+ underBits
+ 
+ 	^ underBits!

Item was added:
+ (PackageInfo named: 'Graphics') postscript: 'CornerRounder initialize.'!



More information about the Squeak-dev mailing list