flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [29/31] git commit: [flex-asjs] [refs/heads/develop] - JS layout has to propagate sizeChanged events
Date Tue, 09 Dec 2014 05:17:16 GMT
JS layout has to propagate sizeChanged events


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/7e97921c
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/7e97921c
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/7e97921c

Branch: refs/heads/develop
Commit: 7e97921cd2162397f206290ac8923237831e9092
Parents: 3ad5889
Author: Alex Harui <aharui@apache.org>
Authored: Mon Dec 8 18:03:48 2014 -0800
Committer: Alex Harui <aharui@apache.org>
Committed: Mon Dec 8 21:09:29 2014 -0800

----------------------------------------------------------------------
 .../html/beads/layouts/NonVirtualBasicLayout.js | 77 +++++++++++++++++++-
 .../beads/layouts/NonVirtualHorizontalLayout.js | 55 +++++++++++---
 .../beads/layouts/NonVirtualVerticalLayout.js   | 50 +++++++++++--
 3 files changed, 159 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7e97921c/frameworks/js/FlexJS/src/org/apache/flex/html/beads/layouts/NonVirtualBasicLayout.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/beads/layouts/NonVirtualBasicLayout.js
b/frameworks/js/FlexJS/src/org/apache/flex/html/beads/layouts/NonVirtualBasicLayout.js
index cc0d36c..814394e 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/html/beads/layouts/NonVirtualBasicLayout.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/html/beads/layouts/NonVirtualBasicLayout.js
@@ -15,6 +15,9 @@
 goog.provide('org.apache.flex.html.beads.layouts.NonVirtualBasicLayout');
 
 goog.require('org.apache.flex.core.IBeadLayout');
+goog.require('org.apache.flex.core.ILayoutChild');
+goog.require('org.apache.flex.core.ValuesManager');
+goog.require('org.apache.flex.utils.Language');
 
 
 
