This is an automated email from the ASF dual-hosted git repository.
yishayw pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
The following commit(s) were added to refs/heads/develop by this push:
new 5163685 Add bead that helps tile layout set its cell dimensions based
on content.
5163685 is described below
commit 51636852d1d791703cb74b011741fb1f003d5863
Author: DESKTOP-RH4S838\Yishay <[email protected]>
AuthorDate: Wed Jul 10 11:03:40 2019 +0300
Add bead that helps tile layout set its cell dimensions based on
content.
---
.../Basic/src/main/resources/basic-manifest.xml | 1 +
.../royale/html/beads/layouts/ITileLayout.as | 68 ++++++++++++++++
.../apache/royale/html/beads/layouts/TileLayout.as | 4 +-
.../layouts/UseMaxChildForTileCellDimensions.as | 93 ++++++++++++++++++++++
4 files changed, 164 insertions(+), 2 deletions(-)
diff --git a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
index 284cf5c..26cf36f 100644
--- a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
+++ b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
@@ -104,6 +104,7 @@
<component id="HorizontalFlowLayout"
class="org.apache.royale.html.beads.layouts.HorizontalFlowLayout" />
<component id="HorizontalSliderLayout"
class="org.apache.royale.html.beads.layouts.HorizontalSliderLayout" />
<component id="TileLayout"
class="org.apache.royale.html.beads.layouts.TileLayout"/>
+ <component id="UseMaxChildForTileCellDimensions"
class="org.apache.royale.html.beads.layouts.UseMaxChildForTileCellDimensions"/>
<component id="ListView" class="org.apache.royale.html.beads.ListView"/>
<component id="AccordionView"
class="org.apache.royale.html.beads.AccordionView"/>
<component id="CenterElement"
class="org.apache.royale.html.beads.CenterElement"/>
diff --git
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/layouts/ITileLayout.as
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/layouts/ITileLayout.as
new file mode 100644
index 0000000..00bf6ac
--- /dev/null
+++
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/layouts/ITileLayout.as
@@ -0,0 +1,68 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.royale.html.beads.layouts
+{
+ import org.apache.royale.core.IBeadLayout;
+
+ /**
+ * ITileLayout creates a tile layout. You can define the dimensions of
each cell.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 9.6
+ */
+ public interface ITileLayout extends IBeadLayout
+ {
+ /**
+ * The width of each column, in pixels. If left unspecified,
the
+ * columnWidth is determined by dividing the numColumns into
the
+ * strand's bounding box width.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.6
+ */
+ function get columnWidth():Number;
+ function set columnWidth(value:Number):void;
+ /**
+ * The height of each row, in pixels. If left unspecified, the
+ * rowHeight is determine by dividing the possible number of
rows
+ * into the strand's bounding box height.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.6
+ */
+ function get rowHeight():Number;
+ function set rowHeight(value:Number):void;
+ /**
+ * The number of tiles to fit horizontally into the layout.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.6
+ */
+ function get numColumns():Number;
+ function set numColumns(value:Number):void;
+ }
+}
diff --git
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/layouts/TileLayout.as
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/layouts/TileLayout.as
index b9df110..ea68acc 100644
---
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/layouts/TileLayout.as
+++
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/layouts/TileLayout.as
@@ -19,7 +19,7 @@
package org.apache.royale.html.beads.layouts
{
import org.apache.royale.core.LayoutBase;
- import org.apache.royale.core.IBeadLayout;
+ import org.apache.royale.html.beads.layouts.ITileLayout;
import org.apache.royale.core.IBorderPaddingMarginValuesImpl;
import org.apache.royale.core.ILayoutHost;
import org.apache.royale.core.ILayoutView;
@@ -47,7 +47,7 @@ package org.apache.royale.html.beads.layouts
* @playerversion AIR 2.6
* @productversion Royale 0.0
*/
- public class TileLayout extends LayoutBase implements IBeadLayout
+ public class TileLayout extends LayoutBase implements ITileLayout
{
/**
* constructor.
diff --git
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/layouts/UseMaxChildForTileCellDimensions.as
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/layouts/UseMaxChildForTileCellDimensions.as
new file mode 100644
index 0000000..2cc4df4
--- /dev/null
+++
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/layouts/UseMaxChildForTileCellDimensions.as
@@ -0,0 +1,93 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.royale.html.beads.layouts
+{
+ import org.apache.royale.core.IBead;
+ import org.apache.royale.core.IItemRendererParent;
+ import org.apache.royale.core.IStrand;
+ import org.apache.royale.core.IUIBase;
+ import org.apache.royale.events.Event;
+ import org.apache.royale.events.IEventDispatcher;
+ import org.apache.royale.html.beads.IListView;
+ import org.apache.royale.html.beads.layouts.ITileLayout;
+
+ /**
+ * The UseMaxChildForTileCellDimensions class bead finds the biggest
item renderer in a tiled list
+ * and sets the tile dimensions accordingly.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.6
+ */
+ public class UseMaxChildForTileCellDimensions implements IBead
+ {
+ /**
+ * constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.6
+ */
+ public function UseMaxChildForTileCellDimensions()
+ {
+ super();
+ }
+
+ public function set strand(value:IStrand):void
+ {
+ (value as
IEventDispatcher).addEventListener("layoutNeeded", layoutNeededHandler);
+ }
+
+ private function layoutNeededHandler(e:Event):void
+ {
+ var strand:IStrand = e.target as IStrand;
+ var dataGroup:IItemRendererParent =
(strand.getBeadByType(IListView) as IListView).dataGroup;
+ var maxWidth:int = 0;
+ var maxHeight:int = 0;
+ for (var i:int = 0; i < dataGroup.numItemRenderers; i++)
+ {
+ var uibase:IUIBase =
dataGroup.getItemRendererForIndex(i) as IUIBase;
+ if (!uibase.visible)
+ {
+ continue;
+ }
+ if (!isNaN(uibase.width) && maxWidth <
uibase.width)
+ {
+ maxWidth = uibase.width;
+ }
+ if (!isNaN(uibase.height) && maxHeight <
uibase.height)
+ {
+ maxHeight = uibase.height;
+ }
+ }
+ var tileLayout:ITileLayout =
strand.getBeadByType(ITileLayout) as ITileLayout;
+ if (maxWidth > 0)
+ {
+ tileLayout.columnWidth = maxWidth;
+ }
+ if (maxHeight > 0)
+ {
+ tileLayout.rowHeight = maxHeight;
+ }
+ }
+
+ }
+}