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
|
define.class(function($server$, composition, $ui$, screen, cadgrid, view, icon, label){
define.class(this, "selectorrect", view, function(){
this.name = 'selectorrect'
this.bordercolorfn = function(pos){
var check = (int(mod(0.05 * (gl_FragCoord.x + gl_FragCoord.y + time * 40.),2.)) == 1)? 1.0: 0.0
return vec4(check * vec3(0.8), 1)
}
this.bordercolor = vec4(1, 1, 1, 0.4)
this.borderwidth = 5
this.bgcolor = vec4(1, 1, 1, 0.07)
this.borderradius = 2
this.position = "absolute"
this.visible = false
})
this.style = {
icon: {
fgcolor:"red",
margin:40,
fontsize:60
}
}
this.render = function(){ return [
screen({name:'default', clearcolor:vec4('black')},
cadgrid({
flex:1,
justifycontent:"center",
alignitems:"center",
pointermove:function(event){
var select = this.find('selectorrect');
select.visible = true;
select.pos = vec2(event.min[0], event.min[1]);
select.size = vec2(event.max[0] - event.min[0], event.max[1] - event.min[1])
},
pointerend:function(event){
for (var i=0;i< this.children.length;i++) {
var child = this.children[i];
child.bgcolor = "transparent";
}
var select = this.find('selectorrect');
var rect = vec4(event.min[0], event.min[1], event.max[0] - event.min[0], event.max[1] - event.min[1])
var selection = this.screen.childrenInRect(rect, [select]);
for (var i=0;i< selection.length;i++) {
var selected = selection[i];
if (selected.noselect !== true) {
selected.bgcolor = "green";
}
}
select.visible = false
}
},
label({noselect:true, text:"Drag the selection box around the objects below to demonstrate selection", fgcolor:"blue"}),
icon({icon:"star-o", bgcolor:"transparent"}), icon({icon:"circle-o", bgcolor:"transparent"}), icon({icon:"square-o", bgcolor:"transparent"}),
this.selectorrect()
)
)
]}
})
|