[Cuis-dev] PaddedMorph preview

ken.dickey at whidbey.com ken.dickey at whidbey.com
Tue Sep 10 13:49:07 PDT 2024


Hmmm.. defaults seem to make this look funny.

(ImageMorph new
     borderWidth: 6;
     borderColor: Color green;
     padding: 0) openInWorld.

Image + border looks too small for extent.  Perhaps use attached? (NB 
Not quite right)

Note:
(im := ImageMorph new
	 borderWidth: 6;
	 borderColor: Color green) openInWorld.
im padding: 0.
im padding: 3.

Otherwise have to require morphExtent reset to minimumExtent in example?

Perhaps just have ImageMorph class>>new not set non-zero extent.

Something to chat about tomorrow.

Cheers,
-KenD


-------------- next part --------------
'From Cuis7.1 [latest update: #6686] on 10 September 2024 at 1:41:51 pm'!

!ImageMorph methodsFor: 'drawing' stamp: 'KenD 9/10/2024 13:41:43'!
drawOn: aCanvas

	((padding > `0 at 0`) or: [self morphExtent > self minimumExtent]) 
		ifTrue: [ 	| innerOrigin |
			"Make use of my color in area between border and image"
			innerOrigin := borderWidth @ borderWidth.
			aCanvas
				fillRectangle:  (innerOrigin extent: extent - (2 * innerOrigin ))
				color:  color].
			
	(borderWidth > 0) ifTrue: [
		aCanvas
			frameRectangle:  (`0 at 0` extent: extent)
			color:  borderColor
			borderWidth:  borderWidth 
			borderStyleSymbol:  #simple ].
		
	aCanvas image: image at: self interiorOrigin.
! !
-------------- next part --------------
'From Cuis7.1 [latest update: #6686] on 10 September 2024 at 1:42:22 pm'!

!ImageMorph methodsFor: 'accessing' stamp: 'KenD 9/10/2024 13:35:09'!
padding: numberOrPoint
	
	| pt |
	pt := numberOrPoint asPoint.
	super padding: pt.
	(pt isZero) 
		ifTrue:  [self morphExtent: self minimumExtent]
		ifFalse: [self morphExtent: (extent max: self minimumExtent)].

	self redrawNeeded! !


More information about the Cuis-dev mailing list