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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
|
#include <lib/std.mi>
#include <lib/config.mi>
#define MAIN_ATTRIBS_MGR
Function updateVisCmd();
Function updateOpenCloseDirection();
// this implements the main app drawer
#include "drawer.m"
// this loads the skin config attributes definitions
#include "attribs.m"
Global Layout main, shade;
Global Container maincontainer;
Global Group frameGroup, ButtonsVideo,ButtonsVis,ButtonsVideoDetach,ButtonsVisDetach,ButtonsVideoSwitchto,ButtonsVisSwitchto;
Global Button btnOpen,btnClose,btnMaximize,btnRestore, btnVisDetach, btnVideoDetach, btnVisSwitchto, btnVideoSwitchto;
Global Layer resizer,resizerDrawer,OpenCloseHider;
Global GuiObject VideoVisGroup;
Global Int evershown;
Global Int ismaximized;
Global Int lasttotop;
//------------------------------------------------------------------------
// script startup
//------------------------------------------------------------------------
System.onScriptLoaded() {
// init skin attributes for this script
initAttribs();
// bind objects
frameGroup = getScriptGroup();
btnOpen = frameGroup.findObject("videoavs.open");
btnClose = frameGroup.findObject("videoavs.close");
btnMaximize = frameGroup.findObject("button.vid.max");
btnRestore = frameGroup.findObject("button.vid.restore");
resizer = frameGroup.findObject("player.main.resizer");
resizerDrawer = frameGroup.findObject("drawer.resizer");
ButtonsVideo = frameGroup.findObject("buttons.video");
ButtonsVis = frameGroup.findObject("buttons.vis");
ButtonsVideoDetach = frameGroup.findObject("buttons.video.detach");
ButtonsVisDetach = frameGroup.findObject("buttons.vis.detach");
BtnVisDetach = ButtonsVisDetach.findObject("button.vis.detach");
BtnVideoDetach = ButtonsVideoDetach.findObject("button.vid.detach");
ButtonsVideoSwitchto = frameGroup.findObject("buttons.video.switchto");
ButtonsVisSwitchto = frameGroup.findObject("buttons.vis.switchto");
BtnVisSwitchto = ButtonsVisSwitchto.findObject("button.vis.Switchto");
BtnVideoSwitchto = ButtonsVideoSwitchto.findObject("button.vid.Switchto");
OpenCloseHider=frameGroup.findObject("openclosehider");
main = frameGroup.getParentLayout();
maincontainer = main.getContainer();
VideoVisGroup = frameGroup.findObject("AVSGroup");
VideoVisGroup.hide();
// bind drawer script attribs to our attribs
__drawer_directiontop_attrib = drawer_directiontop_attrib;
__scrolldrawerattrib = scrolldrawerattrib;
__drawer_directionbypass_attrib = drawer_directionbypass_attrib;
__vis_detach_attrib = vis_detach_attrib;
__video_detach_attrib = video_detach_attrib;
// startup drawer script
initDrawer(main, "VideoAVS");
// more init
if (vis_detach_attrib.getData() == "1" && video_detach_attrib.getData() == "1") OpenCloseHider.show();
else OpenCloseHider.hide();
lasttotop = 0;
}
//------------------------------------------------------------------------
// grab a handle to the windowshade layout, can't get it in onScriptLoaded since it doesn't exists yet
// also, first time we are shown, we update the viscmd button's action
//------------------------------------------------------------------------
main.onSetVisible(int show) {
if (!evershown) {
evershown = 1;
if (!shade) {
shade = maincontainer.getLayout("shade");
}
updateVisCmd();
updateOpenCloseDirection();
}
}
//------------------------------------------------------------------------
// script shutdown
//------------------------------------------------------------------------
System.onScriptUnloading() {
// shutdown the drawer script
shutdownDrawer();
}
//------------------------------------------------------------------------
// drawer script backend
//------------------------------------------------------------------------
Int getDrawerClosedHeight() {
return 280; // this is the size of the layout when the drawer is closed
}
Int getDefaultDrawerOpenHeight() {
return 510; // this is the default size of the layout, used when it opens the first time
}
// whenever the main window is resized while its drawer is closed, we change the height of the drawer the
// next time it opens so that video will fit 4:3
Int getDrawerOpenAutoHeight(int layoutwidth) {
return (layoutwidth-6)*(3/4)+55+270;
}
WindowHolder getVisWindowHolder() {
WindowHolder wh = getScriptGroup().findObject("myviswnd");
return wh; // we return our vis windowholder object
}
WindowHolder getVideoWindowHolder() {
WindowHolder wh = getScriptGroup().findObject("myvideownd");
return wh; // we return our video windowholder object
}
//------------------------------------------------------------------------
// optional drawer events
//------------------------------------------------------------------------
onDoneOpeningDrawer() {
// nothing to do
}
onDoneClosingDrawer() {
VideoVisGroup.hide();
}
onBeforeOpeningDrawer() {
resizer.setXmlParam("resize", "bottomright");
resizerDrawer.setXmlParam("resize", "bottomright");
btnOpen.hide();
main.setXmlParam("minimum_h", "380");
VideoVisGroup.show();
}
onBeforeClosingDrawer() {
resizer.setXmlParam("resize", "right");
resizerDrawer.setXmlParam("resize", "right");
main.setXmlParam("minimum_h", "280");
btnOpen.show();
}
onShowVis() {
ButtonsVideo.hide();
ButtonsVideoDetach.hide();
ButtonsVideoSwitchto.hide();
ButtonsVis.show();
ButtonsVisDetach.show();
if (video_detach_attrib.getData() == "0") ButtonsVisSwitchto.show();
}
onHideVis() {
ButtonsVis.hide();
ButtonsVisDetach.hide();
ButtonsVisSwitchto.hide();
}
onShowVideo() {
ButtonsVis.hide();
ButtonsVisDetach.hide();
ButtonsVisSwitchto.hide();
ButtonsVideo.show();
ButtonsVideoDetach.show();
if (vis_detach_attrib.getData() == "0") ButtonsVideoSwitchto.show();
}
onHideVideo() {
ButtonsVideo.hide();
ButtonsVideoDetach.hide();
ButtonsVideoSwitchto.hide();
}
onDetachVideo() {
ButtonsVisSwitchto.hide();
if (vis_detach_attrib.getData() == "1") OpenCloseHider.show();
}
onAttachVideo() {
ButtonsVisSwitchto.show();
OpenCloseHider.hide();
}
onDetachVis() {
ButtonsVideoSwitchto.hide();
if (video_detach_attrib.getData() == "1") OpenCloseHider.show();
}
onAttachVis() {
ButtonsVideoSwitchto.show();
OpenCloseHider.hide();
}
onBeforeRestore() {
btnMaximize.show();
btnRestore.hide();
}
onBeforeMaximize() {
btnRestore.show();
btnMaximize.hide();
}
onCancelMaximize() {
btnMaximize.show();
btnRestore.hide();
}
// -----------------------------------------------------------------------
// drawer control
// -----------------------------------------------------------------------
btnOpen.onLeftClick() {
openDrawer();
}
btnClose.onLeftClick() {
closeDrawer();
}
btnMaximize.onLeftClick() {
maximizeWindow();
}
btnRestore.onLeftClick() {
restoreWindow();
}
BtnVisDetach.onLeftClick() {
detachVis();
}
BtnVideoDetach.onLeftClick() {
detachVideo();
}
BtnVisSwitchto.onLeftClick() {
switchToVideo();
}
BtnVideoSwitchto.onLeftClick() {
switchToVis();
}
// -----------------------------------------------------------------------
// when the player window is moved on the screen, we should update the up/down arrow for the open/close buttons since the
// drawer may have changed the direction it will open depending on user settings
// -----------------------------------------------------------------------
main.onMove() {
updateOpenCloseDirection();
}
// -----------------------------------------------------------------------
// just invert the images when the direction is to top and restore them otherwise
// -----------------------------------------------------------------------
updateOpenCloseDirection() {
if (isDrawerToTop()) {
if (!lasttotop) {
btnClose.setXmlParam("image", "player.button.videoavs");
btnClose.setXmlParam("downimage", "player.button.videoavs.pressed");
btnClose.setXmlParam("hoverImage", "player.button.videoavs.hover");
btnOpen.setXmlParam("image", "player.button.videoavs.up");
btnOpen.setXmlParam("downimage", "player.button.videoavs.up.pressed");
btnOpen.setXmlParam("hoverImage", "player.button.videoavs.up.hover");
lasttotop = 1;
}
} else {
if (lasttotop) {
btnOpen.setXmlParam("image", "player.button.videoavs");
btnOpen.setXmlParam("downimage", "player.button.videoavs.pressed");
btnOpen.setXmlParam("hoverImage", "player.button.videoavs.hover");
btnClose.setXmlParam("image", "player.button.videoavs.up");
btnClose.setXmlParam("downimage", "player.button.videoavs.up.pressed");
btnClose.setXmlParam("hoverImage", "player.button.videoavs.up.hover");
lasttotop = 0;
}
}
}
// -----------------------------------------------------------------------
updateVisCmd() {
Button btn = getScriptGroup().findObject("button.vis.misc");
if (btn) {
if (viscmd_menu_attrib.getData() == "1") {
btn.setXmlParam("action", "Vis_Menu");
} else {
btn.setXmlParam("action", "Vis_Cfg");
}
}
}
|