écriture du wrapper pour le chargement des éléments...
...du canvas
... | ... |
@@ -41,7 +41,7 @@ var deviceClass = { |
41 | 41 |
m.knobs = knobsClass.new(m.node); |
42 | 42 |
m.softkeys = softkeysClass.new(m.node, m.role); |
43 | 43 |
m.display.loadsvg(); |
44 |
- m.display.loadGroup([ |
|
44 |
+ m.display.loadGroup({hide : [ |
|
45 | 45 |
'Failures', |
46 | 46 |
'SoftKeysTexts', |
47 | 47 |
'PFD-Widgets', |
... | ... |
@@ -52,7 +52,7 @@ var deviceClass = { |
52 | 52 |
'FlightInstruments', |
53 | 53 |
'VDI', |
54 | 54 |
'OMI', |
55 |
- ], []); |
|
55 |
+ ]}); |
|
56 | 56 |
zkv.getNode(m.role ~ 'init').setIntValue(0); |
57 | 57 |
m.setstatus(d + 1); |
58 | 58 |
return m; |
... | ... |
@@ -14,6 +14,7 @@ var displayClass = { |
14 | 14 |
}); |
15 | 15 |
m.display.setColorBackground(0,0,0); |
16 | 16 |
m.role = role; |
17 |
+ m.screenElements = {}; |
|
17 | 18 |
|
18 | 19 |
return m; |
19 | 20 |
}, |
... | ... |
@@ -33,13 +34,13 @@ var displayClass = { |
33 | 34 |
else { |
34 | 35 |
me.progress.hide(); |
35 | 36 |
me.screen.show(); |
36 |
- me.showGroup([ |
|
37 |
+ me.loadGroup({ show : [ |
|
37 | 38 |
'SoftKeysTexts', |
38 | 39 |
'COMM', |
39 | 40 |
'NAV', |
40 | 41 |
'XPDR-TIME', |
41 | 42 |
'FlightInstruments' |
42 |
- ]); |
|
43 |
+ ]}); |
|
43 | 44 |
me.progress.removeAllChildren(); |
44 | 45 |
me.progress = nil; |
45 | 46 |
me.showInitProgress = nil; |
... | ... |
@@ -69,22 +70,37 @@ var displayClass = { |
69 | 70 |
.setColor(1,0,0), '.'); |
70 | 71 |
}, |
71 | 72 |
|
72 |
- loadGroup : func (hide, show) { |
|
73 |
- if (typeof(hide) != 'vector') hide = [ hide ]; |
|
74 |
- if (typeof(show) != 'vector') show = [ show ]; |
|
75 |
- foreach (var id; hide) { |
|
76 |
- var e = me.screen.getElementById(id); |
|
77 |
- if (e != nil) |
|
78 |
- e.hide(); |
|
79 |
- else |
|
80 |
- print('SVG ID ' ~ id ~ ' not found'); |
|
73 |
+ loadGroup : func (h) { |
|
74 |
+ if (typeof(h) != 'hash') { |
|
75 |
+ msg_dbg(sprintf("%s need a hash, but get a %s from %s", |
|
76 |
+ caller(0)[0], |
|
77 |
+ typeof(h), |
|
78 |
+ caller(1)[0])); |
|
79 |
+ return; |
|
81 | 80 |
} |
82 |
- foreach (var id; show) { |
|
83 |
- var e = me.screen.getElementById(id); |
|
84 |
- if (e != nil) |
|
85 |
- e.show(); |
|
81 |
+ var setMethod = func (e, t) { |
|
82 |
+ if (t == 'hide') |
|
83 |
+ me.screenElements[e].hide(); |
|
84 |
+ elsif (t == 'show') |
|
85 |
+ me.screenElements[e].show(); |
|
86 |
+ elsif (t == 'rot' or t == 'trans') |
|
87 |
+ me.screenElements[e].createTransform(); |
|
86 | 88 |
else |
87 |
- print('SVG ID ' ~ id ~ ' not found'); |
|
89 |
+ print('unknown method ' ~ t); |
|
90 |
+ }; |
|
91 |
+ foreach (var todo; keys(h)) { |
|
92 |
+ if (typeof(h[todo]) != 'vector') h[todo] = [ h[todo] ]; |
|
93 |
+ foreach (var id; h[todo]) { |
|
94 |
+ if (! contains(me.screenElements, id)) { |
|
95 |
+ me.screenElements[id] = me.screen.getElementById(id); |
|
96 |
+ if (me.screenElements[id] != nil) |
|
97 |
+ setMethod(id, todo); |
|
98 |
+ else |
|
99 |
+ print('SVG ID ' ~ id ~ ' not found'); |
|
100 |
+ } |
|
101 |
+ else |
|
102 |
+ setMethod(id, todo); |
|
103 |
+ } |
|
88 | 104 |
} |
89 | 105 |
}, |
90 | 106 |
|