Author: titmuss
Date: Wed Apr 16 02:49:29 2008
New Revision: 2238
URL: http://svn.slimdevices.com?rev=2238&root=Jive&view=rev
Log:
Bug: N/A
Description:
Prototype mouse support.
Modified:
7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Menu.lua
7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Scrollbar.lua
7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Slider.lua
7.2/trunk/squeezeplay/src/squeezeplay/src/ui/jive.h
7.2/trunk/squeezeplay/src/squeezeplay/src/ui/jive_event.c
7.2/trunk/squeezeplay/src/squeezeplay/src/ui/jive_framework.c
7.2/trunk/squeezeplay/src/squeezeplay/src/ui/jive_menu.c
7.2/trunk/squeezeplay/src/squeezeplay/src/ui/jive_widget.c
7.2/trunk/squeezeplay/src/squeezeplay/src/ui/jive_window.c
7.2/trunk/squeezeplay/src/squeezeplay/src/ui/lua_jiveui.c
7.2/trunk/squeezeplay/src/squeezeplay/src/ui/lua_jiveui.pkg
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=2238&root=Jive&r1=2237&r2=2238&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 Wed Apr 16
02:49:29 2008
@@ -60,8 +60,11 @@
local EVENT_SHOW = jive.ui.EVENT_SHOW
local EVENT_HIDE = jive.ui.EVENT_HIDE
local EVENT_SERVICE_JNT = jive.ui.EVENT_SERVICE_JNT
-local EVENT_FOCUS_GAINED = jive.ui.EVENT_FOCUS_GAINED
-local EVENT_FOCUS_LOST = jive.ui.EVENT_FOCUS_LOST
+local EVENT_FOCUS_GAINED = jive.ui.EVENT_FOCUS_GAINED
+local EVENT_FOCUS_LOST = jive.ui.EVENT_FOCUS_LOST
+local EVENT_MOUSE_PRESS = jive.ui.EVENT_MOUSE_PRESS
+local EVENT_MOUSE_DOWN = jive.ui.EVENT_MOUSE_DOWN
+local EVENT_MOUSE_DRAG = jive.ui.EVENT_MOUSE_DRAG
local EVENT_CONSUME = jive.ui.EVENT_CONSUME
local EVENT_UNUSED = jive.ui.EVENT_UNUSED
@@ -187,6 +190,37 @@
end
end
+ elseif evtype == EVENT_MOUSE_PRESS then
+
+ if self.scrollbar:mouseInside(event) then
+ -- forward event to scrollbar
+ self.scrollbar:_event(event)
+
+ else
+ r = self:dispatchNewEvent(EVENT_ACTION)
+
+ if r == EVENT_UNUSED then
+ self:playSound("BUMP")
+ self:getWindow():bumpRight()
+ end
+ return r
+ end
+
+ elseif evtype == EVENT_MOUSE_DOWN or
+ evtype == EVENT_MOUSE_DRAG then
+
+ if self.scrollbar:mouseInside(event) then
+ -- forward event to scrollbar
+ self.scrollbar:_event(event)
+
+ else
+ -- menu selection follows mouse
+ local x,y,w,h = self:mouseBounds(event)
+ local i = y / self.itemHeight --(h / self.numWidgets)
+
+ self:setSelectedIndex(self.topItem + math.floor(i))
+ end
+
elseif evtype == EVENT_SHOW or
evtype == EVENT_HIDE then
@@ -224,7 +258,12 @@
return true
end
end)
- obj.scrollbar = Scrollbar("scrollbar")
+ obj.scrollbar = Scrollbar("scrollbar",
+ function(_, value)
+ log:warn("V=", value)
+ obj:setSelectedIndex(value)
+ end)
+
obj.scrollbar.parent = obj
obj.layoutRoot = true
obj.closeable = true
Modified: 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Scrollbar.lua
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Scrollbar.lua?rev=2238&root=Jive&r1=2237&r2=2238&view=diff
==============================================================================
--- 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Scrollbar.lua (original)
+++ 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Scrollbar.lua Wed Apr
16 02:49:29 2008
@@ -38,6 +38,7 @@
local tostring, type = tostring, type
local oo = require("loop.simple")
+local math = require("math")
local Slider = require("jive.ui.Slider")
local Widget = require("jive.ui.Widget")
@@ -60,13 +61,14 @@
-function __init(self, style)
+function __init(self, style, closure)
local obj = oo.rawnew(self, Slider(style))
obj.range = 1
obj.value = 1
obj.size = 1
+ obj.closure = closure
return obj
end
@@ -87,12 +89,25 @@
self.value = pos - min
self.size = size
+self.foo = min
+
self:reDraw()
end
-function _eventHandler(self, event)
- -- XXXX FIXME todo
+function _adjustPosition(self, percent)
+ local oldvalue = self.value
+
+ local pos = math.floor(percent * self.range)
+
+ self.value = pos - self.foo
+ self:reDraw()
+
+ log:warn("value=", self.value, " oldvalue=", oldvalue, " closure=",
self.closure)
+
+ if self.value ~= oldvalue and self.closure then
+ self.closure(self, pos, false)
+ end
end
Modified: 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Slider.lua
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Slider.lua?rev=2238&root=Jive&r1=2237&r2=2238&view=diff
==============================================================================
--- 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Slider.lua (original)
+++ 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Slider.lua Wed Apr 16
02:49:29 2008
@@ -46,6 +46,8 @@
local EVENT_SCROLL = jive.ui.EVENT_SCROLL
local EVENT_CONSUME = jive.ui.EVENT_CONSUME
local EVENT_UNUSED = jive.ui.EVENT_UNUSED
+local EVENT_MOUSE_DOWN = jive.ui.EVENT_MOUSE_DOWN
+local EVENT_MOUSE_DRAG = jive.ui.EVENT_MOUSE_DRAG
local KEY_BACK = jive.ui.KEY_BACK
local KEY_UP = jive.ui.KEY_UP
@@ -73,7 +75,7 @@
obj:setValue(value or obj.min)
- obj:addListener(EVENT_SCROLL | EVENT_KEY_PRESS,
+ obj:addListener(EVENT_SCROLL | EVENT_KEY_PRESS | EVENT_MOUSE_DOWN |
EVENT_MOUSE_DRAG,
function(event)
obj:_eventHandler(event)
end)
@@ -176,6 +178,21 @@
self:_adjustSlider(event:getScroll())
return EVENT_CONSUME
+ elseif type == EVENT_MOUSE_DOWN or
+ type == EVENT_MOUSE_DRAG then
+
+ local x,y,w,h = self:mouseBounds(event)
+
+ if w > h then
+ -- horizontal
+ self:_adjustPosition(x / w)
+ log:warn("H=", x / w)
+ else
+ -- vertical
+ self:_adjustPosition(y / h)
+ log:warn("V=", y / h)
+ end
+
elseif type == EVENT_KEY_PRESS then
local keycode = event:getKeycode()
Modified: 7.2/trunk/squeezeplay/src/squeezeplay/src/ui/jive.h
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/squeezeplay/src/ui/jive.h?rev=2238&root=Jive&r1=2237&r2=2238&view=diff
==============================================================================
--- 7.2/trunk/squeezeplay/src/squeezeplay/src/ui/jive.h (original)
+++ 7.2/trunk/squeezeplay/src/squeezeplay/src/ui/jive.h Wed Apr 16 02:49:29 2008
@@ -91,13 +91,13 @@
JIVE_EVENT_FOCUS_GAINED = 0x040000,
JIVE_EVENT_FOCUS_LOST = 0x080000,
-/* unused = 0x100000, */
+ JIVE_EVENT_MOUSE_DRAG = 0x100000,
JIVE_EVENT_WINDOW_RESIZE = 0x200000,
JIVE_EVENT_SWITCH = 0x400000,
JIVE_EVENT_MOTION = 0x800000,
JIVE_EVENT_KEY_ALL = ( JIVE_EVENT_KEY_DOWN |
JIVE_EVENT_KEY_UP | JIVE_EVENT_KEY_PRESS | JIVE_EVENT_KEY_HOLD ),
- JIVE_EVENT_MOUSE_ALL = ( JIVE_EVENT_MOUSE_DOWN |
JIVE_EVENT_MOUSE_PRESS | JIVE_EVENT_MOUSE_HOLD ),
+ JIVE_EVENT_MOUSE_ALL = ( JIVE_EVENT_MOUSE_DOWN |
JIVE_EVENT_MOUSE_PRESS | JIVE_EVENT_MOUSE_HOLD | JIVE_EVENT_MOUSE_DRAG ),
JIVE_EVENT_ALL_INPUT = ( JIVE_EVENT_KEY_ALL |
JIVE_EVENT_MOUSE_ALL | JIVE_EVENT_SCROLL),
JIVE_EVENT_VISIBLE_ALL = ( JIVE_EVENT_SHOW | JIVE_EVENT_HIDE ),
@@ -133,8 +133,9 @@
enum {
JIVE_USER_EVENT_TIMER = 0x00000001,
- JIVE_USER_EVENT_KEY_HOLD = 0x00000002,
- JIVE_USER_EVENT_EVENT = 0x00000003,
+ JIVE_USER_EVENT_KEY_HOLD = 0x00000002,
+ JIVE_USER_EVENT_MOUSE_HOLD = 0x00000003,
+ JIVE_USER_EVENT_EVENT = 0x00000004,
};
@@ -387,6 +388,8 @@
int jiveL_widget_get_bounds(lua_State *L);
int jiveL_widget_get_preferred_bounds(lua_State *L);
int jiveL_widget_get_border(lua_State *L);
+int jiveL_widget_mouse_bounds(lua_State *L);
+int jiveL_widget_mouse_inside(lua_State *L);
int jiveL_widget_reskin(lua_State *L);
int jiveL_widget_relayout(lua_State *L);
int jiveL_widget_redraw(lua_State *L);
Modified: 7.2/trunk/squeezeplay/src/squeezeplay/src/ui/jive_event.c
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/squeezeplay/src/ui/jive_event.c?rev=2238&root=Jive&r1=2237&r2=2238&view=diff
==============================================================================
--- 7.2/trunk/squeezeplay/src/squeezeplay/src/ui/jive_event.c (original)
+++ 7.2/trunk/squeezeplay/src/squeezeplay/src/ui/jive_event.c Wed Apr 16
02:49:29 2008
@@ -146,6 +146,7 @@
case JIVE_EVENT_MOUSE_UP:
case JIVE_EVENT_MOUSE_PRESS:
case JIVE_EVENT_MOUSE_HOLD:
+ case JIVE_EVENT_MOUSE_DRAG:
lua_pushinteger(L, event->u.mouse.x);
lua_pushinteger(L, event->u.mouse.y);
return 2;
@@ -246,6 +247,9 @@
case JIVE_EVENT_MOUSE_HOLD:
lua_pushfstring(L, "MOUSE_HOLD x=%d,y=%d", event->u.mouse.x,
event->u.mouse.y);
break;
+ case JIVE_EVENT_MOUSE_DRAG:
+ lua_pushfstring(L, "MOUSE_DRAG x=%d,y=%d", event->u.mouse.x,
event->u.mouse.y);
+ break;
case JIVE_EVENT_MOTION:
lua_pushfstring(L, "MOTION x=%d,y=%d,z=%d", event->u.motion.x,
event->u.motion.y, event->u.motion.z);
Modified: 7.2/trunk/squeezeplay/src/squeezeplay/src/ui/jive_framework.c
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/squeezeplay/src/ui/jive_framework.c?rev=2238&root=Jive&r1=2237&r2=2238&view=diff
==============================================================================
--- 7.2/trunk/squeezeplay/src/squeezeplay/src/ui/jive_framework.c (original)
+++ 7.2/trunk/squeezeplay/src/squeezeplay/src/ui/jive_framework.c Wed Apr 16
02:49:29 2008
@@ -51,9 +51,18 @@
KEY_STATE_SENT,
} key_state = KEY_STATE_NONE;
+static enum jive_mouse_state {
+ MOUSE_STATE_NONE,
+ MOUSE_STATE_DOWN,
+ MOUSE_STATE_DRAG,
+ MOUSE_STATE_SENT,
+} mouse_state = MOUSE_STATE_NONE;
+
static JiveKey key_mask = 0;
static SDL_TimerID key_timer = NULL;
+
+static SDL_TimerID mouse_timer = NULL;
static struct jive_keymap keymap[] = {
{ SDLK_RIGHT, JIVE_KEY_GO },
@@ -895,6 +904,20 @@
}
+static Uint32 mousehold_callback(Uint32 interval, void *param) {
+ SDL_Event user_event;
+ memset(&user_event, 0, sizeof(SDL_Event));
+
+ user_event.type = SDL_USEREVENT;
+ user_event.user.code = JIVE_USER_EVENT_MOUSE_HOLD;
+ user_event.user.data1 = param;
+
+ SDL_PushEvent(&user_event);
+
+ return 0;
+}
+
+
static int do_dispatch_event(lua_State *L, JiveEvent *jevent) {
int r;
@@ -916,6 +939,7 @@
JiveEvent jevent;
memset(&jevent, 0, sizeof(JiveEvent));
+ jevent.ticks = SDL_GetTicks();
switch (event->type) {
case SDL_QUIT:
@@ -927,32 +951,88 @@
/* map the mouse scroll wheel to up/down */
if (event->button.button == SDL_BUTTON_WHEELUP) {
jevent.type = JIVE_EVENT_SCROLL;
- jevent.ticks = SDL_GetTicks();
--(jevent.u.scroll.rel);
break;
}
else if (event->button.button == SDL_BUTTON_WHEELDOWN) {
jevent.type = JIVE_EVENT_SCROLL;
- jevent.ticks = SDL_GetTicks();
++(jevent.u.scroll.rel);
break;
}
+
// Fall through
case SDL_MOUSEBUTTONUP:
- // FIXME mouse down/up detection
+ if (event->button.button == SDL_BUTTON_LEFT) {
+ if (event->button.state == SDL_PRESSED) {
+ jevent.type = JIVE_EVENT_MOUSE_DOWN;
+ jevent.u.mouse.x = event->button.x;
+ jevent.u.mouse.y = event->button.y;
+ }
+ else {
+ jevent.type = JIVE_EVENT_MOUSE_UP;
+ jevent.u.mouse.x = event->button.x;
+ jevent.u.mouse.y = event->button.y;
+ }
+ }
+
+ if (event->type == SDL_MOUSEBUTTONDOWN) {
+ if (mouse_state == MOUSE_STATE_NONE) {
+ int param;
+
+ mouse_state = MOUSE_STATE_DOWN;
+
+ if (mouse_timer) {
+ SDL_RemoveTimer(mouse_timer);
+ }
+
+ param = (event->button.y << 16) |
event->button.x;
+ mouse_timer = SDL_AddTimer(HOLD_TIMEOUT,
&mousehold_callback, (void *) param);
+ break;
+ }
+ }
+ else /* SDL_MOUSEBUTTONUP */ {
+ if (mouse_state == MOUSE_STATE_DOWN) {
+ /*
+ * MOUSE_PRESSED and MOUSE_UP events
+ */
+ JiveEvent up;
+
+ memset(&up, 0, sizeof(JiveEvent));
+ up.type = JIVE_EVENT_MOUSE_PRESS;
+ up.ticks = SDL_GetTicks();
+ up.u.mouse.x = event->button.x;
+ up.u.mouse.y = event->button.y;
+ jive_queue_event(&up);
+ }
+
+ if (mouse_timer) {
+ SDL_RemoveTimer(mouse_timer);
+ mouse_timer = NULL;
+ }
+
+ mouse_state = MOUSE_STATE_NONE;
+ }
+ break;
+
+ case SDL_MOUSEMOTION:
+ if (event->motion.state & SDL_BUTTON(1) && mouse_state !=
MOUSE_STATE_SENT) {
+ jevent.type = JIVE_EVENT_MOUSE_DRAG;
+ jevent.u.mouse.x = event->motion.x;
+ jevent.u.mouse.y = event->motion.y;
+
+ mouse_state = MOUSE_STATE_DRAG;
+ }
break;
case SDL_KEYDOWN:
if (event->key.keysym.sym == SDLK_UP) {
jevent.type = JIVE_EVENT_SCROLL;
- jevent.ticks = SDL_GetTicks();
--(jevent.u.scroll.rel);
break;
}
else if (event->key.keysym.sym == SDLK_DOWN) {
jevent.type = JIVE_EVENT_SCROLL;
- jevent.ticks = SDL_GetTicks();
++(jevent.u.scroll.rel);
break;
}
@@ -989,7 +1069,6 @@
key_mask |= entry->keycode;
jevent.type = JIVE_EVENT_KEY_DOWN;
- jevent.ticks = SDL_GetTicks();
jevent.u.key.code = entry->keycode;
if (key_timer) {
@@ -1021,7 +1100,6 @@
JiveEvent keyup;
jevent.type = JIVE_EVENT_KEY_PRESS;
- jevent.ticks = SDL_GetTicks();
jevent.u.key.code = key_mask;
memset(&keyup, 0, sizeof(JiveEvent));
@@ -1039,7 +1117,6 @@
* KEY_UP event
*/
jevent.type = JIVE_EVENT_KEY_UP;
- jevent.ticks = SDL_GetTicks();
jevent.u.key.code = entry->keycode;
break;
}
@@ -1068,10 +1145,19 @@
case JIVE_USER_EVENT_KEY_HOLD:
jevent.type = JIVE_EVENT_KEY_HOLD;
- jevent.ticks = SDL_GetTicks();
jevent.u.key.code = (JiveKey) event->user.data1;
key_state = KEY_STATE_SENT;
break;
+
+ case JIVE_USER_EVENT_MOUSE_HOLD:
+ if (mouse_state == MOUSE_STATE_DOWN) {
+ jevent.type = JIVE_EVENT_MOUSE_HOLD;
+ jevent.u.mouse.x = (unsigned int)
event->user.data1 & 0xFFFF;
+ jevent.u.mouse.y = ((unsigned int)
event->user.data1 >> 16) & 0xFFFF;
+ mouse_state = MOUSE_STATE_SENT;
+ }
+ break;
+
case JIVE_USER_EVENT_EVENT:
memcpy(&jevent, event->user.data1, sizeof(JiveEvent));
free(event->user.data1);
@@ -1105,7 +1191,6 @@
next_jive_origin++;
jevent.type = JIVE_EVENT_WINDOW_RESIZE;
- jevent.ticks = SDL_GetTicks();
break;
}
@@ -1208,6 +1293,8 @@
{ "getBounds", jiveL_widget_get_bounds },
{ "getPreferredBounds", jiveL_widget_get_preferred_bounds },
{ "getBorder", jiveL_widget_get_border },
+ { "mouseBounds", jiveL_widget_mouse_bounds },
+ { "mouseInside", jiveL_widget_mouse_inside },
{ "reSkin", jiveL_widget_reskin },
{ "reLayout", jiveL_widget_relayout },
{ "reDraw", jiveL_widget_redraw },
Modified: 7.2/trunk/squeezeplay/src/squeezeplay/src/ui/jive_menu.c
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/squeezeplay/src/ui/jive_menu.c?rev=2238&root=Jive&r1=2237&r2=2238&view=diff
==============================================================================
--- 7.2/trunk/squeezeplay/src/squeezeplay/src/ui/jive_menu.c (original)
+++ 7.2/trunk/squeezeplay/src/squeezeplay/src/ui/jive_menu.c Wed Apr 16
02:49:29 2008
@@ -44,6 +44,9 @@
/* menu properties */
peer->item_height = jive_style_int(L, 1, "itemHeight", 20);
+
+ lua_pushinteger(L, peer->item_height);
+ lua_setfield(L, 1, "itemHeight");
peer->font = jive_font_ref(jive_style_font(L, 1, "font"));
peer->fg = jive_style_color(L, 1, "fg", JIVE_COLOR_BLACK, NULL);
Modified: 7.2/trunk/squeezeplay/src/squeezeplay/src/ui/jive_widget.c
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/squeezeplay/src/ui/jive_widget.c?rev=2238&root=Jive&r1=2237&r2=2238&view=diff
==============================================================================
--- 7.2/trunk/squeezeplay/src/squeezeplay/src/ui/jive_widget.c (original)
+++ 7.2/trunk/squeezeplay/src/squeezeplay/src/ui/jive_widget.c Wed Apr 16
02:49:29 2008
@@ -175,6 +175,74 @@
lua_pushinteger(L, peer->border.top);
lua_pushinteger(L, peer->border.right);
lua_pushinteger(L, peer->border.bottom);
+ return 4;
+}
+
+
+int jiveL_widget_mouse_inside(lua_State *L) {
+ JiveWidget *peer;
+ JiveEvent* event;
+
+ /* stack is:
+ * 1: widget
+ * 2: mouse event
+ */
+
+ if (jive_getmethod(L, 1, "checkSkin")) {
+ lua_pushvalue(L, 1);
+ lua_call(L, 1, 0);
+ }
+
+ lua_getfield(L, 1, "peer");
+ peer = lua_touserdata(L, -1);
+ if (!peer) {
+ lua_pushboolean(L, 0);
+ return 1;
+ }
+
+ event = (JiveEvent*)lua_touserdata(L, 2);
+ if (!event || (event->type & JIVE_EVENT_MOUSE_ALL) == 0) {
+ lua_pushboolean(L, 0);
+ return 1;
+ }
+
+ lua_pushboolean(L, peer->bounds.x < event->u.mouse.x &&
event->u.mouse.x < peer->bounds.x + peer->bounds.w &&
+ peer->bounds.y < event->u.mouse.y && event->u.mouse.y <
peer->bounds.y + peer->bounds.h);
+ return 1;
+}
+
+
+int jiveL_widget_mouse_bounds(lua_State *L) {
+ JiveWidget *peer;
+ JiveEvent* event;
+
+ /* stack is:
+ * 1: widget
+ * 2: mouse event
+ */
+
+ if (jive_getmethod(L, 1, "checkSkin")) {
+ lua_pushvalue(L, 1);
+ lua_call(L, 1, 0);
+ }
+
+ lua_getfield(L, 1, "peer");
+ peer = lua_touserdata(L, -1);
+ if (!peer) {
+ lua_pushboolean(L, 0);
+ return 1;
+ }
+
+ event = (JiveEvent*)lua_touserdata(L, 2);
+ if (!event || (event->type & JIVE_EVENT_MOUSE_ALL) == 0) {
+ lua_pushboolean(L, 0);
+ return 1;
+ }
+
+ lua_pushinteger(L, event->u.mouse.x - peer->bounds.x);
+ lua_pushinteger(L, event->u.mouse.y - peer->bounds.y -
peer->padding.top - peer->padding.bottom);
+ lua_pushinteger(L, peer->bounds.w);
+ lua_pushinteger(L, peer->bounds.h);
return 4;
}
Modified: 7.2/trunk/squeezeplay/src/squeezeplay/src/ui/jive_window.c
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/squeezeplay/src/ui/jive_window.c?rev=2238&root=Jive&r1=2237&r2=2238&view=diff
==============================================================================
--- 7.2/trunk/squeezeplay/src/squeezeplay/src/ui/jive_window.c (original)
+++ 7.2/trunk/squeezeplay/src/squeezeplay/src/ui/jive_window.c Wed Apr 16
02:49:29 2008
@@ -281,6 +281,41 @@
}
+static int mouse_closure(lua_State *L) {
+ JiveWidget *peer;
+ JiveEvent *event;
+
+ /* stack is:
+ * 1: widget
+ * upvalue:
+ * 1: event
+ */
+
+ lua_getfield(L, 1, "peer");
+ peer = lua_touserdata(L, -1);
+ if (!peer) {
+ lua_pop(L, 1);
+ return 0;
+ }
+
+ event = lua_touserdata(L, lua_upvalueindex(1));
+
+ if (peer->bounds.x < event->u.mouse.x && event->u.mouse.x <
peer->bounds.x + peer->bounds.w &&
+ peer->bounds.y < event->u.mouse.y && event->u.mouse.y <
peer->bounds.y + peer->bounds.h) {
+ if (jive_getmethod(L, 1, "_event")) {
+ lua_pushvalue(L, 1); /* widget */
+ lua_pushvalue(L, lua_upvalueindex(1)); /* event */
+ lua_call(L, 2, 1);
+
+ // FIXME return value
+ lua_pop(L, 1);
+ }
+ }
+
+ return 0;
+}
+
+
int jiveL_window_event_handler(lua_State *L) {
int r = 0;
@@ -312,6 +347,26 @@
}
break;
+
+ case JIVE_EVENT_MOUSE_DOWN:
+ case JIVE_EVENT_MOUSE_UP:
+ case JIVE_EVENT_MOUSE_PRESS:
+ case JIVE_EVENT_MOUSE_HOLD:
+ case JIVE_EVENT_MOUSE_DRAG:
+
+ /* Forward mouse events to the enclosed widgets */
+ if (jive_getmethod(L, 1, "iterate")) {
+ lua_pushvalue(L, 1); // widget
+
+ lua_pushvalue(L, 2); // event
+ lua_pushcclosure(L, mouse_closure, 1);
+
+ lua_call(L, 2, 0);
+ }
+ // FIXME r
+
+ lua_pushinteger(L, r);
+ return 1;
case JIVE_EVENT_WINDOW_ACTIVE:
/*
Modified: 7.2/trunk/squeezeplay/src/squeezeplay/src/ui/lua_jiveui.c
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/squeezeplay/src/ui/lua_jiveui.c?rev=2238&root=Jive&r1=2237&r2=2238&view=diff
==============================================================================
--- 7.2/trunk/squeezeplay/src/squeezeplay/src/ui/lua_jiveui.c (original)
+++ 7.2/trunk/squeezeplay/src/squeezeplay/src/ui/lua_jiveui.c Wed Apr 16
02:49:29 2008
@@ -1,6 +1,6 @@
/*
** Lua binding: jive
-** Generated automatically by tolua++-1.0.92 on Wed Jan 30 21:18:12 2008.
+** Generated automatically by tolua++-1.0.92 on Wed Apr 9 13:56:44 2008.
*/
#ifndef __cplusplus
@@ -2159,6 +2159,7 @@
tolua_constant(tolua_S,"EVENT_HIDE",JIVE_EVENT_HIDE);
tolua_constant(tolua_S,"EVENT_FOCUS_GAINED",JIVE_EVENT_FOCUS_GAINED);
tolua_constant(tolua_S,"EVENT_FOCUS_LOST",JIVE_EVENT_FOCUS_LOST);
+ tolua_constant(tolua_S,"EVENT_MOUSE_DRAG",JIVE_EVENT_MOUSE_DRAG);
tolua_constant(tolua_S,"EVENT_WINDOW_RESIZE",JIVE_EVENT_WINDOW_RESIZE);
tolua_constant(tolua_S,"EVENT_SWITCH",JIVE_EVENT_SWITCH);
tolua_constant(tolua_S,"EVENT_MOTION",JIVE_EVENT_MOTION);
Modified: 7.2/trunk/squeezeplay/src/squeezeplay/src/ui/lua_jiveui.pkg
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/squeezeplay/src/ui/lua_jiveui.pkg?rev=2238&root=Jive&r1=2237&r2=2238&view=diff
==============================================================================
--- 7.2/trunk/squeezeplay/src/squeezeplay/src/ui/lua_jiveui.pkg (original)
+++ 7.2/trunk/squeezeplay/src/squeezeplay/src/ui/lua_jiveui.pkg Wed Apr 16
02:49:29 2008
@@ -101,6 +101,7 @@
JIVE_EVENT_FOCUS_GAINED @ EVENT_FOCUS_GAINED = 0x040000,
JIVE_EVENT_FOCUS_LOST @ EVENT_FOCUS_LOST = 0x080000,
+ JIVE_EVENT_MOUSE_DRAG @ EVENT_MOUSE_DRAG = 0x100000,
JIVE_EVENT_WINDOW_RESIZE @ EVENT_WINDOW_RESIZE = 0x200000,
JIVE_EVENT_SWITCH @ EVENT_SWITCH = 0x400000,
JIVE_EVENT_MOTION @ EVENT_MOTION = 0x800000,
_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/cgi-bin/mailman/listinfo/jive-checkins