The Trunk: MorphicExtras-mt.291.mcz

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

The Trunk: MorphicExtras-mt.291.mcz

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

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

Name: MorphicExtras-mt.291
Author: mt
Time: 15 April 2021, 11:46:31.400208 am
UUID: a73067c7-c5a4-4d20-9981-c11affd02c65
Ancestors: MorphicExtras-mt.290, MorphicExtras-ct.260

Merges MorphicExtras-ct.260 with the updated postscript to update all existing instances of FrameRateMorph.

=============== Diff against MorphicExtras-mt.290 ===============

Item was changed:
  StringMorph subclass: #FrameRateMorph
+ instanceVariableNames: 'lastDisplayTime framesSinceLastDisplay updateInterval mSecsPerFrame framesPerSec'
- instanceVariableNames: 'lastDisplayTime framesSinceLastDisplay'
  classVariableNames: ''
  poolDictionaries: ''
  category: 'MorphicExtras-Demo'!

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 := TimeStamp 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 newContents |
- | now mSecs mSecsPerFrame framesPerSec newContents |
  framesSinceLastDisplay := framesSinceLastDisplay + 1.
+ now := TimeStamp 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.
  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@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.'!