You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@royale.apache.org by GitBox <gi...@apache.org> on 2018/04/03 06:40:41 UTC

[GitHub] alinakazi closed pull request #142: Added HRule and VRule

alinakazi closed pull request #142: Added HRule and VRule 
URL: https://github.com/apache/royale-asjs/pull/142
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as b/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
index d27891fac..09b18c7d1 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
@@ -33,7 +33,8 @@ internal class MXRoyaleClasses
 	import mx.containers.beads.BoxLayout; BoxLayout;
 	import mx.controls.ToolTip; ToolTip;
 	import mx.controls.beads.ToolTipBead; ToolTipBead;
-	
+	import mx.controls.VRule; VRule;
+	import mx.controls.HRule; HRule;
     COMPILE::SWF
     {
         import mx.controls.beads.CSSImageAndTextButtonView; CSSImageAndTextButtonView;
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/HRule.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/HRule.as
new file mode 100644
index 000000000..7c7f38d89
--- /dev/null
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/HRule.as
@@ -0,0 +1,283 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 mx.controls
+{
+
+/* import flash.display.Graphics;
+ */import mx.core.UIComponent;
+
+//--------------------------------------
+//  Styles
+//--------------------------------------
+
+/**
+ *  The shadow color of the line. 
+ *  <ul>
+ *    <li>If <code>strokeWidth</code> is 1, shadowColor
+ *    does nothing.</li>
+ *    <li>If <code>strokeWidth</code> is 2, shadowColor is
+ *    the color of the bottom line.</li>
+ *    <li>If <code>strokeWidth</code> is greater than 2, shadowColor
+ *    is the color of the bottom and right edges of the rectangle.</li>
+ *  </ul>
+ * 
+ *  @default 0xEEEEEE
+ *  
+ *  @langversion 3.0
+ *  @playerversion Flash 9
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+[Style(name="shadowColor", type="uint", format="Color", inherit="yes")]
+
+/**
+ *  The color of the line. 
+ *  <ul>
+ *    <li>If <code>strokeWidth</code> is 1, strokeColor is
+ *    the color of the entire line.</li>
+ *    <li>If <code>strokeWidth</code> is 2, strokeColor is 
+ *    the color of the top line.</li>
+ *    <li>If <code>strokeWidth</code> is greater than 2, strokeColor is
+ *    the color of the top and left edges of the rectangle.</li>
+ *  </ul> 
+ *  
+ *  @default 0xC4CCCC
+ *  
+ *  @langversion 3.0
+ *  @playerversion Flash 9
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+[Style(name="strokeColor", type="uint", format="Color", inherit="yes")]
+
+/**
+ *  The thickness of the rule in pixels.
+ *  <ul>
+ *    <li>If <code>strokeWidth</code> is 1,
+ *    the rule is a 1-pixel-wide line.</li>
+ *    <li>If <code>strokeWidth</code> is 2,
+ *    the rule is two adjacent 1-pixel-wide horizontal lines.</li>
+ *    <li>If <code>strokeWidth</code> is greater than 2,
+ *    the rule is a hollow rectangle with 1-pixel-wide edges.</li>
+ *  </ul>
+ * 
+ *  @default 2
+ *  
+ *  @langversion 3.0
+ *  @playerversion Flash 9
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+[Style(name="strokeWidth", type="Number", format="Length", inherit="yes")]
+    // Note: stroke-width is inheriting in SVG,
+    // although border-width is not inheriting in CSS
+
+//--------------------------------------
+//  Other metadata
+//--------------------------------------
+
+/* [IconFile("HRule.png")]
+
+[Alternative(replacement="spark.primitives.Line", since="4.0")]
+ */
+/**
+ *  The HRule control creates a single horizontal line.
+ *  You typically use this control to create a dividing line
+ *  within a container.
+ *
+ *  <p>The HRule control has the following default properties:</p>
+ *     <table class="innertable">
+ *        <tr>
+ *           <th>Characteristic</th>
+ *           <th>Description</th>
+ *        </tr>
+ *        <tr>
+ *           <td>Default size</td>
+ *           <td>The default width is 100 pixels, default height is 2 pixels. By default, the HRule control is not resizable; set width and height to percentage values to enable resizing.</td>
+ *        </tr>
+ *        <tr>
+ *           <td>strokeWidth</td>
+ *           <td>2 pixels.</td>
+ *        </tr>
+ *        <tr>
+ *           <td>strokeColor</td>
+ *           <td>0xC4CCCC.</td>
+ *        </tr>
+ *        <tr>
+ *           <td>shadowColor</td>
+ *           <td>0xEEEEEE.</td>
+ *        </tr>
+ *     </table>
+ *
+ *  @mxml
+ *  
+ *  <p>The <code>&lt;mx:HRule&gt;</code> tag inherits all of the tag attributes
+ *  of its superclass, and adds the following tag attributes:</p>
+ *  
+ *  <pre>
+ *  &lt;mx:HRule
+ *    <strong>Styles</strong>
+ *    strokeColor="0xC4CCCC"
+ *    shadowColor="0xEEEEEE"
+ *    strokeWidth="2"
+ *  /&gt;
+ *  </pre>
+ *  
+ *  @includeExample examples/SimpleHRule.mxml
+ *
+ *  @see mx.controls.VRule
+ *  
+ *  @langversion 3.0
+ *  @playerversion Flash 9
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+public class HRule extends UIComponent
+{
+    /* include "../core/Version.as"; */
+
+    //--------------------------------------------------------------------------
+    //
+    //  Class constants
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  @private
+     */
+    private static const DEFAULT_PREFERRED_WIDTH:Number = 100;
+
+    //--------------------------------------------------------------------------
+    //
+    //  Constructor
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  Constructor.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function HRule()
+    {
+        super();
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    //  Overridden methods: UIComponent
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  @private
+     */
+    override protected function measure():void
+    {
+        super.measure();
+
+        measuredWidth = DEFAULT_PREFERRED_WIDTH;
+        measuredHeight = getStyle("strokeWidth");
+    }
+    
+    /**
+     *  @private
+     *  The appearance of our horizontal rule is inspired by
+     *  the leading browser's rendering of HTML's <HR>.
+     *
+     *  The only reliable way to draw the 1-pixel lines that are
+     *  the borders of the horizontal rule is by filling rectangles!
+     *  Otherwise, very short lines become antialised, probably because
+     *  the Player is trying to render an endcap.
+     */
+    override protected function updateDisplayList(unscaledWidth:Number,
+                                                  unscaledHeight:Number):void
+    {
+        super.updateDisplayList(unscaledWidth, unscaledHeight);
+
+       /*  var g:Graphics = graphics;
+        
+        g.clear();
+
+        // Look up the style properties
+        var strokeColor:Number = getStyle("strokeColor");
+        var shadowColor:Number = getStyle("shadowColor");
+        var strokeWidth:Number = getStyle("strokeWidth");
+
+        // The thickness of the stroke shouldn't be greater than
+        // the unscaledHeight of the bounding rectangle.
+        if (strokeWidth > unscaledHeight)
+            strokeWidth = unscaledHeight;
+
+        // The horizontal rule extends from the left edge
+        // to the right edge of the bounding rectangle and
+        // is vertically centered within the bounding rectangle.
+        var left:Number = 0;
+        var top:Number = (unscaledHeight - strokeWidth) / 2;
+        var right:Number = unscaledWidth;
+        var bottom:Number = top + strokeWidth;
+
+        if (strokeWidth == 1)
+        {
+            // **************
+
+            g.beginFill(strokeColor);
+            g.drawRect(left, top, unscaledWidth, bottom-top);
+            g.endFill();
+        }
+        else if (strokeWidth == 2)
+        {
+            // **************
+            // oooooooooooooo
+
+            g.beginFill(strokeColor);
+            g.drawRect(left, top, unscaledWidth, 1);
+            g.endFill();
+
+            g.beginFill(shadowColor);
+            g.drawRect(left, bottom - 1, unscaledWidth, 1);
+            g.endFill();
+        }
+        else if (strokeWidth > 2)
+        {
+            // *************o
+            // *            o
+            // oooooooooooooo
+
+            g.beginFill(strokeColor);
+            g.drawRect(left, top, unscaledWidth - 1, 1);
+            g.endFill();
+
+            g.beginFill(shadowColor);
+            g.drawRect(right - 1, top, 1, bottom - top - 1);
+            g.drawRect(left, bottom - 1, unscaledWidth, 1);
+            g.endFill();
+
+            g.beginFill(strokeColor);
+            g.drawRect(left, top + 1, 1, bottom - top - 2);
+            g.endFill();
+        } */
+    }
+}
+
+}
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/VRule.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/VRule.as
new file mode 100644
index 000000000..bda35aaae
--- /dev/null
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/VRule.as
@@ -0,0 +1,297 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 mx.controls
+{
+
+/* import flash.display.Graphics;*/
+import mx.core.UIComponent;
+
+//--------------------------------------
+//  Styles
+//--------------------------------------
+
+/**
+ *  The shadow color of the line. 
+ *  <ul>
+ *    <li>If <code>strokeWidth</code> is 1, shadowColor
+ *    does nothing.</li>
+ *    <li>If <code>strokeWidth is 2</code> shadowColor is
+ *    the color of the right line.</li>
+ *    <li>If <code>strokeWidth</code> is greater than 2, shadowColor
+ *    is the color of the bottom and right edges of the rectangle.</li>
+ *  </ul>
+ *  
+ *  @default 0xEEEEEE
+ *  
+ *  @langversion 3.0
+ *  @playerversion Flash 9
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+[Style(name="shadowColor", type="uint", format="Color", inherit="yes")]
+
+/**
+ *  The color of the line. 
+ *  <ul>
+ *    <li>If <code>strokeWidth</code> is 1, strokeColor is
+ *    the color of the entire line.</li>
+ *    <li>If <code>strokeWidth</code> is 2, strokeColor is 
+ *    the color of the left line.</li>
+ *    <li>If <code>strokeWidth</code> is greater than 2, strokeColor is
+ *    the color of the top and left edges of the rectangle.</li>
+ *  </ul>
+ *  
+ *  @default 0xC4CCCC
+ *  
+ *  @langversion 3.0
+ *  @playerversion Flash 9
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+[Style(name="strokeColor", type="uint", format="Color", inherit="yes")]
+
+/**
+ *  The thickness of the rule in pixels. 
+ *  <ul>
+ *    <li>If <code>strokeWidth</code> is 1, 
+ *    the rule is a 1-pixel-wide line.</li>
+ *    <li>If <code>strokeWidth</code> is 2,
+ *    the rule is two adjacent 1-pixel-wide vertical lines.</li>
+ *    <li>If <code>strokeWidth</code> is greater than 2,
+ *    the rule is a hollow rectangle with 1-pixel-wide edges.</li>
+ *  </ul>
+ *  
+ *  @default 2
+ *  
+ *  @langversion 3.0
+ *  @playerversion Flash 9
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+[Style(name="strokeWidth", type="Number", format="Length", inherit="yes")]
+    // Note: stroke-width is inheriting in SVG,
+    // although border-width is not inheriting in CSS
+
+//--------------------------------------
+//  Other metadata
+//--------------------------------------
+
+[IconFile("VRule.png")]
+
+[Alternative(replacement="spark.primitives.Line", since="4.0")]
+
+/**
+ *  The VRule control creates a single vertical line.
+ *  You typically use this control to create a dividing line
+ *  within a container.
+ *
+ *  <p>The HRule control has the following default properties:</p>
+ *     <table class="innertable">
+ *        <tr>
+ *           <th>Characteristic</th>
+ *           <th>Description</th>
+ *        </tr>
+ *        <tr>
+ *           <td>Default size</td>
+ *           <td>The default height is 100 pixels, default width is 2 pixels. By default, the VRule control is not resizable; set width and height to percentage values to enable resizing.</td>
+ *        </tr>
+ *        <tr>
+ *           <td>strokeWidth</td>
+ *           <td>2 pixels.</td>
+ *        </tr>
+ *        <tr>
+ *           <td>strokeColor</td>
+ *           <td>0xC4CCCC.</td>
+ *        </tr>
+ *        <tr>
+ *           <td>shadowColor</td>
+ *           <td>0xEEEEEE.</td>
+ *        </tr>
+ *     </table>
+ *
+ *  @mxml
+ *  
+ *  <p>The <code>&lt;mx:VRule&gt;</code> tag inherits all of the tag attributes
+ *  of its superclass, and adds the following tag attributes:</p>
+ *
+ *  <pre>
+ *  &lt;mx:VRule
+ *    <strong>Styles</strong>
+ *    strokeColor="0xC4CCCC"
+ *    shadowColor="0xEEEEEE"
+ *    strokeWidth="2"
+ *  /&gt;
+ *  </pre>
+ *  
+ *  @includeExample examples/SimpleVRule.mxml
+ *  
+ *  @see mx.controls.HRule
+ *  
+ *  @langversion 3.0
+ *  @playerversion Flash 9
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+public class VRule extends UIComponent
+{
+/*     include "../core/Version.as";
+ */
+    //--------------------------------------------------------------------------
+    //
+    //  Class constants
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  @private
+     */
+    private static const DEFAULT_PREFERRED_HEIGHT:Number = 100;
+
+    //--------------------------------------------------------------------------
+    //
+    //  Constructor
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  Constructor.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function VRule()
+    {
+        super();
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    //  Overridden methods
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  @private
+     */
+    override protected function measure():void
+    {
+        super.measure();
+
+        measuredWidth = getStyle("strokeWidth");
+        measuredHeight = DEFAULT_PREFERRED_HEIGHT;
+    }
+
+    /**
+     *  @private
+     *  The appearance of our vertical rule is inspired by
+     *  the leading browser's rendering of HTML's <VR>.
+     *
+     *  The only reliable way to draw the 1-pixel lines that are
+     *  the borders of the vertical rule is by filling rectangles!
+     *  Otherwise, very short lines become antialised, probably because
+     *  the Player is trying to render an endcap.
+     */
+    override protected function updateDisplayList(unscaledWidth:Number,
+                                                  unscaledHeight:Number):void
+    {
+        super.updateDisplayList(unscaledWidth, unscaledHeight);
+
+      /*   var g:Graphics = graphics;
+        g.clear();
+
+        // Look up the style properties
+        var strokeColor:Number = getStyle("strokeColor");
+        var shadowColor:Number = getStyle("shadowColor");
+        var strokeWidth:Number = getStyle("strokeWidth");
+
+        // The thickness of the stroke shouldn't be greater than
+        // the unscaledWidth of the bounding rectangle.
+        if (strokeWidth > unscaledWidth)
+            strokeWidth = unscaledWidth;
+
+        // The vertical rule extends from the top edge
+        // to the bottom edge of the bounding rectangle and
+        // is horizontally centered within the bounding rectangle.
+        var left:Number = (unscaledWidth - strokeWidth) / 2;
+        var top:Number = 0;
+        var right:Number = left + strokeWidth;
+        var bottom:Number = unscaledHeight;
+
+        if (strokeWidth == 1)
+        {
+            // *
+            // *
+            // *
+            // *
+            // *
+            // *
+            // *
+
+            g.beginFill(strokeColor);
+            g.drawRect(left, top, right-left, unscaledHeight);
+            g.endFill();
+        }
+        else if (strokeWidth == 2)
+        {
+            // *o
+            // *o
+            // *o
+            // *o
+            // *o
+            // *o
+            // *o
+
+            g.beginFill(strokeColor);
+            g.drawRect(left, top, 1, unscaledHeight);
+            g.endFill();
+
+            g.beginFill(shadowColor);
+            g.drawRect(right - 1, top, 1, unscaledHeight);
+            g.endFill();
+        }
+        else if (strokeWidth > 2)
+        {
+            // **o
+            // * o
+            // * o
+            // * o
+            // * o
+            // * o
+            // ooo
+
+            g.beginFill(strokeColor);
+            g.drawRect(left, top, right - left - 1, 1);
+            g.endFill();
+
+            g.beginFill(shadowColor);
+            g.drawRect(right - 1, top, 1, unscaledHeight - 1);
+            g.drawRect(left, bottom - 1, right - left, 1);
+            g.endFill();
+
+            g.beginFill(strokeColor);
+            g.drawRect(left, top + 1, 1, unscaledHeight - 2);
+            g.endFill();
+        } */
+    }
+}
+
+}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services