@shijiu/jsview 1.9.731 → 1.9.759

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 (124) hide show
  1. package/dom/jsv-browser-debug-dom.js +12 -5
  2. package/dom/jsv-code-debug.mjs +14 -0
  3. package/dom/jsv-dom.js +12 -5
  4. package/dom/jsv-engine-js-browser.js +12 -5
  5. package/dom/jsv-forge-define.js +17 -5
  6. package/package.json +14 -17
  7. package/patches/node_modules/react-scripts/config/paths.js +161 -0
  8. package/patches/node_modules/react-scripts/config/webpack.config.js +825 -0
  9. package/patches/node_modules/react-scripts/package.json +108 -0
  10. package/patches/node_modules/vite/dist/node/chunks/dep-0fc8e132.js +8 -1
  11. package/patches/node_modules/vite/dist/node/jsview.vite.config.js +15 -7
  12. package/tools/common.js +7 -2
  13. package/tools/jsview-post-build.js +3 -3
  14. package/tools/jsview-post-install-react.js +1 -3
  15. package/tools/jsview-post-install.js +1 -1
  16. package/dom/jsview-dom/README.md +0 -5
  17. package/dom/jsview-dom/package-lock.json-perfect +0 -3898
  18. package/dom/jsview-dom/package.json +0 -23
  19. package/dom/jsview-dom/rollup/browser-debug-dom.rollup.config.js +0 -15
  20. package/dom/jsview-dom/rollup/dom.rollup.config.js +0 -14
  21. package/dom/jsview-dom/rollup/engine-js-browser.rollup.config.js +0 -14
  22. package/dom/jsview-dom/rollup/forge-define.rollup.config.js +0 -14
  23. package/dom/jsview-dom/scripts/release_dist.sh +0 -36
  24. package/dom/jsview-dom/src/dom-browser-hook/HookDocument.js +0 -118
  25. package/dom/jsview-dom/src/dom-browser-hook/OriginDocument.js +0 -19
  26. package/dom/jsview-dom/src/dom-browser-hook/StyleFormatCheck.js +0 -559
  27. package/dom/jsview-dom/src/dom-browser-hook/index.js +0 -6
  28. package/dom/jsview-dom/src/dom-wrapper/ForgeExtension.js +0 -226
  29. package/dom/jsview-dom/src/dom-wrapper/JsViewForgeApp.js +0 -85
  30. package/dom/jsview-dom/src/dom-wrapper/JsViewProxy.js +0 -51
  31. package/dom/jsview-dom/src/dom-wrapper/event/AnimationEvent.js +0 -7
  32. package/dom/jsview-dom/src/dom-wrapper/event/Event.js +0 -12
  33. package/dom/jsview-dom/src/dom-wrapper/event/FocusEvent.js +0 -9
  34. package/dom/jsview-dom/src/dom-wrapper/event/KeyboardEvent.js +0 -43
  35. package/dom/jsview-dom/src/dom-wrapper/event/LoadEvent.js +0 -8
  36. package/dom/jsview-dom/src/dom-wrapper/index.js +0 -16
  37. package/dom/jsview-dom/src/dom-wrapper/node/AnchorElement.js +0 -24
  38. package/dom/jsview-dom/src/dom-wrapper/node/AudioElement.js +0 -60
  39. package/dom/jsview-dom/src/dom-wrapper/node/Comment.js +0 -10
  40. package/dom/jsview-dom/src/dom-wrapper/node/DivElement.js +0 -498
  41. package/dom/jsview-dom/src/dom-wrapper/node/Document.js +0 -274
  42. package/dom/jsview-dom/src/dom-wrapper/node/Element.js +0 -852
  43. package/dom/jsview-dom/src/dom-wrapper/node/FDivElement.js +0 -48
  44. package/dom/jsview-dom/src/dom-wrapper/node/HeadElement.js +0 -47
  45. package/dom/jsview-dom/src/dom-wrapper/node/ImageElement.js +0 -203
  46. package/dom/jsview-dom/src/dom-wrapper/node/JsvAudioTrackElement.js +0 -22
  47. package/dom/jsview-dom/src/dom-wrapper/node/JsvElement.js +0 -40
  48. package/dom/jsview-dom/src/dom-wrapper/node/LinkElement.js +0 -48
  49. package/dom/jsview-dom/src/dom-wrapper/node/MediaElement.js +0 -230
  50. package/dom/jsview-dom/src/dom-wrapper/node/Node.js +0 -178
  51. package/dom/jsview-dom/src/dom-wrapper/node/SVGElement.js +0 -9
  52. package/dom/jsview-dom/src/dom-wrapper/node/ScriptElement.js +0 -45
  53. package/dom/jsview-dom/src/dom-wrapper/node/StyleElement.js +0 -33
  54. package/dom/jsview-dom/src/dom-wrapper/node/StyleElementCache.js +0 -41
  55. package/dom/jsview-dom/src/dom-wrapper/node/Text.js +0 -22
  56. package/dom/jsview-dom/src/dom-wrapper/node/UnknownElement.js +0 -4
  57. package/dom/jsview-dom/src/dom-wrapper/node/VideoElement.js +0 -237
  58. package/dom/jsview-dom/src/dom-wrapper/style/BorderImage.js +0 -25
  59. package/dom/jsview-dom/src/dom-wrapper/style/Inset.js +0 -26
  60. package/dom/jsview-dom/src/dom-wrapper/style/JsvStyleVariable.js +0 -65
  61. package/dom/jsview-dom/src/dom-wrapper/style/KeyframeRule.js +0 -11
  62. package/dom/jsview-dom/src/dom-wrapper/style/StyleDeclaration.js +0 -609
  63. package/dom/jsview-dom/src/dom-wrapper/style/StyleSheet.js +0 -51
  64. package/dom/jsview-dom/src/dom-wrapper/style/StyleValue.js +0 -385
  65. package/dom/jsview-dom/src/dom-wrapper/style/TextStylePackMap.js +0 -43
  66. package/dom/jsview-dom/src/dom-wrapper/style/URL.js +0 -144
  67. package/dom/jsview-dom/src/dom-wrapper/utils/EventHandler.js +0 -42
  68. package/dom/jsview-dom/src/dom-wrapper/utils/FDivRoot.js +0 -86
  69. package/dom/jsview-dom/src/dom-wrapper/utils/JsvLazySyncCache.js +0 -64
  70. package/dom/jsview-dom/src/dom-wrapper/utils/Log.js +0 -42
  71. package/dom/jsview-dom/src/dom-wrapper/utils/MutationObserver.js +0 -32
  72. package/dom/jsview-dom/src/dom-wrapper/utils/focusableNode.js +0 -715
  73. package/dom/jsview-dom/src/engine-js/ForgeDefine.js +0 -8
  74. package/dom/jsview-dom/src/engine-js/ForgeExtensionDefine.js +0 -14
  75. package/dom/jsview-dom/src/engine-js/browser/PlatformUtils.js +0 -100
  76. package/dom/jsview-dom/src/engine-js/browser/animation_base.js +0 -313
  77. package/dom/jsview-dom/src/engine-js/browser/animation_keyframe.js +0 -64
  78. package/dom/jsview-dom/src/engine-js/browser/animation_progress.js +0 -287
  79. package/dom/jsview-dom/src/engine-js/browser/animation_proxy.js +0 -906
  80. package/dom/jsview-dom/src/engine-js/browser/apic_decoder/demux.js +0 -143
  81. package/dom/jsview-dom/src/engine-js/browser/apic_decoder/gifDecoder.js +0 -12
  82. package/dom/jsview-dom/src/engine-js/browser/apic_decoder/libwebp-0.6.0.min.js +0 -160
  83. package/dom/jsview-dom/src/engine-js/browser/console_log.js +0 -25
  84. package/dom/jsview-dom/src/engine-js/browser/dynamic_key_frames.js +0 -95
  85. package/dom/jsview-dom/src/engine-js/browser/easing.js +0 -114
  86. package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/element_transform.js +0 -122
  87. package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/gjk.js +0 -450
  88. package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/mat.js +0 -102
  89. package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/range_model.js +0 -296
  90. package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/test_collide.js +0 -10
  91. package/dom/jsview-dom/src/engine-js/browser/index.js +0 -38
  92. package/dom/jsview-dom/src/engine-js/browser/latex_parse.js +0 -336
  93. package/dom/jsview-dom/src/engine-js/browser/layout_params.js +0 -113
  94. package/dom/jsview-dom/src/engine-js/browser/layout_view.js +0 -3545
  95. package/dom/jsview-dom/src/engine-js/browser/layout_view_debug.js +0 -15
  96. package/dom/jsview-dom/src/engine-js/browser/media.js +0 -379
  97. package/dom/jsview-dom/src/engine-js/browser/page_base.js +0 -941
  98. package/dom/jsview-dom/src/engine-js/browser/particle_view.js +0 -526
  99. package/dom/jsview-dom/src/engine-js/browser/platform_timer.js +0 -61
  100. package/dom/jsview-dom/src/engine-js/browser/react_utils.js +0 -5
  101. package/dom/jsview-dom/src/engine-js/browser/rect_utils.js +0 -91
  102. package/dom/jsview-dom/src/engine-js/browser/render_bridge.js +0 -128
  103. package/dom/jsview-dom/src/engine-js/browser/render_texture_proxy.js +0 -155
  104. package/dom/jsview-dom/src/engine-js/browser/renderer_deprecated.js +0 -75
  105. package/dom/jsview-dom/src/engine-js/browser/sound_pool.js +0 -139
  106. package/dom/jsview-dom/src/engine-js/browser/steps_animation.js +0 -192
  107. package/dom/jsview-dom/src/engine-js/browser/text_style_cache.js +0 -454
  108. package/dom/jsview-dom/src/engine-js/browser/text_utils.js +0 -299
  109. package/dom/jsview-dom/src/engine-js/browser/text_view.js +0 -428
  110. package/dom/jsview-dom/src/engine-js/browser/texture_manager.js +0 -1060
  111. package/dom/jsview-dom/src/engine-js/browser/url.js +0 -69
  112. package/dom/jsview-dom/src/engine-js/browser/velocity.js +0 -40
  113. package/dom/jsview-dom/src/engine-js/browser/view_sensor/autofroze_sensor.js +0 -77
  114. package/dom/jsview-dom/src/engine-js/browser/view_sensor/drag_impact_sensor.js +0 -67
  115. package/dom/jsview-dom/src/engine-js/browser/view_sensor/impact_sensor.js +0 -98
  116. package/dom/jsview-dom/src/engine-js/browser/view_sensor/impact_sensor_callback.js +0 -21
  117. package/dom/jsview-dom/src/engine-js/browser/view_sensor/impact_sensor_manager.js +0 -24
  118. package/dom/jsview-dom/src/engine-js/browser/view_sensor/index.js +0 -9
  119. package/dom/jsview-dom/src/engine-js/browser/view_sensor/view_sensor.js +0 -268
  120. package/dom/jsview-dom/src/engine-js/browser/view_sensor/view_sensor_manager.js +0 -84
  121. package/dom/jsview-dom/src/engine-js/browser/view_sensor/visible_sensor.js +0 -213
  122. package/dom/jsview-dom/src/engine-js/browser/view_store.js +0 -41
  123. package/dom/jsview-dom/src/engine-js/index.js +0 -2
  124. package/dom/jsview-dom/src/engine-js/native/README.md +0 -1
