a2b1c7f6a775da53c13c86795a6fc43e94bebc3c.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. System.register(["__unresolved_0", "cc", "cc/env", "__unresolved_1"], function (_export, _context) {
  2. "use strict";
  3. var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, Widget, _decorator, EDITOR, Adapter, _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _crd, ccclass, property, executeInEditMode, menu, Flags, AdapterSafeArea;
  4. function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
  5. function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
  6. function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
  7. function _reportPossibleCrUseOfAdapter(extras) {
  8. _reporterNs.report("Adapter", "./Adapter", _context.meta, extras);
  9. }
  10. return {
  11. setters: [function (_unresolved_) {
  12. _reporterNs = _unresolved_;
  13. }, function (_cc) {
  14. _cclegacy = _cc.cclegacy;
  15. __checkObsolete__ = _cc.__checkObsolete__;
  16. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  17. Widget = _cc.Widget;
  18. _decorator = _cc._decorator;
  19. }, function (_ccEnv) {
  20. EDITOR = _ccEnv.EDITOR;
  21. }, function (_unresolved_2) {
  22. Adapter = _unresolved_2.Adapter;
  23. }],
  24. execute: function () {
  25. _crd = true;
  26. _cclegacy._RF.push({}, "5e52cT+eOdD5ZJK8aNQofsx", "AdapterSafeArea", undefined);
  27. __checkObsolete__(['Widget', '_decorator']);
  28. ({
  29. ccclass,
  30. property,
  31. executeInEditMode,
  32. menu
  33. } = _decorator);
  34. Flags = /*#__PURE__*/function (Flags) {
  35. Flags[Flags["None"] = 0] = "None";
  36. Flags[Flags["TOP"] = 1] = "TOP";
  37. Flags[Flags["BOTTOM"] = 2] = "BOTTOM";
  38. Flags[Flags["LEFT"] = 4] = "LEFT";
  39. Flags[Flags["RIGHT"] = 8] = "RIGHT";
  40. return Flags;
  41. }(Flags || {});
  42. /**
  43. * @classdesc 安全区域适配Widget , App.isFullScreenAdaption = true 时有效
  44. * @description
  45. *
  46. * 用法:
  47. *
  48. * 1. 将本组件挂载在节点上即可(注意:该节点上必须挂在 Widget 组件)
  49. *
  50. * 适配原理:
  51. *
  52. * 1. 根据安全区域范围,修改widget组件属性
  53. * 自动添加刘海宽度,以避免显示到安全区域之外
  54. */
  55. _export("default", AdapterSafeArea = (_dec = ccclass("AdapterSafeArea"), _dec2 = menu("Quick适配组件/AdapterSafeArea"), _dec3 = property({
  56. tooltip: EDITOR ? "是否对齐上边" : ""
  57. }), _dec4 = property({
  58. tooltip: EDITOR ? "是否对齐下边" : ""
  59. }), _dec5 = property({
  60. tooltip: EDITOR ? "是否对齐左边" : ""
  61. }), _dec6 = property({
  62. tooltip: EDITOR ? "是否对齐右边" : ""
  63. }), _dec7 = property({
  64. visible: function visible() {
  65. return this.isAlignTop;
  66. },
  67. tooltip: EDITOR ? "本节点顶边和父节点顶边的距离,可填写负值,只有在 isAlignTop 开启时才有作用" : ""
  68. }), _dec8 = property({
  69. visible: function visible() {
  70. return this.isAlignBottom;
  71. },
  72. tooltip: EDITOR ? "本节点顶边和父节点底边的距离,可填写负值,只有在 isAlignBottom 开启时才有作用" : ""
  73. }), _dec9 = property({
  74. visible: function visible() {
  75. return this.isAlignLeft;
  76. },
  77. tooltip: EDITOR ? "本节点顶边和父节点左边的距离,可填写负值,只有在 isAlignLeft 开启时才有作用" : ""
  78. }), _dec10 = property({
  79. visible: function visible() {
  80. return this.isAlignRight;
  81. },
  82. tooltip: EDITOR ? "本节点顶边和父节点右边的距离,可填写负值,只有在 isAlignRight 开启时才有作用" : ""
  83. }), _dec(_class = executeInEditMode(_class = _dec2(_class = (_class2 = class AdapterSafeArea extends (_crd && Adapter === void 0 ? (_reportPossibleCrUseOfAdapter({
  84. error: Error()
  85. }), Adapter) : Adapter) {
  86. constructor() {
  87. super(...arguments);
  88. _initializerDefineProperty(this, "_flags", _descriptor, this);
  89. _initializerDefineProperty(this, "_top", _descriptor2, this);
  90. _initializerDefineProperty(this, "_bottom", _descriptor3, this);
  91. _initializerDefineProperty(this, "_left", _descriptor4, this);
  92. _initializerDefineProperty(this, "_right", _descriptor5, this);
  93. this._isDirty = false;
  94. }
  95. setFlag(flag, value) {
  96. var current = (this._flags & flag) > 0;
  97. if (value == current) {
  98. return;
  99. }
  100. if (value) {
  101. this._flags |= flag;
  102. } else {
  103. this._flags &= ~flag;
  104. }
  105. this._isDirty = true;
  106. }
  107. get isAlignTop() {
  108. return (this._flags & Flags.TOP) > 0;
  109. }
  110. set isAlignTop(v) {
  111. this.setFlag(Flags.TOP, v);
  112. }
  113. get isAlignBottom() {
  114. return (this._flags & Flags.BOTTOM) > 0;
  115. }
  116. set isAlignBottom(v) {
  117. this.setFlag(Flags.BOTTOM, v);
  118. }
  119. get isAlignLeft() {
  120. return (this._flags & Flags.LEFT) > 0;
  121. }
  122. set isAlignLeft(v) {
  123. this.setFlag(Flags.LEFT, v);
  124. }
  125. get isAlignRight() {
  126. return (this._flags & Flags.RIGHT) > 0;
  127. }
  128. set isAlignRight(v) {
  129. this.setFlag(Flags.RIGHT, v);
  130. }
  131. get top() {
  132. return this._top;
  133. }
  134. set top(v) {
  135. if (this._top == v) {
  136. return;
  137. }
  138. this._top = v;
  139. this._isDirty = true;
  140. }
  141. get bottom() {
  142. return this._bottom;
  143. }
  144. set bottom(v) {
  145. if (this._bottom == v) {
  146. return;
  147. }
  148. this._bottom = v;
  149. this._isDirty = true;
  150. }
  151. get left() {
  152. return this._left;
  153. }
  154. set left(v) {
  155. if (this._left == v) {
  156. return;
  157. }
  158. this._left = v;
  159. this._isDirty = true;
  160. }
  161. get right() {
  162. return this._right;
  163. }
  164. set right(v) {
  165. if (this._right == v) {
  166. return;
  167. }
  168. this._right = v;
  169. this._isDirty = true;
  170. }
  171. get widget() {
  172. var comp = this.getComponent(Widget);
  173. if (comp) {
  174. return comp;
  175. }
  176. return this.addComponent(Widget);
  177. }
  178. resetInEditor() {
  179. this.doLayout(true);
  180. }
  181. doLayout(isForce) {
  182. if (isForce === void 0) {
  183. isForce = false;
  184. }
  185. if (this._isDirty || isForce) {
  186. var widget = this.widget;
  187. if (EDITOR) {
  188. widget.left = this.left;
  189. widget.right = this.right;
  190. widget.top = this.top;
  191. widget.bottom = this.bottom;
  192. return;
  193. }
  194. if (!this.isFullScreenAdaption) {
  195. return;
  196. }
  197. if (!widget || !widget.enabled) {
  198. return;
  199. } // 屏幕向上时,加上安全区域高度
  200. if (widget.isAlignTop && this.isAlignTop) {
  201. widget.isAbsoluteTop = true;
  202. if (this.direction == (_crd && Adapter === void 0 ? (_reportPossibleCrUseOfAdapter({
  203. error: Error()
  204. }), Adapter) : Adapter).direction.Portrait) {
  205. widget.top = this.top + (_crd && Adapter === void 0 ? (_reportPossibleCrUseOfAdapter({
  206. error: Error()
  207. }), Adapter) : Adapter).safeArea.outside.height;
  208. } else {
  209. widget.top = this.top;
  210. }
  211. } // 屏幕向下时,加上安全区域高度
  212. if (widget.isAlignBottom && this.isAlignBottom) {
  213. widget.isAbsoluteBottom = true;
  214. if (this.direction == (_crd && Adapter === void 0 ? (_reportPossibleCrUseOfAdapter({
  215. error: Error()
  216. }), Adapter) : Adapter).direction.UpsideDown) {
  217. widget.bottom = this.bottom + (_crd && Adapter === void 0 ? (_reportPossibleCrUseOfAdapter({
  218. error: Error()
  219. }), Adapter) : Adapter).safeArea.outside.height;
  220. } else {
  221. widget.bottom = this.bottom;
  222. }
  223. } // 屏幕向左时,加上安全区域宽度
  224. if (widget.isAlignLeft && this.isAlignLeft) {
  225. widget.isAbsoluteLeft = true;
  226. if (this.direction == (_crd && Adapter === void 0 ? (_reportPossibleCrUseOfAdapter({
  227. error: Error()
  228. }), Adapter) : Adapter).direction.LandscapeLeft) {
  229. widget.left = this.left + (_crd && Adapter === void 0 ? (_reportPossibleCrUseOfAdapter({
  230. error: Error()
  231. }), Adapter) : Adapter).safeArea.outside.width;
  232. } else {
  233. widget.left = this.left;
  234. }
  235. } // 屏幕向右时,加上安全区域宽度
  236. if (widget.isAlignRight && this.isAlignRight) {
  237. widget.isAbsoluteRight = true;
  238. if (this.direction == (_crd && Adapter === void 0 ? (_reportPossibleCrUseOfAdapter({
  239. error: Error()
  240. }), Adapter) : Adapter).direction.LandscapeRight) {
  241. widget.right = this.right + (_crd && Adapter === void 0 ? (_reportPossibleCrUseOfAdapter({
  242. error: Error()
  243. }), Adapter) : Adapter).safeArea.outside.width;
  244. } else {
  245. widget.right = this.right;
  246. }
  247. }
  248. widget.updateAlignment();
  249. this._isDirty = false;
  250. this.doOnAdapterComplete();
  251. }
  252. }
  253. onChangeSize() {
  254. this.doLayout(true);
  255. }
  256. update(dt) {
  257. super.update && super.update(dt);
  258. this.doLayout();
  259. }
  260. }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "_flags", [property], {
  261. configurable: true,
  262. enumerable: true,
  263. writable: true,
  264. initializer: function initializer() {
  265. return Flags.None;
  266. }
  267. }), _applyDecoratedDescriptor(_class2.prototype, "isAlignTop", [_dec3], Object.getOwnPropertyDescriptor(_class2.prototype, "isAlignTop"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "isAlignBottom", [_dec4], Object.getOwnPropertyDescriptor(_class2.prototype, "isAlignBottom"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "isAlignLeft", [_dec5], Object.getOwnPropertyDescriptor(_class2.prototype, "isAlignLeft"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "isAlignRight", [_dec6], Object.getOwnPropertyDescriptor(_class2.prototype, "isAlignRight"), _class2.prototype), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "_top", [property], {
  268. configurable: true,
  269. enumerable: true,
  270. writable: true,
  271. initializer: function initializer() {
  272. return 0;
  273. }
  274. }), _applyDecoratedDescriptor(_class2.prototype, "top", [_dec7], Object.getOwnPropertyDescriptor(_class2.prototype, "top"), _class2.prototype), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "_bottom", [property], {
  275. configurable: true,
  276. enumerable: true,
  277. writable: true,
  278. initializer: function initializer() {
  279. return 0;
  280. }
  281. }), _applyDecoratedDescriptor(_class2.prototype, "bottom", [_dec8], Object.getOwnPropertyDescriptor(_class2.prototype, "bottom"), _class2.prototype), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "_left", [property], {
  282. configurable: true,
  283. enumerable: true,
  284. writable: true,
  285. initializer: function initializer() {
  286. return 0;
  287. }
  288. }), _applyDecoratedDescriptor(_class2.prototype, "left", [_dec9], Object.getOwnPropertyDescriptor(_class2.prototype, "left"), _class2.prototype), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "_right", [property], {
  289. configurable: true,
  290. enumerable: true,
  291. writable: true,
  292. initializer: function initializer() {
  293. return 0;
  294. }
  295. }), _applyDecoratedDescriptor(_class2.prototype, "right", [_dec10], Object.getOwnPropertyDescriptor(_class2.prototype, "right"), _class2.prototype)), _class2)) || _class) || _class) || _class));
  296. _cclegacy._RF.pop();
  297. _crd = false;
  298. }
  299. };
  300. });
  301. //# sourceMappingURL=a2b1c7f6a775da53c13c86795a6fc43e94bebc3c.js.map