1 | -- NotificationLayer.lua |
---|
2 | |
---|
3 | local P = createMenuSheet("NotificationLayer", true, TriBool.True, TriBool.True) |
---|
4 | |
---|
5 | P.queueList = {} |
---|
6 | P.editMode = false |
---|
7 | |
---|
8 | P.sampleWindow = nil |
---|
9 | |
---|
10 | function P.onLoad() |
---|
11 | orxonox.NotificationManager:getInstance():loadQueues() |
---|
12 | P.sampleWindow = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/NotificationLayer/Root/SampleWindow") |
---|
13 | end |
---|
14 | |
---|
15 | function P.createQueue(name, size) |
---|
16 | local root = winMgr:getWindow("orxonox/NotificationLayer/Root") |
---|
17 | local queue = winMgr:createWindow("MenuWidgets/Listbox", "orxonox/NotificationLayer/Root/Queue/" .. name) |
---|
18 | queue:setProperty("BackgroundColor", "00FFFFFF") |
---|
19 | root:addChildWindow(queue) |
---|
20 | |
---|
21 | queue:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, 0))) |
---|
22 | queue:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, 0), CEGUI.UDim(0, P.queueHeightHelper(queue, size)))) |
---|
23 | |
---|
24 | local queueTuple = |
---|
25 | { |
---|
26 | ["window"] = queue, |
---|
27 | ["name"] = name, |
---|
28 | ["edit"] = nil, |
---|
29 | ["visible"] = false |
---|
30 | } |
---|
31 | |
---|
32 | P.queueList[name] = queueTuple -- name access |
---|
33 | P.setVisible(queueTuple, false) |
---|
34 | end |
---|
35 | |
---|
36 | function P.removeQueue(name) |
---|
37 | local queue = P.queueList[name] |
---|
38 | |
---|
39 | if queue ~= nil then |
---|
40 | winMgr:destroyWindow(queue.window) |
---|
41 | end |
---|
42 | P.queueList[name] = nil |
---|
43 | end |
---|
44 | |
---|
45 | function P.pushNotification(queueName, notification) |
---|
46 | local queue = P.queueList[queueName] |
---|
47 | if queue == nil then |
---|
48 | cout(0, "0Queue is nil! " .. queueName) |
---|
49 | return |
---|
50 | end |
---|
51 | item = CEGUI.createListboxTextItem(notification) |
---|
52 | local listbox = CEGUI.toListbox(queue.window) |
---|
53 | if listbox:getItemCount() == 0 then |
---|
54 | listbox:addItem(item) |
---|
55 | else |
---|
56 | listbox:insertItem(item, listbox:getListboxItemFromIndex(0)) |
---|
57 | end |
---|
58 | |
---|
59 | if queue.visible == false then |
---|
60 | P.setVisible(queue, true) |
---|
61 | end |
---|
62 | end |
---|
63 | |
---|
64 | function P.popNotification(queueName) |
---|
65 | local queue = P.queueList[queueName] |
---|
66 | if queue == nil then |
---|
67 | cout(0, "1Queue is nil! " .. queueName) |
---|
68 | return |
---|
69 | end |
---|
70 | local listbox = CEGUI.toListbox(queue.window) |
---|
71 | listbox:removeItem(listbox:getListboxItemFromIndex(listbox:getItemCount()-1)) |
---|
72 | |
---|
73 | if listbox:getItemCount() == 0 then |
---|
74 | P.setVisible(queue, false) |
---|
75 | end |
---|
76 | end |
---|
77 | |
---|
78 | function P.removeNotification(queueName, index) |
---|
79 | local queue = P.queueList[queueName] |
---|
80 | if queue == nil then |
---|
81 | cout(0, "2Queue is nil! " .. queueName) |
---|
82 | return |
---|
83 | end |
---|
84 | local listbox = CEGUI.toListbox(queue.window) |
---|
85 | listbox:removeItem(listbox:getListboxItemFromIndex(tonumber(index))) |
---|
86 | |
---|
87 | if listbox:getItemCount() == 0 then |
---|
88 | P.setVisible(queue, false) |
---|
89 | end |
---|
90 | end |
---|
91 | |
---|
92 | function P.clearQueue(name) |
---|
93 | local queue = P.queueList[name] |
---|
94 | if queue == nil then |
---|
95 | cout(0, "3Queue is nil! " .. name) |
---|
96 | return |
---|
97 | end |
---|
98 | local listbox = CEGUI.toListbox(queue.window) |
---|
99 | CEGUI.toListbox(queue.window):resetList() |
---|
100 | |
---|
101 | P.setVisible(queue, false) |
---|
102 | end |
---|
103 | |
---|
104 | function P.changeSize(name, size) |
---|
105 | local queue = P.queueList[name] |
---|
106 | if queue == nil then |
---|
107 | cout(0, "5Queue is nil! " .. name) |
---|
108 | return |
---|
109 | end |
---|
110 | queue.window:setHeight(CEGUI.UDim(0, P.queueHeightHelper(queue.window, size))) |
---|
111 | end |
---|
112 | |
---|
113 | function P.setVisible(queue, visible) |
---|
114 | if queue == nil then |
---|
115 | cout(0, "6Queue is nil! " .. queue.name) |
---|
116 | return |
---|
117 | end |
---|
118 | queue.window:setVisible(visible) |
---|
119 | queue.visible = visible |
---|
120 | end |
---|
121 | |
---|
122 | function P.enterEditMode() |
---|
123 | P.editMode = true |
---|
124 | |
---|
125 | local root = winMgr:getWindow("orxonox/NotificationLayer/Root") |
---|
126 | |
---|
127 | --Add control frame window. |
---|
128 | local window = winMgr:createWindow("MenuWidgets/FrameWindow", "orxonox/NotificationLayer/Root/EditMode/ControlWindow") |
---|
129 | local frame = tolua.cast(window, "CEGUI::FrameWindow") |
---|
130 | frame:setCloseButtonEnabled(false) |
---|
131 | frame:setText("NotificationLayer Control Window") |
---|
132 | frame:setSize(CEGUI.UVector2(CEGUI.UDim(0.7, 0), CEGUI.UDim(0.2, 0))) |
---|
133 | root:addChildWindow(window) |
---|
134 | local pane = winMgr:createWindow("MenuWidgets/ScrollablePane", "orxonox/NotificationLayer/Root/EditMode/ControlWindow/ScrollingPane") |
---|
135 | pane:setSize(CEGUI.UVector2(CEGUI.UDim(1,-20), CEGUI.UDim(1,-30))) |
---|
136 | pane:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 10), CEGUI.UDim(0, 26))) |
---|
137 | window:addChildWindow(pane) |
---|
138 | |
---|
139 | vertOffset = 0 |
---|
140 | horzOffset = 0 |
---|
141 | local newQueueTitle = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/NotificationLayer/Root/EditMode/ControlWindow/NewQueueTitle") |
---|
142 | newQueueTitle:setText("Create a new NotificationQueue:") |
---|
143 | local size = getMinTextSize(newQueueTitle) |
---|
144 | local textHeight = size[1] |
---|
145 | newQueueTitle:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]), CEGUI.UDim(0, textHeight))) |
---|
146 | newQueueTitle:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset))) |
---|
147 | pane:addChildWindow(newQueueTitle) |
---|
148 | horzOffset = horzOffset + size[2] + 5 |
---|
149 | local newQueueName = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/NotificationLayer/Root/EditMode/ControlWindow/NewQueueName") |
---|
150 | newQueueName:setProperty("ReadOnly", "set:False") |
---|
151 | newQueueName:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]), CEGUI.UDim(0, textHeight))) |
---|
152 | newQueueName:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset))) |
---|
153 | horzOffset = horzOffset + size[2] + 5 |
---|
154 | pane:addChildWindow(newQueueName) |
---|
155 | local create = winMgr:createWindow("MenuWidgets/Button", "orxonox/NotificationLayer/Root/EditMode/ControlWindow/CreateNewQueue") |
---|
156 | create:setText("create") |
---|
157 | P.sampleWindow:setText("create") |
---|
158 | size = getMinTextSize(P.sampleWindow) |
---|
159 | create:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]+20), CEGUI.UDim(0, textHeight))) |
---|
160 | create:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset))) |
---|
161 | orxonox.GUIManager:subscribeEventHelper(create, "Clicked", P.name .. ".createNewQueue_clicked") |
---|
162 | pane:addChildWindow(create) |
---|
163 | horzOffset = horzOffset + size[2]+20 + 5 |
---|
164 | vertOffset = vertOffset + textHeight + 5 |
---|
165 | |
---|
166 | horzOffset = 0 |
---|
167 | local leave = winMgr:createWindow("MenuWidgets/Button", "orxonox/NotificationLayer/Root/EditMode/ControlWindow/LeaveEditModeButton") |
---|
168 | leave:setText("leave Edit Mode") |
---|
169 | P.sampleWindow:setText("leave Edit Mode") |
---|
170 | size = getMinTextSize(P.sampleWindow) |
---|
171 | leave:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]+20), CEGUI.UDim(0, textHeight))) |
---|
172 | leave:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset))) |
---|
173 | orxonox.GUIManager:subscribeEventHelper(leave, "Clicked", P.name .. ".leaveEditMode_clicked") |
---|
174 | pane:addChildWindow(leave) |
---|
175 | horzOffset = horzOffset + size[2]+20 + 5 |
---|
176 | vertOffset = vertOffset + textHeight + 5 |
---|
177 | |
---|
178 | --Replace all queues with FrameWindows |
---|
179 | for k,v in pairs(P.queueList) do |
---|
180 | if v ~= nil then |
---|
181 | local queue = P.queueList[k] |
---|
182 | root:removeChildWindow(queue.window) |
---|
183 | |
---|
184 | local window = P.createQueueEditFrame(queue.name) |
---|
185 | window:setArea(queue.window:getArea()) |
---|
186 | |
---|
187 | queue.edit = window |
---|
188 | end |
---|
189 | end |
---|
190 | end |
---|
191 | |
---|
192 | function P.createQueueEditFrame(name) |
---|
193 | local root = winMgr:getWindow("orxonox/NotificationLayer/Root") |
---|
194 | window = winMgr:createWindow("MenuWidgets/FrameWindow", "orxonox/NotificationLayer/Root/EditMode/" .. name) |
---|
195 | local frame = tolua.cast(window, "CEGUI::FrameWindow") |
---|
196 | frame:setCloseButtonEnabled(true) |
---|
197 | orxonox.GUIManager:subscribeEventHelper(frame, "CloseClicked", P.name .. ".closeQueue_clicked") |
---|
198 | frame:setText("NotificationQueue \"" .. name .. "\"") |
---|
199 | root:addChildWindow(window) |
---|
200 | local pane = winMgr:createWindow("MenuWidgets/ScrollablePane", "orxonox/NotificationLayer/Root/EditMode/" .. name .. "/ScrollingPane") |
---|
201 | pane:setSize(CEGUI.UVector2(CEGUI.UDim(1,-20), CEGUI.UDim(1,-30))) |
---|
202 | pane:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 10), CEGUI.UDim(0, 26))) |
---|
203 | window:addChildWindow(pane) |
---|
204 | |
---|
205 | local horzOffset = 0 |
---|
206 | local vertOffset = 0 |
---|
207 | |
---|
208 | local targetsTitle = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/NotificationLayer/Root/EditMode/" .. name .. "/TargetsTitle") |
---|
209 | targetsTitle:setText("Targets:") |
---|
210 | local size = getMinTextSize(targetsTitle) |
---|
211 | local textHeight = size[1] |
---|
212 | targetsTitle:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]), CEGUI.UDim(0, textHeight))) |
---|
213 | targetsTitle:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset))) |
---|
214 | pane:addChildWindow(targetsTitle) |
---|
215 | horzOffset = horzOffset + size[2] + 5 |
---|
216 | local targets = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/NotificationLayer/Root/EditMode/" .. name .. "/Targets") |
---|
217 | targets:setProperty("ReadOnly", "set:False") |
---|
218 | local targetsText = orxonox.NotificationManager:getInstance():getQueue(name):getTargets() |
---|
219 | targets:setText(targetsText) |
---|
220 | P.sampleWindow:setText(targetsText) |
---|
221 | size = getMinTextSize(P.sampleWindow) |
---|
222 | targets:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]*2+20), CEGUI.UDim(0, textHeight))) |
---|
223 | targets:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset))) |
---|
224 | horzOffset = horzOffset + size[2]*2+20 + 5 |
---|
225 | pane:addChildWindow(targets) |
---|
226 | local save = winMgr:createWindow("MenuWidgets/Button", "orxonox/NotificationLayer/Root/EditMode/" .. name .. "/Targets/Save") |
---|
227 | save:setText("save") |
---|
228 | P.sampleWindow:setText("save") |
---|
229 | size = getMinTextSize(P.sampleWindow) |
---|
230 | local saveTextWidth = size[2]+20 |
---|
231 | save:setSize(CEGUI.UVector2(CEGUI.UDim(0, saveTextWidth), CEGUI.UDim(0, textHeight))) |
---|
232 | save:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset))) |
---|
233 | orxonox.GUIManager:subscribeEventHelper(save, "Clicked", P.name .. ".saveTargets_clicked") |
---|
234 | pane:addChildWindow(save) |
---|
235 | horzOffset = horzOffset + saveTextWidth |
---|
236 | vertOffset = vertOffset + textHeight + 5 |
---|
237 | |
---|
238 | horzOffset = 0 |
---|
239 | local sizeTitle = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/NotificationLayer/Root/EditMode/" .. name .. "/SizeTitle") |
---|
240 | sizeTitle:setText("Size:") |
---|
241 | size = getMinTextSize(sizeTitle) |
---|
242 | sizeTitle:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]), CEGUI.UDim(0, textHeight))) |
---|
243 | sizeTitle:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset))) |
---|
244 | pane:addChildWindow(sizeTitle) |
---|
245 | horzOffset = horzOffset + size[2] + 5 |
---|
246 | local queueSize = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/NotificationLayer/Root/EditMode/" .. name .. "/Size") |
---|
247 | queueSize:setProperty("ReadOnly", "set:False") |
---|
248 | local maxSize = orxonox.NotificationManager:getInstance():getQueue(name):getMaxSize() |
---|
249 | queueSize:setText(maxSize) |
---|
250 | P.sampleWindow:setText(maxSize) |
---|
251 | size = getMinTextSize(P.sampleWindow) |
---|
252 | queueSize:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]*2+20), CEGUI.UDim(0, textHeight))) |
---|
253 | queueSize:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset))) |
---|
254 | horzOffset = horzOffset + size[2]*2+20 + 5 |
---|
255 | pane:addChildWindow(queueSize) |
---|
256 | save = winMgr:createWindow("MenuWidgets/Button", "orxonox/NotificationLayer/Root/EditMode/" .. name .. "/Size/Save") |
---|
257 | save:setText("save") |
---|
258 | P.sampleWindow:setText("save") |
---|
259 | size = getMinTextSize(P.sampleWindow) |
---|
260 | local saveTextWidth = size[2]+20 |
---|
261 | save:setSize(CEGUI.UVector2(CEGUI.UDim(0, saveTextWidth), CEGUI.UDim(0, textHeight))) |
---|
262 | save:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset))) |
---|
263 | orxonox.GUIManager:subscribeEventHelper(save, "Clicked", P.name .. ".saveSize_clicked") |
---|
264 | pane:addChildWindow(save) |
---|
265 | horzOffset = horzOffset + saveTextWidth |
---|
266 | vertOffset = vertOffset + textHeight + 5 |
---|
267 | |
---|
268 | horzOffset = 0 |
---|
269 | local displayTimeTitle = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/NotificationLayer/Root/EditMode/" .. name .. "/DisplayTimeTitle") |
---|
270 | displayTimeTitle:setText("Display time:") |
---|
271 | size = getMinTextSize(displayTimeTitle) |
---|
272 | displayTimeTitle:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]), CEGUI.UDim(0, textHeight))) |
---|
273 | displayTimeTitle:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset))) |
---|
274 | pane:addChildWindow(displayTimeTitle) |
---|
275 | horzOffset = horzOffset + size[2] + 5 |
---|
276 | local displayTime = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/NotificationLayer/Root/EditMode/" .. name .. "/DisplayTime") |
---|
277 | displayTime:setProperty("ReadOnly", "set:False") |
---|
278 | local time = orxonox.NotificationManager:getInstance():getQueue(name):getDisplayTime() |
---|
279 | displayTime:setText(time) |
---|
280 | P.sampleWindow:setText(time) |
---|
281 | size = getMinTextSize(P.sampleWindow) |
---|
282 | displayTime:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]*2+20), CEGUI.UDim(0, textHeight))) |
---|
283 | displayTime:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset))) |
---|
284 | horzOffset = horzOffset + size[2]*2+20 + 5 |
---|
285 | pane:addChildWindow(displayTime) |
---|
286 | save = winMgr:createWindow("MenuWidgets/Button", "orxonox/NotificationLayer/Root/EditMode/" .. name .. "/DisplayTime/Save") |
---|
287 | save:setText("save") |
---|
288 | P.sampleWindow:setText("save") |
---|
289 | size = getMinTextSize(P.sampleWindow) |
---|
290 | local saveTextWidth = size[2]+20 |
---|
291 | save:setSize(CEGUI.UVector2(CEGUI.UDim(0, saveTextWidth), CEGUI.UDim(0, textHeight))) |
---|
292 | save:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset))) |
---|
293 | orxonox.GUIManager:subscribeEventHelper(save, "Clicked", P.name .. ".saveDisplayTime_clicked") |
---|
294 | pane:addChildWindow(save) |
---|
295 | horzOffset = horzOffset + saveTextWidth |
---|
296 | vertOffset = vertOffset + textHeight + 5 |
---|
297 | |
---|
298 | return window |
---|
299 | end |
---|
300 | |
---|
301 | function P.leaveEditMode() |
---|
302 | P.editMode = false |
---|
303 | |
---|
304 | local root = winMgr:getWindow("orxonox/NotificationLayer/Root") |
---|
305 | --Replace all queues with FrameWindows |
---|
306 | for k,v in pairs(P.queueList) do |
---|
307 | if v ~= nil then |
---|
308 | root:addChildWindow(v.window) |
---|
309 | v.window:setArea(v.edit:getArea()) |
---|
310 | winMgr:destroyWindow(v.edit) |
---|
311 | v.edit = nil |
---|
312 | end |
---|
313 | end |
---|
314 | |
---|
315 | --Remove control window |
---|
316 | winMgr:destroyWindow(winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/ControlWindow")) |
---|
317 | end |
---|
318 | |
---|
319 | function P.afterHide() |
---|
320 | if P.editMode then |
---|
321 | P.leaveEditMode() |
---|
322 | showMenuSheet(P.name, false, true) |
---|
323 | end |
---|
324 | end |
---|
325 | |
---|
326 | function P. saveTargets_clicked(e) |
---|
327 | local we = CEGUI.toWindowEventArgs(e) |
---|
328 | local name = we.window:getName() |
---|
329 | |
---|
330 | local match = string.gmatch(name, "EditMode/.*/Targets/Save") |
---|
331 | local nameStr = match() |
---|
332 | local queueName = string.sub(nameStr, 10, string.len(nameStr)-13) |
---|
333 | |
---|
334 | local window = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Targets") |
---|
335 | local save = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Targets/Save") |
---|
336 | local width = window:getWidth():asAbsolute(1) |
---|
337 | |
---|
338 | local queue = orxonox.NotificationManager:getInstance():getQueue(queueName) |
---|
339 | queue:setTargets(window:getText()) |
---|
340 | local targets = queue:getTargets() |
---|
341 | |
---|
342 | window:setText(targets) |
---|
343 | P.sampleWindow:setText(targets) |
---|
344 | local size = getMinTextSize(P.sampleWindow) |
---|
345 | window:setWidth(CEGUI.UDim(0, size[2]*2+20)) |
---|
346 | save:setXPosition(CEGUI.UDim(0, save:getXPosition():asAbsolute(1)-width+window:getWidth():asAbsolute(1))) |
---|
347 | end |
---|
348 | |
---|
349 | function P. saveSize_clicked(e) |
---|
350 | local we = CEGUI.toWindowEventArgs(e) |
---|
351 | local name = we.window:getName() |
---|
352 | |
---|
353 | local match = string.gmatch(name, "EditMode/.*/Size/Save") |
---|
354 | local nameStr = match() |
---|
355 | local queueName = string.sub(nameStr, 10, string.len(nameStr)-10) |
---|
356 | |
---|
357 | local window = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Size") |
---|
358 | local save = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Size/Save") |
---|
359 | local width = window:getWidth():asAbsolute(1) |
---|
360 | |
---|
361 | local queue = orxonox.NotificationManager:getInstance():getQueue(queueName) |
---|
362 | queue:setMaxSize(tonumber(window:getText())) |
---|
363 | local maxSize = queue:getMaxSize() |
---|
364 | |
---|
365 | window:setText(maxSize) |
---|
366 | P.sampleWindow:setText(maxSize) |
---|
367 | local size = getMinTextSize(P.sampleWindow) |
---|
368 | window:setWidth(CEGUI.UDim(0, size[2]*2+20)) |
---|
369 | save:setXPosition(CEGUI.UDim(0, save:getXPosition():asAbsolute(1)-width+window:getWidth():asAbsolute(1))) |
---|
370 | end |
---|
371 | |
---|
372 | function P. saveDisplayTime_clicked(e) |
---|
373 | local we = CEGUI.toWindowEventArgs(e) |
---|
374 | local name = we.window:getName() |
---|
375 | |
---|
376 | local match = string.gmatch(name, "EditMode/.*/DisplayTime/Save") |
---|
377 | local nameStr = match() |
---|
378 | local queueName = string.sub(nameStr, 10, string.len(nameStr)-17) |
---|
379 | |
---|
380 | local window = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/DisplayTime") |
---|
381 | local save = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/DisplayTime/Save") |
---|
382 | local width = window:getWidth():asAbsolute(1) |
---|
383 | |
---|
384 | local queue = orxonox.NotificationManager:getInstance():getQueue(queueName) |
---|
385 | queue:setDisplayTime(tonumber(window:getText())) |
---|
386 | local time = queue:getDisplayTime() |
---|
387 | |
---|
388 | window:setText(time) |
---|
389 | P.sampleWindow:setText(time) |
---|
390 | local size = getMinTextSize(P.sampleWindow) |
---|
391 | window:setWidth(CEGUI.UDim(0, size[2]*2+20)) |
---|
392 | save:setXPosition(CEGUI.UDim(0, save:getXPosition():asAbsolute(1)-width+window:getWidth():asAbsolute(1))) |
---|
393 | end |
---|
394 | |
---|
395 | function P.createNewQueue_clicked(e) |
---|
396 | local window = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/ControlWindow/NewQueueName") |
---|
397 | local name = window:getText() |
---|
398 | orxonox.NotificationManager:getInstance():createQueue(name) |
---|
399 | |
---|
400 | local queue = P.queueList[name] |
---|
401 | if queue == nil then |
---|
402 | cout(0, "7Queue is nil! " .. name) |
---|
403 | return |
---|
404 | end |
---|
405 | |
---|
406 | local frame = P.createQueueEditFrame(name) |
---|
407 | local root = winMgr:getWindow("orxonox/NotificationLayer/Root") |
---|
408 | root:removeChildWindow(queue.window) |
---|
409 | frame:setArea(queue.window:getArea()) |
---|
410 | queue.edit = frame |
---|
411 | |
---|
412 | window:setText("") |
---|
413 | end |
---|
414 | |
---|
415 | function P.leaveEditMode_clicked(e) |
---|
416 | hideMenuSheet(P.name) |
---|
417 | end |
---|
418 | |
---|
419 | function P.closeQueue_clicked(e) |
---|
420 | local we = CEGUI.toWindowEventArgs(e) |
---|
421 | local name = we.window:getName() |
---|
422 | |
---|
423 | local match = string.gmatch(name, "EditMode/.*") |
---|
424 | local nameStr = match() |
---|
425 | local queueName = string.sub(nameStr, 10, string.len(nameStr)) |
---|
426 | |
---|
427 | winMgr:destroyWindow(P.queueList[queueName].edit) |
---|
428 | P.queueList[queueName].edit = nil |
---|
429 | orxonox.NotificationManager:getInstance():getQueue(queueName):destroy() |
---|
430 | end |
---|
431 | |
---|
432 | function P.queueHeightHelper(queue, size) |
---|
433 | local listbox = CEGUI.toListbox(queue) |
---|
434 | local item = CEGUI.createListboxTextItem("Text") |
---|
435 | listbox:addItem(item) |
---|
436 | local singleItemHeight = listbox:getTotalItemsHeight() |
---|
437 | local lookAndFeel = CEGUI.WidgetLookManager:getSingleton():getWidgetLook(queue:getLookNFeel()) |
---|
438 | local formattedArea = lookAndFeel:getNamedArea("ItemRenderingArea"):getArea():getPixelRect(queue) |
---|
439 | local frameHeight = queue:getUnclippedPixelRect():getHeight() - formattedArea:getHeight() |
---|
440 | listbox:removeItem(item) |
---|
441 | return frameHeight + singleItemHeight*size |
---|
442 | end |
---|
443 | |
---|
444 | return P |
---|