mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-31 09:21:18 +02:00
CLuaInstance: Add various CComponentsWindow fuctions
- Added: color buttons for footer, header_height
This commit is contained in:
@@ -1291,12 +1291,10 @@ void CLuaInstance::CWindowRegister(lua_State *L)
|
|||||||
{ "new", CLuaInstance::CWindowNew },
|
{ "new", CLuaInstance::CWindowNew },
|
||||||
{ "paint", CLuaInstance::CWindowPaint },
|
{ "paint", CLuaInstance::CWindowPaint },
|
||||||
{ "hide", CLuaInstance::CWindowHide },
|
{ "hide", CLuaInstance::CWindowHide },
|
||||||
|
{ "header_height", CLuaInstance::CWindowGetHeaderHeight },
|
||||||
{ "__gc", CLuaInstance::CWindowDelete },
|
{ "__gc", CLuaInstance::CWindowDelete },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
#if 0
|
|
||||||
{ "exec", CLuaInstance::CWindowExec },
|
|
||||||
#endif
|
|
||||||
|
|
||||||
luaL_newmetatable(L, "cwindow");
|
luaL_newmetatable(L, "cwindow");
|
||||||
luaL_setfuncs(L, meth, 0);
|
luaL_setfuncs(L, meth, 0);
|
||||||
@@ -1310,6 +1308,10 @@ int CLuaInstance::CWindowNew(lua_State *L)
|
|||||||
lua_assert(lua_istable(L,1));
|
lua_assert(lua_istable(L,1));
|
||||||
|
|
||||||
std::string name, icon = std::string(NEUTRINO_ICON_INFO);
|
std::string name, icon = std::string(NEUTRINO_ICON_INFO);
|
||||||
|
std::string btnRed = "";
|
||||||
|
std::string btnGreen = "";
|
||||||
|
std::string btnYellow = "";
|
||||||
|
std::string btnBlue = "";
|
||||||
int x = 100, y = 100, dx = 450, dy = 250;
|
int x = 100, y = 100, dx = 450, dy = 250;
|
||||||
tableLookup(L, "x", x);
|
tableLookup(L, "x", x);
|
||||||
tableLookup(L, "y", y);
|
tableLookup(L, "y", y);
|
||||||
@@ -1317,10 +1319,38 @@ int CLuaInstance::CWindowNew(lua_State *L)
|
|||||||
tableLookup(L, "dy", dy);
|
tableLookup(L, "dy", dy);
|
||||||
tableLookup(L, "name", name) || tableLookup(L, "title", name) || tableLookup(L, "caption", name);
|
tableLookup(L, "name", name) || tableLookup(L, "title", name) || tableLookup(L, "caption", name);
|
||||||
tableLookup(L, "icon", icon);
|
tableLookup(L, "icon", icon);
|
||||||
|
tableLookup(L, "btnRed", btnRed);
|
||||||
|
tableLookup(L, "btnGreen", btnGreen);
|
||||||
|
tableLookup(L, "btnYellow", btnYellow);
|
||||||
|
tableLookup(L, "btnBlue", btnBlue);
|
||||||
|
|
||||||
CLuaCWindow **udata = (CLuaCWindow **) lua_newuserdata(L, sizeof(CLuaCWindow *));
|
CLuaCWindow **udata = (CLuaCWindow **) lua_newuserdata(L, sizeof(CLuaCWindow *));
|
||||||
*udata = new CLuaCWindow();
|
*udata = new CLuaCWindow();
|
||||||
(*udata)->w = new CComponentsWindow(x, y, dx, dy, name.c_str(), icon.c_str());
|
(*udata)->w = new CComponentsWindow(x, y, dx, dy, name.c_str(), icon.c_str());
|
||||||
|
|
||||||
|
CComponentsFooter* footer = (*udata)->w->getFooterObject();
|
||||||
|
if (footer) {
|
||||||
|
int btnCount = 0;
|
||||||
|
if (btnRed != "") btnCount++;
|
||||||
|
if (btnGreen != "") btnCount++;
|
||||||
|
if (btnYellow != "") btnCount++;
|
||||||
|
if (btnBlue != "") btnCount++;
|
||||||
|
if (btnCount) {
|
||||||
|
fb_pixel_t col = footer->getColorBody();
|
||||||
|
int btnw = (dx-20) / btnCount;
|
||||||
|
int btnh = footer->getHeight();
|
||||||
|
int start = 10;
|
||||||
|
if (btnRed != "")
|
||||||
|
footer->addCCItem(new CComponentsButtonRed(start, CC_CENTERED, btnw, btnh, btnRed, false , true, false, col, col));
|
||||||
|
if (btnGreen != "")
|
||||||
|
footer->addCCItem(new CComponentsButtonGreen(start+=btnw, CC_CENTERED, btnw, btnh, btnGreen, false , true, false, col, col));
|
||||||
|
if (btnYellow != "")
|
||||||
|
footer->addCCItem(new CComponentsButtonYellow(start+=btnw, CC_CENTERED, btnw, btnh, btnYellow, false , true, false, col, col));
|
||||||
|
if (btnBlue != "")
|
||||||
|
footer->addCCItem(new CComponentsButtonBlue(start+=btnw, CC_CENTERED, btnw, btnh, btnBlue, false , true, false, col, col));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
luaL_getmetatable(L, "cwindow");
|
luaL_getmetatable(L, "cwindow");
|
||||||
lua_setmetatable(L, -2);
|
lua_setmetatable(L, -2);
|
||||||
return 1;
|
return 1;
|
||||||
@@ -1361,6 +1391,20 @@ int CLuaInstance::CWindowHide(lua_State *L)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CLuaInstance::CWindowGetHeaderHeight(lua_State *L)
|
||||||
|
{
|
||||||
|
CLuaCWindow *m = CWindowCheck(L, 1);
|
||||||
|
if (!m)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
CComponentsHeader* header = m->w->getHeaderObject();
|
||||||
|
int hh = 0;
|
||||||
|
if (header)
|
||||||
|
hh = header->getHeight();
|
||||||
|
lua_pushinteger(L, hh);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int CLuaInstance::CWindowDelete(lua_State *L)
|
int CLuaInstance::CWindowDelete(lua_State *L)
|
||||||
{
|
{
|
||||||
CLuaCWindow *m = CWindowCheck(L, 1);
|
CLuaCWindow *m = CWindowCheck(L, 1);
|
||||||
|
@@ -198,6 +198,7 @@ private:
|
|||||||
static CLuaCWindow *CWindowCheck(lua_State *L, int n);
|
static CLuaCWindow *CWindowCheck(lua_State *L, int n);
|
||||||
static int CWindowPaint(lua_State *L);
|
static int CWindowPaint(lua_State *L);
|
||||||
static int CWindowHide(lua_State *L);
|
static int CWindowHide(lua_State *L);
|
||||||
|
static int CWindowGetHeaderHeight(lua_State *L);
|
||||||
static int CWindowDelete(lua_State *L);
|
static int CWindowDelete(lua_State *L);
|
||||||
|
|
||||||
static CLuaSignalBox *SignalBoxCheck(lua_State *L, int n);
|
static CLuaSignalBox *SignalBoxCheck(lua_State *L, int n);
|
||||||
|
Reference in New Issue
Block a user