'From Squeak6.0alpha of 21 December 2021 [latest update: #20891] on 23 December 2021 at 3:09:18 pm'!
Form subclass: #DisplayScreen
	instanceVariableNames: 'clippingBox extraRegions '
	classVariableNames: 'DeferringUpdates DisplayChangeSignature DisplayIsFullScreen PlatformScaleFactor RelativeScaleFactorEnabled '
	poolDictionaries: ''
	category: 'Graphics-Display Objects'!

!Controller methodsFor: 'basic control sequence' stamp: 'mt 12/23/2021 11:18'!
interActivityPause
	"if we are looping quickly, insert a short delay.  Thus if we are just doing UI stuff, we won't take up much CPU"
	| currentTime wait |
	MinActivityLapse ifNotNil: [
		lastActivityTime ifNotNil: [ 
			currentTime := Time millisecondClockValue.
			wait := lastActivityTime + MinActivityLapse - currentTime.
			wait > 0 ifTrue: [ 
				wait <= MinActivityLapse  "big waits happen after a snapshot"
					ifTrue: [DisplayScreen checkForNewScreenScaleFactor; checkForNewScreenSize.
							(Delay forMilliseconds: wait) wait ]. ]. ]. ].

	lastActivityTime := Time millisecondClockValue.! !


!DisplayScreen methodsFor: 'scale factor' stamp: 'mt 12/23/2021 11:09'!
platformScaleFactor
	"Answers the platform's (and thus monitor's) current scale factor as last reported via VM primitive."

	^ PlatformScaleFactor ifNil: [PlatformScaleFactor := self class actualScreenScaleFactor]! !

!DisplayScreen methodsFor: 'scale factor' stamp: 'mt 12/23/2021 14:51'!
platformScaleFactor: aFloat
	"Report a new scale factor from the platform to the image. This can happen if you move Squeak's window between monitors with different pixels-per-inch. On some platforms, you can also set a scale factor independent of monitor PPI. Here, we now have to decide whether we pass on that scale factor directly to the user interface or ask the user what to do. The user might have scaled the image regardless of the previous platform scale factor."

	| old new |
	(old := PlatformScaleFactor) = (new := aFloat) ifTrue: [^ self].
	PlatformScaleFactor := new.
	self uiScaleFactor: self uiScaleFactor * (new/old).! !

!DisplayScreen methodsFor: 'scale factor' stamp: 'mt 12/23/2021 14:40'!
relativeUiScaleFactor
	"Answers the scale factor as perceived by the user. Note that this concept might be platform-dependent. On Windows, for example, 100% means pixel-perfect while on macOS 100% means as-the-monitor-demands. So, Retina displays are effectively scaled even if the user sees 100% in a Choose-Your-Scale dialog."
	
	^ self class relativeScaleFactorEnabled
		ifTrue: [ "macOS" self uiScaleFactor / self platformScaleFactor ]
		ifFalse: [ "Windows" self uiScaleFactor ]! !

!DisplayScreen methodsFor: 'scale factor' stamp: 'mt 12/23/2021 14:39'!
relativeUiScaleFactor: aFloat
	
	^ self class relativeScaleFactorEnabled
		ifTrue: [ "macOS" self uiScaleFactor: aFloat * self platformScaleFactor ]
		ifFalse: [ "Windows" self uiScaleFactor: aFloat ]! !

!DisplayScreen methodsFor: 'scale factor' stamp: 'mt 12/23/2021 15:04'!
uiScaleFactor
	"Answers the current scale factor used to configure all widgets, tools, or windows to be prepared for the current rendering system, i.e., BitBlt. Note that 1.0 means 'pixel perfect'."
	
	^ UserInterfaceTheme current isTTCBased
		ifTrue: [RealEstateAgent scaleFactor]
		ifFalse: [RealEstateAgent scaleFactor roundTo: 0.25].! !

!DisplayScreen methodsFor: 'scale factor' stamp: 'mt 12/23/2021 14:24'!
uiScaleFactor: aFloat
	"Sets the effective scale factor for the user interface, i.e., all widgets, tools, and windows. The user can override the CurrentScaleFactor recommended by the platform."

	| oldFactor newFactor |
	(UserInterfaceTheme current canFakeScaleFactor: aFloat) ifTrue: [
		self flag: #isTTCBased.
		^ UserInterfaceTheme current applyScaled: aFloat].
	
	oldFactor := RealEstateAgent scaleFactor. "Use effective, pixel-based factor to bypass StrikeFont magic. See #isTTCBased and #uiScaleFactor."
	newFactor := aFloat max: 1.0.
	newFactor = oldFactor ifTrue: [^ self].
	
	TextStyle pixelsPerInch: 96.0 * aFloat.
	Project current ifNotNil: [:p | p displayScaleChangedFrom: oldFactor to: newFactor].! !


!DisplayScreen class methodsFor: 'display box access' stamp: 'mt 12/23/2021 15:00'!
checkForNewScreenScaleFactor
	"Check whether the platform's scale factor has changed and if so take appropriate actions"

	Display platformScaleFactor: DisplayScreen actualScreenScaleFactor.! !

!DisplayScreen class methodsFor: 'snapshots' stamp: 'mt 12/23/2021 07:48'!
actualScreenScaleFactor
	<primitive: 'primitiveScreenScaleFactor'>
	
	^ 1.0! !

!DisplayScreen class methodsFor: 'preferences' stamp: 'mt 12/23/2021 15:08'!
relativeScaleFactorEnabled
	<preference: 'Show Relative Scale Factor'
		categoryList: #(Morphic Tools visuals)
		description: 'When true, 100% means as-the-platform/monitor-demands, which is typical for macOS. When false, 100% means pixel-perfect, which is typical for Windows.'
		type: #Boolean>

	"Note that we set the default to 'false' because pixels are very prominent in the Morphic programming model. So it makes sense to communcate this kind of pixel scaling openly and thus not hide the #platformScaleFactor from the user."
	^ RelativeScaleFactorEnabled ifNil: [false].! !

!DisplayScreen class methodsFor: 'preferences' stamp: 'mt 12/23/2021 14:32'!
relativeScaleFactorEnabled: aBoolean

	RelativeScaleFactorEnabled := aBoolean.! !


!FontImporterTool methodsFor: 'helper' stamp: 'mt 12/21/2021 16:22'!
fontFromFamily: aFamily

	| readFonts | 
	aFamily ifNil: [^ TextStyle default fonts first].
	readFonts := TTFileDescription readFontsFrom: aFamily allFilenames anyOne.
	^ (readFonts size > 1
		ifTrue: [ 
			| ftArray |
			" see TTCFontSet>>newTextStyleFromTT: "
			ftArray := readFonts collect: [:ttc | |f|
				ttc ifNil: [nil] ifNotNil: [
					f := TTCFont new.
					f ttcDescription: ttc.
					f pointSize: TextStyle defaultFont pointSize.
					f]].
			TTCFontSet newFontArray: ftArray]
		ifFalse: [ |f|
			f := TTCFont new.
			f ttcDescription: readFonts anyOne.
			f pointSize: TextStyle defaultFont pointSize.	
			f])! !


