[ENH] NewProgressBar
Stéphane Rollandin
lecteur at zogotounga.net
Thu Apr 8 13:48:36 UTC 2004
ok I found out what's wrong with my last post: it only works in forked
processes now !
I have a new version: what about something along this line:
------------
label: shortDescription min: minValue max: maxValue
| slot range newBarSize barSize lastRefresh |
slot _ self nextSlotFor: shortDescription.
slot = 0 ifTrue: [^[:barVal| 0 ]].
self openInWorld.
self align: self fullBounds center with: Display boundingBox center.
barSize _ 0.
range _ maxValue - minValue.
lastRefresh _ Time primMillisecondClock.
^[:barVal |
(barVal between: minValue and: maxValue) ifTrue: [
newBarSize _ (barVal - minValue / range * BarWidth) truncated.
newBarSize = barSize ifFalse: [
barSize _ newBarSize.
(bars at: slot) barSize: barSize; changed.
((Time primMillisecondClock - lastRefresh > 25)
and: [Processor preemptedProcess priority ~= Processor activeProcess
priority])
ifTrue: [
self currentWorld displayWorld.
lastRefresh _ Time primMillisecondClock]]].
slot]
------------
where there is some kind of logic to check if we are in the main user
loop (I guess there is a better way to do so)...
Stef
Stéphane Rollandin wrote:
> I found a very simple way to have a clean display when grabbing the
> progress morph:
>
> [ProgressMorph example] fork
>
> now works fine !
>
>
> here is the change (method ProgressMorph>>label:min:max:)
>
> ----------------------
>
> label: shortDescription min: minValue max: maxValue
> | slot range newBarSize barSize |
> slot _ self nextSlotFor: shortDescription.
> slot = 0 ifTrue: [^[:barVal| 0 ]].
> self openInWorld.
> self align: self fullBounds center with: Display boundingBox center.
> barSize _ 0.
> range _ maxValue - minValue.
> ^[:barVal |
> (barVal between: minValue and: maxValue) ifTrue: [
> newBarSize _ (barVal - minValue / range * BarWidth) truncated.
> newBarSize = barSize ifFalse: [
> barSize _ newBarSize.
> (bars at: slot) barSize: barSize; changed]].
> slot]
>
>
> ----------------------
>
> is there any side effect ? (I don't understand what the lastRefresh
> thing was there for :))
>
>
> Stef
>
>
>
>
>
More information about the Squeak-dev
mailing list
|