Author: titmuss
Date: Mon Apr 28 06:04:51 2008
New Revision: 2375

URL: http://svn.slimdevices.com?rev=2375&root=Jive&view=rev
Log:
Bug: N/A
Description:
Prototyped a Button class, this can be used to make any widget (Icon, Label, 
Group, 
etc) into a Button. This only supports a Button click, other events like mouse 
over 
will need to be added.

Added a back link in the title bar.


Added:
    7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Button.lua
Modified:
    7.2/trunk/squeezeplay/src/squeezeplay/Makefile.am
    7.2/trunk/squeezeplay/src/squeezeplay/Makefile.in
    
7.2/trunk/squeezeplay/src/squeezeplay/share/applets/DefaultSkin/DefaultSkinApplet.lua
    
7.2/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua
    7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Group.lua
    7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Menu.lua
    7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Window.lua
    
7.2/trunk/squeezeplay/src/squeezeplay_desktop/share/applets/FullscreenSkin/FullscreenSkinApplet.lua

Modified: 7.2/trunk/squeezeplay/src/squeezeplay/Makefile.am
URL: 
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/squeezeplay/Makefile.am?rev=2375&root=Jive&r1=2374&r2=2375&view=diff
==============================================================================
--- 7.2/trunk/squeezeplay/src/squeezeplay/Makefile.am (original)
+++ 7.2/trunk/squeezeplay/src/squeezeplay/Makefile.am Mon Apr 28 06:04:51 2008
@@ -119,6 +119,7 @@
 jiveuidir = $(pkgdatadir)/jive/ui
 dist_jiveui_DATA = \
        share/jive/ui/Audio.lua \
+       share/jive/ui/Button.lua \
        share/jive/ui/Checkbox.lua \
        share/jive/ui/Choice.lua \
        share/jive/ui/Event.lua \
@@ -557,4 +558,5 @@
        share/applets/DefaultSkin/images/menu_album_selection_tr.png \
        share/applets/DefaultSkin/images/navcluster.png \
        share/applets/DefaultSkin/images/menu_check.png \
-       share/applets/DefaultSkin/images/menu_check_selected.png 
+       share/applets/DefaultSkin/images/menu_check_selected.png \
+       share/applets/DefaultSkin/images/selection_left.png 

Modified: 7.2/trunk/squeezeplay/src/squeezeplay/Makefile.in
URL: 
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/squeezeplay/Makefile.in?rev=2375&root=Jive&r1=2374&r2=2375&view=diff
==============================================================================
--- 7.2/trunk/squeezeplay/src/squeezeplay/Makefile.in (original)
+++ 7.2/trunk/squeezeplay/src/squeezeplay/Makefile.in Mon Apr 28 06:04:51 2008
@@ -415,6 +415,7 @@
 jiveuidir = $(pkgdatadir)/jive/ui
 dist_jiveui_DATA = \
        share/jive/ui/Audio.lua \
+       share/jive/ui/Button.lua \
        share/jive/ui/Checkbox.lua \
        share/jive/ui/Choice.lua \
        share/jive/ui/Event.lua \
@@ -855,7 +856,8 @@
        share/applets/DefaultSkin/images/menu_album_selection_tr.png \
        share/applets/DefaultSkin/images/navcluster.png \
        share/applets/DefaultSkin/images/menu_check.png \
-       share/applets/DefaultSkin/images/menu_check_selected.png 
+       share/applets/DefaultSkin/images/menu_check_selected.png \
+       share/applets/DefaultSkin/images/selection_left.png 
 
 all: $(BUILT_SOURCES)
        $(MAKE) $(AM_MAKEFLAGS) all-am

Modified: 
7.2/trunk/squeezeplay/src/squeezeplay/share/applets/DefaultSkin/DefaultSkinApplet.lua
URL: 
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/squeezeplay/share/applets/DefaultSkin/DefaultSkinApplet.lua?rev=2375&root=Jive&r1=2374&r2=2375&view=diff
==============================================================================
--- 
7.2/trunk/squeezeplay/src/squeezeplay/share/applets/DefaultSkin/DefaultSkinApplet.lua
 (original)
