Author: titmuss
Date: Mon Jan 14 02:51:35 2008
New Revision: 1426

URL: http://svn.slimdevices.com?rev=1426&root=Jive&view=rev
Log:
Bug: 5387
Description:
Fix behaviour of popup windows. This adds some new properites to the Window:
- setAlwaysOnTop() to force this window to the top of the window stack.
- setShowFrameworkWidgets() to enable/disable rendering of global widgets.
- setTransparent() to allows the lower window to be active and redrawn.

Redefined Popup windows to, by default, not allow screensavers, always be on 
top, auto 
hide, not show global widgets and to be transparent.

This corrects the behaviour of popup widgets, and in particular fixes a 
rendering problem 
when using transparent popups. This does not yet correctly render window 
transitions 
while popups are visible.


Modified:
    trunk/jive/src/pkg/jive/share/jive/slim/Player.lua
    trunk/jive/src/pkg/jive/share/jive/ui/Popup.lua
    trunk/jive/src/pkg/jive/share/jive/ui/Window.lua
    trunk/jive/src/pkg/jive/src/ui/jive.h
    trunk/jive/src/pkg/jive/src/ui/jive_framework.c
    trunk/jive/src/pkg/jive/src/ui/jive_window.c

Modified: trunk/jive/src/pkg/jive/share/jive/slim/Player.lua
URL: 
http://svn.slimdevices.com/trunk/jive/src/pkg/jive/share/jive/slim/Player.lua?rev=1426&root=Jive&r1=1425&r2=1426&view=diff
==============================================================================
--- trunk/jive/src/pkg/jive/share/jive/slim/Player.lua (original)
+++ trunk/jive/src/pkg/jive/share/jive/slim/Player.lua Mon Jan 14 02:51:35 2008
@@ -479,6 +479,7 @@
 
        -- create window to display current song info
        self.currentSong.window = Popup("currentsong")
+       self.currentSong.window:setAllowScreensaver(true)
        self.currentSong.artIcon = Icon("icon")
        self.currentSong.text = Label("text", "")
 
@@ -568,21 +569,6 @@
 end
 
 
-function _showCurrentSong(self, text, iconId)
-       log:debug("Player:showCurrentSong()")
-
-       local s = self.currentSong
-
-       if iconId then
-               self.slimServer:fetchArtworkThumb(iconId, s.artIcon, 
artworkThumbUri, nil)
-       end
-
-       s.text:setValue(text)
-
-       s.window:showBriefly(3000, nil, Window.transitionPushPopupUp, 
Window.transitionPushPopupDown)
-end
-
-
 -- _process_displaystatus
 -- receives the display status data
 function _process_displaystatus(self, event)
@@ -594,20 +580,20 @@
                local display = data.display
                local type    = display["type"] or 'text'
 
+               local s = self.currentSong
+
                if type == 'song' then
                        -- new song display from server
-                       self:_showCurrentSong(table.concat(display["text"], 
"\n"), display["icon-id"])
-               elseif type == 'popupplay' then
-                       -- playing display from server for artist/genre/year 
etc - no artwork 
-                       local popup = Popup("popupplay")
-                       popup:addWidget(Label("text", 
table.concat(display["text"], "\n")))
-                       popup:showBriefly(3000, nil, 
Window.transitionPushPopupUp, Window.transitionPushPopupDown)
+                       s.text:setValue(table.concat(display["text"], "\n"))
+                       s.artIcon:setStyle("icon")
+                       self.slimServer:fetchArtworkThumb(display["icon-id"], 
s.artIcon, artworkThumbUri, nil)
                else
-                       -- other message from server
-                       local popup = Popup("popupinfo")
-                       popup:addWidget(Label("text", 
table.concat(display["text"], "\n")))
-                       popup:showBriefly(3000, nil, 
Window.transitionPushPopupUp, Window.transitionPushPopupDown)
+                       s.text:setValue(table.concat(display["text"], "\n"))
+                       s.artIcon:setStyle("noimage")
+                       s.artIcon:setValue(nil)
                end
+
+               s.window:showBriefly(3000, nil, Window.transitionPushPopupUp, 
Window.transitionPushPopupDown)
        end
 end
 

Modified: trunk/jive/src/pkg/jive/share/jive/ui/Popup.lua
URL: 
http://svn.slimdevices.com/trunk/jive/src/pkg/jive/share/jive/ui/Popup.lua?rev=1426&root=Jive&r1=1425&r2=1426&view=diff
==============================================================================
--- trunk/jive/src/pkg/jive/share/jive/ui/Popup.lua (original)
+++ trunk/jive/src/pkg/jive/share/jive/ui/Popup.lua Mon Jan 14 02:51:35 2008
@@ -60,8 +60,11 @@
        obj._DEFAULT_SHOW_TRANSITION = Window.transitionNone
        obj._DEFAULT_HIDE_TRANSITION = Window.transitionNone
 
