'From etoys2.2 of 24 September 2007 [latest update: #1703] on 15 October 2007 at 3:51:40 pm'! "Change Set: noWorldTransluc-sw Date: 15 October 2007 Author: Scott Wallace Do not accept translucency in the setting of the World's color, nor of its 'second color' if a gradient-fill is in effect."! !ColorPickerMorph methodsFor: 'event handling' stamp: 'sw 10/15/2007 15:47'! allowsTranslucency "Answer whether the receiver should respect attempts to choose transparency." | isWorld | isWorld := (target isPlayerLike and: [target costume isWorldMorph]) or: [target isMorph and: [target isWorldMorph]] or: [(target isKindOf: UpdatingRectangleMorph) and: [target involvesWorldColor]]. ^ isWorld not! ! !ColorPickerMorph methodsFor: 'event handling' stamp: 'sw 10/15/2007 03:06'! mouseDown: evt "The mouse went down in the picker; process it." | localPt | localPt _ evt cursorPoint - self topLeft. self deleteAllBalloons. clickedTranslucency := false. (TransparentBox containsPoint: localPt) ifTrue: [self allowsTranslucency ifTrue: [clickedTranslucency _ true]. ^ self]. self inhibitDragging ifFalse: [ (DragBox containsPoint: localPt) ifTrue: [^ evt hand grabMorph: self]. ]. (RevertBox containsPoint: localPt) ifTrue: [^ self updateColor: originalColor feedbackColor: originalColor]. self inhibitDragging ifFalse: [self comeToFront]. sourceHand _ evt hand. self startStepping. ! ! !ColorPickerMorph methodsFor: 'menu' stamp: 'sw 10/15/2007 03:07'! pickUpColorFor: aMorph "Show the eyedropper cursor, and modally track the mouse through a mouse-down and mouse-up cycle" | aHand localPt c | aHand _ aMorph ifNil: [self activeHand] ifNotNil: [aMorph activeHand]. aHand ifNil: [aHand _ self currentHand]. self addToWorld: aHand world near: (aMorph ifNil: [aHand world]) fullBoundsInWorld. self owner ifNil: [^ self]. aHand showTemporaryCursor: (ScriptingSystem formAtKey: #Eyedropper) hotSpotOffset: 6 negated @ 4 negated. "<<<< the form was changed a bit??" aHand modal: true. aHand mouseFocus: self. self updateContinuously: false. [aHand anyButtonPressed] whileFalse: [self trackColorUnderMouse. ActiveWorld doOneCycle]. self deleteAllBalloons. localPt _ aHand lastEvent cursorPoint - self topLeft. self inhibitDragging ifFalse: [(DragBox containsPoint: localPt) ifTrue: ["Click or drag the drag-dot means to anchor as a modeless picker" aHand modal: false. ^ self anchorAndRunModeless: aHand]]. (OpenFullBox containsPoint: localPt) ifTrue: [aHand modal: false. ^ self openPropertySheet]. (clickedTranslucency _ ((TransparentBox containsPoint: localPt) and: [self allowsTranslucency])) ifTrue: [selectedColor _ originalColor]. self updateContinuously: true. [aHand anyButtonPressed] whileTrue: [self updateTargetColorWith: self indicateColorUnderMouse. ActiveWorld doOneCycle]. aHand mouseFocus: nil. aHand modal: false. c _ self getColorFromKedamaWorldIfPossible: aHand cursorPoint. c ifNotNil: [selectedColor _ c]. aHand newMouseFocus: nil; showTemporaryCursor: nil; flushEvents. self delete! ! !ColorPickerMorph methodsFor: 'private' stamp: 'sw 10/15/2007 14:54'! updateAlpha: alpha "Update the appearance of the translucency box to reflect an alpha value. If the receiver is designated as not accepting transulcency, enforce an alpha of 1.0 whatever the incoming value may be." | sliderRect alphaPos toUse | toUse := self allowsTranslucency ifTrue: [alpha] ifFalse: [1.0]. sliderRect := self slopeBox insetBy: 1@3. alphaPos := sliderRect left + (toUse * sliderRect width) rounded. originalForm fill: (sliderRect withRight: alphaPos) fillColor: Color lightGray. originalForm fillWhite: (sliderRect withLeft: alphaPos). originalForm fill: (self slopeBox topRight + (0 @ 3) corner: TransparentBox bottomRight + (-5@-3)) fillColor: (toUse < 1.0 ifTrue: [Color white] ifFalse: [Color lightGray]). TransText displayOn: originalForm at: (TransText boundingBox align: TransText boundingBox center with: TransparentBox center) topLeft rule: Form paint. ! ! !PasteUpMorph methodsFor: 'accessing' stamp: 'sw 10/15/2007 14:41'! color: aColor "Set the receiver's color. Directly set the color if appropriate, else go by way of fillStyle. Strip translucency if the receiver is a WorldMorph." | toUse | (aColor isColor or: [aColor isKindOf: InfiniteForm]) ifFalse:[^ self fillStyle: aColor]. toUse := (self isWorldMorph and: [aColor isColor]) ifTrue: [aColor alpha: 1.0] "reject any translucency" ifFalse: [aColor]. color = aColor ifFalse: [self removeProperty: #fillStyle. color := toUse. self changed]! ! !Player methodsFor: 'slot getters/setters' stamp: 'sw 10/15/2007 03:15'! setSecondColor: aColor "Setter for costume's second color, if it's using gradient fill; if not, does nothing" | aFillStyle aMorph toUse | ^ (aFillStyle _ (aMorph _ costume renderedMorph) fillStyle) isGradientFill ifTrue: [toUse := (costume isWorldMorph and: [aColor isColor]) ifTrue: [aColor alpha: 1.0] "reject any translucency" ifFalse: [aColor]. aFillStyle lastColor: toUse forMorph: aMorph hand: ActiveHand]! ! !UpdatingRectangleMorph methodsFor: 'accessing' stamp: 'sw 10/15/2007 15:47'! involvesWorldColor "Answer whether the receiver involves the world." ^ (target isMorph and: [target isWorldMorph]) or: [target isPlayerLike and: [target costume isWorldMorph]]! !