[squeak-dev] The Trunk: System-mt.875.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Aug 9 15:10:48 UTC 2016


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

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

Name: System-mt.875
Author: mt
Time: 9 August 2016, 5:10:19.663174 pm
UUID: 3b385daa-216f-2343-bb2c-c82ff68474b1
Ancestors: System-mt.874

Fix long delay when changing many fonts at once like in the demo mode.

=============== Diff against System-mt.874 ===============

Item was changed:
  ----- Method: Preferences class>>attemptToRestoreClassicFonts (in category 'prefs - fonts') -----
  attemptToRestoreClassicFonts
  	"If certain fonts formerly used in early versions of Squeak happen to be present in the image, restore them to their corresponding roles.  Not called by any other method -- intended to be invoked via do-it, possibly in a postscript"
  	"Preferences attemptToRestoreClassicFonts"
  
  	
+ 	self setDefaultFonts: #(	(setButtonFontTo:		NewYork		12)
- 	#(	(setButtonFontTo:		NewYork		12)
  		(setCodeFontTo:			NewYork		12)
  		(setFlapsFontTo:			ComicBold		16)
  		(setEToysFontTo:			ComicBold		16)
  		(setListFontTo:			NewYork		12)
  		(setMenuFontTo:			NewYork		12)
  		(setWindowTitleFontTo:	NewYork		15)
+ 		(setSystemFontTo:		NewYork		12)) .!
- 		(setSystemFontTo:		NewYork		12)) do:
- 			[:triplet | | aTextStyle |
- 				(aTextStyle := TextStyle named: triplet second) ifNotNil:
- 					[self perform: triplet first with: (aTextStyle fontOfSize: triplet third).
- 					Transcript cr; show: triplet second, ' installed as ', (triplet first copyFrom: 4 to: triplet first size - 3)]]!

Item was changed:
  ----- Method: Preferences class>>refreshFontSettings (in category 'prefs - fonts') -----
  refreshFontSettings
  	"Try to update all the current font settings to make things consistent."
  
+ 	UserInterfaceTheme current applyAfter: [
+ 		self setFlapsFontTo: (self standardFlapFont);
+ 			setEToysFontTo: (self standardEToysFont);
+ 			setWindowTitleFontTo: (self windowTitleFont);
+ 			setListFontTo: (self standardListFont);
+ 			setMenuFontTo: (self standardMenuFont);
+ 			setSystemFontTo: (TextStyle defaultFont);
+ 			setCodeFontTo: (self standardCodeFont);
+ 			setBalloonHelpFontTo: (BalloonMorph balloonFont)].
- 	self setFlapsFontTo: (self standardFlapFont);
- 		setEToysFontTo: (self standardEToysFont);
- 		setWindowTitleFontTo: (self windowTitleFont);
- 		setListFontTo: (self standardListFont);
- 		setMenuFontTo: (self standardMenuFont);
- 		setSystemFontTo: (TextStyle defaultFont);
- 		setCodeFontTo: (self standardCodeFont);
- 		setBalloonHelpFontTo: (BalloonMorph balloonFont).
  
  	SystemWindow allSubInstancesDo: [ :s | | rawLabel |
  		rawLabel := s getRawLabel.
  		rawLabel owner vResizing: #spaceFill.
  		rawLabel font: rawLabel font.
  		s setLabel: s label.
  		s replaceBoxes ].!

Item was changed:
  ----- Method: Preferences class>>restoreFontsAfter: (in category 'prefs - fonts') -----
  restoreFontsAfter: aBlock
  
  	"Restore the currently chosen set of standard fonts after 
  	evaluating aBlock. Used for tests that modify the default fonts."
  
  	| standardDefaultTextFont standardListFont standardEToysFont standardMenuFont 
  	windowTitleFont standardBalloonHelpFont standardCodeFont standardButtonFont |
  
  	standardDefaultTextFont := Preferences standardDefaultTextFont.
  	standardListFont := Preferences standardListFont.
  	standardEToysFont := Preferences standardEToysFont.
  	standardMenuFont := Preferences standardMenuFont.
  	windowTitleFont := Preferences windowTitleFont.
  	standardBalloonHelpFont := Preferences standardBalloonHelpFont.
  	standardCodeFont := Preferences standardCodeFont.
  	standardButtonFont := Preferences standardButtonFont.
+ 	^ UserInterfaceTheme current applyAfter: [
+ 		aBlock ensure: [
+ 			Preferences setSystemFontTo: standardDefaultTextFont.
+ 			Preferences setListFontTo: standardListFont.
+ 			Preferences setEToysFontTo: standardEToysFont.
+ 			Preferences setMenuFontTo: standardMenuFont.
+ 			Preferences setWindowTitleFontTo: windowTitleFont.
+ 			Preferences setBalloonHelpFontTo: standardBalloonHelpFont.
+ 			Preferences setCodeFontTo: standardCodeFont.
+ 			Preferences setButtonFontTo: standardButtonFont]].
- 	^aBlock ensure: [
- 		Preferences setSystemFontTo: standardDefaultTextFont.
- 		Preferences setListFontTo: standardListFont.
- 		Preferences setEToysFontTo: standardEToysFont.
- 		Preferences setMenuFontTo: standardMenuFont.
- 		Preferences setWindowTitleFontTo: windowTitleFont.
- 		Preferences setBalloonHelpFontTo: standardBalloonHelpFont.
- 		Preferences setCodeFontTo: standardCodeFont.
- 		Preferences setButtonFontTo: standardButtonFont.
- 	].
  !