+++ 
7.2/trunk/squeezeplay/src/squeezeplay/share/applets/DefaultSkin/DefaultSkinApplet.lua
 Mon Apr 28 06:04:51 2008
@@ -332,11 +332,15 @@
        s.title.border = 4
        s.title.position = LAYOUT_NORTH
        s.title.bgImg = titleBox
+       s.title.order = { "back", "text" }
        s.title.text = {}
        s.title.text.padding = { 10, 8, 8, 8 }
        s.title.text.align = "top-left"
        s.title.text.font = FONT_BOLD_18px
        s.title.text.fg = SELECT_COLOR
+       s.title.back = {}
+       s.title.back.img = Surface:loadImage(imgpath .. "selection_left.png")
+       s.title.back.align = "left"
 
 
        -- Menu with three basic styles: normal, selected and locked
@@ -774,7 +778,7 @@
        s.albumtitle = {}
        s.albumtitle.position = LAYOUT_NORTH
        s.albumtitle.bgImg = titleBox
-       s.albumtitle.order = { "icon", "text" }
+       s.albumtitle.order = { "back", "icon", "text" }
        s.albumtitle.w = screenWidth
        s.albumtitle.h = 60
        s.albumtitle.border = 4
@@ -795,6 +799,9 @@
        s.albumtitle.icon.align = "left"
        s.albumtitle.icon.img = Surface:loadImage(imgpath .. 
"menu_album_noartwork.png")
        s.albumtitle.icon.padding = { 9, 0, 0, 0 }
+       s.albumtitle.back = {}
+       s.albumtitle.back.img = Surface:loadImage(imgpath .. 
"selection_left.png")
+       s.albumtitle.back.align = "left"
 
 
        -- titles with mini icons
@@ -810,7 +817,7 @@
        s.minititle.text.align    = 'top-left'
        s.minititle.text.font     = FONT_BOLD_18px
        s.minititle.text.fg       = SELECT_COLOR
-       s.minititle.order         = { "text", "icon" }
+       s.minititle.order         = { "back", "text", "icon" }
        s.minititle.icon = {}
        s.minititle.icon.padding  = { 0, 0, 8, 0 }
        s.minititle.icon.align    = 'right'

Modified: 
7.2/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua
URL: 
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua?rev=2375&root=Jive&r1=2374&r2=2375&view=diff
==============================================================================
--- 
7.2/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua
 (original)
+++ 
7.2/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua
 Mon Apr 28 06:04:51 2008
@@ -46,6 +46,7 @@
 local RadioButton            = require("jive.ui.RadioButton")
 local Checkbox               = require("jive.ui.Checkbox")
 local SimpleMenu             = require("jive.ui.SimpleMenu")
+local Button                 = require("jive.ui.Button")
 local DateTime               = require("jive.utils.datetime")
                              
 local DB                     = require("applets.SlimBrowser.DB")
@@ -312,7 +313,7 @@
        -- however it guarantees the icon in the title is not shared with (the 
same) icon in the menu.
 
        if not group then
-               group = Group("item", { text = Label("text", ""), icon = 
Icon("icon"), play = Icon("play") })
+               group = Group("item", { text = Label("text", ""), icon = 
Icon("icon"), play = Icon("play"), back = Button(Icon("back"), function() 
group:getWindow():dispatchNewEvent(EVENT_KEY_PRESS, KEY_BACK) return 
EVENT_CONSUME end) })
        end
 
        if item then

Added: 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Button.lua
URL: 
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Button.lua?rev=2375&root=Jive&view=auto
==============================================================================
--- 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Button.lua (added)
+++ 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Button.lua Mon Apr 28 
06:04:51 2008
@@ -1,0 +1,36 @@
+local _assert, pairs, string, tostring, type = _assert, pairs, string, 
tostring, type
+local getmetatable = getmetatable
+
+local oo                     = require("loop.base")
+
+local debug                  = require("jive.utils.debug")
+local log                    = require("jive.utils.log").logger("ui")
+
+
+local EVENT_MOUSE_ALL        = jive.ui.EVENT_MOUSE_ALL
+local EVENT_MOUSE_PRESS      = jive.ui.EVENT_MOUSE_PRESS
+
+local EVENT_CONSUME          = jive.ui.EVENT_CONSUME
+local EVENT_UNUSED           = jive.ui.EVENT_UNUSED
+
+
+module(...)
+oo.class(_M, oo.class)
+
+
+function __init(self, widget, action)
+       _assert(widget)
+
+       widget:addListener(EVENT_MOUSE_ALL,
+               function(event)
+                       local type = event:getType()
+
+                       if type == EVENT_MOUSE_PRESS then
+                               return action()
+                       end
+
+                       return EVENT_CONSUME
+               end)
+
+       return widget
+end

