'From Squeak3.2alpha of 3 October 2001 [latest update: #4594] on 10 December 2001 at 2:00:44 am'! "Change Set: colorInViewer-sw Date: 10 December 2001 Author: Scott Wallace Additions, fixes, and adjustments, mostly to color-related categories, in Viewers: ¥ The items in 'color & border' are arranged in a more logical order -- color, border, drop-shadow. ¥ An item is added for setting the gradient color, and the action of the #color slot is modified so that changing it does not clobber the second color if gradient fill is in effect. ¥ The 'observation' methods (e.g. colorUnder) are moved to their own category. They serve very different needs, at very different times, than the other items in the color & border category. ¥ The wordings of some of items (e.g. erstwhile 'sticky') are changed to conform to new wordings now found in the halo menus."! !EToyVocabulary methodsFor: 'method list' stamp: 'sw 12/10/2001 00:18'! masterOrderingOfPhraseSymbols "Answer a dictatorially-imposed presentation list of phrase-symbols. This governs the order in which suitable phrases are presented in etoy viewers using the etoy vocabulary. For any given category, the default implementation is that any items that are in this list will occur first, in the order specified here; after that, all other items will come, in alphabetic order by formal selector." ^ #(beep: forward: turn: getX getY getHeading startScript: pauseScript: stopScript: startAll: pauseAll: stopAll: tellAllSiblings: doScript: getColor getUseGradientFill getSecondColor getRadialGradientFill getBorderWidth getBorderColor getBorderStyle getRoundedCorners getDropShadow getShadowColor )! ! !Morph methodsFor: 'scripting' stamp: 'sw 12/10/2001 02:00'! categoriesForViewer "Answer a list of symbols representing the categories to offer in the viewer, in order" | aClass aList predetermined genericItems | aClass _ self renderedMorph class. aList _ OrderedCollection new. [aClass == Morph] whileFalse: [(aClass class includesSelector: #additionsToViewerCategories) ifTrue: [aList addAllFirstUnlessAlreadyPresent: (aClass additionsToViewerCategories collect: [:categorySpec | categorySpec first])]. aClass _ aClass superclass]. genericItems _ Morph additionsToViewerCategories collect: [:categorySpec | categorySpec first]. aList removeAllFoundIn: genericItems. aList addAllFirstUnlessAlreadyPresent: (Morph additionsToViewerCategories collect: [:categorySpec | categorySpec first]) asSet asOrderedCollection. predetermined _ #(basic #'color & border' geometry motion #'pen use' tests layout #'drag & drop' scripting observation search miscellaneous) select: [:sym | aList includes: sym]. "bulletproof agains change in those names elsewhere" aList removeAllFoundIn: predetermined. ^ predetermined, aList ! ! !Morph class methodsFor: 'scripting' stamp: 'sw 12/9/2001 23:56'! additionsToViewerCategoryColorAndBorder "Answer viewer additions for the 'color & border' category" ^#( #'color & border' ( (slot color 'The color of the object' Color readWrite Player getColor Player setColor:) (slot borderStyle '"The style of the object''s border' BorderStyle readWrite Player getBorderStyle player setBorderStyle:) (slot borderColor 'The color of the object''s border' Color readWrite Player getBorderColor Player setBorderColor:) (slot borderWidth 'The width of the object''s border' Number readWrite Player getBorderWidth Player setBorderWidth:) (slot roundedCorners 'Whether corners should be rounded' Boolean readWrite Player getRoundedCorners Player setRoundedCorners:) (slot gradientFill 'Whether a gradient fill should be used' Boolean readWrite Player getUseGradientFill Player setUseGradientFill:) (slot secondColor 'The second color used when gradientFill is in effect' Color readWrite Player getSecondColor Player setSecondColor:) (slot radialFill 'Whether the gradient fill, if used, should be radial' Boolean readWrite Player getRadialGradientFill Player setRadialGradientFill:) (slot dropShadow 'Whether a drop shadow is shown' Boolean readWrite Player getDropShadow Player setDropShadow:) (slot shadowColor 'The color of the drop shadow' Color readWrite Player getShadowColor Player setShadowColor:) ) ) ! ! !Morph class methodsFor: 'scripting' stamp: 'sw 12/10/2001 00:40'! additionsToViewerCategoryDragAndDrop "Answer viewer additions for the 'drag & drop' category" ^#( #'drag & drop' ( (slot 'drop enabled' 'Whether drop is enabled' Boolean readWrite Player getDropEnabled Player setDropEnabled:) (slot 'resist drag' 'Whether this is sticky' Boolean readWrite Player getSticky Player setSticky:) (slot 'resist removal' 'Whether this is resistant to easy removal via the dismiss or grab halo handles' Boolean readWrite Player getResistsRemoval Player setResistsRemoval:) (slot 'be locked' 'Whether this object should be blind to all input' Boolean readWrite Player getIsLocked Player setIsLocked:) )) ! ! !Morph class methodsFor: 'scripting' stamp: 'sw 12/9/2001 23:26'! additionsToViewerCategoryObservation "Answer viewer additions for the 'observations' category" ^#( observation ( (slot colorUnder 'The color under the center of the object' Color readOnly Player getColorUnder unused unused ) (slot brightnessUnder 'The brightness under the center of the object' Number readOnly Player getBrightnessUnder unused unused) (slot luminanceUnder 'The luminance under the center of the object' Number readOnly Player getLuminanceUnder unused unused) (slot saturationUnder 'The saturation under the center of the object' Number readOnly Player getSaturationUnder unused unused) )) ! ! !Player methodsFor: 'slot getters/setters' stamp: 'sw 12/10/2001 00:34'! getColor "Answer the color of my costume. If it uses a gradient fill, answer the first color." | aFillStyle aMorph | ^ (aFillStyle _ (aMorph _ self costume renderedMorph) fillStyle) isGradientFill ifTrue: [aFillStyle colorRamp first value] ifFalse: [aMorph color]! ! !Player methodsFor: 'slot getters/setters' stamp: 'sw 12/10/2001 00:39'! getIsLocked "Answer whether the receiver's costume is locked" ^ costume isLocked! ! !Player methodsFor: 'slot getters/setters' stamp: 'sw 12/10/2001 00:12'! getSecondColor "Getter for costume's second color, if it's using gradient fill; sonst answers white." | aFillStyle | ^ (aFillStyle _ costume renderedMorph fillStyle) isGradientFill ifTrue: [aFillStyle colorRamp last value] ifFalse: [Color white]! ! !Player methodsFor: 'slot getters/setters' stamp: 'sw 12/10/2001 00:27'! setColor: aColor "Set the color of the graphic as requested" | aFillStyle aMorph | (aFillStyle _ (aMorph _ self costume renderedMorph) fillStyle) isGradientFill ifTrue: [aFillStyle firstColor: aColor forMorph: aMorph hand: nil] ifFalse: [aMorph color: aColor]! ! !Player methodsFor: 'slot getters/setters' stamp: 'sw 12/10/2001 00:40'! setIsLocked: aBoolean "Set my costume's isLocked" costume lock: aBoolean! ! !Player methodsFor: 'slot getters/setters' stamp: 'sw 12/9/2001 23:55'! setSecondColor: aColor "Setter for costume's second color, if it's using gradient fill; if not, does nothing" | aFillStyle aMorph | ^ (aFillStyle _ (aMorph _ costume renderedMorph) fillStyle) isGradientFill ifTrue: [aFillStyle lastColor: aColor forMorph: aMorph hand: ActiveHand]! ! !Morph class methodsFor: 'scripting' stamp: 'sw 12/9/2001 23:26'! additionsToViewerCategories "Answer a list of ( ) pairs that characterize the phrases this kind of morph wishes to add to various Viewer categories." ^ { self additionsToViewerCategoryBasic. self additionsToViewerCategoryScripts. self additionsToViewerCategoryColorAndBorder. self additionsToViewerCategoryGeometry. self additionsToViewerCategoryMiscellaneous. self additionsToViewerCategoryMotion. self additionsToViewerCategoryObservation. self additionsToViewerCategoryPenUse. self additionsToViewerCategoryLayout. self additionsToViewerCategoryDragAndDrop. self additionsToViewerCategoryScripting. self additionsToViewerCategoryTests. }! !