{"id":0,"registry":{"0":{"submorphs":[],"scripts":[],"id":"ADD0B5C0-0DC6-4D8E-9C2A-0EC7E3C71F21","shape":{"__isSmartRef__":true,"id":1},"droppingEnabled":true,"halosEnabled":true,"registeredForMouseEvents":true,"_Position":{"__isSmartRef__":true,"id":8},"showsHalos":false,"name":"ResizeCorner","partsBinMetaInfo":{"__isSmartRef__":true,"id":9},"__SourceModuleName__":"Global.lively.morphic.Core","draggingEnabled":true,"dragStartPoint":null,"originalExtent":{"__isSmartRef__":true,"id":12},"originalTargetExtent":null,"renderContextTable":{"__isSmartRef__":true,"id":13},"eventHandler":{"__isSmartRef__":true,"id":14},"priorExtent":{"__isSmartRef__":true,"id":15},"originalTargetInnerBounds":null,"isResizeCorner":true,"relativeOrigin":null,"derivationIds":[7147,"16E962DF-21E9-4FE6-8B9B-953F0E908113"],"moved":true,"attributeConnections":[{"__isSmartRef__":true,"id":16}],"doNotSerialize":["$$cornerName"],"doNotCopyProperties":["$$cornerName"],"originalTargetBounds":null,"cornerName":"bottomRight","_Rotation":0,"_Scale":1,"__serializedLivelyClosures__":{"__isSmartRef__":true,"id":17},"__LivelyClassName__":"lively.morphic.Box"},"1":{"position":{"__isSmartRef__":true,"id":2},"_Extent":{"__isSmartRef__":true,"id":3},"_BorderWidth":0,"_BorderColor":{"__isSmartRef__":true,"id":4},"_Fill":{"__isSmartRef__":true,"id":5},"__SourceModuleName__":"Global.lively.morphic.Shapes","renderContextTable":{"__isSmartRef__":true,"id":6},"_ClipMode":"visible","_Padding":{"__isSmartRef__":true,"id":7},"__LivelyClassName__":"lively.morphic.Shapes.Rectangle"},"2":{"x":0,"y":0,"__SourceModuleName__":"Global.lively.morphic.Graphics","__LivelyClassName__":"Point"},"3":{"x":10,"y":10,"__SourceModuleName__":"Global.lively.morphic.Graphics","__LivelyClassName__":"Point"},"4":{"r":0.568,"g":0.568,"b":0.568,"a":1,"__SourceModuleName__":"Global.lively.morphic.Graphics","__LivelyClassName__":"Color"},"5":{"r":0.258,"g":0.258,"b":0.258,"a":1,"__LivelyClassName__":"Color","__SourceModuleName__":"Global.lively.morphic.Graphics"},"6":{"init":"initHTML","appendShape":"renderHTML","setPosition":"setPositionHTML","setExtent":"setExtentHTML","setPadding":"setPaddingHTML","setFill":"setFillHTML","setBorderColor":"setBorderColorHTML","setBorderWidth":"setBorderWidthHTML","setStrokeOpacity":"setStrokeOpacityHTML","setBorderRadius":"setBorderRadiusHTML","setBorderStyle":"setBorderStyleHTML","setOpacity":"setOpacityHTML","setClipMode":"setClipModeHTML"},"7":{"x":0,"y":0,"width":0,"height":0,"__SourceModuleName__":"Global.lively.morphic.Graphics","__LivelyClassName__":"Rectangle"},"8":{"x":0,"y":0,"__LivelyClassName__":"Point","__SourceModuleName__":"Global.lively.morphic.Graphics"},"9":{"partsSpaceName":"PartsBin/Widgets/","__SourceModuleName__":"Global.lively.PartsBin","migrationLevel":4,"comment":"Resize an object without using halos.","partName":"ResizeCorner","changes":[{"__isSmartRef__":true,"id":10}],"__LivelyClassName__":"lively.PartsBin.PartsBinMetaInfo"},"10":{"date":{"__isSmartRef__":true,"id":11},"author":"sstamm","message":"preserves layout (submorphs are scaling if they are supposed to scale)","id":"33F1A8EA-C548-40BA-A776-53952F0A78C1"},"11":{"isSerializedDate":true,"string":"Thu Feb 23 2012 12:11:51 GMT+0100 (W. Europe Standard Time)"},"12":{"x":239,"y":138,"__SourceModuleName__":"Global.lively.morphic.Graphics","__LivelyClassName__":"Point"},"13":{"replaceRenderContext":"replaceRenderContextHTML","init":"initHTML","append":"appendHTML","remove":"removeHTML","triggerEvent":"triggerEventHTML","setTransform":"setTransformHTML","setPosition":"setPositionHTML","setRotation":"setRotationHTML","setExtent":"setExtentHTML","setScale":"setScaleHTML","setVisible":"setVisibleHTML","adjustOrigin":"adjustOriginHTML","setPivotPoint":"setPivotPointHTML","setClipMode":"setClipModeHTML","showsVerticalScrollBar":"showsVerticalScrollBarHTML","showsHorizontalScrollBar":"showsHorizontalScrollBarHTML","getScrollBarExtent":"getScrollBarExtentHTML","setHandStyle":"setHandStyleHTML","setPointerEvents":"setPointerEventsHTML","setToolTip":"setToolTipHTML","focus":"focusHTML","blur":"blurHTML","setFocusable":"setFocusableHTML"},"14":{"morph":{"__isSmartRef__":true,"id":0},"__SourceModuleName__":"Global.lively.morphic.Events","__LivelyClassName__":"lively.morphic.EventHandler"},"15":{"x":10,"y":10,"__SourceModuleName__":"Global.lively.morphic.Graphics","__LivelyClassName__":"Point"},"16":{"sourceObj":{"__isSmartRef__":true,"id":0},"sourceAttrName":"cornerName","targetObj":{"__isSmartRef__":true,"id":0},"targetMethodName":"alignToOwner","__SourceModuleName__":"Global.lively.bindings","__LivelyClassName__":"AttributeConnection"},"17":{"onDrag":{"__isSmartRef__":true,"id":18},"onDragEnd":{"__isSmartRef__":true,"id":26},"onDragStart":{"__isSmartRef__":true,"id":34},"reset":{"__isSmartRef__":true,"id":42},"morphMenuItems":{"__isSmartRef__":true,"id":45},"alignToOwner":{"__isSmartRef__":true,"id":52}},"18":{"varMapping":{"__isSmartRef__":true,"id":19},"source":"function onDrag(evt) {\n    // alert(\"onDrag\")\n    // this.owner.setPosition(pt(0,0))\n    // this.owner.setOrigin(pt(0,0))\n    var moveDelta = evt.mousePoint.subPt(this.dragStartPoint)\n    \n    // moveDelta = moveDelta.maxPt(pt(0,0))\n    var ownerExtent = this.owner.getExtent();\n\n    // TODO does not work\n    if (evt.isShiftDown()) {\n        var maxDelta = Math.max(moveDelta.x, moveDelta.y);\n        if (maxDelta == 0) return;\n        var factor = ownerExtent.x /  ownerExtent.y\n        moveDelta = pt(maxDelta * factor, maxDelta )\n    }\n    var accessor = \"with\" + this.cornerName.charAt(0).toUpperCase() + this.cornerName.substring(1);\n\n    var newCorner = this.originalTargetBounds[this.cornerName]().addPt(moveDelta);\n    var newBounds = this.originalTargetBounds[accessor ](newCorner);\n\n    this.owner.setBounds(newBounds);\n   \n    // var newExtent = this.originalTargetExtent.addPt(moveDelta)\n    // alertOK(\"new extent\" + newExtent)\n    // this.owner.setExtent(newExtent);\n    this.owner.submorphs.select(function(ea) {\n        return ea.isResizeCorner\n    }).invoke('alignToOwner');\n    if (this.owner.halos) {\n        this.owner.halos.invoke('alignAtTarget')\n    }\n    // alertOK(\"relative \" + this.relativeOrigin)\n    var newOrigin =  pt(0,0).extent(this.owner.getExtent()).relativeToAbsPoint(this.relativeOrigin)\n\n    // TODO IMPLEMENT updating the origin does not work yet\n    // this.owner.setOrigin(newOrigin);\n    // alertOK(\"new origin \" + newOrigin)\n\n}","funcProperties":{"__isSmartRef__":true,"id":24},"__SourceModuleName__":"Global.lively.lang.Closure","__LivelyClassName__":"lively.Closure"},"19":{"this":{"__isSmartRef__":true,"id":0},"__serializedLivelyClosures__":{"__isSmartRef__":true,"id":20}},"20":{"$super":{"__isSmartRef__":true,"id":21}},"21":{"varMapping":{"__isSmartRef__":true,"id":22},"source":"function () {\n                    try {\n                        return obj.constructor.prototype[name].apply(obj, arguments)\n                    } catch (e) {\n                        alert('Error in $super call: ' + e + '\\n' + e.stack);\n                        return null;\n                    }\n                }","funcProperties":{"__isSmartRef__":true,"id":23},"__SourceModuleName__":"Global.lively.lang.Closure","__LivelyClassName__":"lively.Closure"},"22":{"obj":{"__isSmartRef__":true,"id":0},"name":"onDrag"},"23":{},"24":{"timestamp":{"__isSmartRef__":true,"id":25},"user":"sstamm","tags":[]},"25":{"isSerializedDate":true,"string":"Thu Feb 23 2012 12:08:52 GMT+0100 (W. Europe Standard Time)"},"26":{"varMapping":{"__isSmartRef__":true,"id":27},"source":"function onDragEnd(evt) {\n    this.dragStartPoint = null;\n    this.originalTargetBounds = null;\n    this.relativeOrigin = null;\n}","funcProperties":{"__isSmartRef__":true,"id":32},"__SourceModuleName__":"Global.lively.lang.Closure","__LivelyClassName__":"lively.Closure"},"27":{"this":{"__isSmartRef__":true,"id":0},"__serializedLivelyClosures__":{"__isSmartRef__":true,"id":28}},"28":{"$super":{"__isSmartRef__":true,"id":29}},"29":{"varMapping":{"__isSmartRef__":true,"id":30},"source":"function () {\n                    try {\n                        return obj.constructor.prototype[name].apply(obj, arguments)\n                    } catch (e) {\n                        alert('Error in $super call: ' + e + '\\n' + e.stack);\n                        return null;\n                    }\n                }","funcProperties":{"__isSmartRef__":true,"id":31},"__SourceModuleName__":"Global.lively.lang.Closure","__LivelyClassName__":"lively.Closure"},"30":{"obj":{"__isSmartRef__":true,"id":0},"name":"onDragEnd"},"31":{},"32":{"timestamp":{"__isSmartRef__":true,"id":33},"user":"sstamm","tags":[]},"33":{"isSerializedDate":true,"string":"Thu Feb 23 2012 12:09:00 GMT+0100 (W. Europe Standard Time)"},"34":{"varMapping":{"__isSmartRef__":true,"id":35},"source":"function onDragStart(evt) {\n    var absToRelativePoint =  function (r, absPt) {\n\t\treturn new Point(\n\t\t\t(absPt.x - r.x) / r.width,\n\t\t\t(absPt.y - r.y) / r.height)\n\t}\n    // absToRelativePoint(new Rectangle(10,10,100,100), pt(20,20))\n    // absToRelativePoint(new Rectangle(10,10,100,100), pt(0,0))\n    // absToRelativePoint(new Rectangle(-100,-100,200,200), pt(0,0))\n\n\n    this.dragStartPoint = evt.mousePoint;\n    this.originalTargetBounds= this.owner.bounds();\n    this.relativeOrigin =  absToRelativePoint(pt(0,0).extent(this.owner.getExtent()), this.owner.getOrigin())\n}","funcProperties":{"__isSmartRef__":true,"id":40},"__SourceModuleName__":"Global.lively.lang.Closure","__LivelyClassName__":"lively.Closure"},"35":{"this":{"__isSmartRef__":true,"id":0},"__serializedLivelyClosures__":{"__isSmartRef__":true,"id":36}},"36":{"$super":{"__isSmartRef__":true,"id":37}},"37":{"varMapping":{"__isSmartRef__":true,"id":38},"source":"function () {\n                    try {\n                        return obj.constructor.prototype[name].apply(obj, arguments)\n                    } catch (e) {\n                        alert('Error in $super call: ' + e + '\\n' + e.stack);\n                        return null;\n                    }\n                }","funcProperties":{"__isSmartRef__":true,"id":39},"__SourceModuleName__":"Global.lively.lang.Closure","__LivelyClassName__":"lively.Closure"},"38":{"obj":{"__isSmartRef__":true,"id":0},"name":"onDragStart"},"39":{},"40":{"timestamp":{"__isSmartRef__":true,"id":41},"user":"sstamm","tags":[]},"41":{"isSerializedDate":true,"string":"Thu Feb 23 2012 12:08:40 GMT+0100 (W. Europe Standard Time)"},"42":{"varMapping":{"__isSmartRef__":true,"id":43},"source":"function reset() {\n    this.isResizeCorner = true\n    this.cornerName = 'bottomRight'\n    this.setExtent(pt(10,10));\n    this.setPosition(pt(0,0))\n}","funcProperties":{"__isSmartRef__":true,"id":44},"__SourceModuleName__":"Global.lively.lang.Closure","__LivelyClassName__":"lively.Closure"},"43":{"this":{"__isSmartRef__":true,"id":0}},"44":{},"45":{"varMapping":{"__isSmartRef__":true,"id":46},"source":"function morphMenuItems() {\n    return $super().concat([\n        [\"corner\", [\n            [\"top left\", function() { this.cornerName = 'topLeft'}.bind(this)],\n            [\"top right\", function() { this.cornerName = 'topRight'}.bind(this)],\n            [\"bottom right\", function() { this.cornerName = 'bottomRight'}.bind(this)],\n            [\"bottom left\", function() { this.cornerName = 'bottomLeft'}.bind(this)],\n        ]]\n    ])\t\n}","funcProperties":{"__isSmartRef__":true,"id":51},"__SourceModuleName__":"Global.lively.lang.Closure","__LivelyClassName__":"lively.Closure"},"46":{"this":{"__isSmartRef__":true,"id":0},"__serializedLivelyClosures__":{"__isSmartRef__":true,"id":47}},"47":{"$super":{"__isSmartRef__":true,"id":48}},"48":{"varMapping":{"__isSmartRef__":true,"id":49},"source":"function () {\n\t\t\t\ttry {\n\t\t\t\t\treturn obj.constructor.prototype[name].apply(obj, arguments)\n\t\t\t\t} catch(e) {\n\t\t\t\t\talert('Error in $super call: ' + e + '\\n' + e.stack);\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}","funcProperties":{"__isSmartRef__":true,"id":50},"__SourceModuleName__":"Global.lively.lang.Closure","__LivelyClassName__":"lively.Closure"},"49":{"obj":{"__isSmartRef__":true,"id":0},"name":"morphMenuItems"},"50":{},"51":{},"52":{"varMapping":{"__isSmartRef__":true,"id":53},"source":"function alignToOwner() {\n    this.align(this.bounds()[this.cornerName](), this.owner.shape.bounds()[this.cornerName]() )\n}","funcProperties":{"__isSmartRef__":true,"id":54},"__SourceModuleName__":"Global.lively.lang.Closure","__LivelyClassName__":"lively.Closure"},"53":{"this":{"__isSmartRef__":true,"id":0}},"54":{},"isSimplifiedRegistry":true}}