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
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 <alex.syrel@gmail.com>:
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
#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:pharo-dev-bounces@lists.pharo.org] On Behalf Of Aliaksei Syrel Sent: Wednesday, January 27, 2016 4:12 PM To: Pharo Development List <pharo-dev@lists.pharo.org> 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
From: Pharo-dev [mailto:pharo-dev-bounces@lists.pharo.org] On Behalf Of Henrik Nergaard Sent: Wednesday, January 27, 2016 4:47 PM To: Pharo Development List <pharo-dev@lists.pharo.org> 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 [mailto:pharo-dev-bounces@lists.pharo.org] On Behalf Of Aliaksei Syrel Sent: Wednesday, January 27, 2016 4:12 PM To: Pharo Development List <pharo-dev@lists.pharo.org<mailto:pharo-dev@lists.pharo.org>> 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
Aha, understood! Thanks a lot :) Cheers, Alex On Wed, Jan 27, 2016 at 5:04 PM, Henrik Nergaard <henrik.nergaard@uia.no> wrote:
*From:* Pharo-dev [mailto:pharo-dev-bounces@lists.pharo.org] *On Behalf Of *Henrik Nergaard *Sent:* Wednesday, January 27, 2016 4:47 PM *To:* Pharo Development List <pharo-dev@lists.pharo.org> *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 [mailto:pharo-dev-bounces@lists.pharo.org <pharo-dev-bounces@lists.pharo.org>] *On Behalf Of *Aliaksei Syrel *Sent:* Wednesday, January 27, 2016 4:12 PM *To:* Pharo Development List <pharo-dev@lists.pharo.org> *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
participants (3)
-
Aliaksei Syrel -
Henrik Nergaard -
Thierry Goubier