[ENH] Halo with Icons

Bert Freudenberg bert at isgnw.CS.Uni-Magdeburg.De
Wed Oct 13 18:23:47 UTC 1999


Adds icons to the halo handles (as inspired by Dave Smith's GIF
image) for those who can't remember which is which ;-) 

Have fun,

  /bert

Content-Type: TEXT/PLAIN; CHARSET=US-ASCII; NAME="haloicons-bf.13Oct711pm.cs"
Content-ID: <Pine.LNX.3.96.991013201720.12146B at balloon.cs.uni-magdeburg.de>
Content-Description: 

'From Squeak 2.5 of August 6, 1999 [latest update: #1534] on 13 October 1999 at 7:11:19 pm'!
"Change Set:		haloicons-bf
Date:			11 October 1999
Author:			Bert Freudenberg

Adds icons to halo handles"!


!Color methodsFor: 'conversions' stamp: 'bf 10/13/1999 14:22'!
makeForegroundColor
	"Make a foreground color contrasting with me"
	^self luminance >= "Color red luminance" 0.299
		ifTrue: [Color black]
		ifFalse: [Color white]! !


!HaloMorph methodsFor: 'private' stamp: 'bf 10/13/1999 17:58'!
addHandleAt: aPoint color: aColor icon: iconName on: eventName send: selector to: recipient
	"Add a handle centered at the given point with the given color, and set it up to respond to the given event by sending the given selector to the given recipient.  Return the handle."
	| handle |
	handle _ EllipseMorph
		newBounds: (Rectangle center: aPoint extent: self handleSize asPoint)
		color: aColor.
	self addMorph: handle.
	iconName ifNotNil: [
		| form |
		form _ ScriptingSystem formAtKey: iconName.
		form ifNotNil: [
			handle addMorphCentered: (ImageMorph new
				image: form; 
				color: aColor makeForegroundColor;
				lock	)]].
	handle on: #mouseUp send: #endInteraction to: self.
	handle on: eventName send: selector to: recipient.
	handle setBalloonText: (target balloonHelpTextForHandle: handle).
	^ handle
! !

!HaloMorph methodsFor: 'private' stamp: 'bf 10/13/1999 14:38'!
addHandleAt: aPoint color: aColor on: eventName send: selector to: recipient
	"Add a handle centered at the given point with the given color, and set it up to respond to the given event by sending the given selector to the given recipient.  Return the handle."

	^self addHandleAt: aPoint color: aColor icon: nil on: eventName send: selector to: recipient! !

