[squeak-dev] The Trunk: Morphic-laza.175.mcz
commits at source.squeak.org
commits at source.squeak.org
Tue Sep 8 20:33:18 UTC 2009
Alexander Lazarević uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-laza.175.mcz
==================== Summary ====================
Name: Morphic-laza.175
Author: laza
Time: 8 September 2009, 10:32:12 pm
UUID: d1949c05-063b-394a-8581-66c228e13b6b
Ancestors: Morphic-laza.174
I recognized, that SystemProgressMorph got extended to support changing the label during progress display. This was not fully supported and I changed that. What was also missing was the realignment.
In additon SystemProgressMorph now supports label only display and handles informUserDuring:. See the examples for details.
I also changed the font and some of the look and layout.
=============== Diff against Morphic-ar.172 ===============
Item was added:
+ ----- Method: SystemProgressMorph>>setLabel:at: (in category 'labelling') -----
+ setLabel: shortDescription at: slot
+ (labels at: slot) contents: shortDescription.
+ self recenter!
Item was changed:
----- Method: SystemProgressMorph class>>initialize (in category 'class initialization') -----
initialize
+ "SystemProgressMorph initialize"
+ BarHeight := 8.
+ BarWidth := 300.
+ self reset!
- "SystemProgressMorph initialize; reset"
- BarHeight := 16.
- BarWidth := 200.!
Item was changed:
----- Method: SystemProgressMorph>>nextSlotFor: (in category 'private') -----
nextSlotFor: shortDescription
| bar slots label |
lock critical: [
+ slots := labels size.
- slots := bars size.
activeSlots = slots ifTrue: [^0].
activeSlots := activeSlots + 1.
1 to: slots do: [:index |
+ label := (labels at: index).
+ label ifNil: [
- bar := (bars at: index).
- bar ifNil: [
bar := bars at: index put: (SystemProgressBarMorph new extent: BarWidth at BarHeight).
label := labels at: index put: (StringMorph contents: shortDescription font: font).
self
addMorphBack: label;
addMorphBack: bar.
^index].
+ label owner ifNil: [
- bar owner ifNil: [
bar := bars at: index.
label := labels at: index.
self
addMorphBack: (label contents: shortDescription);
addMorphBack: (bar barSize: 0).
^index]]]
!
Item was changed:
----- Method: SystemProgressMorph>>label:min:max: (in category 'private') -----
label: shortDescription min: minValue max: maxValue
| slot range newBarSize barSize lastRefresh |
+ ((range := maxValue - minValue) < 0 or: [(slot := self nextSlotFor: shortDescription) = 0])
- ((range := maxValue - minValue) <= 0 or: [(slot := self nextSlotFor: shortDescription) = 0])
ifTrue: [^[:barVal| 0 ]].
+ range <= 0 ifTrue: [self removeMorph: (bars at: slot)].
+ self recenter.
self openInWorld.
- self align: self fullBounds center with: Display boundingBox center.
barSize := -1. "Enforces a inital draw of the morph"
lastRefresh := 0.
+ ^[:barVal |
+ barVal isString ifTrue: [
+ self setLabel: barVal at: slot.
+ self currentWorld displayWorld].
+ (barVal isNumber and: [barVal between: minValue and: maxValue]) ifTrue: [
- ^[:barVal |
- (barVal between: minValue and: maxValue) ifTrue: [
newBarSize := (barVal - minValue / range * BarWidth) truncated.
newBarSize = barSize ifFalse: [
barSize := newBarSize.
(bars at: slot) barSize: barSize.
Time primMillisecondClock - lastRefresh > 25 ifTrue: [
self currentWorld displayWorld.
lastRefresh := Time primMillisecondClock]]].
slot]
!
Item was added:
+ ----- Method: SystemProgressMorph class>>exampleChangeLabel (in category 'examples') -----
+ exampleChangeLabel
+ "SystemProgressMorph exampleChangeLabel"
+ | classes |
+ classes := Smalltalk allClasses copyFrom: 1 to: 100.
+ 'InitialLabel'
+ displayProgressAt: Display center
+ from: 0 to: classes size
+ during: [:bar | 1 to: classes size do: [:i |
+ bar value: i.
+ bar value: i printString, '/', classes size printString, ' ', (classes at: i) printString.
+ (Delay forMilliseconds: 100) wait]]
+ !
Item was changed:
----- Method: SystemProgressMorph>>labelAt:put: (in category 'labelling') -----
labelAt: progressBlock put: aString
+ "Change the label for the given progressBlock to aString."
+ progressBlock value: aString!
- "Change the label for the given progressBlock to aString.
- Fixme: I don't know how to map from progressBlock to label.
- For now we just use the top-level label since this works just fine."
- labels first ifNotNil:[:lbl| lbl contents: aString].!
Item was added:
+ ----- Method: SystemProgressMorph>>recenter (in category 'private') -----
+ recenter
+ self align: self fullBounds center with: Display boundingBox center.
+ !
Item was changed:
----- Method: SystemProgressMorph>>initialize (in category 'initialization') -----
initialize
super initialize.
activeSlots := 0.
bars := Array new: 10.
labels := Array new: 10.
+ font := Preferences standardMenuFont.
- font := Preferences windowTitleFont.
lock := Semaphore forMutualExclusion.
self setDefaultParameters;
setProperty: #morphicLayerNumber toValue: self morphicLayerNumber;
layoutPolicy: TableLayout new;
listDirection: #topToBottom;
+ cellPositioning: #leftCenter;
- cellPositioning: #topCenter;
cellInset: 5;
listCentering: #center;
hResizing: #shrinkWrap;
vResizing: #shrinkWrap;
+ layoutInset:30 at 30;
+ minWidth: 150!
- layoutInset:4 at 4.!
Item was added:
+ ----- Method: SystemProgressMorph class>>exampleLabelOnly (in category 'examples') -----
+ exampleLabelOnly
+ "SystemProgressMorph exampleLabelOnly"
+ | words |
+ words := #(zero one two three four five six seven eight nine ten) reversed.
+ UIManager default informUserDuring: [:bar |
+ words do: [:each|
+ bar value: 'Countdown: ', each.
+ (Delay forSeconds: 1) wait]].!
Item was changed:
----- Method: SystemProgressBarMorph>>drawOn: (in category 'drawing') -----
drawOn: aCanvas
| area |
super drawOn: aCanvas.
barSize > 0 ifTrue: [
area := self innerBounds.
area := area origin extent: barSize-2 at area extent y.
+ aCanvas fillRectangle: area color: (Preferences menuTitleColor alpha: 1) darker.
- aCanvas fillRectangle: area color: Preferences menuTitleColor.
].
!
Item was added:
+ ----- Method: SystemProgressMorph class>>informUserAt:during: (in category 'instance creation') -----
+ informUserAt: aPoint during: workBlock
+ ProgressInitiationException
+ display: ' '
+ at: aPoint
+ from: 0
+ to: 0
+ during: workBlock!
Item was changed:
----- Method: SystemProgressMorph>>freeSlot: (in category 'private') -----
freeSlot: number
number > 0 ifTrue: [
lock critical: [
(bars at: number) delete.
(labels at: number) delete.
activeSlots := activeSlots - 1.
activeSlots = 0
ifTrue: [self delete]
+ ifFalse: [self recenter]]]!
- ifFalse: [self align: self fullBounds center with: Display boundingBox center]]]!
More information about the Squeak-dev
mailing list
|