-       obj:autoHide(true)
        obj:setAllowScreensaver(false)
+       obj:setAlwaysOnTop(true)
+       obj:setAutoHide(true)
+       obj:setShowFrameworkWidgets(false)
+       obj:setTransparent(true)
 
        -- by default close popup on keypress
        obj:addListener(EVENT_KEY_PRESS,

Modified: trunk/jive/src/pkg/jive/share/jive/ui/Window.lua
URL: 
http://svn.slimdevices.com/trunk/jive/src/pkg/jive/share/jive/ui/Window.lua?rev=1426&root=Jive&r1=1425&r2=1426&view=diff
==============================================================================
--- trunk/jive/src/pkg/jive/share/jive/ui/Window.lua (original)
+++ trunk/jive/src/pkg/jive/share/jive/ui/Window.lua Mon Jan 14 02:51:35 2008
@@ -107,6 +107,12 @@
 
        local obj = oo.rawnew(self, Widget(style))
 
+       obj.allowScreensaver = true
+       obj.alwaysOnTop = false
+       obj.autoHide = false
+       obj.showFrameworkWidgets = true
+       obj.transparent = false
+
        obj.widgets = {} -- child widgets
        obj.layoutRoot = true
        obj.focus = nil
@@ -140,7 +146,12 @@
 function show(self, transition)
        local stack = Framework.windowStack
 
-       local topwindow = stack[1]
+       local idx = 1
+       local topwindow = stack[idx]
+       while topwindow and topwindow.alwaysOnTop do
+               idx = idx + 1
+               topwindow = stack[idx]
+       end
 
        if topwindow == self then
                -- we're already on top
@@ -162,23 +173,25 @@
        self:dispatchNewEvent(EVENT_SHOW)
 
        -- insert the window in the window stack
-       table.insert(stack, 1, self)
+       table.insert(stack, idx, self)
 
        if topwindow then
                -- push transitions
                transition = transition or self._DEFAULT_SHOW_TRANSITION
                Framework:_startTransition(transition(topwindow, self))
 
-               -- the old window and widgets are no longer visible
-               topwindow:dispatchNewEvent(EVENT_HIDE)
-
-               -- the old window is inactive
-               topwindow:dispatchNewEvent(EVENT_WINDOW_INACTIVE)
+               if not self.transparent then
+                       -- the old window and widgets are no longer visible
+                       topwindow:dispatchNewEvent(EVENT_HIDE)
+
+                       -- the old window is inactive
+                       topwindow:dispatchNewEvent(EVENT_WINDOW_INACTIVE)
+               end
        end
 
        -- hide windows with autoHide enabled
-       while stack[2] ~= nil and stack[2]._autoHide do
-               stack[2]:hide()
+       while stack[idx + 1] ~= nil and stack[idx + 1].autoHide do
+               stack[idx + 1]:hide()
        end
 
        Framework:reDraw(nil)
@@ -351,8 +364,8 @@
 
 ==cut
 --]]
-function autoHide(self, enabled)
-       self._autoHide = enabled and true or nil
+function setAutoHide(self, enabled)
+       self.autoHide = enabled and true or nil
 end
 
 
@@ -548,6 +561,7 @@
        _assert(type(allowScreensaver) == "boolean" or type(allowScreensaver) 
== "function")
 
        self.allowScreensaver = allowScreensaver
+       -- FIXME disable screensaver if active?
 end
 
 
@@ -559,6 +573,30 @@
        else
                return self.allowScreensaver
        end
+end
+
+
+function setAlwaysOnTop(self, alwaysOnTop)
+       _assert(type(alwaysOnTop) == "boolean")
+
+       self.alwaysOnTop = alwaysOnTop
+       -- FIXME modify window position if already shown?
+end
+
+
+function setShowFrameworkWidgets(self, showFrameworkWidgets)
+       _assert(type(showFrameworkWidgets) == "boolean")
+
+       self.showFrameworkWidgets = showFrameworkWidgets
+       self:reLayout()
+end
+
+
+function setTransparent(self, transparent)
+       _assert(type(transparent) == "boolean")
+
+       self.transparent = transparent
+       self:reLayout()
 end
 
 

