@shijiu/jsview 1.9.719
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dom/bin/jsview-browser-debug-dom.min.js +1 -0
- package/dom/bin/jsview-dom.min.js +1 -0
- package/dom/bin/jsview-engine-js-browser.min.js +1 -0
- package/dom/bin/jsview-forge-define.min.js +1 -0
- package/dom/browser-root-style.css +21 -0
- package/dom/jsv-browser-debug-dom.js +8 -0
- package/dom/jsv-dom.js +6 -0
- package/dom/jsv-engine-js-browser.js +6 -0
- package/dom/jsv-forge-define.js +6 -0
- package/dom/jsview-dom/README.md +5 -0
- package/dom/jsview-dom/package-lock.json-perfect +3898 -0
- package/dom/jsview-dom/package.json +23 -0
- package/dom/jsview-dom/rollup/browser-debug-dom.rollup.config.js +15 -0
- package/dom/jsview-dom/rollup/dom.rollup.config.js +14 -0
- package/dom/jsview-dom/rollup/engine-js-browser.rollup.config.js +14 -0
- package/dom/jsview-dom/rollup/forge-define.rollup.config.js +14 -0
- package/dom/jsview-dom/scripts/release_dist.sh +36 -0
- package/dom/jsview-dom/src/dom-browser-hook/HookDocument.js +118 -0
- package/dom/jsview-dom/src/dom-browser-hook/OriginDocument.js +19 -0
- package/dom/jsview-dom/src/dom-browser-hook/StyleFormatCheck.js +559 -0
- package/dom/jsview-dom/src/dom-browser-hook/index.js +6 -0
- package/dom/jsview-dom/src/dom-wrapper/ForgeExtension.js +226 -0
- package/dom/jsview-dom/src/dom-wrapper/JsViewForgeApp.js +85 -0
- package/dom/jsview-dom/src/dom-wrapper/JsViewProxy.js +51 -0
- package/dom/jsview-dom/src/dom-wrapper/event/AnimationEvent.js +7 -0
- package/dom/jsview-dom/src/dom-wrapper/event/Event.js +12 -0
- package/dom/jsview-dom/src/dom-wrapper/event/FocusEvent.js +9 -0
- package/dom/jsview-dom/src/dom-wrapper/event/KeyboardEvent.js +43 -0
- package/dom/jsview-dom/src/dom-wrapper/event/LoadEvent.js +8 -0
- package/dom/jsview-dom/src/dom-wrapper/index.js +16 -0
- package/dom/jsview-dom/src/dom-wrapper/node/AnchorElement.js +24 -0
- package/dom/jsview-dom/src/dom-wrapper/node/AudioElement.js +60 -0
- package/dom/jsview-dom/src/dom-wrapper/node/Comment.js +10 -0
- package/dom/jsview-dom/src/dom-wrapper/node/DivElement.js +498 -0
- package/dom/jsview-dom/src/dom-wrapper/node/Document.js +274 -0
- package/dom/jsview-dom/src/dom-wrapper/node/Element.js +852 -0
- package/dom/jsview-dom/src/dom-wrapper/node/FDivElement.js +48 -0
- package/dom/jsview-dom/src/dom-wrapper/node/HeadElement.js +47 -0
- package/dom/jsview-dom/src/dom-wrapper/node/ImageElement.js +203 -0
- package/dom/jsview-dom/src/dom-wrapper/node/JsvAudioTrackElement.js +22 -0
- package/dom/jsview-dom/src/dom-wrapper/node/JsvElement.js +40 -0
- package/dom/jsview-dom/src/dom-wrapper/node/LinkElement.js +48 -0
- package/dom/jsview-dom/src/dom-wrapper/node/MediaElement.js +230 -0
- package/dom/jsview-dom/src/dom-wrapper/node/Node.js +178 -0
- package/dom/jsview-dom/src/dom-wrapper/node/SVGElement.js +9 -0
- package/dom/jsview-dom/src/dom-wrapper/node/ScriptElement.js +45 -0
- package/dom/jsview-dom/src/dom-wrapper/node/StyleElement.js +33 -0
- package/dom/jsview-dom/src/dom-wrapper/node/StyleElementCache.js +41 -0
- package/dom/jsview-dom/src/dom-wrapper/node/Text.js +22 -0
- package/dom/jsview-dom/src/dom-wrapper/node/UnknownElement.js +4 -0
- package/dom/jsview-dom/src/dom-wrapper/node/VideoElement.js +237 -0
- package/dom/jsview-dom/src/dom-wrapper/style/BorderImage.js +25 -0
- package/dom/jsview-dom/src/dom-wrapper/style/Inset.js +26 -0
- package/dom/jsview-dom/src/dom-wrapper/style/JsvStyleVariable.js +65 -0
- package/dom/jsview-dom/src/dom-wrapper/style/KeyframeRule.js +11 -0
- package/dom/jsview-dom/src/dom-wrapper/style/StyleDeclaration.js +609 -0
- package/dom/jsview-dom/src/dom-wrapper/style/StyleSheet.js +51 -0
- package/dom/jsview-dom/src/dom-wrapper/style/StyleValue.js +385 -0
- package/dom/jsview-dom/src/dom-wrapper/style/TextStylePackMap.js +43 -0
- package/dom/jsview-dom/src/dom-wrapper/style/URL.js +144 -0
- package/dom/jsview-dom/src/dom-wrapper/utils/EventHandler.js +42 -0
- package/dom/jsview-dom/src/dom-wrapper/utils/FDivRoot.js +86 -0
- package/dom/jsview-dom/src/dom-wrapper/utils/JsvLazySyncCache.js +64 -0
- package/dom/jsview-dom/src/dom-wrapper/utils/Log.js +42 -0
- package/dom/jsview-dom/src/dom-wrapper/utils/MutationObserver.js +32 -0
- package/dom/jsview-dom/src/dom-wrapper/utils/focusableNode.js +715 -0
- package/dom/jsview-dom/src/engine-js/ForgeDefine.js +8 -0
- package/dom/jsview-dom/src/engine-js/ForgeExtensionDefine.js +14 -0
- package/dom/jsview-dom/src/engine-js/browser/PlatformUtils.js +100 -0
- package/dom/jsview-dom/src/engine-js/browser/animation_base.js +313 -0
- package/dom/jsview-dom/src/engine-js/browser/animation_keyframe.js +64 -0
- package/dom/jsview-dom/src/engine-js/browser/animation_progress.js +287 -0
- package/dom/jsview-dom/src/engine-js/browser/animation_proxy.js +906 -0
- package/dom/jsview-dom/src/engine-js/browser/apic_decoder/demux.js +143 -0
- package/dom/jsview-dom/src/engine-js/browser/apic_decoder/gifDecoder.js +12 -0
- package/dom/jsview-dom/src/engine-js/browser/apic_decoder/libwebp-0.6.0.min.js +160 -0
- package/dom/jsview-dom/src/engine-js/browser/console_log.js +25 -0
- package/dom/jsview-dom/src/engine-js/browser/dynamic_key_frames.js +95 -0
- package/dom/jsview-dom/src/engine-js/browser/easing.js +114 -0
- package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/element_transform.js +122 -0
- package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/gjk.js +450 -0
- package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/mat.js +102 -0
- package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/range_model.js +296 -0
- package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/test_collide.js +10 -0
- package/dom/jsview-dom/src/engine-js/browser/index.js +38 -0
- package/dom/jsview-dom/src/engine-js/browser/latex_parse.js +336 -0
- package/dom/jsview-dom/src/engine-js/browser/layout_params.js +113 -0
- package/dom/jsview-dom/src/engine-js/browser/layout_view.js +3545 -0
- package/dom/jsview-dom/src/engine-js/browser/layout_view_debug.js +15 -0
- package/dom/jsview-dom/src/engine-js/browser/media.js +379 -0
- package/dom/jsview-dom/src/engine-js/browser/page_base.js +941 -0
- package/dom/jsview-dom/src/engine-js/browser/particle_view.js +526 -0
- package/dom/jsview-dom/src/engine-js/browser/platform_timer.js +61 -0
- package/dom/jsview-dom/src/engine-js/browser/react_utils.js +5 -0
- package/dom/jsview-dom/src/engine-js/browser/rect_utils.js +91 -0
- package/dom/jsview-dom/src/engine-js/browser/render_bridge.js +128 -0
- package/dom/jsview-dom/src/engine-js/browser/render_texture_proxy.js +155 -0
- package/dom/jsview-dom/src/engine-js/browser/renderer_deprecated.js +75 -0
- package/dom/jsview-dom/src/engine-js/browser/sound_pool.js +139 -0
- package/dom/jsview-dom/src/engine-js/browser/steps_animation.js +192 -0
- package/dom/jsview-dom/src/engine-js/browser/text_style_cache.js +454 -0
- package/dom/jsview-dom/src/engine-js/browser/text_utils.js +299 -0
- package/dom/jsview-dom/src/engine-js/browser/text_view.js +428 -0
- package/dom/jsview-dom/src/engine-js/browser/texture_manager.js +1060 -0
- package/dom/jsview-dom/src/engine-js/browser/url.js +69 -0
- package/dom/jsview-dom/src/engine-js/browser/velocity.js +40 -0
- package/dom/jsview-dom/src/engine-js/browser/view_sensor/autofroze_sensor.js +77 -0
- package/dom/jsview-dom/src/engine-js/browser/view_sensor/drag_impact_sensor.js +67 -0
- package/dom/jsview-dom/src/engine-js/browser/view_sensor/impact_sensor.js +98 -0
- package/dom/jsview-dom/src/engine-js/browser/view_sensor/impact_sensor_callback.js +21 -0
- package/dom/jsview-dom/src/engine-js/browser/view_sensor/impact_sensor_manager.js +24 -0
- package/dom/jsview-dom/src/engine-js/browser/view_sensor/index.js +9 -0
- package/dom/jsview-dom/src/engine-js/browser/view_sensor/view_sensor.js +268 -0
- package/dom/jsview-dom/src/engine-js/browser/view_sensor/view_sensor_manager.js +84 -0
- package/dom/jsview-dom/src/engine-js/browser/view_sensor/visible_sensor.js +213 -0
- package/dom/jsview-dom/src/engine-js/browser/view_store.js +41 -0
- package/dom/jsview-dom/src/engine-js/index.js +2 -0
- package/dom/jsview-dom/src/engine-js/native/README.md +1 -0
- package/dom/target_core_revision.mjs +15 -0
- package/index.js +0 -0
- package/loader/header_script_loader.js +134 -0
- package/loader/jsview-main.js +42 -0
- package/loader/jsview.config.default.js +37 -0
- package/loader/jsview.default.config.js +37 -0
- package/loader/loader.js +183 -0
- package/loader/loader_webkit.js +40 -0
- package/package.json +31 -0
- package/patches/node_modules/@vitejs/plugin-react/dist/index.cjs +520 -0
- package/patches/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +17609 -0
- package/patches/node_modules/@vue/compiler-sfc/dist/jsview-css-to-js.js +335 -0
- package/patches/node_modules/@vue/compiler-sfc/dist/jsview-style-format.js +446 -0
- package/patches/node_modules/@vue/compiler-sfc/dist/jsview-style-types.js +91 -0
- package/patches/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js +8038 -0
- package/patches/node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js +1700 -0
- package/patches/node_modules/postcss-js/objectifier.js +90 -0
- package/patches/node_modules/vite/dist/node/chunks/dep-0fc8e132.js +63175 -0
- package/patches/node_modules/vite/dist/node/jsview-react.vite.config.js +7 -0
- package/patches/node_modules/vite/dist/node/jsview-vue.vite.config.js +7 -0
- package/patches/node_modules/vite/dist/node/jsview.vite.config.js +56 -0
- package/patches/node_modules/vue-router/dist/vue-router.mjs +3595 -0
- package/tools/common.js +58 -0
- package/tools/jsview-jsmap-serve.js +105 -0
- package/tools/jsview-post-build.js +184 -0
- package/tools/jsview-post-install-react.js +13 -0
- package/tools/jsview-post-install-vue.js +16 -0
- package/tools/jsview-post-install.js +116 -0
- package/tools/jsview-run-android.js +67 -0
- package/tsconfig.json +34 -0
|
@@ -0,0 +1,428 @@
|
|
|
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(/>/ig, "<");
|
|
276
|
+
}
|
|
277
|
+
if (dst_str.indexOf(" ") !== -1) {
|
|
278
|
+
dst_str = dst_str.replace(/ /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;
|