Morphic magician requested. What is referencePosition?

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

Morphic magician requested. What is referencePosition?

Aliaksei Syrel
Hi

Do anyone know what is Morph>>#referencePosition and why is it used to handle drag and drop?

Here is what method doc says:
"Return the current reference position of the receiver"

Thanks,
Alex
Reply | Threaded
Open this post in threaded view
|

Re: Morphic magician requested. What is referencePosition?

Thierry Goubier
The center of the morph usually? Or sometime another point of importance for that morph (the tip of an arrow)?

Reference point for rotating the morph :)

In drag and drop, allow one to set the position of the dropped morph into the coordinates of the dropped into morph. Probably needed because of the transform morphs...

Thierry

2016-01-27 16:11 GMT+01:00 Aliaksei Syrel <[hidden email]>:
Hi

Do anyone know what is Morph>>#referencePosition and why is it used to handle drag and drop?

Here is what method doc says:
"Return the current reference position of the receiver"

Thanks,
Alex

Reply | Threaded
Open this post in threaded view
|

Re: Morphic magician requested. What is referencePosition?

Henrik Nergaard
In reply to this post by Aliaksei Syrel

#referencePostion returns the specified center for the morph in global coordinates.

By default this will be the same as “self bounds origin + (self bounds extent/2.0)” but can have other depending on what #rotationCenter returns.

 

#referencePositon: on the other hand do not set a new centre, but moves the morph to a new position by using the referencePosition as origin instead of its top left corner.

 

Example:

 

 

| m |

 

m := Morph new

               color: Color orange;

               extent: 200@72;

               openCenteredInWorld;

               yourself.

              

m on: #click send: #value to: [ m referencePosition: (m referencePosition + (10@10)) ]   .

 

Looking at Morph>>#handleDropMorph: referencePosition is used to place the dropped morph in centre of the new owner.

 

observation:

‘(self transformedFrom: anEvent hand world) globalPointToLocal: aMorph referencePosition’ looks incomplete as it will always be equal to just doing ‘aMorph referencePosition’ because #transformedFrom: always returns an IdentityTransform where # globalPointToLocal: just returns the point given to it.

 

Best regards,

Henrik

 

From: Pharo-dev [mailto:[hidden email]] On Behalf Of Aliaksei Syrel
Sent: Wednesday, January 27, 2016 4:12 PM
To: Pharo Development List <[hidden email]>
Subject: [Pharo-dev] Morphic magician requested. What is referencePosition?

 

Hi

 

Do anyone know what is Morph>>#referencePosition and why is it used to handle drag and drop?

 

Here is what method doc says:

"Return the current reference position of the receiver"

 

Thanks,

Alex

Reply | Threaded
Open this post in threaded view
|

Re: Morphic magician requested. What is referencePosition?

Henrik Nergaard

 

 

From: Pharo-dev [mailto:[hidden email]] On Behalf Of Henrik Nergaard
Sent: Wednesday, January 27, 2016 4:47 PM
To: Pharo Development List <[hidden email]>
Subject: Re: [Pharo-dev] Morphic magician requested. What is referencePosition?

 

#referencePostion returns the specified center for the morph in global coordinates.

By default this will be the same as “self bounds origin + (self bounds extent/2.0)” but can have other depending on what #rotationCenter returns.

 

#referencePositon: on the other hand do not set a new centre, but moves the morph to a new position by using the referencePosition as origin instead of its top left corner.

 

Example:

 

 

| m |

 

m := Morph new

               color: Color orange;

               extent: 200@72;

               openCenteredInWorld;

               yourself.

              

m on: #click send: #value to: [ m referencePosition: (m referencePosition + (10@10)) ]   .

 

Looking at Morph>>#handleDropMorph: referencePosition is used to place the dropped morph in centre of the new owner.

 

observation:

‘(self transformedFrom: anEvent hand world) globalPointToLocal: aMorph referencePosition’ looks incomplete as it will always be equal to just doing ‘aMorph referencePosition’ because #transformedFrom: always returns an IdentityTransform where # globalPointToLocal: just returns the point given to it.

 

Correction:

 

#transformedFrom: translates the dropped morph “center” to the receiving morph local coordinates (local from the owning transformationMorph) if it has an owner which is a transformation type Morph (see implementors #tranformFrom:) .

 

 

 

Best regards,

Henrik

 

From: Pharo-dev [[hidden email]] On Behalf Of Aliaksei Syrel
Sent: Wednesday, January 27, 2016 4:12 PM
To: Pharo Development List <[hidden email]>
Subject: [Pharo-dev] Morphic magician requested. What is referencePosition?

 

Hi

 

Do anyone know what is Morph>>#referencePosition and why is it used to handle drag and drop?

 

Here is what method doc says:

"Return the current reference position of the receiver"

 

Thanks,

Alex

Reply | Threaded
Open this post in threaded view
|

Re: Morphic magician requested. What is referencePosition?

Aliaksei Syrel
Aha, understood!
Thanks a lot :)

Cheers,
Alex

On Wed, Jan 27, 2016 at 5:04 PM, Henrik Nergaard <[hidden email]> wrote:

 

 

From: Pharo-dev [mailto:[hidden email]] On Behalf Of Henrik Nergaard
Sent: Wednesday, January 27, 2016 4:47 PM
To: Pharo Development List <[hidden email]>
Subject: Re: [Pharo-dev] Morphic magician requested. What is referencePosition?

 

#referencePostion returns the specified center for the morph in global coordinates.

By default this will be the same as “self bounds origin + (self bounds extent/2.0)” but can have other depending on what #rotationCenter returns.

 

#referencePositon: on the other hand do not set a new centre, but moves the morph to a new position by using the referencePosition as origin instead of its top left corner.

 

Example:

 

 

| m |

 

m := Morph new

               color: Color orange;

               extent: 200@72;

               openCenteredInWorld;

               yourself.

              

m on: #click send: #value to: [ m referencePosition: (m referencePosition + (10@10)) ]   .

 

Looking at Morph>>#handleDropMorph: referencePosition is used to place the dropped morph in centre of the new owner.

 

observation:

‘(self transformedFrom: anEvent hand world) globalPointToLocal: aMorph referencePosition’ looks incomplete as it will always be equal to just doing ‘aMorph referencePosition’ because #transformedFrom: always returns an IdentityTransform where # globalPointToLocal: just returns the point given to it.

 

Correction:

 

#transformedFrom: translates the dropped morph “center” to the receiving morph local coordinates (local from the owning transformationMorph) if it has an owner which is a transformation type Morph (see implementors #tranformFrom:) .

 

 

 

Best regards,

Henrik

 

From: Pharo-dev [[hidden email]] On Behalf Of Aliaksei Syrel
Sent: Wednesday, January 27, 2016 4:12 PM
To: Pharo Development List <[hidden email]>
Subject: [Pharo-dev] Morphic magician requested. What is referencePosition?

 

Hi

 

Do anyone know what is Morph>>#referencePosition and why is it used to handle drag and drop?

 

Here is what method doc says:

"Return the current reference position of the receiver"

 

Thanks,

Alex