Modified: trunk/jive/src/pkg/jive/src/ui/jive.h
URL: 
http://svn.slimdevices.com/trunk/jive/src/pkg/jive/src/ui/jive.h?rev=1426&root=Jive&r1=1425&r2=1426&view=diff
==============================================================================
--- trunk/jive/src/pkg/jive/src/ui/jive.h (original)
+++ trunk/jive/src/pkg/jive/src/ui/jive.h Mon Jan 14 02:51:35 2008
@@ -434,11 +434,9 @@
 
 int jiveL_window_skin(lua_State *L);
 int jiveL_window_check_layout(lua_State *L);
-int jiveL_popup_check_layout(lua_State *L);
 int jiveL_window_iterate(lua_State *L);
-int jiveL_popup_iterate(lua_State *L);
+int jiveL_window_draw_or_transition(lua_State *L);
 int jiveL_window_draw(lua_State *L);
-int jiveL_popup_draw(lua_State *L);
 int jiveL_window_event_handler(lua_State *L);
 int jiveL_window_gc(lua_State *L);
 

Modified: trunk/jive/src/pkg/jive/src/ui/jive_framework.c
URL: 
http://svn.slimdevices.com/trunk/jive/src/pkg/jive/src/ui/jive_framework.c?rev=1426&root=Jive&r1=1425&r2=1426&view=diff
==============================================================================
--- trunk/jive/src/pkg/jive/src/ui/jive_framework.c (original)
+++ trunk/jive/src/pkg/jive/src/ui/jive_framework.c Mon Jan 14 02:51:35 2008
@@ -1184,15 +1184,6 @@
        { NULL, NULL }
 };
 
