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

commits at source.squeak.org commits at source.squeak.org
Fri Feb 27 13:06:43 UTC 2015


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

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

Name: Morphic-mt.766
Author: mt
Time: 27 February 2015, 2:05:26.066 pm
UUID: 1c861e43-3cbf-2649-bd3e-22d1d3d88803
Ancestors: Morphic-mt.765

Several cosmetic fixes considering dockingbar morphs and menu morphs. #roundedMenuCorners is now a pragma-style preference. Several magic numbers could be removed.

=============== Diff against Morphic-mt.765 ===============

Item was changed:
  ----- Method: DockingBarItemMorph>>adjacentTo (in category 'selecting') -----
  adjacentTo
+ 
+ 	| roundedCornersOffset |
+ 	roundedCornersOffset := MenuMorph roundedMenuCorners
+ 		ifTrue: [Morph preferredCornerRadius negated]
+ 		ifFalse: [0].
+ 
- 	
  	owner isFloating
+ 		ifTrue: [^ {self bounds bottomLeft + (roundedCornersOffset @ 4)}].
- 		ifTrue: [^ {self bounds bottomLeft + (4 @ 4)}].
  	owner isAdheringToTop
+ 		ifTrue: [^ {self bounds bottomLeft + (roundedCornersOffset @ 4)}].
- 		ifTrue: [^ {self bounds bottomLeft + (4 @ 4)}].
  	owner isAdheringToLeft
+ 		ifTrue: [^ {self bounds topRight + (roundedCornersOffset @ 4)}].
- 		ifTrue: [^ {self bounds topRight + (4 @ 4)}].
  	owner isAdheringToBottom
+ 		ifTrue: [^ {self bounds topLeft + (roundedCornersOffset @ 4)}].
- 		ifTrue: [^ {self bounds topLeft + (4 @ 4)}].
  	owner isAdheringToRight
+ 		ifTrue: [^ {self bounds topLeft + (roundedCornersOffset @ -4)}].
+ 	^ {self bounds bottomLeft + (roundedCornersOffset @ 5)}!
- 		ifTrue: [^ {self bounds topLeft + (4 @ -4)}].
- 	^ {self bounds bottomLeft + (3 @ 5)}!

Item was changed:
  ----- Method: DockingBarMorph>>activeSubmenu: (in category 'control') -----
  activeSubmenu: aSubmenu 
  	activeSubMenu isNil
  		ifFalse: [activeSubMenu delete].
  	activeSubMenu := aSubmenu.
  	aSubmenu isNil
  		ifTrue: [^ self].
  	activeSubMenu updateMenu.
  	activeSubMenu selectItem: nil event: nil.
  	MenuIcons decorateMenu: activeSubMenu.
  	activeSubMenu 
  		activatedFromDockingBar: self;
- 		borderColor: self borderColor;
  		beSticky;
  		resistsRemoval: true;
  		removeMatchString!

Item was changed:
  ----- Method: DockingBarMorph>>updateColor (in category 'private - layout') -----
  updateColor
  	"private - update the receiver's color"
  	| fill |
+ 	self autoGradient ifFalse: [
+ 		self color ~= originalColor ifTrue: [self color: originalColor].
+ 		^ self].
- 	self autoGradient
- 		ifFalse: [^ self].
  	""
  	fill := GradientFillStyle ramp: self gradientRamp.
  	""
  	fill origin: self topLeft.
  	self isVertical
  		ifTrue: [fill direction: self width @ 0]
  		ifFalse: [fill direction: 0 @ self height].
  	""
  	self fillStyle: fill!

Item was changed:
  ----- Method: MenuItemMorph>>adjacentTo (in category 'selecting') -----
  adjacentTo
  
+ 	^{ self outerBounds topRight. self bounds topLeft }!
- 	^{ self bounds topRight + (10 @ 0). self bounds topLeft }!

