Author: tom
Date: Wed Feb 18 15:18:57 2009
New Revision: 4292

URL: http://svn.slimdevices.com/jive?rev=4292&view=rev
Log:
Bug: N/A
Description:
- Button now support holdAction
- upper left back button does "go_home" for button holdAction
- Action changes- added go_home_or_now_playing, now the old go_home, just goes 
home. The new go_home_or_now_playing does the old behavior (toggling between 
home and NP). go_home_or_now_playing is only used on the controller when 
hitting the home button. (request from Dean, though not sure what he intended 
for hitting IR home)

Modified:
    
7.4/trunk/squeezeplay/src/squeezeplay/share/applets/NowPlaying/NowPlayingApplet.lua
    
7.4/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua
    7.4/trunk/squeezeplay/src/squeezeplay/share/jive/InputToActionMap.lua
    7.4/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Button.lua
    7.4/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Window.lua

Modified: 
7.4/trunk/squeezeplay/src/squeezeplay/share/applets/NowPlaying/NowPlayingApplet.lua
URL: 
http://svn.slimdevices.com/jive/7.4/trunk/squeezeplay/src/squeezeplay/share/applets/NowPlaying/NowPlayingApplet.lua?rev=4292&r1=4291&r2=4292&view=diff
==============================================================================
--- 
7.4/trunk/squeezeplay/src/squeezeplay/share/applets/NowPlaying/NowPlayingApplet.lua
 (original)
+++ 
7.4/trunk/squeezeplay/src/squeezeplay/share/applets/NowPlaying/NowPlayingApplet.lua
 Wed Feb 18 15:18:57 2009
@@ -493,6 +493,10 @@
                                function() 
                                        Framework:pushAction("back")
                                        return EVENT_CONSUME 
+                                       end,
+                                       function()
+                                               Framework:pushAction("go_home")
+                                               return EVENT_CONSUME
                                end
                ),
 

Modified: 
7.4/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua
URL: 
http://svn.slimdevices.com/jive/7.4/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua?rev=4292&r1=4291&r2=4292&view=diff
==============================================================================
--- 
7.4/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua
 (original)
+++ 
7.4/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua
 Wed Feb 18 15:18:57 2009
@@ -419,6 +419,10 @@
                                function()
                                        Framework:pushAction("back")
 
+                                       return EVENT_CONSUME
+                               end,
+                               function()
+                                       Framework:pushAction("go_home")
                                        return EVENT_CONSUME
                                end
                        ), 
@@ -1054,6 +1058,10 @@
                                                                        
Framework:pushAction("back")
 
                                                                        return 
