@wcardinal/wcardinal-ui 0.157.0 → 0.158.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.
Files changed (70) hide show
  1. package/dist/types/wcardinal/ui/d-application-layer-like.d.ts +0 -1
  2. package/dist/types/wcardinal/ui/d-application-layer.d.ts +0 -2
  3. package/dist/types/wcardinal/ui/d-base.d.ts +11 -12
  4. package/dist/types/wcardinal/ui/d-diagram-snapshot.d.ts +0 -2
  5. package/dist/types/wcardinal/ui/d-image-base.d.ts +2 -0
  6. package/dist/types/wcardinal/ui/d-image-piece-layouter-part-bottom.d.ts +4 -0
  7. package/dist/types/wcardinal/ui/d-image-piece-layouter-part-center.d.ts +6 -0
  8. package/dist/types/wcardinal/ui/d-image-piece-layouter-part-container.d.ts +25 -0
  9. package/dist/types/wcardinal/ui/d-image-piece-layouter-part-left.d.ts +4 -0
  10. package/dist/types/wcardinal/ui/d-image-piece-layouter-part-middle.d.ts +6 -0
  11. package/dist/types/wcardinal/ui/d-image-piece-layouter-part-right.d.ts +4 -0
  12. package/dist/types/wcardinal/ui/d-image-piece-layouter-part-top.d.ts +4 -0
  13. package/dist/types/wcardinal/ui/d-image-piece-layouter-part.d.ts +8 -0
  14. package/dist/types/wcardinal/ui/d-image-piece-layouter.d.ts +17 -0
  15. package/dist/types/wcardinal/ui/d-menu-sided.d.ts +1 -1
  16. package/dist/types/wcardinal/ui/d-text-base.d.ts +5 -5
  17. package/dist/types/wcardinal/ui/theme/dark/d-theme-dark-input.d.ts +1 -1
  18. package/dist/types/wcardinal/ui/theme/white/d-theme-white-input.d.ts +1 -1
  19. package/dist/wcardinal/ui/d-application-layer-like.js.map +1 -1
  20. package/dist/wcardinal/ui/d-application-layer.js +3 -21
  21. package/dist/wcardinal/ui/d-application-layer.js.map +1 -1
  22. package/dist/wcardinal/ui/d-base.js +126 -100
  23. package/dist/wcardinal/ui/d-base.js.map +1 -1
  24. package/dist/wcardinal/ui/d-diagram-snapshot.js +2 -18
  25. package/dist/wcardinal/ui/d-diagram-snapshot.js.map +1 -1
  26. package/dist/wcardinal/ui/d-html-element.js +0 -3
  27. package/dist/wcardinal/ui/d-html-element.js.map +1 -1
  28. package/dist/wcardinal/ui/d-image-base.js +9 -264
  29. package/dist/wcardinal/ui/d-image-base.js.map +1 -1
  30. package/dist/wcardinal/ui/d-image-piece-layouter-part-bottom.js +31 -0
  31. package/dist/wcardinal/ui/d-image-piece-layouter-part-bottom.js.map +1 -0
  32. package/dist/wcardinal/ui/d-image-piece-layouter-part-center.js +24 -0
  33. package/dist/wcardinal/ui/d-image-piece-layouter-part-center.js.map +1 -0
  34. package/dist/wcardinal/ui/d-image-piece-layouter-part-container.js +158 -0
  35. package/dist/wcardinal/ui/d-image-piece-layouter-part-container.js.map +1 -0
  36. package/dist/wcardinal/ui/d-image-piece-layouter-part-left.js +30 -0
  37. package/dist/wcardinal/ui/d-image-piece-layouter-part-left.js.map +1 -0
  38. package/dist/wcardinal/ui/d-image-piece-layouter-part-middle.js +24 -0
  39. package/dist/wcardinal/ui/d-image-piece-layouter-part-middle.js.map +1 -0
  40. package/dist/wcardinal/ui/d-image-piece-layouter-part-right.js +31 -0
  41. package/dist/wcardinal/ui/d-image-piece-layouter-part-right.js.map +1 -0
  42. package/dist/wcardinal/ui/d-image-piece-layouter-part-top.js +32 -0
  43. package/dist/wcardinal/ui/d-image-piece-layouter-part-top.js.map +1 -0
  44. package/dist/wcardinal/ui/d-image-piece-layouter-part.js +18 -0
  45. package/dist/wcardinal/ui/d-image-piece-layouter-part.js.map +1 -0
  46. package/dist/wcardinal/ui/d-image-piece-layouter.js +65 -0
  47. package/dist/wcardinal/ui/d-image-piece-layouter.js.map +1 -0
  48. package/dist/wcardinal/ui/d-menu-item-text.js +18 -2
  49. package/dist/wcardinal/ui/d-menu-item-text.js.map +1 -1
  50. package/dist/wcardinal/ui/d-menu-sided.js +2 -2
  51. package/dist/wcardinal/ui/d-menu-sided.js.map +1 -1
  52. package/dist/wcardinal/ui/d-text-base.js +34 -24
  53. package/dist/wcardinal/ui/d-text-base.js.map +1 -1
  54. package/dist/wcardinal/ui/theme/dark/d-theme-dark-input.js +2 -2
  55. package/dist/wcardinal/ui/theme/dark/d-theme-dark-input.js.map +1 -1
  56. package/dist/wcardinal/ui/theme/white/d-theme-white-input.js +2 -2
  57. package/dist/wcardinal/ui/theme/white/d-theme-white-input.js.map +1 -1
  58. package/dist/wcardinal/ui/util/dynamic-font-atlas-font.js +3 -1
  59. package/dist/wcardinal/ui/util/dynamic-font-atlas-font.js.map +1 -1
  60. package/dist/wcardinal-ui-theme-dark.js +3 -3
  61. package/dist/wcardinal-ui-theme-dark.min.js +2 -2
  62. package/dist/wcardinal-ui-theme-dark.min.js.map +1 -1
  63. package/dist/wcardinal-ui-theme-white.js +3 -3
  64. package/dist/wcardinal-ui-theme-white.min.js +2 -2
  65. package/dist/wcardinal-ui-theme-white.min.js.map +1 -1
  66. package/dist/wcardinal-ui.cjs.js +613 -467
  67. package/dist/wcardinal-ui.js +609 -463
  68. package/dist/wcardinal-ui.min.js +2 -2
  69. package/dist/wcardinal-ui.min.js.map +1 -1
  70. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.157.0
2
+ Winter Cardinal UI v0.158.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -12159,7 +12159,7 @@
12159
12159
  _this._auto = new DBaseAutoSet();
12160
12160
  _this._isDirty = true;
12161
12161
  _this._hasDirty = false;
12162
- _this._isChildrenDirty = false;
12162
+ _this._isHierarchyDirty = false;
12163
12163
  _this._shadow = null;
