[etoys-dev] Etoys: Morphic-bf.35.mcz

commits at source.squeak.org commits at source.squeak.org
Sat Aug 14 14:05:38 EDT 2010


Bert Freudenberg uploaded a new version of Morphic to project Etoys:
http://source.squeak.org/etoys/Morphic-bf.35.mcz

==================== Summary ====================

Name: Morphic-bf.35
Author: bf
Time: 14 August 2010, 8:04:28 pm
UUID: c89e9060-2992-4e24-b787-d8ae069aaa71
Ancestors: Morphic-bf.34, Morphic-wiz.32

Merge from inbox (slightly cleaned up)
-------------------------
Name: Morphic-wiz.32
Author: wiz
Time: 12 August 2010, 10:48:26 pm
UUID: 48460cb5-d82f-4f98-aa83-d15fd6b56a9b
Ancestors: Morphic-wiz.31

This removes the Collection>>#asKnownNameMenu and puts the code into the former senders.

That seem to be the worst complaint and in looking at it I can see why. So now its gone.

See Morphic-wiz.32 comments for more info on the targeting apps.

=============== Diff against Morphic-bf.34 ===============

Item was added:
+ ----- Method: SimpleButtonMorph>>clearTarget (in category 'menu') -----
+ clearTarget
+ 
+ 	target _ nil.
+ !

