mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 15:32:59 +02:00
lua_api_cc_picture: add methode doPaintBg(), fix missing background
Re adding compatibility with old behavior for background paint. supplement to: cc_*_picture: add own file for cc_frm_picture. API Documentation: https://wiki.tuxbox-neutrino.org/wiki/Lua:Neutrino-API:cpicture:de#doPaintBg
This commit is contained in:
@@ -35,6 +35,8 @@
|
|||||||
#include "lua_cc_window.h"
|
#include "lua_cc_window.h"
|
||||||
#include "lua_cc_picture.h"
|
#include "lua_cc_picture.h"
|
||||||
|
|
||||||
|
#define LUA_CPICTURE "cpicture"
|
||||||
|
|
||||||
CLuaInstCCPicture* CLuaInstCCPicture::getInstance()
|
CLuaInstCCPicture* CLuaInstCCPicture::getInstance()
|
||||||
{
|
{
|
||||||
static CLuaInstCCPicture* LuaInstCCPicture = NULL;
|
static CLuaInstCCPicture* LuaInstCCPicture = NULL;
|
||||||
@@ -46,7 +48,7 @@ CLuaInstCCPicture* CLuaInstCCPicture::getInstance()
|
|||||||
|
|
||||||
CLuaCCPicture *CLuaInstCCPicture::CCPictureCheck(lua_State *L, int n)
|
CLuaCCPicture *CLuaInstCCPicture::CCPictureCheck(lua_State *L, int n)
|
||||||
{
|
{
|
||||||
return *(CLuaCCPicture **) luaL_checkudata(L, n, "cpicture");
|
return *(CLuaCCPicture **) luaL_checkudata(L, n, LUA_CPICTURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLuaInstCCPicture::CCPictureRegister(lua_State *L)
|
void CLuaInstCCPicture::CCPictureRegister(lua_State *L)
|
||||||
@@ -59,15 +61,16 @@ void CLuaInstCCPicture::CCPictureRegister(lua_State *L)
|
|||||||
{ "setCenterPos", CLuaInstCCPicture::CCPictureSetCenterPos },
|
{ "setCenterPos", CLuaInstCCPicture::CCPictureSetCenterPos },
|
||||||
{ "getHeight", CLuaInstCCPicture::CCPictureGetHeight },
|
{ "getHeight", CLuaInstCCPicture::CCPictureGetHeight },
|
||||||
{ "getWidth", CLuaInstCCPicture::CCPictureGetWidth },
|
{ "getWidth", CLuaInstCCPicture::CCPictureGetWidth },
|
||||||
|
{ "doPaintBg", CLuaInstCCPicture::CCPictureSetDoPaintBG },
|
||||||
{ "__gc", CLuaInstCCPicture::CCPictureDelete },
|
{ "__gc", CLuaInstCCPicture::CCPictureDelete },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
luaL_newmetatable(L, "cpicture");
|
luaL_newmetatable(L, LUA_CPICTURE);
|
||||||
luaL_setfuncs(L, meth, 0);
|
luaL_setfuncs(L, meth, 0);
|
||||||
lua_pushvalue(L, -1);
|
lua_pushvalue(L, -1);
|
||||||
lua_setfield(L, -1, "__index");
|
lua_setfield(L, -1, "__index");
|
||||||
lua_setglobal(L, "cpicture");
|
lua_setglobal(L, LUA_CPICTURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CLuaInstCCPicture::CCPictureNew(lua_State *L)
|
int CLuaInstCCPicture::CCPictureNew(lua_State *L)
|
||||||
@@ -122,8 +125,10 @@ int CLuaInstCCPicture::CCPictureNew(lua_State *L)
|
|||||||
(*udata)->cp = new CComponentsPicture(x, y, image_name, pw, has_shadow, (fb_pixel_t)color_frame, (fb_pixel_t)color_background, (fb_pixel_t)color_shadow, transparency);
|
(*udata)->cp = new CComponentsPicture(x, y, image_name, pw, has_shadow, (fb_pixel_t)color_frame, (fb_pixel_t)color_background, (fb_pixel_t)color_shadow, transparency);
|
||||||
else
|
else
|
||||||
(*udata)->cp = new CComponentsPicture(x, y, dx, dy, image_name, pw, has_shadow, (fb_pixel_t)color_frame, (fb_pixel_t)color_background, (fb_pixel_t)color_shadow, transparency);
|
(*udata)->cp = new CComponentsPicture(x, y, dx, dy, image_name, pw, has_shadow, (fb_pixel_t)color_frame, (fb_pixel_t)color_background, (fb_pixel_t)color_shadow, transparency);
|
||||||
|
|
||||||
|
(*udata)->cp->doPaintBg(true);
|
||||||
(*udata)->parent = pw;
|
(*udata)->parent = pw;
|
||||||
luaL_getmetatable(L, "cpicture");
|
luaL_getmetatable(L, LUA_CPICTURE);
|
||||||
lua_setmetatable(L, -2);
|
lua_setmetatable(L, -2);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -161,10 +166,26 @@ int CLuaInstCCPicture::CCPicturePaint(lua_State *L)
|
|||||||
paramBoolDeprecated(L, tmp.c_str());
|
paramBoolDeprecated(L, tmp.c_str());
|
||||||
do_save_bg = (tmp == "true" || tmp == "1" || tmp == "yes");
|
do_save_bg = (tmp == "true" || tmp == "1" || tmp == "yes");
|
||||||
}
|
}
|
||||||
|
|
||||||
D->cp->paint(do_save_bg);
|
D->cp->paint(do_save_bg);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CLuaInstCCPicture::CCPictureSetDoPaintBG(lua_State *L)
|
||||||
|
{
|
||||||
|
lua_assert(lua_istable(L,1));
|
||||||
|
CLuaCCPicture *D = CCPictureCheck(L, 1);
|
||||||
|
if (!D) return 0;
|
||||||
|
|
||||||
|
bool paint_bg = false;
|
||||||
|
std::string tmp = "false";
|
||||||
|
if (tableLookup(L, "paint_bg", tmp))
|
||||||
|
paint_bg = (tmp == "true" || tmp == "1" || tmp == "yes");
|
||||||
|
|
||||||
|
D->cp->doPaintBg(paint_bg);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int CLuaInstCCPicture::CCPictureHide(lua_State *L)
|
int CLuaInstCCPicture::CCPictureHide(lua_State *L)
|
||||||
{
|
{
|
||||||
lua_assert(lua_istable(L,1));
|
lua_assert(lua_istable(L,1));
|
||||||
|
@@ -48,6 +48,7 @@ class CLuaInstCCPicture
|
|||||||
static int CCPictureSetCenterPos(lua_State *L);
|
static int CCPictureSetCenterPos(lua_State *L);
|
||||||
static int CCPictureGetHeight(lua_State *L);
|
static int CCPictureGetHeight(lua_State *L);
|
||||||
static int CCPictureGetWidth(lua_State *L);
|
static int CCPictureGetWidth(lua_State *L);
|
||||||
|
static int CCPictureSetDoPaintBG(lua_State *L);
|
||||||
static int CCPictureDelete(lua_State *L);
|
static int CCPictureDelete(lua_State *L);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user