Author: titmuss
Date: Mon Nov  3 09:21:37 2008
New Revision: 3261

URL: http://svn.slimdevices.com?rev=3261&root=Jive&view=rev
Log:
Bug: 9191
Description:
Added per window styles and fixed existing applets to use the new api.


Modified:
    7.3/trunk/squeezeplay/src/squeezeplay/share/applets/Flickr/FlickrApplet.lua
    7.3/trunk/squeezeplay/src/squeezeplay/share/applets/Flickr/FlickrMeta.lua
    
7.3/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/MacroPlayApplet.lua
    
7.3/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/MacroPlayMeta.lua
    
7.3/trunk/squeezeplay/src/squeezeplay/share/applets/SetupNetTest/SetupNetTestApplet.lua
    
7.3/trunk/squeezeplay/src/squeezeplay/share/applets/SetupNetTest/SetupNetTestMeta.lua
    7.3/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Window.lua
    7.3/trunk/squeezeplay/src/squeezeplay/src/ui/jive_style.c
    
7.3/trunk/squeezeplay/src/squeezeplay_contrib/share/applets/Bounce/BounceApplet.lua
    
7.3/trunk/squeezeplay/src/squeezeplay_contrib/share/applets/Bounce/BounceMeta.lua
    
7.3/trunk/squeezeplay/src/squeezeplay_contrib/share/applets/Snake/SnakeApplet.lua

Modified: 
7.3/trunk/squeezeplay/src/squeezeplay/share/applets/Flickr/FlickrApplet.lua
URL: 
http://svn.slimdevices.com/7.3/trunk/squeezeplay/src/squeezeplay/share/applets/Flickr/FlickrApplet.lua?rev=3261&root=Jive&r1=3260&r2=3261&view=diff
==============================================================================
--- 7.3/trunk/squeezeplay/src/squeezeplay/share/applets/Flickr/FlickrApplet.lua 
(original)
+++ 7.3/trunk/squeezeplay/src/squeezeplay/share/applets/Flickr/FlickrApplet.lua 
Mon Nov  3 09:21:37 2008
@@ -479,6 +479,13 @@
 function _window(self, ...)
        local window = Window("flickr")
 
+       window:setSkin({
+               flickr = {
+                      layout = Window.noLayout,
+                      font = Font:load("fonts/FreeSans.ttf", 10)
+               }
+       })
+
        -- black window background
        window:setShowFrameworkWidgets(false)
 
@@ -879,15 +886,6 @@
 end
 
 
