[NEWBIE]More questions on PaintBoxMorph

Karl Ramberg karl.ramberg at chello.se
Mon Apr 24 11:08:58 UTC 2000


Thanks again, Bob.
Your the man!

Karl

Bob Arning wrote:

> On Sun, 23 Apr 2000 23:23:56 +0200 Karl Ramberg <karl.ramberg at chello.se> wrote:
> >I still reading and trying to understand stuff in both Smalltalk and
> >morph. This changeset is supposed to change the cursor into a
> >color picker but fails to evoke the world (?) or HandMorph fails to
> >update it self (?). The color picker draws once and then the
> >cursor becomes invisible. The code commented out is to change the
> >cursor back to normal but when commented out it will change the
> >cursor into a color picker and the default cursor (depending on where
> >the invisible cursor is at mouseUp.)
>
> Karl,
>
> There were several problems here:
>
> 1. The form used for the eyedropper seems to have been changed, so it was picking up from the wrong location.
>
> 2. If picking colors from a 32-bit deep Display, the alpha bits could be anything (they only matter squeak-to-squeak, but not squeak-to-OS.
>
> 3. If the hand has anything other than the OS-standard form, it needs to draw itself. The loop that takes control of all cursor tracking didn't handle that.
>
> Changes included below.
>
> Cheers,
> Bob
>
> ===== code snipped below =====
> 'From Squeak2.8alpha of 13 January 2000 [latest update: #2005] on 23 April 2000 at 7:10:32 pm'!
>
> !PaintBoxMorph methodsFor: 'actions' stamp: 'RAA 4/23/2000 19:10'!
> eyedropper: aButton action: aSelector cursor: aCursor
>         "Take total control and pick up a color!!!!"
>         | pt feedbackColor |
>         aButton state: #on.
>         tool ifNotNil: [tool state: #off].
>         currentCursor _ aCursor.
>         self activeHand
>                 showTemporaryCursor: currentCursor
>                 hotSpotOffset: 6 negated @ 4 negated.           "<<<< the form was changed a bit??"
>         feedbackColor _ Display colorAt: Sensor cursorPoint.
>         self addMorphFront: colorMemory.
>         "Full color picker"
>         [Sensor anyButtonPressed]
>                 whileFalse:
>                         [pt _ Sensor cursorPoint.
>
>                         "deal with the fact that 32 bit displays may have garbage in the alpha bits"
>                         feedbackColor _ Display depth = 32 ifTrue: [
>                                 Color colorFromPixelValue: ((Display pixelValueAt: pt) bitOr: 16rFF000000) depth: 32
>                         ] ifFalse: [
>                                 Display colorAt: pt
>                         ].
>
>                         "the hand needs to be drawn"
>                         self activeHand position: pt.
>                         self world displayWorldSafely.
>                         Display fill: colorPatch bounds fillColor: feedbackColor].
>         Sensor waitNoButton.
>         self activeHand showTemporaryCursor: nil hotSpotOffset: 0 @ 0.
>         self currentColor: feedbackColor.
>         colorMemory delete.
>         tool
>                 ifNotNil:
>                         [tool state: #on.
>                         currentCursor _ tool arguments at: 3].
>         aButton state: #off! !





More information about the Squeak-dev mailing list