Index: squeezeplay/src/ui/jive_widget.c =================================================================== --- squeezeplay/src/ui/jive_widget.c (revision 8588) +++ squeezeplay/src/ui/jive_widget.c (working copy) @@ -354,6 +354,7 @@ int jiveL_widget_redraw(lua_State *L) { JiveWidget *peer; + int offset = 0; /* stack is: * 1: widget @@ -365,7 +366,25 @@ peer = lua_touserdata(L, -1); if (peer) { - jive_redraw(&peer->bounds); + /* if the widget is inside a menu using smooth scrolling, find the offset + * and use it to adjust the dirty region reported by the widget */ + lua_getfield(L, 1, "smoothscroll"); + if (lua_istable(L, -1)) { + lua_getfield(L, -1, "pixelOffsetY"); + offset = lua_tointeger(L, -1); + lua_pop(L, 2); + } else { + lua_pop(L, 1); + } + + if (!offset) { + jive_redraw(&peer->bounds); + } else { + SDL_Rect r; + memcpy(&r, &peer->bounds, sizeof(r)); + r.y += offset; + jive_redraw(&r); + } } lua_pop(L, 1); Index: squeezeplay/src/ui/jive_framework.c =================================================================== --- squeezeplay/src/ui/jive_framework.c (revision 8588) +++ squeezeplay/src/ui/jive_framework.c (working copy) @@ -544,6 +544,12 @@ lua_call(L, 3, 0); } +#if 0 + // show the dirty region for debug purposes: + jive_surface_rectangleColor(srf, jive_dirty_region.x, jive_dirty_region.y, + jive_dirty_region.x + jive_dirty_region.w, jive_dirty_region.y + jive_dirty_region.h, 0xFFFFFFFF); +#endif + /* clear the dirty region for non standalone draws */ if (!standalone_draw) { memcpy(&last_dirty_region, &jive_dirty_region, sizeof(last_dirty_region)); Index: squeezeplay/share/jive/ui/Menu.lua =================================================================== --- squeezeplay/share/jive/ui/Menu.lua (revision 8588) +++ squeezeplay/share/jive/ui/Menu.lua (working copy) @@ -48,6 +48,7 @@ local NumberLetterAccel = require("jive.ui.NumberLetterAccel") local Flick = require("jive.ui.Flick") local Timer = require("jive.ui.Timer") +local System = require("jive.System") local log = require("jive.utils.log").logger("squeezeplay.ui") @@ -113,6 +114,9 @@ local MOUSE_DRAG = 3 local MOUSE_CHIRAL = 4 +-- touch hardware supports smooth scrolling and requires additional state to be maintained +local TOUCH = System:hasTouch() or not System:isHardware() + -- our class module(...) oo.class(_M, Widget) @@ -1611,6 +1615,9 @@ if widget then if widget.parent ~= self then widget.parent = self + if TOUCH then + widget:setSmoothScrollingMenu(self) + end widget:dispatchNewEvent(EVENT_SHOW) end @@ -1622,6 +1629,9 @@ for widget,i in pairs(lastWidgets) do widget:dispatchNewEvent(EVENT_HIDE) widget.parent = nil + if TOUCH then + widget:setSmoothScrollingMenu(nil) + end end self.lastWidgets = nextWidgets Index: squeezeplay/share/jive/ui/Widget.lua =================================================================== --- squeezeplay/share/jive/ui/Widget.lua (revision 8588) +++ squeezeplay/share/jive/ui/Widget.lua (working copy) @@ -692,6 +692,11 @@ end +function setSmoothScrollingMenu(self, val) + self.smoothscroll = val +end + + --[[ =head1 LICENSE Index: squeezeplay/share/jive/ui/Group.lua =================================================================== --- squeezeplay/share/jive/ui/Group.lua (revision 8588) +++ squeezeplay/share/jive/ui/Group.lua (working copy) @@ -231,6 +231,13 @@ return table.concat(str) end + +function setSmoothScrollingMenu(self, val) + for _,widget in pairs (self.widgets) do + widget:setSmoothScrollingMenu(val) + end +end + --[[ =head1 LICENSE