flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [14/15] git commit: [flex-asjs] [refs/heads/develop] - refactor layout on the JS side
Date Fri, 22 May 2015 23:04:33 GMT
refactor layout on the JS side


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

Branch: refs/heads/develop
Commit: 31c980a81c3bbc3ee77d3b0a990dbf9c07383cc9
Parents: cac7be7
Author: Alex Harui <aharui@apache.org>
Authored: Fri May 22 15:31:02 2015 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Fri May 22 16:04:12 2015 -0700

----------------------------------------------------------------------
 .../org/apache/flex/html/beads/ContainerView.js | 71 ++++++++++++++++++++
 .../src/org/apache/flex/html/beads/PanelView.js | 36 ++++++----
 .../flex/html/beads/layouts/BasicLayout.js      | 40 +----------
 .../html/beads/layouts/BasicScrollingLayout.js  |  7 +-
 .../flex/html/beads/layouts/HorizontalLayout.js | 41 +----------
 .../flex/html/beads/layouts/TileLayout.js       |  7 +-
 .../flex/html/beads/layouts/VerticalLayout.js   | 41 +----------
 .../beads/layouts/VerticalScrollingLayout.js    |  7 ++
 8 files changed, 105 insertions(+), 145 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/31c980a8/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/ContainerView.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/ContainerView.js b/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/ContainerView.js
index 91b8373..c4771c1 100644
--- a/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/ContainerView.js
+++ b/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/ContainerView.js
@@ -15,6 +15,7 @@
 goog.provide('org_apache_flex_html_beads_ContainerView');
 
 goog.require('org_apache_flex_core_BeadViewBase');
+goog.require('org_apache_flex_core_IBeadLayout');
 goog.require('org_apache_flex_core_ILayoutParent');
 
 
@@ -46,6 +47,54 @@ org_apache_flex_html_beads_ContainerView.prototype.FLEXJS_CLASS_INFO =
     };
 
 
+/**
+ *
+ */
+org_apache_flex_html_beads_ContainerView.
+    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_ContainerView.
+    prototype.changeHandler = function(event) {
+  if (this.layout_ == null) {
+    this.layout_ = this._strand.getBeadByType(org_apache_flex_core_IBeadLayout);
+    if (this.layout_ == null) {
+      var m3 = org_apache_flex_core_ValuesManager.valuesImpl.getValue(this._strand, 'iBeadLayout');
+      this.layout_ = new m3();
+      this._strand.addBead(this.layout_);
+      //this.layout_.strand = this.strand_;
+    }
+  }
+  this.layout_.layout();
+  var max = this.layout_.maxWidth;
+  if (isNaN(this.resizableView.explicitWidth) && !isNaN(max))
+    this.resizableView.setWidth(max, true);
+  max = this.layout_.maxHeight;
+  if (isNaN(this.resizableView.explicitHeight) && !isNaN(max))
+    this.resizableView.setHeight(max, true);
+};
+
+
+/**
+ * @param {org_apache_flex_events_Event} event The event.
+ */
+org_apache_flex_html_beads_ContainerView.
+    prototype.sizeChangeHandler = function(event) {
+  this.addOtherListeners();
+  this.changeHandler(event);
+};
+
+
 Object.defineProperties(org_apache_flex_html_beads_ContainerView.prototype, {
     /** @expose */
     contentView: {
@@ -60,5 +109,27 @@ Object.defineProperties(org_apache_flex_html_beads_ContainerView.prototype,
{
         get: function() {
             return this._strand;
         }
+    },
+    /** @expose */
+    strand: {
+        /** @this {org_apache_flex_html_beads_ContainerView} */
+        set: function(value) {
+            org_apache_flex_utils_Language.superSetter(org_apache_flex_html_beads_ContainerView,
this, 'strand', value);
+            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.explicitWidth) &&
+                  !isNaN(this._strand.explicitHeight))
+                this.addOtherListeners();
+            }
+         }
     }
+
 });

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/31c980a8/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/PanelView.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/PanelView.js b/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/PanelView.js
index 4042eec..206ec20 100644
--- a/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/PanelView.js
+++ b/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/PanelView.js
@@ -14,7 +14,7 @@
 
 goog.provide('org_apache_flex_html_beads_PanelView');
 
-goog.require('org_apache_flex_core_IBeadView');
+goog.require('org_apache_flex_html_beads_ContainerView');
 
 
 