-static const struct luaL_Reg popup_methods[] = {
-       { "_skin", jiveL_window_skin },
-       { "checkLayout", jiveL_popup_check_layout },
-       { "iterate", jiveL_popup_iterate },
-       { "draw", jiveL_popup_draw },
-       { "_eventHandler", jiveL_window_event_handler },
-       { NULL, NULL }
-};
-
 static const struct luaL_Reg timer_methods[] = {
        { "start", jiveL_timer_add_timer },
        { "stop", jiveL_timer_remove_timer },
@@ -1277,10 +1268,6 @@
        luaL_register(L, NULL, window_methods);
        lua_pop(L, 1);
 
-       lua_getfield(L, 2, "Popup");
-       luaL_register(L, NULL, popup_methods);
-       lua_pop(L, 1);
-
        lua_getfield(L, 2, "Slider");
        luaL_register(L, NULL, slider_methods);
        lua_pop(L, 1);

Modified: trunk/jive/src/pkg/jive/src/ui/jive_window.c
URL: 
http://svn.slimdevices.com/trunk/jive/src/pkg/jive/src/ui/jive_window.c?rev=1426&root=Jive&r1=1425&r2=1426&view=diff
==============================================================================
--- trunk/jive/src/pkg/jive/src/ui/jive_window.c (original)
+++ trunk/jive/src/pkg/jive/src/ui/jive_window.c Mon Jan 14 02:51:35 2008
@@ -75,6 +75,20 @@
         */
 
        WindowWidget *peer = jive_getpeer(L, 1, &windowPeerMeta);
+
+       lua_getfield(L, 1, "transparent");
+       if (lua_toboolean(L, -1) && jive_getmethod(L, 1, "getLowerWindow")) {
+               /* if transparent drawn lower window first */
+               lua_pushvalue(L, 1);
+               lua_call(L, 1, 1);
+
+               if (!lua_isnil(L, -1)) {
+                       lua_pushcfunction(L, jiveL_window_check_layout);
+                       lua_pushvalue(L, -2);
+                       lua_call(L, 1, 0);
+               }
+       }
+       lua_pop(L, 1);
 
        if (peer->w.child_origin != jive_origin) {
 #if 0
@@ -110,44 +124,29 @@
        return 0;
 }
 
-int jiveL_popup_check_layout(lua_State *L) {
-       /* stack is:
-        * 1: widget
-        */
-
-       if (jive_getmethod(L, 1, "getLowerWindow")) {
-               lua_pushvalue(L, 1);
-               lua_call(L, 1, 1);
-
-               if (!lua_isnil(L, -1)) {
-                       lua_pushcfunction(L, jiveL_window_check_layout);
+
+int jiveL_window_iterate(lua_State *L) {
+       /* stack is:
+        * 1: widget
+        * 2: closure
+        */
+
+       lua_getfield(L, 1, "showFrameworkWidgets");
+       if (lua_toboolean(L, -1)) {
+               // global widgets
+               jiveL_getframework(L);
+               lua_getfield(L, -1, "widgets");
+               lua_pushnil(L);
+               while (lua_next(L, -2) != 0) {
+                       lua_pushvalue(L, 2);
                        lua_pushvalue(L, -2);
                        lua_call(L, 1, 0);
-               }
-       }
-
-       return jiveL_window_check_layout(L);
-}
-
-
-int jiveL_window_iterate(lua_State *L) {
-       /* stack is:
-        * 1: widget
-        * 2: closure
-        */
-
-       // global widgets
-       jiveL_getframework(L);
-       lua_getfield(L, -1, "widgets");
-       lua_pushnil(L);
-       while (lua_next(L, -2) != 0) {
-               lua_pushvalue(L, 2);
-               lua_pushvalue(L, -2);
-               lua_call(L, 1, 0);
-
-               lua_pop(L, 1);
-       }
-       lua_pop(L, 2);
+                       
+                       lua_pop(L, 1);
+               }
+               lua_pop(L, 2);
+       }
+       lua_pop(L, 1);
 
        // window widgets
        lua_getfield(L, 1, "widgets");
@@ -165,28 +164,6 @@
 }
 
 
-int jiveL_popup_iterate(lua_State *L) {
-       /* stack is:
-        * 1: widget
-        * 2: closure
-        */
-
-       // window widgets
-       lua_getfield(L, 1, "widgets");
-       lua_pushnil(L);
-       while (lua_next(L, -2) != 0) {
-               lua_pushvalue(L, 2);
-               lua_pushvalue(L, -2);
-               lua_call(L, 1, 0);
-
-               lua_pop(L, 1);
-       }
-       lua_pop(L, 1);
-
-       return 0;
-}
-
-
 static int draw_closure(lua_State *L) {
        Uint32 t0 = 0, t1 = 0;
 
@@ -226,40 +203,9 @@
        JiveSurface *srf = tolua_tousertype(L, 2, 0);
        Uint32 layer = luaL_optinteger(L, 3, JIVE_LAYER_ALL);
 
-       /* window background */
-       if ((layer & peer->w.layer) && peer->bg_tile) {
-               jive_tile_blit(peer->bg_tile, srf, peer->w.bounds.x, 
peer->w.bounds.y, peer->w.bounds.w, peer->w.bounds.h);
-       }
-
-       /* draw widgets */
-       if (jive_getmethod(L, 1, "iterate")) {
-               lua_pushvalue(L, 1); // widget
-
-               lua_pushvalue(L, 2); // surface
-               lua_pushvalue(L, 3); // layer
-               lua_pushcclosure(L, draw_closure, 2);
-
-               lua_call(L, 2, 0);
-       }
-
-       return 0;
-}
-
-
-int jiveL_popup_draw(lua_State *L) {
-
-       /* stack is:
-        * 1: widget
-        * 2: surface
-        * 3: layer
-        */
-
-       WindowWidget *peer = jive_getpeer(L, 1, &windowPeerMeta);
-       JiveSurface *srf = tolua_tousertype(L, 2, 0);
-       Uint32 layer = luaL_optinteger(L, 3, JIVE_LAYER_ALL);
-
-       /* draw underneath a popup */
-       if (layer & JIVE_LAYER_FRAME) {
+       lua_getfield(L, 1, "transparent");
+       if (lua_toboolean(L, -1) && (layer & JIVE_LAYER_FRAME)) {
+               /* draw underneath a popup */
                if (jive_getmethod(L, 1, "getLowerWindow")) {
                        lua_pushvalue(L, 1);
                        lua_call(L, 1, 1);
@@ -288,9 +234,27 @@
                        lua_pop(L, 1);
                }
        }
-
-       return jiveL_window_draw(L);
-}
+       lua_pop(L, 1);
+
+       /* window background */
+       if ((layer & peer->w.layer) && peer->bg_tile) {
+               jive_tile_blit(peer->bg_tile, srf, peer->w.bounds.x, 
peer->w.bounds.y, peer->w.bounds.w, peer->w.bounds.h);
+       }
+
+       /* draw widgets */
+       if (jive_getmethod(L, 1, "iterate")) {
+               lua_pushvalue(L, 1); // widget
+
+               lua_pushvalue(L, 2); // surface
+               lua_pushvalue(L, 3); // layer
+               lua_pushcclosure(L, draw_closure, 2);
+
+               lua_call(L, 2, 0);
+       }
+
+       return 0;
+}
+
 
 static int do_array_event(lua_State *L) {
        int r = 0;

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

Reply via email to