flexlayout-react 0.7.15 → 0.8.0

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 (252) hide show
  1. package/ChangeLog.txt +23 -0
  2. package/README.md +157 -330
  3. package/Screenshot_light.png +0 -0
  4. package/Screenshot_rounded.png +0 -0
  5. package/declarations/Attribute.d.ts +1 -1
  6. package/declarations/AttributeDefinitions.d.ts +1 -1
  7. package/declarations/DockLocation.d.ts +12 -12
  8. package/declarations/DropInfo.d.ts +12 -12
  9. package/declarations/I18nLabel.d.ts +12 -14
  10. package/declarations/Orientation.d.ts +7 -7
  11. package/declarations/PopupMenu.d.ts +1 -1
  12. package/declarations/Rect.d.ts +41 -28
  13. package/declarations/Types.d.ts +95 -79
  14. package/declarations/examples/demo/Utils.d.ts +4 -0
  15. package/declarations/index.d.ts +21 -22
  16. package/declarations/model/Action.d.ts +5 -5
  17. package/declarations/model/Actions.d.ts +127 -110
  18. package/declarations/model/BorderNode.d.ts +30 -34
  19. package/declarations/model/BorderSet.d.ts +3 -4
  20. package/declarations/model/ICloseType.d.ts +5 -5
  21. package/declarations/model/IDraggable.d.ts +2 -2
  22. package/declarations/model/IDropTarget.d.ts +2 -2
  23. package/declarations/model/IJsonModel.d.ts +811 -149
  24. package/declarations/model/LayoutWindow.d.ts +28 -0
  25. package/declarations/model/Model.d.ts +91 -86
  26. package/declarations/model/Node.d.ts +17 -17
  27. package/declarations/model/RowNode.d.ts +10 -11
  28. package/declarations/model/TabNode.d.ts +44 -37
  29. package/declarations/model/TabSetNode.d.ts +44 -41
  30. package/declarations/model/Utils.d.ts +1 -1
  31. package/declarations/model/WindowLayout.d.ts +24 -0
  32. package/declarations/src/Attribute.d.ts +1 -0
  33. package/declarations/src/AttributeDefinitions.d.ts +1 -0
  34. package/declarations/src/DockLocation.d.ts +12 -0
  35. package/declarations/src/DropInfo.d.ts +12 -0
  36. package/declarations/src/I18nLabel.d.ts +10 -0
  37. package/declarations/src/Orientation.d.ts +7 -0
  38. package/declarations/src/PopupMenu.d.ts +1 -0
  39. package/declarations/src/Rect.d.ts +31 -0
  40. package/declarations/src/Types.d.ts +92 -0
  41. package/declarations/src/index.d.ts +20 -0
  42. package/declarations/src/model/Action.d.ts +5 -0
  43. package/declarations/src/model/Actions.d.ts +110 -0
  44. package/declarations/src/model/BorderNode.d.ts +28 -0
  45. package/declarations/src/model/BorderSet.d.ts +3 -0
  46. package/declarations/src/model/ICloseType.d.ts +5 -0
  47. package/declarations/src/model/IDraggable.d.ts +2 -0
  48. package/declarations/src/model/IDropTarget.d.ts +2 -0
  49. package/declarations/src/model/IJsonModel.d.ts +153 -0
  50. package/declarations/src/model/Model.d.ts +98 -0
  51. package/declarations/src/model/Node.d.ts +16 -0
  52. package/declarations/src/model/RowNode.d.ts +11 -0
  53. package/declarations/src/model/TabNode.d.ts +36 -0
  54. package/declarations/src/model/TabSetNode.d.ts +37 -0
  55. package/declarations/src/model/Utils.d.ts +1 -0
  56. package/declarations/src/view/BorderButton.d.ts +1 -0
  57. package/declarations/src/view/BorderTab.d.ts +2 -0
  58. package/declarations/src/view/BorderTabSet.d.ts +1 -0
  59. package/declarations/src/view/DragContainer.d.ts +1 -0
  60. package/declarations/src/view/ErrorBoundary.d.ts +1 -0
  61. package/declarations/src/view/FloatingWindow.d.ts +1 -0
  62. package/declarations/src/view/Icons.d.ts +7 -0
  63. package/declarations/src/view/Layout.d.ts +113 -0
  64. package/declarations/src/view/Overlay.d.ts +1 -0
  65. package/declarations/src/view/PopupMenu.d.ts +1 -0
  66. package/declarations/src/view/Row.d.ts +1 -0
  67. package/declarations/src/view/Splitter.d.ts +1 -0
  68. package/declarations/src/view/Tab.d.ts +1 -0
  69. package/declarations/src/view/TabButton.d.ts +1 -0
  70. package/declarations/src/view/TabButtonStamp.d.ts +1 -0
  71. package/declarations/src/view/TabOverflowHook.d.ts +1 -0
  72. package/declarations/src/view/TabSet.d.ts +1 -0
  73. package/declarations/src/view/Utils.d.ts +4 -0
  74. package/declarations/view/BorderButton.d.ts +1 -1
  75. package/declarations/view/BorderTab.d.ts +2 -0
  76. package/declarations/view/BorderTabSet.d.ts +1 -1
  77. package/declarations/view/DragContainer.d.ts +1 -0
  78. package/declarations/view/ErrorBoundary.d.ts +1 -1
  79. package/declarations/view/ExtendedResizeObserver.d.ts +23 -0
  80. package/declarations/view/FloatingWindow.d.ts +1 -1
  81. package/declarations/view/Icons.d.ts +8 -7
  82. package/declarations/view/Layout.d.ts +139 -161
  83. package/declarations/view/Overlay.d.ts +1 -0
  84. package/declarations/view/PopoutWindow.d.ts +1 -0
  85. package/declarations/view/PopupMenu.d.ts +1 -0
  86. package/declarations/view/Row.d.ts +1 -0
  87. package/declarations/view/SizeTracker.d.ts +10 -0
  88. package/declarations/view/Splitter.d.ts +1 -1
  89. package/declarations/view/Tab.d.ts +1 -1
  90. package/declarations/view/TabButton.d.ts +1 -1
  91. package/declarations/view/TabButtonStamp.d.ts +1 -1
  92. package/declarations/view/TabOverflowHook.d.ts +1 -1
  93. package/declarations/view/TabSet.d.ts +1 -1
  94. package/declarations/view/Utils.d.ts +11 -1
  95. package/dist/bundles/demo.js +232052 -0
  96. package/dist/bundles/demo.js.map +1 -0
  97. package/dist/flexlayout.js +122 -92
  98. package/dist/flexlayout_min.js +1 -1
  99. package/lib/Attribute.js +42 -31
  100. package/lib/Attribute.js.map +1 -1
  101. package/lib/AttributeDefinitions.js +131 -108
  102. package/lib/AttributeDefinitions.js.map +1 -1
  103. package/lib/DockLocation.js +120 -124
  104. package/lib/DockLocation.js.map +1 -1
  105. package/lib/DropInfo.js +9 -13
  106. package/lib/DropInfo.js.map +1 -1
  107. package/lib/I18nLabel.js +13 -18
  108. package/lib/I18nLabel.js.map +1 -1
  109. package/lib/Orientation.js +22 -26
  110. package/lib/Orientation.js.map +1 -1
  111. package/lib/Rect.js +104 -72
  112. package/lib/Rect.js.map +1 -1
  113. package/lib/Types.js +96 -83
  114. package/lib/Types.js.map +1 -1
  115. package/lib/index.js +21 -38
  116. package/lib/index.js.map +1 -1
  117. package/lib/model/Action.js +6 -10
  118. package/lib/model/Action.js.map +1 -1
  119. package/lib/model/Actions.js +169 -155
  120. package/lib/model/Actions.js.map +1 -1
  121. package/lib/model/BorderNode.js +385 -406
  122. package/lib/model/BorderNode.js.map +1 -1
  123. package/lib/model/BorderSet.js +66 -121
  124. package/lib/model/BorderSet.js.map +1 -1
  125. package/lib/model/ICloseType.js +6 -9
  126. package/lib/model/ICloseType.js.map +1 -1
  127. package/lib/model/IDraggable.js +1 -2
  128. package/lib/model/IDropTarget.js +1 -2
  129. package/lib/model/IJsonModel.js +1 -2
  130. package/lib/model/LayoutWindow.js +83 -0
  131. package/lib/model/LayoutWindow.js.map +1 -0
  132. package/lib/model/Model.js +614 -496
  133. package/lib/model/Model.js.map +1 -1
  134. package/lib/model/Node.js +217 -228
  135. package/lib/model/Node.js.map +1 -1
  136. package/lib/model/RowNode.js +491 -504
  137. package/lib/model/RowNode.js.map +1 -1
  138. package/lib/model/TabNode.js +289 -184
  139. package/lib/model/TabNode.js.map +1 -1
  140. package/lib/model/TabSetNode.js +457 -446
  141. package/lib/model/TabSetNode.js.map +1 -1
  142. package/lib/model/Utils.js +47 -82
  143. package/lib/model/Utils.js.map +1 -1
  144. package/lib/view/BorderButton.js +124 -138
  145. package/lib/view/BorderButton.js.map +1 -1
  146. package/lib/view/BorderTab.js +47 -0
  147. package/lib/view/BorderTab.js.map +1 -0
  148. package/lib/view/BorderTabSet.js +134 -128
  149. package/lib/view/BorderTabSet.js.map +1 -1
  150. package/lib/view/DragContainer.js +16 -0
  151. package/lib/view/DragContainer.js.map +1 -0
  152. package/lib/view/ErrorBoundary.js +23 -27
  153. package/lib/view/ErrorBoundary.js.map +1 -1
  154. package/lib/view/Icons.js +40 -45
  155. package/lib/view/Icons.js.map +1 -1
  156. package/lib/view/Layout.js +918 -907
  157. package/lib/view/Layout.js.map +1 -1
  158. package/lib/view/Overlay.js +9 -0
  159. package/lib/view/Overlay.js.map +1 -0
  160. package/lib/view/PopoutWindow.js +129 -0
  161. package/lib/view/PopoutWindow.js.map +1 -0
  162. package/lib/view/PopupMenu.js +71 -0
  163. package/lib/view/PopupMenu.js.map +1 -0
  164. package/lib/view/Row.js +45 -0
  165. package/lib/view/Row.js.map +1 -0
  166. package/lib/view/SizeTracker.js +11 -0
  167. package/lib/view/SizeTracker.js.map +1 -0
  168. package/lib/view/Splitter.js +191 -147
  169. package/lib/view/Splitter.js.map +1 -1
  170. package/lib/view/Tab.js +86 -60
  171. package/lib/view/Tab.js.map +1 -1
  172. package/lib/view/TabButton.js +122 -135
  173. package/lib/view/TabButton.js.map +1 -1
  174. package/lib/view/TabButtonStamp.js +16 -21
  175. package/lib/view/TabButtonStamp.js.map +1 -1
  176. package/lib/view/TabOverflowHook.js +150 -149
  177. package/lib/view/TabOverflowHook.js.map +1 -1
  178. package/lib/view/TabSet.js +267 -234
  179. package/lib/view/TabSet.js.map +1 -1
  180. package/lib/view/Utils.js +126 -68
  181. package/lib/view/Utils.js.map +1 -1
  182. package/package.json +36 -30
  183. package/src/Attribute.ts +23 -0
  184. package/src/AttributeDefinitions.ts +38 -15
  185. package/src/DockLocation.ts +13 -13
  186. package/src/I18nLabel.ts +7 -9
  187. package/src/Rect.ts +53 -1
  188. package/src/Types.ts +16 -0
  189. package/src/index.ts +1 -2
  190. package/src/model/Actions.ts +49 -29
  191. package/src/model/BorderNode.ts +208 -214
  192. package/src/model/BorderSet.ts +42 -91
  193. package/src/model/IJsonModel.ts +883 -103
  194. package/src/model/LayoutWindow.ts +121 -0
  195. package/src/model/Model.ts +488 -366
  196. package/src/model/Node.ts +98 -111
  197. package/src/model/RowNode.ts +323 -319
  198. package/src/model/TabNode.ts +294 -110
  199. package/src/model/TabSetNode.ts +300 -242
  200. package/src/model/Utils.ts +6 -32
  201. package/src/view/BorderButton.tsx +32 -52
  202. package/src/view/BorderTab.tsx +70 -0
  203. package/src/view/BorderTabSet.tsx +64 -52
  204. package/src/view/DragContainer.tsx +32 -0
  205. package/src/view/Icons.tsx +6 -0
  206. package/src/view/Layout.tsx +1051 -1046
  207. package/src/view/Overlay.tsx +22 -0
  208. package/src/view/PopoutWindow.tsx +152 -0
  209. package/src/{PopupMenu.tsx → view/PopupMenu.tsx} +36 -31
  210. package/src/view/Row.tsx +68 -0
  211. package/src/view/SizeTracker.tsx +20 -0
  212. package/src/view/Splitter.tsx +167 -112
  213. package/src/view/Tab.tsx +76 -42
  214. package/src/view/TabButton.tsx +36 -55
  215. package/src/view/TabButtonStamp.tsx +5 -9
  216. package/src/view/TabOverflowHook.tsx +14 -9
  217. package/src/view/TabSet.tsx +217 -176
  218. package/src/view/Utils.tsx +119 -39
  219. package/style/_base.scss +140 -34
  220. package/style/dark.css +685 -580
  221. package/style/dark.css.map +1 -1
  222. package/style/dark.scss +3 -1
  223. package/style/gray.css +668 -563
  224. package/style/gray.css.map +1 -1
  225. package/style/gray.scss +2 -0
  226. package/style/light.css +669 -564
  227. package/style/light.css.map +1 -1
  228. package/style/light.scss +4 -2
  229. package/style/rounded.css +697 -0
  230. package/style/rounded.css.map +1 -0
  231. package/style/rounded.scss +194 -0
  232. package/style/underline.css +690 -585
  233. package/style/underline.css.map +1 -1
  234. package/style/underline.scss +2 -0
  235. package/cypress.config.ts +0 -16
  236. package/lib/DragDrop.js +0 -316
  237. package/lib/DragDrop.js.map +0 -1
  238. package/lib/PopupMenu.js +0 -68
  239. package/lib/PopupMenu.js.map +0 -1
  240. package/lib/model/SplitterNode.js +0 -72
  241. package/lib/model/SplitterNode.js.map +0 -1
  242. package/lib/view/FloatingWindow.js +0 -123
  243. package/lib/view/FloatingWindow.js.map +0 -1
  244. package/lib/view/FloatingWindowTab.js +0 -19
  245. package/lib/view/FloatingWindowTab.js.map +0 -1
  246. package/lib/view/TabFloating.js +0 -66
  247. package/lib/view/TabFloating.js.map +0 -1
  248. package/src/DragDrop.ts +0 -392
  249. package/src/model/SplitterNode.ts +0 -78
  250. package/src/view/FloatingWindow.tsx +0 -140
  251. package/src/view/FloatingWindowTab.tsx +0 -29
  252. package/src/view/TabFloating.tsx +0 -101