!Preferences class methodsFor: 'prefs - fonts' stamp: 'mt 12/23/2021 14:21'!
decreaseFontSize

	Display uiScaleFactor: Display uiScaleFactor - 0.25.! !

!Preferences class methodsFor: 'prefs - fonts' stamp: 'mt 12/23/2021 14:20'!
increaseFontSize

	Display uiScaleFactor: Display uiScaleFactor + 0.25.! !

!Preferences class methodsFor: 'prefs - fonts' stamp: 'mt 12/23/2021 07:32'!
setDemoFonts
	"Preferences setDemoFonts"

	Display uiScaleFactor: 1.5.! !

!Preferences class methodsFor: 'prefs - fonts' stamp: 'mt 12/21/2021 08:05'!
setFixedFontTo: aFont

	UserInterfaceTheme current setFixedFontTo: aFont.! !

!Preferences class methodsFor: 'prefs - fonts' stamp: 'mt 12/21/2021 08:04'!
setSystemFontTo: aFont

	UserInterfaceTheme current setSystemFontTo: aFont.! !


!Project methodsFor: 'displaying' stamp: 'mt 12/23/2021 14:22'!
displayScaleChangedFrom: oldFactor to: newFactor

	RealEstateAgent resetScaleFactor. "Reset cached (pixel-based) scale factor used by tool builders etc."! !


!MorphicProject methodsFor: 'display' stamp: 'mt 12/21/2021 17:41'!
displayScaleChangedFrom: oldFactor to: newFactor
	"Update Morphic-specific geometry. Try to be more efficient than UI theme's #applyUserInterfaceTheme."
	
	| scale |
	super displayScaleChangedFrom: oldFactor to: newFactor.
	
	"Based on UserInterfaceTheme >> #apply"
	(#(SimpleHierarchicalListMorph SystemWindow PluggableTextMorph SystemProgressMorph)
		collect: [:className | self environment classNamed: className])
		in: [:widgetClasses | 
			widgetClasses do: [:ea | ea applyUserInterfaceTheme].
			Cursor wait showWhile: [
				SystemNavigation default allObjectsDo: [:o |
					((widgetClasses includes: o class)
						and: [o canApplyUserInterfaceTheme])
							ifTrue: [o applyUserInterfaceTheme]]]].
	
	
	"Resize windows."
	scale := newFactor / oldFactor.
	self world submorphs
		select: [:ea | ea isSystemWindow]
		thenDo: [:ea |
			ea extent: (ea extent * scale).
			ea layoutChanged.
			ea setFramesForLabelArea].! !


!RealEstateAgent class methodsFor: 'display scale' stamp: 'mt 12/21/2021 11:10'!
resetScaleFactor
	
	ScaleFactor := nil.! !

!RealEstateAgent class methodsFor: 'display scale' stamp: 'mt 12/21/2021 12:39'!
scaleFactor
	"Use the default font height to calculate some factor. Note that, in the future, we will be able to use a method that is not based on pixels once we only use TrueType fonts all over the image. Then, TextStyle class >> #pixelsPerInch will suffice, considering that 96 PPI represents a scale factor of 1.0."
	
	^ ScaleFactor ifNil: [ScaleFactor := (TextStyle defaultFont height / StrikeFont referenceHeight)]! !


!ReleaseBuilder class methodsFor: 'scripts' stamp: 'mt 12/22/2021 10:01'!
setPreferences
	"Preferences class defaultValueTableForCurrentRelease"

"	Preferences outOfTheBox."  "<-- uncomment after #defaultValueTableForCurrentRelease is fixed up."

	"General User interaction"
	Preferences
		enable: #generalizedYellowButtonMenu ;
		enable: #swapMouseButtons;
		disable: #mouseOverForKeyboardFocus.
	Morph indicateKeyboardFocus: true.
	Project uiManager openToolsAttachedToMouseCursor: false.
	SearchBar useScratchPad: false.
	
	HandMorph sendMouseWheelToKeyboardFocus: false.
	HandMorph synthesizeMouseWheelEvents: true.
	
	"Text input."
	TextEditor
		 autoEnclose: true ;
		 autoIndent: true ;
		 encloseSelection: true ;
		 destructiveBackWord: false ;
		 blinkingCursor: true ;
		 dumbbellCursor: false.
	PluggableTextMorph simpleFrameAdornments: false.
	TextMorphForEditView draggableTextSelection: true.
	
	"Windows"
	SystemWindow reuseWindows: false.
	SystemWindow windowsRaiseOnClick: true.
	SystemWindow windowTitleActiveOnFirstClick: true.
	Model windowActiveOnFirstClick: false. "Not good for little screen real estate."
	Model useColorfulWindows: false. 

	Preferences
		disable: #fastDragWindowForMorphic.
	AbstractResizerMorph
		gripThickness: 4;
		handleLength: 25.
	CornerGripMorph
		drawCornerResizeHandles: false;
		drawEdgeResizeHandles: false.
	ProportionalSplitterMorph
		showSplitterHandles: false;
		smartHorizontalSplitters: false;
		smartVerticalSplitters: false.

	"Scroll bars."
	Preferences
		enable: #scrollBarsNarrow;
		enable: #scrollBarsOnRight;
		enable: #alwaysHideHScrollbar;
		disable: #alwaysShowHScrollbar;
		disable: #alwaysShowVScrollbar.
	ScrollBar
		scrollBarsWithoutArrowButtons: true;
		scrollBarsWithoutMenuButton: true.
	ScrollPane
		useRetractableScrollBars: false.

	"Rounded corners."
	Morph preferredCornerRadius: 8.
	SystemWindow roundedWindowCorners: false.
	DialogWindow roundedDialogCorners: false.
	MenuMorph roundedMenuCorners: false.
	PluggableButtonMorph roundedButtonCorners: false.
	ScrollBar roundedScrollBarLook: false.
	
	"Gradients."
	SystemWindow gradientWindow: false.
	DialogWindow gradientDialog: false.
	MenuMorph gradientMenu: false.
	PluggableButtonMorph gradientButton: false.
	ScrollBar gradientScrollBar: false.

	"Shadows"
	Preferences enable: #menuAppearance3d.
	Morph useSoftDropShadow: true.
	
	"Lists and Trees"
	PluggableListMorph
		filterableLists: true;
		clearFilterAutomatically: false;
		clearFilterDelay: 500;
		highlightHoveredRow: true;
		highlightPreSelection: false;
		menuRequestUpdatesSelection: true.
	PluggableTreeMorph
		filterByLabelsOnly: false;
		maximumSearchDepth: 1.
	
	"Standard Tools"
	TheWorldMainDockingBar
		showWorldMainDockingBar: true;
		showSecondsInClock: true;
		twentyFourHourClock: true.
	SearchBar useSmartSearch: true.
	Workspace shouldStyle: false.
	TranscriptStream
		forceUpdate: true;
		redirectToStdOut: false;
		characterLimit: 20000.
	Browser
		listClassesHierarchically: true;
		showClassIcons: true;
		showMessageIcons: true;
		sortMessageCategoriesAlphabetically: true.
	SystemBrowser browseWithDragNDrop: true.
	MessageSet useUnifiedMessageLabels: true.
	Preferences
		enable: #annotationPanes;
		defaultAnnotationRequests: #(timeStamp author messageCategory implementorsCount allChangeSets);
		enable: #optionalButtons;
		disable: #diffsWithPrettyPrint;
		enable: #traceMessages;
		enable: #alternativeBrowseIt;
		enable: #menuWithIcons;
		enable: #visualExplorer;
		disable: #showSharedFlaps.
	Preferences disable: #debugLogTimestamp.

	"Halo"
	Preferences
		enable: #showBoundsInHalo ;
		disable: #alternateHandlesLook;
		disable: #showDirectionHandles.
	Morph
		haloForAll: true;
		metaMenuForAll: true.

	"System"
	NetNameResolver enableIPv6: false.
	Scanner
		allowUnderscoreAsAssignment: true;
		prefAllowUnderscoreSelectors: true.
		
	Deprecation showDeprecationWarnings: true

	"that's all, folks"! !


