World to Morph Local Co-ordinates

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

World to Morph Local Co-ordinates

Sean P. DeNigris
Administrator
I'm sure this must be addressed somewhere, but searching the archives for "morph local point" didn't produce anything helpful…

I have a PasteUpMorph that represents a scaled down world. So when a morph sets its position to e.g. 0@0, I want to set it to the topLeft corner of the pasteUp. I can use align:with:, but I thought some of the following might have some usefulness, but all returned 0@0. None of them have tests...
        screen globalPointToLocal: (0@0).
        screen localPointToGlobal: (0@0).
        screen pointInWorld: (0@0).
        screen referencePositionInWorld: (0@0).
        screen point: 0@0 from: screen.

Is there an easy built-in way to convert points from World to the bounds of another (assume rectangular) morph?

Thanks.
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: World to Morph Local Co-ordinates

Igor Stasenko



On 8 January 2014 19:54, Sean P. DeNigris <[hidden email]> wrote:
I'm sure this must be addressed somewhere, but searching the archives for
"morph local point" didn't produce anything helpful…

I have a PasteUpMorph that represents a scaled down world. So when a morph
sets its position to e.g. 0@0, I want to set it to the topLeft corner of the
pasteUp. I can use align:with:, but I thought some of the following might
have some usefulness, but all returned 0@0. None of them have tests...
        screen globalPointToLocal: (0@0).
        screen localPointToGlobal: (0@0).
        screen pointInWorld: (0@0).
        screen referencePositionInWorld: (0@0).
        screen point: 0@0 from: screen.

perhaps if you pick some morph, which (sub)chile of some TransformMorph,
you will be able to see the difference.
but for screen/world zero is always zero, because there is no difference between local and global , since its transformation is identity :)
 
Is there an easy built-in way to convert points from World to the bounds of
another (assume rectangular) morph?

piece of cake, since all morphs use same, global coordinates, simple subtraction works:
 
localpoint := globalpoint - morph topLeft
 
Thanks.



-----
Cheers,
Sean
--
View this message in context: http://forum.world.st/World-to-Morph-Local-Co-ordinates-tp4735247.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.




--
Best regards,
Igor Stasenko.
Reply | Threaded
Open this post in threaded view
|

Re: World to Morph Local Co-ordinates

Markus Schlager-2
In reply to this post by Sean P. DeNigris
Maybe this thread gives some pointer:

http://lists.pharo.org/pipermail/pharo-users_lists.pharo.org/2013-September/008493.html

I tend to call this a bug - at least it's not the expected behavior of
embedded morphs IMO.

Markus


Reply | Threaded
Open this post in threaded view
|

Re: World to Morph Local Co-ordinates

Sean P. DeNigris
Administrator
Interesting thread - thanks!
Cheers,
Sean