12164
12164
  _this.name = (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : "";
12165
12165
  var theme = toTheme(options) || _this.getThemeDefault();
@@ -12169,7 +12169,7 @@
12169
12169
  _this._clearType = toEnum((_b = options === null || options === void 0 ? void 0 : options.clear) !== null && _b !== void 0 ? _b : theme.getClearType(), DLayoutClearType);
12170
12170
  _this._padding = new DBasePadding(theme, options, function () {
12171
12171
  _this.toParentResized();
12172
- _this.toChildrenDirty();
12172
+ _this.toHierarchyDirty();
12173
12173
  DApplications.update(_this);
12174
12174
  });
12175
12175
  var toDirtyAndUpdate = function () {
@@ -12298,8 +12298,8 @@
12298
12298
  if (_this.isDirty() || _this.hasDirty()) {
12299
12299
  _this.toParentHasDirty();
12300
12300
  }
12301
- if (_this._isChildrenDirty) {
12302
- _this.toParentChildrenDirty();
12301
+ if (_this._isHierarchyDirty) {
12302
+ _this.toParentHierarchyDirty();
12303
12303
  }
12304
12304
  var newParent = _this.parent;
12305
12305
  if (newParent instanceof DBase) {
@@ -12391,7 +12391,7 @@
12391
12391
  new DBaseReflowableImpl(this);
12392
12392
  };
12393
12393
  DBase.prototype.onChildrenChange = function () {
12394
- this.toChildrenDirty();
12394
+ this.toHierarchyDirty();
12395
12395
  _super.prototype.onChildrenChange.call(this);
12396
12396
  };
12397
12397
  DBase.prototype.onShortcut = function (e) {
@@ -12421,46 +12421,48 @@
12421
12421
  DBase.prototype.resize = function (width, height) {
12422
12422
  var oldWidth = this._width;
12423
12423
  var oldHeight = this._height;
12424
- var widthResized = oldWidth !== width;
12425
- var heightResized = oldHeight !== height;
12426
- if (widthResized) {
12427
- this._width = width;
12424
+ var newWidth = width != null ? width : oldWidth;
12425
+ var newHeight = height != null ? height : oldHeight;
12426
+ var isWidthChanged = oldWidth !== newWidth;
12427
+ var isHeightChanged = oldHeight !== newHeight;
12428
+ if (isWidthChanged) {
12429
+ this._width = newWidth;
12428
12430
  }
12429
- if (heightResized) {
12430
- this._height = height;
12431
+ if (isHeightChanged) {
12432
+ this._height = newHeight;
12431
12433
  }
12432
- var resized = widthResized || heightResized;
12433
- if (resized) {
12434
- this.onResize(width, height, oldWidth, oldHeight);
12434
+ var isChanged = isWidthChanged || isHeightChanged;
12435
+ if (isChanged) {
12436
+ this.onResize(newWidth, newHeight, oldWidth, oldHeight);
12435
12437
  }
12436
- if (widthResized) {
12438
+ if (isWidthChanged) {
12437
12439
  var scalarSet = this._scalarSet;
12438
12440
  if (scalarSet.x != null) {
12439
- var position = this.transform.position;
12441
+ var position = this._position;
12440
12442
  var parent_1 = this.getParentOfSize();
12441
12443
  if (parent_1) {
12442
- this.x = scalarSet.x(parent_1.width, width, parent_1.padding.getLeft(), position.x);
12444
+ this._position.x = scalarSet.x(parent_1.width, newWidth, parent_1.padding.getLeft(), position.x);
12443
12445
  }
12444
12446
  }
12445
12447
  }
12446
- if (heightResized) {
12448
+ if (isHeightChanged) {
12447
12449
  var scalarSet = this._scalarSet;
12448
12450
  if (scalarSet.y != null) {
12449
- var position = this.transform.position;
12451
+ var position = this._position;
12450
12452
  var parent_2 = this.getParentOfSize();
12451
12453
  if (parent_2) {
12452
- this.y = scalarSet.y(parent_2.height, height, parent_2.padding.getTop(), position.y);
12454
+ this._position.y = scalarSet.y(parent_2.height, newHeight, parent_2.padding.getTop(), position.y);
12453
12455
  }
12454
12456
  }
12455
12457
  }
12456
- return resized;
12458
+ return isChanged;
12457
12459
  };
12458
12460
  DBase.prototype.getClearType = function () {
12459
12461
  return this._clearType;
12460
12462
  };
12461
12463
  DBase.prototype.onResize = function (newWidth, newHeight, oldWidth, oldHeight) {
12462
12464
  this.toDirty();
12463
- this.toChildrenDirty();
12465
+ this.toHierarchyDirty();
12464
12466
  var padding = this._padding;
12465
12467
  var children = this.children;
12466
12468
  for (var i = 0, imax = children.length; i < imax; ++i) {
@@ -12493,7 +12495,7 @@
12493
12495
  return this._position.x;
12494
12496
  },
12495
12497
  set: function (x) {
12496
- this._position.x = x;
12498
+ this.setX(x);
12497
12499
  },
12498
12500
  enumerable: false,
12499
12501
  configurable: true
@@ -12504,15 +12506,25 @@
12504
12506
  return scalarSet.x;
12505
12507
  }
12506
12508
  else {
12507
- return this.x;
12509
+ return this._position.x;
12508
12510
  }
12509
12511
  };
12510
12512
  DBase.prototype.setX = function (x) {
12513
+ var scalarSet = this._scalarSet;
12511
12514
  if (isNumber(x)) {
12512
- this.x = x;
12515
+ var position = this._position;
12516
+ if (position.x !== x) {
12517
+ scalarSet.x = undefined;
12518
+ position.x = x;
12519
+ }
12520
+ else {
12521
+ if (scalarSet.x !== undefined) {
12522
+ scalarSet.x = undefined;
12523
+ this.toParentResized();
12524
+ }
12525
+ }
12513
12526
  }
12514
12527
  else {
12515
- var scalarSet = this._scalarSet;
12516
12528
  var scalar = DScalarFunctions.position(x);
12517
12529
  if (scalarSet.x !== scalar) {
12518
12530
  scalarSet.x = scalar;
@@ -12526,7 +12538,7 @@
12526
12538
  return this._position.y;
12527
12539
  },
12528
12540
  set: function (y) {
12529
- this._position.y = y;
12541
+ this.setY(y);
12530
12542
  },
12531
12543
  enumerable: false,
12532
12544
  configurable: true
@@ -12537,15 +12549,25 @@
12537
12549
  return scalarSet.y;
12538
12550
  }
12539
12551
  else {
12540
- return this.y;
12552
+ return this._position.y;
12541
12553
  }
12542
12554
  };
12543
12555
  DBase.prototype.setY = function (y) {
12556
+ var scalarSet = this._scalarSet;
12544
12557
  if (isNumber(y)) {
12545
- this.y = y;
12558
+ var position = this._position;
12559
+ if (position.y !== y) {
12560
+ scalarSet.y = undefined;
12561
+ position.y = y;
12562
+ }
12563
+ else {
12564
+ if (scalarSet.y !== undefined) {
12565
+ scalarSet.y = undefined;
12566
+ this.toParentResized();
12567
+ }
12568
+ }
12546
12569
  }
12547
12570
  else {
12548
- var scalarSet = this._scalarSet;
12549
12571
  var scalar = DScalarFunctions.position(y);
12550
12572
  if (scalarSet.y !== scalar) {
12551
12573
  scalarSet.y = scalar;
@@ -12559,21 +12581,7 @@
12559
12581
  return this._width;
12560
12582
  },
12561
12583
  set: function (width) {
12562
- var oldWidth = this._width;
12563
- if (oldWidth !== width) {
12564
- this._width = width;
12565
- var height = this._height;
12566
- this.onResize(width, height, oldWidth, height);
12567
- // Layout
12568
- var scalarSet = this._scalarSet;
12569
- if (scalarSet.x != null) {
12570
- var position = this.transform.position;
12571
- var parent_3 = this.getParentOfSize();
12572
- if (parent_3) {
12573
- this.x = scalarSet.x(parent_3.width, width, parent_3.padding.getLeft(), position.x);
12574
- }
12575
- }
12576
- }
12584
+ this.setWidth(width);
12577
12585
  },
12578
12586
  enumerable: false,
12579
12587
  configurable: true
@@ -12586,15 +12594,34 @@
12586
12594
  var isOn = auto.isOn;
12587
12595
  var isAuto = auto.from(width);
12588
12596
  if (auto.isOn !== isOn) {
12589
- this.toChildrenDirty();
12597
+ this.toHierarchyDirty();
12590
12598
  DApplications.update(this);
12591
12599
  }
12592
12600
  if (!isAuto) {
12601
+ var scalarSet = this._scalarSet;
12593
12602
  if (isNumber(width)) {
12594
- this.width = width;
12603
+ var oldWidth = this._width;
12604
+ if (oldWidth !== width) {
12605
+ scalarSet.width = undefined;
12606
+ this._width = width;
12607
+ var height = this._height;
12608
+ this.onResize(width, height, oldWidth, height);
12609
+ if (scalarSet.x != null) {
12610
+ var position = this._position;
12611
+ var parent_3 = this.getParentOfSize();
12612
+ if (parent_3) {
12613
+ position.x = scalarSet.x(parent_3.width, width, parent_3.padding.getLeft(), position.x);
12614
+ }
12615
+ }
12616
+ }
12617
+ else {
12618
+ if (scalarSet.width !== undefined) {
12619
+ scalarSet.width = undefined;
12620
+ this.toParentResized();
12621
+ }
12622
+ }
12595
12623
  }
12596
12624
  else {
12597
- var scalarSet = this._scalarSet;
12598
12625
  var scalar = DScalarFunctions.size(width);
12599
12626
  if (scalarSet.width !== scalar) {
12600
12627
  scalarSet.width = scalar;
@@ -12609,21 +12636,7 @@
12609
12636
  return this._height;
12610
12637
  },
12611
12638
  set: function (height) {
12612
- var oldHeight = this._height;
12613
- if (oldHeight !== height) {
12614
- this._height = height;
12615
- var width = this._width;
12616
- this.onResize(width, height, width, oldHeight);
12617
- // Layout
12618
- var scalarSet = this._scalarSet;
12619
- if (scalarSet.y != null) {
12620
- var position = this.transform.position;
12621
- var parent_4 = this.getParentOfSize();
12622
- if (parent_4) {
12623
- this.y = scalarSet.y(parent_4.height, height, parent_4.padding.getTop(), position.y);
12624
- }
12625
- }
12626
- }
12639
+ this.setHeight(height);
12627
12640
  },
12628
12641
  enumerable: false,
12629
12642
  configurable: true
@@ -12636,15 +12649,34 @@
12636
12649
  var isOn = auto.isOn;
12637
12650
  var isAuto = auto.from(height);
12638
12651
  if (auto.isOn !== isOn) {
12639
- this.toChildrenDirty();
12652
+ this.toHierarchyDirty();
12640
12653
  DApplications.update(this);
12641
12654
  }
12642
12655
  if (!isAuto) {
12656
+ var scalarSet = this._scalarSet;
12643
12657
  if (isNumber(height)) {
12644
- this.height = height;
12658
+ var oldHeight = this._height;
12659
+ if (oldHeight !== height) {
12660
+ scalarSet.height = undefined;
12661
+ this._height = height;
12662
+ var width = this._width;
12663
+ this.onResize(width, height, width, oldHeight);
12664
+ if (scalarSet.y != null) {
12665
+ var position = this._position;
12666
+ var parent_4 = this.getParentOfSize();
12667
+ if (parent_4) {
12668
+ position.y = scalarSet.y(parent_4.height, height, parent_4.padding.getTop(), position.y);
12669
+ }
12670
+ }
12671
+ }
12672
+ else {
12673
+ if (scalarSet.height !== undefined) {
12674
+ scalarSet.height = undefined;
12675
+ this.toParentResized();
12676
+ }
12677
+ }
12645
12678
  }
12646
12679
  else {
12647
- var scalarSet = this._scalarSet;
12648
12680
  var scalar = DScalarFunctions.size(height);
12649
12681
  if (scalarSet.height !== scalar) {
12650
12682
  scalarSet.height = scalar;
@@ -12743,7 +12775,7 @@
12743
12775
  DBase.prototype.show = function () {
12744
12776
  if (!this.visible) {
12745
12777
  this.visible = true;
12746
- this.toParentChildrenDirty();
12778
+ this.toParentHierarchyDirty();
12747
12779
  DApplications.update(this);
12748
12780
  }
12749
12781
  return this;
@@ -12754,7 +12786,7 @@
12754
12786
  DBase.prototype.hide = function () {
12755
12787
  if (this.visible) {
12756
12788
  this.visible = false;
12757
- this.toParentChildrenDirty();
12789
+ this.toParentHierarchyDirty();
12758
12790
  this.blur(true);
12759
12791
  DApplications.update(this);
12760
12792
  }
@@ -12785,25 +12817,25 @@
12785
12817
  parent.toHasDirty();
12786
12818
  }
12787
12819
  };
12788
- DBase.prototype.toChildrenDirty = function () {
12789
- if (!this._isChildrenDirty) {
12790
- this._isChildrenDirty = true;
12791
- this.onChildrenDirty();
12792
- this.toParentChildrenDirty();
12820
+ DBase.prototype.toHierarchyDirty = function () {
12821
+ if (!this._isHierarchyDirty) {
12822
+ this._isHierarchyDirty = true;
12823
+ this.onHierarchyDirty();
12824
+ this.toParentHierarchyDirty();
12793
12825
  return true;
12794
12826
  }
12795
12827
  return false;
12796
12828
  };
12797
- DBase.prototype.toParentChildrenDirty = function () {
12829
+ DBase.prototype.toParentHierarchyDirty = function () {
12798
12830
  var parent = this.parent;
12799
12831
  if (parent instanceof DBase) {
12800
- parent.toChildrenDirty();
12832
+ parent.toHierarchyDirty();
12801
12833
  }
12802
12834
  };
12803
- DBase.prototype.isChildrenDirty = function () {
12804
- return this._isChildrenDirty;
12835
+ DBase.prototype.isHierarchyDirty = function () {
12836
+ return this._isHierarchyDirty;
12805
12837
  };
12806
- DBase.prototype.onChildrenDirty = function () {
12838
+ DBase.prototype.onHierarchyDirty = function () {
12807
12839
  // DO NOTHING
12808
12840
  };
12809
12841
  DBase.prototype.isDirty = function () {
@@ -12919,16 +12951,26 @@
12919
12951
  enumerable: false,
12920
12952
  configurable: true
12921
12953
  });
12922
- DBase.prototype.refit = function () {
12923
- if (this._isChildrenDirty) {
12924
- this._isChildrenDirty = false;
12954
+ DBase.prototype.reflow = function () {
12955
+ var isDirty = this._isDirty;
12956
+ if (isDirty) {
12957
+ this.onReflow();
12958
+ this._isDirty = false;
12959
+ }
12960
+ var hasDirty = this._hasDirty;
12961
+ var isHierarchyDirty = this._isHierarchyDirty;
12962
+ if (hasDirty || isHierarchyDirty) {
12963
+ this._hasDirty = false;
12964
+ this._isHierarchyDirty = false;
12925
12965
  var children = this.children;
12926
12966
  for (var i = 0, imax = children.length; i < imax; ++i) {
12927
12967
  var child = children[i];
12928
12968
  if (child instanceof DBase) {
12929
- child.refit();
12969
+ child.reflow();
12930
12970
  }
12931
12971
  }
12972
+ }
12973
+ if (isDirty || hasDirty || isHierarchyDirty) {
12932
12974
  this.onRefit();
12933
12975
  }
12934
12976
  };
@@ -12963,7 +13005,7 @@
12963
13005
  width = Math.max(width, child.x + child.width);
12964
13006
  }
12965
13007
  }
12966
- this.width = width + this.padding.getRight();
13008
+ this.resize(width + this.padding.getRight(), undefined);
12967
13009
  }
12968
13010
  else if (isHeightAuto) {
12969
13011
  var height = 0;
@@ -12974,7 +13016,7 @@
12974
13016
  height = Math.max(height, child.y + child.height);
12975
13017
  }
12976
13018
  }
12977
- this.height = height + this.padding.getBottom();
13019
+ this.resize(undefined, height + this.padding.getBottom());
12978
13020
  }
12979
13021
  };
12980
13022
  DBase.prototype.isRefitable = function (target) {
@@ -12986,22 +13028,6 @@
12986
13028
  DBase.prototype.hasRefitableWidth = function (target) {
12987
13029
  return (this.isRefitable(target) && !(target instanceof DBase && isFunction(target.getWidth())));
12988
13030
  };
12989
- DBase.prototype.reflow = function () {
12990
- if (this._isDirty) {
12991
- this.onReflow();
12992
- this._isDirty = false;
12993
- }
12994
- if (this._hasDirty) {
12995
- var children = this.children;
12996
- for (var i = 0, imax = children.length; i < imax; ++i) {
12997
- var child = children[i];
12998
- if (child instanceof DBase) {
12999
- child.reflow();
13000
- }
13001
- }
13002
- this._hasDirty = false;
13003
- }
13004
- };
13005
13031
  DBase.prototype.onReflow = function () {
13006
13032
  this._reflowable.onReflow(this, this._width, this._height);
13007
13033
  };
@@ -18305,36 +18331,6 @@
18305
18331
  DOUBLE_CLICKED: 1
18306
18332
  };
18307
18333
 
18308
- /*
18309
- * Copyright (C) 2019 Toshiba Corporation
18310
- * SPDX-License-Identifier: Apache-2.0
18311
- */
18312
- var DAlignHorizontal = {
18313
- LEFT: 0,
18314
- CENTER: 1,
18315
- RIGHT: 2
18316
- };
18317
-
18318
- /*
18319
- * Copyright (C) 2019 Toshiba Corporation
18320
- * SPDX-License-Identifier: Apache-2.0
18321
- */
18322
- var DAlignVertical = {
18323
- TOP: 0,
18324
- MIDDLE: 1,
18325
- BOTTOM: 2
18326
- };
18327
-
18328
- /*
18329
- * Copyright (C) 2019 Toshiba Corporation
18330
- * SPDX-License-Identifier: Apache-2.0
18331
- */
18332
- var DAlignWith = {
18333
- TEXT: 0,
18334
- PADDING: 1,
18335
- BORDER: 2
18336
- };
18337
-
18338
18334
  var DImageBaseThemeWrapperSecondary = /** @class */ (function () {
18339
18335
  function DImageBaseThemeWrapperSecondary(theme) {
18340
18336
  this._theme = theme;
@@ -18397,6 +18393,36 @@
18397
18393
  return DImageBaseThemeWrapperTertiary;
18398
18394
  }());
18399
18395
 
18396
+ /*
18397
+ * Copyright (C) 2019 Toshiba Corporation
18398
+ * SPDX-License-Identifier: Apache-2.0
18399
+ */
18400
+ var DAlignHorizontal = {
18401
+ LEFT: 0,
18402
+ CENTER: 1,
18403
+ RIGHT: 2
18404
+ };
18405
+
18406
+ /*
18407
+ * Copyright (C) 2019 Toshiba Corporation
18408
+ * SPDX-License-Identifier: Apache-2.0
18409
+ */
18410
+ var DAlignVertical = {
18411
+ TOP: 0,
18412
+ MIDDLE: 1,
18413
+ BOTTOM: 2
18414
+ };
18415
+
18416
+ /*
18417
+ * Copyright (C) 2019 Toshiba Corporation
18418
+ * SPDX-License-Identifier: Apache-2.0
18419
+ */
18420
+ var DAlignWith = {
18421
+ TEXT: 0,
18422
+ PADDING: 1,
18423
+ BORDER: 2
18424
+ };
18425
+
18400
18426
  var toImageAlign = function (theme, options) {
18401
18427
  var _a, _b, _c;
18402
18428
  var align = options === null || options === void 0 ? void 0 : options.align;
@@ -18677,6 +18703,388 @@
18677
18703
  return DImagePiece;
18678
18704
  }());
18679
18705
 
18706
+ var DImagePieceLayouterPart = /** @class */ (function () {
18707
+ function DImagePieceLayouterPart() {
18708
+ this.pieces = [];
18709
+ this.size = 0;
18710
+ }
18711
+ DImagePieceLayouterPart.prototype.clear = function () {
18712
+ this.pieces.length = 0;
18713
+ this.size = 0;
18714
+ };
18715
+ DImagePieceLayouterPart.prototype.add = function (image, size, margin) {
18716
+ var pieces = this.pieces;
18717
+ pieces.push(image);
18718
+ this.size += margin + size;
18719
+ };
18720
+ return DImagePieceLayouterPart;
18721
+ }());
18722
+
18723
+ var DImagePieceLayouterPartBottom = /** @class */ (function (_super) {
18724
+ __extends(DImagePieceLayouterPartBottom, _super);
18725
+ function DImagePieceLayouterPartBottom() {
18726
+ return _super !== null && _super.apply(this, arguments) || this;
18727
+ }
18728
+ DImagePieceLayouterPartBottom.prototype.execute = function (pbottom, height, marginAfter) {
18729
+ var pieces = this.pieces;
18730
+ var y = height - pbottom;
18731
+ if (marginAfter) {
18732
+ var margin = 0;
18733
+ for (var i = 0, imax = pieces.length; i < imax; ++i) {
18734
+ var piece = pieces[i];
18735
+ y -= margin + piece.bound.height;
18736
+ piece.image.y = y;
18737
+ margin = piece.margin.horizontal;
18738
+ }
18739
+ }
18740
+ else {
18741
+ for (var i = 0, imax = pieces.length; i < imax; ++i) {
18742
+ var piece = pieces[i];
18743
+ y -= piece.margin.horizontal + piece.bound.height;
18744
+ piece.image.y = y;
18745
+ }
18746
+ }
18747
+ };
18748
+ return DImagePieceLayouterPartBottom;
18749
+ }(DImagePieceLayouterPart));
18750
+
18751
+ var DImagePieceLayouterPartCenter = /** @class */ (function (_super) {
18752
+ __extends(DImagePieceLayouterPartCenter, _super);
18753
+ function DImagePieceLayouterPartCenter() {
18754
+ return _super !== null && _super.apply(this, arguments) || this;
18755
+ }
18756
+ DImagePieceLayouterPartCenter.prototype.add = function (image, size, margin) {
18757
+ var pieces = this.pieces;
18758
+ pieces.push(image);
18759
+ this.size = Math.max(this.size, size);
18760
+ };
18761
+ DImagePieceLayouterPartCenter.prototype.execute = function (pleft, pright, width) {
18762
+ var c = pleft + (width - pleft - pright) * 0.5;
18763
+ var pieces = this.pieces;
18764
+ for (var i = 0, imax = pieces.length; i < imax; ++i) {
18765
+ var piece = pieces[i];
18766
+ piece.image.x = c - piece.bound.width * 0.5;
18767
+ }
18768
+ };
18769
+ return DImagePieceLayouterPartCenter;
18770
+ }(DImagePieceLayouterPart));
18771
+
18772
+ var DImagePieceLayouterPartLeft = /** @class */ (function (_super) {
18773
+ __extends(DImagePieceLayouterPartLeft, _super);
18774
+ function DImagePieceLayouterPartLeft() {
18775
+ return _super !== null && _super.apply(this, arguments) || this;
18776
+ }
18777
+ DImagePieceLayouterPartLeft.prototype.execute = function (pleft, marginAfter) {
18778
+ var pieces = this.pieces;
18779
+ var x = pleft;
18780
+ if (marginAfter) {
18781
+ for (var i = 0, imax = pieces.length; i < imax; ++i) {
18782
+ var piece = pieces[i];
18783
+ piece.image.x = x;
18784
+ x += piece.bound.width + piece.margin.horizontal;
18785
+ }
18786
+ }
18787
+ else {
18788
+ for (var i = 0, imax = pieces.length; i < imax; ++i) {
18789
+ var piece = pieces[i];
18790
+ x += piece.margin.horizontal;
18791
+ piece.image.x = x;
18792
+ x += piece.bound.width;
18793
+ }
18794
+ }
18795
+ };
18796
+ return DImagePieceLayouterPartLeft;
18797
+ }(DImagePieceLayouterPart));
18798
+
18799
+ var DImagePieceLayouterPartMiddle = /** @class */ (function (_super) {
18800
+ __extends(DImagePieceLayouterPartMiddle, _super);
18801
+ function DImagePieceLayouterPartMiddle() {
18802
+ return _super !== null && _super.apply(this, arguments) || this;
18803
+ }
18804
+ DImagePieceLayouterPartMiddle.prototype.add = function (image, size, margin) {
18805
+ var pieces = this.pieces;
18806
+ pieces.push(image);
18807
+ this.size = Math.max(this.size, size);
18808
+ };
18809
+ DImagePieceLayouterPartMiddle.prototype.execute = function (ptop, pbottom, height) {
18810
+ var c = ptop + (height - ptop - pbottom) * 0.5;
18811
+ var pieces = this.pieces;
18812
+ for (var i = 0, imax = pieces.length; i < imax; ++i) {
18813
+ var piece = pieces[i];
18814
+ piece.image.y = c - piece.bound.height * 0.5;
18815
+ }
18816
+ };
18817
+ return DImagePieceLayouterPartMiddle;
18818
+ }(DImagePieceLayouterPart));
18819
+
18820
+ var DImagePieceLayouterPartRight = /** @class */ (function (_super) {
18821
+ __extends(DImagePieceLayouterPartRight, _super);
18822
+ function DImagePieceLayouterPartRight() {
18823
+ return _super !== null && _super.apply(this, arguments) || this;
18824
+ }
18825
+ DImagePieceLayouterPartRight.prototype.execute = function (pright, width, marginAfter) {
18826
+ var pieces = this.pieces;
18827
+ var x = width - pright;
18828
+ if (marginAfter) {
18829
+ var margin = 0;
18830
+ for (var i = 0, imax = pieces.length; i < imax; ++i) {
18831
+ var piece = pieces[i];
18832
+ x -= margin + piece.bound.width;
18833
+ piece.image.x = x;
18834
+ margin = piece.margin.horizontal;
18835
+ }
18836
+ }
18837
+ else {
18838
+ for (var i = 0, imax = pieces.length; i < imax; ++i) {
18839
+ var piece = pieces[i];
18840
+ x -= piece.margin.horizontal + piece.bound.width;
18841
+ piece.image.x = x;
18842
+ }
18843
+ }
18844
+ };
18845
+ return DImagePieceLayouterPartRight;
18846
+ }(DImagePieceLayouterPart));
18847
+
18848
+ var DImagePieceLayouterPartTop = /** @class */ (function (_super) {
18849
+ __extends(DImagePieceLayouterPartTop, _super);
18850
+ function DImagePieceLayouterPartTop() {
18851
+ return _super !== null && _super.apply(this, arguments) || this;
18852
+ }
18853
+ DImagePieceLayouterPartTop.prototype.execute = function (ptop, marginAfter) {
18854
+ var pieces = this.pieces;
18855
+ var y = ptop;
18856
+ if (marginAfter) {
18857
+ var margin = 0;
18858
+ for (var i = 0, imax = pieces.length; i < imax; ++i) {
18859
+ var piece = pieces[i];
18860
+ piece.image.y = margin + y;
18861
+ y += piece.bound.height;
18862
+ margin = piece.margin.vertical;
18863
+ }
18864
+ }
18865
+ else {
18866
+ for (var i = 0, imax = pieces.length; i < imax; ++i) {
18867
+ var piece = pieces[i];
18868
+ y += piece.margin.vertical;
18869
+ piece.image.y = y;
18870
+ y += piece.bound.height;
18871
+ }
18872
+ }
18873
+ };
18874
+ return DImagePieceLayouterPartTop;
18875
+ }(DImagePieceLayouterPart));
18876
+
18877
+ var DImagePieceLayouterPartContainer = /** @class */ (function () {
18878
+ function DImagePieceLayouterPartContainer() {
18879
+ this.left = new DImagePieceLayouterPartLeft();
18880
+ this.center = new DImagePieceLayouterPartCenter();
18881
+ this.right = new DImagePieceLayouterPartRight();
18882
+ this.top = new DImagePieceLayouterPartTop();
18883
+ this.middle = new DImagePieceLayouterPartMiddle();
18884
+ this.bottom = new DImagePieceLayouterPartBottom();
18885
+ }
18886
+ DImagePieceLayouterPartContainer.prototype.clear = function () {
18887
+ this.left.clear();
18888
+ this.center.clear();
18889
+ this.right.clear();
18890
+ this.top.clear();
18891
+ this.middle.clear();
18892
+ this.bottom.clear();
18893
+ this.text = undefined;
18894
+ };
18895
+ DImagePieceLayouterPartContainer.prototype.add = function (image) {
18896
+ var imageImage = image.image;
18897
+ if (imageImage != null) {
18898
+ var imageBound = image.bound;
18899
+ var imageBoundWidth = imageBound.width;
18900
+ var imageBoundHeight = imageBound.height;
18901
+ var imageMargin = image.margin;
18902
+ var imageMarginHorizontal = imageMargin.horizontal;
18903
+ var imageMarginVertical = imageMargin.vertical;
18904
+ var imageAlign = image.align;
18905
+ switch (imageAlign.horizontal) {
18906
+ case DAlignHorizontal.LEFT:
18907
+ this.left.add(image, imageBoundWidth, imageMarginHorizontal);
18908
+ break;
18909
+ case DAlignHorizontal.CENTER:
18910
+ this.center.add(image, imageBoundWidth, imageMarginHorizontal);
18911
+ break;
18912
+ case DAlignHorizontal.RIGHT:
18913
+ this.right.add(image, imageBoundWidth, imageMarginHorizontal);
18914
+ break;
18915
+ }
18916
+ switch (imageAlign.vertical) {
18917
+ case DAlignVertical.TOP:
18918
+ this.top.add(image, imageBoundHeight, imageMarginVertical);
18919
+ break;
18920
+ case DAlignVertical.MIDDLE:
18921
+ this.middle.add(image, imageBoundHeight, imageMarginVertical);
18922
+ break;
18923
+ case DAlignVertical.BOTTOM:
18924
+ this.bottom.add(image, imageBoundHeight, imageMarginVertical);
18925
+ break;
18926
+ }
18927
+ }
18928
+ };
18929
+ DImagePieceLayouterPartContainer.prototype.set = function (text) {
18930
+ this.text = text;
18931
+ };
18932
+ Object.defineProperty(DImagePieceLayouterPartContainer.prototype, "width", {
18933
+ get: function () {
18934
+ var text = this.text;
18935
+ var left = this.left;
18936
+ var center = this.center;
18937
+ var right = this.right;
18938
+ if (text) {
18939
+ return Math.max(left.size + text.width + right.size, center.size);
18940
+ }
18941
+ else {
18942
+ return Math.max(left.size, right.size, center.size);
18943
+ }
18944
+ },
18945
+ enumerable: false,
18946
+ configurable: true
18947
+ });
18948
+ Object.defineProperty(DImagePieceLayouterPartContainer.prototype, "height", {
18949
+ get: function () {
18950
+ var text = this.text;
18951
+ var top = this.top;
18952
+ var middle = this.middle;
18953
+ var bottom = this.bottom;
18954
+ if (text) {
18955
+ return Math.max(top.size + text.height + bottom.size, middle.size);
18956
+ }
18957
+ else {
18958
+ return Math.max(top.size, bottom.size, middle.size);
18959
+ }
18960
+ },
18961
+ enumerable: false,
18962
+ configurable: true
18963
+ });
18964
+ DImagePieceLayouterPartContainer.prototype.execute = function (pleft, ptop, pright, pbottom, textAlign, width, height) {
18965
+ var left = this.left;
18966
+ var center = this.center;
18967
+ var right = this.right;
18968
+ var top = this.top;
18969
+ var middle = this.middle;
18970
+ var bottom = this.bottom;
18971
+ var text = this.text;
18972
+ if (text) {
18973
+ var textX = 0;
18974
+ var textWidth = text.width;
18975
+ switch (textAlign.horizontal) {
18976
+ case DAlignHorizontal.LEFT:
18977
+ textX = pleft + left.size;
18978
+ break;
18979
+ case DAlignHorizontal.CENTER:
18980
+ textX =
18981
+ pleft +
18982
+ (width - pleft - pright - (left.size + textWidth + right.size)) * 0.5 +
18983
+ left.size;
18984
+ break;
18985
+ case DAlignHorizontal.RIGHT:
18986
+ textX = width - pright - right.size - textWidth;
18987
+ break;
18988
+ }
18989
+ var textY = 0;
18990
+ var textHeight = text.height;
18991
+ switch (textAlign.vertical) {
18992
+ case DAlignVertical.TOP:
18993
+ textY = ptop + top.size;
18994
+ break;
18995
+ case DAlignVertical.MIDDLE:
18996
+ textY =
18997
+ ptop +
18998
+ (height - ptop - pbottom - (top.size + textHeight + bottom.size)) * 0.5 +
18999
+ top.size;
19000
+ break;
19001
+ case DAlignVertical.BOTTOM:
19002
+ textY = height - pbottom - bottom.size - textHeight;
19003
+ break;
19004
+ }
19005
+ text.position.set(textX, textY);
19006
+ text.setClippingDelta(left.size + right.size, top.size + bottom.size);
19007
+ left.execute(textX - left.size, true);
19008
+ center.execute(0, 0, textX * 2 + textWidth);
19009
+ right.execute(0, textX + textWidth + right.size, true);
19010
+ top.execute(textY - top.size, true);
19011
+ middle.execute(0, 0, textY * 2 + textHeight);
19012
+ bottom.execute(0, textY + textHeight + bottom.size, true);
19013
+ }
19014
+ else {
19015
+ left.execute(pleft, false);
19016
+ center.execute(pleft, pright, width);
19017
+ right.execute(pright, width, false);
19018
+ top.execute(ptop, false);
19019
+ middle.execute(ptop, pbottom, height);
19020
+ bottom.execute(pbottom, height, false);
19021
+ }
19022
+ };
19023
+ return DImagePieceLayouterPartContainer;
19024
+ }());
19025
+
19026
+ var DImagePieceLayouter = /** @class */ (function () {
19027
+ function DImagePieceLayouter() {
19028
+ this.text = new DImagePieceLayouterPartContainer();
19029
+ this.padding = new DImagePieceLayouterPartContainer();
19030
+ this.border = new DImagePieceLayouterPartContainer();
19031
+ }
19032
+ DImagePieceLayouter.prototype.clear = function () {
19033
+ this.text.clear();
19034
+ this.padding.clear();
19035
+ this.border.clear();
19036
+ };
19037
+ DImagePieceLayouter.prototype.add = function (image) {
19038
+ var imageImage = image.image;
19039
+ if (imageImage) {
19040
+ switch (image.align.with) {
19041
+ case DAlignWith.TEXT:
19042
+ this.text.add(image);
19043
+ break;
19044
+ case DAlignWith.PADDING:
19045
+ this.padding.add(image);
19046
+ break;
19047
+ case DAlignWith.BORDER:
19048
+ this.border.add(image);
19049
+ break;
19050
+ }
19051
+ }
19052
+ };
19053
+ DImagePieceLayouter.prototype.set = function (text) {
19054
+ this.text.set(text);
19055
+ };
19056
+ DImagePieceLayouter.prototype.execute = function (padding, textAlign, width, height) {
19057
+ var pleft = padding.getLeft();
19058
+ var ptop = padding.getTop();
19059
+ var pright = padding.getRight();
19060
+ var pbottom = padding.getBottom();
19061
+ if (width == null) {
19062
+ width = pleft + this.width + pright;
19063
+ }
19064
+ if (height == null) {
19065
+ height = ptop + this.height + pbottom;
19066
+ }
19067
+ this.border.execute(0, 0, 0, 0, textAlign, width, height);
19068
+ this.padding.execute(pleft, ptop, pright, pbottom, textAlign, width, height);
19069
+ this.text.execute(pleft, ptop, pright, pbottom, textAlign, width, height);
19070
+ };
19071
+ Object.defineProperty(DImagePieceLayouter.prototype, "width", {
19072
+ get: function () {
19073
+ return Math.max(this.border.width, this.padding.width, this.text.width);
19074
+ },
19075
+ enumerable: false,
19076
+ configurable: true
19077
+ });
19078
+ Object.defineProperty(DImagePieceLayouter.prototype, "height", {
19079
+ get: function () {
19080
+ return Math.max(this.border.height, this.padding.height, this.text.height);
19081
+ },
19082
+ enumerable: false,
19083
+ configurable: true
19084
+ });
19085
+ return DImagePieceLayouter;
19086
+ }());
19087
+
18680
19088
  /*
18681
19089
  * Copyright (C) 2019 Toshiba Corporation
18682
19090
  * SPDX-License-Identifier: Apache-2.0
@@ -19902,32 +20310,42 @@
19902
20310
  DTextBase.prototype.updateTextPosition = function (text) {
19903
20311
  var align = this._textAlign;
19904
20312
  var padding = this._padding;
19905
- var toRounded = this.toRounded;
19906
- switch (align.horizontal) {
19907
- case DAlignHorizontal.LEFT:
19908
- text.x = toRounded(padding.getLeft());
19909
- break;
19910
- case DAlignHorizontal.CENTER:
19911
- text.x = toRounded((this.width - text.width) * 0.5);
19912
- break;
19913
- case DAlignHorizontal.RIGHT:
19914
- text.x = toRounded(this.width - text.width - padding.getRight());
19915
- break;
20313
+ var auto = this._auto;
20314
+ var textX = 0;
20315
+ var pleft = padding.getLeft();
20316
+ var alignHorizontal = align.horizontal;
20317
+ if (auto.width.isOn || alignHorizontal === DAlignHorizontal.LEFT) {
20318
+ textX = pleft;
19916
20319
  }
19917
- switch (align.vertical) {
19918
- case DAlignVertical.TOP:
19919
- text.y = toRounded(padding.getTop());
19920
- break;
19921
- case DAlignVertical.MIDDLE:
19922
- text.y = toRounded((this.height - text.height) * 0.5);
19923
- break;
19924
- case DAlignVertical.BOTTOM:
19925
- text.y = toRounded(this.height - text.height - padding.getBottom());
19926
- break;
20320
+ else {
20321
+ var width = this.width;
20322
+ var textWidth = text.width;
20323
+ var pright = padding.getRight();
20324
+ if (alignHorizontal === DAlignHorizontal.CENTER) {
20325
+ textX = pleft + (width - pleft - pright - textWidth) * 0.5;
20326
+ }
20327
+ else {
20328
+ textX = width - textWidth - pright;
20329
+ }
19927
20330
  }
19928
- };
19929
- DTextBase.prototype.toRounded = function (value) {
19930
- return Math.round(value);
20331
+ var textY = 0;
20332
+ var ptop = padding.getTop();
20333
+ var alignVertical = align.vertical;
20334
+ if (auto.height.isOn || alignVertical === DAlignVertical.TOP) {
20335
+ textY = ptop;
20336
+ }
20337
+ else {
20338
+ var height = this.height;
20339
+ var textHeight = text.height;
20340
+ var pbottom = padding.getBottom();
20341
+ if (alignVertical === DAlignVertical.MIDDLE) {
20342
+ textY = ptop + (height - ptop - pbottom - textHeight) * 0.5;
20343
+ }
20344
+ else {
20345
+ textY = height - textHeight - pbottom;
20346
+ }
20347
+ }
20348
+ text.position.set(textX, textY);
19931
20349
  };
19932
20350
  DTextBase.prototype.getTextColor = function (theme, state) {
19933
20351
  var color = this._textColor;
@@ -20097,277 +20515,24 @@
20097
20515
  this.updateTextAndImage();
20098
20516
  };
20099
20517
  DImageBase.prototype.updateTextAndImage = function () {
20100
- var text = this._text;
20518
+ var _a;
20101
20519
  var images = this._images;
20102
- var padding = this._padding;
20103
- var toRounded = this.toRounded;
20104
- var width = this.width;
20105
- var height = this.height;
20106
- var pl = padding.getLeft();
20107
- var pr = padding.getRight();
20108
- var pt = padding.getTop();
20109
- var pb = padding.getBottom();
20110
- var noText = text == null;
20111
- var textLeftFirst = noText;
20112
- var textTopFirst = noText;
20113
- var textRightLastMargin = 0;
20114
- var textBottomLastMargin = 0;
20115
- var textLeft = 0;
20116
- var textRight = 0;
20117
- var textTop = 0;
20118
- var textBottom = 0;
20119
- var paddingLeft = pl;
20120
- var paddingRight = width - pr;
20121
- var paddingTop = pt;
20122
- var paddingBottom = height - pb;
20123
- var borderLeft = 0;
20124
- var borderRight = width;
20125
- var borderTop = 0;
20126
- var borderBottom = height;
20520
+ var layouter = ((_a = DImageBase.LAYOUTER) !== null && _a !== void 0 ? _a : (DImageBase.LAYOUTER = new DImagePieceLayouter()));
20127
20521
  for (var i = 0, imax = images.length; i < imax; ++i) {
20128
20522
  var image = images[i];
20129
20523
  image.updateSource();
20130
20524
  image.updateTint();
20131
20525
  image.updateBound();
20132
- var imageImage = image.image;
20133
- if (imageImage) {
20134
- var imageBound = image.bound;
20135
- var imageBoundWidth = imageBound.width;
20136
- var imageBoundHeight = imageBound.height;
20137
- var imageMargin = image.margin;
20138
- var imageMarginHorizontal = imageMargin.horizontal;
20139
- var imageMarginVertical = imageMargin.vertical;
20140
- // Text
20141
- if (image.align.with === DAlignWith.TEXT) {
20142
- switch (image.align.horizontal) {
20143
- case DAlignHorizontal.LEFT:
20144
- imageImage.x = textLeft;
20145
- textLeft += imageBoundWidth;
20146
- if (textLeftFirst) {
20147
- textLeftFirst = false;
20148
- }
20149
- else {
20150
- textLeft += imageMarginHorizontal;
20151
- }
20152
- break;
20153
- case DAlignHorizontal.CENTER:
20154
- // DO NOTHING
20155
- break;
20156
- case DAlignHorizontal.RIGHT:
20157
- textRight -= imageBoundWidth;
20158
- imageImage.x = textRight;
20159
- textRight -= imageMarginHorizontal;
20160
- textRightLastMargin = imageMarginHorizontal;
20161
- break;
20162
- }
20163
- switch (image.align.vertical) {
20164
- case DAlignVertical.TOP:
20165
- imageImage.y = textTop;
20166
- textTop += imageBoundHeight;
20167
- if (textTopFirst) {
20168
- textTopFirst = false;
20169
- }
20170
- else {
20171
- textTop += imageMarginVertical;
20172
- }
20173
- break;
20174
- case DAlignVertical.MIDDLE:
20175
- // DO NOTHING
20176
- break;
20177
- case DAlignVertical.BOTTOM:
20178
- textBottom -= imageBoundHeight;
20179
- imageImage.y = textBottom;
20180
- textBottom -= imageMarginVertical;
20181
- textBottomLastMargin = imageMarginVertical;
20182
- break;
20183
- }
20184
- }
20185
- // Padding
20186
- if (image.align.with === DAlignWith.PADDING) {
20187
- switch (image.align.horizontal) {
20188
- case DAlignHorizontal.LEFT:
20189
- paddingLeft += imageMarginHorizontal;
20190
- imageImage.x = toRounded(paddingLeft);
20191
- paddingLeft += imageBoundWidth;
20192
- break;
20193
- case DAlignHorizontal.CENTER:
20194
- // DO NOTHING
20195
- break;
20196
- case DAlignHorizontal.RIGHT:
20197
- paddingRight -= imageBoundWidth + imageMarginHorizontal;
20198
- imageImage.x = toRounded(paddingRight);
20199
- break;
20200
- }
20201
- switch (image.align.vertical) {
20202
- case DAlignVertical.TOP:
20203
- paddingTop += imageMarginVertical;
20204
- imageImage.y = toRounded(paddingTop);
20205
- paddingTop += imageBoundHeight;
20206
- break;
20207
- case DAlignVertical.MIDDLE:
20208
- // DO NOTHING
20209
- break;
20210
- case DAlignVertical.BOTTOM:
20211
- paddingBottom -= imageBoundHeight + imageMarginVertical;
20212
- imageImage.y = toRounded(paddingBottom);
20213
- break;
20214
- }
20215
- }
20216
- // Border
20217
- if (image.align.with === DAlignWith.BORDER) {
20218
- switch (image.align.horizontal) {
20219
- case DAlignHorizontal.LEFT:
20220
- borderLeft += imageMarginHorizontal;
20221
- imageImage.x = toRounded(borderLeft);
20222
- borderLeft += imageBoundWidth;
20223
- break;
20224
- case DAlignHorizontal.CENTER:
20225
- // DO NOTHING
20226
- break;
20227
- case DAlignHorizontal.RIGHT:
20228
- borderRight -= imageBoundWidth + imageMarginHorizontal;
20229
- imageImage.x = toRounded(borderRight);
20230
- break;
20231
- }
20232
- switch (image.align.vertical) {
20233
- case DAlignVertical.TOP:
20234
- borderTop += imageMarginVertical;
20235
- imageImage.y = toRounded(borderTop);
20236
- borderTop += imageBoundHeight;
20237
- break;
20238
- case DAlignVertical.MIDDLE:
20239
- // DO NOTHING
20240
- break;
20241
- case DAlignVertical.BOTTOM:
20242
- borderBottom -= imageBoundHeight + imageMarginVertical;
20243
- imageImage.y = toRounded(borderBottom);
20244
- break;
20245
- }
20246
- }
20247
- }
20526
+ layouter.add(image);
20248
20527
  }
20249
- if (noText) {
20250
- textRight += textRightLastMargin;
20251
- textBottom += textBottomLastMargin;
20252
- }
20253
- // Text
20254
- var textLeftAdjust = 0;
20255
- var textCenterAdjust = 0;
20256
- var textRightAdjust = 0;
20257
- var textTopAdjust = 0;
20258
- var textMiddleAdjust = 0;
20259
- var textBottomAdjust = 0;
20528
+ var text = this._text;
20260
20529
  if (text != null) {
20261
20530
  this.updateTextColor(text);
20262
- text.setClippingDelta(textLeft - textRight, textTop - textBottom);
20263
- var textAlign = this._textAlign;
20264
- var textWidth = text.width;
20265
- var textHeight = text.height;
20266
- switch (textAlign.horizontal) {
20267
- case DAlignHorizontal.LEFT:
20268
- textLeftAdjust = pl;
20269
- textRightAdjust = textLeftAdjust + textLeft + textWidth - textRight;
20270
- break;
20271
- case DAlignHorizontal.CENTER:
20272
- textLeftAdjust = (width - textLeft + textRight - textWidth) * 0.5;
20273
- textRightAdjust = textLeftAdjust + textLeft + textWidth - textRight;
20274
- break;
20275
- case DAlignHorizontal.RIGHT:
20276
- textRightAdjust = width - pr;
20277
- textLeftAdjust = textRightAdjust + textRight - textWidth - textLeft;
20278
- break;
20279
- }
20280
- text.x = toRounded(textLeftAdjust + textLeft);
20281
- textCenterAdjust = textLeftAdjust + textLeft + textWidth * 0.5;
20282
- switch (textAlign.vertical) {
20283
- case DAlignVertical.TOP:
20284
- textTopAdjust = pt;
20285
- textBottomAdjust = textTopAdjust + textTop + textHeight - textBottom;
20286
- break;
20287
- case DAlignVertical.MIDDLE:
20288
- textTopAdjust = (height - textTop + textBottom - textHeight) * 0.5;
20289
- textBottomAdjust = textTopAdjust + textTop + textHeight - textBottom;
20290
- break;
20291
- case DAlignVertical.BOTTOM:
20292
- textBottomAdjust = height - pb;
20293
- textTopAdjust = textBottomAdjust + textBottom - textHeight - textTop;
20294
- break;
20295
- }
20296
- text.y = toRounded(textTopAdjust + textTop);
20297
- textMiddleAdjust = textTopAdjust + textTop + textHeight * 0.5;
20298
- }
20299
- else {
20300
- textLeftAdjust = (width - textLeft + textRight) * 0.5;
20301
- textRightAdjust = textLeftAdjust + textLeft - textRight;
20302
- textCenterAdjust = textLeftAdjust + textLeft;
20303
- textTopAdjust = (height - textTop + textBottom) * 0.5;
20304
- textBottomAdjust = textTopAdjust + textTop - textBottom;
20305
- textMiddleAdjust = textTopAdjust + textTop;
20306
- }
20307
- var paddingCenterAdjust = width * 0.5;
20308
- var paddingMiddleAdjust = height * 0.5;
20309
- var borderCenterAdjust = width * 0.5;
20310
- var borderMiddleAdjust = height * 0.5;
20311
- for (var i = 0, imax = images.length; i < imax; ++i) {
20312
- var image = images[i];
20313
- var imageImage = image.image;
20314
- if (imageImage) {
20315
- var imageBound = image.bound;
20316
- var imageBoundWidth = imageBound.width;
20317
- var imageBoundHeight = imageBound.height;
20318
- // Text
20319
- if (image.align.with === DAlignWith.TEXT) {
20320
- switch (image.align.horizontal) {
20321
- case DAlignHorizontal.LEFT:
20322
- imageImage.x = toRounded(imageImage.x + textLeftAdjust);
20323
- break;
20324
- case DAlignHorizontal.CENTER:
20325
- imageImage.x = toRounded(textCenterAdjust - imageBoundWidth * 0.5);
20326
- break;
20327
- case DAlignHorizontal.RIGHT:
20328
- imageImage.x = toRounded(imageImage.x + textRightAdjust);
20329
- break;
20330
- }
20331
- switch (image.align.vertical) {
20332
- case DAlignVertical.TOP:
20333
- imageImage.y = toRounded(imageImage.y + textTopAdjust);
20334
- break;
20335
- case DAlignVertical.MIDDLE:
20336
- imageImage.y = toRounded(textMiddleAdjust - imageBoundHeight * 0.5);
20337
- break;
20338
- case DAlignVertical.BOTTOM:
20339
- imageImage.y = toRounded(imageImage.y + textBottomAdjust);
20340
- break;
20341
- }
20342
- }
20343
- // Padding
20344
- if (image.align.with === DAlignWith.PADDING) {
20345
- switch (image.align.horizontal) {
20346
- case DAlignHorizontal.CENTER:
20347
- imageImage.x = toRounded(paddingCenterAdjust - imageBoundWidth * 0.5);
20348
- break;
20349
- }
20350
- switch (image.align.vertical) {
20351
- case DAlignVertical.MIDDLE:
20352
- imageImage.y = toRounded(paddingMiddleAdjust - imageBoundHeight * 0.5);
20353
- break;
20354
- }
20355
- }
20356
- // Border
20357
- if (image.align.with === DAlignWith.BORDER) {
20358
- switch (image.align.horizontal) {
20359
- case DAlignHorizontal.CENTER:
20360
- imageImage.x = toRounded(borderCenterAdjust - imageBoundWidth * 0.5);
20361
- break;
20362
- }
20363
- switch (image.align.vertical) {
20364
- case DAlignVertical.MIDDLE:
20365
- imageImage.y = toRounded(borderMiddleAdjust - imageBoundHeight * 0.5);
20366
- break;
20367
- }
20368
- }
20369
- }
20531
+ layouter.set(text);
20370
20532
  }
20533
+ var auto = this._auto;
20534
+ layouter.execute(this._padding, this._textAlign, auto.width.isOn ? null : this.width, auto.height.isOn ? null : this.height);
20535
+ layouter.clear();
20371
20536
  };
20372
20537
  DImageBase.prototype.isRefitable = function (target) {
20373
20538
  if (_super.prototype.isRefitable.call(this, target)) {
@@ -22673,9 +22838,6 @@
22673
22838
  this.toGlobal(point, point, true);
22674
22839
  result.width = point.x - result.x;
22675
22840
  result.height = point.y - result.y;
22676
- // Rounds pixels as Pixi.js does
22677
- result.x = ((result.x * resolution) | 0) / resolution;
22678
- result.y = ((result.y * resolution) | 0) / resolution;
22679
22841
  return result;
22680
22842
  };
22681
22843
  DHtmlElement.prototype.getClipperRect = function (resolution, point, result) {
@@ -38884,8 +39046,24 @@
38884
39046
  var text = this._shortcutText;
38885
39047
  var margin = this._shortcutMargin;
38886
39048
  if (text != null && margin != null) {
38887
- var toRounded = this.toRounded;
38888
- text.position.set(toRounded(this.width - margin - text.width), toRounded((this.height - text.height) * 0.5));
39049
+ var auto = this._auto;
39050
+ var textX = 0;
39051
+ if (auto.width.isOn) {
39052
+ textX = margin;
39053
+ }
39054
+ else {
39055
+ textX = this.width - text.width - margin;
39056
+ }
39057
+ var textY = 0;
39058
+ var padding = this._padding;
39059
+ var ptop = padding.getTop();
39060
+ if (auto.height.isOn) {
39061
+ textY = ptop;
39062
+ }
39063
+ else {
39064
+ textY = ptop + (this.height - ptop - padding.getBottom() - text.height) * 0.5;
39065
+ }
39066
+ text.position.set(textX, textY);
38889
39067
  }
38890
39068
  };
38891
39069
  DMenuItemText.prototype.updateTextColor = function (text) {
@@ -41639,7 +41817,9 @@
41639
41817
  this.height = size + padding * 2;
41640
41818
  var metrics = pixi_js.TextMetrics.measureFont(fontId);
41641
41819
  this.ascent = metrics.ascent;
41642
- this.descent = metrics.descent;
41820
+ // Becase the descent returned by TextMatrics#measureFont is tend
41821
+ // to be the half of the actual descent browsers use internally.
41822
+ this.descent = metrics.descent * 2;
41643
41823
  }
41644
41824
  return DynamicFontAtlasFont;
41645
41825
  }());
@@ -43747,7 +43927,6 @@
43747
43927
  _this._isOverlay = options.isOverlay();
43748
43928
  _this._padding = options.getPadding();
43749
43929
  _this._rootElement = options.getRootElement();
43750
- _this._refitLimit = 5;
43751
43930
  _this._reflowLimit = 5;
43752
43931
  _this._elementContainer = _this.newElementContainer();
43753
43932
  _this.application = application;
@@ -43941,7 +44120,6 @@
43941
44120
  }
43942
44121
  };
43943
44122
  DApplicationLayer.prototype.render = function () {
43944
- this.refit();
43945
44123
  this.reflow();
43946
44124
  // Please note why the following line is here.
43947
44125
  //
@@ -43977,32 +44155,16 @@
43977
44155
  enumerable: false,
43978
44156
  configurable: true
43979
44157
  });
43980
- DApplicationLayer.prototype.refit = function () {
43981
- var children = this.stage.children;
43982
- for (var ilimit = 0, limit = this._refitLimit; ilimit < limit; ++ilimit) {
43983
- var isChildrenDirty = false;
43984
- for (var i = 0, imax = children.length; i < imax; ++i) {
43985
- var child = children[i];
43986
- if (child instanceof DBase) {
43987
- child.refit();
43988
- isChildrenDirty = isChildrenDirty || child.isChildrenDirty();
43989
- }
43990
- }
43991
- // If DBases are changed during the `refit` process, need to refit again.
43992
- if (!isChildrenDirty) {
43993
- break;
43994
- }
43995
- }
43996
- };
43997
44158
  DApplicationLayer.prototype.reflow = function () {
43998
44159
  var children = this.stage.children;
43999
- for (var ilimit = 0, limit = this._refitLimit; ilimit < limit; ++ilimit) {
44160
+ for (var ilimit = 0, limit = this._reflowLimit; ilimit < limit; ++ilimit) {
44000
44161
  var isDirty = false;
44001
44162
  for (var i = 0, imax = children.length; i < imax; ++i) {
44002
44163
  var child = children[i];
44003
44164
  if (child instanceof DBase) {
44004
44165
  child.reflow();
44005
- isDirty = isDirty || child.isDirty() || child.hasDirty();
44166
+ isDirty =
44167
+ isDirty || child.isDirty() || child.hasDirty() || child.isHierarchyDirty();
44006
44168
  }
44007
44169
  }
44008
44170
  // If DBases are changed during the `reflow` process, need to reflow again.
@@ -54790,16 +54952,6 @@
54790
54952
  }
54791
54953
  return cleanup === true || cleanup.background === true;
54792
54954
  };
54793
- DDiagramSnapshot.prototype.toCleanupRefit = function (options) {
54794
- if (options == null) {
54795
- return true;
54796
- }
54797
- var cleanup = options.cleanup;
54798
- if (cleanup == null || cleanup === true) {
54799
- return true;
54800
- }
54801
- return cleanup !== false && cleanup.refit !== false;
54802
- };
54803
54955
  DDiagramSnapshot.prototype.toCleanupReflow = function (options) {
54804
54956
  if (options == null) {
54805
54957
  return true;
@@ -54849,17 +55001,11 @@
54849
55001
  }
54850
55002
  }
54851
55003
  // Refit & reflow
54852
- var refit = this.toCleanupRefit(options);
54853
55004
  var reflow = this.toCleanupReflow(options);
54854
- if (refit || reflow) {
55005
+ if (reflow) {
54855
55006
  var layer = DApplications.getLayer(canvas);
54856
55007
  if (layer) {
54857
- if (refit) {
54858
- layer.refit();
54859
- }
54860
- if (reflow) {
54861
- layer.reflow();
54862
- }
55008
+ layer.reflow();
54863
55009
  }
54864
55010
  }
54865
55011
  // Extracts
@@ -58987,12 +59133,12 @@
58987
59133
  DMenuSided.prototype.newSelection = function (options) {
58988
59134
  return new DMenuSidedSelection(this.content, options);
58989
59135
  };
58990
- DMenuSided.prototype.onChildrenDirty = function () {
59136
+ DMenuSided.prototype.onHierarchyDirty = function () {
58991
59137
  var selection = this._selection;
58992
59138
  if (selection != null) {
58993
59139
  selection.toDirty();
58994
59140
  }
58995
- _super.prototype.onChildrenDirty.call(this);
59141
+ _super.prototype.onHierarchyDirty.call(this);
58996
59142
  };
58997
59143
  DMenuSided.prototype.newItems = function (items, sticky) {
58998
59144
  DMenuSideds.newItems(this.content, items, sticky);