[squeak-dev] The Trunk: Morphic-mt.1884.mcz
commits at source.squeak.org
commits at source.squeak.org
Thu Feb 10 11:02:07 UTC 2022
Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1884.mcz
==================== Summary ====================
Name: Morphic-mt.1884
Author: mt
Time: 10 February 2022, 12:02:02.024307 pm
UUID: e0a3c9f7-9aa4-8049-9578-7df344af4182
Ancestors: Morphic-mt.1883
Complements ToolBuilder-Kernel-mt.154.
Use it to do some visual tweaks in FontChooserTool and FontImporterTool.
=============== Diff against Morphic-mt.1883 ===============
Item was changed:
----- Method: FontChooserTool>>buildPointSizeInputWith: (in category 'toolbuilder') -----
buildPointSizeInputWith: builder
"Build the font choosers list of point sizes"
| listSpec |
listSpec := builder pluggableInputFieldSpec new.
listSpec
model: self;
plainTextOnly: true;
getText: #pointSizeInput;
+ setText: #pointSizeInput:;
+ softLineWrap: true.
- setText: #pointSizeInput:.
^listSpec
!
Item was changed:
----- Method: FontChooserTool>>buildPointSizeListWith: (in category 'toolbuilder') -----
buildPointSizeListWith: builder
"Build the font choosers list of point sizes"
| listSpec |
listSpec := builder pluggableListSpec new.
listSpec
model: self;
list: #pointSizeList;
getIndex: #selectedPointSizeIndex;
setIndex: #selectedPointSizeIndex:;
+ itemAlignment: #right;
+ padding: self pointSizePadding.
- itemAlignment: #right.
^listSpec
!
Item was changed:
----- Method: FontChooserTool>>buildPreviewPaneWith: (in category 'toolbuilder') -----
buildPreviewPaneWith: builder
"Build the preview panel"
| textSpec |
textSpec := builder pluggableTextSpec new.
textSpec
name: #preview;
model: self;
getText: #contents;
+ textStyle: #selectedFontTextStyle;
softLineWrap: false.
^textSpec!
Item was changed:
----- Method: FontChooserTool>>buildWith: (in category 'toolbuilder') -----
buildWith: builder
"Create the ui for the browser"
"ToolBuilder open: self"
+ | windowSpec hDiv |
+ hDiv := 0.55.
- | windowSpec |
self offerStyleList ifTrue:[
windowSpec := self buildWindowWith: builder specs: {
+ (0 at 0 corner: 0.5 at hDiv) -> [self buildFontListWith: builder].
+ (0.5 at 0 corner: 0.8 at hDiv) -> [self buildStyleListWith: builder].
+ (LayoutFrame fractions: (0.8 at 0 corner: 1.0 at hDiv) offsets: (0 at 0 corner: 0 @ self pointSizeInputHeight negated))
- (0 at 0 corner: 0.5 at 0.4) -> [self buildFontListWith: builder].
- (0.5 at 0 corner: 0.8 at 0.4) -> [self buildStyleListWith: builder].
- (LayoutFrame fractions: (0.8 at 0 corner: 1.0 at 0.4) offsets: (0 at 0 corner: 0 @ self pointSizeInputHeight negated))
-> [self buildPointSizeListWith: builder].
+ (LayoutFrame fractions: (0.8 at hDiv corner: 1.0 at hDiv) offsets: (0 at self pointSizeInputHeight negated corner: 0 at 0))
- (LayoutFrame fractions: (0.8 at 0.4 corner: 1.0 at 0.4) offsets: (0 at self pointSizeInputHeight negated corner: 0 at 0))
-> [self buildPointSizeInputWith: builder].
+ (LayoutFrame fractions: (0.0 at hDiv corner: 1.0 at 1.0) offsets: (0 at 0 corner: 0 @ self buttonHeight negated))
- (LayoutFrame fractions: (0.0 at 0.4 corner: 1.0 at 1.0) offsets: (0 at 0 corner: 0 @ self buttonHeight negated))
-> [self buildPreviewPaneWith: builder].
(LayoutFrame fractions: (0 at 1 corner: 1 at 1) offsets: (0@ self buttonHeight negated corner: 0 at 0))
-> [self buildButtonBarWith: builder].
}.
] ifFalse:[
windowSpec := self buildWindowWith: builder specs: {
+ (0 at 0 corner: 0.7 at hDiv) -> [self buildFontListWith: builder].
+ (LayoutFrame fractions: (0.7 at 0 corner: 1.0 at hDiv) offsets: (0 at 0 corner: 0 @ self pointSizeInputHeight negated))
- (0 at 0 corner: 0.7 at 0.4) -> [self buildFontListWith: builder].
- " (0.4 at 0 corner: 0.8 at 0.4) -> [self buildStyleListWith: builder]."
- (LayoutFrame fractions: (0.7 at 0 corner: 1.0 at 0.4) offsets: (0 at 0 corner: 0 @ self pointSizeInputHeight negated))
-> [self buildPointSizeListWith: builder].
+ (LayoutFrame fractions: (0.7 at hDiv corner: 1.0 at hDiv) offsets: (0 at self pointSizeInputHeight negated corner: 0 at 0))
- (LayoutFrame fractions: (0.7 at 0.4 corner: 1.0 at 0.4) offsets: (0 at self pointSizeInputHeight negated corner: 0 at 0))
-> [self buildPointSizeInputWith: builder].
+ (LayoutFrame fractions: (0.0 at hDiv corner: 1.0 at 1.0) offsets: (0 at 0 corner: 0 @ self buttonHeight negated))
- (LayoutFrame fractions: (0.0 at 0.4 corner: 1.0 at 1.0) offsets: (0 at 0 corner: 0 @ self buttonHeight negated))
-> [self buildPreviewPaneWith: builder].
(LayoutFrame fractions: (0 at 1 corner: 1 at 1) offsets: (0@ self buttonHeight negated corner: 0 at 0))
-> [self buildButtonBarWith: builder].
}.
].
windowSpec extent: self initialExtent.
window := builder build: windowSpec.
"Now that the window has been built, notify selection again to scroll it into view."
self changed: #selectedFontIndex.
self changed: #selectedFontStyleIndex.
self changed: #selectedPointSizeIndex.
self changed: #textStyle with: self selectedFontTextStyle.
^window!
Item was changed:
----- Method: FontChooserTool>>buttonHeight (in category 'toolbuilder') -----
buttonHeight
+
+ ^ ToolBuilder default buttonRowHeight!
- ^ Preferences standardButtonFont height * 3!
Item was changed:
----- Method: FontChooserTool>>contents (in category 'toolbuilder') -----
contents
+ "Note that we cannot just rely on #selectedTextStyle because there are, for example, symbol fonts out there, which require a different set of characters as a sample text."
+
-
^ self selectedFont
ifNil: [Text new]
+ ifNotNil: [:font |
+ font isSymbolFont
+ ifTrue: [font symbolSample]
+ ifFalse: [Text textSample]]!
- ifNotNil: [:font | font sampleText]!
Item was changed:
----- Method: FontChooserTool>>initialExtent (in category 'initialize') -----
initialExtent
+
+ ^ self offerStyleList
+ ifTrue:[450 at 250]
+ ifFalse:[400 at 250].!
- ^self offerStyleList ifTrue:[420 at 300] ifFalse:[320 at 200].!
Item was changed:
----- Method: FontChooserTool>>pointSize: (in category 'point size') -----
pointSize: aNumber
pointSize := aNumber.
+ self changed: #selectedFontTextStyle.
- self changed: #textStyle with: self selectedFontTextStyle.
self changed: #contents.
self changed: #pointSizeList.
self changed: #selectedPointSizeIndex.!
Item was changed:
----- Method: FontChooserTool>>pointSizeInput (in category 'point size') -----
pointSizeInput
+ ^ self pointSize asString asText
+ addAttribute: TextAlignment centered;
+ yourself!
- ^ self pointSize asString!
Item was changed:
----- Method: FontChooserTool>>pointSizeInputHeight (in category 'toolbuilder') -----
pointSizeInputHeight
+ ^ ToolBuilder default inputFieldHeight!
- ^ TextStyle defaultFont height * 1.5!
Item was changed:
----- Method: FontChooserTool>>pointSizeList (in category 'point size') -----
pointSizeList
+ ^self selectedTextStyle pointSizes collect: [:each | each printShowingDecimalPlaces: 1]!
- ^self selectedTextStyle pointSizes collect: [:each | (each printShowingDecimalPlaces: 1), ' ' ]!
Item was added:
+ ----- Method: FontChooserTool>>pointSizePadding (in category 'toolbuilder') -----
+ pointSizePadding
+
+ ^ 0 at 0 corner: (10 * RealEstateAgent scaleFactor) truncated @0!
Item was changed:
----- Method: FontChooserTool>>selectedFontIndex: (in category 'font list') -----
selectedFontIndex: anIndex
anIndex = 0 ifTrue: [^self].
selectedFontIndex := anIndex.
self changed: #selectedFontIndex.
self changed: #selectedFontStyleIndex.
+ self changed: #selectedFontTextStyle.
- self changed: #textStyle with: self selectedFontTextStyle.
self changed: #contents.
self changed: #pointSizeList.
self changed: #selectedPointSizeIndex.
!
Item was changed:
----- Method: FontChooserTool>>selectedFontStyleIndex: (in category 'style list') -----
selectedFontStyleIndex: anIndex
anIndex = 0 ifTrue: [^self].
emphasis := anIndex - 1.
self changed: #selectedFontStyleIndex.
+ self changed: #selectedFontTextStyle.
- self changed: #textStyle with: self selectedFontTextStyle.
self changed: #contents.!
Item was changed:
----- Method: FontImporterTool>>buildButtonBarWith: (in category 'toolbuilder') -----
buildButtonBarWith: builder
"Build the button bar"
+ | panelSpec |
- | panelSpec buttonSpec |
panelSpec := builder pluggablePanelSpec new.
panelSpec
layout: #horizontal;
children: OrderedCollection new.
+ {
+ 'Browse' translated.
+ 'Read the font data and browse the glyphs. Do not install the font into the image.' translated.
+ #browseImported.
+ 'Install' translated.
+ 'Include the font data in the image and provide a TextStyle for the font' translated.
+ #import.
+ 'Close' translated.
+ nil.
+ #close.
+ } groupsDo: [:label :help :action |
+ | buttonSpec |
+ buttonSpec := builder pluggableButtonSpec new
- buttonSpec := builder pluggableButtonSpec new
model: self;
+ label: label;
+ help: help;
+ action: action;
- label: 'Import' translated;
- help: 'Include the font data in the image and provide a TextStyle for the font' translated;
- action: #import;
yourself.
+ panelSpec children addLast: buttonSpec].
- panelSpec children addLast: buttonSpec.
-
- buttonSpec := builder pluggableButtonSpec new
- model: self;
- label: 'Close' translated;
- action: #close;
- yourself.
- panelSpec children addLast: buttonSpec.
-
-
^panelSpec!
Item was changed:
----- Method: FontImporterTool>>buildPreviewPaneWith: (in category 'toolbuilder') -----
buildPreviewPaneWith: builder
"Build the preview panel"
^ builder pluggablePanelSpec new
+ " wantsResizeHandles: true;"
- wantsResizeHandles: true;
children: {
+ builder pluggableTextSpec new
- builder pluggableInputFieldSpec new
model: self;
getText: #filename;
readOnly: true;
indicateUnacceptedChanges: false;
font: self filenameFont;
frame: (LayoutFrame
fractions: (0 at 0 corner: 1 at 0)
offsets: (0 at 0 corner: 0@ self filenameHeight));
yourself.
builder pluggableTextSpec new
model: self;
getText: #previewText;
+ textStyle: #selectedFontTextStyle;
askBeforeDiscardingEdits: false;
indicateUnacceptedChanges: false;
softLineWrap: false;
frame: (LayoutFrame
+ fractions: (0 at 0 corner: 1 at 1)
+ offsets: (0@ self filenameHeight corner: 0@ (self copyrightHeight negated)));
- fractions: (0 at 0 corner: 1 at 0.75)
- offsets: (0@ self filenameHeight corner: 0 at 0));
yourself.
builder pluggableTextSpec new
model: self;
getText: #copyright;
+ font: Preferences standardButtonFont;
readOnly: true;
indicateUnacceptedChanges: false;
frame: (LayoutFrame
+ fractions: (0 at 1 corner: 1 at 1)
+ offsets: (0 @ (self copyrightHeight negated) corner: 0 @ 0));
- fractions: (0 at 0.75 corner: 1 at 1));
yourself
};
yourself!
Item was changed:
----- Method: FontImporterTool>>buttonHeight (in category 'layout') -----
buttonHeight
+
+ ^ ToolBuilder default buttonRowHeight!
- ^ Preferences standardButtonFont height * 3!
Item was added:
+ ----- Method: FontImporterTool>>copyrightHeight (in category 'layout') -----
+ copyrightHeight
+
+ ^ ToolBuilder default inputFieldHeightFor: 2 "lines of normal text"!
Item was changed:
----- Method: FontImporterTool>>currentSelection: (in category 'accessing') -----
currentSelection: anObject
anObject = currentSelection ifTrue: [^ self].
currentSelection := anObject.
+ selectedFont := nil.
self changed: #currentSelection.
self changed: #previewText.
+ self changed: #selectedFontTextStyle.
- self changed: #textStyle with: self selectedFontTextStyle.
self changed: #filename.
self changed: #copyright.!
Item was changed:
----- Method: FontImporterTool>>filename (in category 'model access') -----
filename
^ self currentSelection
ifNil: ['']
ifNotNil: [:sel |
String streamContents: [:stream |
sel allFilenames
do: [:filename | stream nextPutAll: filename]
+ separatedBy: [stream cr ]]]!
- separatedBy: [stream nextPut: $,;nextPut: $ ]]]!
Item was changed:
----- Method: FontImporterTool>>filenameHeight (in category 'layout') -----
filenameHeight
+
+ ^ ToolBuilder default inputFieldHeightFor: 3 "lines"!
- ^ self filenameFont height * 2!
Item was changed:
ScrollPane subclass: #PluggableTextMorph
+ instanceVariableNames: 'textMorph getTextSelector setTextSelector getSelectionSelector hasUnacceptedEdits hasUserEdited askBeforeDiscardingEdits selectionInterval hasEditingConflicts editTextSelector wantsWrapBorder getFontSelector getTextStyleSelector'
- instanceVariableNames: 'textMorph getTextSelector setTextSelector getSelectionSelector hasUnacceptedEdits hasUserEdited askBeforeDiscardingEdits selectionInterval hasEditingConflicts editTextSelector wantsWrapBorder'
classVariableNames: 'AdornmentCache SimpleFrameAdornments SoftLineWrap VisualWrapBorder VisualWrapBorderLimit'
poolDictionaries: ''
category: 'Morphic-Pluggable Widgets'!
Item was changed:
+ ----- Method: PluggableTextMorph>>font: (in category 'model access') -----
- ----- Method: PluggableTextMorph>>font: (in category 'initialization') -----
font: aFont
+
+ self flag: #deprecated.
+ self setFont: aFont.!
- textMorph font: aFont.!
Item was added:
+ ----- Method: PluggableTextMorph>>getFont (in category 'model access') -----
+ getFont
+ "Retrieve the current model text font"
+
+ | newFont |
+ getFontSelector ifNil: [^ TextStyle defaultFont].
+ newFont := model perform: getFontSelector.
+ newFont ifNil: [^ TextStyle defaultFont].
+ ^ newFont!
Item was added:
+ ----- Method: PluggableTextMorph>>getFontSelector (in category 'accessing') -----
+ getFontSelector
+
+ ^ getFontSelector!
Item was added:
+ ----- Method: PluggableTextMorph>>getFontSelector: (in category 'accessing') -----
+ getFontSelector: aSelector
+
+ getFontSelector := aSelector.!
Item was added:
+ ----- Method: PluggableTextMorph>>getTextStyle (in category 'model access') -----
+ getTextStyle
+ "Retrieve the current model text style"
+
+ | newStyle |
+ getTextStyleSelector ifNil: [^ TextStyle default].
+ newStyle := model perform: getTextStyleSelector.
+ newStyle ifNil: [^ TextStyle default].
+ ^ newStyle!
Item was added:
+ ----- Method: PluggableTextMorph>>getTextStyleSelector (in category 'accessing') -----
+ getTextStyleSelector
+
+ ^ getTextStyleSelector!
Item was added:
+ ----- Method: PluggableTextMorph>>getTextStyleSelector: (in category 'accessing') -----
+ getTextStyleSelector: aSelector
+
+ getTextStyleSelector := aSelector.!
Item was changed:
----- Method: PluggableTextMorph>>setDefaultParameters (in category 'initialization') -----
setDefaultParameters
super setDefaultParameters.
self textMorph textStyle defaultFont hasFixedWidth "mt: Law of Demeter ... Can we rely on text styles to only bundle similar fonts?"
+ ifFalse: [self setTextStyle: (self userInterfaceTheme textStyle ifNil: [TextStyle default]) copy]
+ ifTrue: [self setTextStyle: (self userInterfaceTheme textStyleFixed ifNil: [TextStyle defaultFixed]) copy].
- ifFalse: [self textStyle: (self userInterfaceTheme textStyle ifNil: [TextStyle default]) copy]
- ifTrue: [self textStyle: (self userInterfaceTheme textStyleFixed ifNil: [TextStyle defaultFixed]) copy].
self setTextColor: (self userInterfaceTheme textColor ifNil: [Color black]).
self wrapBorderColor: ((self userInterfaceTheme wrapBorderColorModifier ifNil: [ [:c | c muchLighter alpha: 0.3] ])
value: self borderColor).
self
setProperty: #adornmentReadOnly
toValue: (self userInterfaceTheme adornmentReadOnly ifNil: [Color black]);
setProperty: #adornmentRefuse
toValue: (self userInterfaceTheme adornmentRefuse ifNil: [Color tan]);
setProperty: #adornmentConflict
toValue: (self userInterfaceTheme adornmentConflict ifNil: [Color red]);
setProperty: #adornmentDiff
toValue: (self userInterfaceTheme adornmentDiff ifNil: [Color green]);
setProperty: #adornmentNormalEdit
toValue: (self userInterfaceTheme adornmentNormalEdit ifNil: [Color orange]);
setProperty: #adornmentDiffEdit
toValue: (self userInterfaceTheme adornmentDiffEdit ifNil: [Color yellow]).
self
setProperty: #frameAdornmentWidth
toValue: (self userInterfaceTheme frameAdornmentWidth ifNil: [1]).
textMorph
caretColor: (self userInterfaceTheme caretColor ifNil: [Color red]);
selectionColor: (self userInterfaceTheme selectionColor ifNil: [TranslucentColor r: 0.0 g: 0.0 b: 0.8 alpha: 0.2]);
unfocusedSelectionColor: ((self userInterfaceTheme unfocusedSelectionModifier ifNil: [ [:c | Color gray: 0.9] ])
value: textMorph selectionColor).!
Item was added:
+ ----- Method: PluggableTextMorph>>setFont: (in category 'model access') -----
+ setFont: aFont
+ textMorph font: aFont.!
Item was added:
+ ----- Method: PluggableTextMorph>>setTextStyle: (in category 'model access') -----
+ setTextStyle: aTextStyle
+ "Always copy the argument to avoid messing up TextStyle >> #default."
+
+ textMorph textStyle: aTextStyle copy.!
Item was removed:
- ----- Method: PluggableTextMorph>>textStyle: (in category 'initialization') -----
- textStyle: aTextStyle
- textMorph textStyle: aTextStyle.!
Item was changed:
----- Method: PluggableTextMorph>>update: (in category 'updating') -----
update: aSymbol
aSymbol ifNil: [^self].
aSymbol == #flash ifTrue: [^self flash].
aSymbol == getTextSelector
ifTrue: [
self setText: self getText.
getSelectionSelector
ifNotNil: [self setSelection: self getSelection].
^ self].
aSymbol == getSelectionSelector
ifTrue: [^self setSelection: self getSelection].
+
+ aSymbol == getTextStyleSelector
+ ifTrue: [^ self setTextStyle: self getTextStyle].
+ aSymbol == getFontSelector
+ ifTrue: [^ self setFont: self getFont].
aSymbol == #acceptChanges ifTrue: [^ self accept].
aSymbol == #revertChanges ifTrue: [^ self cancelSafely].
(aSymbol == #autoSelect and: [getSelectionSelector notNil])
ifTrue:
[self handleEdit:
[(textMorph editor)
abandonChangeText; "no replacement!!"
setSearch: model autoSelectString;
findAgainNow "do not reset search string"]].
aSymbol == #clearUserEdits ifTrue: [^self hasUnacceptedEdits: false].
aSymbol == #wantToChange
ifTrue:
[self canDiscardEdits ifFalse: [^self promptForCancel].
^self].
aSymbol == #appendEntry
ifTrue:
[self handleEdit: [self appendEntry].
^self refreshWorld].
aSymbol == #appendEntryLater
ifTrue: [self handleEdit: [self appendEntry]].
aSymbol == #clearText
ifTrue:
[self handleEdit: [self changeText: Text new].
^self refreshWorld].
aSymbol == #bs
ifTrue:
[self handleEdit: [self bsText].
^self refreshWorld].
aSymbol == #codeChangedElsewhere
ifTrue:
[self hasEditingConflicts: true.
^self changed].
aSymbol == #saveContents
ifTrue:
[^(self respondsTo: #saveContentsInFile) ifTrue: [self saveContentsInFile]].
aSymbol == #showContents
ifTrue:
[^ self scrollToTop].
!
Item was changed:
----- Method: PluggableTextMorph>>update:with: (in category 'updating') -----
update: aSymbol with: arg1
aSymbol == #editString
ifTrue: [
self editString: arg1.
self hasUnacceptedEdits: true.
^ self].
(aSymbol == #inputRequested and: [self getTextSelector == arg1 or: [self setTextSelector == arg1]])
ifTrue: [
self activeHand newKeyboardFocus: self.
^ self].
aSymbol == #textStyle
ifTrue: [
+ self setTextStyle: arg1.
- self textMorph setTextStyle: arg1.
^ self].
+
+ aSymbol == #font
+ ifTrue: [
+ self setFont: arg1.
+ ^ self].
+
^super update: aSymbol with: arg1!
Item was changed:
----- Method: TextMorph>>setTextStyle: (in category 'initialization') -----
setTextStyle: aTextStyle
+ self flag: #deprecated.
+ self textStyle: aTextStyle.!
- textStyle := aTextStyle.
- self releaseParagraph.!
Item was changed:
----- Method: TextMorph>>textStyle: (in category 'accessing') -----
textStyle: aTextStyle
+ "Change the receiver's set of fonts to aTextStyle. You can access those fonts via the TextFontChange text attribute. If you want to enfore a specific font face or point size, use #font: instead. NOTE THAT you must provide either a freshly created instance of TextStyle or a copy of an existing one. NEVER use, for example, TextStyle class >> #default directly. Also see senders and implementors of #asNewTextStyle."
- "Change the receiver's set of fonts to aTextStyle. You can access those fonts via the TextFontChange text attribute. If you want to enfore a specific font face or point size, use #font: instead."
textStyle := aTextStyle.
self releaseParagraph.!
More information about the Squeak-dev
mailing list
|