From 206f937e6e6f1aab373d9d8602333d1c94873c9f Mon Sep 17 00:00:00 2001 From: Kevin Harrison Date: Tue, 18 Dec 2018 14:36:13 -0500 Subject: [PATCH] Add ui:style --- src/nuklear_love.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/nuklear_love.c b/src/nuklear_love.c index 5086641..775b99d 100644 --- a/src/nuklear_love.c +++ b/src/nuklear_love.c @@ -3979,6 +3979,27 @@ static int nk_love_style_pop(lua_State *L) return 0; } +static int nk_love_style(lua_State *L) +{ + nk_love_assert(lua_checkstack(L, 3), "%s: failed to allocate stack space"); + nk_love_assert_argc(lua_gettop(L) == 3); + if (!lua_isfunction(L, -1)) + luaL_typerror(L, lua_gettop(L), "function"); + lua_pushvalue(L, 1); + lua_insert(L, 2); + lua_pushvalue(L, 1); + lua_insert(L, 3); + lua_insert(L, 2); + lua_getfield(L, 1, "stylePush"); + lua_insert(L, 4); + lua_call(L, 2, 0); + lua_call(L, 1, 0); + lua_getfield(L, 1, "stylePop"); + lua_insert(L, 1); + lua_call(L, 1, 0); + return 0; +} + /* * =============================================================== * @@ -4493,6 +4514,7 @@ LUALIB_API int luaopen_nuklear(lua_State *luaState) NK_LOVE_REGISTER("styleSetFont", nk_love_style_set_font); NK_LOVE_REGISTER("stylePush", nk_love_style_push); NK_LOVE_REGISTER("stylePop", nk_love_style_pop); + NK_LOVE_REGISTER("style", nk_love_style); NK_LOVE_REGISTER("widgetBounds", nk_love_widget_bounds); NK_LOVE_REGISTER("widgetPosition", nk_love_widget_position);