@@ -1,505 +1,492 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RowNode = void 0;
4
- const Attribute_1 = require("../Attribute");
5
- const AttributeDefinitions_1 = require("../AttributeDefinitions");
6
- const DockLocation_1 = require("../DockLocation");
7
- const DropInfo_1 = require("../DropInfo");
8
- const Orientation_1 = require("../Orientation");
9
- const Rect_1 = require("../Rect");
10
- const Types_1 = require("../Types");
11
- const BorderNode_1 = require("./BorderNode");
12
- const Node_1 = require("./Node");
13
- const SplitterNode_1 = require("./SplitterNode");
14
- const TabSetNode_1 = require("./TabSetNode");
15
- class RowNode extends Node_1.Node {
16
- /** @internal */
17
- static _fromJson(json, model) {
18
- const newLayoutNode = new RowNode(model, json);
19
- if (json.children != null) {
20
- for (const jsonChild of json.children) {
21
- if (jsonChild.type === TabSetNode_1.TabSetNode.TYPE) {
22
- const child = TabSetNode_1.TabSetNode._fromJson(jsonChild, model);
23
- newLayoutNode._addChild(child);
24
- }
25
- else {
26
- const child = RowNode._fromJson(jsonChild, model);
27
- newLayoutNode._addChild(child);
28
- }
29
- }
30
- }
31
- return newLayoutNode;
32
- }
33
- /** @internal */
34
- static _createAttributeDefinitions() {
35
- const attributeDefinitions = new AttributeDefinitions_1.AttributeDefinitions();
36
- attributeDefinitions.add("type", RowNode.TYPE, true).setType(Attribute_1.Attribute.STRING).setFixed();
37
- attributeDefinitions.add("id", undefined).setType(Attribute_1.Attribute.STRING);
38
- attributeDefinitions.add("weight", 100).setType(Attribute_1.Attribute.NUMBER);
39
- attributeDefinitions.add("width", undefined).setType(Attribute_1.Attribute.NUMBER);
40
- attributeDefinitions.add("height", undefined).setType(Attribute_1.Attribute.NUMBER);
41
- return attributeDefinitions;
42
- }
43
- /** @internal */
44
- constructor(model, json) {
45
- super(model);
46
- this._dirty = true;
47
- this._drawChildren = [];
48
- this._minHeight = 0;
49
- this._minWidth = 0;
50
- RowNode._attributeDefinitions.fromJson(json, this._attributes);
51
- model._addNode(this);
52
- }
53
- getWeight() {
54
- return this._attributes.weight;
55
- }
56
- getWidth() {
57
- return this._getAttr("width");
58
- }
59
- getHeight() {
60
- return this._getAttr("height");
61
- }
62
- /** @internal */
63
- _setWeight(weight) {
64
- this._attributes.weight = weight;
65
- }
66
- /** @internal */
67
- _layout(rect, metrics) {
68
- super._layout(rect, metrics);
69
- const pixelSize = this._rect._getSize(this.getOrientation());
70
- let totalWeight = 0;
71
- let fixedPixels = 0;
72
- let prefPixels = 0;
73
- let totalPrefWeight = 0;
74
- const drawChildren = this._getDrawChildren();
75
- for (const child of drawChildren) {
76
- const prefSize = child._getPrefSize(this.getOrientation());
77
- if (child._isFixed()) {
78
- if (prefSize !== undefined) {
79
- fixedPixels += prefSize;
80
- }
81
- }
82
- else {
83
- if (prefSize === undefined) {
84
- totalWeight += child.getWeight();
85
- }
86
- else {
87
- prefPixels += prefSize;
88
- totalPrefWeight += child.getWeight();
89
- }
90
- }
91
- }
92
- let resizePreferred = false;
93
- let availablePixels = pixelSize - fixedPixels - prefPixels;
94
- if (availablePixels < 0) {
95
- availablePixels = pixelSize - fixedPixels;
96
- resizePreferred = true;
97
- totalWeight += totalPrefWeight;
98
- }
99
- // assign actual pixel sizes
100
- let totalSizeGiven = 0;
101
- let variableSize = 0;
102
- for (const child of drawChildren) {
103
- const prefSize = child._getPrefSize(this.getOrientation());
104
- if (child._isFixed()) {
105
- if (prefSize !== undefined) {
106
- child._setTempSize(prefSize);
107
- }
108
- }
109
- else {
110
- if (prefSize == null || resizePreferred) {
111
- if (totalWeight === 0) {
112
- child._setTempSize(0);
113
- }
114
- else {
115
- const minSize = child.getMinSize(this.getOrientation());
116
- const size = Math.floor(availablePixels * (child.getWeight() / totalWeight));
117
- child._setTempSize(Math.max(minSize, size));
118
- }
119
- variableSize += child._getTempSize();
120
- }
121
- else {
122
- child._setTempSize(prefSize);
123
- }
124
- }
125
- totalSizeGiven += child._getTempSize();
126
- }
127
- // adjust sizes to exactly fit
128
- if (variableSize > 0) {
129
- while (totalSizeGiven < pixelSize) {
130
- for (const child of drawChildren) {
131
- if (!(child instanceof SplitterNode_1.SplitterNode)) {
132
- const prefSize = child._getPrefSize(this.getOrientation());
133
- if (!child._isFixed() && (prefSize === undefined || resizePreferred) && totalSizeGiven < pixelSize) {
134
- child._setTempSize(child._getTempSize() + 1);
135
- totalSizeGiven++;
136
- }
137
- }
138
- }
139
- }
140
- // decrease size using nodes not at there minimum
141
- while (totalSizeGiven > pixelSize) {
142
- let changed = false;
143
- for (const child of drawChildren) {
144
- if (!(child instanceof SplitterNode_1.SplitterNode)) {
145
- const minSize = child.getMinSize(this.getOrientation());
146
- const size = child._getTempSize();
147
- if (size > minSize && totalSizeGiven > pixelSize) {
148
- child._setTempSize(child._getTempSize() - 1);
149
- totalSizeGiven--;
150
- changed = true;
151
- }
152
- }
153
- }
154
- if (!changed) {
155
- // all children are at min values
156
- break;
157
- }
158
- }
159
- // if still too big then simply reduce all nodes until fits
160
- while (totalSizeGiven > pixelSize) {
161
- let changed = false;
162
- for (const child of drawChildren) {
163
- if (!(child instanceof SplitterNode_1.SplitterNode)) {
164
- const size = child._getTempSize();
165
- if (size > 0 && totalSizeGiven > pixelSize) {
166
- child._setTempSize(child._getTempSize() - 1);
167
- totalSizeGiven--;
168
- changed = true;
169
- }
170
- }
171
- }
172
- if (!changed) {
173
- // all children are at 0 values
174
- break;
175
- }
176
- }
177
- }
178
- // layout children
179
- let p = 0;
180
- for (const child of drawChildren) {
181
- if (this.getOrientation() === Orientation_1.Orientation.HORZ) {
182
- child._layout(new Rect_1.Rect(this._rect.x + p, this._rect.y, child._getTempSize(), this._rect.height), metrics);
183
- }
184
- else {
185
- child._layout(new Rect_1.Rect(this._rect.x, this._rect.y + p, this._rect.width, child._getTempSize()), metrics);
186
- }
187
- p += child._getTempSize();
188
- }
189
- return true;
190
- }
191
- /** @internal */
192
- _getSplitterBounds(splitterNode, useMinSize = false) {
193
- const pBounds = [0, 0];
194
- const drawChildren = this._getDrawChildren();
195
- const p = drawChildren.indexOf(splitterNode);
196
- const node1 = drawChildren[p - 1];
197
- const node2 = drawChildren[p + 1];
198
- if (this.getOrientation() === Orientation_1.Orientation.HORZ) {
199
- const minSize1 = useMinSize ? node1.getMinWidth() : 0;
200
- const minSize2 = useMinSize ? node2.getMinWidth() : 0;
201
- pBounds[0] = node1.getRect().x + minSize1;
202
- pBounds[1] = node2.getRect().getRight() - splitterNode.getWidth() - minSize2;
203
- }
204
- else {
205
- const minSize1 = useMinSize ? node1.getMinHeight() : 0;
206
- const minSize2 = useMinSize ? node2.getMinHeight() : 0;
207
- pBounds[0] = node1.getRect().y + minSize1;
208
- pBounds[1] = node2.getRect().getBottom() - splitterNode.getHeight() - minSize2;
209
- }
210
- return pBounds;
211
- }
212
- /** @internal */
213
- _calculateSplit(splitter, splitterPos) {
214
- let rtn;
215
- const drawChildren = this._getDrawChildren();
216
- const p = drawChildren.indexOf(splitter);
217
- const pBounds = this._getSplitterBounds(splitter);
218
- const weightedLength = drawChildren[p - 1].getWeight() + drawChildren[p + 1].getWeight();
219
- const pixelWidth1 = Math.max(0, splitterPos - pBounds[0]);
220
- const pixelWidth2 = Math.max(0, pBounds[1] - splitterPos);
221
- if (pixelWidth1 + pixelWidth2 > 0) {
222
- const weight1 = (pixelWidth1 * weightedLength) / (pixelWidth1 + pixelWidth2);
223
- const weight2 = (pixelWidth2 * weightedLength) / (pixelWidth1 + pixelWidth2);
224
- rtn = {
225
- node1Id: drawChildren[p - 1].getId(),
226
- weight1,
227
- pixelWidth1,
228
- node2Id: drawChildren[p + 1].getId(),
229
- weight2,
230
- pixelWidth2,
231
- };
232
- }
233
- return rtn;
234
- }
235
- /** @internal */
236
- _getDrawChildren() {
237
- if (this._dirty) {
238
- this._drawChildren = [];
239
- for (let i = 0; i < this._children.length; i++) {
240
- const child = this._children[i];
241
- if (i !== 0) {
242
- const newSplitter = new SplitterNode_1.SplitterNode(this._model);
243
- newSplitter._setParent(this);
244
- this._drawChildren.push(newSplitter);
245
- }
246
- this._drawChildren.push(child);
247
- }
248
- this._dirty = false;
249
- }
250
- return this._drawChildren;
251
- }
252
- /** @internal */
253
- getMinSize(orientation) {
254
- if (orientation === Orientation_1.Orientation.HORZ) {
255
- return this.getMinWidth();
256
- }
257
- else {
258
- return this.getMinHeight();
259
- }
260
- }
261
- /** @internal */
262
- getMinWidth() {
263
- return this._minWidth;
264
- }
265
- /** @internal */
266
- getMinHeight() {
267
- return this._minHeight;
268
- }
269
- /** @internal */
270
- calcMinSize() {
271
- this._minHeight = 0;
272
- this._minWidth = 0;
273
- let first = true;
274
- for (const child of this._children) {
275
- const c = child;
276
- if (c instanceof RowNode) {
277
- c.calcMinSize();
278
- }
279
- if (this.getOrientation() === Orientation_1.Orientation.VERT) {
280
- this._minHeight += c.getMinHeight();
281
- if (!first) {
282
- this._minHeight += this._model.getSplitterSize();
283
- }
284
- this._minWidth = Math.max(this._minWidth, c.getMinWidth());
285
- }
286
- else {
287
- this._minWidth += c.getMinWidth();
288
- if (!first) {
289
- this._minWidth += this._model.getSplitterSize();
290
- }
291
- this._minHeight = Math.max(this._minHeight, c.getMinHeight());
292
- }
293
- first = false;
294
- }
295
- }
296
- /** @internal */
297
- _tidy() {
298
- let i = 0;
299
- while (i < this._children.length) {
300
- const child = this._children[i];
301
- if (child instanceof RowNode) {
302
- child._tidy();
303
- const childChildren = child.getChildren();
304
- if (childChildren.length === 0) {
305
- this._removeChild(child);
306
- }
307
- else if (childChildren.length === 1) {
308
- // hoist child/children up to this level
309
- const subchild = childChildren[0];
310
- this._removeChild(child);
311
- if (subchild instanceof RowNode) {
312
- let subChildrenTotal = 0;
313
- const subChildChildren = subchild.getChildren();
314
- for (const ssc of subChildChildren) {
315
- const subsubChild = ssc;
316
- subChildrenTotal += subsubChild.getWeight();
317
- }
318
- for (let j = 0; j < subChildChildren.length; j++) {
319
- const subsubChild = subChildChildren[j];
320
- subsubChild._setWeight((child.getWeight() * subsubChild.getWeight()) / subChildrenTotal);
321
- this._addChild(subsubChild, i + j);
322
- }
323
- }
324
- else {
325
- subchild._setWeight(child.getWeight());
326
- this._addChild(subchild, i);
327
- }
328
- }
329
- else {
330
- i++;
331
- }
332
- }
333
- else if (child instanceof TabSetNode_1.TabSetNode && child.getChildren().length === 0) {
334
- if (child.isEnableDeleteWhenEmpty()) {
335
- this._removeChild(child);
336
- if (child === this._model.getMaximizedTabset()) {
337
- this._model._setMaximizedTabset(undefined);
338
- }
339
- }
340
- else {
341
- i++;
342
- }
343
- }
344
- else {
345
- i++;
346
- }
347
- }
348
- // add tabset into empty root
349
- if (this === this._model.getRoot() && this._children.length === 0) {
350
- const callback = this._model._getOnCreateTabSet();
351
- let attrs = callback ? callback() : {};
352
- attrs = Object.assign(Object.assign({}, attrs), { selected: -1 });
353
- const child = new TabSetNode_1.TabSetNode(this._model, attrs);
354
- this._model._setActiveTabset(child);
355
- this._addChild(child);
356
- }
357
- }
358
- /** @internal */
359
- canDrop(dragNode, x, y) {
360
- const yy = y - this._rect.y;
361
- const xx = x - this._rect.x;
362
- const w = this._rect.width;
363
- const h = this._rect.height;
364
- const margin = 10; // height of edge rect
365
- const half = 50; // half width of edge rect
366
- let dropInfo;
367
- if (this._model.isEnableEdgeDock() && this._parent === undefined) {
368
- // _root row
369
- if (x < this._rect.x + margin && yy > h / 2 - half && yy < h / 2 + half) {
370
- const dockLocation = DockLocation_1.DockLocation.LEFT;
371
- const outlineRect = dockLocation.getDockRect(this._rect);
372
- outlineRect.width = outlineRect.width / 2;
373
- dropInfo = new DropInfo_1.DropInfo(this, outlineRect, dockLocation, -1, Types_1.CLASSES.FLEXLAYOUT__OUTLINE_RECT_EDGE);
374
- }
375
- else if (x > this._rect.getRight() - margin && yy > h / 2 - half && yy < h / 2 + half) {
376
- const dockLocation = DockLocation_1.DockLocation.RIGHT;
377
- const outlineRect = dockLocation.getDockRect(this._rect);
378
- outlineRect.width = outlineRect.width / 2;
379
- outlineRect.x += outlineRect.width;
380
- dropInfo = new DropInfo_1.DropInfo(this, outlineRect, dockLocation, -1, Types_1.CLASSES.FLEXLAYOUT__OUTLINE_RECT_EDGE);
381
- }
382
- else if (y < this._rect.y + margin && xx > w / 2 - half && xx < w / 2 + half) {
383
- const dockLocation = DockLocation_1.DockLocation.TOP;
384
- const outlineRect = dockLocation.getDockRect(this._rect);
385
- outlineRect.height = outlineRect.height / 2;
386
- dropInfo = new DropInfo_1.DropInfo(this, outlineRect, dockLocation, -1, Types_1.CLASSES.FLEXLAYOUT__OUTLINE_RECT_EDGE);
387
- }
388
- else if (y > this._rect.getBottom() - margin && xx > w / 2 - half && xx < w / 2 + half) {
389
- const dockLocation = DockLocation_1.DockLocation.BOTTOM;
390
- const outlineRect = dockLocation.getDockRect(this._rect);
391
- outlineRect.height = outlineRect.height / 2;
392
- outlineRect.y += outlineRect.height;
393
- dropInfo = new DropInfo_1.DropInfo(this, outlineRect, dockLocation, -1, Types_1.CLASSES.FLEXLAYOUT__OUTLINE_RECT_EDGE);
394
- }
395
- if (dropInfo !== undefined) {
396
- if (!dragNode._canDockInto(dragNode, dropInfo)) {
397
- return undefined;
398
- }
399
- }
400
- }
401
- return dropInfo;
402
- }
403
- /** @internal */
404
- drop(dragNode, location, index) {
405
- const dockLocation = location;
406
- const parent = dragNode.getParent();
407
- if (parent) {
408
- parent._removeChild(dragNode);
409
- }
410
- if (parent !== undefined && parent.getType() === TabSetNode_1.TabSetNode.TYPE) {
411
- parent._setSelected(0);
412
- }
413
- if (parent !== undefined && parent.getType() === BorderNode_1.BorderNode.TYPE) {
414
- parent._setSelected(-1);
415
- }
416
- let tabSet;
417
- if (dragNode instanceof TabSetNode_1.TabSetNode) {
418
- tabSet = dragNode;
419
- }
420
- else {
421
- const callback = this._model._getOnCreateTabSet();
422
- tabSet = new TabSetNode_1.TabSetNode(this._model, callback ? callback(dragNode) : {});
423
- tabSet._addChild(dragNode);
424
- }
425
- let size = this._children.reduce((sum, child) => {
426
- return sum + child.getWeight();
427
- }, 0);
428
- if (size === 0) {
429
- size = 100;
430
- }
431
- tabSet._setWeight(size / 3);
432
- const horz = !this._model.isRootOrientationVertical();
433
- if (horz && dockLocation === DockLocation_1.DockLocation.LEFT || !horz && dockLocation === DockLocation_1.DockLocation.TOP) {
434
- this._addChild(tabSet, 0);
435
- }
436
- else if (horz && dockLocation === DockLocation_1.DockLocation.RIGHT || !horz && dockLocation === DockLocation_1.DockLocation.BOTTOM) {
437
- this._addChild(tabSet);
438
- }
439
- else if (horz && dockLocation === DockLocation_1.DockLocation.TOP || !horz && dockLocation === DockLocation_1.DockLocation.LEFT) {
440
- const vrow = new RowNode(this._model, {});
441
- const hrow = new RowNode(this._model, {});
442
- hrow._setWeight(75);
443
- tabSet._setWeight(25);
444
- for (const child of this._children) {
445
- hrow._addChild(child);
446
- }
447
- this._removeAll();
448
- vrow._addChild(tabSet);
449
- vrow._addChild(hrow);
450
- this._addChild(vrow);
451
- }
452
- else if (horz && dockLocation === DockLocation_1.DockLocation.BOTTOM || !horz && dockLocation === DockLocation_1.DockLocation.RIGHT) {
453
- const vrow = new RowNode(this._model, {});
454
- const hrow = new RowNode(this._model, {});
455
- hrow._setWeight(75);
456
- tabSet._setWeight(25);
457
- for (const child of this._children) {
458
- hrow._addChild(child);
459
- }
460
- this._removeAll();
461
- vrow._addChild(hrow);
462
- vrow._addChild(tabSet);
463
- this._addChild(vrow);
464
- }
465
- this._model._setActiveTabset(tabSet);
466
- this._model._tidy();
467
- }
468
- toJson() {
469
- const json = {};
470
- RowNode._attributeDefinitions.toJson(json, this._attributes);
471
- json.children = [];
472
- for (const child of this._children) {
473
- json.children.push(child.toJson());
474
- }
475
- return json;
476
- }
477
- isEnableDrop() {
478
- return true;
479
- }
480
- /** @internal */
481
- _getPrefSize(orientation) {
482
- let prefSize = this.getWidth();
483
- if (orientation === Orientation_1.Orientation.VERT) {
484
- prefSize = this.getHeight();
485
- }
486
- return prefSize;
487
- }
488
- /** @internal */
489
- _getAttributeDefinitions() {
490
- return RowNode._attributeDefinitions;
491
- }
492
- /** @internal */
493
- _updateAttrs(json) {
494
- RowNode._attributeDefinitions.update(json, this._attributes);
495
- }
496
- /** @internal */
497
- static getAttributeDefinitions() {
498
- return RowNode._attributeDefinitions;
499
- }
500
- }
501
- exports.RowNode = RowNode;
502
- RowNode.TYPE = "row";
503
- /** @internal */
504
- RowNode._attributeDefinitions = RowNode._createAttributeDefinitions();
1
+ import { Attribute } from "../Attribute";
2
+ import { AttributeDefinitions } from "../AttributeDefinitions";
3
+ import { DockLocation } from "../DockLocation";
4
+ import { DropInfo } from "../DropInfo";
5
+ import { Orientation } from "../Orientation";
6
+ import { CLASSES } from "../Types";
7
+ import { BorderNode } from "./BorderNode";
8
+ import { DefaultMax, DefaultMin, Model } from "./Model";
9
+ import { Node } from "./Node";
10
+ import { TabSetNode } from "./TabSetNode";
11
+ import { canDockToWindow } from "../view/Utils";
12
+ export class RowNode extends Node {
13
+ /** @internal */
14
+ static fromJson(json, model, layoutWindow) {
15
+ const newLayoutNode = new RowNode(model, layoutWindow.windowId, json);
16
+ if (json.children != null) {
17
+ for (const jsonChild of json.children) {
18
+ if (jsonChild.type === TabSetNode.TYPE) {
19
+ const child = TabSetNode.fromJson(jsonChild, model, layoutWindow);
20
+ newLayoutNode.addChild(child);
21
+ }
22
+ else {
23
+ const child = RowNode.fromJson(jsonChild, model, layoutWindow);
24
+ newLayoutNode.addChild(child);
25
+ }
26
+ }
27
+ }
28
+ return newLayoutNode;
29
+ }
30
+ /** @internal */
31
+ constructor(model, windowId, json) {
32
+ super(model);
33
+ this.windowId = windowId;
34
+ this.minHeight = DefaultMin;
35
+ this.minWidth = DefaultMin;
36
+ this.maxHeight = DefaultMax;
37
+ this.maxWidth = DefaultMax;
38
+ RowNode.attributeDefinitions.fromJson(json, this.attributes);
39
+ this.normalizeWeights();
40
+ model.addNode(this);
41
+ }
42
+ getWeight() {
43
+ return this.attributes.weight;
44
+ }
45
+ toJson() {
46
+ const json = {};
47
+ RowNode.attributeDefinitions.toJson(json, this.attributes);
48
+ json.children = [];
49
+ for (const child of this.children) {
50
+ json.children.push(child.toJson());
51
+ }
52
+ return json;
53
+ }
54
+ /** @internal */
55
+ getWindowId() {
56
+ return this.windowId;
57
+ }
58
+ setWindowId(windowId) {
59
+ this.windowId = windowId;
60
+ }
61
+ /** @internal */
62
+ setWeight(weight) {
63
+ this.attributes.weight = weight;
64
+ }
65
+ /** @internal */
66
+ getSplitterBounds(index) {
67
+ const h = this.getOrientation() === Orientation.HORZ;
68
+ const c = this.getChildren();
69
+ const ss = this.model.getSplitterSize();
70
+ const fr = c[0].getRect();
71
+ const lr = c[c.length - 1].getRect();
72
+ let p = h ? [fr.x, lr.getRight()] : [fr.y, lr.getBottom()];
73
+ const q = h ? [fr.x, lr.getRight()] : [fr.y, lr.getBottom()];
74
+ for (let i = 0; i < index; i++) {
75
+ const n = c[i];
76
+ p[0] += h ? n.getMinWidth() : n.getMinHeight();
77
+ q[0] += h ? n.getMaxWidth() : n.getMaxHeight();
78
+ if (i > 0) {
79
+ p[0] += ss;
80
+ q[0] += ss;
81
+ }
82
+ }
83
+ for (let i = c.length - 1; i >= index; i--) {
84
+ const n = c[i];
85
+ p[1] -= (h ? n.getMinWidth() : n.getMinHeight()) + ss;
86
+ q[1] -= (h ? n.getMaxWidth() : n.getMaxHeight()) + ss;
87
+ }
88
+ p = [Math.max(q[1], p[0]), Math.min(q[0], p[1])];
89
+ return p;
90
+ }
91
+ /** @internal */
92
+ getSplitterInitials(index) {
93
+ const h = this.getOrientation() === Orientation.HORZ;
94
+ const c = this.getChildren();
95
+ const ss = this.model.getSplitterSize();
96
+ const initialSizes = [];
97
+ let sum = 0;
98
+ for (let i = 0; i < c.length; i++) {
99
+ const n = c[i];
100
+ const r = n.getRect();
101
+ const s = h ? r.width : r.height;
102
+ initialSizes.push(s);
103
+ sum += s;
104
+ }
105
+ const startRect = c[index].getRect();
106
+ const startPosition = (h ? startRect.x : startRect.y) - ss;
107
+ return { initialSizes, sum, startPosition };
108
+ }
109
+ /** @internal */
110
+ calculateSplit(index, splitterPos, initialSizes, sum, startPosition) {
111
+ const h = this.getOrientation() === Orientation.HORZ;
112
+ const c = this.getChildren();
113
+ const sn = c[index];
114
+ const smax = h ? sn.getMaxWidth() : sn.getMaxHeight();
115
+ const sizes = [...initialSizes];
116
+ if (splitterPos < startPosition) { // moved left
117
+ let shift = startPosition - splitterPos;
118
+ let altShift = 0;
119
+ if (sizes[index] + shift > smax) {
120
+ altShift = sizes[index] + shift - smax;
121
+ sizes[index] = smax;
122
+ }
123
+ else {
124
+ sizes[index] += shift;
125
+ }
126
+ for (let i = index - 1; i >= 0; i--) {
127
+ const n = c[i];
128
+ const m = h ? n.getMinWidth() : n.getMinHeight();
129
+ if (sizes[i] - shift > m) {
130
+ sizes[i] -= shift;
131
+ break;
132
+ }
133
+ else {
134
+ shift -= sizes[i] - m;
135
+ sizes[i] = m;
136
+ }
137
+ }
138
+ for (let i = index + 1; i < c.length; i++) {
139
+ const n = c[i];
140
+ const m = h ? n.getMaxWidth() : n.getMaxHeight();
141
+ if (sizes[i] + altShift < m) {
142
+ sizes[i] += altShift;
143
+ break;
144
+ }
145
+ else {
146
+ altShift -= m - sizes[i];
147
+ sizes[i] = m;
148
+ }
149
+ }
150
+ }
151
+ else {
152
+ let shift = splitterPos - startPosition;
153
+ let altShift = 0;
154
+ if (sizes[index - 1] + shift > smax) {
155
+ altShift = sizes[index - 1] + shift - smax;
156
+ sizes[index - 1] = smax;
157
+ }
158
+ else {
159
+ sizes[index - 1] += shift;
160
+ }
161
+ for (let i = index; i < c.length; i++) {
162
+ const n = c[i];
163
+ const m = h ? n.getMinWidth() : n.getMinHeight();
164
+ if (sizes[i] - shift > m) {
165
+ sizes[i] -= shift;
166
+ break;
167
+ }
168
+ else {
169
+ shift -= sizes[i] - m;
170
+ sizes[i] = m;
171
+ }
172
+ }
173
+ for (let i = index - 1; i >= 0; i--) {
174
+ const n = c[i];
175
+ const m = h ? n.getMaxWidth() : n.getMaxHeight();
176
+ if (sizes[i] + altShift < m) {
177
+ sizes[i] += altShift;
178
+ break;
179
+ }
180
+ else {
181
+ altShift -= m - sizes[i];
182
+ sizes[i] = m;
183
+ }
184
+ }
185
+ }
186
+ // 0.1 is to prevent weight ever going to zero
187
+ const weights = sizes.map(s => Math.max(0.1, s) * 100 / sum);
188
+ // console.log(splitterPos, startPosition, "sizes", sizes);
189
+ // console.log("weights",weights);
190
+ return weights;
191
+ }
192
+ /** @internal */
193
+ getMinSize(orientation) {
194
+ if (orientation === Orientation.HORZ) {
195
+ return this.getMinWidth();
196
+ }
197
+ else {
198
+ return this.getMinHeight();
199
+ }
200
+ }
201
+ /** @internal */
202
+ getMinWidth() {
203
+ return this.minWidth;
204
+ }
205
+ /** @internal */
206
+ getMinHeight() {
207
+ return this.minHeight;
208
+ }
209
+ /** @internal */
210
+ getMaxSize(orientation) {
211
+ if (orientation === Orientation.HORZ) {
212
+ return this.getMaxWidth();
213
+ }
214
+ else {
215
+ return this.getMaxHeight();
216
+ }
217
+ }
218
+ /** @internal */
219
+ getMaxWidth() {
220
+ return this.maxWidth;
221
+ }
222
+ /** @internal */
223
+ getMaxHeight() {
224
+ return this.maxHeight;
225
+ }
226
+ /** @internal */
227
+ calcMinMaxSize() {
228
+ this.minHeight = DefaultMin;
229
+ this.minWidth = DefaultMin;
230
+ this.maxHeight = DefaultMax;
231
+ this.maxWidth = DefaultMax;
232
+ let first = true;
233
+ for (const child of this.children) {
234
+ const c = child;
235
+ c.calcMinMaxSize();
236
+ if (this.getOrientation() === Orientation.VERT) {
237
+ this.minHeight += c.getMinHeight();
238
+ this.maxHeight += c.getMaxHeight();
239
+ if (!first) {
240
+ this.minHeight += this.model.getSplitterSize();
241
+ this.maxHeight += this.model.getSplitterSize();
242
+ }
243
+ this.minWidth = Math.max(this.minWidth, c.getMinWidth());
244
+ this.maxWidth = Math.min(this.maxWidth, c.getMaxWidth());
245
+ }
246
+ else {
247
+ this.minWidth += c.getMinWidth();
248
+ this.maxWidth += c.getMaxWidth();
249
+ if (!first) {
250
+ this.minWidth += this.model.getSplitterSize();
251
+ this.maxWidth += this.model.getSplitterSize();
252
+ }
253
+ this.minHeight = Math.max(this.minHeight, c.getMinHeight());
254
+ this.maxHeight = Math.min(this.maxHeight, c.getMaxHeight());
255
+ }
256
+ first = false;
257
+ }
258
+ }
259
+ /** @internal */
260
+ tidy() {
261
+ let i = 0;
262
+ while (i < this.children.length) {
263
+ const child = this.children[i];
264
+ if (child instanceof RowNode) {
265
+ child.tidy();
266
+ const childChildren = child.getChildren();
267
+ if (childChildren.length === 0) {
268
+ this.removeChild(child);
269
+ }
270
+ else if (childChildren.length === 1) {
271
+ // hoist child/children up to this level
272
+ const subchild = childChildren[0];
273
+ this.removeChild(child);
274
+ if (subchild instanceof RowNode) {
275
+ let subChildrenTotal = 0;
276
+ const subChildChildren = subchild.getChildren();
277
+ for (const ssc of subChildChildren) {
278
+ const subsubChild = ssc;
279
+ subChildrenTotal += subsubChild.getWeight();
280
+ }
281
+ for (let j = 0; j < subChildChildren.length; j++) {
282
+ const subsubChild = subChildChildren[j];
283
+ subsubChild.setWeight((child.getWeight() * subsubChild.getWeight()) / subChildrenTotal);
284
+ this.addChild(subsubChild, i + j);
285
+ }
286
+ }
287
+ else {
288
+ subchild.setWeight(child.getWeight());
289
+ this.addChild(subchild, i);
290
+ }
291
+ }
292
+ else {
293
+ i++;
294
+ }
295
+ }
296
+ else if (child instanceof TabSetNode && child.getChildren().length === 0) {
297
+ if (child.isEnableDeleteWhenEmpty()) {
298
+ this.removeChild(child);
299
+ if (child === this.model.getMaximizedTabset(this.windowId)) {
300
+ this.model.setMaximizedTabset(undefined, this.windowId);
301
+ }
302
+ }
303
+ else {
304
+ i++;
305
+ }
306
+ }
307
+ else {
308
+ i++;
309
+ }
310
+ }
311
+ // add tabset into empty root
312
+ if (this === this.model.getRoot(this.windowId) && this.children.length === 0) {
313
+ const callback = this.model.getOnCreateTabSet();
314
+ let attrs = callback ? callback() : {};
315
+ attrs = Object.assign(Object.assign({}, attrs), { selected: -1 });
316
+ const child = new TabSetNode(this.model, attrs);
317
+ this.model.setActiveTabset(child, this.windowId);
318
+ this.addChild(child);
319
+ }
320
+ }
321
+ /** @internal */
322
+ canDrop(dragNode, x, y) {
323
+ const yy = y - this.rect.y;
324
+ const xx = x - this.rect.x;
325
+ const w = this.rect.width;
326
+ const h = this.rect.height;
327
+ const margin = 10; // height of edge rect
328
+ const half = 50; // half width of edge rect
329
+ let dropInfo;
330
+ if (this.getWindowId() !== Model.MAIN_WINDOW_ID && !canDockToWindow(dragNode)) {
331
+ return undefined;
332
+ }
333
+ if (this.model.isEnableEdgeDock() && this.parent === undefined) {
334
+ if (x < this.rect.x + margin && yy > h / 2 - half && yy < h / 2 + half) {
335
+ const dockLocation = DockLocation.LEFT;
336
+ const outlineRect = dockLocation.getDockRect(this.rect);
337
+ outlineRect.width = outlineRect.width / 2;
338
+ dropInfo = new DropInfo(this, outlineRect, dockLocation, -1, CLASSES.FLEXLAYOUT__OUTLINE_RECT_EDGE);
339
+ }
340
+ else if (x > this.rect.getRight() - margin && yy > h / 2 - half && yy < h / 2 + half) {
341
+ const dockLocation = DockLocation.RIGHT;
342
+ const outlineRect = dockLocation.getDockRect(this.rect);
343
+ outlineRect.width = outlineRect.width / 2;
344
+ outlineRect.x += outlineRect.width;
345
+ dropInfo = new DropInfo(this, outlineRect, dockLocation, -1, CLASSES.FLEXLAYOUT__OUTLINE_RECT_EDGE);
346
+ }
347
+ else if (y < this.rect.y + margin && xx > w / 2 - half && xx < w / 2 + half) {
348
+ const dockLocation = DockLocation.TOP;
349
+ const outlineRect = dockLocation.getDockRect(this.rect);
350
+ outlineRect.height = outlineRect.height / 2;
351
+ dropInfo = new DropInfo(this, outlineRect, dockLocation, -1, CLASSES.FLEXLAYOUT__OUTLINE_RECT_EDGE);
352
+ }
353
+ else if (y > this.rect.getBottom() - margin && xx > w / 2 - half && xx < w / 2 + half) {
354
+ const dockLocation = DockLocation.BOTTOM;
355
+ const outlineRect = dockLocation.getDockRect(this.rect);
356
+ outlineRect.height = outlineRect.height / 2;
357
+ outlineRect.y += outlineRect.height;
358
+ dropInfo = new DropInfo(this, outlineRect, dockLocation, -1, CLASSES.FLEXLAYOUT__OUTLINE_RECT_EDGE);
359
+ }
360
+ if (dropInfo !== undefined) {
361
+ if (!dragNode.canDockInto(dragNode, dropInfo)) {
362
+ return undefined;
363
+ }
364
+ }
365
+ }
366
+ return dropInfo;
367
+ }
368
+ /** @internal */
369
+ drop(dragNode, location, index) {
370
+ const dockLocation = location;
371
+ const parent = dragNode.getParent();
372
+ if (parent) {
373
+ parent.removeChild(dragNode);
374
+ }
375
+ if (parent !== undefined && parent instanceof TabSetNode) {
376
+ parent.setSelected(0);
377
+ }
378
+ if (parent !== undefined && parent instanceof BorderNode) {
379
+ parent.setSelected(-1);
380
+ }
381
+ let node;
382
+ if (dragNode instanceof TabSetNode || dragNode instanceof RowNode) {
383
+ node = dragNode;
384
+ // need to turn round if same orientation unless docking oposite direction
385
+ if (node instanceof RowNode && node.getOrientation() === this.getOrientation() &&
386
+ (location.getOrientation() === this.getOrientation() || location === DockLocation.CENTER)) {
387
+ node = new RowNode(this.model, this.windowId, {});
388
+ node.addChild(dragNode);
389
+ }
390
+ }
391
+ else {
392
+ const callback = this.model.getOnCreateTabSet();
393
+ node = new TabSetNode(this.model, callback ? callback(dragNode) : {});
394
+ node.addChild(dragNode);
395
+ }
396
+ let size = this.children.reduce((sum, child) => {
397
+ return sum + child.getWeight();
398
+ }, 0);
399
+ if (size === 0) {
400
+ size = 100;
401
+ }
402
+ node.setWeight(size / 3);
403
+ const horz = !this.model.isRootOrientationVertical();
404
+ if (dockLocation === DockLocation.CENTER) {
405
+ if (index === -1) {
406
+ this.addChild(node, this.children.length);
407
+ }
408
+ else {
409
+ this.addChild(node, index);
410
+ }
411
+ }
412
+ else if (horz && dockLocation === DockLocation.LEFT || !horz && dockLocation === DockLocation.TOP) {
413
+ this.addChild(node, 0);
414
+ }
415
+ else if (horz && dockLocation === DockLocation.RIGHT || !horz && dockLocation === DockLocation.BOTTOM) {
416
+ this.addChild(node);
417
+ }
418
+ else if (horz && dockLocation === DockLocation.TOP || !horz && dockLocation === DockLocation.LEFT) {
419
+ const vrow = new RowNode(this.model, this.windowId, {});
420
+ const hrow = new RowNode(this.model, this.windowId, {});
421
+ hrow.setWeight(75);
422
+ node.setWeight(25);
423
+ for (const child of this.children) {
424
+ hrow.addChild(child);
425
+ }
426
+ this.removeAll();
427
+ vrow.addChild(node);
428
+ vrow.addChild(hrow);
429
+ this.addChild(vrow);
430
+ }
431
+ else if (horz && dockLocation === DockLocation.BOTTOM || !horz && dockLocation === DockLocation.RIGHT) {
432
+ const vrow = new RowNode(this.model, this.windowId, {});
433
+ const hrow = new RowNode(this.model, this.windowId, {});
434
+ hrow.setWeight(75);
435
+ node.setWeight(25);
436
+ for (const child of this.children) {
437
+ hrow.addChild(child);
438
+ }
439
+ this.removeAll();
440
+ vrow.addChild(hrow);
441
+ vrow.addChild(node);
442
+ this.addChild(vrow);
443
+ }
444
+ if (node instanceof TabSetNode) {
445
+ this.model.setActiveTabset(node, this.windowId);
446
+ }
447
+ this.model.tidy();
448
+ }
449
+ /** @internal */
450
+ isEnableDrop() {
451
+ return true;
452
+ }
453
+ /** @internal */
454
+ getAttributeDefinitions() {
455
+ return RowNode.attributeDefinitions;
456
+ }
457
+ /** @internal */
458
+ updateAttrs(json) {
459
+ RowNode.attributeDefinitions.update(json, this.attributes);
460
+ }
461
+ /** @internal */
462
+ static getAttributeDefinitions() {
463
+ return RowNode.attributeDefinitions;
464
+ }
465
+ // NOTE: flex-grow cannot have values < 1 otherwise will not fill parent, need to normalize
466
+ normalizeWeights() {
467
+ let sum = 0;
468
+ for (const n of this.children) {
469
+ const node = n;
470
+ sum += node.getWeight();
471
+ }
472
+ if (sum === 0) {
473
+ sum = 1;
474
+ }
475
+ for (const n of this.children) {
476
+ const node = n;
477
+ node.setWeight(Math.max(0.001, 100 * node.getWeight() / sum));
478
+ }
479
+ }
480
+ /** @internal */
481
+ static createAttributeDefinitions() {
482
+ const attributeDefinitions = new AttributeDefinitions();
483
+ attributeDefinitions.add("type", RowNode.TYPE, true).setType(Attribute.STRING).setFixed();
484
+ attributeDefinitions.add("id", undefined).setType(Attribute.STRING).setDescription(`the unique id of the row, if left undefined a uuid will be assigned`);
485
+ attributeDefinitions.add("weight", 100).setType(Attribute.NUMBER).setDescription(`relative weight for sizing of this row in parent row`);
486
+ return attributeDefinitions;
487
+ }
488
+ }
489
+ RowNode.TYPE = "row";
490
+ /** @internal */
491
+ RowNode.attributeDefinitions = RowNode.createAttributeDefinitions();
505
492
  //# sourceMappingURL=RowNode.js.map