@babylonjs/gui-editor 5.0.0-alpha.65 → 5.0.0-beta.1

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.
@@ -44976,7 +44976,7 @@ var PropertyTabComponent = /** @class */ (function (_super) {
44976
44976
  if (windowAsAny.Playground && oldId) {
44977
44977
  windowAsAny.Playground.onRequestCodeChangeObservable.notifyObservers({
44978
44978
  regex: new RegExp(oldId, "g"),
44979
- replace: "parseFromSnippetAsync(\"" + adt.snippetId,
44979
+ replace: "parseFromSnippetAsync(\"" + adt.snippetId + ")",
44980
44980
  });
44981
44981
  }
44982
44982
  resolve(adt.snippetId);
@@ -45011,8 +45011,8 @@ var PropertyTabComponent = /** @class */ (function (_super) {
45011
45011
  .then(function (snippetId) {
45012
45012
  adt.snippetId = snippetId;
45013
45013
  var alertMessage = "GUI saved with ID: " + adt.snippetId;
45014
- if (navigator.clipboard) {
45015
- navigator.clipboard
45014
+ if (_this.props.globalState.hostWindow.navigator.clipboard) {
45015
+ _this.props.globalState.hostWindow.navigator.clipboard
45016
45016
  .writeText(adt.snippetId)
45017
45017
  .then(function () {
45018
45018
  _this.props.globalState.hostWindow.alert(alertMessage + ". The ID was copied to your clipboard.");
@@ -47823,6 +47823,7 @@ var GuiGizmoComponent = /** @class */ (function (_super) {
47823
47823
  if (_this._responsive) {
47824
47824
  _this.props.globalState.workbench.convertToPercentage(node, false);
47825
47825
  }
47826
+ _this.props.globalState.workbench._liveGuiTextureRerender = false;
47826
47827
  _this.props.globalState.onPropertyGridUpdateRequiredObservable.notifyObservers();
47827
47828
  }
47828
47829
  }
@@ -48095,7 +48096,17 @@ var GuiGizmoComponent = /** @class */ (function (_super) {
48095
48096
  var _this = this;
48096
48097
  var _a, _b;
48097
48098
  // Get the canvas element from the DOM.
48098
- var canvas = document.getElementById("workbench-canvas");
48099
+ var canvas = this.props.globalState.hostDocument.getElementById("workbench-canvas");
48100
+ var scalePointCursors = [
48101
+ "nesw-resize",
48102
+ "nwse-resize",
48103
+ "nesw-resize",
48104
+ "nwse-resize",
48105
+ "ew-resize",
48106
+ "ns-resize",
48107
+ "ew-resize",
48108
+ "ns-resize"
48109
+ ];
48099
48110
  var _loop_1 = function (i) {
48100
48111
  var scalePoint = canvas.ownerDocument.createElement("div");
48101
48112
  scalePoint.className = "ge-scalePoint";
@@ -48105,6 +48116,7 @@ var GuiGizmoComponent = /** @class */ (function (_super) {
48105
48116
  scalePoint.style.left = i * 100 + "px";
48106
48117
  scalePoint.style.top = i * 100 + "px";
48107
48118
  scalePoint.style.transform = "translate(-50%, -50%)";
48119
+ scalePoint.style.cursor = scalePointCursors[i];
48108
48120
  scalePoint.addEventListener("pointerdown", function () {
48109
48121
  _this._setMousePosition(i);
48110
48122
  });
@@ -48338,6 +48350,7 @@ var WorkbenchComponent = /** @class */ (function (_super) {
48338
48350
  _this._selectionDepth = 0;
48339
48351
  _this._doubleClick = null;
48340
48352
  _this._lockMainSelection = false;
48353
+ _this._liveGuiTextureRerender = true;
48341
48354
  _this.keyEvent = function (evt) {
48342
48355
  _this._ctrlKeyIsPressed = evt.ctrlKey;
48343
48356
  _this._altKeyIsPressed = evt.altKey;
@@ -48922,6 +48935,7 @@ var WorkbenchComponent = /** @class */ (function (_super) {
48922
48935
  };
48923
48936
  WorkbenchComponent.prototype._onMove = function (guiControl, evt, startPos, ignorClick) {
48924
48937
  if (ignorClick === void 0) { ignorClick = false; }
48938
+ this._liveGuiTextureRerender = false;
48925
48939
  var newX = evt.x - startPos.x;
48926
48940
  var newY = evt.y - startPos.y;
48927
48941
  if (this._setConstraintDirection) {
@@ -49092,18 +49106,17 @@ var WorkbenchComponent = /** @class */ (function (_super) {
49092
49106
  // also, every time *we* re-render (due to a change in the GUI), we must re-render the original ADT
49093
49107
  // to prevent an infite loop, we flip a boolean flag
49094
49108
  if (this.globalState.liveGuiTexture) {
49095
- var doRerender_1 = true;
49096
49109
  this._guiRenderObserver = this.globalState.guiTexture.onBeginRenderObservable.add(function () {
49097
49110
  var _a;
49098
- if (doRerender_1) {
49111
+ if (_this._liveGuiTextureRerender) {
49099
49112
  (_a = _this.globalState.liveGuiTexture) === null || _a === void 0 ? void 0 : _a.markAsDirty();
49100
49113
  }
49101
- doRerender_1 = true;
49114
+ _this._liveGuiTextureRerender = true;
49102
49115
  });
49103
49116
  this._liveRenderObserver = this.globalState.liveGuiTexture.onEndRenderObservable.add(function () {
49104
49117
  var _a;
49105
49118
  (_a = _this.globalState.guiTexture) === null || _a === void 0 ? void 0 : _a.markAsDirty();
49106
- doRerender_1 = false;
49119
+ _this._liveGuiTextureRerender = false;
49107
49120
  });
49108
49121
  }
49109
49122
  this.props.globalState.onErrorMessageDialogRequiredObservable.notifyObservers("Welcome to the GUI Editor Alpha. This editor is still a work in progress. Icons are currently temporary. Please submit feedback using the \"Give feedback\" button in the menu. ");
@@ -49117,12 +49130,13 @@ var WorkbenchComponent = /** @class */ (function (_super) {
49117
49130
  WorkbenchComponent.prototype.synchronizeLiveGUI = function () {
49118
49131
  var _this = this;
49119
49132
  if (this.globalState.liveGuiTexture) {
49120
- this.props.globalState.guiTexture._rootContainer.getDescendants().filter(function (desc) { return desc.name !== "Art-Board-Background"; }).forEach(function (desc) { return desc.dispose(); });
49133
+ this.globalState.guiTexture._rootContainer.getDescendants().filter(function (desc) { return desc.name !== "Art-Board-Background"; }).forEach(function (desc) { return desc.dispose(); });
49121
49134
  this.globalState.liveGuiTexture.rootContainer.getDescendants(true).forEach(function (desc) {
49122
49135
  var _a;
49123
49136
  (_a = _this.globalState.liveGuiTexture) === null || _a === void 0 ? void 0 : _a.removeControl(desc);
49124
49137
  _this.appendBlock(desc);
49125
49138
  });
49139
+ this.globalState.guiTexture.snippetId = this.globalState.liveGuiTexture.snippetId;
49126
49140
  }
49127
49141
  };
49128
49142
  //Add map-like controls to an ArcRotate camera
@@ -49457,15 +49471,13 @@ var GUIEditor = /** @class */ (function () {
49457
49471
  */
49458
49472
  GUIEditor.Show = function (options) {
49459
49473
  return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"])(this, void 0, void 0, function () {
49460
- var popupWindow, hostElement, globalState, graphEditor, error_1, popupWindow;
49474
+ var hostElement, popupWindow, globalState, graphEditor, error_1, popupWindow;
49461
49475
  return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__generator"])(this, function (_a) {
49462
49476
  switch (_a.label) {
49463
49477
  case 0:
49464
- if (this._CurrentState) {
49465
- popupWindow = _sharedUiComponents_lines_popup__WEBPACK_IMPORTED_MODULE_5__["Popup"]["gui-editor"];
49466
- if (popupWindow) {
49467
- popupWindow.close();
49468
- }
49478
+ hostElement = options.hostElement;
49479
+ // if we are in a standalone window and we have some current state, just load the GUI from the snippet server, don't do anything else
49480
+ if (this._CurrentState && hostElement) {
49469
49481
  if (options.currentSnippetToken) {
49470
49482
  try {
49471
49483
  this._CurrentState.workbench.loadFromSnippet(options.currentSnippetToken);
@@ -49474,13 +49486,13 @@ var GUIEditor = /** @class */ (function () {
49474
49486
  //swallow and continue
49475
49487
  }
49476
49488
  }
49477
- if (options.liveGuiTexture) {
49478
- this._CurrentState.liveGuiTexture = options.liveGuiTexture;
49479
- }
49480
49489
  return [2 /*return*/];
49481
49490
  }
49482
- hostElement = options.hostElement;
49483
49491
  if (!hostElement) {
49492
+ popupWindow = _sharedUiComponents_lines_popup__WEBPACK_IMPORTED_MODULE_5__["Popup"]["gui-editor"];
49493
+ if (popupWindow) {
49494
+ popupWindow.close();
49495
+ }
49484
49496
  hostElement = _sharedUiComponents_lines_popup__WEBPACK_IMPORTED_MODULE_5__["Popup"].CreatePopup("BABYLON.JS GUI EDITOR", "gui-editor", 1200, 800);
49485
49497
  }
49486
49498
  globalState = new _globalState__WEBPACK_IMPORTED_MODULE_3__["GlobalState"]();