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

Thiede, Christoph Christoph.Thiede at student.hpi.uni-potsdam.de
Sun Feb 6 17:50:29 UTC 2022


Hi Marcel,


thank you for all your recent work on the font and graphics domain! These are really valuable for Squeak; I know multiple people that already face away from Squeak because "the text looks so old-fashioned and puny". The new scaling and the convenience for installing other fonts for other charsets definitely improve this, even though many of us are familiar with the classical compact display!


One question about this commit: Is this expected to resolve the limitation that you cannot style the different characters in a list item with different attributes/emphases? :-) If yes, I did not yet figure out how to do this. When I change Context >> #printString like this, the entire line remains unformatted:


printString
"Answer an emphasized string in case of a breakpoint method"

^(self method notNil and: [self method hasBreakpoint])
ifTrue:[super printString asText , ' [break]' asText allBold]
ifFalse:[super printString]


Best,

Christoph

________________________________
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von commits at source.squeak.org <commits at source.squeak.org>
Gesendet: Samstag, 5. Februar 2022 17:50:13
An: squeak-dev at lists.squeakfoundation.org; packages at lists.squeakfoundation.org
Betreff: [squeak-dev] The Trunk: Morphic-mt.1871.mcz

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

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

Name: Morphic-mt.1871
Author: mt
Time: 5 February 2022, 5:50:07.252947 pm
UUID: ace9011c-de05-9846-b208-cccb9d5232a8
Ancestors: Morphic-mt.1870

Adds support for font changes in list items. Use it to spice up the "set style..." dialog in text fields.

=============== Diff against Morphic-mt.1870 ===============

Item was changed:
  ----- Method: LazyListMorph>>display:atRow:on: (in category 'drawing') -----
  display: item atRow: row on: canvas
         "display the given item at row row"

         | drawBounds leading emphasized rowColor itemAsText alignment |
         itemAsText := item asStringOrText.
         alignment := self cellPositioning.

         "If it is a text, we will only use the first character's emphasis."
+        emphasized := itemAsText isText
+                ifFalse: [ font "fast path" ]
+                ifTrue: [ "Note that a font change may interfere with the receiver's uniform item height."
+                        (itemAsText
+                                fontAt: 1 withDefault: font)
+                                emphasized: (itemAsText emphasisAt: 1)].
-        emphasized := itemAsText isText
-                ifTrue: [font emphasized: (itemAsText emphasisAt: 1)]
-                ifFalse: [font].

         rowColor := itemAsText isText
                 ifTrue: [itemAsText colorAt: 1 ifNone: [self colorForRow: row]]
                 ifFalse: [self colorForRow: row].

         drawBounds := self drawBoundsForRow: row.

         alignment ~= #leftCenter ifTrue: [
                 | itemWidth |
                 itemWidth := self widthToDisplayItem: item. "includes left/right margins"
                 alignment == #center ifTrue: [
                         drawBounds := (self center x - (itemWidth / 2) floor) @ drawBounds top corner: (self center x + (itemWidth / 2) ceiling) @ drawBounds bottom].
                 alignment == #rightCenter ifTrue: [
                         drawBounds := (self right - itemWidth) @ drawBounds top corner: self right @ drawBounds bottom]].

         "Draw icon if existing. Adjust draw bounds in that case."
         drawBounds := drawBounds translateBy: (self cellInset left @ 0).
         (self icon: row) ifNotNil: [ :icon || top |
                 top := drawBounds top + ((drawBounds height - self iconExtent y) // 2).
                 canvas translucentImage: icon at: drawBounds left @ top.
                 drawBounds := drawBounds left: drawBounds left + self iconExtent x + self cellInset left ].

         "We will only draw strings here."
         leading :=  emphasized lineGapSliceForMorphs. "look vertically centered"
         drawBounds := drawBounds translateBy: (0 @ self cellInset top).
         canvas
                 drawString: itemAsText asString
                 in: (drawBounds origin + (0 @ leading) corner: drawBounds corner)
                 font: emphasized
                 color: rowColor.

         "Draw filter matches if any."
         self
                 displayFilterOn: canvas
                 for: row
                 in: drawBounds
                 font: emphasized.!

Item was changed:
  ----- Method: TextEditor>>changeStyle (in category 'attributes') -----
  changeStyle
         "Let user change styles for the current text pane."
-        | names reply style current menuList |

+        | known knownTTCStyles knownLegacyStyles defaultStyles
+        newStyle current currentName menuList |
         current := morph textStyle.
+        currentName := current defaultFamilyName.
+
+        knownTTCStyles := ((TextStyle actualTextStyles select: [:ea | ea isTTCStyle])
+                sorted: [:a :b | a defaultFamilyName <= b defaultFamilyName])
+                collect: [:ea | ea defaultFamilyName -> ea] as: OrderedDictionary.
+        knownLegacyStyles := ((TextStyle actualTextStyles reject: [:ea | ea isTTCStyle])
+                sorted: [:a :b | a defaultFamilyName <= b defaultFamilyName])
+                collect: [:ea | ea defaultFamilyName -> ea] as: OrderedDictionary.
+        defaultStyles := ((TextStyle defaultFamilyNames
+                collect: [:ea | ea -> (TextStyle named: ea)] as: OrderedDictionary)
+                reject: [:ea | ea isNil "undefined default styles"])
+                sorted: [:a :b | a key <= b key].
+
+        known := defaultStyles, {'---' -> nil}, knownTTCStyles, {'--- ' -> nil}, knownLegacyStyles.
+        menuList := Array streamContents: [:s |
+                known keysAndValuesDo: [ :knownName :knownStyle |
+                        s nextPut: (((knownStyle notNil and: [knownStyle defaultFamilyName = currentName])
+                                ifTrue: [ (' > ', knownName, ' (current)' translated) asText ]
+                                ifFalse: [ knownName asText ]) addAttribute: (TextFontReference toFont: (knownStyle ifNil: [TextStyle default])defaultFont); yourself)]].
+        known := known values.
+        newStyle := Project uiManager chooseFrom: menuList values: known.
+        newStyle ifNotNil: [morph textStyle: newStyle copy].
-        names := TextStyle knownTextStyles.
-        menuList := names collect: [ :styleName |
-                styleName = current name
-                        ifTrue: [ '<on>', styleName ]
-                        ifFalse: [ '<off>', styleName ]].
-        reply := Project uiManager chooseFrom: menuList values: names.
-        reply ifNotNil: [
-                (style := TextStyle named: reply) ifNil: [Beeper beep. ^ true].
-                morph textStyle: style copy].
         ^ true!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220206/a1be5e1d/attachment.html>


More information about the Squeak-dev mailing list