Relative position of submorph

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

Relative position of submorph

Ulrich Vollert
Hi,

I am doing my first steps with Pharo, and I am deeply impressed and amazed about this wonderful development world of Smalltalk. Thanks to all developers who made Pharo available!

As my first project, I am trying to develop an animation and want to animate a subclass of ImageMorph named PlaneMorph in a StandardWindow.

I defined a method PlaneMorph>>step which calculates new positions like:

        step
                ....
                self position: newPosition
       

When adding my PlaneMorph to a StandardWindow like

        window addMorph: PlaneMorph new

the coordinates are not relative (inside) of the window but relative to the main window of Pharo.

My solution to position PlaneMorph relative to the position of the StandardWindow:

I tell the PlaneMorph to which surrounding window it belongs (PlaneMorph new window: window), store the window in an instance variable of PlaneMorph and positon it in PlaneMorph>>step relative  to the window as

        self position: newPosition + window position

Is this solution good design?

I wonder whether it is a good idea that the PlaneMorph knows about the window.

Regards,
Ulrich