--- applet skin
-function skin(self, s)
-       s.flickr = {
-               layout = Window.noLayout,
-               font = Font:load("fonts/FreeSans.ttf", 10)
-       }
-end
-
-
 --[[
 
 =head1 LICENSE

Modified: 
7.3/trunk/squeezeplay/src/squeezeplay/share/applets/Flickr/FlickrMeta.lua
URL: 
http://svn.slimdevices.com/7.3/trunk/squeezeplay/src/squeezeplay/share/applets/Flickr/FlickrMeta.lua?rev=3261&root=Jive&r1=3260&r2=3261&view=diff
==============================================================================
--- 7.3/trunk/squeezeplay/src/squeezeplay/share/applets/Flickr/FlickrMeta.lua 
(original)
+++ 7.3/trunk/squeezeplay/src/squeezeplay/share/applets/Flickr/FlickrMeta.lua 
Mon Nov  3 09:21:37 2008
@@ -46,10 +46,6 @@
 
 
 function registerApplet(self)
-
-       -- load our skin
-       jiveMain:loadSkin("Flickr", "skin")
-
 end
 
 function configureApplet(self)

Modified: 
7.3/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/MacroPlayApplet.lua
URL: 
http://svn.slimdevices.com/7.3/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/MacroPlayApplet.lua?rev=3261&root=Jive&r1=3260&r2=3261&view=diff
==============================================================================
--- 
7.3/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/MacroPlayApplet.lua
 (original)
+++ 
7.3/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/MacroPlayApplet.lua
 Mon Nov  3 09:21:37 2008
@@ -105,6 +105,15 @@
        local window = Window("window", self:string("MACRO_AUTOSTART"))
        local menu = SimpleMenu("menu", items)
        local help = Textarea("textarea", "")
+
+       window:setSkin({
+               macroPass = {
+                       img = Surface:loadImage("applets/MacroPlay/pass.png"),
+               },
+               macroFail = {
+                       img = Surface:loadImage("applets/MacroPlay/fail.png"),
+               },
+       })
 
        window:addWidget(help)
        window:addWidget(menu)
@@ -519,16 +528,6 @@
 end
 
 
-function skin(self, s)
-       s.macroPass = {
-               img = Surface:loadImage("applets/MacroPlay/pass.png")
-       }
-       s.macroFail = {
-               img = Surface:loadImage("applets/MacroPlay/fail.png")
-       }
-end
-
-
 --[[
 
 =head1 LICENSE

Modified: 
7.3/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/MacroPlayMeta.lua
URL: 
http://svn.slimdevices.com/7.3/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/MacroPlayMeta.lua?rev=3261&root=Jive&r1=3260&r2=3261&view=diff
==============================================================================
--- 
7.3/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/MacroPlayMeta.lua 
(original)
+++ 
7.3/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/MacroPlayMeta.lua 
Mon Nov  3 09:21:37 2008
@@ -53,7 +53,5 @@
 
        -- menu item to start
        jiveMain:addItem(meta:menuItem('macroPlay', 'extras', 'MACRO_PLAY', 
function(applet, ...) applet:settingsShow(...) end))
-
-       jiveMain:loadSkin("MacroPlay", "skin")
 end
 

Modified: 
7.3/trunk/squeezeplay/src/squeezeplay/share/applets/SetupNetTest/SetupNetTestApplet.lua
URL: 
http://svn.slimdevices.com/7.3/trunk/squeezeplay/src/squeezeplay/share/applets/SetupNetTest/SetupNetTestApplet.lua?rev=3261&root=Jive&r1=3260&r2=3261&view=diff
==============================================================================
--- 
7.3/trunk/squeezeplay/src/squeezeplay/share/applets/SetupNetTest/SetupNetTestApplet.lua
 (original)
+++ 
7.3/trunk/squeezeplay/src/squeezeplay/share/applets/SetupNetTest/SetupNetTestApplet.lua
 Mon Nov  3 09:21:37 2008
@@ -66,6 +66,21 @@
        end
 
        self.window = Window("nettest", self:string('SETUPNETTEST_TESTING'))
+       self.window:setSkin({
+               nettest = {
+                       icon = {
+                               padding = { 20, 3, 20, 1 }
+                       },
+                       graphtitle = {
+                               padding = { 20, 7, 0, 0 },
+                               fg = { 0xE7, 0xE7, 0xE7 }
+                       },
+                       graphaxis = {
+                                 padding = { 20, 1, 0, 0 },
+                                 fg = { 0xE7, 0xE7, 0xE7 }
+                       }
+               }
+       })
 
        self:tieAndShowWindow(self.window)
 
@@ -154,7 +169,7 @@
 
 
 function showHelpWindow(self)
-       local window = Window("nettest", self:string('SETUPNETTEST_HELPTITLE'))
+       local window = Window("window", self:string('SETUPNETTEST_HELPTITLE'))
        local help = Textarea("textarea", self:string('SETUPNETTEST_HELP'))
 
        window:addWidget(help)
@@ -265,23 +280,6 @@
 end
 
 
-function skin(self, s)
-       s.nettest = {
-               icon = {
-                       padding = { 20, 3, 20, 1 }
-               },
-               graphtitle = {
-                       padding = { 20, 7, 0, 0 },
-                       fg = { 0xE7, 0xE7, 0xE7 }
-               },
-               graphaxis = {
-                       padding = { 20, 1, 0, 0 },
-                       fg = { 0xE7, 0xE7, 0xE7 }
-               }
-       }
-end
-
-
 function free(self)
        self.timer:stop()
        self:stopTest()

Modified: 
7.3/trunk/squeezeplay/src/squeezeplay/share/applets/SetupNetTest/SetupNetTestMeta.lua
URL: 
http://svn.slimdevices.com/7.3/trunk/squeezeplay/src/squeezeplay/share/applets/SetupNetTest/SetupNetTestMeta.lua?rev=3261&root=Jive&r1=3260&r2=3261&view=diff
==============================================================================
--- 
7.3/trunk/squeezeplay/src/squeezeplay/share/applets/SetupNetTest/SetupNetTestMeta.lua
 (original)
+++ 
7.3/trunk/squeezeplay/src/squeezeplay/share/applets/SetupNetTest/SetupNetTestMeta.lua
 Mon Nov  3 09:21:37 2008
@@ -33,8 +33,6 @@
        -- add the menu item to homeMenu but 'hidden', or else the 
playerCurrent notification method below quits happening (not sure why this is 
the case, but it is)
        -- item will be made visible by moving it to advancedSettings in the 
playerCurrent notification below
        jiveMain:addItem(meta.menu)
-
-       jiveMain:loadSkin("SetupNetTest", "skin")
 end
 
 -- hide menu item when player goes away

Modified: 7.3/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Window.lua
URL: 
http://svn.slimdevices.com/7.3/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Window.lua?rev=3261&root=Jive&r1=3260&r2=3261&view=diff
==============================================================================
--- 7.3/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Window.lua (original)
+++ 7.3/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Window.lua Mon Nov  3 
09:21:37 2008
@@ -799,6 +799,16 @@
 end
 
 
+function setSkin(self, skin)
+        self.skin = skin
+end
+
+
+function getSkin(self)
+        return self.skin
+end
+
+
 function __tostring(self)
        if self.title then
                return "Window(" .. tostring(self.title) .. ")"

Modified: 7.3/trunk/squeezeplay/src/squeezeplay/src/ui/jive_style.c
URL: 
http://svn.slimdevices.com/7.3/trunk/squeezeplay/src/squeezeplay/src/ui/jive_style.c?rev=3261&root=Jive&r1=3260&r2=3261&view=diff
==============================================================================
--- 7.3/trunk/squeezeplay/src/squeezeplay/src/ui/jive_style.c (original)
+++ 7.3/trunk/squeezeplay/src/squeezeplay/src/ui/jive_style.c Mon Nov  3 
09:21:37 2008
@@ -50,20 +50,22 @@
 static int jiveL_style_find_value(lua_State *L) {
        /* stack is:
         * 1: widget
-        * 2: path
-        * 3: key
+        * 2: skin
+        * 3: path
+        * 4: key
         */
 
-       const char *path = lua_tostring(L, 2);
-       const char *key = lua_tostring(L, 3);
+       const char *path = lua_tostring(L, 3);
+       const char *key = lua_tostring(L, 4);
 
        char *ptr = (char *) path;
        while (ptr) {
                char *tmp = strdup(ptr);
 
-               get_jive_ui_style(L);
+               lua_pushvalue(L, 2);
                if (search_path(L, 1, tmp, key) && !lua_isnil(L, -1)) {
                        free(tmp);
+
                        lua_remove(L, -2);
                        return 1;
                }
@@ -79,6 +81,24 @@
        lua_pushnil(L);
        return 1;
 }
+
+#if RUNTIME_DEBUG
+static void debug_style(lua_State *L, const char *path, const char *key) {
+       lua_getglobal(L, "tostring");
+       lua_pushvalue(L, -2);
+       lua_call(L, 1, 1);
+
+       lua_getglobal(L, "tostring");
+       lua_pushvalue(L, 1);
+       lua_call(L, 1, 1);
+
+       DEBUG_TRACE("style: [%s] %s : %s = %s", lua_tostring(L, -1), path, key, 
lua_tostring(L, -2));
+       lua_pop(L, 2);
+}
+#else
+static void debug_style(lua_State *L, const char *path, const char *key) {
+}
+#endif
 
 static int STYLE_VALUE_NIL;
 
@@ -113,7 +133,6 @@
        pathidx = lua_gettop(L);
        path = lua_tostring(L, -1);
 
-
        /* check cache */
        lua_getfield(L, LUA_REGISTRYINDEX, "jiveStyleCache");
        if (lua_isnil(L, -1)) {
@@ -143,9 +162,10 @@
                // find value
                lua_pushcfunction(L, jiveL_style_find_value);
                lua_pushvalue(L, 1); // widget
+               get_jive_ui_style(L); // skin
                lua_pushvalue(L, pathidx);
                lua_pushvalue(L, 2); // key
-               lua_call(L, 3, 1);
+               lua_call(L, 4, 1);
 
                if (lua_isnil(L, -1)) {
                        /* use a marker for nil */
@@ -156,14 +176,7 @@
                }
                lua_setfield(L, -3, key);
 
-#if RUNTIME_DEBUG
-               lua_getglobal(L, "tostring");
-               lua_pushvalue(L, -2);
-               lua_call(L, 1, 1);
-
-               DEBUG_TRACE("style: %s : %s = %s", path, key, lua_tostring(L, 
-1));
-               lua_pop(L, 1);
-#endif
+               debug_style(L, path, key);
        }
 
        /* nil marker */
@@ -174,13 +187,40 @@
        }
        lua_pop(L, 1);
 
+       if (!lua_isnil(L, -1)) {
+               /* return skin value */
+               return 1;
+       }
+
+       /* per widget skin */
+       if (jive_getmethod(L, 1, "getWindow")) {
+               lua_pushvalue(L, 1);
+               lua_call(L, 1, 1);
+
+               if (!lua_isnil(L, -1)) {
+                       lua_getfield(L, -1, "skin");
+                       if (!lua_isnil(L, -1)) {
+                               lua_pushcfunction(L, jiveL_style_find_value);
+                               lua_pushvalue(L, 1); // widget
+                               lua_pushvalue(L, -3); // skin
+                               lua_pushvalue(L, pathidx);
+                               lua_pushvalue(L, 2); // key
+                               lua_call(L, 4, 1);
+
+                               if (!lua_isnil(L, -1)) {
+                                       debug_style(L, path, key);
+
+                                       return 1;
+                               }
+                               lua_pop(L, 1);
+                       }
+               }
+               lua_pop(L, 1);
+       }
+
        /* default value */
-       if (lua_isnil(L, -1)) {
-
-               lua_pop(L, 1);
-               lua_pushvalue(L, 3);
-
-       }
+       lua_pop(L, 1);
+       lua_pushvalue(L, 3);
 
        return 1;
 }

Modified: 
7.3/trunk/squeezeplay/src/squeezeplay_contrib/share/applets/Bounce/BounceApplet.lua
URL: 
http://svn.slimdevices.com/7.3/trunk/squeezeplay/src/squeezeplay_contrib/share/applets/Bounce/BounceApplet.lua?rev=3261&root=Jive&r1=3260&r2=3261&view=diff
==============================================================================
--- 
7.3/trunk/squeezeplay/src/squeezeplay_contrib/share/applets/Bounce/BounceApplet.lua
 (original)
+++ 
7.3/trunk/squeezeplay/src/squeezeplay_contrib/share/applets/Bounce/BounceApplet.lua
 Mon Nov  3 09:21:37 2008
@@ -98,6 +98,12 @@
        local window = Window("bounce")
        local w, h = Framework:getScreenSize()
 
+       window:setSkin({
+               bounce = {
+                       layout = Window.noLayout,
+               }
+       })
+
        self.sprits = {}
 
        -- squeezebox string
@@ -147,13 +153,6 @@
 end
 
 
--- applet skin
-function skin(self, s)
-       s.bounce = {}
-       s.bounce.layout = Window.noLayout
-end
-
-
 --[[
 
 =head1 LICENSE

Modified: 
7.3/trunk/squeezeplay/src/squeezeplay_contrib/share/applets/Bounce/BounceMeta.lua
URL: 
http://svn.slimdevices.com/7.3/trunk/squeezeplay/src/squeezeplay_contrib/share/applets/Bounce/BounceMeta.lua?rev=3261&root=Jive&r1=3260&r2=3261&view=diff
==============================================================================
--- 
7.3/trunk/squeezeplay/src/squeezeplay_contrib/share/applets/Bounce/BounceMeta.lua
 (original)
+++ 
7.3/trunk/squeezeplay/src/squeezeplay_contrib/share/applets/Bounce/BounceMeta.lua
 Mon Nov  3 09:21:37 2008
@@ -34,8 +34,6 @@
 end
 
 function registerApplet(self)
-       -- load our skin
-       jiveMain:loadSkin("Bounce", "skin")
 end
 
 function configureApplet(self)

Modified: 
7.3/trunk/squeezeplay/src/squeezeplay_contrib/share/applets/Snake/SnakeApplet.lua
URL: 
http://svn.slimdevices.com/7.3/trunk/squeezeplay/src/squeezeplay_contrib/share/applets/Snake/SnakeApplet.lua?rev=3261&root=Jive&r1=3260&r2=3261&view=diff
==============================================================================
--- 
7.3/trunk/squeezeplay/src/squeezeplay_contrib/share/applets/Snake/SnakeApplet.lua
 (original)
+++ 
7.3/trunk/squeezeplay/src/squeezeplay_contrib/share/applets/Snake/SnakeApplet.lua
 Mon Nov  3 09:21:37 2008
@@ -163,10 +163,6 @@
        -- draw red dots
        self:drawList(red_dots, 0xFF0000FF)
        self.bg:reDraw()
-end
-
-function skin(self, s)
-       s.snake.layout = Window.noLayout
 end
 
 function gameOver()

_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/cgi-bin/mailman/listinfo/jive-checkins

Reply via email to