!StrikeFont class methodsFor: '*System-constants' stamp: 'mt 12/21/2021 08:58'!
referenceHeight
	"Since Squeak 4.1, the standard system/text font has been pre-rendered to a height of 14 pixels, which are about 10.5 point in 96 PPI. We can use this value to compute the effective in-image scale factor using the current system font's height (in pixels). If that font happens to be a TTCFont, the same #pointSize can result in a different #pixelSize once PPI changes.
	
	StrikeFont ... 10.5 pt = 14 px in 96 ppi = 1.0 or 100%
	TTCFont ... 96 ppi = 1.0 or 100%
	"

	^ 14 "pixels"! !


!TTCFont class methodsFor: '*System-constants' stamp: 'mt 12/21/2021 13:15'!
referencePointSize
	"See commentary in StrikeFont class >> #referenceHeight."

	^ 10.5! !


!TextStyle class methodsFor: 'utilities' stamp: 'mt 12/21/2021 11:05'!
pixelsPerInch: aNumber
	"Set the nominal number of pixels per inch to aNumber."

	self pixelsPerInch = aNumber ifTrue: [^ self].
	TextConstants at: #pixelsPerInch put: aNumber.
	AbstractFont allSubInstancesDo: [ :font | font pixelsPerInchChanged ].! !


!TheWorldMainDockingBar methodsFor: 'submenu - extras' stamp: 'mt 12/23/2021 14:42'!
chooseCustomScaleFactor

	| result |
	result := Project uiManager request: 'Please enter a scale factor in %' translated initialAnswer: '350'.
	result ifEmpty: [^ self].
	[result := result asInteger abs] ifError: [^ self].
	result < 100 ifTrue: [^ self].
	Display relativeUiScaleFactor: result / 100.! !

