[squeak-dev] The Trunk: Morphic-tpr.1038.mcz

commits at source.squeak.org commits at source.squeak.org
Sat Nov 14 19:31:56 UTC 2015


tim Rowledge uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-tpr.1038.mcz

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

Name: Morphic-tpr.1038
Author: tpr
Time: 13 November 2015, 4:49:05.868 pm
UUID: 677751c2-0b1e-4ae5-ab35-183319ec6919
Ancestors: Morphic-mt.1037, Morphic-tpr.996

DockingBarMorph - don't allow editing of menu items unless a preference is set. It isn't something you want in a production application.
The squeak menu ought to be a DockingBarMenuMorph, not a plain menu morph.
MenuMorph>popUpAdjacentTo:forHand:from: misuses 'owner owner' instead of 'world'
Add option for dragged Morphs to tell the Hand that they handlewhat happens when being dragged; useful for dragging Morphs that take a long time to draw the shadow, or perhaps want to render quite differently etc.

=============== Diff against Morphic-mt.1037 ===============

Item was changed:
  ----- Method: DockingBarItemMorph>>mouseDown: (in category 'events') -----
  mouseDown: evt
  	"Handle a mouse down event. Menu items get activated when the mouse is over them."
  
+ 	(evt shiftPressed and:[self wantsKeyboardFocusOnShiftClick]) ifTrue: [ ^super mouseDown: evt ].  "enable label editing" 
- 	evt shiftPressed ifTrue: [ ^super mouseDown: evt ].  "enable label editing" 
  	isSelected
  		ifTrue: [
  			evt hand newMouseFocus: nil.
  			owner selectItem: nil event: evt. ]
  		ifFalse: [
  			(self containsPoint: evt position) ifFalse: [ self halt ].
  			owner activate: evt. "Redirect to menu for valid transitions"
  			owner selectItem: self event: evt. ]
  !

Item was added:
+ ----- Method: DockingBarItemMorph>>wantsKeyboardFocusOnShiftClick (in category 'events') -----
+ wantsKeyboardFocusOnShiftClick
+ 	"set this preference to false to prevent user editing of docking bar menu items"
+ 	^Preferences enable: #allowMenubarItemEditing!

Item was changed:
  ----- Method: DockingBarMorph class>>squeakMenu (in category 'samples') -----
  squeakMenu
  	| menu |
+ 	menu := DockingBarMenuMorph new defaultTarget: self.
- 	menu := MenuMorph new defaultTarget: self.
  	menu
  		add: 'Hello'
  		target: self
  		selector: #inform:
  		argument: 'Hello World!!'.
  	menu
  		add: 'Long Hello'
  		target: self
  		selector: #inform:
  		argument: 'Helloooo World!!'.
  	menu
  		add: 'A very long Hello'
  		target: self
  		selector: #inform:
  		argument: 'Hellooooooooooooooo World!!'.
  	menu
  		add: 'An incredible long Hello'
  		target: self
  		selector: #inform:
  		argument: 'Hellooooooooooooooooooooooo World!!'.
  	^ menu!

