[squeak-dev] The Trunk: Morphic-mt.856.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Apr 10 15:30:00 UTC 2015


Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.856.mcz

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

Name: Morphic-mt.856
Author: mt
Time: 10 April 2015, 5:29:28.492 pm
UUID: 20dbd6ea-8701-fd4c-8c03-55c3e70edbda
Ancestors: Morphic-mt.855

Added the possibility to indicate the current keyboard focus for *every* morph. It is a preference, which can be enabled but is disabled by default.

Why needed? It may be hard to determine the current keyboard focus if #mouseOverForKeyboardFocus is disabled.

Morphs can overwrite the default preference by either implementing #indicateKeyboardFocus or setting a property with that name to #never. (PluggableTextMorph does that for its text morph)

This commit includes also some fixes for #keyboardFocusChange: were overwritten methods forgot to call super.

=============== Diff against Morphic-mt.855 ===============

Item was added:
+ ----- Method: MenuMorph>>drawKeyboardFocusIndicationOn: (in category 'drawing') -----
+ drawKeyboardFocusIndicationOn: aCanvas 
+ 	"Draw the menu. Add keyboard-focus feedback if appropriate"
+ 
+ 	(self rootMenu hasProperty: #hasUsedKeyboard)
+ 		ifTrue: [ 
+ 			aCanvas
+ 				frameRectangle: self innerBounds
+ 				width: Preferences menuBorderWidth
+ 				color: Preferences keyboardFocusColor].!

Item was removed:
- ----- Method: MenuMorph>>drawOn: (in category 'drawing') -----
- drawOn: aCanvas 
- 	"Draw the menu. Add keyboard-focus feedback if appropriate"
- 
- 	super drawOn: aCanvas.
- 
- 	(ActiveHand notNil
- 			and: [ActiveHand keyboardFocus == self
- 			and: [self rootMenu hasProperty: #hasUsedKeyboard]])
- 		ifTrue: [
- 			aCanvas
- 				frameAndFillRectangle: self innerBounds
- 				fillColor: Color transparent
- 				borderWidth: Preferences menuBorderWidth
- 				borderColor: Preferences keyboardFocusColor
- 		].
- !

Item was added:
+ ----- Method: MenuMorph>>indicateKeyboardFocus (in category 'testing') -----
+ indicateKeyboardFocus
+ 
+ 	^ true!

Item was removed:
- ----- Method: MenuMorph>>keyboardFocusChange: (in category 'keyboard control') -----
- keyboardFocusChange: aBoolean
- 	"Notify change due to green border for keyboard focus"
- 
- 	self changed!

Item was changed:
  Object subclass: #Morph
  	instanceVariableNames: 'bounds owner submorphs fullBounds color extension'
+ 	classVariableNames: 'IndicateKeyboardFocus PreferredCornerRadius UseSoftDropShadow'
- 	classVariableNames: 'PreferredCornerRadius UseSoftDropShadow'
  	poolDictionaries: ''
  	category: 'Morphic-Kernel'!
  
  !Morph commentStamp: 'efc 2/26/2003 20:01' prior: 0!
  A Morph (from the Greek "shape" or "form") is an interactive graphical object. General information on the Morphic system can be found at http://minnow.cc.gatech.edu/squeak/30. 
  
  Morphs exist in a tree, rooted at a World (generally a PasteUpMorph). The morphs owned by a morph are its submorphs. Morphs are drawn recursively; if a Morph has no owner it never gets drawn. To hide a Morph and its submorphs, set its #visible property to false using the #visible: method. 
  
  The World (screen) coordinate system is used for most coordinates, but can be changed if there is a TransformMorph somewhere in the owner chain. 
  
  My instance variables have accessor methods (e.g., #bounds, #bounds:). Most users should use the accessor methods instead of using the instance variables directly.
  
  Structure:
  instance var 	Type 			Description 
  bounds 			Rectangle 		A Rectangle indicating my position and a size that will enclose 									me. 
  owner 			Morph		 	My parent Morph, or nil for the top-level Morph, which is a
   				or nil			world, typically a PasteUpMorph.
  submorphs 		Array 			My child Morphs. 
  fullBounds 		Rectangle 		A Rectangle minimally enclosing me and my submorphs. 
  color 			Color 			My primary color. Subclasses can use this in different ways. 
  extension 		MorphExtension Allows extra properties to be stored without adding a
  				or nil  				storage burden to all morphs. 
  
  By default, Morphs do not position their submorphs. Morphs may position their submorphs directly or use a LayoutPolicy to automatically control their submorph positioning.
  
  Although Morph has some support for BorderStyle, most users should use BorderedMorph if they want borders.!

Item was added:
+ ----- Method: Morph class>>indicateKeyboardFocus (in category 'preferences') -----
+ indicateKeyboardFocus
+ 
+ 	<preference: 'Indicate Keyboard Focus'
+ 		categoryList: #(keyboard Morphic general)
+ 		description: 'If enabled, there will be a visual highlight drawn onto the morph to help the user find out about the current keyboard focus. This is especially useful when the keyboard focus does not match the mouse position.'
+ 		type: #Boolean>
+ 	^ IndicateKeyboardFocus ifNil: [false]!

Item was added:
+ ----- Method: Morph class>>indicateKeyboardFocus: (in category 'preferences') -----
+ indicateKeyboardFocus: aBoolean
+ 
+ 	IndicateKeyboardFocus := aBoolean.!

Item was added:
+ ----- Method: Morph>>drawKeyboardFocusIndicationOn: (in category 'drawing') -----
+ drawKeyboardFocusIndicationOn: aCanvas
+ 
+ 	self wantsRoundedCorners
+ 		ifTrue: [aCanvas frameRoundRect: self bounds radius: self class preferredCornerRadius width: 3 "self borderStyle width" color: self keyboardFocusColor]
+ 		ifFalse: [aCanvas frameRectangle: self bounds width: 3  "self borderStyle width" color: self keyboardFocusColor].!

Item was changed:
  ----- Method: Morph>>drawOverlayOn: (in category 'drawing') -----
  drawOverlayOn: aCanvas
  	"Draw something over all my submorphs."
  	
  	self drawDropHighlightOn: aCanvas.
+ 	self drawMouseDownHighlightOn: aCanvas.
+ 
+ 	(self indicateKeyboardFocus and: [self hasKeyboardFocus])
+ 		ifTrue: [self drawKeyboardFocusIndicationOn: aCanvas].!
- 	self drawMouseDownHighlightOn: aCanvas.!

Item was changed:
  ----- Method: Morph>>hasKeyboardFocus: (in category 'event handling') -----
  hasKeyboardFocus: aHand
  
+ 	^ aHand keyboardFocus == self keyboardFocusDelegate!
- 	^ aHand keyboardFocus == self!

Item was added:
+ ----- Method: Morph>>indicateKeyboardFocus (in category 'testing') -----
+ indicateKeyboardFocus
+ 
+ 	^ (self hasProperty: #indicateKeyboardFocus)
+ 		ifTrue: [(self valueOfProperty: #indicateKeyboardFocus) ~~ #never]
+ 		ifFalse: [self class indicateKeyboardFocus]!

Item was changed:
  ----- Method: Morph>>keyboardFocusChange: (in category 'event handling') -----
  keyboardFocusChange: aBoolean
+ 	"The message is sent to a morph when its keyboard focus change. The given argument indicates that the receiver is gaining keyboard focus (versus losing) the keyboard focus. Morphs that accept keystrokes should change their appearance in some way when they are the current keyboard focus. This default implementation does nothing."
+ 
+ 	self indicateKeyboardFocus ifTrue: [self changed].!
- 	"The message is sent to a morph when its keyboard focus change. The given argument indicates that the receiver is gaining keyboard focus (versus losing) the keyboard focus. Morphs that accept keystrokes should change their appearance in some way when they are the current keyboard focus. This default implementation does nothing."!

Item was added:
+ ----- Method: Morph>>keyboardFocusColor (in category 'drawing') -----
+ keyboardFocusColor
+ 
+ 	^ Preferences keyboardFocusColor muchDarker alpha: 0.5!

Item was changed:
  ----- Method: PluggableListMorph>>keyboardFocusChange: (in category 'event handling') -----
  keyboardFocusChange: aBoolean 
  	"The message is sent to a morph when its keyboard focus changes.
  	The given argument indicates that the receiver is gaining (versus losing) the keyboard focus.
  	In this case, all we need to do is to redraw border feedback"
  	aBoolean ifFalse: [
  		self hoverRow: nil.
  		self class clearFilterAutomatically ifTrue:
  			[ self hasFilter ifTrue:
  				[ self
  					 removeFilter ;
  					 updateList ] ] ].
+ 		
+ 	super keyboardFocusChange: aBoolean.!
- 	(self innerBounds areasOutside: (self innerBounds insetBy: 1)) do:
- 		[ : rect | self invalidRect: rect ]!

Item was changed:
  ----- Method: PluggableTextMorph>>setText: (in category 'model access') -----
  setText: aText
  	textMorph
  		ifNil: [textMorph := self textMorphClass new
  					contents: aText
  					wrappedTo: self innerBounds width.
  				textMorph
  					margins: (3 at 0 corner: 0 at 0);
+ 					setEditView: self;
+ 					setProperty: #indicateKeyboardFocus toValue: #never.
- 					setEditView: self.
  				scroller addMorph: textMorph]
  		ifNotNil: [textMorph newContents: aText].
  	self hasUnacceptedEdits: false.
  	self setScrollDeltas.!

Item was changed:
  ----- Method: TextMorphForEditView>>keyboardFocusChange: (in category 'event handling') -----
  keyboardFocusChange: aBoolean 
  	"rr 3/21/2004 22:55 : removed the #ifFalse: branch, 
  	which was responsible of the deselection of text when the 
  	paragraph lost focus. This way selection works in a more standard 
  	way, and this permits the menu keyboard control to be really effective"
  	paragraph isNil ifFalse:[paragraph focused: aBoolean].
+ 	aBoolean
+ 		ifTrue: [
+ 			"A hand is wanting to send us characters..."
+ 			self hasFocus ifFalse: [self editor	"Forces install"].
+ 			Editor blinkingCursor ifTrue: [self startBlinking]]
+ 		ifFalse:[
+ 			self stopBlinking].
- 	aBoolean ifTrue:["A hand is wanting to send us characters..."
- 		self hasFocus ifFalse: [self editor	"Forces install"].
- 		Editor blinkingCursor ifTrue: [self startBlinking].
- 	] ifFalse:[
- 		self stopBlinking.
- 	].
  	self changed.
+ 
+ 	"Tell my edit-view about this because I am his delegate."
+ 	self editView keyboardFocusChange: aBoolean.
  !

Item was changed:
  (PackageInfo named: 'Morphic') postscript: '"Update existing scrollbars."
  ScrollBar allSubInstances do: [:sb |
  	sb removeAllMorphs; initializeSlider].
  ScrollPane allSubInstances do: [:sc |
  	sc vScrollBar
  		setValueSelector: #vScrollBarValue:;
  		menuSelector: #vScrollBarMenuButtonPressed:.
  	sc hScrollBar
  		setValueSelector: #hScrollBarValue:;
  		menuSelector: #hScrollBarMenuButtonPressed:.
  	sc vSetScrollDelta; hSetScrollDelta].
  
  (Preferences dictionaryOfPreferences at: #alternativeWindowBoxesLook) defaultValue: false.
  "Force SystemProgressMorph to be reset"
  SystemProgressMorph initialize; reset.
  
  "Initialize the key bindings and menus"
  Editor initialize.
  
  "Retain scrollBar look now that the pref actually does something"
  Preferences enable: #gradientScrollBars.
  
  "apply the new icons"
  MenuIcons initializeIcons.
  TheWorldMainDockingBar updateInstances.
  
  "Cleanup old-style preferences here. Remove before new release."
  Preferences removePreference: #gradientMenu. "Now in MenuMorph."
  Preferences removePreference: #roundedMenuCorners. "Now in MenuMorph."
  
  "Fix clipping bug of open windows. New ones are not affected."
  TransformMorph allInstances do: [:ea | ea clipSubmorphs: true].
  
  "Now in ScrollBar."
+ Preferences removePreference: #scrollBarsWithoutMenuButton. 
+ 
+ "Keyboard focus indication."
+ PluggableTextMorph allSubInstances do: [:m |
+ 	m textMorph setProperty: #indicateKeyboardFocus toValue: #never].'!
- Preferences removePreference: #scrollBarsWithoutMenuButton. '!



More information about the Squeak-dev mailing list