!TheWorldMainDockingBar methodsFor: 'submenu - extras' stamp: 'mt 12/19/2021 09:11'!
extrasMenuOn: aDockingBar 

	aDockingBar addItem: [ :it|
		it 	contents: 'Extras' translated;
			addSubMenu: [:menu|
				menu addItem:[:item|
					item
						contents: 'Recover Changes' translated;
						help: 'Recover changes after a crash' translated;
						icon: MenuIcons smallDocumentClockIcon;
						target: ChangeList;
						selector: #browseRecentLog].
				menu addItem:[:item|
					item
						contents: 'Recover Method Versions' translated;
						help: 'Recover versions of deleted methods' translated;
						target: ChangeList;
						selector: #browseMethodVersions].				
				menu addLine.
				menu addItem:[:item|
					item
						contents: 'Themes & Colors' translated;
						subMenuUpdater: self
						selector: #themesAndWindowColorsOn: ].
				menu addItem:[:item|
					item
						contents: 'Scale Factor' translated;
						subMenuUpdater: self
						selector: #scaleFactorsOn:].
				menu addItem:[:item|
					item
						contents: 'Language' translated;
						subMenuUpdater: self
						selector: #languageTranslatorsOn: ].
				menu addItem:[:item|
					item
						contents: 'Set Author Initials' translated;
						help: 'Sets the author initials' translated;
						icon: MenuIcons smallUserQuestionIcon;
						target: Utilities;
						selector: #setAuthorInitials].
				menu addItem:[:item|
					item
						contents: 'Restore Display (r)' translated;
						help: 'Redraws the entire display' translated;
						target: Project current;
						selector: #restoreDisplay].
				menu addItem:[:item|
					item
						contents: 'Rebuild Menus' translated;
						help: 'Rebuilds the menu bar' translated;
						target: TheWorldMainDockingBar;
						selector: #updateInstances].
				menu addLine.
				menu addItem:[:item|
					item
						contents: 'Start Profiler' translated;
						help: 'Starts the profiler' translated;
						icon: MenuIcons smallTimerIcon;
						target: self;
						selector: #startMessageTally].
				menu addItem:[:item|
					item
						contents: 'Collect Garbage' translated;
						help: 'Run the garbage collector and report space usage' translated;
						target: Utilities;
						selector: #garbageCollectAndReport].
				menu addItem:[:item|
					item
						contents: 'Purge Undo Records' translated;
						help: 'Save space by removing all the undo information remembered in all projects' translated;
						target: CommandHistory;
						selector: #resetAllHistory].
				menu addItem:[:item|
					item
						contents: 'VM statistics' translated;
						help: 'Virtual Machine information' translated;
						target: self;
						selector: #vmStatistics].
				menu addLine.
				menu addItem:[:item|
					item
						contents: 'Graphical Imports' translated;
						help: 'View the global repository called ImageImports; you can easily import external graphics into ImageImports via the FileList' translated;
						target: (Imports default);
						selector: #viewImages].
				menu addItem:[:item|
					item
						contents: 'Standard Graphics Library' translated;
						help: 'Lets you view and change the system''s standard library of graphics' translated;
						target: ScriptingSystem;
						selector: #inspectFormDictionary].
				menu addItem:[:item|
					item
						contents: 'Annotation Setup' translated;
						help: 'Click here to get a little window that will allow you to specify which types of annotations, in which order, you wish to see in the annotation panes of browsers and other tools' translated;
						target: Preferences;
						selector: #editAnnotations].
				menu addItem:[:item|
					item
						contents: 'Browse My Changes' translated;
						help: 'Browse all of my changes since the last time #condenseSources was run.' translated;
						target: SystemNavigation new;
						selector: #browseMyChanges].
			] ]! !

!TheWorldMainDockingBar methodsFor: 'submenu - extras' stamp: 'mt 12/23/2021 14:45'!
scaleFactorsOn: menu

	| presets currentScaleFactor currentPlatformScaleFactor |
	currentScaleFactor := (Display relativeUiScaleFactor * 100) rounded.
	currentPlatformScaleFactor := (Display platformScaleFactor * 100) rounded.
	presets := 100 to: 300 by: 25.
	
	presets do: [:scale |
		scale = 175 ifTrue: [menu addLine]. "TTCFont used after this line..."
		menu addItem: [:item|
			item
				contents: ('{1}{2}%{3}' format: {
					currentScaleFactor = scale ifTrue: ['<yes>'] ifFalse: ['<no>'].
					scale.
					DisplayScreen relativeScaleFactorEnabled
						ifTrue: ['' "macOS"] ifFalse: [
							scale = currentPlatformScaleFactor
								ifTrue: [' (recommended)'] ifFalse: ['']]
					});
				target: Display;
				selector: #relativeUiScaleFactor:;
				arguments: {scale / 100}]].
		
	menu addLine.
	menu addItem: [:item |
		item
			contents: ((presets includes: currentScaleFactor) not ifTrue: ['<yes> Custom: ', currentScaleFactor, '% ...'] ifFalse: ['<no>Other scale factor...']);
			target: self;
			selector: #chooseCustomScaleFactor].! !

!TheWorldMainDockingBar methodsFor: 'submenu - extras' stamp: 'mt 12/21/2021 13:33'!
themesAndWindowColorsOn: menu
	| themes |
	menu addItem:[:item|
		item
			contents: (Model useColorfulWindows ifTrue: ['<yes>'] ifFalse: ['<no>']), 'Colorful Windows' translated;
			target: self;
			selector: #toggleColorfulWindows].
	menu addItem:[:item|
		item
			contents: (SystemWindow gradientWindow not ifTrue: ['<yes>'] ifFalse: ['<no>']), 'Flat Widget Look' translated;
			target: self;
			selector: #toggleGradients].
	menu addLine.
	menu addItem:[:item |
		item
			contents: (((Preferences valueOfFlag: #menuAppearance3d ifAbsent: [false]) and: [Morph useSoftDropShadow]) ifTrue: ['<yes>'] ifFalse: ['<no>']), 'Soft Shadows' translated;
			target: self;
			selector: #toggleSoftShadows].
	menu addItem:[:item |
		item
			contents: (((Preferences valueOfFlag: #menuAppearance3d ifAbsent: [false]) and: [Morph useSoftDropShadow not]) ifTrue: ['<yes>'] ifFalse: ['<no>']), 'Hard Shadows' translated;
			target: self;
			selector: #toggleHardShadows].
	menu addLine.
	menu addItem:[:item |
		item
			contents: (SystemWindow roundedWindowCorners ifTrue: ['<yes>'] ifFalse: ['<no>']), 'Rounded Window/Dialog/Menu Look' translated;
			target: self;
			selector: #toggleRoundedWindowLook].
	menu addItem:[:item |
		item
			contents: (PluggableButtonMorph roundedButtonCorners ifTrue: ['<yes>'] ifFalse: ['<no>']), 'Rounded Button/Scrollbar Look' translated;
			target: self;
			selector: #toggleRoundedButtonLook].
	menu addLine.
	themes := UserInterfaceTheme allThemes asArray sort: #name ascending.
	themes := themes select: [ :each | each isGenuine].
	themes ifEmpty: [ 
		menu addItem: [ :item | 
			item
				contents: '(No UI themes found.)' translated;
				isEnabled: false ] ].
	themes do: [ :each |
		menu addItem: [ :item |
			item 
				contents: (UserInterfaceTheme current name = each name ifTrue: ['<yes>'] ifFalse: ['<no>']), each name;
				target: each;
				selector: #applyScaled ] ].
	menu	
		addLine;
		add: 'Set Etoys Mode' translated target: ReleaseBuilderSqueakland selector: #setEtoysMode.
	menu
		addLine;
		add: 'Restore UI Theme Background' translated target: self selector: #restoreThemeBackground;
		add: 'Edit Current UI Theme...' translated target: self selector: #editCurrentTheme.! !


!UserInterfaceTheme methodsFor: 'actions' stamp: 'mt 12/23/2021 14:17'!
applyAfter: aBlock

	lastScaleFactor := RealEstateAgent scaleFactor.
	self class current: self. "Font callbacks from Preferences to here."
	self ignoreApplyDuring: aBlock.
	self apply.! !

!UserInterfaceTheme methodsFor: 'actions' stamp: 'mt 12/21/2021 15:29'!
ignoreApplyDuring: aBlock

	ignoreApply := true.
	^ aBlock ensure: [ignoreApply := false]! !

!UserInterfaceTheme methodsFor: 'private - display scale' stamp: 'mt 12/23/2021 14:19'!
applyScaled
	"Apply the receiver but keep the current #uiScaleFactor."
	
	self applyScaled: Display uiScaleFactor.! !

!UserInterfaceTheme methodsFor: 'private - display scale' stamp: 'mt 12/21/2021 11:31'!
applyScaled: aFloat
	"Apply the receiver with the given scale factor aFloat."
	
	self setScaleFactor: aFloat.! !

!UserInterfaceTheme methodsFor: 'private - display scale' stamp: 'mt 12/21/2021 13:49'!
canFakeScaleFactor: aFloat
	"Answer whether we can fake the given scale factor with pre-rendered fonts."

	self isTTCBased ifFalse: [^ true "Need to #makeTTCBased anyway."].
	(self lookupScaleFactor: 1.0) ifNil: [^ false "Without a fake 100%, we go all-in with TrueType fonts."].

	aFloat = 1.0 ifTrue: [^ true].
	aFloat = 1.25 ifTrue: [^ true].
	aFloat = 1.5 ifTrue: [^ true].
	
	^ false! !

!UserInterfaceTheme methodsFor: 'private - display scale' stamp: 'mt 12/21/2021 14:11'!
checkScaleFactor100
	"The receiver must not be the reference theme for 100% using pre-rendered fonts."
	
	self
		assert: [self isTTCBased or: [self localScaleFactor ~= 1.0]]
		description: 'You must not modify the reference theme!!'.! !

!UserInterfaceTheme methodsFor: 'private - display scale' stamp: 'mt 12/21/2021 14:11'!
checkTheme100

	| theme100 |
	self flag: #isTTCBased.
	theme100 := self lookupScaleFactor: 1.0.
	self
		assert: [theme100 notNil]
		description: 'Reference theme not found!! Please reset all themes.'.
	^ theme100! !

!UserInterfaceTheme methodsFor: 'private - display scale' stamp: 'mt 12/21/2021 16:31'!
copyWithScaleFactor: aFloat
	"Duplicate the receiver and reconfigure the copy to have its #scaleFactor match factorInPercent. This method is used for preserving the reference theme, which has a 100% scale factor."

	| copy |
	self
		assert: [self isTTCBased not]
		description: 'There is no need to duplicate themes that are already based on TrueType fonts!!'.
	
	copy := UserInterfaceTheme named: 'Demo'.
	copy merge: self overwrite: true.
	
	copy name: self name.
	copy set: #standardSystemFont to: nil. "We are not theme100 for the moment."
	self assert: [copy localScaleFactor isNil].

	copy setScaleFactorPreApply: aFloat.
	
	^ copy! !

!UserInterfaceTheme methodsFor: 'private - display scale' stamp: 'mt 12/21/2021 16:51'!
doScale100
	"Private. Use #applyScaled:. The reference theme, which has a 100% scale factor, must already be there. Look it up and apply it."
	
	self checkTheme100 apply.
	TextStyle pixelsPerInch: 96.0. "Restore Squeak's default PPI for 100%."! !

!UserInterfaceTheme methodsFor: 'private - display scale' stamp: 'mt 12/22/2021 09:23'!
doScale125
	"Private. Use #applyScaled:. This is actually about 135% because of which font sizes we have available."
	
	self flag: #hack. "mt: A different scale factor should not result in different point sizes being selected BUT the same point size resulting in a different pixel height."
	
	self setFonts: #(
		standardSystemFont 14.5
		standardFixedFont 14.5
	
		standardCodeFont 14.5
		standardListFont 14.5
		standardButtonFont 10.5
		standardMenuFont 14.5
		standardFlapFont 10.5
			
		windowTitleFont 14.5
		balloonHelpFont 10.5
		haloLabelFont 14.5) forceTTC: false.

	self apply.
	TextStyle pixelsPerInch: 96.0. "Restore Squeak's default PPI for 100%."! !

!UserInterfaceTheme methodsFor: 'private - display scale' stamp: 'mt 12/22/2021 09:23'!
doScale150
	"Private. Use #applyScaled:. Traditional 'Demo Mode'. Optimized for existing pre-rendered fonts. Does not fall back on TTC font. See #doScale:. This is actually about 157% because of which font sizes we have available."
	
	self flag: #hack. "mt: A different scale factor should not result in different point sizes being selected BUT the same point size resulting in a different pixel height."
	
	self setFonts: #(
		standardSystemFont 16.5
		standardFixedFont 16.5
	
		standardCodeFont 16.5
		standardListFont 16.5
		standardButtonFont 14.5
		standardMenuFont 16.5
		standardFlapFont 14.5
			
		windowTitleFont 16.5
		balloonHelpFont 14.5
		haloLabelFont 16.5) forceTTC: false.

	self apply.
	TextStyle pixelsPerInch: 96.0. "Restore Squeak's default PPI for 100%."! !

!UserInterfaceTheme methodsFor: 'private - display scale' stamp: 'mt 12/22/2021 09:34'!
isGenuine

	self isTTCBased ifTrue: [
		"The receiver is only genuine if there is no other theme with the same same, probably one with pre-rendered fonts."
		^ (self class allThemes anySatisfy: [:theme |
			theme ~~ self and: [theme name = self name]]) not].

	^ self localScaleFactor = 1.0! !

!UserInterfaceTheme methodsFor: 'private - display scale' stamp: 'mt 12/21/2021 14:04'!
isTTCBased
	"Answer whether the receiver uses only TrueType fonts, which can flexibly adapt to changing scale factors."

	^ (self get: #standardSystemFont) ifNil: [false] ifNotNil: [:font | font isTTCFont]
	
	"properties keysDo: [:key |
		(key isSymbol and: [key endsWith: #Font])
			ifTrue: [(self get: key) isTTCFont ifFalse: [^ false]]].
	^ true"! !

!UserInterfaceTheme methodsFor: 'private - display scale' stamp: 'mt 12/21/2021 14:42'!
localScaleFactor
	"Answers the scale factor that the receiver supports, which is arbitrary for themes that only use TTCFonts."

	self
		assert: [self isTTCBased not]
		description: 'The local scale factor is undefined for TrueType-based themes!!'.

	^ (self get: #standardSystemFont)
		ifNil: ["Not yet initialized."]
		ifNotNil: [:font | (font height / StrikeFont referenceHeight) roundTo: 0.25]! !

!UserInterfaceTheme methodsFor: 'private - display scale' stamp: 'mt 12/21/2021 17:05'!
lookupScaleFactor: aFloat
	"Answer a theme that fakes the given scale factor with pre-rendered fonts."

	^ self class allThemes
		detect: [:ea | ea name = self name and: [ea isTTCBased not and: [ea localScaleFactor = aFloat]]]
		ifNone: ["Not found."]! !

!UserInterfaceTheme methodsFor: 'private - display scale' stamp: 'mt 12/21/2021 16:26'!
lookupSimilar
	"Answer a theme that is similar to the receiver but not the reference theme for pre-rendered fonts."

	^ self class allThemes
		detect: [:ea | ea name = self name and: [ea isTTCBased or: [ea localScaleFactor ~= 1.0]]]
		ifNone: ["Not found."]! !

!UserInterfaceTheme methodsFor: 'private - display scale' stamp: 'mt 12/22/2021 09:24'!
makeTTCBased
	"100%"
	
	self isTTCBased ifTrue: [^ self].
	
	self setFonts: #(
		standardSystemFont 10.5
		standardFixedFont 10.5
	
		standardCodeFont 10.5
		standardListFont 10.5
		standardButtonFont 7.5
		standardMenuFont 10.5
		standardFlapFont 7.5
			
		windowTitleFont 10.5
		balloonHelpFont 7.5
		haloLabelFont 10.5) forceTTC: true.
		
	self assert: [self isTTCBased].! !

!UserInterfaceTheme methodsFor: 'private - display scale' stamp: 'mt 12/22/2021 09:22'!
setFonts: specs forceTTC: forceTTC
	"Change fonts. Do not apply the receiver."
		
	| theme100 |
	self checkScaleFactor100.
	theme100 := self checkTheme100.
	
	specs groupsDo: [:symbolicFontName :newPointSize | | font100 fontScaled |
		font100 := theme100 get: symbolicFontName.
		fontScaled := font100 isTTCFont
			ifTrue: [TTCFont familyName: font100 familyName pointSize: newPointSize emphasis: font100 emphasis]
			ifFalse: [
				forceTTC
					ifTrue: [TTCFont familyName: self ttcFallbackName pointSize: newPointSize emphasis: font100 emphasis]
					ifFalse: [StrikeFont familyName: font100 familyName pointSize: newPointSize emphasized: font100 emphasis]].
		self
			assert: [fontScaled pointSize = newPointSize]
			description: 'No pre-rendered font with the correct point size available'.
		self set: symbolicFontName to: fontScaled].! !

!UserInterfaceTheme methodsFor: 'private - display scale' stamp: 'mt 12/22/2021 09:41'!
setScaleFactor: aFloat
	"Private. Use #applyScaled:. In the receiver, change the fonts to have a scale of aFloat. Change all fonts to be TrueType fonts if no pre-rendered fonts exist. Never change the 100% reference theme but make a copy. Apply the receiver to the system."

	(self isTTCBased not and: [aFloat = self localScaleFactor])
		ifTrue: [self isCurrent ifFalse: [self apply]. ^ self].

	(self lookupScaleFactor: aFloat)
		ifNotNil: [:theme | ^ theme apply "Already there with pre-rendered fonts. Use class-side #cleanUp: to reset broken themes."].
	
	(self isTTCBased not and: [self localScaleFactor = 1.0]) "!!!! Never change the reference theme !!!!"
		ifTrue: [^ self lookupSimilar ifNil: [self copyWithScaleFactor: aFloat] ifNotNil: [:other | other setScaleFactorPreApply: aFloat]].
	
	aFloat = 1.0 ifTrue: [^ self doScale100].
	aFloat = 1.25 ifTrue: [^ self doScale125].
	aFloat = 1.5 ifTrue: [^ self doScale150].

	"And now transition from the pre-rendered world into the TrueType world. Or re-use an existing TrueType-based theme with new values. See #lookupSimilar above."
	TextStyle pixelsPerInch: 96.0 * RealEstateAgent scaleFactor "current, based on pixels".
	self makeTTCBased.
	self applyAfter: [TextStyle pixelsPerInch: 96.0 * aFloat "new, not rounded"].! !

!UserInterfaceTheme methodsFor: 'private - display scale' stamp: 'mt 12/21/2021 16:33'!
setScaleFactorPreApply: aFloat

	| last |
	last := Current.
	[Current := self.  "Manage side-effects in #setDefaultFonts: ..."
	self setScaleFactor: aFloat]
		on: Error do: [:ex | Current := last. ex pass].! !

!UserInterfaceTheme methodsFor: 'private - display scale' stamp: 'mt 12/20/2021 10:23'!
ttcFallbackName
	"Answer the name of the TTCFont that should be used as a fallback for pre-rendered StrikeFonts that do not have the requested #pointSize available. See #ttcCorrection."
	
	^ 'BitstreamVeraSans'! !

!UserInterfaceTheme methodsFor: 'testing' stamp: 'mt 12/19/2021 10:03'!
isCurrent
	"Note that changes to the receiver's properties without calling #apply can result in visual differences even though the answer might be 'true'."
	
	^ self class current == self! !

!UserInterfaceTheme methodsFor: 'private - fonts' stamp: 'mt 12/22/2021 08:22'!
fixFontsAndScaleAround: applyThemeBlock
	"Given that the receiver is the current UI theme, set the system's default fonts, which define RealEstateAgent's #scaleFactor. If the factor changes, resize open windows to make them fit the scaled contents. Note that themes can have arbitrary point sizes for their system font, even though it is not recommended. See TTCFont class >> #referencePointSize."

	lastScaleFactor ifNil: [lastScaleFactor := RealEstateAgent scaleFactor].

	"Due to the current font situation, update TextConstants."
	(self get: #standardSystemFont) ifNotNil: [:font | self installSystemFont: font].
	(self get: #standardFixedFont) ifNotNil: [:font | self installFixedFont: font].	

	"Propagate the receiver's properties across the system."
	applyThemeBlock value.

	"Due to the current real-estate manager situation, resize all windows. Works only for Morphic projects."
	self scaleMorphicToolsBy: RealEstateAgent scaleFactor / lastScaleFactor.
		
	lastScaleFactor := nil.! !

!UserInterfaceTheme methodsFor: 'private - fonts' stamp: 'mt 12/22/2021 08:12'!
installFixedFont: aFont
	"Establish the default fixed text font and style"

	| aStyle |
	self flag: #todo. "mt: Support derivatives such as bold and italic."
	aStyle := aFont textStyle.
	aStyle defaultFontIndex: (aStyle fontIndexOf: aFont).
	TextStyle setDefaultFixed: aStyle.! !

!UserInterfaceTheme methodsFor: 'private - fonts' stamp: 'mt 12/22/2021 08:17'!
installSystemFont: aFont
	"Establish the default text font and style"

	| aStyle |
	self flag: #todo. "mt: Support derivatives such as bold and italic."
	aStyle := aFont textStyle.
	aStyle defaultFontIndex: (aStyle fontIndexOf: aFont).

	TextStyle setDefault: aStyle.
	RealEstateAgent resetScaleFactor.
	
	Flaps replaceToolsFlap.
	ScriptingSystem resetStandardPartsBin.! !

!UserInterfaceTheme methodsFor: 'private - fonts' stamp: 'mt 12/22/2021 08:22'!
scaleMorphicToolsBy: factor

	Project current isMorphic ifFalse: [^ self].
	(factor closeTo: 1) ifTrue: [^ self].
	
	Project current world submorphs
		select: [:morph | morph isSystemWindow]
		thenDo: [:window |
			window extent: window extent * factor.
			window layoutChanged.
			window setFramesForLabelArea].! !

!UserInterfaceTheme methodsFor: 'private - fonts' stamp: 'mt 12/22/2021 08:13'!
setFixedFontTo: aFont
	"Establish the default fixed text font and style"

	self set: #standardFixedFont to: aFont.
	self isCurrent ifTrue: [self apply].! !

!UserInterfaceTheme methodsFor: 'private - fonts' stamp: 'mt 12/23/2021 07:38'!
setSystemFontTo: aFont
	"Establish the default text font and style"

	(Display uiScaleFactor = 1.0 and: [aFont isTTCFont not and: [aFont height ~= StrikeFont referenceHeight]])
		ifTrue: [^ self error: ('Incompatible pre-rendered font for 100% scale factor. Height must be {1} px' format: {StrikeFont referenceHeight})].

	(Display uiScaleFactor = 1.0 and: [aFont isTTCFont and: [aFont pointSize ~= TTCFont referencePointSize]])
		ifTrue: [self notify: ('The standard system/text font should be {1} pt. If you want to increase the overall font size, please change the screen scale factor instead. You may proceed without harm.' format: {TTCFont referencePointSize})].

	self set: #standardSystemFont to: aFont.
	self isCurrent ifTrue: [self apply].! !

!UserInterfaceTheme methodsFor: 'printing' stamp: 'mt 12/21/2021 13:48'!
printOn: aStream

	super printOn: aStream.

	aStream space; print: name.
	self isTTCBased ifFalse: [
		aStream space; nextPutAll: ('({1}%)' format: {self localScaleFactor * 100})].! !


!UserInterfaceTheme class methodsFor: 'initialize-release' stamp: 'mt 12/23/2021 14:19'!
cleanUpAndReset
	"Rebuild all themes and re-apply the current one by name."
	
	| nameToReset scaleFactorToReset |
	nameToReset := self current name.
	scaleFactorToReset := Display uiScaleFactor.
	self cleanUp: true.
	(self named: nameToReset) applyScaled: scaleFactorToReset.! !


!CommunityTheme class methodsFor: 'instance creation' stamp: 'mt 12/20/2021 17:13'!
addDarkFonts: aUserInterfaceTheme
	"Set-up fonts."
	aUserInterfaceTheme
		set: #balloonHelpFont to: [StrikeFont familyName: 'Darkmap DejaVu Sans' pointSize: 7.5 emphasized: TextEmphasis italic emphasisCode];
		set: #standardButtonFont to: [StrikeFont familyName: 'Darkmap DejaVu Sans' pointSize: 7.5];
		set: #standardCodeFont to: [StrikeFont familyName: 'Bitmap DejaVu Sans' pointSize: 10.5];
		set: #standardFlapFont to: [StrikeFont familyName: 'Bitmap DejaVu Sans' pointSize: 7.5 emphasized: TextEmphasis bold emphasisCode];
		set: #haloLabelFont to: [StrikeFont familyName: 'Darkmap DejaVu Sans' pointSize: 10.5];
		set: #standardListFont to: [StrikeFont familyName: 'Bitmap DejaVu Sans' pointSize: 10.5];
		set: #standardMenuFont to: [StrikeFont familyName: 'Bitmap DejaVu Sans' pointSize: 10.5];
		set: #standardSystemFont to: [StrikeFont familyName: 'Bitmap DejaVu Sans' pointSize: 10.5];
		set: #windowTitleFont to: [StrikeFont familyName: 'Bitmap DejaVu Sans' pointSize: 10.5 emphasized: TextEmphasis bold emphasisCode]! !


!MonokaiTheme class methodsFor: 'instance creation' stamp: 'mt 12/20/2021 17:12'!
addDarkFonts: theme

	"Set-up fonts."
	theme
		set: #balloonHelpFont to: [StrikeFont familyName: 'Darkmap DejaVu Sans' pointSize: 7.5];
		set: #standardButtonFont to: [StrikeFont familyName: 'Darkmap DejaVu Sans' pointSize: 7.5];
		set: #standardCodeFont to: [StrikeFont familyName: 'Darkmap DejaVu Sans' pointSize: 10.5];
		set: #standardFlapFont to: [StrikeFont familyName: 'Darkmap DejaVu Sans' pointSize: 7.5 emphasized: TextEmphasis bold emphasisCode];
		set: #haloLabelFont to: [StrikeFont familyName: 'Darkmap DejaVu Sans' pointSize: 10.5];
		set: #standardListFont to: [StrikeFont familyName: 'Darkmap DejaVu Sans' pointSize: 10.5];
		set: #standardMenuFont to: [StrikeFont familyName: 'Darkmap DejaVu Sans' pointSize: 10.5];
		set: #standardSystemFont to: [StrikeFont familyName: 'Darkmap DejaVu Sans' pointSize: 10.5];
		set: #windowTitleFont to: [StrikeFont familyName: 'Darkmap DejaVu Sans' pointSize: 10.5].! !


!SolarizedTheme class methodsFor: 'instance creation' stamp: 'mt 12/20/2021 17:12'!
addDarkFonts: theme

	"Set-up fonts."
	theme
		set: #balloonHelpFont to: [StrikeFont familyName: 'Darkmap DejaVu Sans' pointSize: 7.5];
		set: #standardButtonFont to: [StrikeFont familyName: 'Darkmap DejaVu Sans' pointSize: 7.5];
		set: #standardCodeFont to: [StrikeFont familyName: 'Darkmap DejaVu Sans' pointSize: 10.5];
		set: #standardFlapFont to: [StrikeFont familyName: 'Darkmap DejaVu Sans' pointSize: 7.5 emphasized: TextEmphasis bold emphasisCode];
		set: #haloLabelFont to: [StrikeFont familyName: 'Darkmap DejaVu Sans' pointSize: 10.5];
		set: #standardListFont to: [StrikeFont familyName: 'Darkmap DejaVu Sans' pointSize: 10.5];
		set: #standardMenuFont to: [StrikeFont familyName: 'Darkmap DejaVu Sans' pointSize: 10.5];
		set: #standardSystemFont to: [StrikeFont familyName: 'Darkmap DejaVu Sans' pointSize: 10.5];
		set: #windowTitleFont to: [StrikeFont familyName: 'Darkmap DejaVu Sans' pointSize: 10.5].! !

!SolarizedTheme class methodsFor: 'instance creation' stamp: 'mt 12/20/2021 17:12'!
addLightFonts: theme

	"Set-up fonts."
	theme
		set: #balloonHelpFont to: [StrikeFont familyName: 'Bitmap DejaVu Sans' pointSize: 7.5];
		set: #standardButtonFont to: [StrikeFont familyName: 'Bitmap DejaVu Sans' pointSize: 7.5];
		set: #standardCodeFont to: [StrikeFont familyName: 'Bitmap DejaVu Sans' pointSize: 10.5];
		set: #standardFlapFont to: [StrikeFont familyName: 'Bitmap DejaVu Sans' pointSize: 7.5 emphasized: TextEmphasis bold emphasisCode];
		set: #haloLabelFont to: [StrikeFont familyName: 'Bitmap DejaVu Sans' pointSize: 10.5];
		set: #standardListFont to: [StrikeFont familyName: 'Bitmap DejaVu Sans' pointSize: 10.5];
		set: #standardMenuFont to: [StrikeFont familyName: 'Bitmap DejaVu Sans' pointSize: 10.5];
		set: #standardSystemFont to: [StrikeFont familyName: 'Bitmap DejaVu Sans' pointSize: 10.5];
		set: #windowTitleFont to: [StrikeFont familyName: 'Bitmap DejaVu Sans' pointSize: 10.5 emphasized: TextEmphasis bold emphasisCode].! !


!SqueakTheme class methodsFor: 'instance creation' stamp: 'mt 12/21/2021 13:33'!
addFonts: theme

	theme
		set: #standardSystemFont to: [StrikeFont familyName: 'Bitmap DejaVu Sans' pointSize: 10.5];
		set: #standardFixedFont to: [TTCFont familyName: 'BitstreamVeraSansMono' pointSize: 10.5];

		set: #standardCodeFont to: [StrikeFont familyName: 'Bitmap DejaVu Sans' pointSize: 10.5];
		set: #standardListFont to: [StrikeFont familyName: 'Bitmap DejaVu Sans' pointSize: 10.5];
		set: #standardButtonFont to: [StrikeFont familyName: 'Bitmap DejaVu Sans' pointSize: 7.5];
		set: #standardMenuFont to: [StrikeFont familyName: 'Bitmap DejaVu Sans' pointSize: 10.5];
		set: #standardFlapFont to: [StrikeFont familyName: 'Bitmap DejaVu Sans' pointSize: 7.5 emphasized: TextEmphasis bold emphasisCode];

		set: #windowTitleFont to: [StrikeFont familyName: 'Bitmap DejaVu Sans' pointSize: 10.5 emphasized: TextEmphasis bold emphasisCode];
		set: #balloonHelpFont to: [StrikeFont familyName: 'Bitmap DejaVu Sans' pointSize: 7.5];
		set: #haloLabelFont to: [StrikeFont familyName: 'Bitmap DejaVu Sans' pointSize: 10.5].! !


!TrimTheme class methodsFor: 'instance creation' stamp: 'mt 12/20/2021 17:12'!
addFonts: theme

	"Set-up fonts."
	theme
		set: #balloonHelpFont to: [StrikeFont familyName: 'Darkmap DejaVu Sans' pointSize: 7.5];
		set: #standardButtonFont to: [StrikeFont familyName: 'Darkmap DejaVu Sans' pointSize: 7.5];
		set: #standardCodeFont to: [StrikeFont familyName: 'Darkmap DejaVu Sans' pointSize: 10.5];
		set: #standardFlapFont to: [StrikeFont familyName: 'Darkmap DejaVu Sans' pointSize: 7.5 emphasized: TextEmphasis bold emphasisCode];
		set: #haloLabelFont to: [StrikeFont familyName: 'Darkmap DejaVu Sans' pointSize: 10.5];
		set: #standardListFont to: [StrikeFont familyName: 'Darkmap DejaVu Sans' pointSize: 10.5];
		set: #standardMenuFont to: [StrikeFont familyName: 'Darkmap DejaVu Sans' pointSize: 10.5];
		set: #standardSystemFont to: [StrikeFont familyName: 'Darkmap DejaVu Sans' pointSize: 10.5];
		set: #windowTitleFont to: [StrikeFont familyName: 'Darkmap DejaVu Sans' pointSize: 10.5].! !


!WorldState methodsFor: 'update cycle' stamp: 'mt 12/23/2021 11:18'!
doOneCycleNowFor: aWorld
	"Immediately do one cycle of the interaction loop.
	This should not be called directly, but only via doOneCycleFor:"

	| capturingGesture |
	DisplayScreen checkForNewScreenScaleFactor; checkForNewScreenSize.
	capturingGesture := false.
	"self flag: #bob.	"	"need to consider remote hands in lower worlds"
	
	"process user input events"
	LastCycleTime := Time millisecondClockValue.
	self handsDo: [:hand |
		hand becomeActiveDuring: [
			hand processEvents.
			capturingGesture := capturingGesture or: [hand isCapturingGesturePoints]]].
	
	"The gesture recognizer needs enough points to be accurate.
	Therefore morph stepping is disabled while capturing points for the recognizer"
	capturingGesture ifFalse: [
		aWorld runStepMethods.		"there are currently some variations here"
		self displayWorldSafely: aWorld].! !


!UserInterfaceTheme class reorganize!
('tools' allThemeProperties allThemePropertiesDo: categories propertiesForCategory: propertiesForClass:)
('accessing' allThemes current current: default default:)
('private' clientClasses clientClassesToReapply)
('initialize-release' cleanUp: cleanUpAndReset initialize named: reset)
!

UserInterfaceTheme removeSelector: #setFixedFontSilentlyTo:!
UserInterfaceTheme removeSelector: #setFonts:!
UserInterfaceTheme removeSelector: #setSystemFontSilentlyTo:!

!UserInterfaceTheme reorganize!
('actions' apply applyAfter: applyTo: ignoreApplyDuring:)
('private - display scale' applyScaled applyScaled: canFakeScaleFactor: checkScaleFactor100 checkTheme100 copyWithScaleFactor: doScale100 doScale125 doScale150 isGenuine isTTCBased localScaleFactor lookupScaleFactor: lookupSimilar makeTTCBased setFonts:forceTTC: setScaleFactor: setScaleFactorPreApply: ttcFallbackName)
('testing' isCurrent)
('private - fonts' fixFontsAndScaleAround: installFixedFont: installSystemFont: scaleMorphicToolsBy: setFixedFontTo: setSystemFontTo:)
('private' atomicUpdate: get: get:for: get:for:do: getViaLink: getViaSuperclasses: preMerge: properties validateCanMerge:)
('building' clear: clear:for: derive:for:from: derive:for:from:at: derive:for:from:at:do: derive:for:from:do: link: merge: merge:overwrite: set:for:to: set:to:)
('initialization' initialize register unregister)
('accessing' name name: next unsetProperties)
('copying' postCopy)
('printing' printOn:)
!


!TextStyle class reorganize!
('class initialization' initialize initializeStyleDecoder styleDecoder)
('constants' default defaultFixed defaultFixedFont defaultFont named: setDefault: setDefaultFixed:)
('instance creation' changeDefaultFontSizeBy: fontArray: initDefaultFontsAndStyle new)
('mime file in/out' collectionFromCompressedMIMEString: looseFontsFromFamily: replaceFontsIn:with: replaceStyle:with:)
('TextConstants access' actualTextStyles defaultFamilyNames fontArrayForStyle: fontPointSizesFor: fontSizesFor: fontWidthsFor: knownTextStyles knownTextStylesWithoutDefault pointSizesFor:)
('user interface' importFontsFromStyleFiles)
('utilities' decodeStyleName: fontSizeSummary fontSizeSummaryContents pixelsPerInch pixelsPerInch: pixelsToPoints: pointsToPixels:)
('*System-Fonts' chooseTTCFontSize:)
('*Morphic-user interface' emphasisMenuForFont:target:selector:highlight: fontMenuForStyle:target:selector: fontMenuForStyle:target:selector:highlight: promptForFont:andSendTo:withSelector: promptForFont:andSendTo:withSelector:highlight:)
('*System-Changes-mime file in/out' writeSF2FamilyNamed:inDirectory:toChangeSet: writeStyle:named:toChangeSet:)
('*Etoys-Squeakland-instance creation' addNewStyle:)
!


!TTCFont class reorganize!
('class initialization' initialize shutDown unload)
('file list services' fileReaderServicesForFile:suffix: serviceInstallTrueTypeFontStyle services)
('instance creation' familyName:pointSize: familyName:pointSize:emphasis: family:size: familyName:pointSize:emphasized: getExistings: newTextStyleFromTT: newTextStyleFromTTFile: newTextStyleFromTTStream:)
('objects from disk' classVersion)
('*System-constants' referencePointSize)
('other' indexOfSubfamilyName: isCacheAllNil pointSizes recreateCache registerAll register:at: registry removeAllDerivatives removeStyleName: reorganizeForNewFontArray:name: repairDerivativeFonts unregister: version)
!

RealEstateAgent class removeSelector: #applyUserInterfaceTheme!
RealEstateAgent class removeSelector: #themeProperties!
RealEstateAgent removeSelector: #applyUserInterfaceTheme!
RealEstateAgent removeSelector: #canApplyUserInterfaceTheme!

!RealEstateAgent reorganize!
('as yet unclassified')
!

Preferences class removeSelector: #changeFontSize:!
Preferences class removeSelector: #displaySizeChanged!
Preferences class removeSelector: #setDefaultFonts:!
DisplayScreen removeSelector: #effectiveScaleFactor!
DisplayScreen removeSelector: #effectiveScaleFactor:!
DisplayScreen removeSelector: #effectiveUiScaleFactor:!
DisplayScreen removeSelector: #relativeScaleFactor!
DisplayScreen removeSelector: #scaleFactor!
DisplayScreen removeSelector: #scaleFactor:!
Form subclass: #DisplayScreen
	instanceVariableNames: 'clippingBox extraRegions'
	classVariableNames: 'DeferringUpdates DisplayChangeSignature DisplayIsFullScreen PlatformScaleFactor RelativeScaleFactorEnabled'
	poolDictionaries: ''
	category: 'Graphics-Display Objects'!
UserInterfaceTheme allThemes do: [:each | 
	"Convert 'Demo + Squeak' to 'Squeak'. Not needed anymore because of #scaleFactor in each theme."
	each name: (each name findTokens: '+') last withBlanksTrimmed].

TheWorldMainDockingBar updateInstances.

"Unpack unnecessary StrikeFontSet in Accuny."
(TextStyle named: 'Accuny') ifNotNil: [:style |
	style fontArray withIndexDo: [:fontSet :index |
		((fontSet isKindOf: StrikeFontSet) and: [fontSet fontArray size = 1])
			ifTrue: [style fontArray at: index put: fontSet fontArray first]]].
	
"Fix font names for Atlanta."
(TextStyle named: 'Atlanta') fontArray do: [:font |
	font name last isDigit ifFalse: [font name: font name, font pointSize]].

"Fix PPI to be around 96 in all pre-rendered fonts."
(TextStyle knownTextStylesWithoutDefault
	collect: [:ea | TextStyle named: ea]
	thenSelect: [:style | style defaultFont isTTCFont not])
		do: [:style | style fontArray do: [:font |
			font pointSize: ((72 * font height / 96) roundTo: 0.5).
			font derivativeFonts do: [:derivate |
				derivate pointSize: font pointSize]]].

"Fixes a bug where some emphasis got lost in high-DPI mode."	
UserInterfaceTheme cleanUpAndReset.!