EVENT_CONSUME
+                                                               end,
+                                                               function()
+                                                                       
Framework:pushAction("go_home")
+                                                                       return 
EVENT_CONSUME
                                                                end
                                                        ), 
                                                        nowplaying = Button(
@@ -1453,7 +1461,7 @@
        ["play_favorite_8"] = _goPlayFavoriteAction,
        ["play_favorite_9"] = _goPlayFavoriteAction,
        
-       ["go_home"] = function()
+       ["go_home_or_now_playing"] = function()
                local windowStack = Framework.windowStack
 
                -- are we in home?
@@ -1463,6 +1471,11 @@
                        _goNow('nowPlaying', Window.transitionPushLeft)
                end
 
+               return EVENT_CONSUME
+       end,
+
+       ["go_home"] = function()
+               _goNow('home')
                return EVENT_CONSUME
        end,
 
@@ -1765,8 +1778,8 @@
 
 -- map from a key to an actionName
 local _actionToActionName = {
-       ["go_home"] = 'home',
-       ["pause"]   = 'pause', 
+       ["go_home_or_now_playing"] = 'home',
+       ["pause"]   = 'pause',
        ["stop"]   = 'pause-hold',
        ["play"]    = 'play',
        ["custom_mix"]    = 'play-hold',

Modified: 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/InputToActionMap.lua
URL: 
http://svn.slimdevices.com/jive/7.4/trunk/squeezeplay/src/squeezeplay/share/jive/InputToActionMap.lua?rev=4292&r1=4291&r2=4292&view=diff
==============================================================================
--- 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/InputToActionMap.lua 
(original)
+++ 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/InputToActionMap.lua Wed 
Feb 18 15:18:57 2009
@@ -23,7 +23,7 @@
 
        ["/"]   = "go_search",
        ["h"]   = "go_home",
-       ["J"]   = "go_home",
+       ["J"]   = "go_home_or_now_playing",
        ["D"]   = "disconnect_player",
        ["x"]   = "play",
        ["p"]   = "play",
@@ -64,7 +64,7 @@
 
 keyActionMappings = {}
 keyActionMappings.press = {
-       [KEY_HOME] = "go_home",
+       [KEY_HOME] = "go_home_or_now_playing",
        [KEY_PLAY] = "play",
        [KEY_ADD] = "add",
        [KEY_BACK] = "back",

Modified: 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Button.lua
URL: 
http://svn.slimdevices.com/jive/7.4/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Button.lua?rev=4292&r1=4291&r2=4292&view=diff
==============================================================================
--- 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Button.lua (original)
+++ 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Button.lua Wed Feb 18 
15:18:57 2009
@@ -2,6 +2,7 @@
 local getmetatable = getmetatable
 
 local oo                     = require("loop.base")
+local Timer                  = require("jive.ui.Timer")
 
 local debug                  = require("jive.utils.debug")
 local log                    = require("jive.utils.log").logger("ui")
@@ -20,12 +21,30 @@
 
 local BUFFER_DISTANCE = 75
 
+local HOLD_TIMEOUT = 1000
+
 module(...)
 oo.class(_M, oo.class)
 
 
-function __init(self, widget, action)
+function __init(self, widget, action, holdAction)
        _assert(widget)
+
+       --A mouse sequence is a full down,activity,up sequence - false during 
down,activity and true on up
+       widget.mouseSequenceComplete = true
+
+       -- holdAction will be called if the mouse is down and not dragged for 
HOLD_TIMEOUT millis.
+       if holdAction then
+               widget.holdTimer = Timer(HOLD_TIMEOUT,
+                       function ()
+                               widget:setStyleModifier(nil)
+                               widget:reDraw()
+
+                               widget.mouseSequenceComplete = true
+                               holdAction()
+                       end,
+                       true)
+       end
 
        widget:addListener(EVENT_MOUSE_ALL,
                function(event)
@@ -34,41 +53,58 @@
                        if type == EVENT_MOUSE_DOWN then
                                --uncomment when pressed changes are merged
 --                             widget:setStyleModifier("pressed")
+                               if widget.holdTimer then
+                                       widget.holdTimer:restart()
+                               end
+                               widget.mouseSequenceComplete = false
+
                                widget:reDraw()
                                return EVENT_CONSUME
                        end
 
                        if type == EVENT_MOUSE_UP then
+                               if widget.holdTimer then
+                                       widget.holdTimer:stop()
+                               end
+                               
                                widget:setStyleModifier(nil)
                                widget:reDraw()
 
-                               if mouseInsideBufferDistance(widget, event) then
-                                       return action()
+                               if not widget.mouseSequenceComplete then
+                                       widget.mouseSequenceComplete = true
+                                       if mouseInsideBufferDistance(widget, 
event) then
+                                               if action then
+                                                       return action()
+                                               end
+                                       end
                                end
                                --else nothing (i.e. cancel)
                                return EVENT_CONSUME
                        end
 
                        if type == EVENT_MOUSE_DRAG then
-
-                               if mouseInsideBufferDistance(widget, event) then
-                                       --uncomment when pressed changes are 
merged
---                                     widget:setStyleModifier("pressed")
-                                       widget:reDraw()
-                               else
-                                       widget:setStyleModifier(nil)
-                                       widget:reDraw()
+                               --eliminating hold after a drag is similar to 
typical desktop behavior, plus it's
+                                -- very tricky to have hold triggered after a 
drag, when "hold outside of the bounds" is factored in
+                               if widget.holdTimer then
+                                       widget.holdTimer:stop()
                                end
 
+                               if not widget.mouseSequenceComplete then
+                                       if mouseInsideBufferDistance(widget, 
event) then
+                                               --uncomment when pressed 
changes are merged
+       --                                      
widget:setStyleModifier("pressed")
+                                               widget:reDraw()
+                                       else
+                                               --dragging outside of buffer 
distance, change pressed style to normal
+                                               widget:setStyleModifier(nil)
+                                               widget:reDraw()
+                                       end
+                               end
+                               
                                return EVENT_CONSUME
                        end
 
-                       if type == EVENT_MOUSE_PRESS then
-                               --only ever respond to the up, since it manages 
the response now
-                               return EVENT_CONSUME
-                       end
-
-                       --todo handle hold - will probably need a passed in 
holdAction or pass back the state to action()
+                       -- press and hold consumed - only ever respond to the 
up (or hold timer), since they manages the response now
 
                        return EVENT_CONSUME
                end)

Modified: 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Window.lua
URL: 
http://svn.slimdevices.com/jive/7.4/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Window.lua?rev=4292&r1=4291&r2=4292&view=diff
==============================================================================
--- 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Window.lua (original)
+++ 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Window.lua Wed Feb 18 
15:18:57 2009
@@ -162,6 +162,10 @@
                                        function() 
                                                Framework:pushAction("back")
                                                return EVENT_CONSUME
+                                       end,
+                                       function()
+                                               Framework:pushAction("go_home")
+                                               return EVENT_CONSUME
                                        end
                                ), 
                                nowplaying = Button(
@@ -699,7 +703,8 @@
                                        { text = Label("text", title),
                                        icon = Icon("icon"),
                                        back = Button(Icon("back"), 
-                                               Framework:pushAction("back"))
+                                               Framework:pushAction("back"),
+                                               Framework:pushAction("go_home"))
                                        })
                self:_addWidget(self.title)
                self.title:_event(Event:new(EVENT_FOCUS_GAINED))

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

Reply via email to