@@ -22,6 +22,7 @@ goog.require('org_apache_flex_core_IBeadView');
  * @constructor
  */
 org_apache_flex_html_beads_PanelView = function() {
+  org_apache_flex_html_beads_PanelView.base(this, 'constructor');
   /**
    * @private
    * @type {boolean}
@@ -34,6 +35,9 @@ org_apache_flex_html_beads_PanelView = function() {
   */
   this.titleBar_ = null;
 };
+goog.inherits(
+    org_apache_flex_html_beads_PanelView,
+    org_apache_flex_html_beads_ContainerView);
 
 
 /**
@@ -44,33 +48,36 @@ org_apache_flex_html_beads_PanelView = function() {
 org_apache_flex_html_beads_PanelView
   .prototype.FLEXJS_CLASS_INFO =
     { names: [{ name: 'PanelView',
-                qName: 'org_apache_flex_html_beads_PanelView'}],
-      interfaces: [org_apache_flex_core_IBeadView] };
+                qName: 'org_apache_flex_html_beads_PanelView'}]};
 
 
 Object.defineProperties(org_apache_flex_html_beads_PanelView.prototype, {
     /** @expose */
+    contentView: {
+        /** @this {org_apache_flex_html_beads_ContainerView} */
+        get: function() {
+            return this._strand.contentArea;
+        }
+    },
+    /** @expose */
     strand: {
         /** @this {org_apache_flex_html_beads_PanelView} */
         set: function(value) {
-            this.strand_ = value;
+            org_apache_flex_utils_Language.superSetter(org_apache_flex_html_beads_PanelView,
this, 'strand', value);
 
             if (!this.titleBar_)
               this.titleBar_ = new org_apache_flex_html_TitleBar();
 
-            this.strand_.titleBar = this.titleBar_;
+            this._strand.titleBar = this.titleBar_;
             this.titleBar_.id = 'titleBar';
-            this.titleBar_.model = this.strand_.model;
+            this.titleBar_.model = this._strand.model;
 
-            this.strand_.controlBar =
+            this._strand.controlBar =
                 new org_apache_flex_html_ControlBar();
 
-            this.strand_.addEventListener('childrenAdded',
-                goog.bind(this.changeHandler, this));
-
             // listen for changes to the strand's model so items can be changed
             // in the view
-            this.strand_.model.addEventListener('titleChange',
+            this._strand.model.addEventListener('titleChange',
                 goog.bind(this.changeHandler, this));
         }
     },
@@ -89,11 +96,12 @@ Object.defineProperties(org_apache_flex_html_beads_PanelView.prototype,
{
 
 
 /**
+ * @override
  * @param {Object} event The event that triggered this handler.
  */
 org_apache_flex_html_beads_PanelView.prototype.changeHandler =
     function(event) {
-  var strand = this.strand_;
+  var strand = this._strand;
   if (!this.titleBarAdded_)
   {
     this.titleBarAdded_ = true;
@@ -106,7 +114,7 @@ org_apache_flex_html_beads_PanelView.prototype.changeHandler =
     this.titleBar_.title = strand.model.title;
   }
 
-  var p = this.strand_.positioner;
+  var p = this._strand.positioner;
   if (!strand.isWidthSizedToContent()) {
     var w = strand.width;
     w -= p.offsetWidth - p.clientWidth;
@@ -125,5 +133,5 @@ org_apache_flex_html_beads_PanelView.prototype.changeHandler =
     h -= p.offsetHeight - p.clientHeight;
     strand.contentArea.style.height = h.toString() + 'px';
   }
-  this.strand_.dispatchEvent('layoutNeeded');
+  org_apache_flex_html_beads_PanelView.base(this, 'changeHandler', event);
 };

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/31c980a8/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/BasicLayout.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/BasicLayout.js
b/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/BasicLayout.js
index 9126b28..ac7b2c6 100644
--- a/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/BasicLayout.js
+++ b/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/BasicLayout.js
@@ -50,19 +50,6 @@ Object.defineProperties(org_apache_flex_html_beads_layouts_BasicLayout.prototype
         set: function(value) {
             if (this.strand_ !== value) {
               this.strand_ = value;
-              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));
-
-                this.addOtherListeners();
-              }
             }
         }
     }
@@ -70,34 +57,9 @@ Object.defineProperties(org_apache_flex_html_beads_layouts_BasicLayout.prototype
 
 
 /**
- *
- */
-org_apache_flex_html_beads_layouts_BasicLayout.
-    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_BasicLayout.
-    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_BasicLayout.
-    prototype.changeHandler = function(event) {
+    prototype.layout = function() {
   var i, n, h, w;
 
   var viewBead = this.strand_.getBeadByType(org_apache_flex_core_ILayoutParent);

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/31c980a8/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/BasicScrollingLayout.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/BasicScrollingLayout.js
b/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/BasicScrollingLayout.js
index 86c51a2..162ec41 100644
--- a/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/BasicScrollingLayout.js
+++ b/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/BasicScrollingLayout.js
@@ -47,10 +47,6 @@ Object.defineProperties(org_apache_flex_html_beads_layouts_BasicScrollingLayout.
         set: 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));
             }
         }
     }