Item was changed:
  AlignmentMorph subclass: #MenuMorph
  	instanceVariableNames: 'defaultTarget selectedItem stayUp popUpOwner activeSubMenu'
+ 	classVariableNames: 'CloseBoxImage GradientMenu PushPinImage RoundedMenuCorners'
- 	classVariableNames: 'CloseBoxImage GradientMenu PushPinImage'
  	poolDictionaries: ''
  	category: 'Morphic-Menus'!
  
  !MenuMorph commentStamp: '<historical>' prior: 0!
  Instance variables:
  	defaultTarget 	<Object>				The default target for creating menu items
  	selectedItem		<MenuItemMorph> 	The currently selected item in the receiver
  	stayUp 			<Boolean>			True if the receiver should stay up after clicks
  	popUpOwner 	<MenuItemMorph>	The menu item that automatically invoked the receiver, if any.
  	activeSubMenu 	<MenuMorph>		The currently active submenu.!

Item was changed:
  ----- Method: MenuMorph class>>gradientMenu: (in category 'preferences') -----
  gradientMenu: aBoolean
  
  	GradientMenu := aBoolean.
+ 	SystemProgressMorph reset.
+ 	
+ 	"Update docking bars and their sub-menus."
+ 	ActiveWorld mainDockingBars do: [:bar |
+ 		bar
+ 			autoGradient: aBoolean;
+ 			updateColor].
+ 	TheWorldMainDockingBar updateInstances.!
- 	SystemProgressMorph reset.!

Item was added:
+ ----- Method: MenuMorph class>>roundedMenuCorners (in category 'preferences') -----
+ roundedMenuCorners
+ 
+ 	<preference: 'roundedMenuCorners'
+ 		category: #menus
+ 		description: 'Whether morphic menus should have rounded corners.'
+ 		type: #Boolean>
+ 	^ RoundedMenuCorners ifNil: [true]!

Item was added:
+ ----- Method: MenuMorph class>>roundedMenuCorners: (in category 'preferences') -----
+ roundedMenuCorners: aBoolean
+ 
+ 	RoundedMenuCorners := aBoolean.
+ 	SystemProgressMorph reset.
+ 	TheWorldMainDockingBar updateInstances.!

