=== SlimBrowser/SlimBrowserApplet.lua ================================================================== --- SlimBrowser/SlimBrowserApplet.lua (revision 38873) +++ SlimBrowser/SlimBrowserApplet.lua (local) @@ -578,12 +578,11 @@ useTextArea = true end --- debug.dump(item, 8) if not group then if labelStyle == 'title' then group = Group(labelStyle, { - text = Label("text", ""), + text = Label("text", ""), icon = Icon("icon"), lbutton = _backButton(), rbutton = _nowPlayingButton(), @@ -1734,6 +1733,10 @@ --nextWindow on the action local aNextWindow + -- cache context menu actions for next window + local bActionContextMenu + local iActionContextMenu + -- setSelectedIndex will set the selected index of a menu. To be used in concert with nextWindow local iSetSelectedIndex local bSetSelectedIndex @@ -1803,7 +1806,9 @@ -- check for a 'do' action (overrides a straight 'go') -- actionName is corrected below!! bAction = _safeDeref(chunk, 'base', 'actions', 'do') + bActionContextMenu = _safeDeref(chunk, 'base', 'actions', 'more') iAction = _safeDeref(item, 'actions', 'do') + iActionContextMenu = _safeDeref(item, 'actions', 'more') onAction = _safeDeref(item, 'actions', 'on') offAction = _safeDeref(item, 'actions', 'off') end @@ -1845,7 +1850,31 @@ if iAction or bAction or choiceAction or nextWindow then -- the resulting action, if any local jsonAction + local jsonActionContextMenu + -- this block is solely for caching the callback for the more command for use in the next window + if iActionContextMenu then + if type(iActionContextMenu) == 'table' then + jsonActionContextMenu = iActionContextMenu + end + elseif bActionContextMenu then + jsonActionContextMenu = bActionContextMenu + local paramName = jsonActionContextMenu["itemsParams"] + local iParams = item[paramName] + if iParams then + -- found 'em! + -- add them to the command + -- make sure the base has a params item! + local params = jsonActionContextMenu["params"] + if not params then + params = {} + jsonActionContextMenu["params"] = params + end + for k,v in pairs(iParams) do + params[k] = v + end + end + end -- special case, handling a choice item action if choiceAction and selectedIndex then jsonAction = _safeDeref(item, 'actions', actionName, 'choices', selectedIndex) @@ -1909,6 +1938,7 @@ end end -- elseif bAction +--debug.dump(jsonAction, 8) -- now we may have found a command if jsonAction or useNextWindow then log:debug("_actionHandler(", actionName, "): json action") @@ -1967,7 +1997,7 @@ elseif item["showBigArtwork"] then sink = _bigArtworkPopup elseif actionName == 'go' or actionName == 'play-hold' then - step, sink = _newDestination(_getCurrentStep(), item, _newWindowSpec(db, item, isContextMenu), _browseSink, jsonAction) + step, sink = _newDestination(_getCurrentStep(), item, _newWindowSpec(db, item, isContextMenu), _browseSink, jsonAction, jsonActionContextMenu) if step.menu then from, qty = _decideFirstChunk(step, jsonAction) end @@ -1977,7 +2007,6 @@ -- using addAction is temporary to ensure backwards compatibility -- until all 'add' commands are removed in SC in favor of 'more' _safeDeref(chunk, 'base', 'addAction') == 'more') then - log:debug('Context Menu') -- Bug 14061: send command flag to have XMLBrowser fork CM response off to get playback controls if jsonAction.params then @@ -2137,7 +2166,6 @@ log:debug("_browseMenuListener: ACTION") local action = event:getAction() local actionName = _actionToActionName[action] - if actionName then return _actionHandler(menu, menuItem, db, dbIndex, event, actionName, item) end @@ -2454,21 +2482,58 @@ -- the destination can be retrieved (i.e. reunite data and window) -- data is generic data that is stored in the step; it is used f.e. to keep the json action between the -- first incantation and the subsequent ones needed to capture all data (see _browseSink). -_newDestination = function(origin, item, windowSpec, sink, data) +-- contextMenu is the json action of the more command (if any) from the previous menu item +_newDestination = function(origin, item, windowSpec, sink, data, contextMenu) log:debug("_newDestination():") log:debug(windowSpec) +--debug.dump(data, 8) -- a DB (empty...) local db = DB(windowSpec) local window + local titleWidgetComplete = false + if windowSpec.isContextMenu then window = ContextMenuWindow("", windowSpec.windowId) -- todo localize or decide what title text should be else window = Window(windowSpec.windowStyle or 'text_list', _, _, windowSpec.windowId) + if contextMenu then + log:warn('Turn the text into a button') + local titleWidget = Group('title', { + text = Button( + Group( "textButton", { Label("text", windowSpec.text) } ), + function() + log:warn('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!') + local step, sink = _newDestination(_getCurrentStep(), item, _newWindowSpec(db, item, true), _browseSink, contextMenu) + local from, qty + if step.menu then + from, qty = _decideFirstChunk(step, contextMenu) + end + _pushToNewWindow(step) + _performJSONAction(contextMenu, from, qty, step, sink, _) + end + ), + +--[[ + text = Button( + Group( "textButton", { Label("text", windowSpec.text) } ), + function() + log:warn('!!!!!!!!!!!!!!!!') + return EVENT_CONSUME + end + ), +--]] + + icon = Icon("icon"), + lbutton = _backButton(), + rbutton = _nowPlayingButton(), + }) + window:setTitleWidget(titleWidget) + titleWidgetComplete = true + end end - local titleWidgetComplete = false local timeFormat = nil local menu -- if the item has an input field or fields, we must ask for it @@ -2533,15 +2598,18 @@ db = db, -- step db sink = false, -- sink closure embedding this step data = data, -- data (generic) + contextMenu = contextMenu, -- json action of previous menu item actionModifier = false, -- modifier } log:debug("new step: " , step) + if not windowSpec.isContextMenu and not titleWidgetComplete then - window:setTitleWidget(_decoratedLabel(nil, 'title', windowSpec, step, false)) + window:setTitleWidget(_decoratedLabel(nil, 'title', windowSpec, step, false, contextMenu)) end + if step.menu then if windowSpec.isContextMenu then step.menu:setDisableVerticalBump(true) === WQVGAsmallSkin/WQVGAsmallSkinApplet.lua ================================================================== --- WQVGAsmallSkin/WQVGAsmallSkinApplet.lua (revision 38873) +++ WQVGAsmallSkin/WQVGAsmallSkinApplet.lua (local) @@ -819,6 +819,11 @@ } } + s.title.textButton = _uses(s.title.text, { + bgImg = titlebarButtonBox, + text = _uses(s.title.text), + }) + s.text_block_black = { bgImg = Tile:fillColor(0x000000ff), position = LAYOUT_NORTH, @@ -1471,7 +1476,7 @@ line = { { font = _boldfont(18), - height = 21, + height = 18, }, { font = _font(14), @@ -1480,6 +1485,13 @@ }, }, }) + s.text_list.title.textButton = _uses(s.text_list.title.text, { + bgImg = titlebarButtonBox, + text = _uses(s.text_list.title.text), + }) + s.text_list.title.pressed.textButton = _uses(s.text_list.title.textButton, { + bgImg = titlebarButtonPressedBox, + }) -- choose player window is exactly the same as text_list on all windows except WQVGAlarge s.choose_player = s.text_list