@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.
- package/gulp/tasks/clean.js +9 -0
- package/gulp/tasks/compile.js +27 -0
- package/gulp/tasks/copy-to-dist.js +15 -0
- package/gulp/tasks/generate-definitions.js +86 -0
- package/gulpfile.js +22 -0
- package/package.json +30 -0
- package/src/app/AppModule.ts +26 -0
- package/src/app/AppSettings.ts +9 -0
- package/src/app/commands/LoadAppConfigCommand.ts +61 -0
- package/src/app/commands/ParseStaticItemsConfigCommand.ts +32 -0
- package/src/app/data/AppConfigType.ts +1 -0
- package/src/app/data/AppConfigVO.ts +27 -0
- package/src/app/data/IAppModelStorageVO.ts +4 -0
- package/src/app/data/IItemsConfigVO.ts +5 -0
- package/src/app/managers/AppManager.ts +68 -0
- package/src/app/models/AppConfigModel.ts +20 -0
- package/src/app/models/AppModel.ts +18 -0
- package/src/app/views/AppMainContainer.ts +23 -0
- package/src/assets/AssetsModule.ts +13 -0
- package/src/assets/commands/ParseAssetsConfigCommand.ts +25 -0
- package/src/assets/data/IAssetsConfigVO.ts +5 -0
- package/src/assets/models/AssetsModel.ts +7 -0
- package/src/base/BaseObjectWithGlobalDispatcher.ts +23 -0
- package/src/base/commands/BaseAppCommand.ts +22 -0
- package/src/base/data/BaseAppObjectWithStaticVO.ts +15 -0
- package/src/base/managers/BaseAppManager.ts +5 -0
- package/src/base/mediators/BaseAppMediator.ts +24 -0
- package/src/base/models/BaseAppGenericObjectsModel.ts +23 -0
- package/src/base/models/BaseAppModel.ts +5 -0
- package/src/base/modules/AppModulesManager.ts +44 -0
- package/src/base/modules/BaseAppModule.ts +17 -0
- package/src/base/views/BaseAppView.ts +25 -0
- package/src/containers/ContainersModule.ts +13 -0
- package/src/containers/managers/ContainersManager.ts +27 -0
- package/src/data/IAppGenericObjectVO.ts +5 -0
- package/src/date/DateSettings.ts +6 -0
- package/src/debug/DebugModule.ts +22 -0
- package/src/dependencies/DependenciesModule.ts +13 -0
- package/src/display/data/IGetSizable.ts +5 -0
- package/src/display/tools/GetSizeTools.ts +25 -0
- package/src/display/views/AppContainer.ts +20 -0
- package/src/display/views/button/BaseBtn.ts +325 -0
- package/src/display/views/button/BaseBtnEvent.ts +4 -0
- package/src/display/views/button/BaseBtnState.ts +31 -0
- package/src/display/views/button/BaseBtnView.ts +230 -0
- package/src/display/views/button/DefaultButtonViewConfig.ts +10 -0
- package/src/display/views/button/IButtonViewConfig.ts +16 -0
- package/src/display/views/button/ISimpleButtonConfig.ts +22 -0
- package/src/display/views/button/SimpleButtonState.ts +31 -0
- package/src/display/views/button/SimpleButtonView.ts +226 -0
- package/src/display/views/getsize/GetSizeTools.ts +32 -0
- package/src/display/views/getsize/IGetSizeObject.ts +5 -0
- package/src/display/views/layout/BaseLayout.ts +160 -0
- package/src/display/views/layout/ColumnLayout.ts +120 -0
- package/src/display/views/layout/LayoutConfig.ts +15 -0
- package/src/display/views/layout/RowLayout.ts +115 -0
- package/src/display/views/layout/container/BaseLayoutableContainer.ts +21 -0
- package/src/display/views/layout/container/ILayoutableChild.ts +3 -0
- package/src/display/views/layout/container/ILayoutableContainer.ts +18 -0
- package/src/display/views/resize/IResizable.ts +6 -0
- package/src/display/views/resize/ResizableContainer.ts +80 -0
- package/src/display/views/simplelist/ISimpleListItem.ts +5 -0
- package/src/display/views/simplelist/SimpleList.ts +318 -0
- package/src/display/views/simplelist/SimpleListEvent.ts +4 -0
- package/src/display/views/sizedistributor/ISizeDistributorChild.ts +5 -0
- package/src/display/views/sizedistributor/SizeDistributor.ts +129 -0
- package/src/display/views/sizedistributor/SizeDistributorConfig.ts +12 -0
- package/src/display/views/togglegroup/IToggableItem.ts +6 -0
- package/src/display/views/togglegroup/IToggleGroupItem.ts +6 -0
- package/src/display/views/togglegroup/ToggleGroup.ts +140 -0
- package/src/display/views/togglegroup/ToggleGroupEvent.ts +3 -0
- package/src/display/views/viewstack/IViewStackItem.ts +7 -0
- package/src/display/views/viewstack/ViewLazyCreationServiceLocatorStack.ts +19 -0
- package/src/display/views/viewstack/ViewLazyCreationStack.ts +47 -0
- package/src/display/views/viewstack/ViewStack.ts +93 -0
- package/src/display/views/viewstack/ViewStackLazyCreation.ts +45 -0
- package/src/events/commands/DispatchGlobalEventCommand.ts +22 -0
- package/src/facade/Facade.ts +194 -0
- package/src/facade/IFacadeOptions.ts +7 -0
- package/src/globaleventdispatcher/GlobalEventDispatcherModule.ts +16 -0
- package/src/globaleventdispatcher/commands/WaitGlobalEventCommand.ts +25 -0
- package/src/globaleventdispatcher/dispatcher/GlobalEventDispatcher.ts +53 -0
- package/src/globaleventdispatcher/dispatcher/GlobalEventDispatcherEvent.ts +4 -0
- package/src/globaleventdispatcher/dispatcher/IGlobalDispatchEventVO.ts +4 -0
- package/src/globaleventdispatcher/managers/GlobalEventsCommandManager.ts +26 -0
- package/src/hints/commands/AnimateHintCommand.ts +99 -0
- package/src/hints/data/DefaultHintConfig.ts +22 -0
- package/src/hints/data/HintContainerId.ts +1 -0
- package/src/hints/data/IHintConfig.ts +20 -0
- package/src/html/HTMLModule.ts +13 -0
- package/src/html/managers/HTMLManager.ts +32 -0
- package/src/index.ts +21 -0
- package/src/init/commands/InitApplicationCommand.ts +34 -0
- package/src/init/commands/InitApplicationDataCommand.ts +19 -0
- package/src/init/commands/InitApplicationDataEvent.ts +3 -0
- package/src/load/LoadGroupName.ts +5 -0
- package/src/load/LoadModule.ts +23 -0
- package/src/load/LoaderId.ts +5 -0
- package/src/locales/LocalesModule.ts +11 -0
- package/src/locales/commands/ParseLocaleConfigCommand.ts +28 -0
- package/src/package.json +36 -0
- package/src/pages/PageId.ts +4 -0
- package/src/pages/PagesModule.ts +13 -0
- package/src/pages/commands/ChangePageCommand.ts +18 -0
- package/src/pages/models/PagesModel.ts +38 -0
- package/src/pages/models/PagesModelEvent.ts +3 -0
- package/src/pages/views/BasePageView.ts +75 -0
- package/src/pages/views/PagesView.ts +57 -0
- package/src/pool/ObjectsPoolModule.ts +13 -0
- package/src/renderer/RendererModule.ts +14 -0
- package/src/renderer/events/RendererManagerEvent.ts +3 -0
- package/src/renderer/managers/RendererManager.ts +52 -0
- package/src/server/ServerModule.ts +14 -0
- package/src/server/commands/BaseServerCommand.ts +39 -0
- package/src/server/data/IServerRequestVO.ts +12 -0
- package/src/server/data/IServerResponseVO.ts +15 -0
- package/src/server/data/ServerErrorCode.ts +3 -0
- package/src/server/models/ServerModel.ts +34 -0
- package/src/sounds/SoundsModule.ts +24 -0
- package/src/sounds/SoundsSettings.ts +5 -0
- package/src/sounds/managers/BackgroundMusicManager.ts +48 -0
- package/src/sounds/managers/SoundsStorageManager.ts +45 -0
- package/src/storage/StorageModule.ts +13 -0
- package/src/storage/StorageModuleConfig.ts +3 -0
- package/src/storage/managers/StorageManager.ts +159 -0
- package/src/strategy/managers/BaseStrategyManager.ts +37 -0
- package/src/strategy/models/BaseStrategyModel.ts +40 -0
- package/src/strategy/strategies/BaseStrategy.ts +21 -0
- package/src/time/TimeModule.ts +16 -0
- package/src/time/managers/TimeManager.ts +29 -0
- package/src/time/models/TimeModel.ts +29 -0
- package/src/time/models/TimeModelEvent.ts +3 -0
- package/src/windows/data/IWindowConfigVO.ts +9 -0
- package/src/windows/managers/IShowWindowVO.ts +4 -0
- package/src/windows/managers/WindowsManager.ts +72 -0
- package/src/windows/views/BaseWindow.ts +22 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import {Align, Point, VAlign} from "@flashist/flibs";
|
|
2
|
+
|
|
3
|
+
import {LayoutConfig} from "./LayoutConfig";
|
|
4
|
+
import {ILayoutableContainer} from "./container/ILayoutableContainer";
|
|
5
|
+
|
|
6
|
+
import {ILayoutableChild} from "./container/ILayoutableChild";
|
|
7
|
+
import {GetSizeTools} from "../../tools/GetSizeTools";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* ...
|
|
11
|
+
* @author Mark (ruFlashist@gmail.com)
|
|
12
|
+
*/
|
|
13
|
+
export abstract class BaseLayout {
|
|
14
|
+
protected settings: LayoutConfig;
|
|
15
|
+
protected _totalSize: Point = new Point();
|
|
16
|
+
|
|
17
|
+
constructor(settings?: Partial<LayoutConfig>) {
|
|
18
|
+
|
|
19
|
+
this.settings = new LayoutConfig();
|
|
20
|
+
if (settings) {
|
|
21
|
+
(Object as any).assign(this.settings, settings);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public abstract arrange(container: ILayoutableContainer): void;
|
|
26
|
+
|
|
27
|
+
public getMaxChildSize(container: ILayoutableContainer): Point {
|
|
28
|
+
var result: Point = new Point();
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
var childrenCount: number = container.layoutGetChildrenNum();
|
|
32
|
+
|
|
33
|
+
var tempChild: ILayoutableChild;
|
|
34
|
+
var tempChildSize: Point;
|
|
35
|
+
|
|
36
|
+
for (var childIndex: number = 0; childIndex < childrenCount; childIndex++) {
|
|
37
|
+
tempChild = container.layoutGetChildAt(childIndex);
|
|
38
|
+
|
|
39
|
+
tempChildSize = GetSizeTools.getObjectSize(tempChild);
|
|
40
|
+
|
|
41
|
+
if (tempChildSize.x > result.x) {
|
|
42
|
+
result.x = tempChildSize.x;
|
|
43
|
+
}
|
|
44
|
+
if (tempChildSize.y > result.y) {
|
|
45
|
+
result.y = tempChildSize.y;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
protected arrangeChild(child: ILayoutableChild,
|
|
54
|
+
prevChild: ILayoutableChild,
|
|
55
|
+
align: String,
|
|
56
|
+
valign: String,
|
|
57
|
+
childMaxSize: Point,
|
|
58
|
+
columnIndex: number = 0,
|
|
59
|
+
rowIndex: number = 0,
|
|
60
|
+
cellShift: Point = null): void {
|
|
61
|
+
|
|
62
|
+
var tempChildSize: Point = GetSizeTools.getObjectSize(child);
|
|
63
|
+
|
|
64
|
+
var newChildPos: Point = new Point();
|
|
65
|
+
|
|
66
|
+
newChildPos.x = this.settings.paddingX + (childMaxSize.x + this.settings.spacingX) * columnIndex;
|
|
67
|
+
switch (align) {
|
|
68
|
+
case Align.CENTER:
|
|
69
|
+
newChildPos.x += Math.floor((childMaxSize.x - tempChildSize.x) / 2);
|
|
70
|
+
break;
|
|
71
|
+
|
|
72
|
+
case Align.RIGHT:
|
|
73
|
+
newChildPos.x += childMaxSize.x - tempChildSize.x;
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
newChildPos.y = this.settings.paddingY + (childMaxSize.y + this.settings.paddingY) * rowIndex;
|
|
78
|
+
switch (valign) {
|
|
79
|
+
case VAlign.MIDDLE:
|
|
80
|
+
newChildPos.y += Math.floor((childMaxSize.y - tempChildSize.y) / 2);
|
|
81
|
+
break;
|
|
82
|
+
|
|
83
|
+
case VAlign.BOTTOM:
|
|
84
|
+
newChildPos.y += childMaxSize.y - tempChildSize.y;
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
if (cellShift) {
|
|
90
|
+
newChildPos.x += cellShift.x;
|
|
91
|
+
newChildPos.y += cellShift.y;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
this.applyChildPosition(child, newChildPos.x, newChildPos.y);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
protected applyChildPosition(child: ILayoutableChild, x: number, y: number): void {
|
|
98
|
+
if (this.settings.isNeedFloorCoordinates) {
|
|
99
|
+
x = Math.floor(x);
|
|
100
|
+
y = Math.floor(y);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
child.x = x;
|
|
104
|
+
child.y = y;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
public abstract findRealRowsAndColumnsCount(container: ILayoutableContainer): Point;
|
|
108
|
+
|
|
109
|
+
public findFullColumnsAndRowsInSize(container: ILayoutableContainer, size: Point): Point {
|
|
110
|
+
var result: Point = new Point();
|
|
111
|
+
|
|
112
|
+
var tempSize: Point;
|
|
113
|
+
var childsCount: number = container.layoutGetChildrenNum();
|
|
114
|
+
for (var columnIndex: number = 1; columnIndex <= childsCount; columnIndex++) {
|
|
115
|
+
tempSize = this.getTotalSizeForRowsAndColumns(container, columnIndex, 1);
|
|
116
|
+
|
|
117
|
+
if (tempSize.x <= size.x) {
|
|
118
|
+
result.x = columnIndex;
|
|
119
|
+
|
|
120
|
+
} else {
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
for (var rowIndex: number = 1; rowIndex <= childsCount; rowIndex++) {
|
|
126
|
+
tempSize = this.getTotalSizeForRowsAndColumns(container, 1, rowIndex);
|
|
127
|
+
|
|
128
|
+
if (tempSize.y <= size.y) {
|
|
129
|
+
result.y = rowIndex;
|
|
130
|
+
|
|
131
|
+
} else {
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
protected getTotalSizeForRowsAndColumns(container: ILayoutableContainer, columnsCount: number, rowsCount: number): Point {
|
|
141
|
+
var result: Point = new Point();
|
|
142
|
+
|
|
143
|
+
var maxChildSize: Point = this.getMaxChildSize(container);
|
|
144
|
+
result.x = this.settings.paddingX * 2 + maxChildSize.x * columnsCount + (this.settings.spacingY * (columnsCount - 1));
|
|
145
|
+
result.y = this.settings.paddingY * 2 + maxChildSize.y * rowsCount + (this.settings.spacingX * (rowsCount - 1));
|
|
146
|
+
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
protected updateTotalSize(container: ILayoutableContainer): void {
|
|
151
|
+
var realRowsAndColumnsCount: Point = this.findRealRowsAndColumnsCount(container);
|
|
152
|
+
var newTotalSize: Point = this.getTotalSizeForRowsAndColumns(container, realRowsAndColumnsCount.x, realRowsAndColumnsCount.y);
|
|
153
|
+
|
|
154
|
+
this._totalSize = newTotalSize;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
public getTotalSize(): Point {
|
|
158
|
+
return this._totalSize;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import {BaseLayout} from "./BaseLayout";
|
|
2
|
+
import {ILayoutableContainer} from "./container/ILayoutableContainer";
|
|
3
|
+
import {Logger} from "@flashist/fcore";
|
|
4
|
+
import {Point} from "@flashist/flibs";
|
|
5
|
+
import {GetSizeTools} from "../../tools/GetSizeTools";
|
|
6
|
+
import {ILayoutableChild} from "./container/ILayoutableChild";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* ...
|
|
10
|
+
* @author Mark (ruFlashist@gmail.com)
|
|
11
|
+
*/
|
|
12
|
+
export class ColumnLayout extends BaseLayout {
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Расстановка элементов контейнера.
|
|
16
|
+
*
|
|
17
|
+
* @param coutnainer
|
|
18
|
+
*/
|
|
19
|
+
public arrange(container:ILayoutableContainer):void {
|
|
20
|
+
|
|
21
|
+
if (!container) {
|
|
22
|
+
Logger.log("ColumnLayout | arrange", "WARNING! Can't find container!");
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var tempChild:ILayoutableChild;
|
|
27
|
+
//var tempSizableChild:IGetSizeSprite;
|
|
28
|
+
var tempChildSize:Point;
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
var childMaxSize:Point = this.getMaxChildSize(container);
|
|
32
|
+
|
|
33
|
+
//
|
|
34
|
+
var prevChild:ILayoutableChild;
|
|
35
|
+
var prevChildSize:Point;
|
|
36
|
+
//
|
|
37
|
+
var childrenCount:number = container.layoutGetChildrenNum();
|
|
38
|
+
for (var childIndex:number = 0; childIndex < childrenCount; childIndex++) {
|
|
39
|
+
tempChild = container.layoutGetChildAt(childIndex);
|
|
40
|
+
|
|
41
|
+
tempChildSize = GetSizeTools.getObjectSize(tempChild);
|
|
42
|
+
|
|
43
|
+
this.arrangeChild(tempChild, prevChild, this.settings.align, this.settings.valign, childMaxSize, 0, childIndex);
|
|
44
|
+
|
|
45
|
+
// Запоминаем данные о текущем элементе
|
|
46
|
+
prevChild = tempChild;
|
|
47
|
+
prevChildSize = tempChildSize;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
this.updateTotalSize(container);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Выравнивание объекта.
|
|
56
|
+
*
|
|
57
|
+
* @param child
|
|
58
|
+
* @param align
|
|
59
|
+
* @param valign
|
|
60
|
+
* @param childMaxSize
|
|
61
|
+
* @param columnIndex
|
|
62
|
+
* @param rowIndex
|
|
63
|
+
* @param cellShift
|
|
64
|
+
*/
|
|
65
|
+
protected arrangeChild(child:ILayoutableChild, prevChild:ILayoutableChild, align:String, valign:String, childMaxSize:Point, columnIndex:number = 0, rowIndex:number = 0, cellShift:Point = null):void {
|
|
66
|
+
super.arrangeChild(child, prevChild, align, valign, childMaxSize, columnIndex, rowIndex, cellShift);
|
|
67
|
+
|
|
68
|
+
// В однострочных/одностолбцовых расстановках объекты должны расстанавливаться друг от дуга
|
|
69
|
+
// не в зависимости от максимального размера, а в зависимости от взаимного размера ближайших объектов
|
|
70
|
+
if (prevChild) {
|
|
71
|
+
var prevChildSize:Point = GetSizeTools.getObjectSize(prevChild);
|
|
72
|
+
//child.y = prevChild.y + prevChildSize.y + this.settings.spacing.y;
|
|
73
|
+
|
|
74
|
+
this.applyChildPosition(
|
|
75
|
+
child,
|
|
76
|
+
child.x,
|
|
77
|
+
prevChild.y + prevChildSize.y + this.settings.spacingY
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Обновление общего размера расстановки.
|
|
84
|
+
*
|
|
85
|
+
* @param container
|
|
86
|
+
*/
|
|
87
|
+
protected updateTotalSize(container:ILayoutableContainer):void {
|
|
88
|
+
super.updateTotalSize(container);
|
|
89
|
+
|
|
90
|
+
// В однострочных/одностолбцовых расстановках общий размер по одной из сторон должен рассчитываться
|
|
91
|
+
// не на основе максимального размера, а на положения и размера последнего элемента
|
|
92
|
+
var childrenCount:number = container.layoutGetChildrenNum();
|
|
93
|
+
if (childrenCount > 0) {
|
|
94
|
+
var lastChild:ILayoutableChild = container.layoutGetChildAt(childrenCount - 1);
|
|
95
|
+
if (lastChild) {
|
|
96
|
+
var lastChildSize:Point = GetSizeTools.getObjectSize(lastChild);
|
|
97
|
+
this._totalSize.y = lastChild.y + lastChildSize.y + this.settings.paddingY;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Получение количества строк и столбцов.
|
|
105
|
+
*
|
|
106
|
+
* @param container
|
|
107
|
+
*
|
|
108
|
+
* @return
|
|
109
|
+
*/
|
|
110
|
+
public findRealRowsAndColumnsCount(container:ILayoutableContainer):Point {
|
|
111
|
+
var result:Point = new Point();
|
|
112
|
+
|
|
113
|
+
var childrenCount:number = container.layoutGetChildrenNum();
|
|
114
|
+
result.x = 1;
|
|
115
|
+
result.y = childrenCount;
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import {BaseLayout} from "./BaseLayout";
|
|
2
|
+
import {Logger} from "@flashist/fcore";
|
|
3
|
+
import {Point} from "@flashist/flibs";
|
|
4
|
+
import {ILayoutableContainer} from "./container/ILayoutableContainer";
|
|
5
|
+
import {ILayoutableChild} from "./container/ILayoutableChild";
|
|
6
|
+
import {GetSizeTools} from "../../tools/GetSizeTools";
|
|
7
|
+
|
|
8
|
+
export class RowLayout extends BaseLayout {
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Расстановка элементов контейнера.
|
|
12
|
+
*
|
|
13
|
+
* @param coutnainer
|
|
14
|
+
*/
|
|
15
|
+
public arrange(container: ILayoutableContainer): void {
|
|
16
|
+
if (!container) {
|
|
17
|
+
Logger.log("ColumnLayout | arrange", "WARNING! Can't find container!");
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
var tempChild: ILayoutableChild;
|
|
22
|
+
//var tempSizableChild:IGetSizeSprite;
|
|
23
|
+
var tempChildSize: Point;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
var childMaxSize: Point = this.getMaxChildSize(container);
|
|
27
|
+
|
|
28
|
+
//
|
|
29
|
+
var prevChild: ILayoutableChild;
|
|
30
|
+
var prevChildSize: Point;
|
|
31
|
+
//
|
|
32
|
+
var childrenCount: number = container.layoutGetChildrenNum();
|
|
33
|
+
for (var childIndex: number = 0; childIndex < childrenCount; childIndex++) {
|
|
34
|
+
tempChild = container.layoutGetChildAt(childIndex);
|
|
35
|
+
|
|
36
|
+
tempChildSize = GetSizeTools.getObjectSize(tempChild);
|
|
37
|
+
|
|
38
|
+
this.arrangeChild(tempChild, prevChild, this.settings.align, this.settings.valign, childMaxSize, childIndex);
|
|
39
|
+
|
|
40
|
+
// Запоминаем данные о текущем элементе
|
|
41
|
+
prevChild = tempChild;
|
|
42
|
+
prevChildSize = tempChildSize;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
this.updateTotalSize(container);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Выравнивание объекта.
|
|
51
|
+
*
|
|
52
|
+
* @param child
|
|
53
|
+
* @param align
|
|
54
|
+
* @param valign
|
|
55
|
+
* @param childMaxSize
|
|
56
|
+
* @param columnIndex
|
|
57
|
+
* @param rowIndex
|
|
58
|
+
* @param cellShift
|
|
59
|
+
*/
|
|
60
|
+
protected arrangeChild(child: ILayoutableChild, prevChild: ILayoutableChild, align: String, valign: String, childMaxSize: Point, columnIndex: number = 0, rowIndex: number = 0, cellShift: Point = null): void {
|
|
61
|
+
super.arrangeChild(child, prevChild, align, valign, childMaxSize, columnIndex, rowIndex, cellShift);
|
|
62
|
+
|
|
63
|
+
// В однострочных/одностолбцовых расстановках объекты должны расстанавливаться друг от дуга
|
|
64
|
+
// не в зависимости от максимального размера, а в зависимости от взаимного размера ближайших объектов
|
|
65
|
+
if (prevChild) {
|
|
66
|
+
var prevChildSize: Point = GetSizeTools.getObjectSize(prevChild);
|
|
67
|
+
//child.y = prevChild.y + prevChildSize.y + this.settings.spacing.y;
|
|
68
|
+
|
|
69
|
+
this.applyChildPosition(
|
|
70
|
+
child,
|
|
71
|
+
prevChild.x + prevChildSize.x + this.settings.spacingX,
|
|
72
|
+
child.y
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Обновление общего размера расстановки.
|
|
79
|
+
*
|
|
80
|
+
* @param container
|
|
81
|
+
*/
|
|
82
|
+
protected updateTotalSize(container: ILayoutableContainer): void {
|
|
83
|
+
super.updateTotalSize(container);
|
|
84
|
+
|
|
85
|
+
// В однострочных/одностолбцовых расстановках общий размер по одной из сторон должен рассчитываться
|
|
86
|
+
// не на основе максимального размера, а на положения и размера последнего элемента
|
|
87
|
+
var childrenCount: number = container.layoutGetChildrenNum();
|
|
88
|
+
if (childrenCount > 0) {
|
|
89
|
+
var lastChild: ILayoutableChild = container.layoutGetChildAt(childrenCount - 1);
|
|
90
|
+
if (lastChild) {
|
|
91
|
+
var lastChildSize: Point = GetSizeTools.getObjectSize(lastChild);
|
|
92
|
+
this._totalSize.x = lastChild.x + lastChildSize.x + this.settings.paddingX;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Получение количества строк и столбцов.
|
|
100
|
+
*
|
|
101
|
+
* @param container
|
|
102
|
+
*
|
|
103
|
+
* @return
|
|
104
|
+
*/
|
|
105
|
+
public findRealRowsAndColumnsCount(container: ILayoutableContainer): Point {
|
|
106
|
+
var result: Point = new Point();
|
|
107
|
+
|
|
108
|
+
var childrenCount: number = container.layoutGetChildrenNum();
|
|
109
|
+
result.x = childrenCount;
|
|
110
|
+
result.y = 1;
|
|
111
|
+
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {FContainer} from "@flashist/flibs";
|
|
2
|
+
|
|
3
|
+
import {ILayoutableContainer} from "./ILayoutableContainer";
|
|
4
|
+
import {ILayoutableChild} from "./ILayoutableChild";
|
|
5
|
+
|
|
6
|
+
export class BaseLayoutableContainer<ChildType extends ILayoutableChild = ILayoutableChild>
|
|
7
|
+
extends FContainer
|
|
8
|
+
implements ILayoutableContainer<ChildType> {
|
|
9
|
+
|
|
10
|
+
public children: ChildType[];
|
|
11
|
+
|
|
12
|
+
layoutGetChildrenNum(): number {
|
|
13
|
+
return this.children.length;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
layoutGetChildAt(index: number): ChildType {
|
|
17
|
+
return this.children[index];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {ILayoutableChild} from "./ILayoutableChild";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ...
|
|
5
|
+
* @author Mark (ruFlashist@gmail.com)
|
|
6
|
+
*/
|
|
7
|
+
export interface ILayoutableContainer<ChildrenType extends ILayoutableChild = ILayoutableChild> {
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Получение количество дочерних объектов
|
|
11
|
+
*/
|
|
12
|
+
layoutGetChildrenNum(): number;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Получение дочернего объекта по индексу
|
|
16
|
+
*/
|
|
17
|
+
layoutGetChildAt(index: number): ChildrenType;
|
|
18
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { FContainer, Point } from "@flashist/flibs";
|
|
2
|
+
import { IResizable } from "./IResizable";
|
|
3
|
+
import { AppContainer } from "../AppContainer";
|
|
4
|
+
|
|
5
|
+
export class ResizableContainer<DataType extends object = object> extends AppContainer<DataType> implements IResizable {
|
|
6
|
+
|
|
7
|
+
private _resizeSize: Point;
|
|
8
|
+
private _maxSize: Point;
|
|
9
|
+
private _minSize: Point;
|
|
10
|
+
|
|
11
|
+
protected construction(...args): void {
|
|
12
|
+
super.construction(...args);
|
|
13
|
+
|
|
14
|
+
this._minSize = new Point();
|
|
15
|
+
this._maxSize = new Point();
|
|
16
|
+
this._resizeSize = new Point();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public resize(width: number, height: number): void {
|
|
20
|
+
if (this._minSize.x) {
|
|
21
|
+
width = Math.max(width, this._minSize.x)
|
|
22
|
+
}
|
|
23
|
+
if (this._maxSize.x) {
|
|
24
|
+
width = Math.min(width, this._maxSize.x)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (this._minSize.y) {
|
|
28
|
+
height = Math.max(width, this._minSize.y)
|
|
29
|
+
}
|
|
30
|
+
if (this._maxSize.y) {
|
|
31
|
+
height = Math.min(height, this._maxSize.y)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
this.resizeSize.x = width;
|
|
35
|
+
this.resizeSize.y = height;
|
|
36
|
+
|
|
37
|
+
if (this.isConstructed) {
|
|
38
|
+
this.arrange();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
get minSize(): Point {
|
|
43
|
+
return this._minSize;
|
|
44
|
+
}
|
|
45
|
+
set minSize(value: Point) {
|
|
46
|
+
if (!value) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (value.x === this._minSize.x && value.y === this._minSize.y) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
this._minSize = value.clone();
|
|
54
|
+
|
|
55
|
+
this.resize(this.resizeSize.x, this.resizeSize.y);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
get maxSize(): Point {
|
|
59
|
+
return this._maxSize;
|
|
60
|
+
}
|
|
61
|
+
set maxSize(value: Point) {
|
|
62
|
+
if (!value) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (value.x === this._maxSize.x && value.y === this._maxSize.y) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
this._maxSize = value.clone();
|
|
70
|
+
|
|
71
|
+
this.resize(this.resizeSize.x, this.resizeSize.y);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public get resizeSize(): Point {
|
|
75
|
+
return this._resizeSize;
|
|
76
|
+
}
|
|
77
|
+
public set resizeSize(value: Point) {
|
|
78
|
+
throw new Error("Resize size should be changed through the resize method!");
|
|
79
|
+
}
|
|
80
|
+
}
|