The Trunk: Morphic-mt.1594.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Morphic-mt.1594.mcz

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

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

Name: Morphic-mt.1594
Author: mt
Time: 26 November 2019, 4:39:59.476764 pm
UUID: 93c42f58-dfe3-bb42-85a6-0ba82ea72017
Ancestors: Morphic-jr.1593

Fixes that regression with custom text attributes in tree widgets.

=============== Diff against Morphic-jr.1593 ===============

Item was changed:
  ----- Method: IndentingListItemMorph>>getLabelFor: (in category 'model access') -----
  getLabelFor: model
+ "Note that the given model is usually aListItemWrapper."
+
+ ^ model asStringOrText!
-
- ^ model asString!

Item was added:
+ ----- Method: IndentingListItemMorph>>initWithColor:andFont: (in category 'initialization') -----
+ initWithColor: aColor andFont: aFont
+
+ (self hasProperty: #hasColorFromText)
+ ifFalse: [self color: aColor].
+
+ (self hasProperty: #hasEmphasisFromText)
+ ifTrue: [
+ (self hasProperty: #hasFontFromText)
+ ifFalse: [self font: aFont "Keeps emphasis from text."]]
+ ifFalse: [
+ (self hasProperty: #hasFontFromText)
+ ifTrue: [self emphasis: aFont emphasis "Keeps font from text."]
+ ifFalse: [self font: aFont emphasis: aFont emphasis]]
+ !

Item was added:
+ ----- Method: IndentingListItemMorph>>initializeFromText: (in category 'initialization') -----
+ initializeFromText: aText
+ "Overridden to keep track of text-based attributes."
+
+ | priorFont priorEmphasis priorColor |
+ priorFont := self font.
+ priorEmphasis := self emphasis.
+ priorColor := self color.
+
+ super initializeFromText: aText.
+
+ priorFont == self font
+ ifFalse: [self setProperty: #hasFontFromText toValue: true].
+ priorFont == self emphasis
+ ifFalse: [self setProperty: #hasEmphasisFromText toValue: true].
+ priorColor == self color
+ ifFalse: [self setProperty: #hasColorFromText toValue: true].!

Item was added:
+ ----- Method: ListItemWrapper>>asStringOrText (in category 'converting') -----
+ asStringOrText
+ "Documentation only. You can create a custom wrapper that returns text with formatting. The tree widget will then use the text attributes of the first characters and applies them to the entire label. LazyListMorph works the same way."
+
+ ^ self asString!

Item was changed:
  ----- Method: SimpleHierarchicalListMorph>>addMorphsTo:from:allowSorting:withExpandedItems:atLevel: (in category 'private') -----
  addMorphsTo: morphList from: aCollection allowSorting: sortBoolean withExpandedItems: expandedItems atLevel: newIndent
 
  | priorMorph newCollection firstAddition |
  priorMorph := nil.
  newCollection := (sortBoolean and: [sortingSelector notNil]) ifTrue: [
  aCollection sorted: [ :a :b |
  (a perform: sortingSelector) <= (b perform: sortingSelector)]
  ] ifFalse: [
  aCollection
  ].
  firstAddition := nil.
  newCollection do: [:item |
  priorMorph := self indentingItemClass basicNew
  initWithContents: item
  prior: priorMorph
  forList: self
  indentLevel: newIndent.
  priorMorph
+ initWithColor: self textColor
+ andFont: self font.
+ priorMorph
- color: self textColor;
- font: self font;
  selectionColor: self selectionColor;
  selectionTextColor: self selectionTextColor;
  hoverColor: self hoverColor;
  highlightTextColor: self highlightTextColor;
  filterColor: self filterColor;
  filterTextColor: self filterTextColor.
  firstAddition ifNil: [firstAddition := priorMorph].
  morphList add: priorMorph.
  ((item hasEquivalentIn: expandedItems) or: [priorMorph isExpanded]) ifTrue: [
  self flag: #bug. "mt: Endless recursion can happen for similar items in the tree."
  priorMorph isExpanded: true.
  priorMorph
  addChildrenForList: self
  addingTo: morphList
  withExpandedItems: expandedItems.
  ].
  ].
  ^firstAddition
 
  !

Item was changed:
  ----- Method: StringMorph>>font: (in category 'accessing') -----
  font: aFont
  "Set the font my text will use. The emphasis remains unchanged."
 
- aFont = font ifTrue: [^ self].
-
  self
  setFont: (aFont emphasized: self emphasis)
  emphasis: self emphasis.!

Item was changed:
  ----- Method: StringMorph>>initWithContents:font:emphasis: (in category 'initialization') -----
+ initWithContents: aStringOrText font: aFont emphasis: emphasisCode
- initWithContents: aString font: aFont emphasis: emphasisCode
 
  self initialize.
 
+ aStringOrText isText
+ ifTrue: [self initializeFromText: aStringOrText]
+ ifFalse: [
+ self initializeFromString: aStringOrText.
+ self font: aFont emphasis: emphasisCode].!
- contents := aString.
-
- self font: aFont emphasis: emphasisCode.!

Item was added:
+ ----- Method: StringMorph>>initializeFromString: (in category 'initialization') -----
+ initializeFromString: aString
+
+ contents := aString.!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Morphic-mt.1594.mcz

marcel.taeumel
You can either return a text object in from that model-label callback (here: #labelFor:) or configure a custom node class (here: PluggableTreeItemNode).



Best,
Marcel

Am 26.11.2019 16:40:24 schrieb [hidden email] <[hidden email]>:

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

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

Name: Morphic-mt.1594
Author: mt
Time: 26 November 2019, 4:39:59.476764 pm
UUID: 93c42f58-dfe3-bb42-85a6-0ba82ea72017
Ancestors: Morphic-jr.1593

Fixes that regression with custom text attributes in tree widgets.

=============== Diff against Morphic-jr.1593 ===============

Item was changed:
----- Method: IndentingListItemMorph>>getLabelFor: (in category 'model access') -----
getLabelFor: model
+ "Note that the given model is usually aListItemWrapper."
+
+ ^ model asStringOrText!
-
- ^ model asString!

Item was added:
+ ----- Method: IndentingListItemMorph>>initWithColor:andFont: (in category 'initialization') -----
+ initWithColor: aColor andFont: aFont
+
+ (self hasProperty: #hasColorFromText)
+ ifFalse: [self color: aColor].
+
+ (self hasProperty: #hasEmphasisFromText)
+ ifTrue: [
+ (self hasProperty: #hasFontFromText)
+ ifFalse: [self font: aFont "Keeps emphasis from text."]]
+ ifFalse: [
+ (self hasProperty: #hasFontFromText)
+ ifTrue: [self emphasis: aFont emphasis "Keeps font from text."]
+ ifFalse: [self font: aFont emphasis: aFont emphasis]]
+ !

Item was added:
+ ----- Method: IndentingListItemMorph>>initializeFromText: (in category 'initialization') -----
+ initializeFromText: aText
+ "Overridden to keep track of text-based attributes."
+
+ | priorFont priorEmphasis priorColor |
+ priorFont := self font.
+ priorEmphasis := self emphasis.
+ priorColor := self color.
+
+ super initializeFromText: aText.
+
+ priorFont == self font
+ ifFalse: [self setProperty: #hasFontFromText toValue: true].
+ priorFont == self emphasis
+ ifFalse: [self setProperty: #hasEmphasisFromText toValue: true].
+ priorColor == self color
+ ifFalse: [self setProperty: #hasColorFromText toValue: true].!

Item was added:
+ ----- Method: ListItemWrapper>>asStringOrText (in category 'converting') -----
+ asStringOrText
+ "Documentation only. You can create a custom wrapper that returns text with formatting. The tree widget will then use the text attributes of the first characters and applies them to the entire label. LazyListMorph works the same way."
+
+ ^ self asString!

Item was changed:
----- Method: SimpleHierarchicalListMorph>>addMorphsTo:from:allowSorting:withExpandedItems:atLevel: (in category 'private') -----
addMorphsTo: morphList from: aCollection allowSorting: sortBoolean withExpandedItems: expandedItems atLevel: newIndent

| priorMorph newCollection firstAddition |
priorMorph := nil.
newCollection := (sortBoolean and: [sortingSelector notNil]) ifTrue: [
aCollection sorted: [ :a :b |
(a perform: sortingSelector) <= (b="" perform:="">
] ifFalse: [
aCollection
].
firstAddition := nil.
newCollection do: [:item |
priorMorph := self indentingItemClass basicNew
initWithContents: item
prior: priorMorph
forList: self
indentLevel: newIndent.
priorMorph
+ initWithColor: self textColor
+ andFont: self font.
+ priorMorph
- color: self textColor;
- font: self font;
selectionColor: self selectionColor;
selectionTextColor: self selectionTextColor;
hoverColor: self hoverColor;
highlightTextColor: self highlightTextColor;
filterColor: self filterColor;
filterTextColor: self filterTextColor.
firstAddition ifNil: [firstAddition := priorMorph].
morphList add: priorMorph.
((item hasEquivalentIn: expandedItems) or: [priorMorph isExpanded]) ifTrue: [
self flag: #bug. "mt: Endless recursion can happen for similar items in the tree."
priorMorph isExpanded: true.
priorMorph
addChildrenForList: self
addingTo: morphList
withExpandedItems: expandedItems.
].
].
^firstAddition

!

Item was changed:
----- Method: StringMorph>>font: (in category 'accessing') -----
font: aFont
"Set the font my text will use. The emphasis remains unchanged."

- aFont = font ifTrue: [^ self].
-
self
setFont: (aFont emphasized: self emphasis)
emphasis: self emphasis.!

Item was changed:
----- Method: StringMorph>>initWithContents:font:emphasis: (in category 'initialization') -----
+ initWithContents: aStringOrText font: aFont emphasis: emphasisCode
- initWithContents: aString font: aFont emphasis: emphasisCode

self initialize.

+ aStringOrText isText
+ ifTrue: [self initializeFromText: aStringOrText]
+ ifFalse: [
+ self initializeFromString: aStringOrText.
+ self font: aFont emphasis: emphasisCode].!
- contents := aString.
-
- self font: aFont emphasis: emphasisCode.!

Item was added:
+ ----- Method: StringMorph>>initializeFromString: (in category 'initialization') -----
+ initializeFromString: aString
+
+ contents := aString.!