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,417 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import {YES, NO, BMExtend} from '../Core/BMCoreUI'
|
|
3
|
+
import {__BMVelocityAnimate} from '../Core/BMAnimationContext'
|
|
4
|
+
import {BMLayoutAttribute, BMLayoutConstraintKind, BMLayoutConstraintRelation} from '../BMView/BMLayoutConstraint_v2.5'
|
|
5
|
+
import {BMMenuItem} from '../BMView/BMMenu'
|
|
6
|
+
import { _BMLayoutEditorCollectionSettingsPanel, BMLayoutEditorSettingsTab, _BMLayoutEditorSettingsPanel, _BMURLOfImageAtPath, BMLayoutEditorSettingKind, BMLayoutEditorSettingsSection, BMLayoutEditorSetting, BMLayoutEditorEnumSetting } from './BMLayoutEditorSettings'
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
// @type _BMLayoutEditorConstraintSettingsPanel
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A class that controls the settings for a view.
|
|
13
|
+
*/
|
|
14
|
+
export function _BMLayoutEditorConstraintSettingsPanel() {} // <constructor>
|
|
15
|
+
|
|
16
|
+
_BMLayoutEditorConstraintSettingsPanel.prototype = BMExtend(Object.create(_BMLayoutEditorCollectionSettingsPanel.prototype), {
|
|
17
|
+
constructor: _BMLayoutEditorConstraintSettingsPanel,
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The view whose settings are displayed.
|
|
21
|
+
*/
|
|
22
|
+
_displayedConstraint: undefined, // <BMLayoutConstraint>
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The view from which this constraint settings panel was opened.
|
|
26
|
+
*/
|
|
27
|
+
_referenceView: undefined, // <BMView>
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The visual attributes tab.
|
|
31
|
+
*/
|
|
32
|
+
_attributesTab: undefined, // <BMLayoutEditorSettingsTab>
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Designated initializer. Initializes this settings panel with the given settings view.
|
|
36
|
+
* @param view <_BMLayoutSettingsView> The settings view.
|
|
37
|
+
* @return <_BMLayoutEditorSettingsPanel> This setttings panel.
|
|
38
|
+
*/
|
|
39
|
+
initWithSettingsView(settingsView, {forConstraint: constraint, withReferenceView: view}) {
|
|
40
|
+
_BMLayoutEditorSettingsPanel.prototype.initWithSettingsView.call(this, settingsView);
|
|
41
|
+
|
|
42
|
+
this._displayedConstraint = constraint;
|
|
43
|
+
this._referenceView = view;
|
|
44
|
+
|
|
45
|
+
// Create the default tabs
|
|
46
|
+
this._attributesTab = BMLayoutEditorSettingsTab.tabWithName('Attributes', {icon: _BMURLOfImageAtPath('images/Properties.png')});
|
|
47
|
+
this._attributesTab._settingsPanel = this;
|
|
48
|
+
|
|
49
|
+
this._currentTab = this._attributesTab;
|
|
50
|
+
|
|
51
|
+
this._tabs = [this._attributesTab];
|
|
52
|
+
|
|
53
|
+
this.title = 'Constraint';
|
|
54
|
+
|
|
55
|
+
if (this.layoutEditor.delegate && this.layoutEditor.delegate.layoutEditorAdditionalSettingTabsForConstraint) {
|
|
56
|
+
const additionalTabs = this.layoutEditor.delegate.layoutEditorAdditionalSettingTabsForConstraint(this.layoutEditor, constraint);
|
|
57
|
+
this._tabs = this._tabs.concat(additionalTabs);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
for (const tab of this._tabs) {
|
|
61
|
+
tab._settingsPanel = this;
|
|
62
|
+
tab._constraint = constraint;
|
|
63
|
+
tab.updateSettings();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// TODO: Custom tabs
|
|
67
|
+
|
|
68
|
+
return this;
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Invoked by tabs when their settings have been invalidated and should be updated.
|
|
74
|
+
* @param tab <BMLayoutEditorSettingsTab> The tab whose settings have been invalidated.
|
|
75
|
+
*/
|
|
76
|
+
_updateSettingsForTab(tab) {
|
|
77
|
+
if (tab == this._attributesTab) {
|
|
78
|
+
tab._settingSections.length = 0;
|
|
79
|
+
|
|
80
|
+
const constraint = this._displayedConstraint;
|
|
81
|
+
|
|
82
|
+
// Prepare the menu options
|
|
83
|
+
const attributeOptions = [];
|
|
84
|
+
if (!constraint.isConstraintCollection) if (constraint._kind == BMLayoutConstraintKind.Horizontal) {
|
|
85
|
+
if (constraint._sourceViewAttribute === BMLayoutAttribute.Width) {
|
|
86
|
+
attributeOptions.push(BMMenuItem.menuItemWithName(constraint._sourceViewAttribute, {userInfo: constraint._sourceViewAttribute}));
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
attributeOptions.push(BMMenuItem.menuItemWithName(BMLayoutAttribute.Leading, {userInfo: BMLayoutAttribute.Leading}));
|
|
90
|
+
attributeOptions.push(BMMenuItem.menuItemWithName(BMLayoutAttribute.CenterX, {userInfo: BMLayoutAttribute.CenterX}));
|
|
91
|
+
attributeOptions.push(BMMenuItem.menuItemWithName(BMLayoutAttribute.Trailing, {userInfo: BMLayoutAttribute.Trailing}));
|
|
92
|
+
attributeOptions.push(BMMenuItem.menuItemWithName(BMLayoutAttribute.Left, {userInfo: BMLayoutAttribute.Left}));
|
|
93
|
+
attributeOptions.push(BMMenuItem.menuItemWithName(BMLayoutAttribute.Right, {userInfo: BMLayoutAttribute.Right}));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
if (constraint._sourceViewAttribute === BMLayoutAttribute.Height) {
|
|
98
|
+
attributeOptions.push(BMMenuItem.menuItemWithName(constraint._sourceViewAttribute, {userInfo: constraint._sourceViewAttribute}));
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
attributeOptions.push(BMMenuItem.menuItemWithName(BMLayoutAttribute.Top, {userInfo: BMLayoutAttribute.Top}));
|
|
102
|
+
attributeOptions.push(BMMenuItem.menuItemWithName(BMLayoutAttribute.CenterY, {userInfo: BMLayoutAttribute.CenterY}));
|
|
103
|
+
attributeOptions.push(BMMenuItem.menuItemWithName(BMLayoutAttribute.Bottom, {userInfo: BMLayoutAttribute.Bottom}));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (constraint.isConstraintCollection) {
|
|
108
|
+
if (constraint._hasEditableConstant) {
|
|
109
|
+
const constant = BMLayoutEditorSettingsSection.section();
|
|
110
|
+
constant._settings[0] = BMLayoutEditorSetting.settingWithName('Constant', {kind: BMLayoutEditorSettingKind.Constant, target: constraint, variations: YES, property: 'constant'});
|
|
111
|
+
constant._settings[0].automaticallyExpandsVariations = YES;
|
|
112
|
+
this._attributesTab._settingSections.push(constant);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const affectedViews = BMLayoutEditorSettingsSection.section();
|
|
116
|
+
affectedViews.title = 'Affected Views';
|
|
117
|
+
let index = 1;
|
|
118
|
+
for (const view of constraint._views) {
|
|
119
|
+
affectedViews._settings.push(BMLayoutEditorSetting.settingWithName('View ' + index, {kind: BMLayoutEditorSettingKind.View, target: constraint._views, property: index - 1}));
|
|
120
|
+
index++;
|
|
121
|
+
}
|
|
122
|
+
this._attributesTab._settingSections.push(affectedViews);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
const firstView = BMLayoutEditorSettingsSection.section();
|
|
126
|
+
firstView._settings[0] = BMLayoutEditorSetting.settingWithName('First View', {kind: BMLayoutEditorSettingKind.View, target: constraint, property: '_sourceView'});
|
|
127
|
+
firstView._settings[1] = BMLayoutEditorEnumSetting.settingWithName('Attribute', {kind: BMLayoutEditorSettingKind.Enum, target: constraint, property: '_sourceViewAttribute'});
|
|
128
|
+
firstView._settings[1].options = attributeOptions;
|
|
129
|
+
this._attributesTab._settingSections.push(firstView);
|
|
130
|
+
|
|
131
|
+
const relation = BMLayoutEditorSettingsSection.section();
|
|
132
|
+
relation._settings[0] = BMLayoutEditorEnumSetting.settingWithName('Relation', {kind: BMLayoutEditorSettingKind.Enum, target: constraint, property: '_relation'});
|
|
133
|
+
relation._settings[0].options = [
|
|
134
|
+
BMMenuItem.menuItemWithName('=', {userInfo: BMLayoutConstraintRelation.Equals}),
|
|
135
|
+
BMMenuItem.menuItemWithName('\u2265', {userInfo: BMLayoutConstraintRelation.GreaterThanOrEquals}),
|
|
136
|
+
BMMenuItem.menuItemWithName('\u2264', {userInfo: BMLayoutConstraintRelation.LessThanOrEquals})
|
|
137
|
+
];
|
|
138
|
+
this._attributesTab._settingSections.push(relation);
|
|
139
|
+
|
|
140
|
+
const secondView = BMLayoutEditorSettingsSection.section();
|
|
141
|
+
if (constraint._targetView) {
|
|
142
|
+
secondView._settings[0] = BMLayoutEditorSetting.settingWithName('Multiplier', {kind: BMLayoutEditorSettingKind.Number, target: constraint, property: '_multiplier'});
|
|
143
|
+
secondView._settings[1] = BMLayoutEditorSetting.settingWithName('Second View', {kind: BMLayoutEditorSettingKind.View, target: constraint, property: '_targetView'});
|
|
144
|
+
secondView._settings[2] = BMLayoutEditorEnumSetting.settingWithName('Attribute', {kind: BMLayoutEditorSettingKind.Enum, target: constraint, property: '_targetViewAttribute'});
|
|
145
|
+
secondView._settings[2].options = attributeOptions;
|
|
146
|
+
}
|
|
147
|
+
let constantSetting;
|
|
148
|
+
secondView._settings[secondView._settings.length] = constantSetting = BMLayoutEditorSetting.settingWithName('Constant', {kind: BMLayoutEditorSettingKind.Constant, target: constraint, variations: YES, property: 'constant'});
|
|
149
|
+
constantSetting.automaticallyExpandsVariations = YES;
|
|
150
|
+
this._attributesTab._settingSections.push(secondView);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const priority = BMLayoutEditorSettingsSection.section();
|
|
154
|
+
priority._settings[0] = BMLayoutEditorSetting.settingWithName('Priority', {kind: BMLayoutEditorSettingKind.Number, target: constraint, variations: YES, property: 'priority'});
|
|
155
|
+
priority._settings[1] = BMLayoutEditorSetting.settingWithName('Active', {kind: BMLayoutEditorSettingKind.Boolean, target: constraint, variations: YES, property: 'isActive'});
|
|
156
|
+
priority._settings[1].automaticallyExpandsVariations = YES;
|
|
157
|
+
this._attributesTab._settingSections.push(priority);
|
|
158
|
+
|
|
159
|
+
if (this.layoutEditor.delegate && this.layoutEditor.delegate.layoutEditorAdditionalSettingSectionsForTab) {
|
|
160
|
+
for (const section of this.layoutEditor.delegate.layoutEditorAdditionalSettingSectionsForTab(this.layoutEditor, tab)) {
|
|
161
|
+
tab._settingSections.push(section);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const deleteSection = BMLayoutEditorSettingsSection.section();
|
|
166
|
+
deleteSection._settings[0] = BMLayoutEditorSetting.settingWithName('Delete', {kind: BMLayoutEditorSettingKind.DeleteConstraintButton, target: constraint, variations: NO});
|
|
167
|
+
this._attributesTab._settingSections.push(deleteSection);
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
tab._settingSections.length = 0;
|
|
171
|
+
|
|
172
|
+
if (this.layoutEditor.delegate && this.layoutEditor.delegate.layoutEditorAdditionalSettingSectionsForTab) {
|
|
173
|
+
for (const section of this.layoutEditor.delegate.layoutEditorAdditionalSettingSectionsForTab(this.layoutEditor, tab)) {
|
|
174
|
+
tab._settingSections.push(section);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
// @override - BMLayoutEditorSettingsPanel
|
|
181
|
+
async settingsPanelWillAppear(animated) {
|
|
182
|
+
this.layoutEditor.selectConstraint(this._displayedConstraint, {withReferenceView: this._referenceView});
|
|
183
|
+
|
|
184
|
+
await 0;
|
|
185
|
+
|
|
186
|
+
// Focus the relevant constraint box
|
|
187
|
+
const setting = BMLayoutEditorSetting.settingWithName('Constant', {kind: BMLayoutEditorSettingKind.Constant, target: this._displayedConstraint, variations: YES, property: 'constant'});
|
|
188
|
+
setting._sizeClass = this.layoutEditor.activeSizeClass;
|
|
189
|
+
|
|
190
|
+
const indexPath = this._attributesTab.indexPathForObject(setting);
|
|
191
|
+
const cell = indexPath && this._attributesTab._collectionView.cellAtIndexPath(indexPath);
|
|
192
|
+
if (cell) {
|
|
193
|
+
cell._delaysSuggestionsDropdown = YES;
|
|
194
|
+
cell._inputView.node.focus();
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
|
|
198
|
+
// @override - BMLayoutEditorSettingsPanel
|
|
199
|
+
settingsPanelDidAppear(animated) {
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
// @override - BMLayoutEditorSettingsPanel
|
|
203
|
+
settingsPanelWillDisappear(animated) {
|
|
204
|
+
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
// @override - BMLayoutEditorSettingsPanel
|
|
208
|
+
settingsPanelDidDisappear(animated) {
|
|
209
|
+
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
// @endtype
|
|
214
|
+
|
|
215
|
+
// @type _BMLayoutEditorConstraintSettingsTab
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* A specialized settings tab used for displaying view layout settings.
|
|
219
|
+
*/
|
|
220
|
+
function _BMLayoutEditorConstraintSettingsTab() {} // <constructor>
|
|
221
|
+
|
|
222
|
+
_BMLayoutEditorConstraintSettingsTab.prototype = BMExtend(Object.create(BMLayoutEditorSettingsTab.prototype), {
|
|
223
|
+
constructor: _BMLayoutEditorConstraintSettingsTab,
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* The view whose constraints are displayed.
|
|
227
|
+
*/
|
|
228
|
+
_displayedView: undefined, // <BMView>
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Controls whether subview constraints are displayed.
|
|
232
|
+
*/
|
|
233
|
+
_showsSubviewConstraints: NO, // <Boolean>
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* The categories of the view's own constraints.
|
|
237
|
+
*/
|
|
238
|
+
_constraintCategories: undefined, // <Object<String, [BMLayoutConstraint]>
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Initializes this view layout tab for the specified view.
|
|
242
|
+
* @param view <BMView> The view whose constraints will be displayed.
|
|
243
|
+
*/
|
|
244
|
+
initWithView(view) {
|
|
245
|
+
BMLayoutEditorSettingsTab.prototype.initWithName.call(this, 'Layout', {icon: _BMURLOfImageAtPath('images/Layout.png')});
|
|
246
|
+
|
|
247
|
+
return this;
|
|
248
|
+
},
|
|
249
|
+
|
|
250
|
+
updateSettings() {
|
|
251
|
+
this._updateSettings();
|
|
252
|
+
},
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Updates the visible constraints.
|
|
256
|
+
* If this tab is visible, it also updates the displayed constraints.
|
|
257
|
+
*/
|
|
258
|
+
_updateSettings() {
|
|
259
|
+
const view = this._displayedView;
|
|
260
|
+
|
|
261
|
+
this.beginUpdates();
|
|
262
|
+
|
|
263
|
+
this._settingSections.length = 0;
|
|
264
|
+
|
|
265
|
+
if (this._intrinsicResistanceSection) {
|
|
266
|
+
this._settingSections.push(this._intrinsicResistanceSection);
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
const intrinsicResistanceSection = BMLayoutEditorSettingsSection.section();
|
|
270
|
+
this._intrinsicResistanceSection = intrinsicResistanceSection;
|
|
271
|
+
intrinsicResistanceSection._settings[0] = BMLayoutEditorSetting.settingWithName('Compression Resistance', {kind: BMLayoutEditorSettingKind.Integer, target: view, property: 'compressionResistance'});
|
|
272
|
+
intrinsicResistanceSection._settings[1] = BMLayoutEditorSetting.settingWithName('Expansion Resistance', {kind: BMLayoutEditorSettingKind.Integer, target: view, property: 'expansionResistance'});
|
|
273
|
+
this._settingSections.push(intrinsicResistanceSection);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if (this._intrinsicSizeSection) {
|
|
277
|
+
this._settingSections.push(this._intrinsicSizeSection);
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
const intrinsicSizeSection = BMLayoutEditorSettingsSection.section();
|
|
281
|
+
this._intrinsicSizeSection = intrinsicSizeSection;
|
|
282
|
+
intrinsicSizeSection._settings[0] = BMLayoutEditorSetting.settingWithName('Intrinsic Size', {kind: BMLayoutEditorSettingKind.Info, target: view, property: 'supportsIntrinsicSize'});
|
|
283
|
+
this._settingSections.push(intrinsicSizeSection);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
const constraintViewPicker = this._constraintViewPickerSection || BMLayoutEditorSettingsSection.section();
|
|
287
|
+
this._constraintViewPickerSection = constraintViewPicker;
|
|
288
|
+
constraintViewPicker.name = 'Show';
|
|
289
|
+
constraintViewPicker._settings[0] = BMLayoutEditorEnumSetting.settingWithName('Show', {kind: BMLayoutEditorSettingKind.Segment, target: this, property: '_displayMode'});
|
|
290
|
+
constraintViewPicker._settings[0].options = [
|
|
291
|
+
BMMenuItem.menuItemWithName('Own Constraints', {icon: _BMURLOfImageAtPath('images/OwnConstraints.png'), userInfo: 'own'}),
|
|
292
|
+
BMMenuItem.menuItemWithName('Subview Constraints', {icon: _BMURLOfImageAtPath('images/SubviewConstraints.png'), userInfo: 'subview'}),
|
|
293
|
+
BMMenuItem.menuItemWithName('Inactive Constraints', {icon: _BMURLOfImageAtPath('images/InactiveConstraints.png'), userInfo: 'inactive'}),
|
|
294
|
+
BMMenuItem.menuItemWithName('All Constraints', {icon: _BMURLOfImageAtPath('images/AllConstraints.png'), userInfo: 'all'})
|
|
295
|
+
];
|
|
296
|
+
this._settingSections.push(constraintViewPicker);
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
// View constraints will be split into four groups:
|
|
300
|
+
//
|
|
301
|
+
// 1. Visible by default and non-collapsible will be the constraints that directly affect the view,
|
|
302
|
+
// or link the view to its siblings or ancestors
|
|
303
|
+
//
|
|
304
|
+
// 2. A second, collapsed by default group, will show the constraints that link the view to its descendants
|
|
305
|
+
//
|
|
306
|
+
// 3. A third, collapsed by default group, will show the inactive constraints
|
|
307
|
+
//
|
|
308
|
+
// 4. A final group shows the view's internal constraints in a read-only mode
|
|
309
|
+
let constraintCategoryMap = {};
|
|
310
|
+
let subviewConstraintCategoryMap = {};
|
|
311
|
+
let inactiveConstraintsMap = {};
|
|
312
|
+
let hasSubviewConstraints = NO;
|
|
313
|
+
let hasInactiveConstraints = NO;
|
|
314
|
+
|
|
315
|
+
// Split up the constraints into the various categories
|
|
316
|
+
view.localConstraints.forEach(constraint => {
|
|
317
|
+
let category = constraint.categoryKind;
|
|
318
|
+
|
|
319
|
+
if (!constraint._configuration.isActive) {
|
|
320
|
+
hasInactiveConstraints = YES;
|
|
321
|
+
inactiveConstraintsMap[category] = inactiveConstraintsMap[category] || [];
|
|
322
|
+
inactiveConstraintsMap[category].push(constraint);
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if (!constraint.isConstraintCollection) {
|
|
327
|
+
// Push subview constraints into their own categories
|
|
328
|
+
if (constraint._sourceView == view && constraint._targetView && constraint._targetView.isDescendantOfView(view)) {
|
|
329
|
+
subviewConstraintCategoryMap[category] = subviewConstraintCategoryMap[category] || [];
|
|
330
|
+
subviewConstraintCategoryMap[category].push(constraint);
|
|
331
|
+
hasSubviewConstraints = YES;
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
if (constraint._targetView == view && constraint._sourceView.isDescendantOfView(view)) {
|
|
335
|
+
subviewConstraintCategoryMap[category] = subviewConstraintCategoryMap[category] || [];
|
|
336
|
+
subviewConstraintCategoryMap[category].push(constraint);
|
|
337
|
+
hasSubviewConstraints = YES;
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
constraintCategoryMap[category] = constraintCategoryMap[category] || [];
|
|
343
|
+
constraintCategoryMap[category].push(constraint);
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
for (const category of Object.keys(constraintCategoryMap).sort()) {
|
|
347
|
+
const section = this[`_${category}`] || BMLayoutEditorSettingsSection.section();
|
|
348
|
+
this[`_${category}`] = section;
|
|
349
|
+
section.length = 0;
|
|
350
|
+
section.name = category + ' Constraints';
|
|
351
|
+
section._settings = constraintCategoryMap[category].map(constraint => BMLayoutEditorSetting.settingWithName(constraint.toString(), {kind: BMLayoutEditorSettingKind.Constraint, target: constraint}));
|
|
352
|
+
|
|
353
|
+
this._settingSections.push(section);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
this._constraintCategories = constraintCategoryMap;
|
|
357
|
+
|
|
358
|
+
//---------------------------------------------------------------------------------------------------------
|
|
359
|
+
if (hasSubviewConstraints && this._showsSubviewConstraints) {
|
|
360
|
+
for (const category of Object.keys(subviewConstraintCategoryMap).sort()) {
|
|
361
|
+
const categoryName = '_subview' + category;
|
|
362
|
+
const section = this[categoryName] || BMLayoutEditorSettingsSection.section();
|
|
363
|
+
this[categoryName] = section;
|
|
364
|
+
section.length = 0;
|
|
365
|
+
section.name = 'Subview ' + category + ' Constraints';
|
|
366
|
+
section._settings = subviewConstraintCategoryMap[category].map(constraint => BMLayoutEditorSetting.settingWithName(constraint.toString(), {kind: BMLayoutEditorSettingKind.Constraint, target: constraint}));
|
|
367
|
+
|
|
368
|
+
this._settingSections.push(section);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
//---------------------------------------------------------------------------------------------------------
|
|
373
|
+
if (hasInactiveConstraints && this._showsInactiveConstraints) {
|
|
374
|
+
for (const category of Object.keys(inactiveConstraintsMap).sort()) {
|
|
375
|
+
const categoryName = '_inactive' + category;
|
|
376
|
+
const section = this[category] || BMLayoutEditorSettingsSection.section();
|
|
377
|
+
this[category] = section;
|
|
378
|
+
section.length = 0;
|
|
379
|
+
section.name = 'Inactive ' + category + ' Constraints';
|
|
380
|
+
section._settings = inactiveConstraintsMap[category].map(constraint => BMLayoutEditorSetting.settingWithName(constraint.toString(), {kind: BMLayoutEditorSettingKind.Constraint, target: constraint}));
|
|
381
|
+
|
|
382
|
+
this._settingSections.push(section);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
//---------------------------------------------------------------------------------------------------------
|
|
387
|
+
let internalConstraints = view.internalConstraints();
|
|
388
|
+
if (internalConstraints.length) {
|
|
389
|
+
const section = this._internalConstraintsSection || BMLayoutEditorSettingsSection.section();
|
|
390
|
+
this._internalConstraintsSection = section;
|
|
391
|
+
section.length = 0;
|
|
392
|
+
section.name = 'Internal Constraints';
|
|
393
|
+
section._settings = internalConstraints.map(constraint => BMLayoutEditorSetting.settingWithName(constraint.toString(), {kind: BMLayoutEditorSettingKind.Constraint, target: constraint}));
|
|
394
|
+
|
|
395
|
+
this._settingSections.push(section);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
if (this.layoutEditor) this.layoutEditor._drawConstraintsForView(this._displayedView, {includesInactiveConstraints: this._showsInactiveConstraints, includesSubviewConstraints: this._showsSubviewConstraints});
|
|
399
|
+
|
|
400
|
+
const deactivateConstraintsSection = BMLayoutEditorSettingsSection.section();
|
|
401
|
+
deactivateConstraintsSection._settings[0] = BMLayoutEditorSetting.settingWithName('Deactivate Constraints', {kind: BMLayoutEditorSettingKind.DeactivateConstraintsButton, target: this});
|
|
402
|
+
this._settingSections.push(deactivateConstraintsSection);
|
|
403
|
+
|
|
404
|
+
this.commitUpdates();
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Constructs and returns a view layout settings tab for the given view.
|
|
410
|
+
* @param view <BMView> The view whose constraints will be displayed.
|
|
411
|
+
* @return <_BMLayoutEditorConstraintSettingsTab> A view layout settings tab.
|
|
412
|
+
*/
|
|
413
|
+
_BMLayoutEditorConstraintSettingsTab.viewLayoutTabForView = function (view) {
|
|
414
|
+
return (new _BMLayoutEditorConstraintSettingsTab).initWithView(view);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// @endtype
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// @type interface BMLayoutEditorDelegate extends BMWindowDelegate
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The specification for a `BMLayoutEditorDelegate` object, which is used to provide information to the layout editor regarding additional settings and can
|
|
5
|
+
* receive various lifecycle callbacks from it.
|
|
6
|
+
*/
|
|
7
|
+
function BMLayoutEditorDelegate() {} // <constructor>
|
|
8
|
+
|
|
9
|
+
BMLayoutEditorDelegate.prototype = {
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Invoked by the layout editor to obtain an optional list of additional tabs to use when creating the settings
|
|
13
|
+
* panel for a view.
|
|
14
|
+
*
|
|
15
|
+
* Delegates that implement this method should return an array of additional tabs that will be added to the panel.
|
|
16
|
+
*
|
|
17
|
+
* It is not required to add the actual settings to the tabs from this method. Instead, the layout editor will invoke
|
|
18
|
+
* the `layoutEditorAdditionalSettingSectionsForTab(_, _)` method to obtain the settings to add after this method returns.
|
|
19
|
+
* @param editor <BMLayoutEditor> The layout editor invoking this method.
|
|
20
|
+
* @param view <BMView> The view for which to add additional tabs.
|
|
21
|
+
* @return <[BMLayoutEditorSettingsTab]> An array of settings tabs.
|
|
22
|
+
*/
|
|
23
|
+
layoutEditorAdditionalSettingTabsForView(editor, view) {
|
|
24
|
+
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Invoked by the layout editor to obtain an optional list of additional tabs to use when creating the settings
|
|
29
|
+
* panel for a constraint.
|
|
30
|
+
*
|
|
31
|
+
* Delegates that implement this method should return an array of additional tabs that will be added to the panel.
|
|
32
|
+
*
|
|
33
|
+
* It is not required to add the actual settings to the tabs from this method. Instead, the layout editor will invoke
|
|
34
|
+
* the `layoutEditorAdditionalSettingSectionsForTab(_, _)` method to obtain the settings to add after this method returns.
|
|
35
|
+
* @param editor <BMLayoutEditor> The layout editor invoking this method.
|
|
36
|
+
* @param constraint <BMLayoutConstraint> The view for which to add additional tabs.
|
|
37
|
+
* @return <[BMLayoutEditorSettingsTab]> An array of settings tabs.
|
|
38
|
+
*/
|
|
39
|
+
layoutEditorAdditionalSettingTabsForConstraint(editor, constraint) {
|
|
40
|
+
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Invoked by the layout editor to obtain an optional list of additional setting sections to add to the given tab when
|
|
45
|
+
* creating the settings panel for a selected object. This method will also be invoked whenever the settings for the given
|
|
46
|
+
* tab have been invalidated.
|
|
47
|
+
*
|
|
48
|
+
* Delegates that implement this method should return an array of additional sesctions that will be added to the panel.
|
|
49
|
+
* @param editor <BMLayoutEditor> The layout editor invoking this method.
|
|
50
|
+
* @param tab <BMLayoutEditorSettingsTab> The tab for which to add additional settings.
|
|
51
|
+
* @return <[BMLayoutEditorSettingsSection]> An array of settings ssections.
|
|
52
|
+
*/
|
|
53
|
+
layoutEditorAdditionalSettingSectionsForTab(editor, tab) {
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// @endtype
|