@@ -48,17 +51,83 @@ org.apache.flex.html.beads.layouts.NonVirtualBasicLayout.
     prototype.set_strand = function(value) {
   if (this.strand_ !== value) {
     this.strand_ = value;
-    this.strand_.addEventListener('childrenAdded',
-        goog.bind(this.changeHandler, this));
-    this.strand_.addEventListener('layoutNeeded',
-        goog.bind(this.changeHandler, this));
+    if (this.strand_.isWidthSizedToContent() &&
+        this.strand_.isHeightSizedToContent())
+      this.addOtherListeners();
+    else {
+      this.strand_.addEventListener('heightChanged',
+          goog.bind(this.changeHandler, this));
+      this.strand_.addEventListener('widthChanged',
+          goog.bind(this.changeHandler, this));
+      this.strand_.addEventListener('sizeChanged',
+          goog.bind(this.sizeChangeHandler, this));
+      if (!isNaN(this.strand_.get_explicitWidth()) &&
+          !isNaN(this.strand_.get_explicitHeight()))
+          this.addOtherListeners();
+    }
   }
 };
 
 
 /**
+ *
+ */
+org.apache.flex.html.beads.layouts.NonVirtualBasicLayout.
+    prototype.addOtherListeners = function() {
+  this.strand_.addEventListener('childrenAdded',
+      goog.bind(this.changeHandler, this));
+  this.strand_.addEventListener('layoutNeeded',
+     goog.bind(this.changeHandler, this));
+  this.strand_.addEventListener('itemsCreated',
+     goog.bind(this.changeHandler, this));
+};
+
+
+/**
+ * @param {org.apache.flex.events.Event} event The event.
+ */
+org.apache.flex.html.beads.layouts.NonVirtualBasicLayout.
+    prototype.sizeChangeHandler = function(event) {
+  this.addOtherListeners();
+  this.changeHandler(event);
+};
+
+
+/**
  * @param {org.apache.flex.events.Event} event The text getter.
  */
 org.apache.flex.html.beads.layouts.NonVirtualBasicLayout.
     prototype.changeHandler = function(event) {
+  var i, n, h, w;
+
+  var viewBead = this.strand_.getBeadByType(org.apache.flex.core.ILayoutParent);
+  var contentView = viewBead.get_contentView();
+  w = contentView.get_width();
+  h = contentView.get_height();
+  n = contentView.get_numElements();
+  for (i = 0; i < n; i++) {
+    var child = contentView.getElementAt(i);
+    var left = org.apache.flex.core.ValuesManager.valuesImpl.getValue(child, 'left');
+    var right = org.apache.flex.core.ValuesManager.valuesImpl.getValue(child, 'right');
+    var top = org.apache.flex.core.ValuesManager.valuesImpl.getValue(child, 'top');
+    var bottom = org.apache.flex.core.ValuesManager.valuesImpl.getValue(child, 'bottom');
+
+    if (!isNaN(left)) {
+      child.positioner.style.position = 'absolute';
+      child.positioner.style.left = left.toString() + 'px';
+    }
+    if (!isNaN(top)) {
+      child.positioner.style.position = 'absolute';
+      child.positioner.style.top = top.toString() + 'px';
+    }
+    if (!isNaN(right)) {
+      child.positioner.style.position = 'absolute';
+      child.positioner.style.right = right.toString() + 'px';
+    }
+    if (!isNaN(bottom)) {
+      child.positioner.style.position = 'absolute';
+      child.positioner.style.bottom = bottom.toString() + 'px';
+    }
+    child.dispatchEvent('sizeChanged');
+  }
 };

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7e97921c/frameworks/js/FlexJS/src/org/apache/flex/html/beads/layouts/NonVirtualHorizontalLayout.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/beads/layouts/NonVirtualHorizontalLayout.js
b/frameworks/js/FlexJS/src/org/apache/flex/html/beads/layouts/NonVirtualHorizontalLayout.js
index c52d458..320985d 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/html/beads/layouts/NonVirtualHorizontalLayout.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/html/beads/layouts/NonVirtualHorizontalLayout.js
@@ -51,21 +51,50 @@ org.apache.flex.html.beads.layouts.NonVirtualHorizontalLayout.
     function(value) {
   if (this.strand_ !== value) {
     this.strand_ = value;
-    this.strand_.addEventListener('childrenAdded',
-        goog.bind(this.changeHandler, this));
-    this.strand_.addEventListener('itemsCreated',
-                                  goog.bind(this.changeHandler, this));
-    this.strand_.addEventListener('elementAdded',
-                                  goog.bind(this.changeHandler, this));
+    if (this.strand_.isWidthSizedToContent() &&
+        this.strand_.isHeightSizedToContent())
+      this.addOtherListeners();
+    else {
+      this.strand_.addEventListener('heightChanged',
+          goog.bind(this.changeHandler, this));
+      this.strand_.addEventListener('widthChanged',
+          goog.bind(this.changeHandler, this));
+      this.strand_.addEventListener('sizeChanged',
+          goog.bind(this.sizeChangeHandler, this));
+      if (!isNaN(this.strand_.get_explicitWidth()) &&
+          !isNaN(this.strand_.get_explicitHeight()))
+          this.addOtherListeners();
+    }
     this.strand_.element.style.display = 'block';
-
-    this.changeHandler(null);
   }
 };
 
 
 /**
-          NonVirtualHorizontalLayout}
+ *
+ */
+org.apache.flex.html.beads.layouts.NonVirtualHorizontalLayout.
+    prototype.addOtherListeners = function() {
+  this.strand_.addEventListener('childrenAdded',
+      goog.bind(this.changeHandler, this));
+  this.strand_.addEventListener('layoutNeeded',
+     goog.bind(this.changeHandler, this));
+  this.strand_.addEventListener('itemsCreated',
+     goog.bind(this.changeHandler, this));
+};
+
+
+/**
+ * @param {org.apache.flex.events.Event} event The event.
+ */
+org.apache.flex.html.beads.layouts.NonVirtualHorizontalLayout.
+    prototype.sizeChangeHandler = function(event) {
+  this.addOtherListeners();
+  this.changeHandler(event);
+};
+
+
+/**
  * @param {org.apache.flex.events.Event} event The text getter.
  */
 org.apache.flex.html.beads.layouts.NonVirtualHorizontalLayout.
