[Pharo-project] Morph does not refresh or show
Hello, I am having an issue where I need to refresh an object that is a subclass of RectangleMorph in a window. My object needs to travel across the screen at certain intervals. A controller object tells this RectangleMorph object where wants it, and in turn the Rectangle object sets its new position with self position: newX@ newY. but the object does not show up. It does however take the exact time it should to travel, but it just doesn't display itself. When I run the same program in debug, everything works fine, meaning I can see the object travel across the screen. Am I missing a method to refresh the object in real time? I have tried self changed, etc. Thanks Barakat -- View this message in context: http://forum.world.st/Morph-does-not-refresh-or-show-tp3700516p3700516.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
You need to give the morph the time to refresh. This regularly happens in the UI process, but probably not in your case because the system is busy with other things. Have a look at how OB implements the smooth scrolling of the panes: ScrollBar>>animateValue: aNumber duration: anInteger anInteger <= 0 ifTrue: [ self setValue: aNumber ] ifFalse: [ | startTime start | startTime := Time millisecondClockValue. start := value roundTo: scrollDelta. [ | delta | [ (delta := Time millisecondClockValue - startTime) < anInteger ] whileTrue: [ self setValue: (aNumber - start) * (delta / anInteger) + start. Processor yield ]. self setValue: aNumber ] fork ] Typically morphic animations should be implemented implemented using the built-in stepping mechanism (#wantsSteps, #step, ...), but that's not always possible. Lukas On 28 July 2011 08:21, abara <barakat2@illinois.edu> wrote:
Hello,
I am having an issue where I need to refresh an object that is a subclass of RectangleMorph in a window. My object needs to travel across the screen at certain intervals.
A controller object tells this RectangleMorph object where wants it, and in turn the Rectangle object sets its new position with     self position: newX@ newY.
but the object does not show up. It does however take the exact time it should to travel, but it just doesn't display itself.
When I run the same program in debug, everything works fine, meaning I can see the object travel across the screen. Am I missing a method to refresh the object in real time? I have tried self changed, etc.
Thanks Barakat
-- View this message in context: http://forum.world.st/Morph-does-not-refresh-or-show-tp3700516p3700516.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
-- Lukas Renggli www.lukas-renggli.ch
On 28 July 2011 09:04, Lukas Renggli <renggli@gmail.com> wrote:
You need to give the morph the time to refresh. This regularly happens in the UI process, but probably not in your case because the system is busy with other things. Have a look at how OB implements the smooth scrolling of the panes:
ScrollBar>>animateValue: aNumber duration: anInteger     anInteger <= 0         ifTrue: [ self setValue: aNumber ]         ifFalse: [             | startTime start |             startTime := Time millisecondClockValue.             start := value roundTo: scrollDelta.             [ | delta |             [ (delta := Time millisecondClockValue - startTime) < anInteger ] whileTrue: [                 self setValue: (aNumber - start) * (delta / anInteger) + start.                 Processor yield ].                 self setValue: aNumber ]                     fork ]
Typically morphic animations should be implemented implemented using the built-in stepping mechanism (#wantsSteps, #step, ...), but that's not always possible.
I would say, that's the only way how morphs should animate themselves. Because if you do it otherwise (like in a loop), then you pausing a rest of processing, blocking UI etc and this is not good. A good example for morphs animation is bouncing atoms. But i'm not sure if it still residing in pharo images.
Lukas
On 28 July 2011 08:21, abara <barakat2@illinois.edu> wrote:
Hello,
I am having an issue where I need to refresh an object that is a subclass of RectangleMorph in a window. My object needs to travel across the screen at certain intervals.
A controller object tells this RectangleMorph object where wants it, and in turn the Rectangle object sets its new position with     self position: newX@ newY.
but the object does not show up. It does however take the exact time it should to travel, but it just doesn't display itself.
When I run the same program in debug, everything works fine, meaning I can see the object travel across the screen. Am I missing a method to refresh the object in real time? I have tried self changed, etc.
Thanks Barakat
-- View this message in context: http://forum.world.st/Morph-does-not-refresh-or-show-tp3700516p3700516.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
-- Lukas Renggli www.lukas-renggli.ch
-- Best regards, Igor Stasenko AKA sig.
ScrollBar>>animateValue: aNumber duration: anInteger     anInteger <= 0         ifTrue: [ self setValue: aNumber ]         ifFalse: [             | startTime start |             startTime := Time millisecondClockValue.             start := value roundTo: scrollDelta.             [ | delta |             [ (delta := Time millisecondClockValue - startTime) < anInteger ] whileTrue: [                 self setValue: (aNumber - start) * (delta / anInteger) + start.                 Processor yield ].                 self setValue: aNumber ]                     fork ]
Typically morphic animations should be implemented implemented using the built-in stepping mechanism (#wantsSteps, #step, ...), but that's not always possible.
I would say, that's the only way how morphs should animate themselves. Because if you do it otherwise (like in a loop), then you pausing a rest of processing, blocking UI etc and this is not good.
I agree, but the above code does not have that problem. In fact it works pretty well, i.e. when the system is busy/slow it just sets the end state of the animation.
A good example for morphs animation is bouncing atoms. But i'm not sure if it still residing in pharo images.
Now if somebody is looking for an interesting project I would suggest to implement CoreAnimation clone (http://en.wikipedia.org/wiki/Core_Animation). CoreAnimation is a beautiful and powerful object-oriented animation system for Cocoa. It should be strait forward to port the API, because Cocoa is essentially a nice implementation of Morphic. Lukas -- Lukas Renggli www.lukas-renggli.ch
On 28 July 2011 09:58, Lukas Renggli <renggli@gmail.com> wrote:
ScrollBar>>animateValue: aNumber duration: anInteger     anInteger <= 0         ifTrue: [ self setValue: aNumber ]         ifFalse: [             | startTime start |             startTime := Time millisecondClockValue.             start := value roundTo: scrollDelta.             [ | delta |             [ (delta := Time millisecondClockValue - startTime) < anInteger ] whileTrue: [                 self setValue: (aNumber - start) * (delta / anInteger) + start.                 Processor yield ].                 self setValue: aNumber ]                     fork ]
Typically morphic animations should be implemented implemented using the built-in stepping mechanism (#wantsSteps, #step, ...), but that's not always possible.
I would say, that's the only way how morphs should animate themselves. Because if you do it otherwise (like in a loop), then you pausing a rest of processing, blocking UI etc and this is not good.
I agree, but the above code does not have that problem. In fact it works pretty well, i.e. when the system is busy/slow it just sets the end state of the animation.
A good example for morphs animation is bouncing atoms. But i'm not sure if it still residing in pharo images.
Now if somebody is looking for an interesting project I would suggest to implement CoreAnimation clone (http://en.wikipedia.org/wiki/Core_Animation). CoreAnimation is a beautiful and powerful object-oriented animation system for Cocoa. It should be strait forward to port the API, because Cocoa is essentially a nice implementation of Morphic.
What about licensing issues?
Lukas
-- Lukas Renggli www.lukas-renggli.ch
-- Best regards, Igor Stasenko AKA sig.
Now if somebody is looking for an interesting project I would suggest to implement CoreAnimation clone (http://en.wikipedia.org/wiki/Core_Animation). CoreAnimation is a beautiful and powerful object-oriented animation system for Cocoa. It should be strait forward to port the API, because Cocoa is essentially a nice implementation of Morphic.
What about licensing issues?
I don't know. The implementation is proprietary and there is no source code available. I would just take the architecture/API as inspiration for an implementation in Smalltalk. Clutter (http://www.clutter-project.org/) and an uncountable number of Javascript libraries contain open-source implementation of such animation frameworks (LGPL though). Lukas -- Lukas Renggli www.lukas-renggli.ch
I would say, that's the only way how morphs should animate themselves. Because if you do it otherwise (like in a loop), then you pausing a rest of processing, blocking UI etc and this is not good.
I agree, but the above code does not have that problem. In fact it works pretty well, i.e. when the system is busy/slow it just sets the end state of the animation.
A good example for morphs animation is bouncing atoms. But i'm not sure if it still residing in pharo images.
Now if somebody is looking for an interesting project I would suggest to implement CoreAnimation clone (http://en.wikipedia.org/wiki/Core_Animation). CoreAnimation is a beautiful and powerful object-oriented animation system for Cocoa. It should be strait forward to port the API, because Cocoa is essentially a nice implementation of Morphic.
Thanks for the pointer. I really think that we should start to move and have sexy new stuff. I hope that soon we will be done with the basic infrastructure of Pharo (file, collection, compiler...) so that we can do more fun stuff
Lukas
-- Lukas Renggli www.lukas-renggli.ch
participants (4)
-
abara -
Igor Stasenko -
Lukas Renggli -
Stéphane Ducasse