!HaloMorph methodsFor: 'private' stamp: 'bf 10/13/1999 18:01'!
addHandles
	| box s dismissHandle |
	target isWorldMorph ifTrue: [^ self addHandlesForWorldHalos].
	self removeAllMorphs.  "remove old handles, if any"
	s _ self handleSize.
	
	self bounds: target renderedMorph fullBoundsInWorld.  "update my size"
	box _ self basicBox.

	self addHandleAt: box topLeft color: Color red
		icon: 'Halo-Menu'
		on: #mouseDown send: #doMenu:with: to: self.

	"innerTarget colorSettable ifTrue:
		[self addGraphicalHandle: ColorHalo at: (box topLeft + (0 at 14)) on: #mouseDown send: #doRecolor:with: to: self]."  "possible future"

	self addHandleAt: (box leftCenter + (0 @ (s+2)) min: box leftCenter + box bottomLeft // 2)
		color: Color lightBrown icon: 'Halo-Tile'
		on: #mouseDown send: #tearOffTile to: innerTarget.

	dismissHandle _ self addHandleAt: (box topLeft + ((s+2)@0) min: box topLeft + box topCenter // 2)
		color: Color red muchLighter icon: 'Halo-Dismiss'
		on: #mouseDown send: #mouseDownInDimissHandle:with: to: self.
	dismissHandle on: #mouseUp send: #maybeDismiss:with: to: self.
	dismissHandle on: #mouseStillDown send: #setDismissColor:with: to: self.

	self addHandleAt: box leftCenter color: Color cyan
		icon: 'Halo-View'
		on: #mouseDown send: #openViewerForArgument to: innerTarget.

	self addHandleAt: box topCenter color: Color black
		icon: 'Halo-Grab'
		on: #mouseDown send: #doGrab:with: to: self.

	(self addHandleAt: (box topCenter + ((s+2)@0) min: box topCenter + box topRight // 2)
		color: Color brown icon: 'Halo-Drag'
		on: #mouseDown send: #startDrag:with: to: self)
		on: #mouseStillDown send: #doDrag:with: to: self.

	self addHandleAt: box topRight
		color: Color green icon: 'Halo-Dup'
		on: #mouseDown send: #doDup:with: to: self.

	Preferences showDebugHaloHandle ifTrue:
		[self addHandleAt: ((box topRight + box rightCenter) // 2)
			color: Color blue veryMuchLighter icon: 'Halo-Debug'
			on: #mouseDown send: #doDebug:with: to: self].

	target balloonText ifNotNil:
		[(self addHandleAt: box bottomCenter color: Color lightBlue
			on: #mouseDown send: #mouseDownOnHelpHandle: to: innerTarget)
			on: #mouseUp send: #deleteBalloon to: innerTarget].

	(self addHandleAt: box bottomLeft
		color: Color blue icon: 'Halo-Rot'
		on: #mouseDown send: #startRot:with: to: self)
		on: #mouseStillDown send: #doRot:with: to: self.

	target isFlexMorph
		ifTrue: [(self addHandleAt: box bottomRight color: Color lightOrange
				icon: 'Halo-Scale'
				on: #mouseDown send: #startScale:with: to: self)
				on: #mouseStillDown send: #doScale:with: to: self]
		ifFalse: [(self addHandleAt: box bottomRight color: Color yellow
				icon: 'Halo-Scale'
				on: #mouseDown send: #startGrow:with: to: self)
				on: #mouseStillDown send: #doGrow:with: to: self].

	innerTarget addOptionalHandlesTo: self box: box.
	self addName.
	growingOrRotating _ false.
	self layoutChanged.
	self changed.
! !


!ImageMorph methodsFor: 'accessing' stamp: 'bf 10/13/1999 14:09'!
color: aColor
	super color: aColor.
	(image depth == 1 and: [aColor isColor]) ifTrue: [
		image colors: {Color transparent. aColor}.
		self changed]! !


"Postscript:
Initialize halo icons in the standard form dictionary"
ScriptingSystem mergeGraphicsFrom: ((Dictionary new) add: ('Halo-Debug'->(Form
	extent: 16 at 16
	depth: 1
	fromArray: #( 0 0 0 0 0 266338304 103809024 103809024 103809024 103809024 266338304 0 0 0 0 0)
	offset: 0 at 0)); add: ('Halo-Tile'->(Form
	extent: 16 at 16
	depth: 1
	fromArray: #( 0 0 0 0 0 536346624 536346624 404226048 404226048 536346624 536346624 0 0 0 0 0)
	offset: 0 at 0)); add: ('Halo-Scale'->(Form
	extent: 16 at 16
	depth: 1
	fromArray: #( 0 0 0 0 265289728 139460608 139460608 139460608 139460608 265289728 1048576 267386880 0 0 0 0)
	offset: 0 at 0)); add: ('Halo-Menu'->(Form
	extent: 16 at 16
	depth: 1
	fromArray: #( 0 0 0 267386880 267386880 267386880 135266304 267386880 135266304 267386880 135266304 267386880 0 0 0 0)
	offset: 0 at 0)); add: ('Halo-Grab'->(Form
	extent: 16 at 16
	depth: 1
	fromArray: #( 0 25165824 25165824 37748736 69206016 135266304 268959744 669253632 338165760 204472320 69206016 69206016 132120576 0 0 0)
	offset: 0 at 0)); add: ('Halo-Drag'->(Form
	extent: 16 at 16
	depth: 1
	fromArray: #( 0 0 0 473432064 268959744 401080320 69206016 69206016 69206016 69206016 401080320 268959744 473432064 0 0 0)
	offset: 0 at 0)); add: ('Halo-Rot'->(Form
	extent: 16 at 16
	depth: 1
	fromArray: #( 0 0 25165824 33554432 0 132120576 69730304 606339072 606339072 337641472 132120576 0 4194304 25165824 0 0)
	offset: 0 at 0)); add: ('Halo-View'->(Form
	extent: 16 at 16
	depth: 1
	fromArray: #( 0 0 0 0 132120576 486014976 770965504 1341259776 669253632 467140608 132120576 0 0 0 0 0)
	offset: 0 at 0)); add: ('Halo-Dup'->(Form
	extent: 16 at 16
	depth: 1
	fromArray: #( 0 0 0 0 528482304 276824064 284688384 277348352 285736960 520617984 17301504 33030144 0 0 0 0)
	offset: 0 at 0)); add: ('Halo-Dismiss'->(Form
	extent: 16 at 16
	depth: 1
	fromArray: #( 0 0 0 0 204472320 242221056 132120576 62914560 62914560 132120576 242221056 204472320 0 0 0 0)
	offset: 0 at 0)); yourself)!





More information about the Squeak-dev mailing list