Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1198.mcz ==================== Summary ==================== Name: Morphic-mt.1198 Author: mt Time: 22 July 2016, 1:24:23.585873 pm UUID: 052d96c3-da19-7d4e-9448-5c3fd07148db Ancestors: Morphic-mt.1197 Make system progress morph use accessors instead of direct instVar accesses to support smooth feature updates in the future. Especially #position:label:min:max: is problematic if we add or remove instVars in SystemProgressMorph because that morph is used when loading code. We had a similar issue with HandMorph in the recent past. Still, bugs can occur when updating from older Squeak images. Hence, we might want to consider "restarting" the update process for each entry in an update map. =============== Diff against Morphic-mt.1197 =============== Item was added: + ----- Method: SystemProgressMorph>>activeSlots (in category 'accessing') ----- + activeSlots + + ^ activeSlots! Item was added: + ----- Method: SystemProgressMorph>>activeSlots: (in category 'accessing') ----- + activeSlots: anObject + + activeSlots := anObject! Item was added: + ----- Method: SystemProgressMorph>>bars (in category 'accessing') ----- + bars + + ^ bars! Item was added: + ----- Method: SystemProgressMorph>>bars: (in category 'accessing') ----- + bars: anObject + + bars := anObject! Item was added: + ----- Method: SystemProgressMorph>>font (in category 'accessing') ----- + font + + ^ font! Item was added: + ----- Method: SystemProgressMorph>>font: (in category 'accessing') ----- + font: anObject + + font := anObject! Item was changed: ----- Method: SystemProgressMorph>>freeSlot: (in category 'private') ----- freeSlot: number number > 0 ifFalse: [^self]. lock critical: [| label | + label := self labels at: number. - label := labels at: number. (label isNil or: [label owner isNil]) ifTrue: [^self]. "Has been freed before" label delete. + (self bars at: number) delete. + self activeSlots: self activeSlots - 1. + self activeSlots = 0 - (bars at: number) delete. - activeSlots := activeSlots - 1. - activeSlots = 0 ifTrue: [self delete] ifFalse: [self reposition]]! Item was added: + ----- Method: SystemProgressMorph>>labels (in category 'accessing') ----- + labels + + ^ labels! Item was added: + ----- Method: SystemProgressMorph>>labels: (in category 'accessing') ----- + labels: anObject + + labels := anObject! Item was changed: ----- Method: SystemProgressMorph>>nextSlotFor: (in category 'private') ----- nextSlotFor: shortDescription lock critical: [ | label bar slots | + slots := self labels size. + self activeSlots = slots ifTrue: [^0]. + self activeSlots: self activeSlots + 1. - slots := labels size. - activeSlots = slots ifTrue: [^0]. - activeSlots := activeSlots + 1. 1 to: slots do: [:index | + label := (self labels at: index). - label := (labels at: index). label ifNil: [ + bar := self bars at: index put: (SystemProgressBarMorph new extent: BarWidth@BarHeight). + label := self labels at: index put: (StringMorph contents: shortDescription font: self font). - bar := bars at: index put: (SystemProgressBarMorph new extent: BarWidth@BarHeight). - label := labels at: index put: (StringMorph contents: shortDescription font: font). self addMorphBack: label; addMorphBack: bar. ^index]. label owner ifNil: [ + bar := self bars at: index. + label := self labels at: index. - bar := bars at: index. - label := labels at: index. self addMorphBack: (label contents: shortDescription); addMorphBack: (bar barSize: 0). ^index]]] ! Item was changed: ----- Method: SystemProgressMorph>>position:label:min:max: (in category 'private') ----- position: aPoint label: shortDescription min: minValue max: maxValue | slot range barSize lastRefresh | + self requestedPosition: aPoint. - requestedPosition := aPoint. ((range := maxValue - minValue) < 0 or: [(slot := self nextSlotFor: shortDescription) = 0]) ifTrue: [^[:barVal| 0 ]]. + range <= 0 ifTrue: [self removeMorph: (self bars at: slot)]. - range <= 0 ifTrue: [self removeMorph: (bars at: slot)]. self reposition. self openInWorld. barSize := -1. "Enforces a inital draw of the morph" lastRefresh := 0. ^[:barVal | | newBarSize | barVal isString ifTrue: [ self setLabel: barVal at: slot. self currentWorld displayWorld]. (barVal isNumber and: [range >= 1 and: [barVal between: minValue and: maxValue]]) ifTrue: [ newBarSize := (barVal - minValue / range * BarWidth) truncated. newBarSize = barSize ifFalse: [ barSize := newBarSize. + (self bars at: slot) barSize: barSize. - (bars at: slot) barSize: barSize. Time utcMicrosecondClock - lastRefresh > 25000 ifTrue: [ self currentWorld displayWorld. lastRefresh := Time utcMicrosecondClock]]]. slot]! Item was changed: ----- Method: SystemProgressMorph>>reposition (in category 'private') ----- reposition "Put ourself in the requested position on the display, but ensure completely within the bounds of the display" | position | self bounds: ((self fullBounds align: self fullBounds center + with: (self requestedPosition ifNil: [ self fullBounds center ])) translatedToBeWithin: Display boundingBox). - with: (requestedPosition ifNil: [ self fullBounds center ])) translatedToBeWithin: Display boundingBox). "Check to see if labels are wider than progress bars. In that case do a centered instead of the default left aligned layout." position := self width > (Inset x * 2 + (self borderWidth * 2) + BarWidth) ifTrue: [ #topCenter ] ifFalse: [ #leftCenter ]. self cellPositioning: position! Item was added: + ----- Method: SystemProgressMorph>>requestedPosition (in category 'accessing') ----- + requestedPosition + + ^ requestedPosition! Item was added: + ----- Method: SystemProgressMorph>>requestedPosition: (in category 'accessing') ----- + requestedPosition: anObject + + requestedPosition := anObject! Item was changed: ----- Method: SystemProgressMorph>>setLabel:at: (in category 'labelling') ----- setLabel: shortDescription at: slot + (self labels at: slot) contents: shortDescription. - (labels at: slot) contents: shortDescription. self reposition! |
Free forum by Nabble | Edit this page |