flexlayout-react 0.7.3 → 0.7.4
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/ChangeLog.txt +4 -0
- package/declarations/view/Icons.d.ts +1 -0
- package/dist/flexlayout.js +96 -184
- package/dist/flexlayout_min.js +1 -1
- package/lib/Attribute.js +12 -17
- package/lib/Attribute.js.map +1 -1
- package/lib/AttributeDefinitions.js +44 -53
- package/lib/AttributeDefinitions.js.map +1 -1
- package/lib/DockLocation.js +41 -46
- package/lib/DockLocation.js.map +1 -1
- package/lib/DragDrop.js +55 -60
- package/lib/DragDrop.js.map +1 -1
- package/lib/DropInfo.js +3 -8
- package/lib/DropInfo.js.map +1 -1
- package/lib/I18nLabel.js +2 -5
- package/lib/I18nLabel.js.map +1 -1
- package/lib/Orientation.js +11 -16
- package/lib/Orientation.js.map +1 -1
- package/lib/PopupMenu.js +24 -28
- package/lib/PopupMenu.js.map +1 -1
- package/lib/Rect.js +35 -41
- package/lib/Rect.js.map +1 -1
- package/lib/Types.js +2 -5
- package/lib/Types.js.map +1 -1
- package/lib/index.js +22 -38
- package/lib/index.js.map +1 -1
- package/lib/model/Action.js +3 -8
- package/lib/model/Action.js.map +1 -1
- package/lib/model/Actions.js +68 -75
- package/lib/model/Actions.js.map +1 -1
- package/lib/model/BorderNode.js +183 -206
- package/lib/model/BorderNode.js.map +1 -1
- package/lib/model/BorderSet.js +44 -55
- package/lib/model/BorderSet.js.map +1 -1
- package/lib/model/ICloseType.js +2 -5
- package/lib/model/ICloseType.js.map +1 -1
- package/lib/model/IDraggable.js +1 -2
- package/lib/model/IDropTarget.js +1 -2
- package/lib/model/IJsonModel.js +1 -2
- package/lib/model/Model.js +217 -232
- package/lib/model/Model.js.map +1 -1
- package/lib/model/Node.js +87 -94
- package/lib/model/Node.js.map +1 -1
- package/lib/model/RowNode.js +204 -250
- package/lib/model/RowNode.js.map +1 -1
- package/lib/model/SplitterNode.js +35 -57
- package/lib/model/SplitterNode.js.map +1 -1
- package/lib/model/TabNode.js +100 -124
- package/lib/model/TabNode.js.map +1 -1
- package/lib/model/TabSetNode.js +176 -199
- package/lib/model/TabSetNode.js.map +1 -1
- package/lib/model/Utils.js +20 -26
- package/lib/model/Utils.js.map +1 -1
- package/lib/view/BorderButton.js +45 -49
- package/lib/view/BorderButton.js.map +1 -1
- package/lib/view/BorderTabSet.js +57 -61
- package/lib/view/BorderTabSet.js.map +1 -1
- package/lib/view/ErrorBoundary.js +15 -37
- package/lib/view/ErrorBoundary.js.map +1 -1
- package/lib/view/FloatingWindow.js +43 -56
- package/lib/view/FloatingWindow.js.map +1 -1
- package/lib/view/FloatingWindowTab.js +12 -16
- package/lib/view/FloatingWindowTab.js.map +1 -1
- package/lib/view/Icons.js +7 -15
- package/lib/view/Icons.js.map +1 -1
- package/lib/view/Layout.js +392 -449
- package/lib/view/Layout.js.map +1 -1
- package/lib/view/Splitter.js +53 -57
- package/lib/view/Splitter.js.map +1 -1
- package/lib/view/Tab.js +31 -35
- package/lib/view/Tab.js.map +1 -1
- package/lib/view/TabButton.js +46 -50
- package/lib/view/TabButton.js.map +1 -1
- package/lib/view/TabButtonStamp.js +11 -15
- package/lib/view/TabButtonStamp.js.map +1 -1
- package/lib/view/TabFloating.js +30 -34
- package/lib/view/TabFloating.js.map +1 -1
- package/lib/view/TabOverflowHook.js +46 -50
- package/lib/view/TabOverflowHook.js.map +1 -1
- package/lib/view/TabSet.js +93 -106
- package/lib/view/TabSet.js.map +1 -1
- package/lib/view/Utils.js +11 -17
- package/lib/view/Utils.js.map +1 -1
- package/package.json +1 -1
- package/src/view/FloatingWindow.tsx +5 -1
- package/src/view/Layout.tsx +1 -5
package/lib/model/RowNode.js
CHANGED
|
@@ -1,109 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __assign = (this && this.__assign) || function () {
|
|
18
|
-
__assign = Object.assign || function(t) {
|
|
19
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
-
s = arguments[i];
|
|
21
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
-
t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
return t;
|
|
25
|
-
};
|
|
26
|
-
return __assign.apply(this, arguments);
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.RowNode = void 0;
|
|
30
|
-
var Attribute_1 = require("../Attribute");
|
|
31
|
-
var AttributeDefinitions_1 = require("../AttributeDefinitions");
|
|
32
|
-
var DockLocation_1 = require("../DockLocation");
|
|
33
|
-
var DropInfo_1 = require("../DropInfo");
|
|
34
|
-
var Orientation_1 = require("../Orientation");
|
|
35
|
-
var Rect_1 = require("../Rect");
|
|
36
|
-
var Types_1 = require("../Types");
|
|
37
|
-
var BorderNode_1 = require("./BorderNode");
|
|
38
|
-
var Node_1 = require("./Node");
|
|
39
|
-
var SplitterNode_1 = require("./SplitterNode");
|
|
40
|
-
var TabSetNode_1 = require("./TabSetNode");
|
|
41
|
-
var RowNode = /** @class */ (function (_super) {
|
|
42
|
-
__extends(RowNode, _super);
|
|
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 { Rect } from "../Rect";
|
|
7
|
+
import { CLASSES } from "../Types";
|
|
8
|
+
import { BorderNode } from "./BorderNode";
|
|
9
|
+
import { Node } from "./Node";
|
|
10
|
+
import { SplitterNode } from "./SplitterNode";
|
|
11
|
+
import { TabSetNode } from "./TabSetNode";
|
|
12
|
+
export class RowNode extends Node {
|
|
43
13
|
/** @internal */
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
RowNode._attributeDefinitions.fromJson(json,
|
|
51
|
-
model._addNode(
|
|
52
|
-
return _this;
|
|
14
|
+
constructor(model, json) {
|
|
15
|
+
super(model);
|
|
16
|
+
this._dirty = true;
|
|
17
|
+
this._drawChildren = [];
|
|
18
|
+
this._minHeight = 0;
|
|
19
|
+
this._minWidth = 0;
|
|
20
|
+
RowNode._attributeDefinitions.fromJson(json, this._attributes);
|
|
21
|
+
model._addNode(this);
|
|
53
22
|
}
|
|
54
23
|
/** @internal */
|
|
55
|
-
|
|
56
|
-
|
|
24
|
+
static _fromJson(json, model) {
|
|
25
|
+
const newLayoutNode = new RowNode(model, json);
|
|
57
26
|
if (json.children != null) {
|
|
58
|
-
for (
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
var child = TabSetNode_1.TabSetNode._fromJson(jsonChild, model);
|
|
27
|
+
for (const jsonChild of json.children) {
|
|
28
|
+
if (jsonChild.type === TabSetNode.TYPE) {
|
|
29
|
+
const child = TabSetNode._fromJson(jsonChild, model);
|
|
62
30
|
newLayoutNode._addChild(child);
|
|
63
31
|
}
|
|
64
32
|
else {
|
|
65
|
-
|
|
33
|
+
const child = RowNode._fromJson(jsonChild, model);
|
|
66
34
|
newLayoutNode._addChild(child);
|
|
67
35
|
}
|
|
68
36
|
}
|
|
69
37
|
}
|
|
70
38
|
return newLayoutNode;
|
|
71
|
-
}
|
|
39
|
+
}
|
|
72
40
|
/** @internal */
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
attributeDefinitions.add("type", RowNode.TYPE, true).setType(
|
|
76
|
-
attributeDefinitions.add("id", undefined).setType(
|
|
77
|
-
attributeDefinitions.add("weight", 100).setType(
|
|
78
|
-
attributeDefinitions.add("width", undefined).setType(
|
|
79
|
-
attributeDefinitions.add("height", undefined).setType(
|
|
41
|
+
static _createAttributeDefinitions() {
|
|
42
|
+
const attributeDefinitions = new AttributeDefinitions();
|
|
43
|
+
attributeDefinitions.add("type", RowNode.TYPE, true).setType(Attribute.STRING).setFixed();
|
|
44
|
+
attributeDefinitions.add("id", undefined).setType(Attribute.STRING);
|
|
45
|
+
attributeDefinitions.add("weight", 100).setType(Attribute.NUMBER);
|
|
46
|
+
attributeDefinitions.add("width", undefined).setType(Attribute.NUMBER);
|
|
47
|
+
attributeDefinitions.add("height", undefined).setType(Attribute.NUMBER);
|
|
80
48
|
return attributeDefinitions;
|
|
81
|
-
}
|
|
82
|
-
|
|
49
|
+
}
|
|
50
|
+
getWeight() {
|
|
83
51
|
return this._attributes.weight;
|
|
84
|
-
}
|
|
85
|
-
|
|
52
|
+
}
|
|
53
|
+
getWidth() {
|
|
86
54
|
return this._getAttr("width");
|
|
87
|
-
}
|
|
88
|
-
|
|
55
|
+
}
|
|
56
|
+
getHeight() {
|
|
89
57
|
return this._getAttr("height");
|
|
90
|
-
}
|
|
58
|
+
}
|
|
91
59
|
/** @internal */
|
|
92
|
-
|
|
60
|
+
_setWeight(weight) {
|
|
93
61
|
this._attributes.weight = weight;
|
|
94
|
-
}
|
|
62
|
+
}
|
|
95
63
|
/** @internal */
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
for (
|
|
105
|
-
|
|
106
|
-
var prefSize = child._getPrefSize(this.getOrientation());
|
|
64
|
+
_layout(rect, metrics) {
|
|
65
|
+
super._layout(rect, metrics);
|
|
66
|
+
const pixelSize = this._rect._getSize(this.getOrientation());
|
|
67
|
+
let totalWeight = 0;
|
|
68
|
+
let fixedPixels = 0;
|
|
69
|
+
let prefPixels = 0;
|
|
70
|
+
let totalPrefWeight = 0;
|
|
71
|
+
const drawChildren = this._getDrawChildren();
|
|
72
|
+
for (const child of drawChildren) {
|
|
73
|
+
const prefSize = child._getPrefSize(this.getOrientation());
|
|
107
74
|
if (child._isFixed()) {
|
|
108
75
|
if (prefSize !== undefined) {
|
|
109
76
|
fixedPixels += prefSize;
|
|
@@ -119,19 +86,18 @@ var RowNode = /** @class */ (function (_super) {
|
|
|
119
86
|
}
|
|
120
87
|
}
|
|
121
88
|
}
|
|
122
|
-
|
|
123
|
-
|
|
89
|
+
let resizePreferred = false;
|
|
90
|
+
let availablePixels = pixelSize - fixedPixels - prefPixels;
|
|
124
91
|
if (availablePixels < 0) {
|
|
125
92
|
availablePixels = pixelSize - fixedPixels;
|
|
126
93
|
resizePreferred = true;
|
|
127
94
|
totalWeight += totalPrefWeight;
|
|
128
95
|
}
|
|
129
96
|
// assign actual pixel sizes
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
for (
|
|
133
|
-
|
|
134
|
-
var prefSize = child._getPrefSize(this.getOrientation());
|
|
97
|
+
let totalSizeGiven = 0;
|
|
98
|
+
let variableSize = 0;
|
|
99
|
+
for (const child of drawChildren) {
|
|
100
|
+
const prefSize = child._getPrefSize(this.getOrientation());
|
|
135
101
|
if (child._isFixed()) {
|
|
136
102
|
if (prefSize !== undefined) {
|
|
137
103
|
child._setTempSize(prefSize);
|
|
@@ -143,8 +109,8 @@ var RowNode = /** @class */ (function (_super) {
|
|
|
143
109
|
child._setTempSize(0);
|
|
144
110
|
}
|
|
145
111
|
else {
|
|
146
|
-
|
|
147
|
-
|
|
112
|
+
const minSize = child.getMinSize(this.getOrientation());
|
|
113
|
+
const size = Math.floor(availablePixels * (child.getWeight() / totalWeight));
|
|
148
114
|
child._setTempSize(Math.max(minSize, size));
|
|
149
115
|
}
|
|
150
116
|
variableSize += child._getTempSize();
|
|
@@ -158,10 +124,9 @@ var RowNode = /** @class */ (function (_super) {
|
|
|
158
124
|
// adjust sizes to exactly fit
|
|
159
125
|
if (variableSize > 0) {
|
|
160
126
|
while (totalSizeGiven < pixelSize) {
|
|
161
|
-
for (
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
var prefSize = child._getPrefSize(this.getOrientation());
|
|
127
|
+
for (const child of drawChildren) {
|
|
128
|
+
if (!(child instanceof SplitterNode)) {
|
|
129
|
+
const prefSize = child._getPrefSize(this.getOrientation());
|
|
165
130
|
if (!child._isFixed() && (prefSize === undefined || resizePreferred) && totalSizeGiven < pixelSize) {
|
|
166
131
|
child._setTempSize(child._getTempSize() + 1);
|
|
167
132
|
totalSizeGiven++;
|
|
@@ -171,12 +136,11 @@ var RowNode = /** @class */ (function (_super) {
|
|
|
171
136
|
}
|
|
172
137
|
// decrease size using nodes not at there minimum
|
|
173
138
|
while (totalSizeGiven > pixelSize) {
|
|
174
|
-
|
|
175
|
-
for (
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
var size = child._getTempSize();
|
|
139
|
+
let changed = false;
|
|
140
|
+
for (const child of drawChildren) {
|
|
141
|
+
if (!(child instanceof SplitterNode)) {
|
|
142
|
+
const minSize = child.getMinSize(this.getOrientation());
|
|
143
|
+
const size = child._getTempSize();
|
|
180
144
|
if (size > minSize && totalSizeGiven > pixelSize) {
|
|
181
145
|
child._setTempSize(child._getTempSize() - 1);
|
|
182
146
|
totalSizeGiven--;
|
|
@@ -191,11 +155,10 @@ var RowNode = /** @class */ (function (_super) {
|
|
|
191
155
|
}
|
|
192
156
|
// if still too big then simply reduce all nodes until fits
|
|
193
157
|
while (totalSizeGiven > pixelSize) {
|
|
194
|
-
|
|
195
|
-
for (
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
var size = child._getTempSize();
|
|
158
|
+
let changed = false;
|
|
159
|
+
for (const child of drawChildren) {
|
|
160
|
+
if (!(child instanceof SplitterNode)) {
|
|
161
|
+
const size = child._getTempSize();
|
|
199
162
|
if (size > 0 && totalSizeGiven > pixelSize) {
|
|
200
163
|
child._setTempSize(child._getTempSize() - 1);
|
|
201
164
|
totalSizeGiven--;
|
|
@@ -210,72 +173,70 @@ var RowNode = /** @class */ (function (_super) {
|
|
|
210
173
|
}
|
|
211
174
|
}
|
|
212
175
|
// layout children
|
|
213
|
-
|
|
214
|
-
for (
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
child._layout(new Rect_1.Rect(this._rect.x + p, this._rect.y, child._getTempSize(), this._rect.height), metrics);
|
|
176
|
+
let p = 0;
|
|
177
|
+
for (const child of drawChildren) {
|
|
178
|
+
if (this.getOrientation() === Orientation.HORZ) {
|
|
179
|
+
child._layout(new Rect(this._rect.x + p, this._rect.y, child._getTempSize(), this._rect.height), metrics);
|
|
218
180
|
}
|
|
219
181
|
else {
|
|
220
|
-
child._layout(new
|
|
182
|
+
child._layout(new Rect(this._rect.x, this._rect.y + p, this._rect.width, child._getTempSize()), metrics);
|
|
221
183
|
}
|
|
222
184
|
p += child._getTempSize();
|
|
223
185
|
}
|
|
224
186
|
return true;
|
|
225
|
-
}
|
|
187
|
+
}
|
|
226
188
|
/** @internal */
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
var minSize2 = useMinSize ? node2.getMinWidth() : 0;
|
|
189
|
+
_getSplitterBounds(splitterNode, useMinSize = false) {
|
|
190
|
+
const pBounds = [0, 0];
|
|
191
|
+
const drawChildren = this._getDrawChildren();
|
|
192
|
+
const p = drawChildren.indexOf(splitterNode);
|
|
193
|
+
const node1 = drawChildren[p - 1];
|
|
194
|
+
const node2 = drawChildren[p + 1];
|
|
195
|
+
if (this.getOrientation() === Orientation.HORZ) {
|
|
196
|
+
const minSize1 = useMinSize ? node1.getMinWidth() : 0;
|
|
197
|
+
const minSize2 = useMinSize ? node2.getMinWidth() : 0;
|
|
237
198
|
pBounds[0] = node1.getRect().x + minSize1;
|
|
238
199
|
pBounds[1] = node2.getRect().getRight() - splitterNode.getWidth() - minSize2;
|
|
239
200
|
}
|
|
240
201
|
else {
|
|
241
|
-
|
|
242
|
-
|
|
202
|
+
const minSize1 = useMinSize ? node1.getMinHeight() : 0;
|
|
203
|
+
const minSize2 = useMinSize ? node2.getMinHeight() : 0;
|
|
243
204
|
pBounds[0] = node1.getRect().y + minSize1;
|
|
244
205
|
pBounds[1] = node2.getRect().getBottom() - splitterNode.getHeight() - minSize2;
|
|
245
206
|
}
|
|
246
207
|
return pBounds;
|
|
247
|
-
}
|
|
208
|
+
}
|
|
248
209
|
/** @internal */
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
210
|
+
_calculateSplit(splitter, splitterPos) {
|
|
211
|
+
let rtn;
|
|
212
|
+
const drawChildren = this._getDrawChildren();
|
|
213
|
+
const p = drawChildren.indexOf(splitter);
|
|
214
|
+
const pBounds = this._getSplitterBounds(splitter);
|
|
215
|
+
const weightedLength = drawChildren[p - 1].getWeight() + drawChildren[p + 1].getWeight();
|
|
216
|
+
const pixelWidth1 = Math.max(0, splitterPos - pBounds[0]);
|
|
217
|
+
const pixelWidth2 = Math.max(0, pBounds[1] - splitterPos);
|
|
257
218
|
if (pixelWidth1 + pixelWidth2 > 0) {
|
|
258
|
-
|
|
259
|
-
|
|
219
|
+
const weight1 = (pixelWidth1 * weightedLength) / (pixelWidth1 + pixelWidth2);
|
|
220
|
+
const weight2 = (pixelWidth2 * weightedLength) / (pixelWidth1 + pixelWidth2);
|
|
260
221
|
rtn = {
|
|
261
222
|
node1Id: drawChildren[p - 1].getId(),
|
|
262
|
-
weight1
|
|
263
|
-
pixelWidth1
|
|
223
|
+
weight1,
|
|
224
|
+
pixelWidth1,
|
|
264
225
|
node2Id: drawChildren[p + 1].getId(),
|
|
265
|
-
weight2
|
|
266
|
-
pixelWidth2
|
|
226
|
+
weight2,
|
|
227
|
+
pixelWidth2,
|
|
267
228
|
};
|
|
268
229
|
}
|
|
269
230
|
return rtn;
|
|
270
|
-
}
|
|
231
|
+
}
|
|
271
232
|
/** @internal */
|
|
272
|
-
|
|
233
|
+
_getDrawChildren() {
|
|
273
234
|
if (this._dirty) {
|
|
274
235
|
this._drawChildren = [];
|
|
275
|
-
for (
|
|
276
|
-
|
|
236
|
+
for (let i = 0; i < this._children.length; i++) {
|
|
237
|
+
const child = this._children[i];
|
|
277
238
|
if (i !== 0) {
|
|
278
|
-
|
|
239
|
+
const newSplitter = new SplitterNode(this._model);
|
|
279
240
|
newSplitter._setParent(this);
|
|
280
241
|
this._drawChildren.push(newSplitter);
|
|
281
242
|
}
|
|
@@ -284,36 +245,35 @@ var RowNode = /** @class */ (function (_super) {
|
|
|
284
245
|
this._dirty = false;
|
|
285
246
|
}
|
|
286
247
|
return this._drawChildren;
|
|
287
|
-
}
|
|
248
|
+
}
|
|
288
249
|
/** @internal */
|
|
289
|
-
|
|
290
|
-
if (orientation ===
|
|
250
|
+
getMinSize(orientation) {
|
|
251
|
+
if (orientation === Orientation.HORZ) {
|
|
291
252
|
return this.getMinWidth();
|
|
292
253
|
}
|
|
293
254
|
else {
|
|
294
255
|
return this.getMinHeight();
|
|
295
256
|
}
|
|
296
|
-
}
|
|
257
|
+
}
|
|
297
258
|
/** @internal */
|
|
298
|
-
|
|
259
|
+
getMinWidth() {
|
|
299
260
|
return this._minWidth;
|
|
300
|
-
}
|
|
261
|
+
}
|
|
301
262
|
/** @internal */
|
|
302
|
-
|
|
263
|
+
getMinHeight() {
|
|
303
264
|
return this._minHeight;
|
|
304
|
-
}
|
|
265
|
+
}
|
|
305
266
|
/** @internal */
|
|
306
|
-
|
|
267
|
+
calcMinSize() {
|
|
307
268
|
this._minHeight = 0;
|
|
308
269
|
this._minWidth = 0;
|
|
309
|
-
|
|
310
|
-
for (
|
|
311
|
-
|
|
312
|
-
var c = child;
|
|
270
|
+
let first = true;
|
|
271
|
+
for (const child of this._children) {
|
|
272
|
+
const c = child;
|
|
313
273
|
if (c instanceof RowNode) {
|
|
314
274
|
c.calcMinSize();
|
|
315
275
|
}
|
|
316
|
-
if (this.getOrientation() ===
|
|
276
|
+
if (this.getOrientation() === Orientation.VERT) {
|
|
317
277
|
this._minHeight += c.getMinHeight();
|
|
318
278
|
if (!first) {
|
|
319
279
|
this._minHeight += this._model.getSplitterSize();
|
|
@@ -329,32 +289,31 @@ var RowNode = /** @class */ (function (_super) {
|
|
|
329
289
|
}
|
|
330
290
|
first = false;
|
|
331
291
|
}
|
|
332
|
-
}
|
|
292
|
+
}
|
|
333
293
|
/** @internal */
|
|
334
|
-
|
|
335
|
-
|
|
294
|
+
_tidy() {
|
|
295
|
+
let i = 0;
|
|
336
296
|
while (i < this._children.length) {
|
|
337
|
-
|
|
297
|
+
const child = this._children[i];
|
|
338
298
|
if (child instanceof RowNode) {
|
|
339
299
|
child._tidy();
|
|
340
|
-
|
|
300
|
+
const childChildren = child.getChildren();
|
|
341
301
|
if (childChildren.length === 0) {
|
|
342
302
|
this._removeChild(child);
|
|
343
303
|
}
|
|
344
304
|
else if (childChildren.length === 1) {
|
|
345
305
|
// hoist child/children up to this level
|
|
346
|
-
|
|
306
|
+
const subchild = childChildren[0];
|
|
347
307
|
this._removeChild(child);
|
|
348
308
|
if (subchild instanceof RowNode) {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
for (
|
|
352
|
-
|
|
353
|
-
var subsubChild = ssc;
|
|
309
|
+
let subChildrenTotal = 0;
|
|
310
|
+
const subChildChildren = subchild.getChildren();
|
|
311
|
+
for (const ssc of subChildChildren) {
|
|
312
|
+
const subsubChild = ssc;
|
|
354
313
|
subChildrenTotal += subsubChild.getWeight();
|
|
355
314
|
}
|
|
356
|
-
for (
|
|
357
|
-
|
|
315
|
+
for (let j = 0; j < subChildChildren.length; j++) {
|
|
316
|
+
const subsubChild = subChildChildren[j];
|
|
358
317
|
subsubChild._setWeight((child.getWeight() * subsubChild.getWeight()) / subChildrenTotal);
|
|
359
318
|
this._addChild(subsubChild, i + j);
|
|
360
319
|
}
|
|
@@ -368,7 +327,7 @@ var RowNode = /** @class */ (function (_super) {
|
|
|
368
327
|
i++;
|
|
369
328
|
}
|
|
370
329
|
}
|
|
371
|
-
else if (child instanceof
|
|
330
|
+
else if (child instanceof TabSetNode && child.getChildren().length === 0) {
|
|
372
331
|
if (child.isEnableDeleteWhenEmpty()) {
|
|
373
332
|
this._removeChild(child);
|
|
374
333
|
if (child === this._model.getMaximizedTabset()) {
|
|
@@ -385,50 +344,50 @@ var RowNode = /** @class */ (function (_super) {
|
|
|
385
344
|
}
|
|
386
345
|
// add tabset into empty root
|
|
387
346
|
if (this === this._model.getRoot() && this._children.length === 0) {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
attrs =
|
|
391
|
-
|
|
347
|
+
const callback = this._model._getOnCreateTabSet();
|
|
348
|
+
let attrs = callback ? callback() : {};
|
|
349
|
+
attrs = Object.assign(Object.assign({}, attrs), { selected: -1 });
|
|
350
|
+
const child = new TabSetNode(this._model, attrs);
|
|
392
351
|
this._model._setActiveTabset(child);
|
|
393
352
|
this._addChild(child);
|
|
394
353
|
}
|
|
395
|
-
}
|
|
354
|
+
}
|
|
396
355
|
/** @internal */
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
356
|
+
canDrop(dragNode, x, y) {
|
|
357
|
+
const yy = y - this._rect.y;
|
|
358
|
+
const xx = x - this._rect.x;
|
|
359
|
+
const w = this._rect.width;
|
|
360
|
+
const h = this._rect.height;
|
|
361
|
+
const margin = 10; // height of edge rect
|
|
362
|
+
const half = 50; // half width of edge rect
|
|
363
|
+
let dropInfo;
|
|
405
364
|
if (this._model.isEnableEdgeDock() && this._parent === undefined) {
|
|
406
365
|
// _root row
|
|
407
366
|
if (x < this._rect.x + margin && yy > h / 2 - half && yy < h / 2 + half) {
|
|
408
|
-
|
|
409
|
-
|
|
367
|
+
const dockLocation = DockLocation.LEFT;
|
|
368
|
+
const outlineRect = dockLocation.getDockRect(this._rect);
|
|
410
369
|
outlineRect.width = outlineRect.width / 2;
|
|
411
|
-
dropInfo = new
|
|
370
|
+
dropInfo = new DropInfo(this, outlineRect, dockLocation, -1, CLASSES.FLEXLAYOUT__OUTLINE_RECT_EDGE);
|
|
412
371
|
}
|
|
413
372
|
else if (x > this._rect.getRight() - margin && yy > h / 2 - half && yy < h / 2 + half) {
|
|
414
|
-
|
|
415
|
-
|
|
373
|
+
const dockLocation = DockLocation.RIGHT;
|
|
374
|
+
const outlineRect = dockLocation.getDockRect(this._rect);
|
|
416
375
|
outlineRect.width = outlineRect.width / 2;
|
|
417
376
|
outlineRect.x += outlineRect.width;
|
|
418
|
-
dropInfo = new
|
|
377
|
+
dropInfo = new DropInfo(this, outlineRect, dockLocation, -1, CLASSES.FLEXLAYOUT__OUTLINE_RECT_EDGE);
|
|
419
378
|
}
|
|
420
379
|
else if (y < this._rect.y + margin && xx > w / 2 - half && xx < w / 2 + half) {
|
|
421
|
-
|
|
422
|
-
|
|
380
|
+
const dockLocation = DockLocation.TOP;
|
|
381
|
+
const outlineRect = dockLocation.getDockRect(this._rect);
|
|
423
382
|
outlineRect.height = outlineRect.height / 2;
|
|
424
|
-
dropInfo = new
|
|
383
|
+
dropInfo = new DropInfo(this, outlineRect, dockLocation, -1, CLASSES.FLEXLAYOUT__OUTLINE_RECT_EDGE);
|
|
425
384
|
}
|
|
426
385
|
else if (y > this._rect.getBottom() - margin && xx > w / 2 - half && xx < w / 2 + half) {
|
|
427
|
-
|
|
428
|
-
|
|
386
|
+
const dockLocation = DockLocation.BOTTOM;
|
|
387
|
+
const outlineRect = dockLocation.getDockRect(this._rect);
|
|
429
388
|
outlineRect.height = outlineRect.height / 2;
|
|
430
389
|
outlineRect.y += outlineRect.height;
|
|
431
|
-
dropInfo = new
|
|
390
|
+
dropInfo = new DropInfo(this, outlineRect, dockLocation, -1, CLASSES.FLEXLAYOUT__OUTLINE_RECT_EDGE);
|
|
432
391
|
}
|
|
433
392
|
if (dropInfo !== undefined) {
|
|
434
393
|
if (!dragNode._canDockInto(dragNode, dropInfo)) {
|
|
@@ -437,50 +396,49 @@ var RowNode = /** @class */ (function (_super) {
|
|
|
437
396
|
}
|
|
438
397
|
}
|
|
439
398
|
return dropInfo;
|
|
440
|
-
}
|
|
399
|
+
}
|
|
441
400
|
/** @internal */
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
401
|
+
drop(dragNode, location, index) {
|
|
402
|
+
const dockLocation = location;
|
|
403
|
+
const parent = dragNode.getParent();
|
|
445
404
|
if (parent) {
|
|
446
405
|
parent._removeChild(dragNode);
|
|
447
406
|
}
|
|
448
|
-
if (parent !== undefined && parent.getType() ===
|
|
407
|
+
if (parent !== undefined && parent.getType() === TabSetNode.TYPE) {
|
|
449
408
|
parent._setSelected(0);
|
|
450
409
|
}
|
|
451
|
-
if (parent !== undefined && parent.getType() ===
|
|
410
|
+
if (parent !== undefined && parent.getType() === BorderNode.TYPE) {
|
|
452
411
|
parent._setSelected(-1);
|
|
453
412
|
}
|
|
454
|
-
|
|
455
|
-
if (dragNode instanceof
|
|
413
|
+
let tabSet;
|
|
414
|
+
if (dragNode instanceof TabSetNode) {
|
|
456
415
|
tabSet = dragNode;
|
|
457
416
|
}
|
|
458
417
|
else {
|
|
459
|
-
|
|
460
|
-
tabSet = new
|
|
418
|
+
const callback = this._model._getOnCreateTabSet();
|
|
419
|
+
tabSet = new TabSetNode(this._model, callback ? callback(dragNode) : {});
|
|
461
420
|
tabSet._addChild(dragNode);
|
|
462
421
|
}
|
|
463
|
-
|
|
422
|
+
let size = this._children.reduce((sum, child) => {
|
|
464
423
|
return sum + child.getWeight();
|
|
465
424
|
}, 0);
|
|
466
425
|
if (size === 0) {
|
|
467
426
|
size = 100;
|
|
468
427
|
}
|
|
469
428
|
tabSet._setWeight(size / 3);
|
|
470
|
-
|
|
471
|
-
if (horz && dockLocation ===
|
|
429
|
+
const horz = !this._model.isRootOrientationVertical();
|
|
430
|
+
if (horz && dockLocation === DockLocation.LEFT || !horz && dockLocation === DockLocation.TOP) {
|
|
472
431
|
this._addChild(tabSet, 0);
|
|
473
432
|
}
|
|
474
|
-
else if (horz && dockLocation ===
|
|
433
|
+
else if (horz && dockLocation === DockLocation.RIGHT || !horz && dockLocation === DockLocation.BOTTOM) {
|
|
475
434
|
this._addChild(tabSet);
|
|
476
435
|
}
|
|
477
|
-
else if (horz && dockLocation ===
|
|
478
|
-
|
|
479
|
-
|
|
436
|
+
else if (horz && dockLocation === DockLocation.TOP || !horz && dockLocation === DockLocation.LEFT) {
|
|
437
|
+
const vrow = new RowNode(this._model, {});
|
|
438
|
+
const hrow = new RowNode(this._model, {});
|
|
480
439
|
hrow._setWeight(75);
|
|
481
440
|
tabSet._setWeight(25);
|
|
482
|
-
for (
|
|
483
|
-
var child = _a[_i];
|
|
441
|
+
for (const child of this._children) {
|
|
484
442
|
hrow._addChild(child);
|
|
485
443
|
}
|
|
486
444
|
this._removeAll();
|
|
@@ -488,13 +446,12 @@ var RowNode = /** @class */ (function (_super) {
|
|
|
488
446
|
vrow._addChild(hrow);
|
|
489
447
|
this._addChild(vrow);
|
|
490
448
|
}
|
|
491
|
-
else if (horz && dockLocation ===
|
|
492
|
-
|
|
493
|
-
|
|
449
|
+
else if (horz && dockLocation === DockLocation.BOTTOM || !horz && dockLocation === DockLocation.RIGHT) {
|
|
450
|
+
const vrow = new RowNode(this._model, {});
|
|
451
|
+
const hrow = new RowNode(this._model, {});
|
|
494
452
|
hrow._setWeight(75);
|
|
495
453
|
tabSet._setWeight(25);
|
|
496
|
-
for (
|
|
497
|
-
var child = _c[_b];
|
|
454
|
+
for (const child of this._children) {
|
|
498
455
|
hrow._addChild(child);
|
|
499
456
|
}
|
|
500
457
|
this._removeAll();
|
|
@@ -504,44 +461,41 @@ var RowNode = /** @class */ (function (_super) {
|
|
|
504
461
|
}
|
|
505
462
|
this._model._setActiveTabset(tabSet);
|
|
506
463
|
this._model._tidy();
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
|
|
464
|
+
}
|
|
465
|
+
toJson() {
|
|
466
|
+
const json = {};
|
|
510
467
|
RowNode._attributeDefinitions.toJson(json, this._attributes);
|
|
511
468
|
json.children = [];
|
|
512
|
-
for (
|
|
513
|
-
var child = _a[_i];
|
|
469
|
+
for (const child of this._children) {
|
|
514
470
|
json.children.push(child.toJson());
|
|
515
471
|
}
|
|
516
472
|
return json;
|
|
517
|
-
}
|
|
518
|
-
|
|
473
|
+
}
|
|
474
|
+
isEnableDrop() {
|
|
519
475
|
return true;
|
|
520
|
-
}
|
|
476
|
+
}
|
|
521
477
|
/** @internal */
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
if (orientation ===
|
|
478
|
+
_getPrefSize(orientation) {
|
|
479
|
+
let prefSize = this.getWidth();
|
|
480
|
+
if (orientation === Orientation.VERT) {
|
|
525
481
|
prefSize = this.getHeight();
|
|
526
482
|
}
|
|
527
483
|
return prefSize;
|
|
528
|
-
}
|
|
484
|
+
}
|
|
529
485
|
/** @internal */
|
|
530
|
-
|
|
486
|
+
_getAttributeDefinitions() {
|
|
531
487
|
return RowNode._attributeDefinitions;
|
|
532
|
-
}
|
|
488
|
+
}
|
|
533
489
|
/** @internal */
|
|
534
|
-
|
|
490
|
+
_updateAttrs(json) {
|
|
535
491
|
RowNode._attributeDefinitions.update(json, this._attributes);
|
|
536
|
-
}
|
|
492
|
+
}
|
|
537
493
|
/** @internal */
|
|
538
|
-
|
|
494
|
+
static getAttributeDefinitions() {
|
|
539
495
|
return RowNode._attributeDefinitions;
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
}(Node_1.Node));
|
|
546
|
-
exports.RowNode = RowNode;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
RowNode.TYPE = "row";
|
|
499
|
+
/** @internal */
|
|
500
|
+
RowNode._attributeDefinitions = RowNode._createAttributeDefinitions();
|
|
547
501
|
//# sourceMappingURL=RowNode.js.map
|