@flashist/appframework 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/gulp/tasks/clean.js +9 -0
  2. package/gulp/tasks/compile.js +27 -0
  3. package/gulp/tasks/copy-to-dist.js +15 -0
  4. package/gulp/tasks/generate-definitions.js +86 -0
  5. package/gulpfile.js +22 -0
  6. package/package.json +30 -0
  7. package/src/app/AppModule.ts +26 -0
  8. package/src/app/AppSettings.ts +9 -0
  9. package/src/app/commands/LoadAppConfigCommand.ts +61 -0
  10. package/src/app/commands/ParseStaticItemsConfigCommand.ts +32 -0
  11. package/src/app/data/AppConfigType.ts +1 -0
  12. package/src/app/data/AppConfigVO.ts +27 -0
  13. package/src/app/data/IAppModelStorageVO.ts +4 -0
  14. package/src/app/data/IItemsConfigVO.ts +5 -0
  15. package/src/app/managers/AppManager.ts +68 -0
  16. package/src/app/models/AppConfigModel.ts +20 -0
  17. package/src/app/models/AppModel.ts +18 -0
  18. package/src/app/views/AppMainContainer.ts +23 -0
  19. package/src/assets/AssetsModule.ts +13 -0
  20. package/src/assets/commands/ParseAssetsConfigCommand.ts +25 -0
  21. package/src/assets/data/IAssetsConfigVO.ts +5 -0
  22. package/src/assets/models/AssetsModel.ts +7 -0
  23. package/src/base/BaseObjectWithGlobalDispatcher.ts +23 -0
  24. package/src/base/commands/BaseAppCommand.ts +22 -0
  25. package/src/base/data/BaseAppObjectWithStaticVO.ts +15 -0
  26. package/src/base/managers/BaseAppManager.ts +5 -0
  27. package/src/base/mediators/BaseAppMediator.ts +24 -0
  28. package/src/base/models/BaseAppGenericObjectsModel.ts +23 -0
  29. package/src/base/models/BaseAppModel.ts +5 -0
  30. package/src/base/modules/AppModulesManager.ts +44 -0
  31. package/src/base/modules/BaseAppModule.ts +17 -0
  32. package/src/base/views/BaseAppView.ts +25 -0
  33. package/src/containers/ContainersModule.ts +13 -0
  34. package/src/containers/managers/ContainersManager.ts +27 -0
  35. package/src/data/IAppGenericObjectVO.ts +5 -0
  36. package/src/date/DateSettings.ts +6 -0
  37. package/src/debug/DebugModule.ts +22 -0
  38. package/src/dependencies/DependenciesModule.ts +13 -0
  39. package/src/display/data/IGetSizable.ts +5 -0
  40. package/src/display/tools/GetSizeTools.ts +25 -0
  41. package/src/display/views/AppContainer.ts +20 -0
  42. package/src/display/views/button/BaseBtn.ts +325 -0
  43. package/src/display/views/button/BaseBtnEvent.ts +4 -0
  44. package/src/display/views/button/BaseBtnState.ts +31 -0
  45. package/src/display/views/button/BaseBtnView.ts +230 -0
  46. package/src/display/views/button/DefaultButtonViewConfig.ts +10 -0
  47. package/src/display/views/button/IButtonViewConfig.ts +16 -0
  48. package/src/display/views/button/ISimpleButtonConfig.ts +22 -0
  49. package/src/display/views/button/SimpleButtonState.ts +31 -0
  50. package/src/display/views/button/SimpleButtonView.ts +226 -0
  51. package/src/display/views/getsize/GetSizeTools.ts +32 -0
  52. package/src/display/views/getsize/IGetSizeObject.ts +5 -0
  53. package/src/display/views/layout/BaseLayout.ts +160 -0
  54. package/src/display/views/layout/ColumnLayout.ts +120 -0
  55. package/src/display/views/layout/LayoutConfig.ts +15 -0
  56. package/src/display/views/layout/RowLayout.ts +115 -0
  57. package/src/display/views/layout/container/BaseLayoutableContainer.ts +21 -0
  58. package/src/display/views/layout/container/ILayoutableChild.ts +3 -0
  59. package/src/display/views/layout/container/ILayoutableContainer.ts +18 -0
  60. package/src/display/views/resize/IResizable.ts +6 -0
  61. package/src/display/views/resize/ResizableContainer.ts +80 -0
  62. package/src/display/views/simplelist/ISimpleListItem.ts +5 -0
  63. package/src/display/views/simplelist/SimpleList.ts +318 -0
  64. package/src/display/views/simplelist/SimpleListEvent.ts +4 -0
  65. package/src/display/views/sizedistributor/ISizeDistributorChild.ts +5 -0
  66. package/src/display/views/sizedistributor/SizeDistributor.ts +129 -0
  67. package/src/display/views/sizedistributor/SizeDistributorConfig.ts +12 -0
  68. package/src/display/views/togglegroup/IToggableItem.ts +6 -0
  69. package/src/display/views/togglegroup/IToggleGroupItem.ts +6 -0
  70. package/src/display/views/togglegroup/ToggleGroup.ts +140 -0
  71. package/src/display/views/togglegroup/ToggleGroupEvent.ts +3 -0
  72. package/src/display/views/viewstack/IViewStackItem.ts +7 -0
  73. package/src/display/views/viewstack/ViewLazyCreationServiceLocatorStack.ts +19 -0
  74. package/src/display/views/viewstack/ViewLazyCreationStack.ts +47 -0
  75. package/src/display/views/viewstack/ViewStack.ts +93 -0
  76. package/src/display/views/viewstack/ViewStackLazyCreation.ts +45 -0
  77. package/src/events/commands/DispatchGlobalEventCommand.ts +22 -0
  78. package/src/facade/Facade.ts +194 -0
  79. package/src/facade/IFacadeOptions.ts +7 -0
  80. package/src/globaleventdispatcher/GlobalEventDispatcherModule.ts +16 -0
  81. package/src/globaleventdispatcher/commands/WaitGlobalEventCommand.ts +25 -0
  82. package/src/globaleventdispatcher/dispatcher/GlobalEventDispatcher.ts +53 -0
  83. package/src/globaleventdispatcher/dispatcher/GlobalEventDispatcherEvent.ts +4 -0
  84. package/src/globaleventdispatcher/dispatcher/IGlobalDispatchEventVO.ts +4 -0
  85. package/src/globaleventdispatcher/managers/GlobalEventsCommandManager.ts +26 -0
  86. package/src/hints/commands/AnimateHintCommand.ts +99 -0
  87. package/src/hints/data/DefaultHintConfig.ts +22 -0
  88. package/src/hints/data/HintContainerId.ts +1 -0
  89. package/src/hints/data/IHintConfig.ts +20 -0
  90. package/src/html/HTMLModule.ts +13 -0
  91. package/src/html/managers/HTMLManager.ts +32 -0
  92. package/src/index.ts +21 -0
  93. package/src/init/commands/InitApplicationCommand.ts +34 -0
  94. package/src/init/commands/InitApplicationDataCommand.ts +19 -0
  95. package/src/init/commands/InitApplicationDataEvent.ts +3 -0
  96. package/src/load/LoadGroupName.ts +5 -0
  97. package/src/load/LoadModule.ts +23 -0
  98. package/src/load/LoaderId.ts +5 -0
  99. package/src/locales/LocalesModule.ts +11 -0
  100. package/src/locales/commands/ParseLocaleConfigCommand.ts +28 -0
  101. package/src/package.json +36 -0
  102. package/src/pages/PageId.ts +4 -0
  103. package/src/pages/PagesModule.ts +13 -0
  104. package/src/pages/commands/ChangePageCommand.ts +18 -0
  105. package/src/pages/models/PagesModel.ts +38 -0
  106. package/src/pages/models/PagesModelEvent.ts +3 -0
  107. package/src/pages/views/BasePageView.ts +75 -0
  108. package/src/pages/views/PagesView.ts +57 -0
  109. package/src/pool/ObjectsPoolModule.ts +13 -0
  110. package/src/renderer/RendererModule.ts +14 -0
  111. package/src/renderer/events/RendererManagerEvent.ts +3 -0
  112. package/src/renderer/managers/RendererManager.ts +52 -0
  113. package/src/server/ServerModule.ts +14 -0
  114. package/src/server/commands/BaseServerCommand.ts +39 -0
  115. package/src/server/data/IServerRequestVO.ts +12 -0
  116. package/src/server/data/IServerResponseVO.ts +15 -0
  117. package/src/server/data/ServerErrorCode.ts +3 -0
  118. package/src/server/models/ServerModel.ts +34 -0
  119. package/src/sounds/SoundsModule.ts +24 -0
  120. package/src/sounds/SoundsSettings.ts +5 -0
  121. package/src/sounds/managers/BackgroundMusicManager.ts +48 -0
  122. package/src/sounds/managers/SoundsStorageManager.ts +45 -0
  123. package/src/storage/StorageModule.ts +13 -0
  124. package/src/storage/StorageModuleConfig.ts +3 -0
  125. package/src/storage/managers/StorageManager.ts +159 -0
  126. package/src/strategy/managers/BaseStrategyManager.ts +37 -0
  127. package/src/strategy/models/BaseStrategyModel.ts +40 -0
  128. package/src/strategy/strategies/BaseStrategy.ts +21 -0
  129. package/src/time/TimeModule.ts +16 -0
  130. package/src/time/managers/TimeManager.ts +29 -0
  131. package/src/time/models/TimeModel.ts +29 -0
  132. package/src/time/models/TimeModelEvent.ts +3 -0
  133. package/src/windows/data/IWindowConfigVO.ts +9 -0
  134. package/src/windows/managers/IShowWindowVO.ts +4 -0
  135. package/src/windows/managers/WindowsManager.ts +72 -0
  136. package/src/windows/views/BaseWindow.ts +22 -0
  137. package/tsconfig.json +19 -0