Item was changed:
  ----- Method: Preferences class>>setDefaultFonts: (in category 'prefs - fonts') -----
  setDefaultFonts: defaultFontsSpec
  	"Since this is called from menus, we can take the opportunity to prompt for missing font styles."
  
  	| fontNames map emphases |
  	fontNames := defaultFontsSpec collect: [:array | array second].
  	map := IdentityDictionary new.
  	emphases := IdentityDictionary new.
  	fontNames do: [:originalName | | decoded style |
  		decoded := TextStyle decodeStyleName: originalName.
  		style := map at: originalName put: (TextStyle named: decoded second).
  		emphases at: originalName put: decoded first.
  		style ifNil: [map at: originalName put: TextStyle default]].
  
+ 	UserInterfaceTheme current applyAfter: [
+ 		defaultFontsSpec do: [:triplet | self
+ 			perform: triplet first
+ 			with: (((map at: triplet second) fontOfPointSize: triplet third) emphasized: (emphases at: triplet second))]].!
- 	defaultFontsSpec do: [:triplet | self
- 		perform: triplet first
- 		with: (((map at: triplet second) fontOfPointSize: triplet third) emphasized: (emphases at: triplet second))]!

Item was changed:
  Object subclass: #UserInterfaceTheme
+ 	instanceVariableNames: 'scope properties name next ignoreApply'
- 	instanceVariableNames: 'scope properties name next'
  	classVariableNames: 'All Current Default'
  	poolDictionaries: ''
  	category: 'System-Support'!
  
  !UserInterfaceTheme commentStamp: '<historical>' prior: 0!
  A UserInterfaceTheme is a dictionary of preferred visual-properties; colors, borderStyles, borderWidths, fonts, forms, etc. used to color and style the IDE.
  
  Accessing The Theme
  To access the proper UserInterfaceTheme instance for an object, send it #userInterfaceTheme.  The default implementation on Object provides the one instance of that is in-use by the IDE at the current time.
  
  Customizing The Theme
  We can ask the userInterfaceTheme for the value of any visual-property, by name:
  
  	mySystemWindow userInterfaceTheme closeBoxImage
  
  Initially, the above answers nil, which causes the legacy code to use whatever default it's always used.  To override various visual-properties of any kind of object, the #set: onAny: to: message can be used.  For example, 
  
  	myUserInterfaceTheme
  		set: #closeBoxImage 
  		for: SystemWindow
  		to: MenuIcons smallCancelIcon
  
  Alternatively, values may be derived based on other values in the theme, as in:
  
  	myUserInterfaceTheme
  		set: #color 
  		for: FillInTheBlankMorph
  		to: { MenuMorph->#color.  #twiceDarker }
  
  Now, the accessing expression, above, will answer will answer MenuIcons' smallCancelIcon instead of nil.  SystemWindow's code can be changed to use the expression above to access elements of the theme.
  
  Upgrading Legacy Code
  Following the introduction of this class, various client code all around the system must be modified to access it.  This variety of legacy code uses a variety of methods to specify their visual properties:
  
  	1) a hard-coded values.
  	2) a values derived from some other value.
  	3) providing local storage for a settable value which can be nil.
  	4) providing local storage for a settable value which is expected to always have a particular valid value (never nil).
  
  The requirement, for each case, is to let the value be overridden.  
  
  The solution for each of the above should be handled respectively to the above list, as follows:
  
  	1) Check the userInterfaceTheme, if that property returns nil, use the legacy hard-coded value.  (see example: SystemWindow>>#createCloseBox).
  	2) Nothing to do -- simply perform the same derivation on the result of (1).
  	3) Check the local storage, if present, use it.  If nil, then check the userInterfaceTheme, if it has this property present, use it, else return nil.
  	4) Check the userInterfaceTheme, if the property is not nil, use it, otherwise use the local value.
  
  Tool Support
  If a new access to #userInterfaceTheme is added to the code, be sure to add the property and its description to the #themeSettings for that class.  See implementors of #themeSettings for examples.!

Item was changed:
  ----- Method: UserInterfaceTheme>>apply (in category 'actions') -----
  apply
  	"Apply this theme to all affected objects. Let classes decide on how to iterate and call their instances."
  
+ 	ignoreApply == true ifTrue: [^ self].
+ 	
  	UserInterfaceTheme current: self.
  
  	self class clientClassesToReapply in: [:cc |
  		cc do: [:eachClass | eachClass applyUserInterfaceTheme].
  		(cc select: [:eachClass | eachClass canApplyThemeToInstances])
  			do: [:eachClass | eachClass applyThemeToInstances]
  			displayingProgress: [:eachClass | 'Applying {1} to instances of {2}' format: {self name. eachClass name}]
  			every: 1000 ].
  
  	Project current restoreDisplay.!

Item was added:
+ ----- Method: UserInterfaceTheme>>applyAfter: (in category 'actions') -----
+ applyAfter: block
+ 
+ 	ignoreApply := true.
+ 	^ block ensure: [ignoreApply := false. self apply]!



More information about the Squeak-dev mailing list