[squeak-dev] The Trunk: Morphic-mt.1010.mcz
commits at source.squeak.org
commits at source.squeak.org
Tue Oct 6 11:50:32 UTC 2015
Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1010.mcz
==================== Summary ====================
Name: Morphic-mt.1010
Author: mt
Time: 6 October 2015, 1:49:59.363 pm
UUID: 5584d8ee-d8e6-1041-8d6f-076e24462426
Ancestors: Morphic-cmm.1009
Allow morphs to have custom corner radiuses when using the rounded corner style.
=============== Diff against Morphic-cmm.1009 ===============
Item was changed:
----- Method: Morph>>boundsWithinCorners (in category 'drawing') -----
boundsWithinCorners
"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."
^ self wantsRoundedCorners
+ ifTrue: [self bounds insetBy: 0 at self cornerRadius]
- ifTrue: [self bounds insetBy: 0 at self class preferredCornerRadius]
ifFalse: [self bounds]
!
Item was added:
+ ----- Method: Morph>>cornerRadius (in category 'rounding') -----
+ cornerRadius
+
+ ^ self
+ valueOfProperty: #cornerRadius
+ ifAbsent: [self class preferredCornerRadius]!
Item was added:
+ ----- Method: Morph>>cornerRadius: (in category 'rounding') -----
+ cornerRadius: radius
+
+ self
+ setProperty: #cornerRadius
+ toValue: radius.
+
+ self changed.!
Item was changed:
+ ----- Method: Morph>>cornerStyle (in category 'rounding') -----
- ----- Method: Morph>>cornerStyle (in category 'visual properties') -----
cornerStyle
"Returns one of the following symbols:
#square
#rounded
according to the current corner style."
^ self valueOfProperty: #cornerStyle ifAbsent: [#square]!
Item was changed:
----- Method: Morph>>drawDropHighlightOn: (in category 'drawing') -----
drawDropHighlightOn: aCanvas
self highlightedForDrop ifTrue: [
self wantsRoundedCorners
+ ifTrue: [aCanvas frameRoundRect: self fullBounds radius: self cornerRadius width: 1 color: self dropHighlightColor]
- ifTrue: [aCanvas frameRoundRect: self fullBounds radius: self class preferredCornerRadius width: 1 color: self dropHighlightColor]
ifFalse: [aCanvas frameRectangle: self fullBounds color: self dropHighlightColor]].!
Item was changed:
----- Method: Morph>>drawDropShadowOn: (in category 'drawing') -----
drawDropShadowOn: aCanvas
"Rectangular shadow with support for rounded corners."
| shadowBounds |
shadowBounds := self shadowOffset isRectangle
ifTrue: [self bounds outsetBy: self shadowOffset]
ifFalse: [self bounds translateBy: (self shadowOffset negated max: 0 at 0)].
"Only redraw the shadow if the shadow area is affected."
+ ((aCanvas clipRect intersects: shadowBounds) and: [((self bounds insetBy: (self wantsRoundedCorners ifFalse: [0] ifTrue: [self cornerRadius])) containsRect: aCanvas clipRect) not])
- ((aCanvas clipRect intersects: shadowBounds) and: [((self bounds insetBy: (self wantsRoundedCorners ifFalse: [0] ifTrue: [self class preferredCornerRadius])) containsRect: aCanvas clipRect) not])
ifTrue: [
(self hasProperty: #dropShadow)
ifFalse: [self updateDropShadowCache].
aCanvas
translucentImage: (self valueOfProperty: #dropShadow)
at: shadowBounds topLeft].!
Item was changed:
----- Method: Morph>>drawKeyboardFocusIndicationOn: (in category 'drawing') -----
drawKeyboardFocusIndicationOn: aCanvas
self wantsRoundedCorners
+ ifTrue: [aCanvas frameRoundRect: self bounds radius: self cornerRadius width: 3 "self borderStyle width" color: self keyboardFocusColor]
- ifTrue: [aCanvas frameRoundRect: self bounds radius: self class preferredCornerRadius width: 3 "self borderStyle width" color: self keyboardFocusColor]
ifFalse: [aCanvas frameRectangle: self bounds width: 3 "self borderStyle width" color: self keyboardFocusColor].!
Item was changed:
----- Method: Morph>>drawMouseDownHighlightOn: (in category 'drawing') -----
drawMouseDownHighlightOn: aCanvas
self highlightedForMouseDown ifTrue: [
self wantsRoundedCorners
+ ifTrue: [aCanvas frameRoundRect: self fullBounds radius: self cornerRadius width: 1 color: self color darker darker]
- ifTrue: [aCanvas frameRoundRect: self fullBounds radius: self class preferredCornerRadius width: 1 color: self color darker darker]
ifFalse: [aCanvas frameRectangle: self fullBounds color: self color darker darker]].!
Item was changed:
----- Method: Morph>>drawOn: (in category 'drawing') -----
drawOn: aCanvas
self wantsRoundedCorners
+ ifTrue: [aCanvas frameAndFillRoundRect: self bounds radius: self cornerRadius fillStyle: self fillStyle borderWidth: self borderStyle width borderColor: self borderStyle color]
- ifTrue: [aCanvas frameAndFillRoundRect: self bounds radius: self class preferredCornerRadius fillStyle: self fillStyle borderWidth: self borderStyle width borderColor: self borderStyle color]
ifFalse: [aCanvas fillRectangle: self bounds fillStyle: self fillStyle borderStyle: self borderStyle].
!
Item was changed:
----- Method: Morph>>updateDropShadowCache (in category 'drawing') -----
updateDropShadowCache
| shadowBounds offset form canvas drawBlock localBounds mask maskCanvas |
shadowBounds := self shadowOffset isRectangle
ifTrue: [0 at 0 corner: (self bounds outsetBy: self shadowOffset) extent]
ifFalse: [0 at 0 corner: self extent + self shadowOffset abs].
offset := self shadowOffset isRectangle
ifTrue: [0 at 0]
ifFalse: [self shadowOffset max: 0 at 0].
localBounds := self shadowOffset isRectangle
ifTrue: [self shadowOffset topLeft extent: self extent]
ifFalse: [(self shadowOffset negated max: 0 at 0) extent: self extent].
form := Form extent: shadowBounds extent depth: Display depth.
canvas := form getCanvas.
drawBlock := self useSoftDropShadow
ifFalse: [
[:c | self wantsRoundedCorners
+ ifTrue: [c fillRoundRect: localBounds radius: self cornerRadius fillStyle: self shadowColor]
- ifTrue: [c fillRoundRect: localBounds radius: self class preferredCornerRadius fillStyle: self shadowColor]
ifFalse: [c fillRectangle: localBounds fillStyle: self shadowColor]]]
ifTrue: [
[:c | self wantsRoundedCorners
ifTrue: [0 to: 9 do: [:i |
c
fillRoundRect: (shadowBounds insetBy: i)
+ radius: (self cornerRadius max: 20) -i
- radius: (self class preferredCornerRadius max: 20) -i
fillStyle: (self shadowColor alpha: self shadowColor alpha * (i+1))]]
ifFalse: [0 to: 9 do: [:i |
c
fillRoundRect: (shadowBounds insetBy: i) radius: 20-i
fillStyle: (self shadowColor alpha: self shadowColor alpha * (i+1))]]]].
canvas
translateBy: offset
during: [ :shadowCanvas | drawBlock value: shadowCanvas].
"Support transparent morph colors without having the shadow to shine through.."
mask := Form extent: shadowBounds extent depth: Display depth.
maskCanvas := mask getCanvas.
self wantsRoundedCorners
+ ifTrue: [maskCanvas fillRoundRect: (localBounds insetBy: self borderWidth) radius: self cornerRadius fillStyle: Color black]
- ifTrue: [maskCanvas fillRoundRect: (localBounds insetBy: self borderWidth) radius: self class preferredCornerRadius fillStyle: Color black]
ifFalse: [maskCanvas fillRectangle: (localBounds insetBy: self borderWidth) fillStyle: Color black].
mask
displayOn: form
at: 0 at 0
rule: Form erase.
self setProperty: #dropShadow toValue: form.!
Item was changed:
----- Method: NewBalloonMorph>>drawDropShadowOn: (in category 'drawing') -----
drawDropShadowOn: aCanvas
aCanvas
translateBy: self shadowOffset
during: [ :shadowCanvas |
(shadowCanvas isVisible: self bubbleBounds) ifTrue: [
self wantsRoundedCorners
+ ifTrue: [shadowCanvas fillRoundRect: self bubbleBounds radius: self cornerRadius fillStyle: self shadowColor]
- ifTrue: [shadowCanvas fillRoundRect: self bubbleBounds radius: self class preferredCornerRadius fillStyle: self shadowColor]
ifFalse: [shadowCanvas fillRectangle: self bubbleBounds fillStyle: self shadowColor]].
self hasTail ifTrue: [
shadowCanvas
drawPolygon: self verticesForTail
fillStyle: self shadowColor]].
!
Item was changed:
----- Method: NewBalloonMorph>>drawOn: (in category 'drawing') -----
drawOn: aCanvas
"Bubble."
self wantsRoundedCorners
ifTrue: [aCanvas
frameAndFillRoundRect: self bubbleBounds
+ radius: self cornerRadius fillStyle: self fillStyle borderWidth: self borderStyle width borderColor: self borderStyle color]
- radius: self class preferredCornerRadius fillStyle: self fillStyle borderWidth: self borderStyle width borderColor: self borderStyle color]
ifFalse: [aCanvas
fillRectangle: self bubbleBounds
fillStyle: self fillStyle borderStyle: self borderStyle].
"Tail."
self hasTail ifTrue: [
self verticesForTail in: [:points |
| pixelOffset |
pixelOffset := points first y < points second y
ifFalse: [points first x < points second x
ifTrue: [self borderStyle width negated @ self borderStyle width] "bottomLeft"
ifFalse: [self borderStyle width @ self borderStyle width]] "bottomRight"
ifTrue: [points first x < points second x
ifTrue: [self borderStyle width negated @ self borderStyle width negated] "topLeft"
ifFalse: [self borderStyle width @ self borderStyle width negated]]. "topRight"
aCanvas
drawPolygon: points
fillStyle: self fillStyle.
aCanvas
line: points first
to: points second + pixelOffset
width: self borderStyle width
color: self borderStyle color.
aCanvas
line: points first
to: points third + pixelOffset
width: self borderStyle width
color: self borderStyle color]]!
Item was changed:
----- Method: NewBalloonMorph>>verticesForTail (in category 'drawing') -----
verticesForTail
| offset factorX factorY tpos bpos |
offset := 5 + (self wantsRoundedCorners
+ ifTrue: [self cornerRadius]
- ifTrue: [self class preferredCornerRadius]
ifFalse: [0]).
tpos := self tailPosition.
factorX := tpos x < self center x ifTrue: [1] ifFalse: [-1].
factorY := tpos y > self center y ifTrue: [1] ifFalse: [-1].
bpos := self bubbleBounds perform: self orientation.
^ {
tpos.
bpos + (((offset + self tailWidth) * factorX) @ (self borderStyle width negated * factorY)).
bpos + ((offset * factorX) @ (self borderStyle width negated * factorY)).}!
Item was changed:
----- Method: PluggableButtonMorph>>drawBackgroundOn: (in category 'drawing') -----
drawBackgroundOn: aCanvas
| cc gradient borderColor fill |
cc := self color.
cc isTransparent ifTrue:[cc := Color gray: 0.9].
self enabled ifFalse:[cc := Color lightGray].
cc brightness > 0.9 ifTrue:[cc := cc adjustBrightness: 0.9 - cc brightness].
showSelectionFeedback ifTrue:[
borderColor := cc muchDarker.
gradient := GradientFillStyle ramp: {
0.0 -> cc muchDarker.
0.1-> (cc adjustBrightness: -0.2).
0.5 -> cc.
0.9-> (cc adjustBrightness: -0.1).
1 -> cc muchDarker}.
cc := cc muchDarker.
] ifFalse:[
borderColor := Color lightGray.
gradient := GradientFillStyle ramp: {
0.0 -> Color white.
0.1-> (cc adjustBrightness: 0.05).
0.6 -> (cc darker)}.
].
gradient origin: bounds topLeft.
gradient direction: 0 at self height.
PluggableButtonMorph gradientButton
ifFalse: [fill := SolidFillStyle color: cc]
ifTrue: [fill := gradient].
^ self wantsRoundedCorners
ifTrue: [aCanvas
frameAndFillRoundRect: self bounds
+ radius: self cornerRadius
- radius: self class preferredCornerRadius
fillStyle: fill
borderWidth: 1
borderColor: borderColor]
ifFalse: [aCanvas
frameAndFillRectangle: self bounds
fillColor: fill asColor
borderWidth: 1
borderColor: borderColor darker;
fillRectangle: self innerBounds
fillStyle: fill]!
Item was changed:
----- Method: UserDialogBoxMorph>>drawSubmorphsOn: (in category 'drawing') -----
drawSubmorphsOn: aCanvas
super drawSubmorphsOn: aCanvas.
self wantsRoundedCorners ifTrue: [
"Overdraw lower part of title bar to hide bottom corners."
aCanvas
+ fillRectangle: (self submorphs first "titleRow" bottomLeft - (-1 @ self submorphs first cornerRadius)
- fillRectangle: (self submorphs first "titleRow" bottomLeft - (-1 @ Morph preferredCornerRadius)
corner: self submorphs first "titleRow" bottomRight - (1 at 0))
color: self color].!
Item was changed:
----- Method: UserDialogBoxMorph>>initialize (in category 'initialization') -----
initialize
| titleRow cc |
super initialize.
self color: Color white.
self listDirection: #topToBottom; wrapCentering: #center;
hResizing: #shrinkWrap; vResizing: #shrinkWrap.
self layoutInset: -1 @ -1; cellInset: 5 at 5.
self borderStyle: BorderStyle thinGray.
self setProperty: #indicateKeyboardFocus: toValue: #never.
FillInTheBlankMorph roundedDialogCorners
ifTrue: [self useRoundedCorners].
self hasDropShadow: Preferences menuAppearance3d.
self useSoftDropShadow
ifFalse: [
self
shadowColor: (TranslucentColor r: 0.0 g: 0.0 b: 0.0 alpha: 0.666);
shadowOffset: 1 @ 1]
ifTrue: [
self
shadowColor: (TranslucentColor r: 0.0 g: 0.0 b: 0.0 alpha: 0.01);
shadowOffset: (10 at 8 corner: 10 at 12)].
cc := Color gray: 0.8.
titleRow := AlignmentMorph newRow.
titleRow hResizing: #spaceFill; vResizing: #shrinkWrap.
self cornerStyle == #rounded
ifTrue: [titleRow useRoundedCorners].
titleRow borderStyle: BorderStyle thinGray.
+ titleRow layoutInset: (5 at 5 corner: (2@ (5 + (titleRow cornerStyle == #rounded ifTrue: [titleRow cornerRadius] ifFalse: [0])))).
- titleRow layoutInset: (5 at 5 corner: (2@ (5 + (titleRow cornerStyle == #rounded ifTrue: [Morph preferredCornerRadius] ifFalse: [0])))).
titleRow color: cc.
titleRow fillStyle: self titleGradient.
titleMorph := StringMorph new.
titleMorph emphasis: 1.
titleRow addMorph: titleMorph.
labelMorph := TextMorph new.
labelMorph margins: (Preferences standardButtonFont widthOf: $x) * 2 @ 0.
labelMorph lock.
buttonRow := AlignmentMorph newRow
vResizing: #rigid;
height: (Preferences standardButtonFont height + 20);
hResizing: #spaceFill;
layoutInset:
(((Preferences standardButtonFont widthOf: $x) * 2 @ 0)
corner: ((Preferences standardButtonFont widthOf: $x) * 2 @ 10));
cellInset: (Preferences standardButtonFont widthOf: $x) * 2.
buttonRow color: Color transparent.
self
addMorphBack: titleRow ;
addMorphBack: labelMorph ;
addMorphBack: buttonRow.
keyMap := Dictionary new!
More information about the Squeak-dev
mailing list
|