@itwin/appui-react 3.4.0-dev.36 → 3.4.0-dev.37
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/lib/cjs/appui-react/childwindow/ChildWindowManager.d.ts.map +1 -1
- package/lib/cjs/appui-react/childwindow/ChildWindowManager.js +4 -5
- package/lib/cjs/appui-react/childwindow/ChildWindowManager.js.map +1 -1
- package/lib/cjs/appui-react/frontstage/FrontstageDef.d.ts +13 -1
- package/lib/cjs/appui-react/frontstage/FrontstageDef.d.ts.map +1 -1
- package/lib/cjs/appui-react/frontstage/FrontstageDef.js +140 -96
- package/lib/cjs/appui-react/frontstage/FrontstageDef.js.map +1 -1
- package/lib/cjs/appui-react/stagepanels/StagePanelDef.d.ts +0 -6
- package/lib/cjs/appui-react/stagepanels/StagePanelDef.d.ts.map +1 -1
- package/lib/cjs/appui-react/widget-panels/Frontstage.d.ts +20 -697
- package/lib/cjs/appui-react/widget-panels/Frontstage.d.ts.map +1 -1
- package/lib/cjs/appui-react/widget-panels/Frontstage.js +275 -278
- package/lib/cjs/appui-react/widget-panels/Frontstage.js.map +1 -1
- package/lib/cjs/appui-react/widget-panels/useWidgetDirection.js +1 -1
- package/lib/cjs/appui-react/widget-panels/useWidgetDirection.js.map +1 -1
- package/lib/cjs/appui-react/widgets/WidgetDef.d.ts +13 -6
- package/lib/cjs/appui-react/widgets/WidgetDef.d.ts.map +1 -1
- package/lib/cjs/appui-react/widgets/WidgetDef.js +6 -1
- package/lib/cjs/appui-react/widgets/WidgetDef.js.map +1 -1
- package/lib/esm/appui-react/childwindow/ChildWindowManager.d.ts.map +1 -1
- package/lib/esm/appui-react/childwindow/ChildWindowManager.js +4 -5
- package/lib/esm/appui-react/childwindow/ChildWindowManager.js.map +1 -1
- package/lib/esm/appui-react/frontstage/FrontstageDef.d.ts +13 -1
- package/lib/esm/appui-react/frontstage/FrontstageDef.d.ts.map +1 -1
- package/lib/esm/appui-react/frontstage/FrontstageDef.js +142 -98
- package/lib/esm/appui-react/frontstage/FrontstageDef.js.map +1 -1
- package/lib/esm/appui-react/stagepanels/StagePanelDef.d.ts +0 -6
- package/lib/esm/appui-react/stagepanels/StagePanelDef.d.ts.map +1 -1
- package/lib/esm/appui-react/widget-panels/Frontstage.d.ts +20 -697
- package/lib/esm/appui-react/widget-panels/Frontstage.d.ts.map +1 -1
- package/lib/esm/appui-react/widget-panels/Frontstage.js +266 -272
- package/lib/esm/appui-react/widget-panels/Frontstage.js.map +1 -1
- package/lib/esm/appui-react/widget-panels/useWidgetDirection.js +2 -2
- package/lib/esm/appui-react/widget-panels/useWidgetDirection.js.map +1 -1
- package/lib/esm/appui-react/widgets/WidgetDef.d.ts +13 -6
- package/lib/esm/appui-react/widgets/WidgetDef.d.ts.map +1 -1
- package/lib/esm/appui-react/widgets/WidgetDef.js +6 -1
- package/lib/esm/appui-react/widgets/WidgetDef.js.map +1 -1
- package/package.json +32 -32
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
/* eslint-disable deprecation/deprecation */
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.
|
|
8
|
+
exports.useItemsManager = exports.useFrontstageManager = exports.getFrontstageStateSettingName = exports.FRONTSTAGE_SETTINGS_NAMESPACE = exports.useSaveFrontstageSettings = exports.useSavedFrontstageState = exports.setWidgetLabel = exports.expandWidget = exports.showWidget = exports.setWidgetState = exports.isPanelCollapsed = exports.packNineZoneState = exports.restoreNineZoneState = exports.initializeNineZoneState = exports.initializePanel = exports.isFrontstageStateSettingResult = exports.addPanelWidgets = exports.getPanelZoneWidgets = exports.getWidgetId = exports.removeMissingWidgets = exports.addMissingWidgets = exports.appendWidgets = exports.addWidgets = exports.useLabels = exports.ActiveFrontstageDefProvider = exports.WidgetPanelsFrontstage = exports.useNineZoneDispatch = exports.useUpdateNineZoneSize = exports.useNineZoneState = void 0;
|
|
9
9
|
/** @packageDocumentation
|
|
10
10
|
* @module Frontstage
|
|
11
11
|
*/
|
|
@@ -268,7 +268,6 @@ function appendWidgets(state, widgetDefs, side, preferredWidgetIndex) {
|
|
|
268
268
|
const saveTab = state.tabs[widgetDef.id];
|
|
269
269
|
const preferredPanelWidgetSize = saveTab ? saveTab.preferredPanelWidgetSize : widgetDef.preferredPanelSize;
|
|
270
270
|
const preferredFloatingWidgetSize = saveTab ? saveTab.preferredFloatingWidgetSize : widgetDef.defaultFloatingSize;
|
|
271
|
-
const preferredPopoutWidgetSize = saveTab ? saveTab.preferredPopoutWidgetSize : undefined;
|
|
272
271
|
// if a defaultFloatingSize is specified then this mean the widget can't determine its intrinsic size and must be explicitly sized
|
|
273
272
|
const userSized = saveTab ? (saveTab.userSized || !!widgetDef.defaultFloatingSize && !!saveTab.preferredFloatingWidgetSize)
|
|
274
273
|
: !!widgetDef.defaultFloatingSize;
|
|
@@ -278,7 +277,6 @@ function appendWidgets(state, widgetDefs, side, preferredWidgetIndex) {
|
|
|
278
277
|
canPopout: widgetDef.canPopout,
|
|
279
278
|
preferredPanelWidgetSize,
|
|
280
279
|
preferredFloatingWidgetSize,
|
|
281
|
-
preferredPopoutWidgetSize,
|
|
282
280
|
userSized,
|
|
283
281
|
isFloatingStateWindowResizable: widgetDef.isFloatingStateWindowResizable,
|
|
284
282
|
hideWithUiWhenFloating: !!widgetDef.hideWithUiWhenFloating,
|
|
@@ -286,13 +284,35 @@ function appendWidgets(state, widgetDefs, side, preferredWidgetIndex) {
|
|
|
286
284
|
if (widgetDef.isFloatingStateSupported && widgetDef.defaultState === appui_abstract_1.WidgetState.Floating) {
|
|
287
285
|
const floatingContainerId = (_a = widgetDef.floatingContainerId) !== null && _a !== void 0 ? _a : (0, appui_layout_react_1.getUniqueId)();
|
|
288
286
|
const widgetContainerId = getWidgetId(side, panelZoneKeys[preferredWidgetIndex]);
|
|
289
|
-
const
|
|
287
|
+
const home = { side, widgetId: widgetContainerId, widgetIndex: 0 };
|
|
290
288
|
const preferredPosition = widgetDef.defaultFloatingPosition;
|
|
291
|
-
|
|
289
|
+
if (floatingContainerId in state.widgets) {
|
|
290
|
+
state = (0, appui_layout_react_1.addTabToWidget)(state, widgetDef.id, floatingContainerId);
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
const tab = state.tabs[widgetDef.id];
|
|
294
|
+
const size = { height: 200, width: 300, ...tab.preferredFloatingWidgetSize };
|
|
295
|
+
const preferredPoint = preferredPosition !== null && preferredPosition !== void 0 ? preferredPosition : { x: (state.size.width - size.width) / 2, y: (state.size.height - size.height) / 2 };
|
|
296
|
+
const nzBounds = core_react_1.Rectangle.createFromSize(state.size);
|
|
297
|
+
const bounds = core_react_1.Rectangle.createFromSize(size).offset(preferredPoint);
|
|
298
|
+
const containedBounds = bounds.containIn(nzBounds);
|
|
299
|
+
state = (0, appui_layout_react_1.addFloatingWidget)(state, floatingContainerId, [widgetDef.id], {
|
|
300
|
+
bounds: containedBounds.toProps(),
|
|
301
|
+
home,
|
|
302
|
+
userSized,
|
|
303
|
+
}, {
|
|
304
|
+
isFloatingStateWindowResizable: widgetDef.isFloatingStateWindowResizable,
|
|
305
|
+
});
|
|
306
|
+
}
|
|
292
307
|
}
|
|
293
308
|
else {
|
|
294
309
|
const widgetPanelSectionId = (0, appui_layout_react_1.getWidgetPanelSectionId)(side, preferredWidgetIndex);
|
|
295
|
-
|
|
310
|
+
if (widgetPanelSectionId in state.widgets) {
|
|
311
|
+
state = (0, appui_layout_react_1.addTabToWidget)(state, widgetDef.id, widgetPanelSectionId);
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
state = (0, appui_layout_react_1.addPanelWidget)(state, side, widgetPanelSectionId, [widgetDef.id]);
|
|
315
|
+
}
|
|
296
316
|
}
|
|
297
317
|
}
|
|
298
318
|
return state;
|
|
@@ -340,17 +360,15 @@ function addMissingWidgets(frontstageDef, initialState) {
|
|
|
340
360
|
return state;
|
|
341
361
|
}
|
|
342
362
|
exports.addMissingWidgets = addMissingWidgets;
|
|
343
|
-
/**
|
|
344
|
-
function
|
|
363
|
+
/** Hide widgets with Hidden defaultState. */
|
|
364
|
+
function hideWidgets(state, frontstageDef) {
|
|
345
365
|
const tabs = Object.values(state.tabs);
|
|
346
366
|
for (const tab of tabs) {
|
|
347
367
|
const widgetDef = frontstageDef.findWidgetDef(tab.id);
|
|
348
368
|
if (!widgetDef)
|
|
349
369
|
continue;
|
|
350
370
|
if (widgetDef.defaultState === appui_abstract_1.WidgetState.Hidden) {
|
|
351
|
-
state = (
|
|
352
|
-
hideWidget(draft, widgetDef);
|
|
353
|
-
});
|
|
371
|
+
state = hideWidget(state, widgetDef);
|
|
354
372
|
}
|
|
355
373
|
}
|
|
356
374
|
return state;
|
|
@@ -359,16 +377,15 @@ function removeHiddenWidgets(state, frontstageDef) {
|
|
|
359
377
|
* @internal
|
|
360
378
|
*/
|
|
361
379
|
function removeMissingWidgets(frontstageDef, initialState) {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
});
|
|
380
|
+
let state = initialState;
|
|
381
|
+
for (const [, tab] of Object.entries(state.tabs)) {
|
|
382
|
+
if (tab.id === appui_layout_react_1.toolSettingsTabId)
|
|
383
|
+
continue;
|
|
384
|
+
const widgetDef = frontstageDef.findWidgetDef(tab.id);
|
|
385
|
+
if (widgetDef)
|
|
386
|
+
continue;
|
|
387
|
+
state = (0, appui_layout_react_1.removeTab)(state, tab.id);
|
|
388
|
+
}
|
|
372
389
|
return state;
|
|
373
390
|
}
|
|
374
391
|
exports.removeMissingWidgets = removeMissingWidgets;
|
|
@@ -524,23 +541,23 @@ function isFrontstageStateSettingResult(settingsResult) {
|
|
|
524
541
|
}
|
|
525
542
|
exports.isFrontstageStateSettingResult = isFrontstageStateSettingResult;
|
|
526
543
|
/** @internal */
|
|
527
|
-
function initializePanel(
|
|
528
|
-
|
|
544
|
+
function initializePanel(state, frontstageDef, panelSide) {
|
|
545
|
+
state = addPanelWidgets(state, frontstageDef, panelSide);
|
|
529
546
|
const location = toStagePanelLocation(panelSide);
|
|
530
547
|
const panelDef = frontstageDef.getStagePanelDef(location);
|
|
531
|
-
|
|
548
|
+
state = (0, immer_1.default)(state, (draft) => {
|
|
532
549
|
var _a, _b, _c;
|
|
533
550
|
const panel = draft.panels[panelSide];
|
|
534
551
|
panel.minSize = (_a = panelDef === null || panelDef === void 0 ? void 0 : panelDef.minSize) !== null && _a !== void 0 ? _a : panel.minSize;
|
|
535
552
|
panel.pinned = (_b = panelDef === null || panelDef === void 0 ? void 0 : panelDef.pinned) !== null && _b !== void 0 ? _b : panel.pinned;
|
|
536
553
|
panel.resizable = (_c = panelDef === null || panelDef === void 0 ? void 0 : panelDef.resizable) !== null && _c !== void 0 ? _c : panel.resizable;
|
|
537
554
|
if (panelDef === null || panelDef === void 0 ? void 0 : panelDef.maxSizeSpec) {
|
|
538
|
-
panel.maxSize = getPanelMaxSize(panelDef.maxSizeSpec, panelSide,
|
|
555
|
+
panel.maxSize = getPanelMaxSize(panelDef.maxSizeSpec, panelSide, state.size);
|
|
539
556
|
}
|
|
540
557
|
const size = panelDef === null || panelDef === void 0 ? void 0 : panelDef.size;
|
|
541
558
|
panel.size = size === undefined ? size : Math.min(Math.max(size, panel.minSize), panel.maxSize);
|
|
542
559
|
});
|
|
543
|
-
return
|
|
560
|
+
return state;
|
|
544
561
|
}
|
|
545
562
|
exports.initializePanel = initializePanel;
|
|
546
563
|
function getPanelMaxSize(maxSizeSpec, panel, nineZoneSize) {
|
|
@@ -550,7 +567,7 @@ function getPanelMaxSize(maxSizeSpec, panel, nineZoneSize) {
|
|
|
550
567
|
const size = (0, appui_layout_react_1.isHorizontalPanelSide)(panel) ? nineZoneSize.height : nineZoneSize.width;
|
|
551
568
|
return maxSizeSpec.percentage / 100 * size;
|
|
552
569
|
}
|
|
553
|
-
const stateVersion =
|
|
570
|
+
const stateVersion = 13; // this needs to be bumped when NineZoneState is changed (to recreate the layout).
|
|
554
571
|
/** @internal */
|
|
555
572
|
function initializeNineZoneState(frontstageDef) {
|
|
556
573
|
let nineZone = defaultNineZone;
|
|
@@ -572,6 +589,7 @@ function initializeNineZoneState(frontstageDef) {
|
|
|
572
589
|
for (const [, panel] of Object.entries(stateDraft.panels)) {
|
|
573
590
|
const expanded = panel.widgets.find((widgetId) => stateDraft.widgets[widgetId].minimized === false);
|
|
574
591
|
const firstWidget = panel.widgets.length > 0 ? stateDraft.widgets[panel.widgets[0]] : undefined;
|
|
592
|
+
// istanbul ignore next
|
|
575
593
|
if (!expanded && firstWidget) {
|
|
576
594
|
firstWidget.minimized = false;
|
|
577
595
|
}
|
|
@@ -600,7 +618,7 @@ function initializeNineZoneState(frontstageDef) {
|
|
|
600
618
|
}
|
|
601
619
|
});
|
|
602
620
|
nineZone = addMissingWidgets(frontstageDef, nineZone);
|
|
603
|
-
nineZone =
|
|
621
|
+
nineZone = hideWidgets(nineZone, frontstageDef);
|
|
604
622
|
nineZone = processPopoutWidgets(nineZone, frontstageDef);
|
|
605
623
|
return nineZone;
|
|
606
624
|
}
|
|
@@ -613,29 +631,32 @@ exports.initializeNineZoneState = initializeNineZoneState;
|
|
|
613
631
|
function restoreNineZoneState(frontstageDef, saved) {
|
|
614
632
|
let restored = {
|
|
615
633
|
...saved,
|
|
616
|
-
tabs:
|
|
634
|
+
tabs: defaultNineZone.tabs,
|
|
617
635
|
};
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
636
|
+
for (const [, tab] of Object.entries(saved.tabs)) {
|
|
637
|
+
// Re-add the placeholder tab in order to correctly remove it from the state if WidgetDef is not found.
|
|
638
|
+
restored = (0, appui_layout_react_1.addTab)(restored, tab.id);
|
|
639
|
+
const widgetDef = frontstageDef.findWidgetDef(tab.id);
|
|
640
|
+
if (!widgetDef) {
|
|
641
|
+
core_bentley_1.Logger.logInfo(UiFramework_1.UiFramework.loggerCategory(restoreNineZoneState), "WidgetDef is not found for saved tab.", () => ({
|
|
642
|
+
frontstageId: frontstageDef.id,
|
|
643
|
+
tabId: tab.id,
|
|
644
|
+
}));
|
|
645
|
+
restored = (0, appui_layout_react_1.removeTab)(restored, tab.id);
|
|
646
|
+
continue;
|
|
647
|
+
}
|
|
648
|
+
restored = (0, immer_1.default)(restored, (draft) => {
|
|
630
649
|
draft.tabs[tab.id] = {
|
|
631
650
|
...tab,
|
|
632
|
-
label: getWidgetLabel(
|
|
633
|
-
hideWithUiWhenFloating: widgetDef
|
|
634
|
-
iconSpec: widgetDef
|
|
635
|
-
canPopout: widgetDef
|
|
636
|
-
isFloatingStateWindowResizable: widgetDef
|
|
651
|
+
label: getWidgetLabel(widgetDef.label),
|
|
652
|
+
hideWithUiWhenFloating: widgetDef.hideWithUiWhenFloating,
|
|
653
|
+
iconSpec: widgetDef.iconSpec,
|
|
654
|
+
canPopout: widgetDef.canPopout,
|
|
655
|
+
isFloatingStateWindowResizable: widgetDef.isFloatingStateWindowResizable,
|
|
637
656
|
};
|
|
638
|
-
}
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
restored = (0, immer_1.default)(restored, (draft) => {
|
|
639
660
|
// remove center panel section if one is found in left or right panels
|
|
640
661
|
const oldLeftMiddleIndex = saved.panels.left.widgets.findIndex((value) => value === "leftMiddle");
|
|
641
662
|
// istanbul ignore next
|
|
@@ -663,14 +684,6 @@ function restoreNineZoneState(frontstageDef, saved) {
|
|
|
663
684
|
}
|
|
664
685
|
return;
|
|
665
686
|
});
|
|
666
|
-
// TODO: remove when isUUID check is refactored.
|
|
667
|
-
restored = (0, immer_1.default)(restored, (draft) => {
|
|
668
|
-
// Floating widget might have been removed when saving, dock tool settings if tab is not found.
|
|
669
|
-
const location = (0, appui_layout_react_1.findTab)(draft, appui_layout_react_1.toolSettingsTabId);
|
|
670
|
-
if (!location) {
|
|
671
|
-
draft.toolSettings.type = "docked";
|
|
672
|
-
}
|
|
673
|
-
});
|
|
674
687
|
if (FrontstageManager_1.FrontstageManager.nineZoneSize && (0 !== FrontstageManager_1.FrontstageManager.nineZoneSize.height || 0 !== FrontstageManager_1.FrontstageManager.nineZoneSize.width)) {
|
|
675
688
|
restored = FrameworkStateReducer(restored, {
|
|
676
689
|
type: "RESIZE",
|
|
@@ -683,20 +696,6 @@ function restoreNineZoneState(frontstageDef, saved) {
|
|
|
683
696
|
return restored;
|
|
684
697
|
}
|
|
685
698
|
exports.restoreNineZoneState = restoreNineZoneState;
|
|
686
|
-
/**
|
|
687
|
-
* Checks to see whether a widget id is one of our generated uuids
|
|
688
|
-
* @param uuid the string value to test
|
|
689
|
-
* @returns boolean
|
|
690
|
-
*/
|
|
691
|
-
function isUUID(uuid) {
|
|
692
|
-
const s = `${uuid}`;
|
|
693
|
-
const result = s.match("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$");
|
|
694
|
-
// istanbul ignore else
|
|
695
|
-
if (result === null) {
|
|
696
|
-
return false;
|
|
697
|
-
}
|
|
698
|
-
return true;
|
|
699
|
-
}
|
|
700
699
|
/** Prepares NineZoneState to be saved.
|
|
701
700
|
* @note Removes toolSettings tab.
|
|
702
701
|
* @note Removes tab labels and iconSpec.
|
|
@@ -711,33 +710,62 @@ function packNineZoneState(state) {
|
|
|
711
710
|
for (const [, tab] of Object.entries(state.tabs)) {
|
|
712
711
|
if (tab.id === appui_layout_react_1.toolSettingsTabId)
|
|
713
712
|
continue;
|
|
714
|
-
// istanbul ignore else
|
|
715
|
-
if (isUUID(tab.id))
|
|
716
|
-
continue;
|
|
717
713
|
draft.tabs[tab.id] = {
|
|
718
714
|
id: tab.id,
|
|
719
715
|
preferredFloatingWidgetSize: tab.preferredFloatingWidgetSize,
|
|
720
|
-
preferredPopoutWidgetSize: tab.preferredPopoutWidgetSize,
|
|
721
716
|
allowedPanelTargets: tab.allowedPanelTargets,
|
|
722
717
|
userSized: tab.userSized,
|
|
723
718
|
};
|
|
724
719
|
}
|
|
725
720
|
});
|
|
726
|
-
packed = (0, immer_1.default)(packed, (draft) => {
|
|
727
|
-
for (const [, floatingWidget] of Object.entries(state.floatingWidgets.byId)) {
|
|
728
|
-
const widgetId = floatingWidget.id;
|
|
729
|
-
// istanbul ignore else
|
|
730
|
-
if (isUUID(widgetId)) {
|
|
731
|
-
const idIndex = draft.floatingWidgets.allIds.indexOf(widgetId);
|
|
732
|
-
draft.floatingWidgets.allIds.splice(idIndex, 1);
|
|
733
|
-
delete draft.floatingWidgets.byId[widgetId];
|
|
734
|
-
delete draft.widgets[widgetId];
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
});
|
|
738
721
|
return packed;
|
|
739
722
|
}
|
|
740
723
|
exports.packNineZoneState = packNineZoneState;
|
|
724
|
+
// TODO: clean-up of saved widgets.
|
|
725
|
+
// istanbul ignore next
|
|
726
|
+
function packSavedWidgets(savedWidgets, frontstageDef) {
|
|
727
|
+
for (const widgetDef of frontstageDef.widgetDefs) {
|
|
728
|
+
const id = widgetDef.id;
|
|
729
|
+
const initialWidget = {
|
|
730
|
+
id,
|
|
731
|
+
};
|
|
732
|
+
const widget = (0, immer_1.default)(initialWidget, (draft) => {
|
|
733
|
+
if (widgetDef.tabLocation) {
|
|
734
|
+
draft.tabLocation = { ...widgetDef.tabLocation };
|
|
735
|
+
}
|
|
736
|
+
if (widgetDef.popoutBounds) {
|
|
737
|
+
draft.popoutBounds = widgetDef.popoutBounds.toProps();
|
|
738
|
+
}
|
|
739
|
+
});
|
|
740
|
+
if (widget === initialWidget)
|
|
741
|
+
continue;
|
|
742
|
+
savedWidgets = (0, immer_1.default)(savedWidgets, (draft) => {
|
|
743
|
+
draft.push(widget);
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
return savedWidgets;
|
|
747
|
+
}
|
|
748
|
+
// istanbul ignore next
|
|
749
|
+
function restoreSavedWidgets(savedWidgets, frontstage) {
|
|
750
|
+
let i = savedWidgets.length;
|
|
751
|
+
while (i--) {
|
|
752
|
+
const savedWidget = savedWidgets[i];
|
|
753
|
+
const widgetId = savedWidget.id;
|
|
754
|
+
const widgetDef = frontstage.findWidgetDef(widgetId);
|
|
755
|
+
if (!widgetDef)
|
|
756
|
+
continue;
|
|
757
|
+
if (savedWidget.tabLocation) {
|
|
758
|
+
widgetDef.tabLocation = { ...savedWidget.tabLocation };
|
|
759
|
+
}
|
|
760
|
+
if (savedWidget.popoutBounds) {
|
|
761
|
+
widgetDef.popoutBounds = core_react_1.Rectangle.create(savedWidget.popoutBounds);
|
|
762
|
+
}
|
|
763
|
+
savedWidgets = (0, immer_1.default)(savedWidgets, (draft) => {
|
|
764
|
+
draft.splice(i, 1);
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
return savedWidgets;
|
|
768
|
+
}
|
|
741
769
|
/** @internal */
|
|
742
770
|
function isPanelCollapsed(zoneStates, panelStates) {
|
|
743
771
|
const openZone = zoneStates.find((zoneState) => zoneState === ZoneDef_1.ZoneState.Open);
|
|
@@ -745,121 +773,117 @@ function isPanelCollapsed(zoneStates, panelStates) {
|
|
|
745
773
|
return !openZone && !openPanel;
|
|
746
774
|
}
|
|
747
775
|
exports.isPanelCollapsed = isPanelCollapsed;
|
|
748
|
-
function
|
|
749
|
-
|
|
750
|
-
const
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
isFloatingStateWindowResizable: widgetDef.isFloatingStateWindowResizable,
|
|
756
|
-
hideWithUiWhenFloating: !!widgetDef.hideWithUiWhenFloating,
|
|
757
|
-
});
|
|
758
|
-
nineZone.tabs[newTab.id] = newTab;
|
|
759
|
-
if (widgetDef.tabLocation.widgetId in nineZone.widgets) {
|
|
760
|
-
// Add to existing widget (by widget id).
|
|
761
|
-
const widgetId = widgetDef.tabLocation.widgetId;
|
|
762
|
-
const newTabWidget = nineZone.widgets[widgetId];
|
|
763
|
-
newTabWidget.tabs.splice(widgetDef.tabLocation.tabIndex, 0, newTab.id);
|
|
776
|
+
function addHiddenWidget(state, widgetDef) {
|
|
777
|
+
const tabLocation = widgetDef.tabLocation || widgetDef.defaultTabLocation;
|
|
778
|
+
const tabId = widgetDef.id;
|
|
779
|
+
const widgetId = tabLocation.widgetId;
|
|
780
|
+
if (widgetId in state.widgets) {
|
|
781
|
+
// Add to an existing widget (by widget id).
|
|
782
|
+
return (0, appui_layout_react_1.insertTabToWidget)(state, tabId, widgetId, tabLocation.tabIndex);
|
|
764
783
|
}
|
|
765
|
-
else if (
|
|
766
|
-
const
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
else {
|
|
773
|
-
const home = { side: widgetDef.tabLocation.side, widgetId: widgetDef.floatingContainerId, widgetIndex: 0 };
|
|
774
|
-
(0, appui_layout_react_1.addWidgetTabToDraftFloatingPanel)(nineZone, (_b = widgetDef.floatingContainerId) !== null && _b !== void 0 ? _b : widgetDef.id, widgetDef.id, home, newTab);
|
|
784
|
+
else if (tabLocation.floatingWidget) {
|
|
785
|
+
const floatingWidget = tabLocation.floatingWidget;
|
|
786
|
+
const floatingWidgetId = floatingWidget.id;
|
|
787
|
+
// Add to an existing floating widget.
|
|
788
|
+
// istanbul ignore next
|
|
789
|
+
if (floatingWidgetId in state.widgets) {
|
|
790
|
+
return (0, appui_layout_react_1.insertTabToWidget)(state, tabId, floatingWidgetId, tabLocation.tabIndex);
|
|
775
791
|
}
|
|
792
|
+
// Add to a new floating widget.
|
|
793
|
+
const nzBounds = core_react_1.Rectangle.createFromSize(state.size);
|
|
794
|
+
const bounds = core_react_1.Rectangle.create(floatingWidget.bounds).containIn(nzBounds);
|
|
795
|
+
return (0, appui_layout_react_1.addFloatingWidget)(state, floatingWidgetId, [tabId], {
|
|
796
|
+
...floatingWidget,
|
|
797
|
+
bounds: bounds.toProps(),
|
|
798
|
+
});
|
|
776
799
|
}
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
newTabWidget.tabs.splice(widgetDef.tabLocation.tabIndex, 0, newTab.id);
|
|
785
|
-
}
|
|
786
|
-
else {
|
|
787
|
-
// Create a new panel widget.
|
|
788
|
-
const newWidget = (0, appui_layout_react_1.createWidgetState)((0, appui_layout_react_1.getUniqueId)(), [newTab.id]);
|
|
789
|
-
nineZone.widgets[newWidget.id] = (0, immer_1.castDraft)(newWidget);
|
|
790
|
-
newTabPanel.widgets.splice(widgetDef.tabLocation.widgetIndex, 0, newWidget.id);
|
|
791
|
-
}
|
|
800
|
+
// Add to a panel section.
|
|
801
|
+
const panel = state.panels[tabLocation.side];
|
|
802
|
+
// Add to existing panel section.
|
|
803
|
+
if (panel.widgets.length >= panel.maxWidgetCount) {
|
|
804
|
+
const sectionIndex = Math.min(panel.maxWidgetCount - 1, tabLocation.widgetIndex);
|
|
805
|
+
const sectionId = panel.widgets[sectionIndex];
|
|
806
|
+
return (0, appui_layout_react_1.insertTabToWidget)(state, tabId, sectionId, tabLocation.tabIndex);
|
|
792
807
|
}
|
|
808
|
+
// Create a new panel section.
|
|
809
|
+
const newSectionId = (0, appui_layout_react_1.getUniqueId)();
|
|
810
|
+
return (0, appui_layout_react_1.insertPanelWidget)(state, panel.side, newSectionId, [tabId], tabLocation.widgetIndex);
|
|
793
811
|
}
|
|
794
812
|
/** @internal */
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
813
|
+
function setWidgetState(state, widgetDef, widgetState) {
|
|
814
|
+
if (widgetState === appui_abstract_1.WidgetState.Hidden) {
|
|
815
|
+
return hideWidget(state, widgetDef);
|
|
816
|
+
}
|
|
817
|
+
else if (widgetState === appui_abstract_1.WidgetState.Open) {
|
|
798
818
|
const id = widgetDef.id;
|
|
799
|
-
let location = (0, appui_layout_react_1.
|
|
819
|
+
let location = (0, appui_layout_react_1.getTabLocation)(state, id);
|
|
800
820
|
if (!location) {
|
|
801
|
-
|
|
802
|
-
location = (0, appui_layout_react_1.
|
|
803
|
-
(0, core_bentley_1.assert)(!!location);
|
|
804
|
-
}
|
|
805
|
-
if (!!widgetDef.tabLocation.floating) {
|
|
806
|
-
nineZone.floatingWidgets.byId[(_a = widgetDef.floatingContainerId) !== null && _a !== void 0 ? _a : widgetDef.id].hidden = false;
|
|
821
|
+
state = addHiddenWidget(state, widgetDef);
|
|
822
|
+
location = (0, appui_layout_react_1.getTabLocation)(state, id);
|
|
807
823
|
}
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
panel.size = (_b = panel.minSize) !== null && _b !== void 0 ? _b : 200;
|
|
824
|
+
return (0, immer_1.default)(state, (draft) => {
|
|
825
|
+
var _a;
|
|
826
|
+
(0, core_bentley_1.assert)(!!location);
|
|
827
|
+
const widget = draft.widgets[location.widgetId];
|
|
828
|
+
widget.minimized = false;
|
|
829
|
+
widget.activeTabId = id;
|
|
830
|
+
if ((0, appui_layout_react_1.isFloatingTabLocation)(location)) {
|
|
831
|
+
const floatingWidget = draft.floatingWidgets.byId[location.floatingWidgetId];
|
|
832
|
+
floatingWidget.hidden = false;
|
|
833
|
+
// istanbul ignore else
|
|
819
834
|
}
|
|
820
|
-
|
|
835
|
+
else if ((0, appui_layout_react_1.isPanelTabLocation)(location)) {
|
|
836
|
+
const panel = draft.panels[location.side];
|
|
837
|
+
panel.collapsed = false;
|
|
838
|
+
if (undefined === panel.size || 0 === panel.size) {
|
|
839
|
+
// istanbul ignore next
|
|
840
|
+
panel.size = (_a = panel.minSize) !== null && _a !== void 0 ? _a : 200;
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
});
|
|
821
844
|
}
|
|
822
|
-
else if (
|
|
845
|
+
else if (widgetState === appui_abstract_1.WidgetState.Closed) {
|
|
823
846
|
const id = widgetDef.id;
|
|
824
|
-
let location = (0, appui_layout_react_1.
|
|
847
|
+
let location = (0, appui_layout_react_1.getTabLocation)(state, id);
|
|
825
848
|
if (!location) {
|
|
826
|
-
|
|
827
|
-
location = (0, appui_layout_react_1.
|
|
828
|
-
(0, core_bentley_1.assert)(!!location);
|
|
849
|
+
state = addHiddenWidget(state, widgetDef);
|
|
850
|
+
location = (0, appui_layout_react_1.getTabLocation)(state, id);
|
|
829
851
|
}
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
852
|
+
// TODO: should change activeTabId of a widget with multiple tabs.
|
|
853
|
+
return (0, immer_1.default)(state, (draft) => {
|
|
854
|
+
(0, core_bentley_1.assert)(!!location);
|
|
855
|
+
const widget = draft.widgets[location.widgetId];
|
|
856
|
+
if ((0, appui_layout_react_1.isFloatingTabLocation)(location)) {
|
|
857
|
+
if (id === widget.activeTabId) {
|
|
858
|
+
widget.minimized = true;
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
});
|
|
839
862
|
}
|
|
840
|
-
|
|
863
|
+
return state;
|
|
864
|
+
}
|
|
865
|
+
exports.setWidgetState = setWidgetState;
|
|
841
866
|
/** Stores widget location and hides it in the UI. */
|
|
842
867
|
function hideWidget(state, widgetDef) {
|
|
843
|
-
const location = (0, appui_layout_react_1.
|
|
868
|
+
const location = (0, appui_layout_react_1.getTabLocation)(state, widgetDef.id);
|
|
844
869
|
if (!location)
|
|
845
|
-
return;
|
|
846
|
-
|
|
847
|
-
|
|
870
|
+
return state;
|
|
871
|
+
// istanbul ignore else
|
|
872
|
+
if ((0, appui_layout_react_1.isFloatingTabLocation)(location)) {
|
|
873
|
+
const floatingWidget = state.floatingWidgets.byId[location.widgetId];
|
|
848
874
|
widgetDef.setFloatingContainerId(location.floatingWidgetId);
|
|
849
875
|
widgetDef.tabLocation = {
|
|
850
|
-
side:
|
|
851
|
-
tabIndex:
|
|
876
|
+
side: floatingWidget.home.side,
|
|
877
|
+
tabIndex: floatingWidget.home.widgetIndex,
|
|
852
878
|
widgetId: widgetDef.id,
|
|
853
|
-
widgetIndex:
|
|
854
|
-
|
|
879
|
+
widgetIndex: floatingWidget.home.widgetIndex,
|
|
880
|
+
floatingWidget,
|
|
855
881
|
};
|
|
856
882
|
}
|
|
857
|
-
else
|
|
858
|
-
// istanbul ignore else
|
|
859
|
-
if (!(0, appui_layout_react_1.isPopoutLocation)(location)) {
|
|
883
|
+
else if (!(0, appui_layout_react_1.isPopoutTabLocation)(location)) {
|
|
860
884
|
const widgetId = location.widgetId;
|
|
861
|
-
const side =
|
|
862
|
-
const widgetIndex =
|
|
885
|
+
const side = (0, appui_layout_react_1.isPanelTabLocation)(location) ? location.side : "left";
|
|
886
|
+
const widgetIndex = (0, appui_layout_react_1.isPanelTabLocation)(location) ? state.panels[side].widgets.indexOf(widgetId) : 0;
|
|
863
887
|
const tabIndex = state.widgets[location.widgetId].tabs.indexOf(widgetDef.id);
|
|
864
888
|
widgetDef.tabLocation = {
|
|
865
889
|
side,
|
|
@@ -868,50 +892,56 @@ function hideWidget(state, widgetDef) {
|
|
|
868
892
|
widgetIndex,
|
|
869
893
|
};
|
|
870
894
|
}
|
|
871
|
-
(0, appui_layout_react_1.
|
|
895
|
+
return (0, appui_layout_react_1.removeTabFromWidget)(state, widgetDef.id);
|
|
872
896
|
}
|
|
873
897
|
/** @internal */
|
|
874
|
-
|
|
875
|
-
const location = (0, appui_layout_react_1.
|
|
898
|
+
function showWidget(state, id) {
|
|
899
|
+
const location = (0, appui_layout_react_1.getTabLocation)(state, id);
|
|
876
900
|
if (!location)
|
|
877
|
-
return;
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
const panel = nineZone.panels[location.side];
|
|
881
|
-
panel.collapsed = false;
|
|
882
|
-
widget.minimized = false;
|
|
901
|
+
return state;
|
|
902
|
+
state = (0, immer_1.default)(state, (draft) => {
|
|
903
|
+
const widget = draft.widgets[location.widgetId];
|
|
883
904
|
widget.activeTabId = id;
|
|
884
|
-
|
|
905
|
+
widget.minimized = false;
|
|
906
|
+
if ((0, appui_layout_react_1.isPanelTabLocation)(location)) {
|
|
907
|
+
const panel = draft.panels[location.side];
|
|
908
|
+
panel.collapsed = false;
|
|
909
|
+
}
|
|
910
|
+
});
|
|
911
|
+
if ((0, appui_layout_react_1.isFloatingTabLocation)(location)) {
|
|
912
|
+
state = (0, appui_layout_react_1.floatingWidgetBringToFront)(state, location.floatingWidgetId);
|
|
885
913
|
}
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
});
|
|
914
|
+
return state;
|
|
915
|
+
}
|
|
916
|
+
exports.showWidget = showWidget;
|
|
890
917
|
/** @internal */
|
|
891
|
-
|
|
892
|
-
const location = (0, appui_layout_react_1.
|
|
918
|
+
function expandWidget(state, id) {
|
|
919
|
+
const location = (0, appui_layout_react_1.getTabLocation)(state, id);
|
|
893
920
|
if (!location)
|
|
894
|
-
return;
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
921
|
+
return state;
|
|
922
|
+
return (0, immer_1.default)(state, (draft) => {
|
|
923
|
+
const widget = draft.widgets[location.widgetId];
|
|
924
|
+
if ((0, appui_layout_react_1.isPanelTabLocation)(location)) {
|
|
925
|
+
const panel = draft.panels[location.side];
|
|
926
|
+
panel.widgets.forEach((wId) => {
|
|
927
|
+
const w = draft.widgets[wId];
|
|
928
|
+
w.minimized = true;
|
|
929
|
+
});
|
|
930
|
+
}
|
|
902
931
|
widget.minimized = false;
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
return;
|
|
907
|
-
});
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
exports.expandWidget = expandWidget;
|
|
908
935
|
/** @internal */
|
|
909
|
-
|
|
910
|
-
if (!(id in
|
|
911
|
-
return;
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
936
|
+
function setWidgetLabel(state, id, label) {
|
|
937
|
+
if (!(id in state.tabs))
|
|
938
|
+
return state;
|
|
939
|
+
return (0, immer_1.default)(state, (draft) => {
|
|
940
|
+
const tab = draft.tabs[id];
|
|
941
|
+
tab.label = label;
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
exports.setWidgetLabel = setWidgetLabel;
|
|
915
945
|
/** @internal */
|
|
916
946
|
function useSavedFrontstageState(frontstageDef) {
|
|
917
947
|
const uiStateStorage = (0, useUiStateStorage_1.useUiStateStorageHandler)();
|
|
@@ -932,20 +962,23 @@ function useSavedFrontstageState(frontstageDef) {
|
|
|
932
962
|
}
|
|
933
963
|
const id = frontstageDef.id;
|
|
934
964
|
const version = frontstageDef.version;
|
|
935
|
-
const
|
|
936
|
-
if (isMountedRef.current)
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
965
|
+
const settingResult = await uiStateStorageRef.current.getSetting(exports.FRONTSTAGE_SETTINGS_NAMESPACE, getFrontstageStateSettingName(id));
|
|
966
|
+
if (!isMountedRef.current)
|
|
967
|
+
return;
|
|
968
|
+
if (isFrontstageStateSettingResult(settingResult)) {
|
|
969
|
+
const setting = settingResult.setting;
|
|
970
|
+
if (setting.version >= version && setting.stateVersion >= stateVersion) {
|
|
971
|
+
const restored = restoreNineZoneState(frontstageDef, setting.nineZone);
|
|
972
|
+
const savedWidgets = restoreSavedWidgets(setting.widgets, frontstageDef);
|
|
941
973
|
let state = addMissingWidgets(frontstageDef, restored);
|
|
942
|
-
state =
|
|
974
|
+
state = hideWidgets(state, frontstageDef);
|
|
943
975
|
state = processPopoutWidgets(state, frontstageDef);
|
|
944
976
|
frontstageDef.nineZoneState = state;
|
|
977
|
+
frontstageDef.savedWidgetDefs = savedWidgets;
|
|
945
978
|
return;
|
|
946
979
|
}
|
|
947
|
-
frontstageDef.nineZoneState = initializeNineZoneState(frontstageDef);
|
|
948
980
|
}
|
|
981
|
+
frontstageDef.nineZoneState = initializeNineZoneState(frontstageDef);
|
|
949
982
|
}
|
|
950
983
|
fetchFrontstageState(); // eslint-disable-line @typescript-eslint/no-floating-promises
|
|
951
984
|
}, [frontstageDef]);
|
|
@@ -955,16 +988,19 @@ exports.useSavedFrontstageState = useSavedFrontstageState;
|
|
|
955
988
|
function useSaveFrontstageSettings(frontstageDef) {
|
|
956
989
|
const nineZone = useNineZoneState(frontstageDef);
|
|
957
990
|
const uiSettingsStorage = (0, useUiStateStorage_1.useUiStateStorageHandler)();
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
991
|
+
const saveSetting = React.useMemo(() => {
|
|
992
|
+
return debounce(async (frontstage, state, savedWidgets) => {
|
|
993
|
+
const id = frontstage.id;
|
|
994
|
+
const setting = {
|
|
995
|
+
id,
|
|
996
|
+
version: frontstage.version,
|
|
997
|
+
stateVersion,
|
|
998
|
+
nineZone: packNineZoneState(state),
|
|
999
|
+
widgets: packSavedWidgets(savedWidgets, frontstage),
|
|
1000
|
+
};
|
|
1001
|
+
await uiSettingsStorage.saveSetting(exports.FRONTSTAGE_SETTINGS_NAMESPACE, getFrontstageStateSettingName(id), setting);
|
|
1002
|
+
}, 1000);
|
|
1003
|
+
}, [uiSettingsStorage]);
|
|
968
1004
|
React.useEffect(() => {
|
|
969
1005
|
return () => {
|
|
970
1006
|
saveSetting.cancel();
|
|
@@ -973,7 +1009,8 @@ function useSaveFrontstageSettings(frontstageDef) {
|
|
|
973
1009
|
React.useEffect(() => {
|
|
974
1010
|
if (!nineZone || nineZone.draggedTab)
|
|
975
1011
|
return;
|
|
976
|
-
|
|
1012
|
+
const savedWidgets = frontstageDef.savedWidgetDefs || [];
|
|
1013
|
+
saveSetting(frontstageDef, nineZone, savedWidgets);
|
|
977
1014
|
}, [frontstageDef, nineZone, saveSetting]);
|
|
978
1015
|
}
|
|
979
1016
|
exports.useSaveFrontstageSettings = useSaveFrontstageSettings;
|
|
@@ -1012,7 +1049,7 @@ function useFrontstageManager(frontstageDef, useToolAsToolSettingsLabel) {
|
|
|
1012
1049
|
React.useEffect(() => {
|
|
1013
1050
|
const listener = createListener(frontstageDef, ({ widgetDef, widgetState }) => {
|
|
1014
1051
|
(0, core_bentley_1.assert)(!!frontstageDef.nineZoneState);
|
|
1015
|
-
frontstageDef.nineZoneState =
|
|
1052
|
+
frontstageDef.nineZoneState = setWidgetState(frontstageDef.nineZoneState, widgetDef, widgetState);
|
|
1016
1053
|
});
|
|
1017
1054
|
FrontstageManager_1.FrontstageManager.onWidgetStateChangedEvent.addListener(listener);
|
|
1018
1055
|
return () => {
|
|
@@ -1022,7 +1059,7 @@ function useFrontstageManager(frontstageDef, useToolAsToolSettingsLabel) {
|
|
|
1022
1059
|
React.useEffect(() => {
|
|
1023
1060
|
const listener = createListener(frontstageDef, ({ widgetDef }) => {
|
|
1024
1061
|
(0, core_bentley_1.assert)(!!frontstageDef.nineZoneState);
|
|
1025
|
-
frontstageDef.nineZoneState =
|
|
1062
|
+
frontstageDef.nineZoneState = showWidget(frontstageDef.nineZoneState, widgetDef.id);
|
|
1026
1063
|
});
|
|
1027
1064
|
FrontstageManager_1.FrontstageManager.onWidgetShowEvent.addListener(listener);
|
|
1028
1065
|
return () => {
|
|
@@ -1032,8 +1069,8 @@ function useFrontstageManager(frontstageDef, useToolAsToolSettingsLabel) {
|
|
|
1032
1069
|
React.useEffect(() => {
|
|
1033
1070
|
const listener = createListener(frontstageDef, ({ widgetDef }) => {
|
|
1034
1071
|
(0, core_bentley_1.assert)(!!frontstageDef.nineZoneState);
|
|
1035
|
-
let nineZoneState =
|
|
1036
|
-
nineZoneState =
|
|
1072
|
+
let nineZoneState = showWidget(frontstageDef.nineZoneState, widgetDef.id);
|
|
1073
|
+
nineZoneState = expandWidget(nineZoneState, widgetDef.id);
|
|
1037
1074
|
frontstageDef.nineZoneState = nineZoneState;
|
|
1038
1075
|
});
|
|
1039
1076
|
FrontstageManager_1.FrontstageManager.onWidgetExpandEvent.addListener(listener);
|
|
@@ -1062,7 +1099,7 @@ function useFrontstageManager(frontstageDef, useToolAsToolSettingsLabel) {
|
|
|
1062
1099
|
const listener = createListener(frontstageDef, ({ widgetDef }) => {
|
|
1063
1100
|
(0, core_bentley_1.assert)(!!frontstageDef.nineZoneState);
|
|
1064
1101
|
const label = widgetDef.label;
|
|
1065
|
-
frontstageDef.nineZoneState =
|
|
1102
|
+
frontstageDef.nineZoneState = setWidgetLabel(frontstageDef.nineZoneState, widgetDef.id, label);
|
|
1066
1103
|
});
|
|
1067
1104
|
FrontstageManager_1.FrontstageManager.onWidgetLabelChangedEvent.addListener(listener);
|
|
1068
1105
|
return () => {
|
|
@@ -1077,7 +1114,7 @@ function useFrontstageManager(frontstageDef, useToolAsToolSettingsLabel) {
|
|
|
1077
1114
|
(0, core_bentley_1.assert)(!!frontstageDef.nineZoneState);
|
|
1078
1115
|
const label = useToolAsToolSettingsLabel ?
|
|
1079
1116
|
((_a = core_frontend_1.IModelApp.tools.find(toolId)) === null || _a === void 0 ? void 0 : _a.flyover) || defaultLabel : defaultLabel;
|
|
1080
|
-
frontstageDef.nineZoneState =
|
|
1117
|
+
frontstageDef.nineZoneState = setWidgetLabel(frontstageDef.nineZoneState, appui_layout_react_1.toolSettingsTabId, label);
|
|
1081
1118
|
});
|
|
1082
1119
|
// Whenever the frontstageDef or the useTool... changes, keep the label up to date.
|
|
1083
1120
|
updateLabel();
|
|
@@ -1110,7 +1147,7 @@ function useItemsManager(frontstageDef) {
|
|
|
1110
1147
|
return;
|
|
1111
1148
|
state = addMissingWidgets(def, state);
|
|
1112
1149
|
state = removeMissingWidgets(def, state);
|
|
1113
|
-
state =
|
|
1150
|
+
state = hideWidgets(state, def); // TODO: should only apply to widgets provided by registered provider in onUiProviderRegisteredEvent.
|
|
1114
1151
|
def.nineZoneState = state;
|
|
1115
1152
|
};
|
|
1116
1153
|
React.useEffect(() => {
|
|
@@ -1124,48 +1161,8 @@ function useItemsManager(frontstageDef) {
|
|
|
1124
1161
|
}, [frontstageDef]);
|
|
1125
1162
|
}
|
|
1126
1163
|
exports.useItemsManager = useItemsManager;
|
|
1127
|
-
function tabShownInCurrentWidget(def, state) {
|
|
1128
|
-
for (const [, widget] of Object.entries(state.widgets)) {
|
|
1129
|
-
const foundTab = widget.tabs.find((tabId) => tabId === def.id);
|
|
1130
|
-
// istanbul ignore else
|
|
1131
|
-
if (foundTab)
|
|
1132
|
-
return true;
|
|
1133
|
-
}
|
|
1134
|
-
return false;
|
|
1135
|
-
}
|
|
1136
1164
|
// istanbul ignore next
|
|
1137
1165
|
function determineNewWidgets(defs, state) {
|
|
1138
|
-
|
|
1139
|
-
return (defs || []).filter((def) => !(def.id in state.tabs) || !tabShownInCurrentWidget(def, state));
|
|
1140
|
-
}
|
|
1141
|
-
/** @internal */
|
|
1142
|
-
async function saveFrontstagePopoutWidgetSizeAndPosition(state, stageId, stageVersion, childWindowId, childWindow) {
|
|
1143
|
-
const location = (0, appui_layout_react_1.findWidget)(state, childWindowId);
|
|
1144
|
-
// istanbul ignore else
|
|
1145
|
-
if (location) {
|
|
1146
|
-
const adjustmentWidth = core_bentley_1.ProcessDetector.isElectronAppFrontend ? 16 : 0;
|
|
1147
|
-
const adjustmentHeight = core_bentley_1.ProcessDetector.isElectronAppFrontend ? 39 : 0;
|
|
1148
|
-
const newState = (0, immer_1.default)(state, (draft) => {
|
|
1149
|
-
const widget = draft.widgets[childWindowId];
|
|
1150
|
-
const tab = draft.tabs[widget.activeTabId];
|
|
1151
|
-
tab.preferredPopoutWidgetSize = {
|
|
1152
|
-
x: childWindow.screenX,
|
|
1153
|
-
y: childWindow.screenY,
|
|
1154
|
-
width: childWindow.innerWidth + adjustmentWidth,
|
|
1155
|
-
height: childWindow.innerHeight + adjustmentHeight,
|
|
1156
|
-
};
|
|
1157
|
-
});
|
|
1158
|
-
const setting = {
|
|
1159
|
-
id: stageId,
|
|
1160
|
-
nineZone: packNineZoneState(newState),
|
|
1161
|
-
stateVersion,
|
|
1162
|
-
version: stageVersion,
|
|
1163
|
-
};
|
|
1164
|
-
await UiFramework_1.UiFramework.getUiStateStorage().saveSetting(exports.FRONTSTAGE_SETTINGS_NAMESPACE, getFrontstageStateSettingName(stageId), setting);
|
|
1165
|
-
return newState;
|
|
1166
|
-
}
|
|
1167
|
-
// istanbul ignore next
|
|
1168
|
-
return state;
|
|
1166
|
+
return (defs || []).filter((def) => !(def.id in state.tabs));
|
|
1169
1167
|
}
|
|
1170
|
-
exports.saveFrontstagePopoutWidgetSizeAndPosition = saveFrontstagePopoutWidgetSizeAndPosition;
|
|
1171
1168
|
//# sourceMappingURL=Frontstage.js.map
|