@@ -1,428 +0,0 @@
1
- /* eslint-disable no-unused-vars */
2
- /* eslint-disable no-prototype-builtins */
3
- import Forge from "../ForgeDefine";
4
-
5
- Forge.TextShaderType = {
6
- LinearGradient: 0,
7
- Image: 1,
8
- };
9
- class TextShader {
10
- constructor(type, params) {
11
- this.Type = type;
12
- this.Params = params;
13
- }
14
- }
15
- Forge.TextShader = TextShader;
16
- class TextViewParams {
17
- constructor() {
18
- const layout_view = new Forge.LayoutView();
19
- const renderer = layout_view.GetRenderer();
20
- this._Renderer = renderer;
21
- this.StringWithFont = Forge.sTextUtils.StringWithFont("", 0, undefined, "center", "middle", undefined, false, false, undefined, undefined, "top");
22
- this.RectArea = new Forge.RectArea(0, 0, 0, 0);// default w:0, h:0
23
- this.TextAttr = Forge.sTextUtils.TextAttr("ellipsis", "none");
24
- this.Marquee = null;// {repetition: "infinite", direction: "left", speed: "normal" };
25
- this.Shader = null;
26
- this.IsInstantLoad = true;
27
- this.LineHeight = 0;
28
- this.LatexMode = false;
29
- }
30
-
31
- SetInstantLoad(is_instant_load) {
32
- this.IsInstantLoad = is_instant_load;
33
- return this;
34
- }
35
-
36
- SetStringWithFont(string_with_font) {
37
- this.StringWithFont = string_with_font;// renderer.StringWithFont
38
- return this;
39
- }
40
-
41
- SetLatexMode(latex_mode) {
42
- this.LatexMode = latex_mode;
43
- return this;
44
- }
45
-
46
- SetFontStyle(_size_or_set, _font, _alignment, _vertical_align, _text_color, _italic, _bold, _shadow, _stroke_width, _vertical_area_align) {
47
- if (typeof _size_or_set === "object") {
48
- this.StringWithFont = Forge.sTextUtils.StringWithFont(
49
- "",
50
- (typeof _size_or_set.size !== "undefined" ? _size_or_set.size : 10),
51
- (typeof _size_or_set.font !== "undefined" ? _size_or_set.font : "宋体"),
52
- (typeof _size_or_set.hAlign !== "undefined" ? _size_or_set.hAlign : "center"),
53
- (typeof _size_or_set.vAlign !== "undefined" ? _size_or_set.vAlign : "middle"),
54
- (typeof _size_or_set.textColor !== "undefined" ? _size_or_set.textColor : "#000000"),
55
- (typeof _size_or_set.italic !== "undefined" ? _size_or_set.italic : false),
56
- (typeof _size_or_set.bold !== "undefined" ? _size_or_set.bold : false),
57
- (typeof _size_or_set.shadow !== "undefined" ? _size_or_set.shadow : null),
58
- (typeof _size_or_set.strokeWidth !== "undefined" ? _size_or_set.strokeWidth : null),
59
- (typeof _size_or_set.vAreaAlign !== "undefined" ? _size_or_set.vAreaAlign : "top"),
60
- );
61
- } else {
62
- this.StringWithFont = Forge.sTextUtils.StringWithFont(
63
- "", _size_or_set, _font, _alignment, _vertical_align, _text_color, _italic, _bold, _shadow, _stroke_width, _vertical_area_align);
64
- }
65
- return this;
66
- }
67
-
68
- SetRectArea(rect_area) {
69
- if (rect_area instanceof Forge.RectArea) {
70
- this.RectArea = rect_area;
71
- } else {
72
- this.RectArea = new Forge.RectArea(rect_area.x, rect_area.y, rect_area.width, rect_area.height);
73
- }
74
- return this;
75
- }
76
-
77
- SetViewSize(rect_area) {
78
- if (!(rect_area instanceof Forge.RectArea)) {
79
- rect_area = new Forge.RectArea(rect_area.x, rect_area.y, rect_area.width, rect_area.height);
80
- }
81
- this.SetRectArea(rect_area);
82
- if (this.LineHeight === 0 && rect_area.height !== 0) {
83
- this.LineHeight = rect_area.height;
84
- }
85
- return this;
86
- }
87
-
88
- SetTextAttr(set) {
89
- let text_overflow;
90
- if (set.hasOwnProperty("textOverflow")) { text_overflow = set.textOverflow; } else if (set.hasOwnProperty("text_overflow")) // 兼容老定义
91
- { text_overflow = set.text_overflow; } else { text_overflow = "clip"; }
92
- let word_wrap;
93
- if (set.hasOwnProperty("wordWrap")) { word_wrap = set.wordWrap; } else if (set.hasOwnProperty("word_wrap")) // 兼容老定义
94
- { word_wrap = set.word_wrap; } else { word_wrap = "none"; }
95
- this.TextAttr = {
96
- word_wrap,
97
- text_overflow
98
- };
99
- return this;
100
- }
101
-
102
- SetMarquee(marquee) {
103
- if (marquee) {
104
- this.Marquee = { repetition: "infinite", direction: "left", speed: "normal" };// set default
105
- if (marquee.repetition) { this.Marquee.repetition = marquee.repetition; }
106
- if (marquee.direction) { this.Marquee.direction = marquee.direction; }
107
- if (marquee.speed) { this.Marquee.speed = marquee.speed; }
108
- }
109
- return this;
110
- }
111
-
112
- SetShader(shader) {
113
- this.Shader = shader;
114
- return this;
115
- }
116
-
117
- SetLineHeight(line_height) {
118
- this.LineHeight = line_height;
119
- return this;
120
- }
121
-
122
- // 启用获取复制文字Texture信息功能
123
- EnableDuplicateBuilder() {
124
- this.BuildCopyBag = true;
125
- }
126
-
127
- Clone() {
128
- const text_view_params = new TextViewParams(null);
129
- text_view_params.StringWithFont = this.StringWithFont;
130
- text_view_params.RectArea = this.RectArea;
131
- text_view_params.TextAttr = this.TextAttr;
132
- text_view_params.LineHeight = this.LineHeight;
133
- return text_view_params;
134
- }
135
- }
136
- Forge.TextViewParams = TextViewParams;
137
- window.TextViewParams = Forge.TextViewParams;
138
-
139
- class TextViewEx {
140
- constructor(texture_manager, text_view_params, text_string, quick, texture_onload_callbacks) {
141
- this._layoutView = null;
142
- this._textWidth = 0;
143
- this._textViewReahHeight = 0;
144
- this._marqueeRunning = true;
145
- this._marqueePause = false;
146
- this._marqueeCurrentNum = 2;
147
- this._textView = null;
148
- this._TextViewParams = text_view_params;
149
- this._NeedQuick = typeof quick === "undefined" ? false : quick;// 默认需要实际高度
150
- this._marquee = text_view_params.Marquee;
151
- this._rectArea = text_view_params.RectArea;
152
- this._DrawCount = 0;
153
- this._ShowInterval = 0;
154
- this._TextureManager = texture_manager;
155
- this._LatexMode = text_view_params.LatexMode;
156
- this._Shader = text_view_params.Shader;
157
- this._IsInstantLoad = text_view_params.IsInstantLoad ? 1 : 0;
158
- this._AutoHeight = false;
159
- this._EnableTextureOnloadCallback = !!texture_onload_callbacks;
160
- this._DuplicateBag = (text_view_params.BuildCopyBag ?
161
- {
162
- // 创建非空bag后,就可以在GetTextTextureByMultiRows()处理时获取信息
163
- Set: null, // Texture的ResourceInfo中的Set
164
- Swf: null, // String with font
165
- Siz: null, // AddView时的width和height
166
- } : null);
167
- const _this = this;
168
- let _renderer = null;
169
- const _blockWidth = text_view_params.RectArea.width;
170
- const _blockHeight = text_view_params.RectArea.height;
171
- let _stringWithFont = null;
172
- let _matrixClipLayoutview = null;
173
-
174
- if (this._marquee !== null) {
175
- // 只有在Maquee情况下需要ClipView(PS: react模式下不需要文字自身的maquee)
176
- _matrixClipLayoutview = new Forge.ClipView();
177
- _matrixClipLayoutview.Init();
178
- _matrixClipLayoutview.SetClipRect(
179
- 0,
180
- 0,
181
- _blockWidth,
182
- _blockHeight,
183
- true);
184
- _matrixClipLayoutview.SetId("matrixClipLayoutview");
185
- _matrixClipLayoutview.OnDettachFromSystem = function () {
186
- _this._marqueeRunning = false;
187
- Forge.ClipView.prototype.OnDettachFromSystem.call(this); // Call to super class
188
- };
189
- } else {
190
- _matrixClipLayoutview = new Forge.LayoutView();
191
- _matrixClipLayoutview.OnDettachFromSystem = function () {
192
- if (this._TextureOnloadCallbacksTimer) {
193
- clearTimeout(this._TextureOnloadCallbacksTimer);
194
- this._TextureOnloadCallbacksTimer = null;
195
- }
196
- };
197
- }
198
-
199
- _renderer = _matrixClipLayoutview.GetRenderer();
200
- this._Renderer = _renderer;
201
- let text_str = text_string;
202
- if (!text_str) {
203
- text_str = text_view_params.StringWithFont.str;
204
- }
205
- // 对字符串进行转义字符替换(Escape character);
206
- text_str = this._ConvertEscToString(text_str);
207
- let italic = false;
208
- if (text_view_params.StringWithFont.italic.length > 0) {
209
- italic = true;
210
- }
211
- let bold = false;
212
- if (text_view_params.StringWithFont.bold.length > 0) {
213
- bold = true;
214
- }
215
- _stringWithFont = Forge.sTextUtils.StringWithFont(
216
- text_str,
217
- text_view_params.StringWithFont.size,
218
- text_view_params.StringWithFont.font,
219
- text_view_params.StringWithFont.alignment,
220
- text_view_params.StringWithFont.vertical_align,
221
- text_view_params.StringWithFont.textColour,
222
- italic,
223
- bold,
224
- text_view_params.StringWithFont.shadow,
225
- text_view_params.StringWithFont.stroke_width,
226
- text_view_params.StringWithFont.vertical_area_align
227
- );
228
-
229
- // 需要实际宽高时,或有跑马灯设置,才获取实际的宽度
230
- if (typeof text_view_params.Marquee !== "undefined"
231
- && text_view_params.Marquee !== null) {
232
- this._textWidth = Forge.sTextUtils.GetTextWidth(_stringWithFont);
233
- } else if (!this._NeedQuick) {
234
- this._textWidth = Forge.sTextUtils.GetTextWidth(_stringWithFont);
235
- } else {
236
- this._textWidth = text_view_params.RectArea.width - 2 * text_view_params.RectArea.x;
237
- }
238
-
239
- // add text view
240
- this.addTextView(_matrixClipLayoutview, _stringWithFont,
241
- text_view_params.TextAttr, text_view_params.RectArea,
242
- text_view_params.Marquee, text_view_params.LineHeight);
243
- if (this._TextureOnloadCallbacksTimer) {
244
- clearTimeout(this._TextureOnloadCallbacksTimer);
245
- this._TextureOnloadCallbacksTimer = null;
246
- }
247
- this._TextureOnloadCallbacksTimer = setTimeout(() => {
248
- if (texture_onload_callbacks) {
249
- texture_onload_callbacks({
250
- width: this._textView.Element.clientWidth,
251
- height: this._textView.Element.clientHeight
252
- });
253
- }
254
- }, 0);
255
-
256
- this._layoutView = _matrixClipLayoutview;
257
-
258
- this._TextTexture = null;
259
-
260
- this._MarqueeTimer = null;
261
- }
262
-
263
- _ConvertEscToString(src_string) {
264
- let dst_str = `${src_string}`;// 强转字符串型
265
- if (dst_str.indexOf(""") !== -1) {
266
- dst_str = dst_str.replace(/"/ig, "\"");
267
- }
268
- if (dst_str.indexOf("&") !== -1) {
269
- dst_str = dst_str.replace(/&/ig, "&");
270
- }
271
- if (dst_str.indexOf("<") !== -1) {
272
- dst_str = dst_str.replace(/</ig, ">");
273
- }
274
- if (dst_str.indexOf(">") !== -1) {
275
- dst_str = dst_str.replace(/&gt;/ig, "<");
276
- }
277
- if (dst_str.indexOf("&nbsp;") !== -1) {
278
- dst_str = dst_str.replace(/&nbsp;/ig, " ");
279
- }
280
- return dst_str;
281
- }
282
-
283
- EnableAutoHeight() {
284
- this._AutoHeight = true;
285
- this._textView.EnableAutoHeight();
286
- }
287
-
288
- addTextView(parent_view, t_StringWithFont, t_TextAttr, t_RectArea, t_Marquee, line_height) {
289
- const block_height = t_RectArea.height;
290
- let text_texture;
291
- const rect_area = Forge.Clone(t_RectArea);
292
- let text_view = null;
293
- if (t_StringWithFont.str.length !== 0) {
294
- text_texture = this._TextureManager.GetTextTextureByMultiRows(t_StringWithFont, t_TextAttr, rect_area,
295
- line_height, this._NeedQuick, this._Shader, this._IsInstantLoad, this._LatexMode, this._DuplicateBag);
296
-
297
- // Set text texture
298
- this._TextTexture = text_texture.texture;
299
-
300
- // set real height
301
- this._textViewReahHeight = text_texture.real_height;
302
- text_view = new Forge.LayoutView();
303
- text_view.Init(new Forge.TextureSetting(text_texture.texture, null, null, true));
304
- text_view.SetId(`Text-${t_StringWithFont.str}`);
305
-
306
- if (t_StringWithFont.vertical_area_align === "middle" || t_StringWithFont.vertical_area_align === "bottom") {
307
- text_view.Element.style.display = "table-cell";
308
- text_view.Element.style.position = "static";
309
- parent_view.Element.style.display = "table";
310
- parent_view.Element.style.position = "static";
311
- }
312
- parent_view.AddView(text_view,
313
- new Forge.LayoutParams({
314
- x: 0,
315
- y: 0,
316
- width: rect_area.width,
317
- height: block_height
318
- }));
319
- this._textView = text_view;
320
- } else {
321
- this._textViewReahHeight = 0;
322
- Forge.LogI("t_StringWithFont.str.length is 0");
323
- }
324
- }
325
-
326
- // 获取快速构建同样文字样式TextViewEx的信息(样式和描画区域相同,一般出现在MetroWidget的重复项中的文字样式
327
- // 获取样式后,通过 CopiedTextViewEx 快速创建文字View
328
- GetDuplicateBuilder() {
329
- return this._DuplicateBag;
330
- }
331
-
332
- GetLayoutView() {
333
- return this._layoutView;
334
- }
335
-
336
- GetTextWidth() {
337
- if (this._textView) {
338
- return this._textView.Element.clientWidth;
339
- }
340
- return Math.floor(this._textWidth + 0.5);
341
- }
342
-
343
- StartAnimation(animation) {
344
- if (animation && this._textView !== null) {
345
- this._textView.StartAnimation(animation);
346
- }
347
- }
348
- }
349
- Forge.TextViewEx = TextViewEx;
350
- Forge.TextViewControl = TextViewEx;
351
-
352
- class CopiedTextViewEx {
353
- /**
354
- * 通过TextViewEx.GetDuplicateBuilder获得信息快速构建的文字View控件<br>
355
- * 【重要】该控件主要为React场景服务,不支持Maquee和needQuick模式
356
- *
357
- * @public
358
- * @param texture_manager {Forge.TextureManager}
359
- * @param {String} text_string 文本
360
- * @param {Object} text_area_size 文字展示区域,格式 {width:xxx, height:xxx}
361
- * @param {Object} duplicate_info_bag TextViewEx.GetDuplicateBuilder得到的结构体(不要进行改动)
362
- * @param {Function} texture_onload_callbacks 加载完成后的回调
363
- * @class Forge.CopiedTextViewEx
364
- **/
365
- constructor(texture_manager, text_string, text_area_size, duplicate_info_bag, texture_onload_callbacks) {
366
- const text_area = { x: 0, y: 0, width: text_area_size.width, height: text_area_size.height };
367
-
368
- this._ContainerView = new Forge.LayoutView();
369
- this._TextView = this._AddTextView(
370
- texture_manager, text_string, text_area,
371
- this._ContainerView, duplicate_info_bag, texture_onload_callbacks);
372
- }
373
-
374
- _AddTextView(texture_manager, text_string, text_area,
375
- container_view, duplicate_info_bag, texture_onload_callbacks) {
376
- let text_view = null;
377
- if (text_string && text_string.length !== 0) {
378
- const text_texture = texture_manager.GetCopiedTextTexture(
379
- text_string,
380
- text_area,
381
- duplicate_info_bag,
382
- texture_onload_callbacks);
383
-
384
- text_view = new Forge.LayoutView();
385
- text_view.Init(new Forge.TextureSetting(text_texture, null, null, true));
386
- if (text_string.length < 15) {
387
- text_view.SetId(`Text-${text_string}`);
388
- } else {
389
- // 文字太长时,使用长度来代表view id
390
- text_view.SetId(`Text-Long${text_string.length}`);
391
- }
392
-
393
- container_view.AddView(text_view,
394
- new Forge.LayoutParams({
395
- x: 0,
396
- y: 0,
397
- width: text_area.width,
398
- height: text_area.height
399
- }));
400
-
401
- // 注册加载完成后的回调
402
- if (texture_onload_callbacks) {
403
- text_texture.RegisterLoadImageCallback(null, texture_onload_callbacks, null);
404
- }
405
- }
406
-
407
- return text_view;
408
- }
409
-
410
- EnableAutoHeight() {
411
- if (this._TextView) {
412
- this._TextView.EnableAutoHeight();
413
- }
414
- }
415
-
416
- GetLayoutView() {
417
- return this._ContainerView;
418
- }
419
- }
420
- Forge.CopiedTextViewEx = CopiedTextViewEx;
421
-
422
- Forge.Clone = function (obj) {
423
- // 效率低的深度层次拷贝
424
- // 非深层次拷贝请换成Object.assign进行拷贝
425
- return JSON.parse(JSON.stringify(obj));
426
- };
427
-
428
- window.Clone = Forge.Clone;