@@ -76,9 +105,11 @@ org.apache.flex.html.beads.layouts.NonVirtualHorizontalLayout.
   n = children.length;
   for (i = 0; i < n; i++)
   {
-    if (children[i].style.display == 'none')
-      children[i].lastDisplay_ = 'inline-block';
+    var child = children[i];
+    if (child.style.display == 'none')
+      child.lastDisplay_ = 'inline-block';
     else
-      children[i].style.display = 'inline-block';
+      child.style.display = 'inline-block';
+    child.flexjs_wrapper.dispatchEvent('sizeChanged');
   }
 };

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7e97921c/frameworks/js/FlexJS/src/org/apache/flex/html/beads/layouts/NonVirtualVerticalLayout.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/beads/layouts/NonVirtualVerticalLayout.js
b/frameworks/js/FlexJS/src/org/apache/flex/html/beads/layouts/NonVirtualVerticalLayout.js
index 1828677..69e3362 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/html/beads/layouts/NonVirtualVerticalLayout.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/html/beads/layouts/NonVirtualVerticalLayout.js
@@ -48,15 +48,49 @@ org.apache.flex.html.beads.layouts.NonVirtualVerticalLayout.
     prototype.set_strand = function(value) {
   if (this.strand_ !== value) {
     this.strand_ = value;
-    this.strand_.addEventListener('childrenAdded',
-        goog.bind(this.changeHandler, this));
-    this.strand_.addEventListener('layoutNeeded',
-        goog.bind(this.changeHandler, this));
+    if (this.strand_.isWidthSizedToContent() &&
+        this.strand_.isHeightSizedToContent())
+      this.addOtherListeners();
+    else {
+      this.strand_.addEventListener('heightChanged',
+          goog.bind(this.changeHandler, this));
+      this.strand_.addEventListener('widthChanged',
+          goog.bind(this.changeHandler, this));
+      this.strand_.addEventListener('sizeChanged',
+          goog.bind(this.sizeChangeHandler, this));
+      if (!isNaN(this.strand_.get_explicitWidth()) &&
+          !isNaN(this.strand_.get_explicitHeight()))
+          this.addOtherListeners();
+    }
   }
 };
 
 
 /**
+ *
+ */
+org.apache.flex.html.beads.layouts.NonVirtualVerticalLayout.
+    prototype.addOtherListeners = function() {
+  this.strand_.addEventListener('childrenAdded',
+      goog.bind(this.changeHandler, this));
+  this.strand_.addEventListener('layoutNeeded',
+     goog.bind(this.changeHandler, this));
+  this.strand_.addEventListener('itemsCreated',
+     goog.bind(this.changeHandler, this));
+};
+
+
+/**
+ * @param {org.apache.flex.events.Event} event The event.
+ */
+org.apache.flex.html.beads.layouts.NonVirtualVerticalLayout.
+    prototype.sizeChangeHandler = function(event) {
+  this.addOtherListeners();
+  this.changeHandler(event);
+};
+
+
+/**
  * @param {org.apache.flex.events.Event} event The text getter.
  */
 org.apache.flex.html.beads.layouts.NonVirtualVerticalLayout.
@@ -67,10 +101,12 @@ org.apache.flex.html.beads.layouts.NonVirtualVerticalLayout.
   n = children.length;
   for (i = 0; i < n; i++)
   {
-    if (children[i].style.display === 'none') {
-      children[i].lastDisplay_ = 'block';
+    var child = children[i];
+    if (child.style.display === 'none') {
+      child.lastDisplay_ = 'block';
     } else {
-      children[i].style.display = 'block';
+      child.style.display = 'block';
     }
+    child.flexjs_wrapper.dispatchEvent('sizeChanged');
   }
 };


Mime
View raw message