[Orxonox-commit 2646] r7351 - in code/branches/notifications: data/gui/scripts src/modules/notifications

dafrick at orxonox.net dafrick at orxonox.net
Sat Sep 4 17:56:35 CEST 2010


Author: dafrick
Date: 2010-09-04 17:56:35 +0200 (Sat, 04 Sep 2010)
New Revision: 7351

Modified:
   code/branches/notifications/data/gui/scripts/NotificationLayer.lua
   code/branches/notifications/src/modules/notifications/NotificationManager.cc
Log:
NotificationQueue now disappears if there are no notifications to be displayed. Also: "Fixed" Seg-fault.


Modified: code/branches/notifications/data/gui/scripts/NotificationLayer.lua
===================================================================
--- code/branches/notifications/data/gui/scripts/NotificationLayer.lua	2010-09-04 15:26:49 UTC (rev 7350)
+++ code/branches/notifications/data/gui/scripts/NotificationLayer.lua	2010-09-04 15:56:35 UTC (rev 7351)
@@ -4,16 +4,19 @@
 
 P.queueList = {}
 P.nameList = {}
+P.visible = nil
 
 function P.createQueue(name, size)
     local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
     local queue = winMgr:createWindow("MenuWidgets/Listbox", "orxonox/NotificationLayer/Root/Queue/" .. name)
-    queue:setProperty("BackgroundColor", "00FFFFFF")
+    queue:setProperty("BackgroundColor", "66FFFFFF")
     root:addChildWindow(queue)
 
     queue:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, 0)))
     queue:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, 0), CEGUI.UDim(0, P.queueHeightHelper(queue, size))))
 
+    P.setVisible(queue, false)
+
     table.insert(P.queueList, queue)
     table.insert(P.nameList, name)
     --TODO: Check name for uniqueness.
@@ -49,6 +52,10 @@
     else
         listbox:insertItem(item, listbox:getListboxItemFromIndex(0))
     end
+
+    if P.visible == false then
+        P.setVisible(queue, true)
+    end
 end
 
 function P.popNotification(queueName)
@@ -59,6 +66,10 @@
     end
     local listbox = CEGUI.toListbox(queue)
     listbox:removeItem(listbox:getListboxItemFromIndex(listbox:getItemCount()-1))
+
+    if listbox:getItemCount() == 0 then
+        P.setVisible(queue, false)
+    end
 end
 
 function P.removeNotification(queueName, index)
@@ -69,6 +80,10 @@
     end
     local listbox = CEGUI.toListbox(queue)
     listbox:removeItem(listbox:getListboxItemFromIndex(tonumber(index)))
+
+    if listbox:getItemCount() == 0 then
+        P.setVisible(queue, false)
+    end
 end
 
 function P.clearQueue(name)
@@ -79,6 +94,8 @@
     end
     local listbox = CEGUI.toListbox(queue)
     CEGUI.toListbox(queue):resetList()
+
+    P.setVisible(queue, false)
 end
 
 function P.changePosition(name, xPos, yPos)
@@ -100,6 +117,11 @@
     queue:setHeight(CEGUI.UDim(0, P.queueHeightHelper(queue, size)))
 end
 
+function P.setVisible(queue, visible)
+    queue:setVisible(visible)
+    P.visible = visible
+end
+
 function P.nameToQueueHelper(name)
     local queue = nil
     for k,v in pairs(P.nameList) do

Modified: code/branches/notifications/src/modules/notifications/NotificationManager.cc
===================================================================
--- code/branches/notifications/src/modules/notifications/NotificationManager.cc	2010-09-04 15:26:49 UTC (rev 7350)
+++ code/branches/notifications/src/modules/notifications/NotificationManager.cc	2010-09-04 15:56:35 UTC (rev 7351)
@@ -73,7 +73,7 @@
     */
     NotificationManager::~NotificationManager()
     {
-        this->queue_->destroy();
+        //this->queue_->destroy();
     }
 
     /**




More information about the Orxonox-commit mailing list