bm-core-ui 2.7.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.
- package/CHANGELOG.md +1624 -0
- package/LICENSE +21 -0
- package/README.md +145 -0
- package/build/@types/index.d.ts +14078 -0
- package/build/BMCodeEditor/BMCodeEditor.js +707 -0
- package/build/BMCollectionView/BMCollectionView.js +5861 -0
- package/build/BMCollectionView/BMCollectionViewCell.js +688 -0
- package/build/BMCollectionView/BMCollectionViewFlowLayout.js +4467 -0
- package/build/BMCollectionView/BMCollectionViewLayout.js +830 -0
- package/build/BMCollectionView/BMCollectionViewLayoutAttributes.js +673 -0
- package/build/BMCollectionView/BMCollectionViewMasonryLayout.js +491 -0
- package/build/BMCollectionView/BMCollectionViewStackLayout.js +634 -0
- package/build/BMCollectionView/BMCollectionViewTileLayout.js +1121 -0
- package/build/BMCoreUI.css +2833 -0
- package/build/BMView/BMAttributedLabelView.js +310 -0
- package/build/BMView/BMLayoutConstraint_v2.5.js +1813 -0
- package/build/BMView/BMLayoutGuide.js +192 -0
- package/build/BMView/BMLayoutSizeClass.js +466 -0
- package/build/BMView/BMMenu.js +574 -0
- package/build/BMView/BMScrollView.js +247 -0
- package/build/BMView/BMTextField.js +512 -0
- package/build/BMView/BMTextFieldDelegate.js +71 -0
- package/build/BMView/BMView_v2.5.js +3572 -0
- package/build/BMView/BMViewport.js +221 -0
- package/build/BMViewLayoutEditor/BMLayoutEditor.js +6117 -0
- package/build/BMViewLayoutEditor/BMLayoutEditorConstraintSettings.js +417 -0
- package/build/BMViewLayoutEditor/BMLayoutEditorDelegate.js +59 -0
- package/build/BMViewLayoutEditor/BMLayoutEditorSettingCells.js +1653 -0
- package/build/BMViewLayoutEditor/BMLayoutEditorSettings.js +1480 -0
- package/build/BMViewLayoutEditor/BMLayoutEditorSettingsComplexCells.js +431 -0
- package/build/BMViewLayoutEditor/BMLayoutEditorSettingsDelegate.js +46 -0
- package/build/BMViewLayoutEditor/BMLayoutEditorVariablesController.js +460 -0
- package/build/BMViewLayoutEditor/BMLayoutEditorViewGroupSettings.js +293 -0
- package/build/BMViewLayoutEditor/BMLayoutEditorViewSettings.js +382 -0
- package/build/BMViewLayoutEditor/BMLayoutVariableProvider.js +202 -0
- package/build/BMWindow/BMConfirmationPopup.js +477 -0
- package/build/BMWindow/BMKeyboardShortcut.js +151 -0
- package/build/BMWindow/BMPopover/BMPopover.js +492 -0
- package/build/BMWindow/BMToolWindow.js +71 -0
- package/build/BMWindow/BMWindow.js +2000 -0
- package/build/Core/BMAnimationContext.js +1181 -0
- package/build/Core/BMColor.js +991 -0
- package/build/Core/BMCoreUI.js +470 -0
- package/build/Core/BMFunctionCollection.js +110 -0
- package/build/Core/BMIndexPath.js +165 -0
- package/build/Core/BMInset.js +138 -0
- package/build/Core/BMKeyPath.js +100 -0
- package/build/Core/BMPoint.js +291 -0
- package/build/Core/BMRect.js +556 -0
- package/build/Core/BMSize.js +137 -0
- package/build/iScroll/LICENSE +22 -0
- package/build/iScroll/iscroll-probe.js +2154 -0
- package/build/images/AlignBottom.png +0 -0
- package/build/images/AlignCenterX.png +0 -0
- package/build/images/AlignCenterY.png +0 -0
- package/build/images/AlignLeading.png +0 -0
- package/build/images/AlignTop.png +0 -0
- package/build/images/AlignTrailing.png +0 -0
- package/build/images/AllConstraints.png +0 -0
- package/build/images/BottomConstraint.png +0 -0
- package/build/images/CenterXConstraint.png +0 -0
- package/build/images/CenterYConstraint.png +0 -0
- package/build/images/CoreUI2.png +0 -0
- package/build/images/CoreUI2@2x.png +0 -0
- package/build/images/Desktop.png +0 -0
- package/build/images/DesktopMini.png +0 -0
- package/build/images/EqualHeight.png +0 -0
- package/build/images/EqualHorizontalSpacing.png +0 -0
- package/build/images/EqualHorizontalSpacingInSuperview.png +0 -0
- package/build/images/EqualVerticalSpacing.png +0 -0
- package/build/images/EqualVerticalSpacingInSuperview.png +0 -0
- package/build/images/EqualWidth.png +0 -0
- package/build/images/HeightConstraint.png +0 -0
- package/build/images/InactiveConstraints.png +0 -0
- package/build/images/Layout.png +0 -0
- package/build/images/LayoutVariables.png +0 -0
- package/build/images/LeftConstraint.png +0 -0
- package/build/images/OwnConstraints.png +0 -0
- package/build/images/Phone.png +0 -0
- package/build/images/PhoneLandscape.png +0 -0
- package/build/images/PhoneLandscapeMini.png +0 -0
- package/build/images/PhoneMini.png +0 -0
- package/build/images/PhonePortrait.png +0 -0
- package/build/images/PhonePortraitMini.png +0 -0
- package/build/images/Properties.png +0 -0
- package/build/images/RightConstraint.png +0 -0
- package/build/images/SubviewConstraints.png +0 -0
- package/build/images/Tablet.png +0 -0
- package/build/images/TabletLandscape.png +0 -0
- package/build/images/TabletLandscapeMini.png +0 -0
- package/build/images/TabletMini.png +0 -0
- package/build/images/TabletPortrait.png +0 -0
- package/build/images/TabletPortraitMini.png +0 -0
- package/build/images/TopConstraint.png +0 -0
- package/build/images/WidthConstraint.png +0 -0
- package/build/index.js +40 -0
- package/lib/@types/BMCoreUI.min.d.ts +14078 -0
- package/lib/BMCoreUI.min.js +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
//@ts-check
|
|
2
|
+
|
|
3
|
+
import { BMView } from "../BMView/BMView_v2.5";
|
|
4
|
+
import { BMExtend, BMStringByCapitalizingString, NO, YES } from "../Core/BMCoreUI";
|
|
5
|
+
import { BMInsetMake } from "../Core/BMInset";
|
|
6
|
+
import { BMSizeMake } from "../Core/BMSize";
|
|
7
|
+
import { BMLayoutEditorSettingsCell, BMLayoutEditorSettingsTitleView } from "./BMLayoutEditorSettingCells";
|
|
8
|
+
|
|
9
|
+
// @type BMLayoutEditorSettingsSizeCell extends BMLayoutEditorSettingsCell
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A cell type specialized for displaying `BMSize` settings.
|
|
13
|
+
*/
|
|
14
|
+
export function BMLayoutEditorSettingsSizeCell () {} // <constructor>
|
|
15
|
+
|
|
16
|
+
BMLayoutEditorSettingsSizeCell.prototype = BMExtend(Object.create(BMLayoutEditorSettingsCell.prototype), {
|
|
17
|
+
constructor: BMLayoutEditorSettingsSizeCell,
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The view that displays this setting's title.
|
|
21
|
+
*/
|
|
22
|
+
_titleView: undefined, // <BMView>
|
|
23
|
+
get titleView() {
|
|
24
|
+
return this._titleView;
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The view that displays this setting's width input node.
|
|
29
|
+
*/
|
|
30
|
+
_widthInputView: undefined, // <BMView>
|
|
31
|
+
get widthInputView() {
|
|
32
|
+
return this._widthInputView;
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The view that displays this setting's height input node.
|
|
37
|
+
*/
|
|
38
|
+
_heightInputView: undefined, // <BMView>
|
|
39
|
+
get heightInputView() {
|
|
40
|
+
return this._heightInputView;
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The view that displays this setting's bounding box indicator node.
|
|
45
|
+
*/
|
|
46
|
+
_indicator: undefined, // <BMView>
|
|
47
|
+
get indicator() {
|
|
48
|
+
return this._indicator;
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Set to `YES` while this cell is bound.
|
|
53
|
+
*/
|
|
54
|
+
_bound: NO, // <Boolean>
|
|
55
|
+
|
|
56
|
+
// @override - BMCollectionViewCell
|
|
57
|
+
prepareForReuse() {
|
|
58
|
+
this._bound = NO;
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
// @override - BMCollectionViewCell
|
|
62
|
+
prepareForDisplay() {
|
|
63
|
+
this._bound = YES;
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Constructs and returns a numeric input view.
|
|
68
|
+
* @returns <BMView> A view.
|
|
69
|
+
*/
|
|
70
|
+
_createInputView() {
|
|
71
|
+
const inputNode = document.createElement('input');
|
|
72
|
+
inputNode.className = 'BMWindowInput BMLayoutEditorDetailsCellInput BMLayoutEditorDetailsItemNumericValue';
|
|
73
|
+
inputNode.type = 'number';
|
|
74
|
+
|
|
75
|
+
const inputView = BMView.viewForNode(inputNode);
|
|
76
|
+
inputView.debuggingName = 'InputView';
|
|
77
|
+
inputView.supportsAutomaticIntrinsicSize = YES;
|
|
78
|
+
|
|
79
|
+
return inputView;
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
// @override - BMCollectionViewCell
|
|
83
|
+
initWithCollectionView(collectionView, args) {
|
|
84
|
+
BMLayoutEditorSettingsCell.prototype.initWithCollectionView.apply(this, arguments);
|
|
85
|
+
|
|
86
|
+
this._titleView = BMLayoutEditorSettingsTitleView.titleView();
|
|
87
|
+
this.contentView.addSubview(this._titleView);
|
|
88
|
+
|
|
89
|
+
this._titleView.leading.equalTo(this.contentView.leading, {plus: 8}).isActive = YES;
|
|
90
|
+
this._titleView.top.equalTo(this.contentView.top, {plus: 4}).isActive = YES;
|
|
91
|
+
|
|
92
|
+
this._indicator = BMView.view();
|
|
93
|
+
this._indicator.node.className = 'BMLayoutEditorDetailsBoxIndicator';
|
|
94
|
+
|
|
95
|
+
const widthIndicator = document.createElement('div');
|
|
96
|
+
widthIndicator.className = 'BMLayoutEditorDetailsWidthIndicator';
|
|
97
|
+
this._indicator.node.appendChild(widthIndicator);
|
|
98
|
+
|
|
99
|
+
const heightIndicator = document.createElement('div');
|
|
100
|
+
heightIndicator.className = 'BMLayoutEditorDetailsHeightIndicator';
|
|
101
|
+
this._indicator.node.appendChild(heightIndicator);
|
|
102
|
+
|
|
103
|
+
this.contentView.addSubview(this._indicator);
|
|
104
|
+
this._indicator.height.equalTo(40).isActive = YES;
|
|
105
|
+
this._indicator.width.equalTo(40).isActive = YES;
|
|
106
|
+
|
|
107
|
+
this._widthInputView = this._createInputView();
|
|
108
|
+
this.contentView.addSubview(this._widthInputView);
|
|
109
|
+
this._widthInputView.width.equalTo(64).isActive = YES;
|
|
110
|
+
this._widthInputView.node.style.textAlign = 'center';
|
|
111
|
+
|
|
112
|
+
this._heightInputView = this._createInputView();
|
|
113
|
+
this.contentView.addSubview(this._heightInputView);
|
|
114
|
+
this._heightInputView.width.equalTo(64).isActive = YES;
|
|
115
|
+
this._heightInputView.node.style.textAlign = 'right';
|
|
116
|
+
|
|
117
|
+
// Width goes below title, then box indicator below it
|
|
118
|
+
this._widthInputView.top.equalTo(this._titleView.bottom, {plus: -4}).isActive = YES;
|
|
119
|
+
this._indicator.top.equalTo(this._widthInputView.bottom, {plus: 12}).isActive = YES;
|
|
120
|
+
this._indicator.bottom.lessThanOrEqualTo(this.contentView.bottom, {plus: -4}).isActive = YES;
|
|
121
|
+
this._heightInputView.centerY.equalTo(this._indicator.centerY).isActive = YES;
|
|
122
|
+
|
|
123
|
+
// Box indicator's center X is at 50%, input boxes are placed around it
|
|
124
|
+
this._indicator.centerX.equalTo(this.contentView.centerX, {priority: 750}).isActive = YES;
|
|
125
|
+
this._indicator.leading.equalTo(this._heightInputView.trailing, {plus: 12}).isActive = YES;
|
|
126
|
+
this._widthInputView.centerX.equalTo(this._indicator.centerX).isActive = YES;
|
|
127
|
+
this.contentView.trailing.greaterThanOrEqualTo(this._indicator.trailing, {plus: 8}).isActive = YES;
|
|
128
|
+
|
|
129
|
+
[this._widthInputView, this._heightInputView].forEach(inputView => {
|
|
130
|
+
const inputNode = inputView.node;
|
|
131
|
+
|
|
132
|
+
inputNode.addEventListener('input', event => {
|
|
133
|
+
if (!this._bound) return;
|
|
134
|
+
|
|
135
|
+
this._inputValueDidChangeWithEvent(event);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
inputNode.addEventListener('paste', event => {
|
|
139
|
+
if (!this._bound) return;
|
|
140
|
+
|
|
141
|
+
this._inputValueDidChangeWithEvent(event);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
inputNode.addEventListener('focus', e => this.retain());
|
|
145
|
+
inputNode.addEventListener('blur', e => this.release());
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
return this;
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
// @override - BMCollectionViewSettingsCell
|
|
153
|
+
cellDidBindToSetting(setting) {
|
|
154
|
+
this._titleView.setting = setting;
|
|
155
|
+
|
|
156
|
+
let size;
|
|
157
|
+
if (setting.sizeClass) {
|
|
158
|
+
if (setting.target._variations[setting.sizeClass]) {
|
|
159
|
+
if (setting.property in setting.target._variations[setting.sizeClass]) {
|
|
160
|
+
setting.target._variations[setting.sizeClass][setting.property];
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
size = setting.target[setting.property];
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (size) {
|
|
169
|
+
this._widthInputView.node.value = size.width;
|
|
170
|
+
this._heightInputView.node.value = size.height;
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
this._widthInputView.node.value = '';
|
|
174
|
+
this._heightInputView.node.value = '';
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Invoked when the value of either the width or height inputs changes.
|
|
180
|
+
* @param event <UIEvent> The event that triggered this action.
|
|
181
|
+
*/
|
|
182
|
+
_inputValueDidChangeWithEvent(event) {
|
|
183
|
+
const setting = this.setting;
|
|
184
|
+
|
|
185
|
+
const width = parseInt(this._widthInputView.node.value, 10);
|
|
186
|
+
const height = parseInt(this._heightInputView.node.value, 10);
|
|
187
|
+
|
|
188
|
+
let size = !isNaN(width) && !isNaN(height) ? BMSizeMake(width, height) : undefined;
|
|
189
|
+
|
|
190
|
+
// If the property is non-nullable default to [0, 0]
|
|
191
|
+
if (!setting.nullable && !size) {
|
|
192
|
+
size = BMSizeMake();
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
this.layoutEditor.setValue(size, {forSetting: setting});
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
// @endtype
|
|
202
|
+
|
|
203
|
+
// @type BMLayoutEditorSettingInsetCell extends BMLayoutEditorSettingsCell
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* A cell type specialized for displaying `BMInset` settings.
|
|
207
|
+
*/
|
|
208
|
+
export function BMLayoutEditorSettingsInsetCell () {} // <constructor>
|
|
209
|
+
|
|
210
|
+
BMLayoutEditorSettingsInsetCell.prototype = BMExtend(Object.create(BMLayoutEditorSettingsCell.prototype), {
|
|
211
|
+
constructor: BMLayoutEditorSettingsInsetCell,
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* The view that displays this setting's title.
|
|
215
|
+
*/
|
|
216
|
+
_titleView: undefined, // <BMView>
|
|
217
|
+
get titleView() {
|
|
218
|
+
return this._titleView;
|
|
219
|
+
},
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* The view that displays this setting's left input node.
|
|
223
|
+
*/
|
|
224
|
+
_leftInputView: undefined, // <BMView>
|
|
225
|
+
get leftInputView() {
|
|
226
|
+
return this._leftInputView;
|
|
227
|
+
},
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* The view that displays this setting's top input node.
|
|
231
|
+
*/
|
|
232
|
+
_topInputView: undefined, // <BMView>
|
|
233
|
+
get heightInputView() {
|
|
234
|
+
return this._topInputView;
|
|
235
|
+
},
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* The view that displays this setting's left input node.
|
|
239
|
+
*/
|
|
240
|
+
_rightInputView: undefined, // <BMView>
|
|
241
|
+
get rightInputView() {
|
|
242
|
+
return this._rightInputView;
|
|
243
|
+
},
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* The view that displays this setting's top input node.
|
|
247
|
+
*/
|
|
248
|
+
_bottomInputView: undefined, // <BMView>
|
|
249
|
+
get bottomInputView() {
|
|
250
|
+
return this._bottomInputView;
|
|
251
|
+
},
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* The view that displays this setting's bounding box indicator node.
|
|
255
|
+
*/
|
|
256
|
+
_indicator: undefined, // <BMView>
|
|
257
|
+
get indicator() {
|
|
258
|
+
return this._indicator;
|
|
259
|
+
},
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Set to `YES` while this cell is bound.
|
|
263
|
+
*/
|
|
264
|
+
_bound: NO, // <Boolean>
|
|
265
|
+
|
|
266
|
+
// @override - BMCollectionViewCell
|
|
267
|
+
prepareForReuse() {
|
|
268
|
+
this._bound = NO;
|
|
269
|
+
},
|
|
270
|
+
|
|
271
|
+
// @override - BMCollectionViewCell
|
|
272
|
+
prepareForDisplay() {
|
|
273
|
+
this._bound = YES;
|
|
274
|
+
},
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Constructs and returns a numeric input view.
|
|
278
|
+
* @returns <BMView> A view.
|
|
279
|
+
*/
|
|
280
|
+
_createInputView() {
|
|
281
|
+
const inputNode = document.createElement('input');
|
|
282
|
+
inputNode.className = 'BMWindowInput BMLayoutEditorDetailsCellInput BMLayoutEditorDetailsItemNumericValue';
|
|
283
|
+
inputNode.type = 'number';
|
|
284
|
+
|
|
285
|
+
const inputView = BMView.viewForNode(inputNode);
|
|
286
|
+
inputView.debuggingName = 'InputView';
|
|
287
|
+
inputView.supportsAutomaticIntrinsicSize = YES;
|
|
288
|
+
|
|
289
|
+
return inputView;
|
|
290
|
+
},
|
|
291
|
+
|
|
292
|
+
// @override - BMCollectionViewCell
|
|
293
|
+
initWithCollectionView(collectionView, args) {
|
|
294
|
+
BMLayoutEditorSettingsCell.prototype.initWithCollectionView.apply(this, arguments);
|
|
295
|
+
|
|
296
|
+
this._titleView = BMLayoutEditorSettingsTitleView.titleView();
|
|
297
|
+
this.contentView.addSubview(this._titleView);
|
|
298
|
+
|
|
299
|
+
this._titleView.leading.equalTo(this.contentView.leading, {plus: 8}).isActive = YES;
|
|
300
|
+
this._titleView.top.equalTo(this.contentView.top, {plus: 4}).isActive = YES;
|
|
301
|
+
|
|
302
|
+
this._indicator = BMView.view();
|
|
303
|
+
this._indicator.node.className = 'BMLayoutEditorDetailsBoxIndicator';
|
|
304
|
+
|
|
305
|
+
const topLeftIndicator = document.createElement('div');
|
|
306
|
+
topLeftIndicator.className = 'BMLayoutEditorDetailsInsetTopLeftIndicator';
|
|
307
|
+
this._indicator.node.appendChild(topLeftIndicator);
|
|
308
|
+
|
|
309
|
+
const bottomRightIndicator = document.createElement('div');
|
|
310
|
+
bottomRightIndicator.className = 'BMLayoutEditorDetailsInsetBottomRightIndicator';
|
|
311
|
+
this._indicator.node.appendChild(bottomRightIndicator);
|
|
312
|
+
|
|
313
|
+
this.contentView.addSubview(this._indicator);
|
|
314
|
+
this._indicator.height.equalTo(48).isActive = YES;
|
|
315
|
+
this._indicator.width.equalTo(48).isActive = YES;
|
|
316
|
+
|
|
317
|
+
this._leftInputView = this._createInputView();
|
|
318
|
+
this.contentView.addSubview(this._leftInputView);
|
|
319
|
+
this._leftInputView.width.equalTo(64).isActive = YES;
|
|
320
|
+
this._leftInputView.node.style.textAlign = 'right';
|
|
321
|
+
|
|
322
|
+
this._topInputView = this._createInputView();
|
|
323
|
+
this.contentView.addSubview(this._topInputView);
|
|
324
|
+
this._topInputView.width.equalTo(64).isActive = YES;
|
|
325
|
+
this._topInputView.node.style.textAlign = 'center';
|
|
326
|
+
|
|
327
|
+
this._rightInputView = this._createInputView();
|
|
328
|
+
this.contentView.addSubview(this._rightInputView);
|
|
329
|
+
this._rightInputView.width.equalTo(64).isActive = YES;
|
|
330
|
+
|
|
331
|
+
this._bottomInputView = this._createInputView();
|
|
332
|
+
this.contentView.addSubview(this._bottomInputView);
|
|
333
|
+
this._bottomInputView.width.equalTo(64).isActive = YES;
|
|
334
|
+
this._bottomInputView.node.style.textAlign = 'center';
|
|
335
|
+
|
|
336
|
+
// Top goes below title, then box indicator below it, then bottom below it
|
|
337
|
+
this._topInputView.top.equalTo(this._titleView.bottom, {plus: -4}).isActive = YES;
|
|
338
|
+
this._indicator.top.equalTo(this._topInputView.bottom, {plus: 4}).isActive = YES;
|
|
339
|
+
this._bottomInputView.top.equalTo(this._indicator.bottom, {plus: 4}).isActive = YES;
|
|
340
|
+
this._bottomInputView.bottom.lessThanOrEqualTo(this.contentView.bottom, {plus: -4}).isActive = YES;
|
|
341
|
+
this._leftInputView.centerY.equalTo(this._indicator.centerY).isActive = YES;
|
|
342
|
+
this._rightInputView.centerY.equalTo(this._indicator.centerY).isActive = YES;
|
|
343
|
+
|
|
344
|
+
// Box indicator's center X is at 50%, input boxes are placed around it
|
|
345
|
+
this._indicator.centerX.equalTo(this.contentView.centerX, {priority: 750}).isActive = YES;
|
|
346
|
+
this._indicator.leading.equalTo(this._leftInputView.trailing, {plus: 4}).isActive = YES;
|
|
347
|
+
this._rightInputView.leading.equalTo(this._indicator.trailing, {plus: 4}).isActive = YES;
|
|
348
|
+
this._topInputView.centerX.equalTo(this._indicator.centerX).isActive = YES;
|
|
349
|
+
this._bottomInputView.centerX.equalTo(this._indicator.centerX).isActive = YES;
|
|
350
|
+
this._topInputView.centerX.equalTo(this._indicator.centerX).isActive = YES;
|
|
351
|
+
this.contentView.trailing.greaterThanOrEqualTo(this._rightInputView.trailing, {plus: 8}).isActive = YES;
|
|
352
|
+
|
|
353
|
+
[this._leftInputView, this._topInputView, this._rightInputView, this._bottomInputView].forEach(inputView => {
|
|
354
|
+
const inputNode = inputView.node;
|
|
355
|
+
|
|
356
|
+
inputNode.addEventListener('input', event => {
|
|
357
|
+
if (!this._bound) return;
|
|
358
|
+
|
|
359
|
+
this._inputValueDidChangeWithEvent(event);
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
inputNode.addEventListener('paste', event => {
|
|
363
|
+
if (!this._bound) return;
|
|
364
|
+
|
|
365
|
+
this._inputValueDidChangeWithEvent(event);
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
inputNode.addEventListener('focus', e => this.retain());
|
|
369
|
+
inputNode.addEventListener('blur', e => this.release());
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
return this;
|
|
374
|
+
},
|
|
375
|
+
|
|
376
|
+
// @override - BMCollectionViewSettingsCell
|
|
377
|
+
cellDidBindToSetting(setting) {
|
|
378
|
+
this._titleView.setting = setting;
|
|
379
|
+
|
|
380
|
+
let inset;
|
|
381
|
+
if (setting.sizeClass) {
|
|
382
|
+
if (setting.target._variations[setting.sizeClass]) {
|
|
383
|
+
if (setting.property in setting.target._variations[setting.sizeClass]) {
|
|
384
|
+
setting.target._variations[setting.sizeClass][setting.property];
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
inset = setting.target[setting.property];
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
if (inset) {
|
|
393
|
+
this._leftInputView.node.value = inset.left;
|
|
394
|
+
this._topInputView.node.value = inset.top;
|
|
395
|
+
this._rightInputView.node.value = inset.right;
|
|
396
|
+
this._bottomInputView.node.value = inset.bottom;
|
|
397
|
+
}
|
|
398
|
+
else {
|
|
399
|
+
this._leftInputView.node.value = '';
|
|
400
|
+
this._topInputView.node.value = '';
|
|
401
|
+
this._rightInputView.node.value = '';
|
|
402
|
+
this._bottomInputView.node.value = '';
|
|
403
|
+
}
|
|
404
|
+
},
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Invoked when the value of either the width or height inputs changes.
|
|
408
|
+
* @param event <UIEvent> The event that triggered this action.
|
|
409
|
+
*/
|
|
410
|
+
_inputValueDidChangeWithEvent(event) {
|
|
411
|
+
const setting = this.setting;
|
|
412
|
+
|
|
413
|
+
const left = parseInt(this._leftInputView.node.value, 10);
|
|
414
|
+
const top = parseInt(this._topInputView.node.value, 10);
|
|
415
|
+
const right = parseInt(this._rightInputView.node.value, 10);
|
|
416
|
+
const bottom = parseInt(this._bottomInputView.node.value, 10);
|
|
417
|
+
|
|
418
|
+
let inset = !isNaN(left) && !isNaN(top) && !isNaN(right) && !isNaN(bottom) ? BMInsetMake(left, top, right, bottom) : undefined;
|
|
419
|
+
|
|
420
|
+
// If the property is non-nullable default to [0, 0]
|
|
421
|
+
if (!setting.nullable && !inset) {
|
|
422
|
+
inset = BMInsetMake();
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
this.layoutEditor.setValue(inset, {forSetting: setting});
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
// @endtype
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// @type interface BMLayoutEditorSettingsDelegate
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The specification for a `BMLayoutEditorSettingsDelegate` object, which is used to provide information to the layout editor regarding the variation status of
|
|
5
|
+
* settings and implements the behvaiour for when settings are changed.
|
|
6
|
+
*
|
|
7
|
+
* The `BMView` and `BMLayoutConstraint` classes implement this interface for standard settings. View subclasses can override these methods and provide
|
|
8
|
+
* additional settings and behaviours for them. Whenever these methods are overridden, the subclasses should invoke the superclass implementation to allow
|
|
9
|
+
* the correct handling of standard settings.
|
|
10
|
+
*
|
|
11
|
+
* All of the methods defined in this protocol are required; omitting any method will lead to a runtime error when the layout editor
|
|
12
|
+
* attempts to invoke it on the delegate object.
|
|
13
|
+
*/
|
|
14
|
+
function BMLayoutEditorSettingsDelegate() {} // <constructor>
|
|
15
|
+
|
|
16
|
+
BMLayoutEditorSettingsDelegate.prototype = {
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Invoked by the layout editor to determine which variations are currently active for the
|
|
20
|
+
* setting given as a parameter.
|
|
21
|
+
* @param editor <BMLayoutEditor> The layout editor invoking this method.
|
|
22
|
+
* @param setting <BMLayoutEditorSetting> The setting for which to retrieve variations.
|
|
23
|
+
* @return <[BMLayoutVariation]> An array of active variations.
|
|
24
|
+
*/
|
|
25
|
+
layoutEditorActiveVariationsForSetting(editor, setting) {
|
|
26
|
+
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Invoked by the layout editor when the value for a setting changes. If the value that changed
|
|
31
|
+
* is specific to a size class, that size class will be given as a parameter.
|
|
32
|
+
* @param editor <BMLayoutEditor> The layout editor invoking this method.
|
|
33
|
+
* @param value <AnyObject> The new value of the setting.
|
|
34
|
+
* {
|
|
35
|
+
* @param setting <BMLayoutEditorSetting> The setting that was changed.
|
|
36
|
+
* @param forSizeClass <BMLayoutSizeClass, nullable> If specified, this indicates that the new value applies to a certain size class.
|
|
37
|
+
* In this case, the value of this parameter indicates the size class to which the new value applies.
|
|
38
|
+
* }
|
|
39
|
+
*/
|
|
40
|
+
layoutEditorSettingValueDidChange(value, {setting, forSizeClass}) {
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// @endtype
|