<div dir="ltr"><div>Hi <br></div><div>I moved the previous commit to treated.</div><div><br></div><div>Threshold is same as for deleting by dropping vertices on top of each other:  3</div><div>Maybe it should be bigger to be convenient, you can test changing the value here:<br></div><div><br></div><div>
PolygonMorph>>dropVertex:event:fromHandle

</div><div>...</div><div>    (otherMorphsVertex dist: p) < 3<br>
            ifTrue: [vertices at: ix put: otherMorphsVertex]

</div><div><br></div><div><br></div><div>Best,</div><div>Karl<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Feb 4, 2020 at 8:05 PM Thiede, Christoph <<a href="mailto:Christoph.Thiede@student.hpi.uni-potsdam.de">Christoph.Thiede@student.hpi.uni-potsdam.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">



<div>

<div id="gmail-m_2355153866704816389divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<p>Wow, I did not know that you can overwrite an existing commit in the inbox :o</p>
<p><br>
</p>
<p>Unfortunately, I can't reproduce the feature. How do I use the snapping after activating it in the menu? Probably the threshold is too small for a visible effect on a 250 % DPI screen.</p>
<div id="gmail-m_2355153866704816389Signature">
<div id="gmail-m_2355153866704816389divtagdefaultwrapper" dir="ltr" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<div name="divtagdefaultwrapper">
<div>
<div id="gmail-m_2355153866704816389Item.MessagePartBody">
<div id="gmail-m_2355153866704816389Item.MessageUniqueBody" style="font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont">
<div dir="ltr">
<div id="gmail-m_2355153866704816389divtagdefaultwrapper"><font face="Calibri,Helvetica,sans-serif,EmojiFont,Apple Color Emoji,Segoe UI Emoji,NotoColorEmoji,Segoe UI Symbol,Android Emoji,EmojiSymbols">
<div id="gmail-m_2355153866704816389Signature">
<div style="margin:0px"><font style="font-family:Calibri,Arial,Helvetica,sans-serif,serif,EmojiFont"></font></div>
</div>
</font></div>
</div>
</div>
</div>
<div id="gmail-m_2355153866704816389Item.MessagePartBody"><br>
</div>
<div id="gmail-m_2355153866704816389Item.MessagePartBody">Best,</div>
<div id="gmail-m_2355153866704816389Item.MessagePartBody">Christoph</div>
</div>
<div><font size="2" color="#808080"></font></div>
</div>
</div>
</div>
</div>
<hr style="display:inline-block;width:98%">
<div id="gmail-m_2355153866704816389divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>Von:</b> Squeak-dev <<a href="mailto:squeak-dev-bounces@lists.squeakfoundation.org" target="_blank">squeak-dev-bounces@lists.squeakfoundation.org</a>> im Auftrag von karl ramberg <<a href="mailto:karlramberg@gmail.com" target="_blank">karlramberg@gmail.com</a>><br>
<b>Gesendet:</b> Dienstag, 4. Februar 2020 19:55:12<br>
<b>An:</b> The general-purpose Squeak developers list<br>
<b>Betreff:</b> Re: [squeak-dev] The Inbox: Morphic-kfr.1620.mcz</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div dir="ltr">
<div>Hi,</div>
<div>Thanks for checking.<br>
</div>
<div>The method had gone into the wrong category so it was in wrong package (Etoys). :-(<br>
</div>
<div>I'll move the method to the right category and reupload</div>
<div><br>
</div>
<div>Best,</div>
<div>Karl<br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Tue, Feb 4, 2020 at 6:34 PM Thiede, Christoph <<a href="mailto:Christoph.Thiede@student.hpi.uni-potsdam.de" target="_blank">Christoph.Thiede@student.hpi.uni-potsdam.de</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div id="gmail-m_2355153866704816389gmail-m_6314616048955877134divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<p><span style="font-size:12pt">Nice idea :-)</span><br>
</p>
<div dir="ltr">
<div id="gmail-m_2355153866704816389gmail-m_6314616048955877134x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<p><br>
</p>
<p>But when I merge this commit, it misses #<span>snapToOtherPolygonPhrase:</span></p>
<p><span><br>
</span></p>
<p><span><img size="107564" id="gmail-m_2355153866704816389gmail-m_6314616048955877134x_img321337" src="cid:17011a229a3f456b1e51" width="475" height="180"><br>
</span></p>
<p><br>
</p>
<p><span>Btw, #snapToOtherPolyongs itself is also absent in my image. Are you depending on another inbox commit?</span></p>
<p><span><br>
</span></p>
<p><span>Best,</span></p>
<p><span>Christoph</span></p>
<p><br>
</p>
<div id="gmail-m_2355153866704816389gmail-m_6314616048955877134x_Signature">
<div id="gmail-m_2355153866704816389gmail-m_6314616048955877134x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<div name="x_divtagdefaultwrapper">
<div><font size="2" color="#808080"></font></div>
</div>
</div>
</div>
</div>
<hr style="display:inline-block;width:98%">
<div id="gmail-m_2355153866704816389gmail-m_6314616048955877134x_divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>Von:</b> Squeak-dev <<a href="mailto:squeak-dev-bounces@lists.squeakfoundation.org" target="_blank">squeak-dev-bounces@lists.squeakfoundation.org</a>>
 im Auftrag von <a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a> <<a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a>><br>
<b>Gesendet:</b> Dienstag, 4. Februar 2020 17:56:00<br>
<b>An:</b> <a href="mailto:squeak-dev@lists.squeakfoundation.org" target="_blank">
squeak-dev@lists.squeakfoundation.org</a><br>
<b>Betreff:</b> [squeak-dev] The Inbox: Morphic-kfr.1620.mcz</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt">
<div>A new version of Morphic was added to project The Inbox:<br>
<a href="http://source.squeak.org/inbox/Morphic-kfr.1620.mcz" id="gmail-m_2355153866704816389gmail-m_6314616048955877134LPlnk775505" target="_blank">http://source.squeak.org/inbox/Morphic-kfr.1620.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: Morphic-kfr.1620<br>
Author: kfr<br>
Time: 4 February 2020, 5:55:31.268512 pm<br>
UUID: 741c35fd-d7ac-e54b-9199-ed1dda9e4df9<br>
Ancestors: Morphic-kfr.1619<br>
<br>
Enhancement for PolygonMorph. When a vertex is dropped it will snap if it is close to another PolygonMorphs vertex. It is possible to toggle functionality on/ off in menu<br>
<br>
=============== Diff against Morphic-kfr.1619 ===============<br>
<br>
Item was changed:<br>
  BorderedMorph subclass: #PolygonMorph<br>
+        instanceVariableNames: 'vertices closed filledForm arrows arrowForms smoothCurve curveState borderDashSpec handles borderForm snapToOtherPolygons'<br>
-        instanceVariableNames: 'vertices closed filledForm arrows arrowForms smoothCurve curveState borderDashSpec handles borderForm'<br>
         classVariableNames: ''<br>
         poolDictionaries: ''<br>
         category: 'Morphic-Basic'!<br>
  <br>
  !PolygonMorph commentStamp: 'md 2/24/2006 20:34' prior: 0!<br>
  This class implements a morph which can behave as four different objects depending on the the following two facts:<br>
  - is it OPEN or CLOSED?<br>
  - is it SEGMENTED or SMOOTHED.<br>
  <br>
  1. The OPEN and SEGMENTED variant looks like polyline.<br>
  <br>
  2. The OPEN and SMOOTHED variant looks like spline (kind of curve)<br>
  <br>
  3. The CLOSED and SEGMENTED variant looks like polygon. This is actually what you get when you do<br>
         PolygonMorph new openInWorld<br>
  You get a triangle. See below how to manipulate these objects...<br>
  <br>
  4. The CLOSED and SMOOTHED variant looks like blob (???)<br>
  <br>
  Prototypes of this morph can also be found in "Object Catalog". Several (different variants) of this object are among "Basic" morphs.<br>
  <br>
  Explore the assiciated morph-menu. It enables you<br>
  - to toggle showing of "handles". They make it possible to<br>
         - reposition already existing vertices (by moving yellow handles)<br>
         - create new vertices (by moving green handles)<br>
         - delete already existing vertices (by dragging and dropping one yellow handle closely<br>
           nearby the adjacent yellow handle<br>
    Handles can be made visible/hidden by shift+leftclicking the morph. This way it is possible<br>
    to quickly show handles, adjust vertices and then again hide handles.<br>
  - making closed polygon open, i.e. converting it to a curve (and vice versa)<br>
  - toggle smoothed/segmented line/outline<br>
  - set up custom dashing (for line, curves or borders of closed polygons<br>
  - set up custom arrow-heads (for lines resp. curves)<br>
  <br>
  ------------------------------------------------------------------------------------------<br>
  Implementation notes:<br>
  <br>
  This class combines the old Polygon and Curve classes.<br>
  <br>
  The 1-bit fillForm to make display and containment tests reasonably fast.  However, this functionality is in the process of being supplanted by balloon capabilities, which should eventually provide anti-aliasing as well.<br>
  <br>
  wiz 7/18/2004 21:26<br>
  s have made some changes to this class to<br>
  <br>
  1) correct some bugs associated with one vertex polygons.<br>
  <br>
  2) prepare for some enhancements with new curves.<br>
  <br>
  3) add shaping items to menu.!<br>
