1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<krpano>
<!--
showtext() xml plugin
- showtext() and <textstyle> support for HTML5
- extended <textstyle> functionality compared to the build-in showtext() action
- just include this xml file via: <include url="showtext.xml" />
- docu: https://krpano.com/plugins/showtext/
- krpano 1.20
-->
<!-- predefine a DEFAULT textstyle element -->
<textstyle name="DEFAULT" />
<!-- the automatic running (autorun=preinit) install action -->
<action name="showtext_install" autorun="preinit" scope="private:showtext">
<!-- remove the build-in 'showtext' function to use the 'showtext' <action> instead: -->
delete(global.showtext);
<!-- initialize internal variables -->
set(showtext_style, DEFAULT);
set(showtext_prevstyle, null);
set(showtext_text, '');
set(showtext_prevtext, '');
set(showtext_timeout, 0.1);
set(showtext_fadeout, 0.0);
set(showtext_clipping, false);
</action>
<action name="showtext" scope="private:showtext" args="text, style">
if(!style, set(style, DEFAULT));
if(global.textstyle[get(style)],
copy(showtext_style, style);
,
warning("showtext() - there is no textstyle '", style, "' defined!");
global.textstyle.createarrayitem(get(style));
);
copy(showtext_text, text);
if(showtext_text != showtext_prevtext,
copy(showtext_prevtext, showtext_text);
showtext_createnewtext();
,
delayedcall(showtext_timer, get(showtext_timeout), showtext_hide() );
);
</action>
<action name="showtext_createnewtext" scope="private:showtext">
<!-- stop running mouse and alpha update calls -->
stopdelayedcall(showtext_mouseupdates);
stoptween(global.layer[showtext_tf].alpha);
<!-- remove the old textfield when the style has changed -->
if(showtext_style != showtext_prevstyle,
copy(showtext_prevstyle, showtext_style);
removelayer(showtext_tf);
);
<!-- create a new textfield plugin layer -->
addlayer(showtext_tf);
<!-- create 'shortcut' variables (tf,ts) for faster access -->
copy(tf, global.layer[showtext_tf]);
copy(ts, global.textstyle[get(showtext_style)]);
<!-- get the position settings -->
if(ts.origin !== null, copy(ts_origin, ts.origin), set(ts_origin, 'cursor'));
if(ts.edge !== null, copy(ts_edge, ts.edge), set(ts_edge, 'bottom'));
if(ts.xoffset !== null, copy(ts_xoffset, ts.xoffset), set(ts_xoffset, 0));
if(ts.yoffset !== null, copy(ts_yoffset, ts.yoffset), set(ts_yoffset, -3));
<!-- set the position settings -->
if(ts_origin == 'cursor',
set(tf.align, 'lefttop');
showtext_movetomouse();
,
copy(tf.align, ts_origin);
);
copy(tf.edge, ts_edge);
copy(tf.ox, ts_xoffset);
copy(tf.oy, ts_yoffset);
<!-- get the font settings -->
if(ts.font !== null, copy(ts_font, ts.font), set(ts_font, 'Times'));
if(ts.fontsize !== null, copy(ts_fontsize, ts.fontsize), set(ts_fontsize, 12.0));
if(ts.bold !== null, copy(ts_bold, ts.bold), set(ts_bold, true));
if(ts.italic !== null, copy(ts_italic, ts.italic), set(ts_italic, false));
if(ts.textcolor !== null, copy(ts_textcolor, ts.textcolor), set(ts_textcolor, 0x000000));
if(ts.textalign !== null, copy(ts_textalign, ts.textalign), set(ts_textalign, 'left'));
<!-- use the font settings to build the CSS style -->
set(tf_css, '');
tohex(ts_textcolor, '#', 6);
txtadd(tf_css, 'font-family:',get(ts_font),'; font-size:',get(ts_fontsize),'px; color:',get(ts_textcolor),'; ');
if(ts_textalign != 'none', txtadd(tf_css, get(tf_css), 'text-align:',get(ts_textalign),'; '));
if(ts_bold, txtadd(tf_css, 'font-weight:bold; '));
if(ts_italic, txtadd(tf_css, 'font-style:italic; '));
if(ts.css !== null, txtadd(tf_css, get(ts.css)));
copy(tf.css, tf_css);
<!-- size settings -->
if(ts.width !== null AND ts.width !== '', copy(tf.width, ts.width));
if(ts.height !== null AND ts.height !== '', copy(tf.height, ts.height));
if(ts.vcenter !== null AND ts.vcenter !== '', copy(tf.vcenter, ts.vcenter));
if(ts.padding !== null AND ts.padding !== '', copy(tf.padding, ts.padding), set(tf.padding,1));
<!-- background, border, shadow settings -->
if(ts.background !== null, copy(tf.background, ts.background));
if(ts.backgroundcolor !== null, copy(tf.backgroundcolor, ts.backgroundcolor));
if(ts.backgroundalpha !== null, copy(tf.backgroundalpha, ts.backgroundalpha));
if(ts.border !== null, copy(tf.border, ts.border), set(tf.border,true));
if(ts.bordercolor !== null, copy(tf.bordercolor, ts.bordercolor));
if(ts.borderalpha !== null, copy(tf.borderalpha, ts.borderalpha));
if(ts.borderwidth !== null, copy(tf.borderwidth, ts.borderwidth));
if(ts.roundedge !== null, copy(tf.roundedge, ts.roundedge));
if(ts.shadow !== null, copy(tf.shadow, ts.shadow));
if(ts.shadowrange !== null, copy(tf.shadowrange, ts.shadowrange));
if(ts.shadowangle !== null, copy(tf.shadowangle, ts.shadowangle));
if(ts.shadowcolor !== null, copy(tf.shadowcolor, ts.shadowcolor));
if(ts.shadowalpha !== null, copy(tf.shadowalpha, ts.shadowalpha));
if(ts.textshadow !== null, copy(tf.textshadow, ts.textshadow));
if(ts.textshadowrange !== null, copy(tf.textshadowrange, ts.textshadowrange));
if(ts.textshadowangle !== null, copy(tf.textshadowangle, ts.textshadowangle));
if(ts.textshadowcolor !== null, copy(tf.textshadowcolor, ts.textshadowcolor));
if(ts.textshadowalpha !== null, copy(tf.textshadowalpha, ts.textshadowalpha));
<!-- showing settings -->
if(ts.alpha !== null, copy(ts_alpha, ts.alpha), set(ts_alpha, 1.0));
if(ts.showtime !== null, copy(ts_showtime, ts.showtime), set(ts_showtime, 0.1));
if(ts.fadetime !== null, copy(ts_fadetime, ts.fadetime), set(ts_fadetime, 0.0));
if(ts.fadeintime !== null, copy(ts_fadeintime, ts.fadeintime), set(ts_fadeintime, 0.0));
copy(showtext_timeout, ts_showtime);
copy(showtext_fadeout, ts_fadetime);
if(ts_fadeintime GT 0,
set(tf.alpha, 0.0);
tween(global.layer[showtext_tf].alpha, get(ts_alpha), get(ts_fadeintime), linear);
,
copy(tf.alpha, ts_alpha);
);
if(ts.noclip !== null, copy(showtext_clipping,ts.noclip), set(showtext_clipping, true));
if(showtext_clipping,
set(tf.onloaded, showtext_do_clipping() );
set(tf.onautosized, showtext_do_clipping() );
);
<!-- special flash-only settings -->
if(ts.embeddedfonts !== null, copy(tf.embeddedfonts, ts.embeddedfonts));
if(ts.effect !== null, copy(tf.effect, ts.effect));
if(ts.blendmode !== null, copy(tf.blendmode, ts.blendmode));
<!-- set the text and the basic settings to start showing the textfield -->
copy(tf.html, showtext_text);
set(tf.enabled, false);
set(tf.zorder, 999999);
if(ts.parent, copy(tf.parent, ts.parent) );
set(tf.type, 'text');
<!-- start the text-hiding timer -->
delayedcall(showtext_timer, get(showtext_timeout), showtext_hide() );
</action>
<action name="showtext_do_clipping" scope="private:showtext">
if(showtext_clipping,
global.layer[showtext_tf].updatepos();
copy(tf_px, global.layer[showtext_tf].pixelx);
copy(tf_py, global.layer[showtext_tf].pixely);
if(tf_px LT 0,
sub(global.layer[showtext_tf].x, tf_px);
,
add(tf_rightedge, tf_px, global.layer[showtext_tf].pixelwidth);
if(tf_rightedge GE global.stagewidth, sub(tf_rightedge,global.stagewidth); sub(global.layer[showtext_tf].x,tf_rightedge); );
);
if(tf_py LT 0,
sub(global.layer[showtext_tf].y, tf_py);
,
add(tf_bottomedge, tf_py, global.layer[showtext_tf].pixelheight);
if(tf_bottomedge GE global.stageheight, sub(tf_bottomedge,global.stageheight); sub(global.layer[showtext_tf].y,tf_bottomedge); );
);
);
</action>
<action name="showtext_movetomouse" scope="private:showtext">
copy(global.layer[showtext_tf].x, global.mouse.stagex);
copy(global.layer[showtext_tf].y, global.mouse.stagey);
showtext_do_clipping();
delayedcall(showtext_mouseupdates, 0, showtext_movetomouse() );
</action>
<action name="showtext_hide" scope="private:showtext">
if(global.layer[showtext_tf],
tween(global.layer[showtext_tf].alpha, 0.0, get(showtext_fadeout), linear,
stopdelayedcall(showtext_mouseupdates);
removelayer(showtext_tf);
set(showtext_text, '');
set(showtext_prevtext, '');
);
);
</action>
</krpano>