Item was changed:
  ----- Method: MovieMorph>>addCustomMenuItems:hand: (in category 'menu') -----
  addCustomMenuItems: aCustomMenu hand: aHandMorph
  
  	| movies subMenu |
  	super addCustomMenuItems: aCustomMenu hand: aHandMorph.
  	aCustomMenu addLine.
  	subMenu _ MenuMorph new defaultTarget: self.
  	frameList size > 1 ifTrue: [
  		subMenu add: 'repaint' translated action: #editDrawing.
  		subMenu add: 'set rotation center' translated action: #setRotationCenter.
  		subMenu add: 'play once' translated action: #playOnce.
  		subMenu add: 'play loop' translated action: #playLoop.
  		subMenu add: 'stop playing' translated action: #stopPlaying.
  		currentFrameIndex > 1 ifTrue: [
  			subMenu add: 'previous frame' translated action: #previousFrame].
  		currentFrameIndex < frameList size ifTrue: [
  			subMenu add: 'next frame' translated action: #nextFrame]].
  	subMenu add: 'extract this frame' translated action: #extractFrame:.
  	movies _
+ 		(self world rootMorphsAt: aHandMorph targetPoint)
- 		(self world rootMorphsAt: aHandMorph targetOffset)
  			select: [:m | (m isKindOf: MovieMorph) or:
  						[m isSketchMorph]].
  	(movies size > 1) ifTrue:
  		[subMenu add: 'insert into movie' translated action: #insertIntoMovie:].
  	aCustomMenu add: 'movie...' translated subMenu: subMenu
  !

Item was added:
+ ----- Method: Morph>>sightWorldTargets: (in category 'meta-actions') -----
+ sightWorldTargets: event 
+ 	"Return the potential targets for the receiver.  
+ 	This is derived from Morph>>potentialEmbeddingTargets."
+ 	| bullseye myWorld menu |
+ 	myWorld := self world
+ 		ifNil: [^ #()].
+ 
+ 	bullseye := Point fromUser.
+ 	menu := CustomMenu new.
+ 	(myWorld potentialTargetsAt: bullseye)
+ 		do: [:m | menu
+ 				add: (m knownName
+ 						ifNil: [m class name asString])
+ 				action: m] .
+ 	self targetFromMenu: menu popupAt: bullseye!

Item was changed:
  ----- Method: MovieMorph>>insertIntoMovie: (in category 'menu') -----
  insertIntoMovie: evt
  
  	| movies aTarget |
  	movies _
+ 		(self world rootMorphsAt: evt  targetPoint)
- 		(self world rootMorphsAt: evt hand targetOffset)
  			select: [:m | ((m isKindOf: MovieMorph) or:
  						 [m isSketchMorph]) and: [m ~= self]].
  	movies isEmpty ifTrue: [^ self].
  	aTarget _ movies first.
  	(aTarget isSketchMorph) ifTrue:
  		[aTarget _ aTarget replaceSelfWithMovie].
  	movies first insertFrames: frameList.
  	self delete.
  !

Item was added:
+ ----- Method: HandMorph>>targetPoint (in category 'accessing') -----
+ targetPoint
+ 	"Return the new position of the target.
+ 	I.E. return the position of the hand less 
+ 	the original distance between hand and target position"
+ 
+ 	^ self position - targetOffset
+ !

Item was added:
+ ----- Method: MenuMorph>>updateItemsWithTarget:orWithHand: (in category 'menu') -----
+ updateItemsWithTarget: aTarget orWithHand: aHand
+ 	"re-target all existing items"
+ 	self items do: 
+ 			[:item | 
+ 			item target isHandMorph 
+ 				ifTrue: [item target: aHand]
+ 				ifFalse: [item target: aTarget]]!

Item was changed:
  ----- Method: SketchMorph>>insertIntoMovie: (in category 'menu') -----
  insertIntoMovie: evt
  
  	| movies aTarget |
  	movies _
+ 		(self world rootMorphsAt: evt  targetPoint)
- 		(self world rootMorphsAt: evt hand targetOffset)
  			select: [:m | ((m isKindOf: MovieMorph) or:
  						 [m isSketchMorph]) and: [m ~= self]].
  	movies isEmpty ifTrue: [^ self].
  	aTarget _ movies first.
  	(aTarget isSketchMorph) ifTrue: [
  		aTarget _ aTarget replaceSelfWithMovie].
  	aTarget insertFrames: (Array with: self).
  	self delete.
  !

Item was added:
+ ----- Method: CustomMenu>>startUpWithCaption:at: (in category '*Morphic-invocation') -----
+ startUpWithCaption: caption at: aPoint 
+ 	"Build and invoke this menu with no initial selection. Answer the  
+ 	selection associated with the menu item chosen by the user or nil if  
+ 	none is chosen; use the provided caption"
+ 	^ self startUp: nil withCaption: caption at: aPoint!

Item was added:
+ ----- Method: MenuMorph>>target: (in category 'menu') -----
+ target: aMorph
+ "Set defaultTarget since thats what we got.
+ For the sake of targetSighting which assumes #target is a word we know."
+ 
+ defaultTarget := aMorph!

Item was changed:
  ----- Method: MenuMorph>>setTarget: (in category 'menu') -----
  setTarget: evt 
  	"Set the default target object to be used for add item commands, and re-target all existing items to the new target or the the invoking hand."
  
+ 	| oldDefaultTarget |
+ 	oldDefaultTarget := defaultTarget .
+ 	self sightTargets: evt. 
+ 	oldDefaultTarget ~~ defaultTarget 
+ 		ifTrue: [self updateItemsWithTarget: defaultTarget orWithHand: evt hand ].
+ 	!
- 	| rootMorphs old |
- 	rootMorphs := self world rootMorphsAt: evt hand targetOffset.
- 	rootMorphs size > 1 
- 		ifTrue: [defaultTarget := rootMorphs second]
- 		ifFalse: [^self].
- 	"re-target all existing items"
- 	self items do: 
- 			[:item | 
- 			old := item target.
- 			old isHandMorph 
- 				ifTrue: [item target: evt hand]
- 				ifFalse: [item target: defaultTarget]]!

Item was added:
+ ----- Method: CustomMenu>>startUp:withCaption:at: (in category '*Morphic-invocation') -----
+ startUp: initialSelection withCaption: caption at: aPoint 
+ 	"Build and invoke this menu with the given initial selection and caption. 
+ 	Answer the selection associated with the menu item chosen by the user 
+ 	or nil if none is chosen."
+ 	self build.
+ 	initialSelection notNil
+ 		ifTrue: [self preSelect: initialSelection].
+ 	^ super startUpWithCaption: caption at: aPoint!

Item was changed:
  ----- Method: SimpleButtonMorph>>addCustomMenuItems:hand: (in category 'menu') -----
  addCustomMenuItems: aCustomMenu hand: aHandMorph
  
  	super addCustomMenuItems: aCustomMenu hand: aHandMorph.
  	self addLabelItemsTo: aCustomMenu hand: aHandMorph.
  	(target isKindOf: BookMorph)
  		ifTrue:
  			[aCustomMenu add: 'set page sound' translated action: #setPageSound:.
  			aCustomMenu add: 'set page visual' translated action: #setPageVisual:]
  		ifFalse:
+ 			[
+ 			aCustomMenu add: 'change action selector' translated action: #setActionSelector.
- 			[aCustomMenu add: 'change action selector' translated action: #setActionSelector.
  			aCustomMenu add: 'change arguments' translated action: #setArguments.
  			aCustomMenu add: 'change when to act' translated action: #setActWhen.
+ 			aCustomMenu add: 'set target' translated action: #sightTargets:.
+ 			target ifNotNil: [aCustomMenu add: 'clear target' translated action: #clearTarget]].
- 			aCustomMenu add: 'change target' translated action: #setTarget.
- 			((self world rootMorphsAt: aHandMorph targetOffset) size > 1) ifTrue:
- 				[aCustomMenu add: 'set target' translated action: #setTarget:]].
  !

Item was changed:
  ----- Method: SimpleButtonMorph>>setTarget: (in category 'menu') -----
  setTarget: evt 
  	| rootMorphs |
+ 	rootMorphs := self world rootMorphsAt: evt  targetPoint.
+ 	target := rootMorphs size > 1
+ 				ifTrue: [rootMorphs second]!
- 	rootMorphs := self world rootMorphsAt: evt hand targetOffset.
- 	target := rootMorphs size > 1 
- 		ifTrue: [rootMorphs second]
- 		ifFalse: [nil]!

Item was changed:
  ----- Method: Morph>>addPaintingItemsTo:hand: (in category 'menus') -----
  addPaintingItemsTo: aMenu hand: aHandMorph
  	"Add items relating to the painting subsystem to the given menu"
  
  	| subMenu movies |
  	subMenu _ MenuMorph new defaultTarget: self.
  
  	subMenu addTranslatedList: #(
  		('repaint' editDrawing)
  	"	('set form by grabbing from screen' setFormByGrabbingFromScreen)"
  		-
  		('set rotation center' setRotationCenter)
  		('reset forward-direction' resetForwardDirection)
  		('set rotation style' setRotationStyle)
  		-
  		('erase pixels of color' erasePixelsOfColor:)
  		('recolor pixels of color' recolorPixelsOfColor:)
  		('reduce color palette' reduceColorPalette:)
  		-
  		('add a border around this shape...' addBorderToShape:)
  		('restore original aspect ratio' restoreOriginalAspectRatio)) translatedNoop.
  
  	movies _
+ 		(self world rootMorphsAt: aHandMorph targetPoint)
- 		(self world rootMorphsAt: aHandMorph targetOffset)
  			select: [:m | (m isKindOf: MovieMorph) or:
  						[m isSketchMorph]].
  	(movies size > 1) ifTrue:
  		[subMenu add: 'insert into movie' translatedNoop action: #insertIntoMovie:].
  	aMenu add: 'painting...' translated subMenu: subMenu!

Item was added:
+ ----- Method: Morph>>targetFromMenu:popupAt: (in category 'meta-actions') -----
+ targetFromMenu: aMenu popupAt: aPoint 
+ 	"Some other morph become target of the receiver"
+ 	| newTarget caption |
+ 	caption := 'Target for {1}' translated format: {self externalName}.
+ 	newTarget := aMenu startUpWithCaption: caption at: aPoint .
+ 	newTarget
+ 		ifNil: [^ self].
+ 	self target: newTarget!

Item was added:
+ ----- Method: Morph>>sightTargets: (in category 'meta-actions') -----
+ sightTargets: event 
+ 	"Return the potential targets for the receiver.  
+ 	This is derived from Morph>>potentialEmbeddingTargets."
+ 	| bullseye menu |
+ 	owner
+ 		ifNil: [^ #()].
+ 	bullseye := Point fromUser.
+     	menu := CustomMenu new.
+ 	(self potentialTargetsAt: bullseye)
+ 		do: [:m | menu
+ 				add: (m knownName
+ 						ifNil: [m class name asString])
+ 				action: m] .
+ 	self targetFromMenu: menu popupAt: bullseye!

Item was added:
+ ----- Method: Morph>>potentialTargetsAt: (in category 'meta-actions') -----
+ potentialTargetsAt: aPoint 
+ 	"Return the potential targets for the receiver.  
+ 	This is derived from Morph>>potentialEmbeddingTargets."
+ 	| realOwner |
+ 	realOwner := self topRendererOrSelf
+ 	owner
+ 		ifNil: [^ #()].
+ 	^ realOwner
+ 		morphsAt: aPoint
+ 		!



More information about the etoys-dev mailing list