Item was changed:
  ----- Method: MenuMorph>>addStayUpIcons (in category 'construction') -----
  addStayUpIcons
  	| title closeBox pinBox titleBarArea titleString |
  	title := submorphs
  				detect: [:ea | ea hasProperty: #titleString]
  				ifNone: [self setProperty: #needsTitlebarWidgets toValue: true.
  					^ self].
  	closeBox := SystemWindowButton new target: self;
  				 actionSelector: #delete;
  				 labelGraphic: self class closeBoxImage;
  				 color: Color transparent;
  				 extent: 14 @ 16;
  				 borderWidth: 0.
  	pinBox := SystemWindowButton new target: self;
  				 actionSelector: #stayUp:;
  				 arguments: {true};
  				 labelGraphic: self class pushPinImage;
  				 color: Color transparent;
  				 extent: 16 @ 16;
  				 borderWidth: 0.
  	Preferences noviceMode
  		ifTrue: [closeBox setBalloonText: 'close this menu'.
  			pinBox setBalloonText: 'keep this menu up'].
  	titleBarArea :=  AlignmentMorph newRow vResizing: #shrinkWrap;
  			 layoutInset: 3;
  			 color: Preferences menuTitleColor;
  			 addMorphBack: closeBox;
  			 addMorphBack: title;
  			 addMorphBack: pinBox.
  	
  	title color: Color transparent.
  
  	titleString := title 
  		findDeepSubmorphThat: [:each | each respondsTo: #font: ]
  		ifAbsent: [StringMorph contents: String empty].
  	titleString font: Preferences windowTitleFont.
+ 	self wantsRoundedCorners
- 	Preferences roundedMenuCorners
  		ifTrue: [titleBarArea useRoundedCorners].
  	
  	self addMorphFront: titleBarArea.
  	titleBarArea setProperty: #titleString toValue: (title valueOfProperty: #titleString).
  	title removeProperty: #titleString.
  	self setProperty: #hasTitlebarWidgets toValue: true.
  	self removeProperty: #needsTitlebarWidgets.
  	self removeStayUpItems!

Item was changed:
  ----- Method: MenuMorph>>initialize (in category 'initialization') -----
  initialize
  	super initialize.
  
  	bounds := 0 @ 0 corner: 40 @ 10.
  
  	self setDefaultParameters.
  
  	self listDirection: #topToBottom.
  	self hResizing: #shrinkWrap.
  	self vResizing: #shrinkWrap.
  	defaultTarget := nil.
  	selectedItem := nil.
  	stayUp := false.
+ 	popUpOwner := nil.!
- 	popUpOwner := nil.
- 
- 	Preferences roundedMenuCorners
- 		ifTrue: [self useRoundedCorners].
- !

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 |
- 	"Present this menu at the given point under control of the given  
- 	hand."
- 	| tryToPlace selectedOffset |
  	hand world startSteppingSubmorphsOf: self.
  	popUpOwner := sourceItem.
+ 	
  	self fullBounds.
+ 	self updateColor.
+ 	
- 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 fullBoundsInWorld amountToTranslateWithin: sourceItem worldBounds.
  			(delta x = 0
  					or: [mustFit])
  				ifTrue: [delta = (0 @ 0)
  						ifFalse: [self position: self position + delta].
  					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.!
- 	tryToPlace value: rightOrLeftPoint first value: false;
- 		 value: rightOrLeftPoint last - (self width @ 0) value: false;
- 		 value: rightOrLeftPoint first value: true!

Item was changed:
  ----- Method: MenuMorph>>setTitleParametersFor: (in category 'initialization') -----
  setTitleParametersFor: aMenuTitle 
  	| menuTitleColor menuTitleBorderColor |
+ 	self wantsRoundedCorners
- 	Preferences roundedMenuCorners
  		ifTrue: [aMenuTitle useRoundedCorners].
  
  	menuTitleColor := Preferences menuColorFromWorld
  				ifTrue: [self color darker]
  				ifFalse: [Preferences menuTitleColor].
  
  	menuTitleBorderColor := Preferences menuAppearance3d
  				ifTrue: [#inset]
  				ifFalse: [Preferences menuColorFromWorld
  						ifTrue: [self color darker muchDarker]
  						ifFalse: [Preferences menuTitleBorderColor]].
  
  	aMenuTitle
  		setColor: menuTitleColor
  		borderWidth: Preferences menuTitleBorderWidth
  		borderColor: menuTitleBorderColor;
  		vResizing: #shrinkWrap;
  		wrapCentering: #center;
  		cellPositioning: #topCenter;
  		layoutInset: 0.
  !

Item was added:
+ ----- Method: MenuMorph>>wantsRoundedCorners (in category 'rounding') -----
+ wantsRoundedCorners
+ 
+ 	^ self class roundedMenuCorners or: [super wantsRoundedCorners]!

Item was changed:
  ----- Method: SystemProgressMorph>>setDefaultParameters (in category 'initialization') -----
  setDefaultParameters
  	"change the receiver's appareance parameters"
  
  	| colorFromMenu worldColor menuColor |
  
  	colorFromMenu := Preferences menuColorFromWorld
  									and: [Display depth > 4
  									and: [(worldColor := self currentWorld color) isColor]].
  
  	menuColor := colorFromMenu
  						ifTrue: [worldColor luminance > 0.7
  										ifTrue: [worldColor mixed: 0.85 with: Color black]
  										ifFalse: [worldColor mixed: 0.4 with: Color white]]
  						ifFalse: [Preferences menuColor].
  
  	self color: menuColor.
  	
+ 	MenuMorph roundedMenuCorners
- 	Preferences roundedMenuCorners
  		ifTrue: [self useRoundedCorners].
  	self borderWidth: Preferences menuBorderWidth.
  
  	Preferences menuAppearance3d ifTrue: [
  		self borderStyle: BorderStyle thinGray.
  		self
  			addDropShadow;
  			shadowColor: (TranslucentColor r: 0.0 g: 0.0 b: 0.0 alpha: 0.666);
  			shadowOffset: 1 @ 1
  	]
  	ifFalse: [
  		| menuBorderColor |
  		menuBorderColor := colorFromMenu
  										ifTrue: [worldColor muchDarker]
  										ifFalse: [Preferences menuBorderColor].
  		self borderColor: menuBorderColor.
  	].
  
  	self
  		updateColor: self
  		color: self color
  		intensity: 1.!

Item was changed:
  ----- Method: SystemWindow class>>updatePreferences (in category 'initializing') -----
  updatePreferences
  	"Temporary method to update system-wide preferences"
  	Preferences setPreference: #defaultWindowColor toValue: (Color veryVeryLightGray muchLighter).
  	(Preferences preferenceAt: #defaultWindowColor) defaultValue: (Color veryVeryLightGray muchLighter).
  
  	Preferences setPreference: #menuAppearance3d toValue: true.
  	(Preferences preferenceAt: #menuAppearance3d) defaultValue: true.
  
  	Preferences setPreference: #menuColorFromWorld toValue: false.
  	(Preferences preferenceAt: #menuColorFromWorld) defaultValue: false.
  
+ 	MenuMorph roundedMenuCorners: false.
- 	Preferences setPreference: #roundedMenuCorners toValue: false.
- 	(Preferences preferenceAt: #roundedMenuCorners) defaultValue: false.
  
  	Preferences setParameter: #menuColor to: (Color gray: 0.9).
  	Preferences setParameter: #menuTitleColor to: (Color transparent).
  	Preferences setParameter: #menuTitleBorderWidth to: 0.
  	Preferences setParameter: #defaultWorldColor to: (Color gray: 0.25).
  
  	Preferences setPreference: #showSplitterHandles toValue: false.
  	(Preferences preferenceAt: #showSplitterHandles) defaultValue: true.
  
  	Preferences setPreference: #showSharedFlaps toValue: false.
  	(Preferences preferenceAt: #showSharedFlaps) defaultValue: false.
  
  	Preferences installBrightWindowColors.
  
  	CornerGripMorph drawCornerResizeHandles: false.
  	FillInTheBlankMorph roundedDialogCorners: true.
  
  	LazyListMorph
  		listSelectionColor: LazyListMorph listSelectionColor;
  		listSelectionTextColor: Color black.
  	PluggableButtonMorph roundedButtonCorners: true.
  	SystemWindow
  		clickOnLabelToEdit: false;
  		doubleClickOnLabelToExpand: true;
  		moveMenuButtonRight: true;
  		hideExpandButton: false.
  !

Item was changed:
  ----- Method: TheWorldMainDockingBar>>createDockingBar (in category 'construction') -----
  createDockingBar
  	"Create a docking bar from the receiver's representation"
  	
  	| dockingBar |
  	dockingBar := DockingBarMorph new
  		adhereToTop;
  		color: Preferences menuColor;
  		gradientRamp: self gradientRamp;
+ 		autoGradient: MenuMorph gradientMenu;
- 		autoGradient: ColorTheme current dockingBarAutoGradient;
  		borderWidth: 0.
  	self fillDockingBar: dockingBar.
  	self labelIfNeeded: dockingBar.
  	^ dockingBar!

Item was changed:
  (PackageInfo named: 'Morphic') postscript: '(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."'!
- Preferences removePreference: #gradientMenu. "Now in MenuMorph."'!



More information about the Squeak-dev mailing list