Bug 8479 - getSize() often returns 0 for a styled icon widget
: getSize() often returns 0 for a styled icon widget
Status: RESOLVED FIXED
Product: SB Touch
Classification: Unclassified
Component: UI
: unspecified
: PC Other
: P5 major (vote)
: ---
Assigned To: Richard Titmuss
:
Depends on:
Blocks: 6504
  Show dependency treegraph
 
Reported: 2008-06-18 13:52 UTC by Ben Klaas
Modified: 2009-03-25 12:25 UTC (History)
2 users (show)

See Also:
Category: ---


Attachments
reproduce issue in NowPlayingApplet (428 bytes, patch)
2008-07-02 12:23 UTC, Ben Klaas
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ben Klaas 2008-06-18 13:52:53 UTC
to fix bug 6504, which creates a new "smallicon" menu style, SlimBrowser needs to not use a hard-coded value for THUMB_SIZE

Richard, will this be a good use of your new service registration code? That is, have DefaultSkin register a method where another applet can query for icon size based on a given style?
Comment 1 Ben Klaas 2008-06-20 14:48:43 UTC
7.1 r2611: SlimBrowserApplet queries the icon style's size for determining the size of the thumbnail to be requested.

NowPlaying needs to yet be fixed, and appears to be a bit trickier.

Using icon:getSize() for browse menus should be enough to fix bug#6504. I'll check that first, but should be able to close that one if I'm correct in that assumption.

Comment 2 Ben Klaas 2008-06-23 09:12:34 UTC
It doesn't look like an icon widget can be queried for its size in many situations. For example, in SlimBrowser roundabout line 838 the titleIcon Icon widget that is created returns 0 when titleIcon:getSize() is called. I've tried a number of tweaks to the icon style (notably adding s.icon.w = 56, s.albumtitle.icon.w = 56, etc.) to no effect. 

-- 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")
     local iconSize = titleIcon:getSize()
     log:warn('**************', iconSize)
     _server:fetchArtworkThumb(data.window["icon-id"], titleIcon, THUMB_SIZE)


110549:4762 WARN (SlimBrowserApplet.lua:839) - **************0

The same is true for the artwork in NowPlayingApplet-- I can't dynamically choose the size to request because getSize() always returns 0

Richard, I poked around the C code a little bit but didn't find anything that looked glaring. Maybe I'm just getting myself confused in the skinning code, but I have a feeling there's something that might need fixing at the C layer. Punting to you for comment...punt back as you see fit.
Comment 3 Richard Titmuss 2008-07-02 03:32:09 UTC
Ben, I think I see the problem but need to test something first. I don't see to be able to trigger the code you've pasted below, how do I get into that code block?
Comment 4 Ben Klaas 2008-07-02 12:23:06 UTC
Created attachment 3530 [details]
reproduce issue in NowPlayingApplet

the example from SlimBrowser wasn't a good one because that part of the code isn't typically hit in normal browse menus.

try this patch against NowPlaying that just creates an icon of style "icon" and queries for its size. It should return a value from the skin for the icon size, but does not.
Comment 5 Richard Titmuss 2008-07-07 01:53:09 UTC
Punting to 7.2
Comment 6 Ben Klaas 2008-12-22 14:47:39 UTC
this is a must fix for the on screen keyboard. Need to be able to have buttons of different widths, styled in the skin, that can be queried with getSize()

Comment 7 Blackketter Dean 2009-03-25 12:16:21 UTC
is this fixed, ben?
Comment 8 Ben Klaas 2009-03-25 12:21:41 UTC
let's call it "worked around effectively" :)
Comment 9 Ben Klaas 2009-03-25 12:25:31 UTC
sorry, that last comment wasn't helpful to peterw, didn't realize there were outside devs cc:ed on this bug.

I would actually say that this bug is not fixed, but within the skin we set a bunch of constants in the param function that effectively do what we need--

in the skin applet:

function param(self)
        return {
                THUMB_SIZE = 41,
                nowPlayingBrowseArtworkSize = 190,
                nowPlayingSSArtworkSize     = 190,
                nowPlayingLargeArtworkSize  = 190,
        }
end

in JiveMain.lua:
function JiveMain:getSkinParam(key)
        if self._skin then
                local param = self._skin:param()

                if key and param[key] then
                        return param[key]
                end
        end

        log:error('no value for skinParam ', key, ' found')
        return nil
end

and finally, in an applet that needs the parameter, e.g., SlimBrowser:
local THUMB_SIZE = jiveMain:getSkinParam("THUMB_SIZE")
-- getSkinParam in this case would return 41


could be that's not an acceptable solution for what peterw is interested in. If not, please reopen.