@@ -58,10 +54,9 @@ Object.defineProperties(org_apache_flex_html_beads_layouts_BasicScrollingLayout.
 
 
 /**
- * @param {org_apache_flex_events_Event} event The text getter.
  */
 org_apache_flex_html_beads_layouts_BasicScrollingLayout.
-    prototype.changeHandler = function(event) {
+    prototype.layout = function() {
   var i, n, h, w;
 
   var viewBead = this.strand_.getBeadByType(org_apache_flex_core_ILayoutParent);

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/31c980a8/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/HorizontalLayout.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/HorizontalLayout.js
b/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/HorizontalLayout.js
index 55d4fb0..05e2ebf 100644
--- a/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/HorizontalLayout.js
+++ b/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/HorizontalLayout.js
@@ -48,20 +48,6 @@ Object.defineProperties(org_apache_flex_html_beads_layouts_HorizontalLayout.prot
         set: function(value) {
             if (this.strand_ !== value) {
               this.strand_ = value;
-              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_.explicitWidth) &&
-                    !isNaN(this.strand_.explicitHeight))
-                    this.addOtherListeners();
-              }
               this.strand_.element.style.display = 'block';
             }
         }
@@ -70,34 +56,9 @@ Object.defineProperties(org_apache_flex_html_beads_layouts_HorizontalLayout.prot
 
 
 /**
- *
- */
-org_apache_flex_html_beads_layouts_HorizontalLayout.
-    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_HorizontalLayout.
-    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_HorizontalLayout.
-    prototype.changeHandler = function(event) {
+    prototype.layout = function() {
   var children, i, n;
 
   children = this.strand_.internalChildren();

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/31c980a8/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/TileLayout.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/TileLayout.js
b/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/TileLayout.js
index 72354b0..d19d760 100644
--- a/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/TileLayout.js
+++ b/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/TileLayout.js
@@ -47,10 +47,6 @@ Object.defineProperties(org_apache_flex_html_beads_layouts_TileLayout.prototype,
         set: 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));
             }
         }
     },
@@ -91,10 +87,9 @@ Object.defineProperties(org_apache_flex_html_beads_layouts_TileLayout.prototype,
 
 
 /**
- * @param {org_apache_flex_events_Event} event The text getter.
  */
 org_apache_flex_html_beads_layouts_TileLayout.
-    prototype.changeHandler = function(event) {
+    prototype.layout = function() {
   var children, i, n, child;
   var xpos, ypos, useWidth, useHeight;
 

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/31c980a8/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/VerticalLayout.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/VerticalLayout.js
b/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/VerticalLayout.js
index f3214eb..ee2a0ec 100644
--- a/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/VerticalLayout.js
+++ b/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/VerticalLayout.js
@@ -47,20 +47,6 @@ Object.defineProperties(org_apache_flex_html_beads_layouts_VerticalLayout.protot
         set: function(value) {
             if (this.strand_ !== value) {
               this.strand_ = value;
-              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_.explicitWidth) &&
-                    !isNaN(this.strand_.explicitHeight))
-                  this.addOtherListeners();
-               }
             }
         }
     }
@@ -68,34 +54,9 @@ Object.defineProperties(org_apache_flex_html_beads_layouts_VerticalLayout.protot
 
 
 /**
- *
- */
-org_apache_flex_html_beads_layouts_VerticalLayout.
-    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_VerticalLayout.
-    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_VerticalLayout.
-    prototype.changeHandler = function(event) {
+    prototype.layout = function() {
   var children, i, n;
 
   children = this.strand_.internalChildren();

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/31c980a8/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/VerticalScrollingLayout.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/VerticalScrollingLayout.js
b/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/VerticalScrollingLayout.js
index 6df6e0c..aa7baba 100644
--- a/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/VerticalScrollingLayout.js
+++ b/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/VerticalScrollingLayout.js
@@ -29,6 +29,13 @@ org_apache_flex_html_beads_layouts_VerticalScrollingLayout = function()
{
 
 
 /**
+ */
+org_apache_flex_html_beads_layouts_VerticalScrollingLayout.
+    prototype.layout = function() {
+};
+
+
+/**
  * Metadata
  *
  * @type {Object.<string, Array.<Object>>}


Mime
View raw message