asproject 0.1.21
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +0 -0
- data/History.txt +0 -0
- data/MIT-LICENSE.txt +20 -0
- data/Manifest.txt +16 -0
- data/README.txt +3 -0
- data/TODO.txt +10 -0
- data/bin/asclass +16 -0
- data/bin/asproject +16 -0
- data/lib/asclass.rb +254 -0
- data/lib/asclass_arguments.rb +147 -0
- data/lib/asproject.rb +248 -0
- data/lib/asproject/version.rb +9 -0
- data/lib/asproject_arguments.rb +175 -0
- data/lib/asproject_base.rb +43 -0
- data/lib/asproject_utils.rb +57 -0
- data/lib/eclipse_project.rb +32 -0
- data/lib/path_finder.rb +286 -0
- data/lib/platform.rb +107 -0
- data/lib/project.rb +82 -0
- data/lib/template_resolver.rb +144 -0
- data/lib/test_suite_generator.rb +128 -0
- data/rakefile.rb +85 -0
- data/setup.rb +1585 -0
- data/templates/asclass/as2/Class.as +11 -0
- data/templates/asclass/as2/Component.as +8 -0
- data/templates/asclass/as2/Interface.as +3 -0
- data/templates/asclass/as2/TestCase.as +30 -0
- data/templates/asclass/as2/TestSuite.as +15 -0
- data/templates/asclass/as3/Class.as +9 -0
- data/templates/asclass/as3/Component.as +9 -0
- data/templates/asclass/as3/Component.mxml +1 -0
- data/templates/asclass/as3/Interface.as +6 -0
- data/templates/asclass/as3/TestCase.as +30 -0
- data/templates/asclass/as3/TestSuite.as +18 -0
- data/templates/asproject/as2/project/rakefile.rb +18 -0
- data/templates/asproject/as2/project/src/AsProject.as +13 -0
- data/templates/asproject/as2/project/test/AsProjectRunner.as +12 -0
- data/templates/asproject/as3/project/rakefile.rb +18 -0
- data/templates/asproject/as3/project/src/AsProject.as +9 -0
- data/templates/asproject/as3/project/src/AsProjectRunner.as +11 -0
- data/templates/asproject/asunit2/project/lib/asunit/AsUnitUi.swf +0 -0
- data/templates/asproject/asunit2/project/lib/asunit/Sys.as +70 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanel.as +182 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTest.as +84 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTextArea.as +111 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTextAreaTest.as +26 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTitleBar.as +81 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ResizeHandle.as +35 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ScrollArrow.as +34 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ScrollHandle.as +43 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ScrollListener.as +10 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/TextScroller.as +169 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/shapes/Rectangle.as +29 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/shapes/Triangle.as +27 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/AsUnit.as +19 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Assert.as +408 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Assertion.as +27 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Reflection.as +68 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Test.as +3 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestCase.as +191 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestCaseXml.as +31 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestFailure.as +15 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestResult.as +15 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestRunner.as +41 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestSetup.as +19 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestSuite.as +22 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/ui/Main.as +325 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/ui/RemoteVersion.as +24 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/ui/SuccessMeter.as +32 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/Comparable.as +7 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/EventListener.as +29 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/EventSource.as +89 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalConnClient.as +42 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalConnGateway.as +47 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalConnServer.as +61 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalMessageBroker.as +58 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/Observable.as +11 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/TextFile.as +30 -0
- data/templates/asproject/asunit25/project/lib/asunit/AsUnitTestRunner.as +13 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/AssertionFailedError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/AssertionPassedError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/ClassNotFoundError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/IllegalOperationError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/InstanceNotFoundError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/InvocationTargetError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/UnimplementedFeatureError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/Assert.as +376 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/AssertMock.as +15 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/AssertTest.as +59 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/ITestListener.as +13 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/Test.as +11 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCase.as +277 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCaseMock.as +23 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCaseTest.as +29 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCaseXml.as +38 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestFailure.as +47 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestResult.as +168 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestSuite.as +102 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/runner/BaseTestRunner.as +101 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/runner/IResultPrinter.as +8 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/textui/ResultPrinter.as +254 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/textui/SuccessBar.as +41 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/textui/TestRunner.as +17 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/util/ArrayIterator.as +24 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/util/ArrayIteratorTest.as +52 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/util/Iterator.as +5 -0
- data/templates/asproject/asunit3/project/lib/asunit/AsUnitTestRunner.as +10 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/AbstractMemberCalledError.as +10 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/AssertionFailedError.as +10 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/ClassNotFoundError.as +10 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/InstanceNotFoundError.as +10 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/UnimplementedFeatureError.as +10 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/Assert.as +271 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/AsynchronousTestCase.as +52 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/AsynchronousTestCaseExample.as +71 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/Test.as +15 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestCase.as +351 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestCaseExample.as +73 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestFailure.as +47 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestListener.as +22 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestResult.as +158 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestSuite.as +115 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/runner/BaseTestRunner.as +15 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/runner/TestSuiteLoader.as +9 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/runner/Version.as +11 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/FlexRunner.as +19 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/FlexTestRunner.as +55 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/ResultPrinter.as +245 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/TestRunner.as +121 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/util/ArrayIterator.as +26 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/util/Iterator.as +9 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/util/Properties.as +30 -0
- data/templates/asproject/asunit3/project/lib/asunit/mx/managers/LayoutManager.as +945 -0
- data/templates/asproject/config/project/config/asclass_config.rb +58 -0
- data/templates/asproject/fb2as/project/.actionScriptProperties +21 -0
- data/templates/asproject/fb2as/project/.project +29 -0
- data/templates/asproject/fdt/project/.as2_classpath +6 -0
- data/templates/asproject/fdt/project/.project +19 -0
- data/templates/ide/mate/Create Class.tmCommand +37 -0
- data/templates/ide/mate/Rebuild Test Suites.tmCommand +33 -0
- data/templates/ide/mate/Run Rake Task.tmCommand +127 -0
- metadata +266 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
package asunit.util {
|
2
|
+
import asunit.errors.UnimplementedFeatureError;
|
3
|
+
import flash.errors.IllegalOperationError;
|
4
|
+
|
5
|
+
[ExcludeClass]
|
6
|
+
public dynamic class Properties {
|
7
|
+
|
8
|
+
public function store(sharedObjectId:String):void {
|
9
|
+
throw new UnimplementedFeatureError("Properties.store");
|
10
|
+
}
|
11
|
+
|
12
|
+
public function put(key:String, value:Object):void {
|
13
|
+
this[key] = value;
|
14
|
+
}
|
15
|
+
|
16
|
+
public function setProperty(key:String, value:Object):void {
|
17
|
+
put(key, value);
|
18
|
+
}
|
19
|
+
|
20
|
+
public function getProperty(key:String):Object {
|
21
|
+
try {
|
22
|
+
return this[key];
|
23
|
+
}
|
24
|
+
catch(e:Error) {
|
25
|
+
throw IllegalOperationError("Properties.getProperty");
|
26
|
+
}
|
27
|
+
return null;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
@@ -0,0 +1,945 @@
|
|
1
|
+
////////////////////////////////////////////////////////////////////////////////
|
2
|
+
//
|
3
|
+
// Copyright (C) 2003-2006 Adobe Macromedia Software LLC and its licensors.
|
4
|
+
// All Rights Reserved. The following is Source Code and is subject to all
|
5
|
+
// restrictions on such code as contained in the End User License Agreement
|
6
|
+
// accompanying this product.
|
7
|
+
//
|
8
|
+
////////////////////////////////////////////////////////////////////////////////
|
9
|
+
|
10
|
+
package mx.managers
|
11
|
+
{
|
12
|
+
|
13
|
+
import flash.display.Stage;
|
14
|
+
import flash.events.Event;
|
15
|
+
import flash.events.EventDispatcher;
|
16
|
+
import mx.core.Application;
|
17
|
+
import mx.core.UIComponent;
|
18
|
+
import mx.core.mx_internal;
|
19
|
+
import mx.events.FlexEvent;
|
20
|
+
import mx.managers.layoutClasses.PriorityQueue;
|
21
|
+
|
22
|
+
use namespace mx_internal;
|
23
|
+
|
24
|
+
/**
|
25
|
+
* The LayoutManager is the engine behind
|
26
|
+
* Flex's measurement and layout strategy.
|
27
|
+
* Layout is performed in three phases; commit, measurement, and layout.
|
28
|
+
*
|
29
|
+
* <p>Each phase is distinct from the others and all UIComponents of
|
30
|
+
* one phase are processed prior to moving on to the next phase.
|
31
|
+
* During the processing of UIComponents in a phase, requests for
|
32
|
+
* UIComponents to get re-processed by some phase may occur.
|
33
|
+
* These requests are queued and are only processed
|
34
|
+
* during the next run of the phase.</p>
|
35
|
+
*
|
36
|
+
* <p>The <b>commit</b> phase begins with a call to
|
37
|
+
* <code>validateProperties()</code>, which walks through a list
|
38
|
+
* (sorted by nesting level) of objects calling each object's
|
39
|
+
* <a href="../core/UIComponent.html#validateProperties()">
|
40
|
+
* <code>validateProperties()</code></a>method.</p>
|
41
|
+
*
|
42
|
+
* <p>The objects in the list are processed by nesting order,
|
43
|
+
* with the <b>most</b> deeply nested object accessed first.
|
44
|
+
* This can also be referred to as bottom-up inside-out ordering.</p>
|
45
|
+
*
|
46
|
+
* <p>This phase allows components whose contents depend on property
|
47
|
+
* settings to configure themselves prior to the measurement
|
48
|
+
* and the layout phases.
|
49
|
+
* For the sake of performance, sometimes a component's property setter
|
50
|
+
* method does not do all the work to update to the new property value.
|
51
|
+
* Instead, the property setter calls the <code>invalidateProperties()</code>
|
52
|
+
* method, deferring the work until this phase runs.
|
53
|
+
* This prevents unnecessary work if the property is set multiple times.</p>
|
54
|
+
*
|
55
|
+
* <p>The <b>measurement</b> phase begins with a call to
|
56
|
+
* <code>validateSize()</code>, which walks through a list
|
57
|
+
* (sorted by nesting level) of objects calling each object's
|
58
|
+
* <a href="../core/UIComponent.html#validateSize()"><code>validateSize()</code></a>
|
59
|
+
* method to determine if the object has changed in size.</p>
|
60
|
+
*
|
61
|
+
* <p>If an object's <a href="../core/UIComponent.html#invalidateSize()">
|
62
|
+
* <code>invalidateSize()</code></a> method was previously called,
|
63
|
+
* then the <code>validateSize()</code> method is called.
|
64
|
+
* If the size or position of the object was changed as a result of the
|
65
|
+
* <code>validateSize()</code> call, then the object's
|
66
|
+
* <a href="../core/UIComponent.html#invalidateDisplayList()">
|
67
|
+
* <code>invalidateDisplayList()</code></a> method is called, thus adding
|
68
|
+
* the object to the processing queue for the next run of the layout phase.
|
69
|
+
* Additionally, the object's parent is marked for both measurement
|
70
|
+
* and layout phases, by calling
|
71
|
+
* <a href="../core/UIComponent.html#invalidateSize()">
|
72
|
+
* <code>invalidateSize()</code></a> and
|
73
|
+
* <a href="../core/UIComponent.html#invalidateDisplayList()">
|
74
|
+
* <code>invalidateDisplayList()</code></a> respectively.</p>
|
75
|
+
*
|
76
|
+
* <p>The objects in the list are processed by nesting order,
|
77
|
+
* with the <b>most</b> deeply nested object accessed first.
|
78
|
+
* This can also be referred to as bottom-up inside-out ordering.</p>
|
79
|
+
*
|
80
|
+
* <p>The <b>layout</b> phase begins with a call to the
|
81
|
+
* <code>validateDisplayList()</code> method, which walks through a list
|
82
|
+
* (reverse sorted by nesting level) of objects calling each object's
|
83
|
+
* <a href="../core/UIComponent.html#validateDisplayList()">
|
84
|
+
* <code>validateDisplayList()</code></a> method to request the object to size
|
85
|
+
* and position all components contained within it (i.e. its children).</p>
|
86
|
+
*
|
87
|
+
* <p>If an object's <a href="../core/UIComponent.html#invalidateDisplayList()">
|
88
|
+
* <code>invalidateDisplayList()</code></a> method was previously called,
|
89
|
+
* then <code>validateDisplayList()</code> method for the object is called.</p>
|
90
|
+
*
|
91
|
+
* <p>The objects in the list are processed in reversed nesting order,
|
92
|
+
* with the <b>least</b> deeply nested object accessed first.
|
93
|
+
* This can also be referred to as top-down or outside-in ordering.</p>
|
94
|
+
*
|
95
|
+
* <p>In general, components do not override the <code>validateProperties()</code>,
|
96
|
+
* <code>validateSize()</code>, or <code>validateDisplayList()</code> methods.
|
97
|
+
* In the case of UIComponents, most components override the
|
98
|
+
* <code>commitProperties()</code>, <code>measure()</code>, or
|
99
|
+
* <code>updateDisplayList()</code> methods, which are called
|
100
|
+
* by the <code>validateProperties()</code>,
|
101
|
+
* <code>validateSize()</code>, or
|
102
|
+
* <code>validateDisplayList()</code> methods, respectively.</p>
|
103
|
+
*
|
104
|
+
* <p>At application startup, a single instance of the LayoutManager is created
|
105
|
+
* and stored in the <code>UIComponent.layoutManager</code> property.
|
106
|
+
* All components are expected to use that instance.
|
107
|
+
* If you do not have access to the UIComponent object,
|
108
|
+
* you can also access the LayoutManager using the static
|
109
|
+
* <code>LayoutManager.getInstance()</code> method.</p>
|
110
|
+
*/
|
111
|
+
public class LayoutManager extends EventDispatcher
|
112
|
+
{
|
113
|
+
|
114
|
+
//--------------------------------------------------------------------------
|
115
|
+
//
|
116
|
+
// Class variables
|
117
|
+
//
|
118
|
+
//--------------------------------------------------------------------------
|
119
|
+
|
120
|
+
/**
|
121
|
+
* @private
|
122
|
+
* The sole instance of this singleton class.
|
123
|
+
*/
|
124
|
+
private static var instance:LayoutManager;
|
125
|
+
|
126
|
+
//--------------------------------------------------------------------------
|
127
|
+
//
|
128
|
+
// Class methods
|
129
|
+
//
|
130
|
+
//--------------------------------------------------------------------------
|
131
|
+
|
132
|
+
/**
|
133
|
+
* Returns the sole instance of this singleton class,
|
134
|
+
* creating it if it does not already exist.
|
135
|
+
*/
|
136
|
+
public static function getInstance():LayoutManager
|
137
|
+
{
|
138
|
+
if (!instance)
|
139
|
+
instance = new LayoutManager();
|
140
|
+
|
141
|
+
return instance;
|
142
|
+
}
|
143
|
+
|
144
|
+
//--------------------------------------------------------------------------
|
145
|
+
//
|
146
|
+
// Constructor
|
147
|
+
//
|
148
|
+
//--------------------------------------------------------------------------
|
149
|
+
|
150
|
+
/**
|
151
|
+
* Constructor.
|
152
|
+
*/
|
153
|
+
public function LayoutManager()
|
154
|
+
{
|
155
|
+
super();
|
156
|
+
}
|
157
|
+
|
158
|
+
//--------------------------------------------------------------------------
|
159
|
+
//
|
160
|
+
// Variables
|
161
|
+
//
|
162
|
+
//--------------------------------------------------------------------------
|
163
|
+
|
164
|
+
/**
|
165
|
+
* @private
|
166
|
+
* A queue of objects that need to dispatch updateComplete events
|
167
|
+
* when invalidation processing is complete
|
168
|
+
*/
|
169
|
+
private var updateCompleteQueue:PriorityQueue = new PriorityQueue();
|
170
|
+
|
171
|
+
/**
|
172
|
+
* @private
|
173
|
+
* A queue of objects to be processed during the first phase
|
174
|
+
* of invalidation processing, when an ILayoutManagerClient has
|
175
|
+
* its validateProperties() method called (which in a UIComponent
|
176
|
+
* calls commitProperties()).
|
177
|
+
* Objects are added to this queue by invalidateProperties()
|
178
|
+
* and removed by validateProperties().
|
179
|
+
*/
|
180
|
+
private var invalidatePropertiesQueue:PriorityQueue = new PriorityQueue();
|
181
|
+
|
182
|
+
/**
|
183
|
+
* @private
|
184
|
+
* A flag indicating whether there are objects
|
185
|
+
* in the invalidatePropertiesQueue.
|
186
|
+
* It is set true by invalidateProperties()
|
187
|
+
* and set false by validateProperties().
|
188
|
+
*/
|
189
|
+
private var invalidatePropertiesFlag:Boolean = false;
|
190
|
+
|
191
|
+
// flag when in validateClient to check the properties queue again
|
192
|
+
private var invalidateClientPropertiesFlag:Boolean = false;
|
193
|
+
|
194
|
+
/**
|
195
|
+
* @private
|
196
|
+
* A queue of objects to be processed during the second phase
|
197
|
+
* of invalidation processing, when an ILayoutManagerClient has
|
198
|
+
* its validateSize() method called (which in a UIComponent
|
199
|
+
* calls measure()).
|
200
|
+
* Objects are added to this queue by invalidateSize().
|
201
|
+
* and removed by validateSize().
|
202
|
+
*/
|
203
|
+
private var invalidateSizeQueue:PriorityQueue = new PriorityQueue();
|
204
|
+
|
205
|
+
/**
|
206
|
+
* @private
|
207
|
+
* A flag indicating whether there are objects
|
208
|
+
* in the invalidateSizeQueue.
|
209
|
+
* It is set true by invalidateSize()
|
210
|
+
* and set false by validateSize().
|
211
|
+
*/
|
212
|
+
private var invalidateSizeFlag:Boolean = false;
|
213
|
+
|
214
|
+
// flag when in validateClient to check the size queue again
|
215
|
+
private var invalidateClientSizeFlag:Boolean = false;
|
216
|
+
|
217
|
+
/**
|
218
|
+
* @private
|
219
|
+
* A queue of objects to be processed during the third phase
|
220
|
+
* of invalidation processing, when an ILayoutManagerClient has
|
221
|
+
* its validateDisplayList() method called (which in a
|
222
|
+
* UIComponent calls updateDisplayList()).
|
223
|
+
* Objects are added to this queue by invalidateDisplayList()
|
224
|
+
* and removed by validateDisplayList().
|
225
|
+
*/
|
226
|
+
private var invalidateDisplayListQueue:PriorityQueue = new PriorityQueue();
|
227
|
+
|
228
|
+
/**
|
229
|
+
* @private
|
230
|
+
* A flag indicating whether there are objects
|
231
|
+
* in the invalidateDisplayListQueue.
|
232
|
+
* It is set true by invalidateDisplayList()
|
233
|
+
* and set false by validateDisplayList().
|
234
|
+
*/
|
235
|
+
private var invalidateDisplayListFlag:Boolean = false;
|
236
|
+
|
237
|
+
/**
|
238
|
+
* @private
|
239
|
+
*/
|
240
|
+
private var callLaterObject:UIComponent;
|
241
|
+
|
242
|
+
/**
|
243
|
+
* @private
|
244
|
+
*/
|
245
|
+
private var callLaterPending:Boolean = false;
|
246
|
+
|
247
|
+
/**
|
248
|
+
* @private
|
249
|
+
*/
|
250
|
+
private var originalFrameRate:Number;
|
251
|
+
|
252
|
+
/**
|
253
|
+
* @private
|
254
|
+
* used in validateClient to quickly estimate whether we have to
|
255
|
+
* search the queues again
|
256
|
+
*/
|
257
|
+
private var targetLevel:int = int.MAX_VALUE;
|
258
|
+
|
259
|
+
//--------------------------------------------------------------------------
|
260
|
+
//
|
261
|
+
// Properties
|
262
|
+
//
|
263
|
+
//--------------------------------------------------------------------------
|
264
|
+
|
265
|
+
//----------------------------------
|
266
|
+
// usePhasedInstantiation
|
267
|
+
//----------------------------------
|
268
|
+
|
269
|
+
/**
|
270
|
+
* @private
|
271
|
+
* Storage for the usePhasedInstantiation property.
|
272
|
+
*/
|
273
|
+
private var _usePhasedInstantiation:Boolean = false;
|
274
|
+
|
275
|
+
/**
|
276
|
+
* A flag that indicates whether the LayoutManager allows screen updates
|
277
|
+
* between phases.
|
278
|
+
* If <code>true</code>, measurement and layout are done in phases, one phase
|
279
|
+
* per screen update.
|
280
|
+
* All components have their <code>validateProperties()</code>
|
281
|
+
* and <code>commitProperties()</code> methods
|
282
|
+
* called until all their properties are validated.
|
283
|
+
* The screen will then be updated.
|
284
|
+
*
|
285
|
+
* <p>Then all components will have their <code>validateSize()</code>
|
286
|
+
* and <code>measure()</code>
|
287
|
+
* methods called until all components have been measured, then the screen
|
288
|
+
* will be updated again. </p>
|
289
|
+
*
|
290
|
+
* <p>Finally, all components will have their
|
291
|
+
* <code>validateDisplayList()</code> and
|
292
|
+
* <code>updateDisplayList()</code> methods called until all components
|
293
|
+
* have been validated, and the screen will be updated again.
|
294
|
+
* If in the validation of one phase, an earlier phase gets invalidated,
|
295
|
+
* the LayoutManager starts over.
|
296
|
+
* This is more efficient when large numbers of components
|
297
|
+
* are being created an initialized. The framework is responsible for setting
|
298
|
+
* this property.</p>
|
299
|
+
*
|
300
|
+
* <p>If <code>false</code>, all three phases are completed before the screen is updated.</p>
|
301
|
+
*/
|
302
|
+
public function get usePhasedInstantiation():Boolean
|
303
|
+
{
|
304
|
+
return _usePhasedInstantiation;
|
305
|
+
}
|
306
|
+
|
307
|
+
/**
|
308
|
+
* @private
|
309
|
+
*/
|
310
|
+
public function set usePhasedInstantiation(value:Boolean):void
|
311
|
+
{
|
312
|
+
if (_usePhasedInstantiation != value)
|
313
|
+
{
|
314
|
+
_usePhasedInstantiation = value;
|
315
|
+
|
316
|
+
// While we're doing phased instantiation, temporarily increase
|
317
|
+
// the frame rate. That will cause the enterFrame and render
|
318
|
+
// events to fire more promptly, which improves performance.
|
319
|
+
var stage:Stage = SystemManager.topLevelSystemManagers[0].stage;
|
320
|
+
if (value)
|
321
|
+
{
|
322
|
+
originalFrameRate = stage.frameRate;
|
323
|
+
stage.frameRate = 1000;
|
324
|
+
}
|
325
|
+
else
|
326
|
+
{
|
327
|
+
stage.frameRate = originalFrameRate;
|
328
|
+
}
|
329
|
+
}
|
330
|
+
}
|
331
|
+
|
332
|
+
//--------------------------------------------------------------------------
|
333
|
+
//
|
334
|
+
// Methods: Invalidation
|
335
|
+
//
|
336
|
+
//--------------------------------------------------------------------------
|
337
|
+
|
338
|
+
/**
|
339
|
+
* Adds an object to the list of components that want their
|
340
|
+
* <code>validateProperties()</code> method called.
|
341
|
+
* A component should call this method when a property changes.
|
342
|
+
* Typically, a property setter method
|
343
|
+
* stores a the new value in a temporary variable and calls
|
344
|
+
* the <code>invalidateProperties()</code> method
|
345
|
+
* so that its <code>validateProperties()</code>
|
346
|
+
* and <code>commitProperties()</code> methods are called
|
347
|
+
* later, when the new value will actually be applied to the component and/or
|
348
|
+
* its children. The advantage of this strategy is that often, more than one
|
349
|
+
* property is changed at a time and the properties may interact with each
|
350
|
+
* other, or repeat some code as they are applied, or need to be applied in
|
351
|
+
* a specific order. This strategy allows the most efficient method of
|
352
|
+
* applying new property values.
|
353
|
+
*
|
354
|
+
* @param obj The object whose property changed.
|
355
|
+
*/
|
356
|
+
public function invalidateProperties(obj:ILayoutManagerClient ):void
|
357
|
+
{
|
358
|
+
if (!invalidatePropertiesFlag && Application.application.systemManager)
|
359
|
+
{
|
360
|
+
invalidatePropertiesFlag = true;
|
361
|
+
|
362
|
+
if (!callLaterPending)
|
363
|
+
{
|
364
|
+
if (!callLaterObject)
|
365
|
+
{
|
366
|
+
callLaterObject = new UIComponent();
|
367
|
+
callLaterObject.systemManager =
|
368
|
+
Application.application.systemManager;
|
369
|
+
callLaterObject.callLater(waitAFrame);
|
370
|
+
}
|
371
|
+
else
|
372
|
+
{
|
373
|
+
callLaterObject.callLater(doPhasedInstantiation);
|
374
|
+
}
|
375
|
+
|
376
|
+
callLaterPending = true;
|
377
|
+
}
|
378
|
+
}
|
379
|
+
|
380
|
+
// trace("LayoutManager adding " + Object(obj) + " to invalidatePropertiesQueue");
|
381
|
+
|
382
|
+
if (targetLevel <= obj.nestLevel)
|
383
|
+
invalidateClientPropertiesFlag = true;
|
384
|
+
|
385
|
+
invalidatePropertiesQueue.addObject(obj, obj.nestLevel);
|
386
|
+
|
387
|
+
// trace("LayoutManager added " + Object(obj) + " to invalidatePropertiesQueue");
|
388
|
+
}
|
389
|
+
|
390
|
+
/**
|
391
|
+
* Adds an object to the list of components that want their
|
392
|
+
* <code>validateSize()</code> method called.
|
393
|
+
* Called when an object's size changes.
|
394
|
+
*
|
395
|
+
* <p>An object's size can change for two reasons:</p>
|
396
|
+
*
|
397
|
+
* <ol>
|
398
|
+
* <li>The content of the object changes. For example, the size of a
|
399
|
+
* button changes when its <code>label</code> is changed.</li>
|
400
|
+
* <li>A script explicitly changes one of the following properties:
|
401
|
+
* <code>minWidth</code>, <code>minHeight</code>,
|
402
|
+
* <code>explicitWidth</code>, <code>explicitHeight</code>,
|
403
|
+
* <code>maxWidth</code>, or <code>maxHeight</code>.</li>
|
404
|
+
* </ol>
|
405
|
+
*
|
406
|
+
* <p>When the first condition occurs, it's necessary to recalculate
|
407
|
+
* the measurements for the object.
|
408
|
+
* When the second occurs, it's not necessary to recalculate the
|
409
|
+
* measurements because the new size of the object is known.
|
410
|
+
* However, it's necessary to remeasure and relayout the object's
|
411
|
+
* parent.</p>
|
412
|
+
*
|
413
|
+
* @param obj The object whose size changed.
|
414
|
+
*/
|
415
|
+
public function invalidateSize(obj:ILayoutManagerClient ):void
|
416
|
+
{
|
417
|
+
if (!invalidateSizeFlag && Application.application.systemManager)
|
418
|
+
{
|
419
|
+
invalidateSizeFlag = true;
|
420
|
+
|
421
|
+
if (!callLaterPending)
|
422
|
+
{
|
423
|
+
if (!callLaterObject)
|
424
|
+
{
|
425
|
+
callLaterObject = new UIComponent();
|
426
|
+
callLaterObject.systemManager =
|
427
|
+
Application.application.systemManager;
|
428
|
+
callLaterObject.callLater(waitAFrame);
|
429
|
+
}
|
430
|
+
else
|
431
|
+
{
|
432
|
+
callLaterObject.callLater(doPhasedInstantiation);
|
433
|
+
}
|
434
|
+
|
435
|
+
callLaterPending = true;
|
436
|
+
}
|
437
|
+
}
|
438
|
+
|
439
|
+
// trace("LayoutManager adding " + Object(obj) + " to invalidateSizeQueue");
|
440
|
+
|
441
|
+
if (targetLevel <= obj.nestLevel)
|
442
|
+
invalidateClientSizeFlag = true;
|
443
|
+
|
444
|
+
invalidateSizeQueue.addObject(obj, obj.nestLevel);
|
445
|
+
|
446
|
+
// trace("LayoutManager added " + Object(obj) + " to invalidateSizeQueue");
|
447
|
+
}
|
448
|
+
|
449
|
+
/**
|
450
|
+
* Called when a component changes in some way that its layout and/or visuals
|
451
|
+
* need to be changed.
|
452
|
+
* In that case, it is necessary to run the component's layout algorithm,
|
453
|
+
* even if the component's size hasn't changed. For example, when a new child component
|
454
|
+
* is added, or a style property changes or the component has been given
|
455
|
+
* a new size by its parent.
|
456
|
+
*
|
457
|
+
* @param obj The object that changed.
|
458
|
+
*/
|
459
|
+
public function invalidateDisplayList(obj:ILayoutManagerClient ):void
|
460
|
+
{
|
461
|
+
if (!invalidateDisplayListFlag && Application.application.systemManager)
|
462
|
+
{
|
463
|
+
invalidateDisplayListFlag = true;
|
464
|
+
|
465
|
+
if (!callLaterPending)
|
466
|
+
{
|
467
|
+
if (!callLaterObject)
|
468
|
+
{
|
469
|
+
callLaterObject = new UIComponent();
|
470
|
+
callLaterObject.systemManager =
|
471
|
+
Application.application.systemManager;
|
472
|
+
callLaterObject.callLater(waitAFrame);
|
473
|
+
}
|
474
|
+
else
|
475
|
+
{
|
476
|
+
callLaterObject.callLater(doPhasedInstantiation);
|
477
|
+
}
|
478
|
+
|
479
|
+
callLaterPending = true;
|
480
|
+
}
|
481
|
+
}
|
482
|
+
|
483
|
+
// trace("LayoutManager adding " + Object(obj) + " to invalidateDisplayListQueue");
|
484
|
+
|
485
|
+
invalidateDisplayListQueue.addObject(obj, obj.nestLevel);
|
486
|
+
|
487
|
+
// trace("LayoutManager added " + Object(obj) + " to invalidateDisplayListQueue");
|
488
|
+
}
|
489
|
+
|
490
|
+
//--------------------------------------------------------------------------
|
491
|
+
//
|
492
|
+
// Methods: Commitment, measurement, layout, and drawing
|
493
|
+
//
|
494
|
+
//--------------------------------------------------------------------------
|
495
|
+
|
496
|
+
/**
|
497
|
+
* Validates all components whose properties have changed and have called
|
498
|
+
* the <code>invalidateProperties()</code> method.
|
499
|
+
* It calls the <code>validateProperties()</code> method on those components
|
500
|
+
* and will call <code>validateProperties()</code> on any other components that are
|
501
|
+
* invalidated while validating other components.
|
502
|
+
*/
|
503
|
+
private function validateProperties():void
|
504
|
+
{
|
505
|
+
// trace("--- LayoutManager: validateProperties --->");
|
506
|
+
|
507
|
+
// Keep traversing the invalidatePropertiesQueue until we've reached the end.
|
508
|
+
// More elements may get added to the queue while we're in this loop, or a
|
509
|
+
// a recursive call to this function may remove elements from the queue while
|
510
|
+
// we're in this loop.
|
511
|
+
var obj:ILayoutManagerClient = ILayoutManagerClient(invalidatePropertiesQueue.removeSmallest());
|
512
|
+
while (obj)
|
513
|
+
{
|
514
|
+
// trace("LayoutManager calling validateProperties() on " + Object(obj) + " " + DisplayObject(obj).width + " " + DisplayObject(obj).height);
|
515
|
+
|
516
|
+
obj.validateProperties();
|
517
|
+
if (!obj.updateCompletePendingFlag)
|
518
|
+
updateCompleteQueue.addObject(obj, obj.nestLevel);
|
519
|
+
|
520
|
+
// Once we start, don't stop.
|
521
|
+
obj = ILayoutManagerClient(invalidatePropertiesQueue.removeSmallest());
|
522
|
+
}
|
523
|
+
|
524
|
+
if (invalidatePropertiesQueue.isEmpty())
|
525
|
+
{
|
526
|
+
// trace("Properties Queue is empty");
|
527
|
+
|
528
|
+
invalidatePropertiesFlag = false;
|
529
|
+
}
|
530
|
+
|
531
|
+
// trace("<--- LayoutManager: validateProperties ---");
|
532
|
+
}
|
533
|
+
|
534
|
+
/**
|
535
|
+
* Validates all components whose properties have changed and have called
|
536
|
+
* the <code>invalidateSize()</code> method.
|
537
|
+
* It calls the <code>validateSize()</code> method on those components
|
538
|
+
* and will call the <code>validateSize()</code> method
|
539
|
+
* on any other components that are
|
540
|
+
* invalidated while validating other components.
|
541
|
+
* The </code>validateSize()</code> method starts with
|
542
|
+
* the most deeply nested child in the tree of display objects
|
543
|
+
*/
|
544
|
+
private function validateSize():void
|
545
|
+
{
|
546
|
+
// trace("--- LayoutManager: validateSize --->");
|
547
|
+
|
548
|
+
var obj:ILayoutManagerClient = ILayoutManagerClient(invalidateSizeQueue.removeLargest());
|
549
|
+
while (obj)
|
550
|
+
{
|
551
|
+
// trace("LayoutManager calling validateSize() on " + Object(obj));
|
552
|
+
|
553
|
+
obj.validateSize();
|
554
|
+
if (!obj.updateCompletePendingFlag)
|
555
|
+
updateCompleteQueue.addObject(obj, obj.nestLevel);
|
556
|
+
|
557
|
+
// trace("LayoutManager validateSize: " + Object(obj) + " " + IFlexDisplayObject(obj).measuredWidth + " " + IFlexDisplayObject(obj).measuredHeight);
|
558
|
+
|
559
|
+
obj = ILayoutManagerClient(invalidateSizeQueue.removeLargest());
|
560
|
+
}
|
561
|
+
|
562
|
+
if (invalidateSizeQueue.isEmpty())
|
563
|
+
{
|
564
|
+
// trace("Measurement Queue is empty");
|
565
|
+
|
566
|
+
invalidateSizeFlag = false;
|
567
|
+
}
|
568
|
+
|
569
|
+
// trace("<--- LayoutManager: validateSize ---");
|
570
|
+
}
|
571
|
+
|
572
|
+
/**
|
573
|
+
* Validates all components whose properties have changed and have called
|
574
|
+
* the <code>invalidateDisplayList()</code> method.
|
575
|
+
* It calls <code>validateDisplayList()</code> method on those components
|
576
|
+
* and will call the <code>validateDisplayList()</code> method
|
577
|
+
* on any other components that are
|
578
|
+
* invalidated while validating other components.
|
579
|
+
* The <code>validateDisplayList()</code> method starts with
|
580
|
+
* the least deeply nested child in the tree of display objects
|
581
|
+
*
|
582
|
+
*/
|
583
|
+
private function validateDisplayList():void
|
584
|
+
{
|
585
|
+
|
586
|
+
// trace("--- LayoutManager: validateDisplayList --->");
|
587
|
+
|
588
|
+
var obj:ILayoutManagerClient = ILayoutManagerClient(invalidateDisplayListQueue.removeSmallest());
|
589
|
+
while (obj)
|
590
|
+
{
|
591
|
+
// trace("LayoutManager calling validateDisplayList on " + Object(obj) + " " + DisplayObject(obj).width + " " + DisplayObject(obj).height);
|
592
|
+
|
593
|
+
obj.validateDisplayList();
|
594
|
+
if (!obj.updateCompletePendingFlag)
|
595
|
+
updateCompleteQueue.addObject(obj, obj.nestLevel);
|
596
|
+
|
597
|
+
// trace("LayoutManager return from validateDisplayList on " + Object(obj) + " " + DisplayObject(obj).width + " " + DisplayObject(obj).height);
|
598
|
+
|
599
|
+
// Once we start, don't stop.
|
600
|
+
obj = ILayoutManagerClient(invalidateDisplayListQueue.removeSmallest());
|
601
|
+
}
|
602
|
+
|
603
|
+
|
604
|
+
if (invalidateDisplayListQueue.isEmpty())
|
605
|
+
{
|
606
|
+
// trace("Layout Queue is empty");
|
607
|
+
|
608
|
+
invalidateDisplayListFlag = false;
|
609
|
+
}
|
610
|
+
|
611
|
+
// trace("<--- LayoutManager: validateDisplayList ---");
|
612
|
+
}
|
613
|
+
|
614
|
+
/**
|
615
|
+
* @private
|
616
|
+
*/
|
617
|
+
private function doPhasedInstantiation():void
|
618
|
+
{
|
619
|
+
// trace(">>DoPhasedInstantation");
|
620
|
+
|
621
|
+
// If phasing, do only one phase: validateProperties(),
|
622
|
+
// validateSize(), or validateDisplayList().
|
623
|
+
if (usePhasedInstantiation)
|
624
|
+
{
|
625
|
+
if (invalidatePropertiesFlag)
|
626
|
+
{
|
627
|
+
validateProperties();
|
628
|
+
|
629
|
+
// The Preloader listens for this event.
|
630
|
+
Application.application.dispatchEvent(
|
631
|
+
new Event("validatePropertiesComplete"));
|
632
|
+
}
|
633
|
+
|
634
|
+
else if (invalidateSizeFlag)
|
635
|
+
{
|
636
|
+
validateSize();
|
637
|
+
|
638
|
+
// The Preloader listens for this event.
|
639
|
+
Application.application.dispatchEvent(
|
640
|
+
new Event("validateSizeComplete"));
|
641
|
+
}
|
642
|
+
|
643
|
+
else if (invalidateDisplayListFlag)
|
644
|
+
{
|
645
|
+
validateDisplayList();
|
646
|
+
|
647
|
+
// The Preloader listens for this event.
|
648
|
+
Application.application.dispatchEvent(
|
649
|
+
new Event("validateDisplayListComplete"));
|
650
|
+
}
|
651
|
+
}
|
652
|
+
|
653
|
+
// Otherwise, do one pass of all three phases.
|
654
|
+
else
|
655
|
+
{
|
656
|
+
if (invalidatePropertiesFlag)
|
657
|
+
validateProperties();
|
658
|
+
|
659
|
+
if (invalidateSizeFlag)
|
660
|
+
validateSize();
|
661
|
+
|
662
|
+
if (invalidateDisplayListFlag)
|
663
|
+
validateDisplayList();
|
664
|
+
}
|
665
|
+
|
666
|
+
//// trace("invalidatePropertiesFlag " + invalidatePropertiesFlag);
|
667
|
+
//// trace("invalidateSizeFlag " + invalidateSizeFlag);
|
668
|
+
//// trace("invalidateDisplayListFlag " + invalidateDisplayListFlag);
|
669
|
+
|
670
|
+
if (invalidatePropertiesFlag ||
|
671
|
+
invalidateSizeFlag ||
|
672
|
+
invalidateDisplayListFlag)
|
673
|
+
{
|
674
|
+
callLaterObject.callLater(doPhasedInstantiation);
|
675
|
+
}
|
676
|
+
else
|
677
|
+
{
|
678
|
+
usePhasedInstantiation = false;
|
679
|
+
|
680
|
+
callLaterPending = false;
|
681
|
+
|
682
|
+
var obj:ILayoutManagerClient = ILayoutManagerClient(updateCompleteQueue.removeLargest());
|
683
|
+
while (obj)
|
684
|
+
{
|
685
|
+
if (!obj.initialized && obj.processedDescriptors)
|
686
|
+
obj.initialized = true;
|
687
|
+
obj.dispatchEvent(new FlexEvent(FlexEvent.UPDATE_COMPLETE));
|
688
|
+
obj.updateCompletePendingFlag = false;
|
689
|
+
obj = ILayoutManagerClient(updateCompleteQueue.removeLargest());
|
690
|
+
}
|
691
|
+
|
692
|
+
// trace("updateComplete");
|
693
|
+
|
694
|
+
dispatchEvent(new FlexEvent(FlexEvent.UPDATE_COMPLETE));
|
695
|
+
}
|
696
|
+
|
697
|
+
// trace("<<DoPhasedInstantation");
|
698
|
+
}
|
699
|
+
|
700
|
+
/**
|
701
|
+
* When properties are changed, components generally do not apply those changes immediately.
|
702
|
+
* Instead the components usually call one of the LayoutManager's invalidate methods and
|
703
|
+
* apply the properties at a later time. The actual property you set can be read back
|
704
|
+
* immediately, but if the property affects other properties in the component or its
|
705
|
+
* children or parents, those other properties may not be immediately updated. To
|
706
|
+
* guarantee that the values are updated, you can call the <code>validateNow()</code> method.
|
707
|
+
* It updates all properties in all components before returning.
|
708
|
+
* Call this method only when necessary as it is a computationally intensive call.
|
709
|
+
*/
|
710
|
+
public function validateNow():void
|
711
|
+
{
|
712
|
+
if (!usePhasedInstantiation)
|
713
|
+
{
|
714
|
+
var infiniteLoopGuard:int = 0;
|
715
|
+
while (callLaterPending && infiniteLoopGuard++ < 100)
|
716
|
+
doPhasedInstantiation();
|
717
|
+
}
|
718
|
+
}
|
719
|
+
|
720
|
+
/**
|
721
|
+
* When properties are changed, components generally do not apply those changes immediately.
|
722
|
+
* Instead the components usually call one of the LayoutManager's invalidate methods and
|
723
|
+
* apply the properties at a later time. The actual property you set can be read back
|
724
|
+
* immediately, but if the property affects other properties in the component or its
|
725
|
+
* children or parents, those other properties may not be immediately updated.
|
726
|
+
*
|
727
|
+
* <p>To guarantee that the values are updated,
|
728
|
+
* you can call the <code>validateClient()</code> method.
|
729
|
+
* It updates all properties in all components whose nest level is greater than or equal
|
730
|
+
* to the target component before returning.
|
731
|
+
* Call this method only when necessary as it is a computationally intensive call.</p>
|
732
|
+
*
|
733
|
+
* @param target The component passed in is used to test which components
|
734
|
+
* should be validated. All components contained by this component will have their
|
735
|
+
* <code>validateProperties()</code>, <code>commitProperties()</code>,
|
736
|
+
* <code>validateSize()</code>, <code>measure()</code>,
|
737
|
+
* <code>validateDisplayList()</code>,
|
738
|
+
* and <code>updateDisplayList()</code> methods called.
|
739
|
+
*
|
740
|
+
* @param skipDisplayList If <code>true</code>,
|
741
|
+
* does not call the <code>validateDisplayList()</code>
|
742
|
+
* and <code>updateDisplayList()</code> methods.
|
743
|
+
*/
|
744
|
+
public function validateClient(target:ILayoutManagerClient , skipDisplayList:Boolean = false):void
|
745
|
+
{
|
746
|
+
var obj:ILayoutManagerClient;
|
747
|
+
var i:int = 0;
|
748
|
+
var done:Boolean = false;
|
749
|
+
var oldTargetLevel:int = targetLevel;
|
750
|
+
|
751
|
+
// the theory here is that most things that get validated are deep in the tree
|
752
|
+
// and so there won't be nested calls to validateClient. However if there is,
|
753
|
+
// we don't want to have a more sophisticated scheme of keeping track
|
754
|
+
// of dirty flags at each level that is being validated, but we definitely
|
755
|
+
// do not want to keep scanning the queues unless we're pretty sure that
|
756
|
+
// something might be dirty so we just say that if something got dirty
|
757
|
+
// during this call at a deeper nesting than the first call to validateClient
|
758
|
+
// then we'll scan the queues. So we only change targetLevel if we're the
|
759
|
+
// outer call to validateClient and only that call restores it.
|
760
|
+
if (targetLevel == int.MAX_VALUE)
|
761
|
+
targetLevel = target.nestLevel;
|
762
|
+
|
763
|
+
// trace("--- LayoutManager: validateClient ---> target = " + target);
|
764
|
+
|
765
|
+
while (!done)
|
766
|
+
{
|
767
|
+
// assume we won't find anything
|
768
|
+
done = true;
|
769
|
+
|
770
|
+
// Keep traversing the invalidatePropertiesQueue until we've reached the end.
|
771
|
+
// More elements may get added to the queue while we're in this loop, or a
|
772
|
+
// a recursive call to this function may remove elements from the queue while
|
773
|
+
// we're in this loop.
|
774
|
+
obj = ILayoutManagerClient(invalidatePropertiesQueue.removeSmallestChild(target));
|
775
|
+
while (obj)
|
776
|
+
{
|
777
|
+
// trace("LayoutManager calling validateProperties() on " + Object(obj) + " " + DisplayObject(obj).width + " " + DisplayObject(obj).height);
|
778
|
+
|
779
|
+
obj.validateProperties();
|
780
|
+
if (!obj.updateCompletePendingFlag)
|
781
|
+
updateCompleteQueue.addObject(obj, obj.nestLevel);
|
782
|
+
|
783
|
+
// Once we start, don't stop.
|
784
|
+
obj = ILayoutManagerClient(invalidatePropertiesQueue.removeSmallestChild(target));
|
785
|
+
}
|
786
|
+
|
787
|
+
if (invalidatePropertiesQueue.isEmpty())
|
788
|
+
{
|
789
|
+
// trace("Properties Queue is empty");
|
790
|
+
|
791
|
+
invalidatePropertiesFlag = false;
|
792
|
+
invalidateClientPropertiesFlag = false;
|
793
|
+
}
|
794
|
+
|
795
|
+
// trace("--- LayoutManager: validateSize --->");
|
796
|
+
|
797
|
+
obj = ILayoutManagerClient(invalidateSizeQueue.removeLargestChild(target));
|
798
|
+
while (obj)
|
799
|
+
{
|
800
|
+
// trace("LayoutManager calling validateSize() on " + Object(obj));
|
801
|
+
|
802
|
+
obj.validateSize();
|
803
|
+
if (!obj.updateCompletePendingFlag)
|
804
|
+
updateCompleteQueue.addObject(obj, obj.nestLevel);
|
805
|
+
|
806
|
+
// trace("LayoutManager validateSize: " + Object(obj) + " " + IFlexDisplayObject(obj).measuredWidth + " " + IFlexDisplayObject(obj).measuredHeight);
|
807
|
+
|
808
|
+
if (invalidateClientPropertiesFlag)
|
809
|
+
{
|
810
|
+
// did any properties get invalidated while validating size?
|
811
|
+
obj = ILayoutManagerClient(invalidatePropertiesQueue.removeSmallestChild(target));
|
812
|
+
if (obj)
|
813
|
+
{
|
814
|
+
// re-queue it. we'll pull it at the beginning of the loop
|
815
|
+
invalidatePropertiesQueue.addObject(obj, obj.nestLevel);
|
816
|
+
done = false;
|
817
|
+
break;
|
818
|
+
}
|
819
|
+
}
|
820
|
+
|
821
|
+
obj = ILayoutManagerClient(invalidateSizeQueue.removeLargestChild(target));
|
822
|
+
}
|
823
|
+
|
824
|
+
if (invalidateSizeQueue.isEmpty())
|
825
|
+
{
|
826
|
+
// trace("Measurement Queue is empty");
|
827
|
+
|
828
|
+
invalidateSizeFlag = false;
|
829
|
+
invalidateClientSizeFlag = false;
|
830
|
+
}
|
831
|
+
|
832
|
+
if (!skipDisplayList)
|
833
|
+
{
|
834
|
+
// trace("--- LayoutManager: validateDisplayList --->");
|
835
|
+
|
836
|
+
obj = ILayoutManagerClient(invalidateDisplayListQueue.removeSmallestChild(target));
|
837
|
+
while (obj)
|
838
|
+
{
|
839
|
+
// trace("LayoutManager calling validateDisplayList on " + Object(obj) + " " + DisplayObject(obj).width + " " + DisplayObject(obj).height);
|
840
|
+
|
841
|
+
obj.validateDisplayList();
|
842
|
+
if (!obj.updateCompletePendingFlag)
|
843
|
+
updateCompleteQueue.addObject(obj, obj.nestLevel);
|
844
|
+
|
845
|
+
// trace("LayoutManager return from validateDisplayList on " + Object(obj) + " " + DisplayObject(obj).width + " " + DisplayObject(obj).height);
|
846
|
+
|
847
|
+
if (invalidateClientPropertiesFlag)
|
848
|
+
{
|
849
|
+
// did any properties get invalidated while validating size?
|
850
|
+
obj = ILayoutManagerClient(invalidatePropertiesQueue.removeSmallestChild(target));
|
851
|
+
if (obj)
|
852
|
+
{
|
853
|
+
// re-queue it. we'll pull it at the beginning of the loop
|
854
|
+
invalidatePropertiesQueue.addObject(obj, obj.nestLevel);
|
855
|
+
done = false;
|
856
|
+
break;
|
857
|
+
}
|
858
|
+
}
|
859
|
+
|
860
|
+
if (invalidateClientSizeFlag)
|
861
|
+
{
|
862
|
+
obj = ILayoutManagerClient(invalidateSizeQueue.removeLargestChild(target));
|
863
|
+
if (obj)
|
864
|
+
{
|
865
|
+
// re-queue it. we'll pull it at the beginning of the loop
|
866
|
+
invalidateSizeQueue.addObject(obj, obj.nestLevel);
|
867
|
+
done = false;
|
868
|
+
break;
|
869
|
+
}
|
870
|
+
}
|
871
|
+
|
872
|
+
// Once we start, don't stop.
|
873
|
+
obj = ILayoutManagerClient(invalidateDisplayListQueue.removeSmallestChild(target));
|
874
|
+
}
|
875
|
+
|
876
|
+
|
877
|
+
if (invalidateDisplayListQueue.isEmpty())
|
878
|
+
{
|
879
|
+
// trace("Layout Queue is empty");
|
880
|
+
|
881
|
+
invalidateDisplayListFlag = false;
|
882
|
+
}
|
883
|
+
}
|
884
|
+
}
|
885
|
+
|
886
|
+
if (oldTargetLevel == int.MAX_VALUE)
|
887
|
+
{
|
888
|
+
targetLevel = int.MAX_VALUE;
|
889
|
+
if (!skipDisplayList)
|
890
|
+
{
|
891
|
+
obj = ILayoutManagerClient(updateCompleteQueue.removeLargestChild(target));
|
892
|
+
while (obj)
|
893
|
+
{
|
894
|
+
if (!obj.initialized)
|
895
|
+
obj.initialized = true;
|
896
|
+
obj.dispatchEvent(new FlexEvent(FlexEvent.UPDATE_COMPLETE));
|
897
|
+
obj.updateCompletePendingFlag = false;
|
898
|
+
obj = ILayoutManagerClient(updateCompleteQueue.removeLargestChild(target));
|
899
|
+
}
|
900
|
+
}
|
901
|
+
}
|
902
|
+
|
903
|
+
// trace("<--- LayoutManager: validateClient --- target = " + target);
|
904
|
+
}
|
905
|
+
|
906
|
+
/**
|
907
|
+
* Returns <code>true</code> if there are components that need validating;
|
908
|
+
* <code>false</code> if all components have been validated.
|
909
|
+
*/
|
910
|
+
public function isInvalid():Boolean
|
911
|
+
{
|
912
|
+
return invalidatePropertiesFlag ||
|
913
|
+
invalidateSizeFlag ||
|
914
|
+
invalidateDisplayListFlag;
|
915
|
+
}
|
916
|
+
|
917
|
+
/**
|
918
|
+
* @private
|
919
|
+
* callLater() is called immediately after an object is created.
|
920
|
+
* We really want to wait one more frame before starting in.
|
921
|
+
*/
|
922
|
+
private function waitAFrame():void
|
923
|
+
{
|
924
|
+
//// trace(">>LayoutManager:WaitAFrame");
|
925
|
+
|
926
|
+
callLaterObject.callLater(doPhasedInstantiation);
|
927
|
+
|
928
|
+
//// trace("<<LayoutManager:WaitAFrame");
|
929
|
+
}
|
930
|
+
|
931
|
+
// METHOD ADDED BY ASUNIT
|
932
|
+
// This method prevents the LayoutManager from
|
933
|
+
// validating entities for whom tearDown has already been called...
|
934
|
+
public function resetAll():void {
|
935
|
+
invalidatePropertiesQueue = new PriorityQueue();
|
936
|
+
invalidateSizeQueue = new PriorityQueue();
|
937
|
+
invalidateDisplayListQueue = new PriorityQueue();
|
938
|
+
|
939
|
+
invalidatePropertiesFlag = false;
|
940
|
+
invalidateClientSizeFlag = false;
|
941
|
+
invalidateDisplayListFlag = false;
|
942
|
+
}
|
943
|
+
}
|
944
|
+
|
945
|
+
}
|