Author: titmuss
Date: Fri May 23 14:49:06 2008
New Revision: 2523
URL: http://svn.slimdevices.com?rev=2523&root=Jive&view=rev
Log:
[EMAIL PROTECTED] (orig r2515): bklaas | 2008-05-23 01:52:22 +0100
Bug: 8123
Description: add customMenuTable to handle slightly changed item table for the
home menu (text altered for context)
[EMAIL PROTECTED] (orig r2519): bklaas | 2008-05-23 21:15:26 +0100
Bug: n/a
Description: allow icon to be sent with current window request response
add getTitleStyle and getTitleWidget Window methods
Modified:
7.2/trunk/ (props changed)
7.2/trunk/squeezeplay/src/squeezeplay/share/applets/CustomizeHomeMenu/CustomizeHomeMenuApplet.lua
7.2/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua
7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/HomeMenu.lua
7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/SimpleMenu.lua
7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Window.lua
Propchange: 7.2/trunk/
------------------------------------------------------------------------------
--- svk:merge (original)
+++ svk:merge Fri May 23 14:49:06 2008
@@ -1,5 +1,5 @@
bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/7.0/trunk:2502
-bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/7.1/trunk:2507
+bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/7.1/trunk:2519
bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/7.0:2013
bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/SN:1083
bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/scrolling:1378
Modified:
7.2/trunk/squeezeplay/src/squeezeplay/share/applets/CustomizeHomeMenu/CustomizeHomeMenuApplet.lua
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/squeezeplay/share/applets/CustomizeHomeMenu/CustomizeHomeMenuApplet.lua?rev=2523&root=Jive&r1=2522&r2=2523&view=diff
==============================================================================
---
7.2/trunk/squeezeplay/src/squeezeplay/share/applets/CustomizeHomeMenu/CustomizeHomeMenuApplet.lua
(original)
+++
7.2/trunk/squeezeplay/src/squeezeplay/share/applets/CustomizeHomeMenu/CustomizeHomeMenuApplet.lua
Fri May 23 14:49:06 2008
@@ -197,7 +197,9 @@
-- fetch item by id
local item = jiveMain:getMenuItem(id)
-- replace to original node, remove
customNode
- jiveMain:setNode(item, item.node)
+ if item then
+ jiveMain:setNode(item,
item.node)
+ end
end
self:storeSettings()
_goHome()
Modified:
7.2/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua?rev=2523&root=Jive&r1=2522&r2=2523&view=diff
==============================================================================
---
7.2/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua
(original)
+++
7.2/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua
Fri May 23 14:49:06 2008
@@ -814,8 +814,9 @@
step.menu:setStyle(step.db:menuStyle())
if data.window then
-- if a titleStyle is being sent, we need to
setTitleWidget completely
- if data.window.titleStyle then
- local titleText
+ if data.window.titleStyle or
data.window['icon-id'] then
+ local titleText, titleStyle, titleIcon
+ local titleWidget =
step.window:getTitleWidget()
-- set the title text if specified
if data.window.text then
titleText = data.window.text
@@ -827,8 +828,23 @@
titleText = ''
end
end
- local titleStyle =
data.window.titleStyle .. 'title'
- local newTitleWidget =
Group(titleStyle, { text = Label("text", titleText), icon = Icon("icon") })
+ if data.window.titleStyle then
+ titleStyle =
data.window.titleStyle .. 'title'
+ else
+ titleStyle =
step.window:getTitleStyle()
+ end
+ -- add the icon if it's been specified
in the window params
+ if data.window['icon-id'] then
+ -- Fetch an image from
SlimServer
+ titleIcon = Icon("icon")
+
_server:fetchArtworkThumb(data.window["icon-id"], titleIcon, THUMB_SIZE)
+ -- only allow the existing icon to stay
if titleStyle isn't being changed
+ elseif not data.window.titleStyle and
titleWidget:getWidget('icon') then
+ titleIcon =
titleWidget:getWidget('icon')
+ else
+ titleIcon = Icon("icon")
+ end
+ local newTitleWidget =
Group(titleStyle, { text = Label("text", titleText), icon = titleIcon })
step.window:setTitleWidget(newTitleWidget)
-- change the text as specified if no
titleStyle param was also sent
elseif data.window.text then
Modified: 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/HomeMenu.lua
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/HomeMenu.lua?rev=2523&root=Jive&r1=2522&r2=2523&view=diff
==============================================================================
--- 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/HomeMenu.lua (original)
+++ 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/HomeMenu.lua Fri May 23
14:49:06 2008
@@ -1,5 +1,5 @@
-local assert, pairs, type = assert, pairs, type
+local assert, pairs, type, tostring, tonumber, setmetatable = assert, pairs,
type, tostring, tonumber, setmetatable
local oo = require("loop.base")
local table = require("jive.utils.table")
@@ -16,6 +16,22 @@
-- our class
module(..., oo.class)
+-- defines a new item that inherits from an existing item
+local function _uses(parent, value)
+ local item = {}
+ setmetatable(item, { __index = parent })
+
+ for k,v in pairs(value or {}) do
+ if type(v) == "table" and type(parent[k]) == "table" then
+ -- recursively inherrit from parent item
+ item[k] = _uses(parent[k], v)
+ else
+ item[k] = v
+ end
+ end
+
+ return item
+end
-- create a new menu
function __init(self, name, style, titleStyle)
@@ -24,6 +40,7 @@
windowTitle = name,
menuTable = {},
nodeTable = {},
+ customMenuTable = {},
customNodes = {},
})
@@ -210,8 +227,6 @@
if item.node ~= 'home' and node == 'home' then
local complexWeight = self:getComplexWeight(item.id,
item)
item.weights = strings:split('%.', complexWeight)
- -- non-home items on home get an indent
- item.indent = #item.weights * 2
end
else
node = item.node
@@ -220,7 +235,14 @@
if self.nodeTable[node] then
self.nodeTable[node].items[item.id] = item
- self.nodeTable[node].menu:addItem(item)
+ local menuIdx = self.nodeTable[node].menu:addItem(item)
+ if node == 'home' and item.homeMenuText then
+ local labelText = item.homeMenuText
+ -- change the menu item's text by creating a new item
table with different label text
+ local myItem = _uses(item, { text = labelText })
+ self.customMenuTable[myItem.id] = myItem
+ self.nodeTable[node].menu:replaceIndex(myItem, menuIdx)
+ end
end
end
@@ -310,11 +332,19 @@
node = item.node
end
assert(node)
+ if node == 'home' and self.customMenuTable[item.id] then
+ local myIdx = self.nodeTable[node].menu:getIdIndex(item.id)
+ local myItem = self.nodeTable[node].menu:getItem(myIdx)
+ self.nodeTable[node].menu:removeItem(myItem)
+ end
+
if self.nodeTable[node] then
self.nodeTable[node].items[item.id] = nil
self.nodeTable[node].menu:removeItem(item)
self:_checkRemoveNode(node)
end
+
+
end
-- remove an item from a menu by its index
Modified: 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/SimpleMenu.lua
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/SimpleMenu.lua?rev=2523&root=Jive&r1=2522&r2=2523&view=diff
==============================================================================
--- 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/SimpleMenu.lua
(original)
+++ 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/SimpleMenu.lua Fri May
23 14:49:06 2008
@@ -35,8 +35,6 @@
The Label includes the following style parameters in addition to the widgets
basic parameters.
-=over
-
B<itemHeight> : the height of each menu item.
=head1 METHODS
@@ -114,21 +112,6 @@
for i = 1,size do
if indexList[i] ~= nil then
local item = list[indexList[i]]
- local labelText = item.text
- -- FIXME
- -- changing labelText for the item for the home menu
- -- also changes it for its default location
- -- label text needs to be changed on a contextual basis
- -- question is how to determine context in
_itemRenderer since self is not available
- --[[
- if item.homeMenuText then
- labelText = item.homeMenuText
- end
- if item.indent then
- local indent = _indent(item.indent)
- labelText = indent .. tostring(labelText)
- end
- --]]
local icon = item.icon or menu.icons[i]
if icon == nil then
@@ -139,13 +122,13 @@
if widgetList[i] == nil then
widgetList[i] = Group(item.style or "item", {
- text = Label("text", labelText),
+ text = Label("text", item.text),
check = Icon("check"),
icon = icon,
})
else
widgetList[i]:setStyle(item.style or "item")
- widgetList[i]:setWidgetValue("text", labelText)
+ widgetList[i]:setWidgetValue("text", item.text)
widgetList[i]:setWidget("icon", icon)
end
end
@@ -201,6 +184,7 @@
the menu is not sorted and elements will be displayed in the order they are
added.
+=cut
--]]
function setComparator(self, comp)
self.comparator = comp
@@ -217,6 +201,7 @@
Item comparator to sort items alphabetically (i.e. using item.text).
+=cut
--]]
function itemComparatorAlpha(a, b)
return tostring(a.text) < tostring(b.text)
@@ -230,6 +215,7 @@
Item comparator to sort items using item.weight as a primary key, and
item.text as a secondary key.
+=cut
--]]
function itemComparatorWeightAlpha(a, b)
local w = a.weight - b.weight
@@ -247,6 +233,7 @@
Item comparator to sort items using item.sortKey as a primary key, item.weight
as a secondary key, and
item.text as a tertiary key.
+=cut
--]]
function itemComparatorKeyWeightAlpha(a, b)
local an = tostring(a.sortKey)
@@ -271,6 +258,7 @@
Item comparator to sort items using a complex a.b.c...n-style item.weights
(table) as a primary key, and
item.text as a secondary key.
+=cut
--]]
function itemComparatorComplexWeightAlpha(a, b)
if not a.weights then
@@ -607,7 +595,6 @@
Menu.setItems(self, self.items, #self.items, index, index)
end
-
--[[
=head2 jive.ui.Menu:updatedItem(item)
Modified: 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Window.lua
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Window.lua?rev=2523&root=Jive&r1=2522&r2=2523&view=diff
==============================================================================
--- 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Window.lua (original)
+++ 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Window.lua Fri May 23
14:49:06 2008
@@ -478,6 +478,39 @@
return nil
end
+--[[
+
+=head2 jive.ui.Window:getTitleWidget()
+
+Returns the window's title widget.
+
+=cut
+--]]
+function getTitleWidget(self)
+ if self.title then
+ return self.title
+ end
+ return nil
+end
+
+
+--[[
+
+=head2 jive.ui.Window:getTitleStyle()
+
+Returns the style of the title widget.
+
+=cut
+--]]
+function getTitleStyle(self)
+ if self.title then
+ if self.title:getWidget('text') then
+ return self.title:getWidget('text'):getStyle()
+ end
+ end
+ return nil
+end
+
--[[
_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/cgi-bin/mailman/listinfo/jive-checkins