@@ -0,0 +1,318 @@
1
+ import {ArrayTools, Dictionary, IConstructor, Logger, ObjectTools} from "@flashist/fcore";
2
+
3
+ import {DisplayTools, FContainer, Point} from "@flashist/flibs";
4
+
5
+ import {ISimpleListItem} from "./ISimpleListItem";
6
+ import {ILayoutableContainer} from "../layout/container/ILayoutableContainer";
7
+ import {IResizable} from "../resize/IResizable";
8
+
9
+ export class SimpleList
10
+ <ItemType extends ISimpleListItem = ISimpleListItem, ItemData extends any = any>
11
+ extends FContainer
12
+ implements ILayoutableContainer {
13
+
14
+ private _dataProvider: ItemData[];
15
+ private _itemsDataPropertyName: string;
16
+ private _itemsProperties: any;
17
+
18
+ private _ItemRendererClass: IConstructor<ItemType>;
19
+
20
+ protected items: ItemType[];
21
+ protected cacheItems: ItemType[];
22
+
23
+ public useItemsCache: boolean;
24
+ public reuseItemsForConcreteData: boolean;
25
+
26
+ protected construction(): void {
27
+ super.construction();
28
+
29
+ this._dataProvider = [];
30
+ this.items = [];
31
+ this.cacheItems = [];
32
+ this._itemsDataPropertyName = "data";
33
+ }
34
+
35
+ public get ItemRendererClass(): IConstructor<ItemType> {
36
+ return this._ItemRendererClass;
37
+ }
38
+ public set ItemRendererClass(value: IConstructor<ItemType>) {
39
+ if (value == this._ItemRendererClass) {
40
+ return;
41
+ }
42
+
43
+ this._ItemRendererClass = value;
44
+
45
+ this.commitItemsData();
46
+ }
47
+
48
+ get itemsProperties(): any {
49
+ return this._itemsProperties;
50
+ }
51
+ set itemsProperties(value: any) {
52
+ if (value === this._itemsProperties) {
53
+ return;
54
+ }
55
+
56
+ this._itemsProperties = value;
57
+
58
+ this.commitItemsData();
59
+ }
60
+
61
+ public get dataProvider(): ItemData[] {
62
+ return this._dataProvider;
63
+ }
64
+ public set dataProvider(value: ItemData[]) {
65
+ if (!value) {
66
+ value = [];
67
+ }
68
+
69
+ if (ArrayTools.checkIfEqual(value, this.dataProvider)) {
70
+ return;
71
+ }
72
+
73
+ this._dataProvider = value;
74
+
75
+ this.commitItemsData();
76
+ }
77
+
78
+ public get itemsDataPropertyName(): string {
79
+ return this._itemsDataPropertyName;
80
+ }
81
+ public set itemsDataPropertyName(value: string) {
82
+ if (value == this._itemsDataPropertyName) {
83
+ return;
84
+ }
85
+
86
+ this._itemsDataPropertyName = value;
87
+
88
+ this.commitItemsData();
89
+ }
90
+
91
+
92
+ protected getItemFromCacheToReuse(data: ItemData): ItemType {
93
+ let result: ItemType;
94
+ for (let item of this.cacheItems) {
95
+ if (item[this._itemsDataPropertyName] === data) {
96
+ result = item;
97
+ // Remove item from the cache, to prevent reusing it as a regular cached item
98
+ ArrayTools.removeItem(this.cacheItems, result);
99
+ break;
100
+ }
101
+ }
102
+
103
+ return result;
104
+ }
105
+
106
+ protected getItemFromCache(): ItemType {
107
+ let result: ItemType;
108
+
109
+ if (this.cacheItems.length > 0) {
110
+ result = this.cacheItems.shift();
111
+ }
112
+
113
+ return result;
114
+ }
115
+
116
+ addItemToCache(item: ItemType): void {
117
+ if (this.cacheItems.indexOf(item) !== -1) {
118
+ return;
119
+ }
120
+
121
+ this.cacheItems.push(item);
122
+ }
123
+
124
+ removeItemFromCache(item: ItemType): void {
125
+ ArrayTools.removeItem(this.cacheItems, item);
126
+ }
127
+
128
+ protected commitItemsData(): void {
129
+ if (!this.ItemRendererClass) {
130
+
131
+ } else if (!this.dataProvider) {
132
+ this.removeAllItems();
133
+
134
+ } else {
135
+ var tempData: any;
136
+ var tempItem: ItemType;
137
+ var itemIndex: number;
138
+ var itemsCount: number = this.dataProvider.length;
139
+
140
+
141
+ var prevItems: ItemType[] = this.items.concat();
142
+
143
+ if (this.items.length) {
144
+ var maxStepsCount: number = 100000;
145
+ var stepIndex: number = 0;
146
+ while (this.items.length > 0) {
147
+ tempItem = this.items[0];
148
+ this.removeItem(tempItem, false);
149
+
150
+ stepIndex++;
151
+ if (stepIndex >= maxStepsCount) {
152
+ Logger.log("SimpleList | commitItemsData", "WARNING! Max steps count reached!");
153
+ break;
154
+ }
155
+ }
156
+ }
157
+
158
+ var reuseItemsToDataMap: Dictionary<ItemData, ItemType> = new Dictionary();
159
+ var reuseDataItems: ItemType[] = [];
160
+ if (this.reuseItemsForConcreteData) {
161
+ itemsCount = this.dataProvider.length;
162
+ for (itemIndex = 0; itemIndex < itemsCount; itemIndex++) {
163
+ tempData = this.dataProvider[itemIndex];
164
+ tempItem = this.getItemFromCacheToReuse(tempData);
165
+
166
+ if (tempItem) {
167
+ reuseDataItems.push(tempItem);
168
+ reuseItemsToDataMap.addItem(tempData, tempItem);
169
+ }
170
+ }
171
+
172
+ // Remove all items, which will be reused for specific data, from the cache
173
+ // ArrayTools.removeItems(this.cacheItems, reuseDataItems);
174
+ }
175
+
176
+ // Creation of items
177
+ for (itemIndex = 0; itemIndex < itemsCount; itemIndex++) {
178
+ tempItem = null;
179
+ tempData = this.dataProvider[itemIndex];
180
+
181
+ // If cache should be used
182
+ if (this.useItemsCache) {
183
+ // If reusing elements for specific data is turned on,
184
+ // try to find an item for specific data
185
+ if (this.reuseItemsForConcreteData) {
186
+ //tempItem = this.getItemFromCache(tempData, this.reuseItemsForConcreteData);
187
+ // tempItem = this.getItemFromCacheToReuse(tempData);
188
+ tempItem = reuseItemsToDataMap.getItem(tempData);
189
+ if (tempItem) {
190
+ reuseItemsToDataMap.removeItemByKey(tempData);
191
+ }
192
+ }
193
+
194
+ if (this.cacheItems.length > 0) {
195
+ // If a cached item for the specific data wasn't found,
196
+ // then try to get regular cached item
197
+ if (!tempItem) {
198
+ tempItem = this.getItemFromCache();
199
+ }
200
+ }
201
+ }
202
+
203
+ if (!tempItem) {
204
+ tempItem = new this.ItemRendererClass();
205
+ }
206
+
207
+ this.addItem(tempItem, itemIndex);
208
+ }
209
+
210
+ // Remove newly used items from the list of the previously used items
211
+ ArrayTools.removeItems(prevItems, this.items);
212
+ // Remove all previously used items (and add them to cache if allowed)
213
+ itemsCount = prevItems.length;
214
+ for (itemIndex = 0; itemIndex < itemsCount; itemIndex++) {
215
+ tempItem = prevItems[itemIndex];
216
+
217
+ this.removeItem(tempItem);
218
+ }
219
+ }
220
+
221
+ if (this.items && this._itemsProperties) {
222
+ for (const singleItem of this.items) {
223
+ ObjectTools.copyProps(
224
+ singleItem,
225
+ this._itemsProperties
226
+ );
227
+ }
228
+ }
229
+
230
+ this.arrange();
231
+ }
232
+
233
+ protected addItem(item: ItemType, index: number): void {
234
+ this.items[index] = item;
235
+
236
+ this.applyDataToItem(item, this.dataProvider[index]);
237
+ DisplayTools.safeAddChildAt(this, item, index);
238
+
239
+ this.resizeSingleItem(item);
240
+ }
241
+
242
+ protected removeItem(item: ItemType, removeFromDisplayList: boolean = true): void {
243
+ if (!item) {
244
+ return;
245
+ }
246
+
247
+ if (removeFromDisplayList) {
248
+ DisplayTools.childRemoveItselfFromParent(item);
249
+ }
250
+ ArrayTools.removeItem(this.items, item);
251
+
252
+ if (this.useItemsCache) {
253
+ this.addItemToCache(item);
254
+ }
255
+ }
256
+
257
+ protected applyDataToItem(item: ItemType, itemData: any): void {
258
+ if (!item) {
259
+ return;
260
+ }
261
+
262
+ item[this.itemsDataPropertyName] = itemData;
263
+ }
264
+
265
+ protected removeAllItems(): void {
266
+ DisplayTools.removeAllChildren(this);
267
+
268
+ this.items = [];
269
+ this.cacheItems = [];
270
+ }
271
+
272
+
273
+ layoutGetChildrenNum(): number {
274
+ return this.items.length;
275
+ }
276
+
277
+ layoutGetChildAt(index: number): ItemType {
278
+ return this.items[index];
279
+ }
280
+
281
+ public getItems(): ItemType[] {
282
+ return this.items.concat();
283
+ }
284
+
285
+ protected childrenResizeSize: Point;
286
+ public resizeItems(childrenWidth: number, childrenHeight: number): void {
287
+ if (!this.childrenResizeSize) {
288
+ this.childrenResizeSize = new Point();
289
+ }
290
+
291
+ if (this.childrenResizeSize.x === childrenWidth &&
292
+ this.childrenResizeSize.y === childrenHeight) {
293
+ return;
294
+ }
295
+
296
+ this.childrenResizeSize.x = childrenWidth;
297
+ this.childrenResizeSize.y = childrenHeight;
298
+
299
+ for (let singleItem of this.items) {
300
+ this.resizeSingleItem(singleItem);
301
+ }
302
+ }
303
+
304
+ protected resizeSingleItem(item: ItemType): void {
305
+ if (!this.childrenResizeSize) {
306
+ return;
307
+ }
308
+
309
+ const resizableItem: IResizable = (item as any);
310
+ if (resizableItem.resize) {
311
+ resizableItem.resize(this.childrenResizeSize.x, this.childrenResizeSize.y);
312
+
313
+ } else {
314
+ item.width = this.childrenResizeSize.x;
315
+ item.height = this.childrenResizeSize.y;
316
+ }
317
+ }
318
+ }
@@ -0,0 +1,4 @@
1
+ export const SimpleListEvent = {
2
+ ITEM_ADDED: "ITEM_ADDED",
3
+ ITEM_REMOVED: "ITEM_REMOVED"
4
+ };
@@ -0,0 +1,5 @@
1
+ import {DisplayObjectContainer} from "@flashist/flibs";
2
+ import {IResizable} from "../resize/IResizable";
3
+
4
+ export interface ISizeDistributorChild extends DisplayObjectContainer, IResizable {
5
+ }
@@ -0,0 +1,129 @@
1
+ export class SizeDistributor {
2
+
3
+ /*protected config: SizeDistributorConfig;
4
+ protected sizePerChild: Dictionary<any, Point>;
5
+
6
+ constructor(config?: Partial<SizeDistributorConfig>) {
7
+ this.config = new SizeDistributorConfig();
8
+ if (config) {
9
+ (Object as any).assign(this.config, config);
10
+ }
11
+ }
12
+
13
+ updateSize(container: ILayoutableContainer<ISizeDistributorChild>, width: number, height: number): void {
14
+
15
+ this.sizePerChild = new Dictionary<any, Point>();
16
+
17
+ let childrenCount: number = container.layoutGetChildrenNum();
18
+
19
+ let tempChild: ISizeDistributorChild;
20
+ let tempChildWidth: number;
21
+ let tempChildHeight: number;
22
+ //
23
+ let defaultChildWidth: number = 0;
24
+ let defaultChildHeight: number = 0;
25
+ //
26
+ let tempSize: Point;
27
+
28
+ // Find distribution and predefined size values
29
+ let totalPredefinedWidth: number = 0;
30
+ let totalPredefinedHeight: number = 0;
31
+ //
32
+ let predefinedWidthChildren: ISizeDistributorChild[] = [];
33
+ let predefinedHeightChildren: ISizeDistributorChild[] = [];
34
+ //
35
+ for (let childIndex = 0; childIndex < childrenCount; childIndex++) {
36
+ tempChild = container.layoutGetChildAt(childIndex);
37
+
38
+ if (this.config.distributeWidth) {
39
+ if (tempChild.getPredefinedWidth && tempChild.getPredefinedWidth()) {
40
+ tempChildWidth = tempChild.getPredefinedWidth();
41
+ predefinedWidthChildren.push(tempChild);
42
+ totalPredefinedWidth += tempChildWidth;
43
+
44
+ tempSize = this.getSizeForChild(tempChild);
45
+ tempSize.x = tempChildWidth;
46
+ }
47
+ }
48
+
49
+ if (this.config.distributeHeight) {
50
+ if (tempChild.getPredefinedHeight && tempChild.getPredefinedHeight()) {
51
+ tempChildHeight = tempChild.getPredefinedHeight();
52
+ predefinedHeightChildren.push(tempChild);
53
+ totalPredefinedHeight += tempChildHeight;
54
+
55
+ tempSize = this.getSizeForChild(tempChild, true);
56
+ tempSize.y = tempChildHeight;
57
+ }
58
+ }
59
+ }
60
+
61
+ if (this.config.distributeWidth) {
62
+ let totalAvailableWidth: number = width - totalPredefinedWidth - (this.config.paddingX * 2);
63
+ totalAvailableWidth -= (this.config.spacingX * (childrenCount - 1));
64
+ //
65
+ let distributeWidthChildrenCount: number = childrenCount - predefinedWidthChildren.length;
66
+ if (distributeWidthChildrenCount > 0) {
67
+ defaultChildWidth = totalAvailableWidth / distributeWidthChildrenCount;
68
+ }
69
+
70
+ } else {
71
+ defaultChildWidth = width;
72
+ }
73
+ // Prevent minus values
74
+ if (defaultChildWidth < 0) {
75
+ defaultChildWidth = 0;
76
+ }
77
+
78
+ if (this.config.distributeHeight) {
79
+ let totalAvailableHeight: number = height - totalPredefinedHeight - (this.config.paddingY * 2);
80
+ totalAvailableHeight -= (this.config.spacingY * (childrenCount - 1));
81
+ //
82
+ let distributeHeightChildrenCount: number = childrenCount - predefinedHeightChildren.length;
83
+ if (distributeHeightChildrenCount > 0) {
84
+ defaultChildHeight = totalAvailableHeight / distributeHeightChildrenCount;
85
+ }
86
+
87
+ } else {
88
+ defaultChildHeight = height;
89
+ }
90
+ // Prevent minus values
91
+ if (defaultChildHeight < 0) {
92
+ defaultChildHeight = 0;
93
+ }
94
+
95
+ if (this.config.isNeedFloorValues) {
96
+ defaultChildWidth = Math.floor(defaultChildWidth);
97
+ defaultChildHeight = Math.floor(defaultChildHeight);
98
+ }
99
+
100
+ // Set size
101
+ for (let childIndex = 0; childIndex < childrenCount; childIndex++) {
102
+ tempChild = (container.layoutGetChildAt(childIndex) as ISizeDistributorChild);
103
+
104
+ tempSize = this.getSizeForChild(tempChild);
105
+ if (tempSize) {
106
+ if (tempSize.x <= 0) {
107
+ tempSize.x = defaultChildWidth;
108
+ }
109
+ if (tempSize.y <= 0) {
110
+ tempSize.y = defaultChildHeight;
111
+ }
112
+
113
+ tempChild.resize(tempSize.x, tempSize.y);
114
+ }
115
+ }
116
+ }
117
+
118
+ protected getSizeForChild(child: any, isNeedCreate: boolean = true): Point {
119
+ let result: Point = this.sizePerChild.getItem(child);
120
+ if (!result) {
121
+ if (isNeedCreate) {
122
+ this.sizePerChild.addItem(child, new Point());
123
+ result = this.sizePerChild.getItem(child)
124
+ }
125
+ }
126
+
127
+ return result;
128
+ }*/
129
+ }
@@ -0,0 +1,12 @@
1
+ export class SizeDistributorConfig {
2
+ distributeWidth:boolean;
3
+ distributeHeight:boolean;
4
+
5
+ spacingX:number = 0;
6
+ spacingY:number = 0;
7
+
8
+ paddingX:number = 0;
9
+ paddingY:number = 0;
10
+
11
+ isNeedFloorValues:boolean = true;
12
+ }
@@ -0,0 +1,6 @@
1
+ import {DisplayObjectContainer} from "@flashist/flibs";
2
+
3
+ export interface IToggableItem extends DisplayObjectContainer {
4
+ id?: string;
5
+ selected: boolean;
6
+ }
@@ -0,0 +1,6 @@
1
+ import {DisplayObjectContainer} from "@flashist/flibs";
2
+
3
+ export interface IToggleGroupItem extends DisplayObjectContainer {
4
+ id: string;
5
+ selected: boolean;
6
+ }
@@ -0,0 +1,140 @@
1
+ import {AssociativeArray, BaseObject} from "@flashist/fcore";
2
+ import {InteractiveEvent} from "@flashist/flibs";
3
+
4
+ import {IToggableItem} from "./IToggableItem";
5
+ import {ToggleGroupEvent} from "./ToggleGroupEvent";
6
+
7
+ export class ToggleGroup<IToggleItemType extends IToggableItem = IToggableItem> extends BaseObject {
8
+
9
+ protected itemsToIdMap: AssociativeArray<IToggleItemType>;
10
+
11
+ private _selectedItem: IToggleItemType;
12
+ // protected toggleItems: IToggleItemType[];
13
+ protected _selectedId: string = "";
14
+
15
+ construction(...args) {
16
+ super.construction(...args);
17
+
18
+ // this.toggleItems = [];
19
+ this.itemsToIdMap = new AssociativeArray<IToggleItemType>();
20
+ }
21
+
22
+ destruction(): void {
23
+ super.destruction();
24
+
25
+ if (this.itemsToIdMap) {
26
+ this.itemsToIdMap.destruction();
27
+ }
28
+ }
29
+
30
+ protected processItemTap(item: IToggleItemType): void {
31
+ this.selectedId = item.id;
32
+ }
33
+
34
+ protected addItemListeners(item: IToggleItemType): void {
35
+ if (!item) {
36
+ return;
37
+ }
38
+
39
+ this.eventListenerHelper.addEventListener(
40
+ item,
41
+ InteractiveEvent.TAP,
42
+ () => {
43
+ this.processItemTap(item);
44
+ }
45
+ );
46
+ }
47
+
48
+ protected removeItemListeners(item: IToggleItemType): void {
49
+ if (!item) {
50
+ return;
51
+ }
52
+
53
+ this.eventListenerHelper.removeAllListeners(item);
54
+ }
55
+
56
+
57
+ addItem(item: IToggleItemType): void {
58
+ // if (this.toggleItems.indexOf(item) != -1) {
59
+ if (this.itemsToIdMap.getItem(item.id)) {
60
+ return;
61
+ }
62
+
63
+ // this.toggleItems.push(item);
64
+ this.itemsToIdMap.push(item, item.id);
65
+
66
+ this.addItemListeners(item);
67
+ }
68
+
69
+ removeItem(item: IToggleItemType): void {
70
+ if (this.selectedItem == item) {
71
+ this.selectedId = null;
72
+ }
73
+
74
+ // ArrayTools.removeItem(this.toggleItems, item);
75
+ this.itemsToIdMap.remove(item);
76
+
77
+ this.removeItemListeners(item);
78
+ }
79
+
80
+ removeAllItems(): void {
81
+ const itemsCopy: IToggleItemType[] = this.itemsToIdMap.getAllItems();
82
+ for (const item of itemsCopy) {
83
+ this.removeItem(item);
84
+ }
85
+ }
86
+
87
+ /*get selectedItem(): IToggleItemType {
88
+ return this._selectedItem;
89
+ }
90
+ set selectedItem(value: IToggleItemType) {
91
+ if (value == this._selectedItem) {
92
+ return;
93
+ }
94
+ if (value && this.toggleItems.indexOf(value) == -1) {
95
+ return;
96
+ }
97
+
98
+ // Reset the previous selected item
99
+ if (this._selectedItem) {
100
+ this._selectedItem.selected = false;
101
+ }
102
+
103
+ this._selectedItem = value;
104
+ // Setup the new selected item
105
+ if (this._selectedItem) {
106
+ this._selectedItem.selected = true;
107
+ }
108
+
109
+ this.commitData();
110
+
111
+ this.dispatchEvent(ToggleGroupEvent.SELECTED_ID_CHANGE);
112
+ }*/
113
+
114
+ public get selectedId(): string {
115
+ return this._selectedId;
116
+ }
117
+ public set selectedId(value: string) {
118
+ if (this._selectedId === value) {
119
+ return;
120
+ }
121
+
122
+ // Reset the previous selected item
123
+ if (this._selectedItem) {
124
+ this._selectedItem.selected = false;
125
+ }
126
+
127
+ this._selectedId = value;
128
+ this._selectedItem = this.itemsToIdMap.getItem(this._selectedId);
129
+ // Setup the new selected item
130
+ if (this._selectedItem) {
131
+ this._selectedItem.selected = true;
132
+ }
133
+
134
+ this.dispatchEvent(ToggleGroupEvent.SELECTED_ID_CHANGE);
135
+ }
136
+
137
+ public get selectedItem(): IToggleItemType {
138
+ return this._selectedItem;
139
+ }
140
+ }
@@ -0,0 +1,3 @@
1
+ export const ToggleGroupEvent = {
2
+ SELECTED_ID_CHANGE: "ToggleGroupEvent.SELECTED_ID_CHANGE"
3
+ };
@@ -0,0 +1,7 @@
1
+ import {IDatable} from "@flashist/fcore";
2
+
3
+ import {IResizable} from "../resize/IResizable";
4
+
5
+ export interface IViewStackItem extends Partial<IResizable>, IDatable {
6
+
7
+ }
@@ -0,0 +1,19 @@
1
+ import {IConstructor} from "@flashist/fcore";
2
+
3
+ import {DisplayObjectContainer, getInstance} from "@flashist/flibs";
4
+
5
+ import {ViewLazyCreationStack} from "./ViewLazyCreationStack";
6
+
7
+ export class ViewLazyCreationServiceLocatorStack<StackViewType extends DisplayObjectContainer = DisplayObjectContainer> extends ViewLazyCreationStack<StackViewType> {
8
+
9
+ protected getNewInstance(id: string): StackViewType {
10
+ let result: StackViewType;
11
+
12
+ let TempClass: IConstructor<any> = (this.viewClassToIdMap.getItem(id) as IConstructor<any>);
13
+ if (TempClass) {
14
+ result = getInstance(TempClass);
15
+ }
16
+
17
+ return result;
18
+ }
19
+ }