Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 3, 2010, 9:17:51 PM (15 years ago)
Author:
dafrick
Message:

Some documenting, cleaning up. Also: Now the NotificationQueue has a height corresponding to its input size.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/notifications/data/gui/scripts/NotificationLayer.lua

    r7338 r7342  
    99    local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
    1010    local queue = winMgr:createWindow("MenuWidgets/Listbox", "orxonox/NotificationLayer/Root/Queue/" .. name)
     11    root:addChildWindow(queue)
     12
    1113    queue:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, 0)))
    12     queue:setSize(CEGUI.UVector2(CEGUI.UDim(1, 0), CEGUI.UDim(0.2, 0)))
    13     root:addChildWindow(queue)
     14    queue:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, 0), CEGUI.UDim(0, P.queueHeightHelper(queue, size))))
     15
    1416    table.insert(P.queueList, queue)
    1517    table.insert(P.nameList, name)
     
    3537
    3638function P.changePosition(name, xPos, yPos)
    37     local queue = P.nameToQueue(name)
     39    local queue = P.nameToQueueHelper(name)
    3840    if queue == nil then
    3941        cout(0, "Queue is nil!")
     
    4446
    4547function P.pushNotification(queueName, notification)
    46     local queue = P.nameToQueue(queueName)
     48    local queue = P.nameToQueueHelper(queueName)
    4749    if queue == nil then
    4850        cout(0, "Queue is nil!")
     
    5961
    6062function P.popNotification(queueName)
    61     local queue = P.nameToQueue(queueName)
     63    local queue = P.nameToQueueHelper(queueName)
    6264    if queue == nil then
    6365        cout(0, "Queue is nil!")
     
    6971
    7072function P.removeNotification(queueName, index)
    71     local queue = P.nameToQueue(queueName)
     73    local queue = P.nameToQueueHelper(queueName)
    7274    if queue == nil then
    7375        cout(0, "Queue is nil!")
     
    7981
    8082function P.clearQueue(name)
    81     local queue = P.nameToQueue(name)
     83    local queue = P.nameToQueueHelper(name)
    8284    if queue == nil then
    8385        cout(0, "Queue is nil!")
     
    8890end
    8991
    90 function P.nameToQueue(name)
     92function P.nameToQueueHelper(name)
    9193    local queue = nil
    9294    for k,v in pairs(P.nameList) do
     
    99101end
    100102
     103function P.queueHeightHelper(queue, size)
     104    local listbox = CEGUI.toListbox(queue)
     105    local item = CEGUI.createListboxTextItem("Text")
     106    listbox:addItem(item)
     107    local singleItemHeight = listbox:getTotalItemsHeight()
     108    local lookAndFeel = CEGUI.WidgetLookManager:getSingleton():getWidgetLook(queue:getLookNFeel())
     109    local formattedArea = lookAndFeel:getNamedArea("ItemRenderingArea"):getArea():getPixelRect(queue)
     110    local frameHeight = queue:getUnclippedPixelRect():getHeight() - formattedArea:getHeight()
     111    listbox:removeItem(item)
     112    return frameHeight + singleItemHeight*size
     113end
     114
    101115return P
    102116
Note: See TracChangeset for help on using the changeset viewer.