move methods accessing LayoutFrame to libview2
authorStefan Vogel <sv@exept.de>
Fri, 29 Jun 2018 17:59:59 +0200
changeset 4139 6dffe5499f3b
parent 4138 6300b7e324a4
child 4141 9ddbf1c9d178
move methods accessing LayoutFrame to libview2
extensions.st
--- a/extensions.st	Fri Jun 29 17:59:07 2018 +0200
+++ b/extensions.st	Fri Jun 29 17:59:59 2018 +0200
@@ -15,6 +15,63 @@
     "
 ! !
 
+!Point methodsFor:'converting'!
+
+asFractionalLayout
+    "return a LayoutOrigin from the receiver,
+     treating the receiver coordinates as fractional parts
+     (i.e. relative to superview).
+     Notice: in 10.5.x LayoutOrigin is not yet officially released."
+
+    ^ LayoutOrigin fractionalFromPoint:self
+
+    "
+     (0@0.5) asFractionalLayout
+     (0@0.5) asLayout
+     (0@10) asLayout
+     (0@10) asOffsetLayout
+    "
+
+! !
+
+!Point methodsFor:'converting'!
+
+asLayout
+    "return a LayoutOrigin from the receiver.
+     If the receiver coordinates are between 0 and 1, take
+     them as fractional parts (relative to superview).
+     Otherwise, treat them as absolute offsets.
+     Notice: in 10.5.x LayoutOrigin is not yet released."
+
+    ^ LayoutOrigin fromPoint:self
+
+    "
+     (0@0.5) asFractionalLayout
+     (0@0.5) asLayout
+     (0@10) asLayout
+     (0@10) asOffsetLayout
+    "
+
+! !
+
+!Point methodsFor:'converting'!
+
+asOffsetLayout
+    "return a LayoutOrigin from the receiver,
+     treating the receiver coordinates as absolute offsets.
+     Notice: in 10.5.x LayoutOrigin is not yet released."
+
+    ^ LayoutOrigin offsetFromPoint:self
+
+    "
+     (0@0.5) asFractionalLayout
+     (0@0.5) asLayout
+     (0@10) asLayout
+     (0@10) asOffsetLayout
+    "
+
+! !
+
 !stx_libview2 class methodsFor:'documentation'!
 
 extensionsVersion_CVS