forked from tickbh/VisualUIEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtScrollView.js
More file actions
196 lines (172 loc) · 5.89 KB
/
ExtScrollView.js
File metadata and controls
196 lines (172 loc) · 5.89 KB
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
let ExtScrollView = {}
ExtScrollView.name = 'UIScrollView'
ExtScrollView.icon = 'app://res/control/scrollview.png'
ExtScrollView.tag = 9
ExtScrollView.GenEmptyNode = function() {
node = new ccui.ScrollView()
node.setContentSize(cc.size(200, 100))
node._className = ExtScrollView.name
return node
}
ExtScrollView.GenNodeByData = function(data, parent) {
node = new ccui.ScrollView()
node.setContentSize(cc.size(data.width || 200, data.height || 100))
ExtScrollView.SetNodePropByData(node, data, parent);
node._className = ExtScrollView.name
return node
}
ExtScrollView.SetNodePropByData = function(node, data, parent) {
if (!isNull(data['innerPosX']) || !isNull(data['innerPosY'])) {
node.setInnerContainerPosition(cc.p(data['innerPosX'] || 0, data['innerPosY'] || 0))
}
if (!isNull(data['innerSizeW']) || !isNull(data['innerSizeH'])) {
node.setInnerContainerSize(cc.size(data['innerSizeW'] || 0, data['innerSizeH'] || 0))
}
(isValue(data['direction'])) && (node.setDirection(parseInt(data['direction'])));
(isValue(data['scrollBarEnabled'])) && (node.setScrollBarEnabled(data['scrollBarEnabled']));
(isValue(data['inertiaScrollEnabled'])) && (node.setInertiaScrollEnabled(data['inertiaScrollEnabled']));
(isValue(data['bounceEnabled'])) && (node.setBounceEnabled(data['bounceEnabled']))
}
ExtScrollView.ExportNodeData = function(node, data) {
let innerPos = node.getInnerContainerPosition()
data['innerPosX'] = innerPos.x
data['innerPosY'] = innerPos.y
let innerSize = node.getInnerContainerSize()
data['innerSizeW'] = innerSize.width
data['innerSizeH'] = innerSize.height
data['direction'] = node._direction
data['scrollBarEnabled'] = node._scrollBarEnabled
data['inertiaScrollEnabled'] = node._inertiaScrollEnabled
data['bounceEnabled'] = node._bounceEnabled
}
// ExtScrollView.SetPropChange = function (control, path, value) {
// if (path == 'innerPosition.x') {
// control._node.setInnerContainerPosition(cc.p(value, control._node.getInnerContainerPosition().y))
// } else if (path == 'innerPosition.y') {
// control._node.setInnerContainerPosition(cc.p(control._node.getInnerContainerPosition().x, value))
// } else if (path == 'innerSize.width') {
// control._node.setInnerContainerSize(value, cc.size(control._node.getInnerContainerSize().height))
// } else if (path == 'innerSize.height') {
// control._node.setInnerContainerSize(cc.size(control._node.getInnerContainerSize().width, value))
// } else if (path == 'direction') {
// value = fixFloatValue(value)
// let pre = control._node._direction
// control._node.setDirection(value == 4 ? 0 : value)
// let after = control._node._direction
// } else if (path == 'scrollBarEnabled') {
// control._node.setScrollBarEnabled(value)
// } else if (path == 'inertiaScrollEnabled') {
// control._node.setInertiaScrollEnabled(value)
// } else if (path == 'bounceEnabled') {
// control._node.setBounceEnabled(value)
// }
// }
ExtScrollView.SetPropChange = function(control, path, value) {
SetDefaultPropChange(control, path, value)
}
ExtScrollView.NodifyPropChange = function(control) {
SetNodifyPropChange(control)
}
ExtScrollView.ExportData = function(node) {
this._node = node
}
ExtScrollView.ExportData.prototype = {
__displayName__: 'ScrollView',
get bounceEnabled() {
return {
path: 'bounceEnabled',
type: 'checkbox',
name: 'bounceEnabled',
attrs: {},
value: this._node._bounceEnabled
}
},
get inertiaScrollEnabled() {
return {
path: 'inertiaScrollEnabled',
type: 'checkbox',
name: 'inertiaScrollEnabled',
attrs: {},
value: this._node._inertiaScrollEnabled
}
},
get scrollBarEnabled() {
return {
path: 'scrollBarEnabled',
type: 'checkbox',
name: 'scrollBarEnabled',
attrs: {},
value: this._node._scrollBarEnabled
}
},
get innerPosition() {
return {
path: 'innerPosition',
type: 'vec2',
name: 'innerPosition',
attrs: {
step: 5,
precision: 0,
min: -1000,
max: 10000
},
value: {
x: this._node.getInnerContainerPosition().x,
y: this._node.getInnerContainerPosition().y
}
}
},
get innerSize() {
let parent = this._node.getParent()
let size = this._node.getInnerContainerSize()
return {
path: 'innerSize',
type: 'size',
name: 'innerSize',
attrs: {
hasParent: false,
min: 0,
step: 5,
precision: 0
},
value: {
width: size.width,
height: size.height
}
}
},
get direction() {
return {
path: 'direction',
type: 'select',
name: 'direction',
attrs: {
selects: {
1: 'VERTICAL',
2: 'HORIZONTAL',
3: 'BOTH',
4: 'NONE'
}
},
value: this._node._direction
}
},
get __props__() {
return [
this.innerPosition,
this.innerSize,
this.direction,
this.inertiaScrollEnabled,
this.scrollBarEnabled,
this.bounceEnabled
]
}
}
ExtScrollView.PropComps = function(node) {
let datas = [new WidgetData(node)]
datas.push(new TouchData(node))
datas.push(new ExtScrollView.ExportData(node))
return datas
}
module.exports = ExtScrollView
RegisterExtNodeControl(ExtScrollView.name, ExtScrollView)