[squeak-dev] The Inbox: MorphicExtras-ct.263.mcz
commits at source.squeak.org
commits at source.squeak.org
Sat Sep 7 10:44:02 UTC 2019
A new version of MorphicExtras was added to project The Inbox:
http://source.squeak.org/inbox/MorphicExtras-ct.263.mcz
==================== Summary ====================
Name: MorphicExtras-ct.263
Author: ct
Time: 7 September 2019, 12:35:29.653698 pm
UUID: 7205ede8-7f4d-3842-bb5f-01738abfc5cb
Ancestors: MorphicExtras-ct.262
Switch from preamble to postscript and from DateAndTime to TimeStamp
=============== Diff against MorphicExtras-mt.260 ===============
Item was changed:
StringMorph subclass: #FrameRateMorph
+ instanceVariableNames: 'lastDisplayTime framesSinceLastDisplay updateInterval mSecsPerFrame framesPerSec'
- instanceVariableNames: 'lastDisplayTime framesSinceLastDisplay'
classVariableNames: ''
poolDictionaries: ''
category: 'MorphicExtras-Demo'!
Item was changed:
----- Method: FrameRateMorph class>>descriptionForPartsBin (in category 'parts bin') -----
descriptionForPartsBin
^ self partName: 'FrameRate' translatedNoop
+ categories: {'Tools' translatedNoop}
- categories: {'Just for Fun' translatedNoop}
documentation: 'A readout that allows you to monitor the frame rate of your system' translatedNoop!
Item was added:
+ ----- Method: FrameRateMorph>>framesPerSec (in category 'accessing') -----
+ framesPerSec
+
+ ^ framesPerSec!
Item was changed:
----- Method: FrameRateMorph>>initialize (in category 'initialization') -----
initialize
"initialize the state of the receiver"
super initialize.
""
+ lastDisplayTime := DateAndTime new.
- lastDisplayTime := 0.
framesSinceLastDisplay := 0.
+ self updateInterval: 500 milliSeconds.
self font: (Preferences standardMenuFont emphasized: 1).
!
Item was added:
+ ----- Method: FrameRateMorph>>mSecsPerFrame (in category 'accessing') -----
+ mSecsPerFrame
+
+ ^ mSecsPerFrame!
Item was changed:
----- Method: FrameRateMorph>>step (in category 'stepping and presenter') -----
step
"Compute and display (every half second or so) the current framerate"
+ | now timePassed |
- | now mSecs mSecsPerFrame framesPerSec newContents |
framesSinceLastDisplay := framesSinceLastDisplay + 1.
+ now := DateAndTime now.
+ timePassed := now - lastDisplayTime.
+ (timePassed > self updateInterval) ifTrue:
+ [| mSecs |
+ mSecs := timePassed asMilliSeconds.
+ mSecsPerFrame := mSecs // framesSinceLastDisplay.
- now := Time millisecondClockValue.
- mSecs := now - lastDisplayTime.
- (mSecs > 500 or: [mSecs < 0 "clock wrap-around"]) ifTrue:
- [mSecsPerFrame := mSecs // framesSinceLastDisplay.
framesPerSec := (framesSinceLastDisplay * 1000) // mSecs.
+ self contents: ('{1} mSecs ({2} frame{3}/sec)'
+ format: {mSecsPerFrame. framesPerSec. framesPerSec = 1 ifTrue: [''] ifFalse: ['s']}).
- newContents := mSecsPerFrame printString, ' mSecs (', framesPerSec printString, ' frame', (framesPerSec = 1 ifTrue: [''] ifFalse: ['s']), '/sec)'.
- self contents: newContents.
lastDisplayTime := now.
framesSinceLastDisplay := 0]
ifFalse:
["Ensure at least one pixel is drawn per frame"
Preferences higherPerformance ifTrue: [self invalidRect: (self position extent: 1 at 1)]]!
Item was added:
+ ----- Method: FrameRateMorph>>updateInterval (in category 'accessing') -----
+ updateInterval
+
+ ^ updateInterval!
Item was added:
+ ----- Method: FrameRateMorph>>updateInterval: (in category 'accessing') -----
+ updateInterval: aNumber
+
+ updateInterval := aNumber!
Item was changed:
+ (PackageInfo named: 'MorphicExtras') postscript: 'FrameRateMorph allSubInstances do: [:frm | | wasStepping |
+ wasStepping := frm isStepping.
+ wasStepping ifTrue: [frm stopStepping].
+ frm
+ instVarNamed: #lastDisplayTime
+ put: DateAndTime now;
+ updateInterval: 500 milliSeconds.
+ wasStepping ifTrue: [frm startStepping]].'!
- (PackageInfo named: 'MorphicExtras') postscript: 'TrashCanMorph preserveTrash: Preferences preserveTrash.
- TrashCanMorph slideDismissalsToTrash: Preferences slideDismissalsToTrash.
-
- Preferences removePreference: #preserveTrash.
- Preferences removePreference: #slideDismissalsToTrash.'!
More information about the Squeak-dev
mailing list
|