Repository: flex-asjs Updated Branches: refs/heads/develop 7965c6de2 -> 88f0bcbe0
Added AbsolutePositioningViewBeadBase so control components can position their sub-elements using absolute positioning. Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/88f0bcbe Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/88f0bcbe Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/88f0bcbe Branch: refs/heads/develop Commit: 88f0bcbe0728e2831e097a1b9593f835cf3c564d Parents: 7965c6d Author: Peter Ent <[email protected]> Authored: Wed May 3 13:08:08 2017 -0400 Committer: Peter Ent <[email protected]> Committed: Wed May 3 13:08:08 2017 -0400 ---------------------------------------------------------------------- .../Basic/src/main/flex/BasicClasses.as | 1 + .../beads/AbsolutePositioningViewBeadBase.as | 113 +++++++++++++++++++ 2 files changed, 114 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/88f0bcbe/frameworks/projects/Basic/src/main/flex/BasicClasses.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/BasicClasses.as b/frameworks/projects/Basic/src/main/flex/BasicClasses.as index 4436e43..c7655cc 100644 --- a/frameworks/projects/Basic/src/main/flex/BasicClasses.as +++ b/frameworks/projects/Basic/src/main/flex/BasicClasses.as @@ -32,6 +32,7 @@ internal class BasicClasses import org.apache.flex.html.beads.DispatchInputFinishedBead; DispatchInputFinishedBead; import org.apache.flex.html.accessories.PasswordInputBead; PasswordInputBead; import org.apache.flex.html.accessories.TextPromptBead; TextPromptBead; + import org.apache.flex.html.beads.AbsolutePositioningViewBeadBase; AbsolutePositioningViewBeadBase; import org.apache.flex.html.beads.AlertView; AlertView; import org.apache.flex.html.beads.models.AlertModel; AlertModel; COMPILE::SWF http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/88f0bcbe/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/AbsolutePositioningViewBeadBase.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/AbsolutePositioningViewBeadBase.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/AbsolutePositioningViewBeadBase.as new file mode 100644 index 0000000..4843e44 --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/AbsolutePositioningViewBeadBase.as @@ -0,0 +1,113 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.beads +{ + import org.apache.flex.core.IBeadView; + import org.apache.flex.core.IChild; + import org.apache.flex.core.IStrand; + import org.apache.flex.core.IUIBase; + + /** + * Use AbsolutePositioningViewBeadBase as the base class for custom control view beads. + * This class sets the strand's position style to "relative" (HTML platform) if it is + * not already set to either "absolute" or "relative". Then use this class's + * setAbsolutePosition(child, x, y) function to place children. The function not + * only set's the child's left and top styles (HTML platform), it also sets the child's + * position to "absolute" (HTML platform). + * + * On the Flash platform, this class will only set the child's x and y properties without + * any other side effects. + * + * @viewbead + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.8 + */ + public class AbsolutePositioningViewBeadBase implements IBeadView + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.8 + */ + public function AbsolutePositioningViewBeadBase() + { + super(); + } + + protected var _strand:IStrand; + + /** + * @copy org.apache.flex.core.IBeaViewd#host + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.8 + */ + public function get host():IUIBase + { + return IUIBase(_strand); + } + + /** + * @copy org.apache.flex.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.8 + */ + public function set strand(value:IStrand):void + { + _strand = value; + + COMPILE::JS { + if (host.element.style.position != "absolute" && host.element.style.position != "relative") { + host.element.style.position = "relative"; + } + } + } + + /** + * Sets the position of the child and, on the HTML platform, sets the child's position style + * value to "absolute". + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.8 + */ + public function setAbsolutePosition(child:IChild, x:Number, y:Number):void + { + var childHost:IUIBase = IUIBase(child); + + childHost.x = x; + childHost.y = y; + + COMPILE::JS { + childHost.element.style.position = "absolute"; + } + } + } +} \ No newline at end of file