<br>
Item was changed:<br>
  ----- Method: PolygonMorph>>addCustomMenuItems:hand: (in category 'menu') -----<br>
  addCustomMenuItems: aMenu hand: aHandMorph<br>
         "Add morph-specific items to the given menu which was invoked by the given hand.  This method provides is invoked both from the halo-menu and from the control-menu regimes."<br>
  <br>
         super addCustomMenuItems: aMenu hand: aHandMorph.<br>
         aMenu addUpdating: #handlesShowingPhrase target: self action: #showOrHideHandles.<br>
         vertices size > 2 ifTrue:<br>
                 [aMenu addUpdating: #openOrClosePhrase target: self action: #makeOpenOrClosed].<br>
  <br>
         aMenu addUpdating: #smoothPhrase target: self action: #toggleSmoothing.<br>
+        aMenu addUpdating: #snapToOtherPolygonPhrase target: self action: #toggleSnapToOtherPolygons.<br>
         aMenu addLine.<br>
         aMenu add: 'specify dashed line' translated action:  #specifyDashedLine.<br>
  <br>
         self isOpen ifTrue:<br>
                 [aMenu addLine.<br>
                 aMenu addWithLabel: '---' enablement: [self isOpen and: [arrows ~~ #none]] action:  #makeNoArrows.<br>
                 aMenu addWithLabel: '-->' enablement: [self isOpen and: [arrows ~~ #forward]] action:  #makeForwardArrow.<br>
                 aMenu addWithLabel: '<--' enablement: [self isOpen and: [arrows ~~ #back]] action:  #makeBackArrow.<br>
                 aMenu addWithLabel: '<->' enablement: [self isOpen and: [arrows ~~ #both]] action:  #makeBothArrows.<br>
                 aMenu add: 'customize arrows' translated action: #customizeArrows:.<br>
                 (self hasProperty: #arrowSpec)<br>
                         ifTrue: [aMenu add: 'standard arrows' translated action: #standardArrows]].!<br>
<br>
Item was changed:<br>
  ----- Method: PolygonMorph>>dropVertex:event:fromHandle: (in category 'editing') -----<br>
+ dropVertex: ix event: evt fromHandle: handle <br>
+        "Leave vertex in new position. If dropped ontop another vertex delete<br>
+        this one.<br>
- dropVertex: ix event: evt fromHandle: handle<br>
-        "Leave vertex in new position. If dropped ontop another vertex delete this one.<br>
         Check for too few vertices before deleting. The alternative <br>
+        is not pretty -wiz"<br>
+        | p world |<br>
-                                is not pretty -wiz"<br>
-        | p |<br>
         p := vertices at: ix.<br>
+        <br>
+        "snap the dropped vertex to a vertex of another PolygonMorph if it is in near proximity"<br>
+        self isSnappingToOtherPolygons<br>
+                ifTrue: [world := Project current world.<br>
+                        world submorphs<br>
+                                do: [:each | ((each respondsTo: #vertices)<br>
+                                                        and: [each ~= self])<br>
+                                                ifTrue: [each vertices<br>
+                                                                do: [:otherMorphsVertex | (otherMorphsVertex dist: p)<br>
+                                                                                        < 3<br>
+                                                                                ifTrue: [vertices at: ix put: otherMorphsVertex]]]]].<br>
         (vertices size >= 2<br>
                         and: ["check for too few vertices before deleting. The alternative
<br>
                                 is not pretty -wiz"<br>
                                 ((vertices atWrap: ix - 1)<br>
                                                 dist: p)<br>
                                                 < 3<br>
                                         or: [((vertices atWrap: ix + 1)<br>
                                                         dist: p)<br>
                                                         < 3]])<br>
                 ifTrue: ["Drag a vertex onto its neighbor means delete"<br>
+                        self deleteVertexAt: ix].<br>
-                                self deleteVertexAt: ix .].<br>
         evt shiftPressed<br>
                 ifTrue: [self removeHandles]<br>
                 ifFalse: [self addHandles<br>
                         "remove then add to recreate"]!<br>
<br>
Item was changed:<br>
  ----- Method: PolygonMorph>>initialize (in category 'initialization') -----<br>
  initialize<br>
  "initialize the state of the receiver"<br>
         super initialize.<br>
  ""<br>
         vertices := Array<br>
                                 with: 5 @ 0<br>
                                 with: 20 @ 10<br>
                                 with: 0 @ 20.<br>
         closed := true.<br>
         smoothCurve := false.<br>
         arrows := #none.<br>
+        snapToOtherPolygons := false.<br>
         self computeBounds!<br>
<br>
Item was added:<br>
+ ----- Method: PolygonMorph>>isSnappingToOtherPolygons (in category 'access') -----<br>
+ isSnappingToOtherPolygons<br>
+   ^snapToOtherPolygons ifNil:[ snapToOtherPolygons := false].<br>
+  !<br>
<br>
Item was added:<br>
+ ----- Method: PolygonMorph>>toggleSnapToOtherPolygons (in category 'menu') -----<br>
+ toggleSnapToOtherPolygons<br>
+      ^snapToOtherPolygons := snapToOtherPolygons not!<br>
<br>
<br>
</div>
</span></font></div>
</div>
<br>
</blockquote>
</div>
</div>
</div>
</div>

<br>
</blockquote></div>