Modified: 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Group.lua
URL: 
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Group.lua?rev=2375&root=Jive&r1=2374&r2=2375&view=diff
==============================================================================
--- 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Group.lua (original)
+++ 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Group.lua Mon Apr 28 
06:04:51 2008
@@ -37,6 +37,7 @@
 local log               = require("jive.utils.log").logger("ui")
 
 local EVENT_ALL         = jive.ui.EVENT_ALL
+local EVENT_MOUSE_ALL   = jive.ui.EVENT_MOUSE_ALL
 local EVENT_UNUSED      = jive.ui.EVENT_UNUSED
 
 local EVENT_SHOW      = jive.ui.EVENT_SHOW
@@ -68,11 +69,14 @@
        -- forward events to contained widgets
        obj:addListener(EVENT_ALL,
                         function(event)
+                                local notMouse = (event:getType() & 
EVENT_MOUSE_ALL) == 0
+
                                 for _,widget in pairs(obj.widgets) do
-                                        local r = widget:_event(event)
-
-                                        if r ~= EVENT_UNUSED then
-                                                return r
+                                        if notMouse or 
widget:mouseInside(event) then
+                                                local r = widget:_event(event)
+                                                if r ~= EVENT_UNUSED then
+                                                        return r
+                                                end
                                         end
                                 end
                                 return EVENT_UNUSED

Modified: 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Menu.lua
URL: 
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Menu.lua?rev=2375&root=Jive&r1=2374&r2=2375&view=diff
==============================================================================
--- 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Menu.lua (original)
+++ 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Menu.lua Mon Apr 28 
06:04:51 2008
@@ -448,7 +448,7 @@
 function setSelectedIndex(self, index)
        _assert(type(index) == "number", "setSelectedIndex index is not a 
number")
 
-       if index <= self.listSize then
+       if index >= 1 and index <= self.listSize then
                self.selected = index
                self:reLayout()
        end

Modified: 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Window.lua
URL: 
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Window.lua?rev=2375&root=Jive&r1=2374&r2=2375&view=diff
==============================================================================
--- 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Window.lua (original)
+++ 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Window.lua Mon Apr 28 
06:04:51 2008
@@ -42,6 +42,7 @@
 local oo                      = require("loop.simple")
 local table                   = require("jive.utils.table")
 local SimpleMenu              = require("jive.ui.SimpleMenu")
+local Button                  = require("jive.ui.Button")
 local Group                   = require("jive.ui.Group")
 local Label                   = require("jive.ui.Label")
 local Icon                    = require("jive.ui.Icon")
@@ -70,6 +71,8 @@
 local EVENT_CONSUME           = jive.ui.EVENT_CONSUME
 local EVENT_UNUSED            = jive.ui.EVENT_UNUSED
 
+local KEY_BACK                = jive.ui.KEY_BACK
+
 local FRAME_RATE              = jive.ui.FRAME_RATE
 local LAYER_ALL               = jive.ui.LAYER_ALL
 local LAYER_CONTENT           = jive.ui.LAYER_CONTENT
@@ -121,7 +124,7 @@
        obj._DEFAULT_HIDE_TRANSITION = transitionPushRight
 
        if titleStyle then
-               obj:setTitleWidget(Group(titleStyle, { text = Label("text", 
title), icon = Icon("icon") }))
+               obj:setTitleWidget(Group(titleStyle, { text = Label("text", 
title), icon = Icon("icon"), back = Button(Icon("back"), function() 
obj:dispatchNewEvent(EVENT_KEY_PRESS, KEY_BACK) return EVENT_CONSUME end) }))
        elseif title then
                obj:setTitle(title)
        end
@@ -470,7 +473,7 @@
        if self.title then
                self.title:setWidgetValue("text", title)
        else
-               self.title = Group("title", { text = Label("text", title), icon 
= Icon("icon") })
+               self.title = Group("title", { text = Label("text", title), icon 
= Icon("icon"), back = Button(Icon("back"), function() 
self:dispatchNewEvent(EVENT_KEY_PRESS, KEY_BACK) return EVENT_CONSUME end) })
                self:_addWidget(self.title)
                self.title:_event(Event:new(EVENT_FOCUS_GAINED))
        end

Modified: 
7.2/trunk/squeezeplay/src/squeezeplay_desktop/share/applets/FullscreenSkin/FullscreenSkinApplet.lua
URL: 
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/squeezeplay_desktop/share/applets/FullscreenSkin/FullscreenSkinApplet.lua?rev=2375&root=Jive&r1=2374&r2=2375&view=diff
==============================================================================
--- 
7.2/trunk/squeezeplay/src/squeezeplay_desktop/share/applets/FullscreenSkin/FullscreenSkinApplet.lua
 (original)
+++ 
7.2/trunk/squeezeplay/src/squeezeplay_desktop/share/applets/FullscreenSkin/FullscreenSkinApplet.lua
 Mon Apr 28 06:04:51 2008
@@ -357,12 +357,18 @@
        s.title.padding = { 15, 5, 10, 0 }
        s.title.position = LAYOUT_NORTH
        s.title.bgImg = titleBox
+       s.title.order = { "back", "text" }
        s.title.text = {}
         s.title.text.w = WH_FILL
        s.title.text.padding = TITLE_PADDING
        s.title.text.align = "top-left"
        s.title.text.font = _boldfont(TITLE_FONT_SIZE)
        s.title.text.fg = TEXT_COLOR_BLACK
+       s.title.back = {}
+       s.title.back.img = Surface:loadImage(imgpath .. 
"pointer_selector_L.png")
+       s.title.back.align = "left"
+
+
 
        -- Menu with three basic styles: normal, selected and locked
        -- First define the dimesions of the menu
@@ -775,7 +781,7 @@
        s.albumtitle = {}
        s.albumtitle.position = LAYOUT_NORTH
        s.albumtitle.bgImg = titleBox
-       s.albumtitle.order = { "icon", "text" }
+       s.albumtitle.order = { "back", "icon", "text" }
        s.albumtitle.w = screenWidth
        s.albumtitle.h = 130
        s.albumtitle.border = 4
@@ -796,6 +802,9 @@
        s.albumtitle.icon.align = "left"
        s.albumtitle.icon.img = Surface:loadImage(imgpath .. 
"menu_album_noartwork_125.png")
        s.albumtitle.icon.padding = { 9, 0, 0, 0 }
+       s.albumtitle.back = {}
+       s.albumtitle.back.img = Surface:loadImage(imgpath .. 
"pointer_selector_L.png")
+       s.albumtitle.back.align = "left"
 
 
        -- titles with mini icons
@@ -812,7 +821,7 @@
        s.minititle.text.align    = 'top-left'
        s.minititle.text.font     = _boldfont(TITLE_FONT_SIZE)
        s.minititle.text.fg       = TEXT_COLOR_BLACK
-       s.minititle.order         = { "text", "icon" }
+       s.minititle.order         = { "back", "text", "icon" }
        s.minititle.icon = {}
        s.minititle.icon.padding  = { 0, 0, 8, 0 }
        s.minititle.icon.align    = 'right'
@@ -1061,7 +1070,7 @@
        s.nowplayingtitle = {}
        s.nowplayingtitle.position = LAYOUT_NORTH
        s.nowplayingtitle.bgImg = titleBox
-       s.nowplayingtitle.order = { "text", "icon" }
+       s.nowplayingtitle.order = { "back", "text", "icon" }
        s.nowplayingtitle.w = screenWidth
        s.nowplayingtitle.h = 70
        s.nowplayingtitle.border = 4

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

Reply via email to