aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/lua_api/gui/iguielement.cpp41
-rw-r--r--src/client/lua_api/gui/iguielement.hpp4
2 files changed, 45 insertions, 0 deletions
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
@@ -49,6 +49,27 @@ 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<s32> 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);
core::rect<s32> rect = el->getAbsoluteClippingRect();
pushrecti(
L,
@@ -61,6 +82,26 @@ int getiguiclippingrect(lua_State* L){
}
/***
+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<s32> 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.
For example, on a window, it sets the title.
diff --git a/src/client/lua_api/gui/iguielement.hpp b/src/client/lua_api/gui/iguielement.hpp
index 0e08644..7969c65 100644
--- a/src/client/lua_api/gui/iguielement.hpp
+++ b/src/client/lua_api/gui/iguielement.hpp
@@ -10,6 +10,8 @@ extern "C" {
int moveiguielement(lua_State* L);
int getiguiclippingrect(lua_State* L);
+int getiguiabsclippingrect(lua_State *L);
+int getiguirelrect(lua_State *L);
int setiguitext(lua_State* L);
int getiguitext(lua_State* L);
int removeiguielement(lua_State* L);
@@ -23,6 +25,8 @@ static const luaL_reg iguielement_m[] = {
{"move", moveiguielement},
{"setrect", setrelrect},
{"getabsrect", getiguiclippingrect},
+ {"getabsclippingrect", getiguiabsclippingrect},
+ {"getrelrect", getiguirelrect},
{"settext", setiguitext},
{"gettext", getiguitext},
{"remove", removeiguielement},