Item was changed:
  ----- Method: HandMorph>>fullDrawOn: (in category 'drawing') -----
  fullDrawOn: aCanvas 
  	"A HandMorph has unusual drawing requirements:
  		1. the hand itself (i.e., the cursor) appears in front of its submorphs
  		2. morphs being held by the hand cast a shadow on the world/morphs below
  	The illusion is that the hand plucks up morphs and carries them above the world."
  
  	"Note: This version caches an image of the morphs being held by the hand for
  	 better performance. This cache is invalidated if one of those morphs changes."
  
  	| disableCaching subBnds |
  	self visible ifFalse: [^self].
  	(aCanvas isVisible: self fullBounds) ifFalse: [^self].
  	(self hasProperty: #errorOnDraw) ifTrue:[^self drawErrorOn: aCanvas].
  	disableCaching := false.
  	disableCaching 
  		ifTrue: 
  			[self nonCachingFullDrawOn: aCanvas.
  			^self].
  	submorphs isEmpty 
  		ifTrue: 
  			[cacheCanvas := nil.
  			^self drawOn: aCanvas].	"just draw the hand itself"
+ 
+ 	"special handling of a single submorph that wants to do its own thing
+ 	when being dragged"
+ 	(submorphs size = 1
+ 			and: [submorphs first handledOwnDraggingBy: self on: aCanvas])
+ 		ifTrue: [^ self drawOn: aCanvas].
+ 
  	subBnds := Rectangle merging: (submorphs collect: [:m | m fullBounds]).
  	self updateCacheCanvas: aCanvas.
  	(cacheCanvas isNil 
  		or: [cachedCanvasHasHoles and: [cacheCanvas depth = 1]]) 
  			ifTrue: 
  				["could not use caching due to translucency; do full draw"
  
  				self nonCachingFullDrawOn: aCanvas.
  				^self].
  
  	"draw the shadow"
  	aCanvas asShadowDrawingCanvas translateBy: self shadowOffset
  		during: 
  			[:shadowCanvas | 
  			cachedCanvasHasHoles 
  				ifTrue: 
  					["Have to draw the real shadow of the form"
  
  					shadowCanvas paintImage: cacheCanvas form at: subBnds origin]
  				ifFalse: 
  					["Much faster if only have to shade the edge of a solid rectangle"
  
  					(subBnds areasOutside: (subBnds translateBy: self shadowOffset negated)) 
  						do: [:r | shadowCanvas fillRectangle: r color: Color black]]].
  
  	"draw morphs in front of the shadow using the cached Form"
  	cachedCanvasHasHoles 
  		ifTrue: [aCanvas paintImage: cacheCanvas form at: subBnds origin]
  		ifFalse: 
  			[aCanvas 
  				drawImage: cacheCanvas form
  				at: subBnds origin
  				sourceRect: cacheCanvas form boundingBox].
  	self drawOn: aCanvas	"draw the hand itself in front of morphs"!

Item was changed:
  ----- Method: MenuMorph>>popUpAdjacentTo:forHand:from: (in category 'control') -----
  popUpAdjacentTo: rightOrLeftPoint forHand: hand from: sourceItem 
  	"Present this menu at the given point under control of the given hand."
  	
  	| tryToPlace selectedOffset rightPoint leftPoint |
  	hand world startSteppingSubmorphsOf: self.
  	popUpOwner := sourceItem.
  	
  	self fullBounds.
  	self updateColor.
  
  	"ensure layout is current"
  	selectedOffset := (selectedItem
  				ifNil: [self items first]) position - self position.
  	tryToPlace := [:where :mustFit | | delta | 
  			self position: where - selectedOffset.
  			delta := self boundsInWorld amountToTranslateWithin: sourceItem worldBounds.
  			(delta x = 0
  					or: [mustFit])
  				ifTrue: [delta = (0 @ 0)
  						ifFalse: [self position: self position + delta].
+ 					sourceItem world addMorphFront: self.
- 					sourceItem owner owner addMorphFront: self.
  					^ self]].
  	rightPoint := rightOrLeftPoint first + ((self layoutInset + self borderWidth) @ 0).
  	leftPoint := rightOrLeftPoint last - ((self layoutInset + self borderWidth + self width) @ 0).
  	tryToPlace
  		value: rightPoint value: false;
  		 value: leftPoint value: false;
  		 value: rightPoint value: true.!

Item was added:
+ ----- Method: Morph>>handledOwnDraggingBy:on: (in category 'dropping/grabbing') -----
+ handledOwnDraggingBy: aHandMorph on: aCanvas
+ "this is my chance to do something differrent to the normal dragging work. return true if I did what I wanted, false if not"
+ 	^false!



More information about the Squeak-dev mailing list