From 7c165e6c5ba2c92bab5359344f0755fd43d1bb9e Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Wed, 3 Oct 2018 17:49:26 -0400 Subject: Changed and added some methods for generic gui elements. Changed getabsrect() to now return getAbsolutePosition() Added getabsclippingrect() to return what getabsrect used to return Added getrelrect() to return getRelativePosition() --- src/client/lua_api/gui/iguielement.cpp | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'src/client/lua_api/gui/iguielement.cpp') diff --git a/src/client/lua_api/gui/iguielement.cpp b/src/client/lua_api/gui/iguielement.cpp index 3567d80..81d339f 100644 --- a/src/client/lua_api/gui/iguielement.cpp +++ b/src/client/lua_api/gui/iguielement.cpp @@ -46,6 +46,27 @@ Find the rectangle that an element occupies */ //getabsrect({element})-> {{sx,sy},{ex,ey}} int getiguiclippingrect(lua_State* L){ + lua_getfield(L,-1,"guielement"); + IGUIElement *el = (IGUIElement*)lua_touserdata(L,-1);//{element},ud_element + lua_pop(L,2); + core::rect rect = el->getAbsolutePosition(); + pushrecti( + L, + rect.UpperLeftCorner.X, + rect.UpperLeftCorner.Y, + rect.LowerRightCorner.X, + rect.LowerRightCorner.Y + ); + return 1; +} + +/*** +Find the rectangle that an element occupies that is visible to the user +@function guielement:getabsclippingrect() +@treturn rect The rectangle that this element occupies that is visible to the user +*/ +//getabsclippingrect({element}) :: {{sx,sy},{ex,ey}} +int getiguiabsclippingrect(lua_State *L){ lua_getfield(L,-1,"guielement"); IGUIElement *el = (IGUIElement*)lua_touserdata(L,-1);//{element},ud_element lua_pop(L,2); @@ -60,6 +81,26 @@ int getiguiclippingrect(lua_State* L){ return 1; } +/*** +Find the relative rectangle that this element occupies +@function guielement:getrelrect() +@treturn rect The rectangle that this element occupies relative to it's parent +*/ +int getiguirelrect(lua_State *L){ + lua_getfield(L,-1,"guielement"); + IGUIElement *el = (IGUIElement*)lua_touserdata(L,-1);//{element},ud_element + lua_pop(L,2); + core::rect rect = el->getRelativePosition(); + pushrecti( + L, + rect.UpperLeftCorner.X, + rect.UpperLeftCorner.Y, + rect.LowerRightCorner.X, + rect.LowerRightCorner.Y + ); + return 1; +} + /*** Sets the text of the element This function may do different things to different gui elements. -- cgit v1.2.3-70-g09d2