forked from tickbh/VisualUIEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtImage.js
More file actions
89 lines (72 loc) · 2.08 KB
/
ExtImage.js
File metadata and controls
89 lines (72 loc) · 2.08 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
let ExtImage = {}
ExtImage.name = 'UIImage'
ExtImage.icon = 'app://res/control/Sprite.png'
ExtImage.tag = 1
ExtImage.defRes = 'res/default/Sprite.png'
ExtImage.GenEmptyNode = function() {
let node = new ccui.ImageView(getFullPathForName(ExtImage.defRes))
node._spriteFrame = ExtImage.defRes
node._className = ExtImage.name
return node
}
ExtImage.GenNodeByData = function(data, parent) {
let node = new ccui.ImageView()
node._className = ExtImage.name
return node
}
ExtImage.SetSpriteFrame = function(node, spriteFrame) {
if (spriteFrame && getFullPathForName(spriteFrame)) {
let fullpath = getFullPathForName(spriteFrame)
cc.textureCache.addImage(fullpath, function() {
let anchor = node.getAnchorPoint()
node.loadTexture(fullpath)
node.setAnchorPoint(anchor)
node._spriteFrame = spriteFrame
})
}
}
ExtImage.SetNodePropByData = function(node, data, parent) {
ExtImage.SetSpriteFrame(node, data.spriteFrame)
}
ExtImage.ExportNodeData = function(node, data) {
node._spriteFrame && (data['spriteFrame'] = node._spriteFrame)
}
ExtImage.SetPropChange = function(control, path, value) {
SetDefaultPropChange(control, path, value)
}
ExtImage.GetLoadImages = function(data) {
return [data['spriteFrame']]
}
ExtImage.NodifyPropChange = function(control) {
SetNodifyPropChange(control)
}
function ImageData(node) {
this._node = node
}
ImageData.prototype = {
__displayName__: 'Image',
__type__: 'ccui.ImageView',
get spriteFrame() {
return {
path: 'spriteFrame',
type: 'asset',
name: 'spriteFrame',
attrs: {},
value: this._node._spriteFrame
}
},
get __props__() {
return [
this.spriteFrame
]
}
}
ExtImage.ImageData = ImageData
ExtImage.PropComps = function(node) {
let datas = [new WidgetData(node)]
datas.push(new TouchData(node))
datas.push(new ImageData(node))
return datas
}
module.exports = ExtImage
RegisterExtNodeControl(ExtImage.name, ExtImage)