Element.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. /*
  2. * This source file is part of RmlUi, the HTML/CSS Interface Middleware
  3. *
  4. * For the latest information, see http://github.com/mikke89/RmlUi
  5. *
  6. * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
  7. * Copyright (c) 2019-2023 The RmlUi Team, and contributors
  8. *
  9. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10. * of this software and associated documentation files (the "Software"), to deal
  11. * in the Software without restriction, including without limitation the rights
  12. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. * copies of the Software, and to permit persons to whom the Software is
  14. * furnished to do so, subject to the following conditions:
  15. *
  16. * The above copyright notice and this permission notice shall be included in
  17. * all copies or substantial portions of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25. * THE SOFTWARE.
  26. *
  27. */
  28. #include "Element.h"
  29. #include "ElementAttributesProxy.h"
  30. #include "ElementChildNodesProxy.h"
  31. #include "ElementStyleProxy.h"
  32. #include "LuaEventListener.h"
  33. #include <RmlUi/Lua/Utilities.h>
  34. namespace Rml {
  35. namespace Lua {
  36. typedef ElementDocument Document;
  37. template <>
  38. void ExtraInit<Element>(lua_State* L, int metatable_index)
  39. {
  40. int top = lua_gettop(L);
  41. // guarantee the "Element.As" table exists
  42. lua_getfield(L, metatable_index - 1, "As");
  43. if (lua_isnoneornil(L, -1)) // if it doesn't exist, create it
  44. {
  45. lua_newtable(L);
  46. lua_setfield(L, metatable_index - 1, "As");
  47. }
  48. lua_pop(L, 1); // pop the result of lua_getfield
  49. lua_pushcfunction(L, Elementnew);
  50. lua_setfield(L, metatable_index - 1, "new");
  51. lua_settop(L, top);
  52. }
  53. int Elementnew(lua_State* L)
  54. {
  55. const char* tag = luaL_checkstring(L, 1);
  56. Element* ele = new Element(tag);
  57. LuaType<Element>::push(L, ele, true);
  58. return 1;
  59. }
  60. // methods
  61. int ElementAddEventListener(lua_State* L, Element* obj)
  62. {
  63. int top = lua_gettop(L);
  64. bool capture = false;
  65. // default false if they didn't pass it in
  66. if (top > 2)
  67. capture = RMLUI_CHECK_BOOL(L, 3);
  68. const char* event = luaL_checkstring(L, 1);
  69. LuaEventListener* listener = nullptr;
  70. int type = lua_type(L, 2);
  71. if (type == LUA_TFUNCTION)
  72. {
  73. listener = new LuaEventListener(L, 2, obj);
  74. }
  75. else if (type == LUA_TSTRING)
  76. {
  77. const char* code = luaL_checkstring(L, 2);
  78. listener = new LuaEventListener(code, obj);
  79. }
  80. else
  81. {
  82. Log::Message(Log::LT_WARNING, "Lua Context:AddEventLisener's 2nd argument can only be a Lua function or a string, you passed in a %s",
  83. lua_typename(L, type));
  84. }
  85. if (listener != nullptr)
  86. {
  87. obj->AddEventListener(event, listener, capture);
  88. }
  89. return 0;
  90. }
  91. int ElementAppendChild(lua_State* L, Element* obj)
  92. {
  93. ElementPtr* element = LuaType<ElementPtr>::check(L, 1);
  94. if (*element)
  95. {
  96. Element* child = obj->AppendChild(std::move(*element));
  97. LuaType<Element>::push(L, child, false);
  98. }
  99. else
  100. {
  101. Log::Message(Log::LT_WARNING, "Could not append child to element '%s', as the child was null. Was it already moved from?",
  102. obj->GetAddress().c_str());
  103. lua_pushnil(L);
  104. }
  105. return 1;
  106. }
  107. int ElementBlur(lua_State* /*L*/, Element* obj)
  108. {
  109. obj->Blur();
  110. return 0;
  111. }
  112. int ElementClick(lua_State* /*L*/, Element* obj)
  113. {
  114. obj->Click();
  115. return 0;
  116. }
  117. int ElementDispatchEvent(lua_State* L, Element* obj)
  118. {
  119. const char* event = luaL_checkstring(L, 1);
  120. Dictionary params;
  121. lua_pushnil(L); // becauase lua_next pops a key from the stack first, we don't want to pop the table
  122. while (lua_next(L, 2) != 0)
  123. {
  124. //[-1] is value, [-2] is key
  125. int type = lua_type(L, -1);
  126. const char* key = luaL_checkstring(L, -2); // key HAS to be a string, or things will go bad
  127. switch (type)
  128. {
  129. case LUA_TNUMBER: params[key] = (float)lua_tonumber(L, -1); break;
  130. case LUA_TBOOLEAN: params[key] = RMLUI_CHECK_BOOL(L, -1); break;
  131. case LUA_TSTRING: params[key] = luaL_checkstring(L, -1); break;
  132. case LUA_TUSERDATA:
  133. case LUA_TLIGHTUSERDATA: params[key] = lua_touserdata(L, -1); break;
  134. default: break;
  135. }
  136. lua_pop(L, 1); // pops value, leaves key for next iteration
  137. }
  138. obj->DispatchEvent(event, params);
  139. return 0;
  140. }
  141. int ElementFocus(lua_State* /*L*/, Element* obj)
  142. {
  143. obj->Focus();
  144. return 0;
  145. }
  146. int ElementGetAttribute(lua_State* L, Element* obj)
  147. {
  148. const char* name = luaL_checkstring(L, 1);
  149. Variant* var = obj->GetAttribute(name);
  150. PushVariant(L, var);
  151. return 1;
  152. }
  153. int ElementGetElementById(lua_State* L, Element* obj)
  154. {
  155. const char* id = luaL_checkstring(L, 1);
  156. Element* ele = obj->GetElementById(id);
  157. LuaType<Element>::push(L, ele, false);
  158. return 1;
  159. }
  160. int ElementGetElementsByTagName(lua_State* L, Element* obj)
  161. {
  162. const char* tag = luaL_checkstring(L, 1);
  163. ElementList list;
  164. obj->GetElementsByTagName(list, tag);
  165. lua_newtable(L);
  166. for (unsigned int i = 0; i < list.size(); i++)
  167. {
  168. PushIndex(L, i);
  169. LuaType<Element>::push(L, list[i], false);
  170. lua_settable(L, -3); //-3 is the table
  171. }
  172. return 1;
  173. }
  174. int ElementQuerySelector(lua_State* L, Element* obj)
  175. {
  176. const char* sel = luaL_checkstring(L, 1);
  177. Element* ele = obj->QuerySelector(sel);
  178. LuaType<Element>::push(L, ele, false);
  179. return 1;
  180. }
  181. int ElementQuerySelectorAll(lua_State* L, Element* obj)
  182. {
  183. const char* tag = luaL_checkstring(L, 1);
  184. ElementList list;
  185. obj->QuerySelectorAll(list, tag);
  186. lua_newtable(L);
  187. for (unsigned int i = 0; i < list.size(); i++)
  188. {
  189. PushIndex(L, i);
  190. LuaType<Element>::push(L, list[i], false);
  191. lua_settable(L, -3); //-3 is the table
  192. }
  193. return 1;
  194. }
  195. int ElementMatches(lua_State* L, Element* obj)
  196. {
  197. const char* tag = luaL_checkstring(L, 1);
  198. lua_pushboolean(L, obj->Matches(tag));
  199. return 1;
  200. }
  201. int ElementHasAttribute(lua_State* L, Element* obj)
  202. {
  203. const char* name = luaL_checkstring(L, 1);
  204. lua_pushboolean(L, obj->HasAttribute(name));
  205. return 1;
  206. }
  207. int ElementHasChildNodes(lua_State* L, Element* obj)
  208. {
  209. lua_pushboolean(L, obj->HasChildNodes());
  210. return 1;
  211. }
  212. int ElementInsertBefore(lua_State* L, Element* obj)
  213. {
  214. ElementPtr* element = LuaType<ElementPtr>::check(L, 1);
  215. Element* adjacent = LuaType<Element>::check(L, 2);
  216. if (*element)
  217. {
  218. Element* inserted = obj->InsertBefore(std::move(*element), adjacent);
  219. LuaType<Element>::push(L, inserted, false);
  220. }
  221. else
  222. {
  223. Log::Message(Log::LT_WARNING, "Could not insert child to element '%s', as the child was null. Was it already moved from?",
  224. obj->GetAddress().c_str());
  225. lua_pushnil(L);
  226. }
  227. return 1;
  228. }
  229. int ElementIsClassSet(lua_State* L, Element* obj)
  230. {
  231. const char* name = luaL_checkstring(L, 1);
  232. lua_pushboolean(L, obj->IsClassSet(name));
  233. return 1;
  234. }
  235. int ElementRemoveAttribute(lua_State* L, Element* obj)
  236. {
  237. const char* name = luaL_checkstring(L, 1);
  238. obj->RemoveAttribute(name);
  239. return 0;
  240. }
  241. int ElementRemoveChild(lua_State* L, Element* obj)
  242. {
  243. Element* element = LuaType<Element>::check(L, 1);
  244. lua_pushboolean(L, static_cast<bool>(obj->RemoveChild(element)));
  245. return 1;
  246. }
  247. int ElementReplaceChild(lua_State* L, Element* obj)
  248. {
  249. ElementPtr* inserted = LuaType<ElementPtr>::check(L, 1);
  250. Element* replaced = LuaType<Element>::check(L, 2);
  251. if (*inserted)
  252. lua_pushboolean(L, static_cast<bool>(obj->ReplaceChild(std::move(*inserted), replaced)));
  253. else
  254. Log::Message(Log::LT_WARNING, "Could not replace child in element '%s', as the child was null. Was it already moved from?",
  255. obj->GetAddress().c_str());
  256. return 1;
  257. }
  258. int ElementScrollIntoView(lua_State* L, Element* obj)
  259. {
  260. bool align = RMLUI_CHECK_BOOL(L, 1);
  261. obj->ScrollIntoView(align);
  262. return 0;
  263. }
  264. int ElementSetAttribute(lua_State* L, Element* obj)
  265. {
  266. const char* name = luaL_checkstring(L, 1);
  267. const char* value = luaL_checkstring(L, 2);
  268. obj->SetAttribute(name, String(value));
  269. return 0;
  270. }
  271. int ElementSetClass(lua_State* L, Element* obj)
  272. {
  273. const char* name = luaL_checkstring(L, 1);
  274. bool value = RMLUI_CHECK_BOOL(L, 2);
  275. obj->SetClass(name, value);
  276. return 0;
  277. }
  278. // getters
  279. int ElementGetAttrattributes(lua_State* L)
  280. {
  281. Element* ele = LuaType<Element>::check(L, 1);
  282. RMLUI_CHECK_OBJ(ele);
  283. ElementAttributesProxy* proxy = new ElementAttributesProxy();
  284. proxy->owner = ele;
  285. LuaType<ElementAttributesProxy>::push(L, proxy, true);
  286. return 1;
  287. }
  288. int ElementGetAttrchild_nodes(lua_State* L)
  289. {
  290. Element* ele = LuaType<Element>::check(L, 1);
  291. RMLUI_CHECK_OBJ(ele);
  292. ElementChildNodesProxy* ecnp = new ElementChildNodesProxy();
  293. ecnp->owner = ele;
  294. LuaType<ElementChildNodesProxy>::push(L, ecnp, true);
  295. return 1;
  296. }
  297. int ElementGetAttrclass_name(lua_State* L)
  298. {
  299. Element* ele = LuaType<Element>::check(L, 1);
  300. RMLUI_CHECK_OBJ(ele);
  301. String classnames = ele->GetClassNames();
  302. lua_pushstring(L, classnames.c_str());
  303. return 1;
  304. }
  305. int ElementGetAttrclient_left(lua_State* L)
  306. {
  307. Element* ele = LuaType<Element>::check(L, 1);
  308. RMLUI_CHECK_OBJ(ele);
  309. lua_pushnumber(L, ele->GetClientLeft());
  310. return 1;
  311. }
  312. int ElementGetAttrclient_height(lua_State* L)
  313. {
  314. Element* ele = LuaType<Element>::check(L, 1);
  315. RMLUI_CHECK_OBJ(ele);
  316. lua_pushnumber(L, ele->GetClientHeight());
  317. return 1;
  318. }
  319. int ElementGetAttrclient_top(lua_State* L)
  320. {
  321. Element* ele = LuaType<Element>::check(L, 1);
  322. RMLUI_CHECK_OBJ(ele);
  323. lua_pushnumber(L, ele->GetClientTop());
  324. return 1;
  325. }
  326. int ElementGetAttrclient_width(lua_State* L)
  327. {
  328. Element* ele = LuaType<Element>::check(L, 1);
  329. RMLUI_CHECK_OBJ(ele);
  330. lua_pushnumber(L, ele->GetClientWidth());
  331. return 1;
  332. }
  333. int ElementGetAttrfirst_child(lua_State* L)
  334. {
  335. Element* ele = LuaType<Element>::check(L, 1);
  336. RMLUI_CHECK_OBJ(ele);
  337. Element* child = ele->GetFirstChild();
  338. if (child == nullptr)
  339. lua_pushnil(L);
  340. else
  341. LuaType<Element>::push(L, child, false);
  342. return 1;
  343. }
  344. int ElementGetAttrid(lua_State* L)
  345. {
  346. Element* ele = LuaType<Element>::check(L, 1);
  347. RMLUI_CHECK_OBJ(ele);
  348. lua_pushstring(L, ele->GetId().c_str());
  349. return 1;
  350. }
  351. int ElementGetAttrinner_rml(lua_State* L)
  352. {
  353. Element* ele = LuaType<Element>::check(L, 1);
  354. RMLUI_CHECK_OBJ(ele);
  355. lua_pushstring(L, ele->GetInnerRML().c_str());
  356. return 1;
  357. }
  358. int ElementGetAttrlast_child(lua_State* L)
  359. {
  360. Element* ele = LuaType<Element>::check(L, 1);
  361. RMLUI_CHECK_OBJ(ele);
  362. Element* child = ele->GetLastChild();
  363. if (child == nullptr)
  364. lua_pushnil(L);
  365. else
  366. LuaType<Element>::push(L, child, false);
  367. return 1;
  368. }
  369. int ElementGetAttrnext_sibling(lua_State* L)
  370. {
  371. Element* ele = LuaType<Element>::check(L, 1);
  372. RMLUI_CHECK_OBJ(ele);
  373. Element* sibling = ele->GetNextSibling();
  374. if (sibling == nullptr)
  375. lua_pushnil(L);
  376. else
  377. LuaType<Element>::push(L, sibling, false);
  378. return 1;
  379. }
  380. int ElementGetAttroffset_height(lua_State* L)
  381. {
  382. Element* ele = LuaType<Element>::check(L, 1);
  383. RMLUI_CHECK_OBJ(ele);
  384. lua_pushnumber(L, ele->GetOffsetHeight());
  385. return 1;
  386. }
  387. int ElementGetAttroffset_left(lua_State* L)
  388. {
  389. Element* ele = LuaType<Element>::check(L, 1);
  390. RMLUI_CHECK_OBJ(ele);
  391. lua_pushnumber(L, ele->GetOffsetLeft());
  392. return 1;
  393. }
  394. int ElementGetAttroffset_parent(lua_State* L)
  395. {
  396. Element* ele = LuaType<Element>::check(L, 1);
  397. RMLUI_CHECK_OBJ(ele);
  398. Element* parent = ele->GetOffsetParent();
  399. LuaType<Element>::push(L, parent, false);
  400. return 1;
  401. }
  402. int ElementGetAttroffset_top(lua_State* L)
  403. {
  404. Element* ele = LuaType<Element>::check(L, 1);
  405. RMLUI_CHECK_OBJ(ele);
  406. lua_pushnumber(L, ele->GetOffsetTop());
  407. return 1;
  408. }
  409. int ElementGetAttroffset_width(lua_State* L)
  410. {
  411. Element* ele = LuaType<Element>::check(L, 1);
  412. RMLUI_CHECK_OBJ(ele);
  413. lua_pushnumber(L, ele->GetOffsetWidth());
  414. return 1;
  415. }
  416. int ElementGetAttrowner_document(lua_State* L)
  417. {
  418. Element* ele = LuaType<Element>::check(L, 1);
  419. RMLUI_CHECK_OBJ(ele);
  420. Document* doc = ele->GetOwnerDocument();
  421. LuaType<Document>::push(L, doc, false);
  422. return 1;
  423. }
  424. int ElementGetAttrparent_node(lua_State* L)
  425. {
  426. Element* ele = LuaType<Element>::check(L, 1);
  427. RMLUI_CHECK_OBJ(ele);
  428. Element* parent = ele->GetParentNode();
  429. if (parent == nullptr)
  430. lua_pushnil(L);
  431. else
  432. LuaType<Element>::push(L, parent, false);
  433. return 1;
  434. }
  435. int ElementGetAttrprevious_sibling(lua_State* L)
  436. {
  437. Element* ele = LuaType<Element>::check(L, 1);
  438. RMLUI_CHECK_OBJ(ele);
  439. Element* sibling = ele->GetPreviousSibling();
  440. if (sibling == nullptr)
  441. lua_pushnil(L);
  442. else
  443. LuaType<Element>::push(L, sibling, false);
  444. return 1;
  445. }
  446. int ElementGetAttrscroll_height(lua_State* L)
  447. {
  448. Element* ele = LuaType<Element>::check(L, 1);
  449. RMLUI_CHECK_OBJ(ele);
  450. lua_pushnumber(L, ele->GetScrollHeight());
  451. return 1;
  452. }
  453. int ElementGetAttrscroll_left(lua_State* L)
  454. {
  455. Element* ele = LuaType<Element>::check(L, 1);
  456. RMLUI_CHECK_OBJ(ele);
  457. lua_pushnumber(L, ele->GetScrollLeft());
  458. return 1;
  459. }
  460. int ElementGetAttrscroll_top(lua_State* L)
  461. {
  462. Element* ele = LuaType<Element>::check(L, 1);
  463. RMLUI_CHECK_OBJ(ele);
  464. lua_pushnumber(L, ele->GetScrollTop());
  465. return 1;
  466. }
  467. int ElementGetAttrscroll_width(lua_State* L)
  468. {
  469. Element* ele = LuaType<Element>::check(L, 1);
  470. RMLUI_CHECK_OBJ(ele);
  471. lua_pushnumber(L, ele->GetScrollWidth());
  472. return 1;
  473. }
  474. int ElementGetAttrstyle(lua_State* L)
  475. {
  476. Element* ele = LuaType<Element>::check(L, 1);
  477. RMLUI_CHECK_OBJ(ele);
  478. ElementStyleProxy* prox = new ElementStyleProxy();
  479. prox->owner = ele;
  480. LuaType<ElementStyleProxy>::push(L, prox, true);
  481. return 1;
  482. }
  483. int ElementGetAttrtag_name(lua_State* L)
  484. {
  485. Element* ele = LuaType<Element>::check(L, 1);
  486. RMLUI_CHECK_OBJ(ele);
  487. lua_pushstring(L, ele->GetTagName().c_str());
  488. return 1;
  489. }
  490. // setters
  491. int ElementSetAttrclass_name(lua_State* L)
  492. {
  493. Element* ele = LuaType<Element>::check(L, 1);
  494. RMLUI_CHECK_OBJ(ele);
  495. const char* name = luaL_checkstring(L, 2);
  496. ele->SetClassNames(name);
  497. return 0;
  498. }
  499. int ElementSetAttrid(lua_State* L)
  500. {
  501. Element* ele = LuaType<Element>::check(L, 1);
  502. RMLUI_CHECK_OBJ(ele);
  503. const char* id = luaL_checkstring(L, 2);
  504. ele->SetId(id);
  505. return 0;
  506. }
  507. int ElementSetAttrinner_rml(lua_State* L)
  508. {
  509. Element* ele = LuaType<Element>::check(L, 1);
  510. RMLUI_CHECK_OBJ(ele);
  511. const char* rml = luaL_checkstring(L, 2);
  512. ele->SetInnerRML(rml);
  513. return 0;
  514. }
  515. int ElementSetAttrscroll_left(lua_State* L)
  516. {
  517. Element* ele = LuaType<Element>::check(L, 1);
  518. RMLUI_CHECK_OBJ(ele);
  519. float scroll = (float)luaL_checknumber(L, 2);
  520. ele->SetScrollLeft(scroll);
  521. return 0;
  522. }
  523. int ElementSetAttrscroll_top(lua_State* L)
  524. {
  525. Element* ele = LuaType<Element>::check(L, 1);
  526. RMLUI_CHECK_OBJ(ele);
  527. float scroll = (float)luaL_checknumber(L, 2);
  528. ele->SetScrollTop(scroll);
  529. return 0;
  530. }
  531. RegType<Element> ElementMethods[] = {
  532. RMLUI_LUAMETHOD(Element, AddEventListener),
  533. RMLUI_LUAMETHOD(Element, AppendChild),
  534. RMLUI_LUAMETHOD(Element, Blur),
  535. RMLUI_LUAMETHOD(Element, Click),
  536. RMLUI_LUAMETHOD(Element, DispatchEvent),
  537. RMLUI_LUAMETHOD(Element, Focus),
  538. RMLUI_LUAMETHOD(Element, GetAttribute),
  539. RMLUI_LUAMETHOD(Element, GetElementById),
  540. RMLUI_LUAMETHOD(Element, GetElementsByTagName),
  541. RMLUI_LUAMETHOD(Element, QuerySelector),
  542. RMLUI_LUAMETHOD(Element, QuerySelectorAll),
  543. RMLUI_LUAMETHOD(Element, Matches),
  544. RMLUI_LUAMETHOD(Element, HasAttribute),
  545. RMLUI_LUAMETHOD(Element, HasChildNodes),
  546. RMLUI_LUAMETHOD(Element, InsertBefore),
  547. RMLUI_LUAMETHOD(Element, IsClassSet),
  548. RMLUI_LUAMETHOD(Element, RemoveAttribute),
  549. RMLUI_LUAMETHOD(Element, RemoveChild),
  550. RMLUI_LUAMETHOD(Element, ReplaceChild),
  551. RMLUI_LUAMETHOD(Element, ScrollIntoView),
  552. RMLUI_LUAMETHOD(Element, SetAttribute),
  553. RMLUI_LUAMETHOD(Element, SetClass),
  554. {nullptr, nullptr},
  555. };
  556. luaL_Reg ElementGetters[] = {
  557. RMLUI_LUAGETTER(Element, attributes),
  558. RMLUI_LUAGETTER(Element, child_nodes),
  559. RMLUI_LUAGETTER(Element, class_name),
  560. RMLUI_LUAGETTER(Element, client_left),
  561. RMLUI_LUAGETTER(Element, client_height),
  562. RMLUI_LUAGETTER(Element, client_top),
  563. RMLUI_LUAGETTER(Element, client_width),
  564. RMLUI_LUAGETTER(Element, first_child),
  565. RMLUI_LUAGETTER(Element, id),
  566. RMLUI_LUAGETTER(Element, inner_rml),
  567. RMLUI_LUAGETTER(Element, last_child),
  568. RMLUI_LUAGETTER(Element, next_sibling),
  569. RMLUI_LUAGETTER(Element, offset_height),
  570. RMLUI_LUAGETTER(Element, offset_left),
  571. RMLUI_LUAGETTER(Element, offset_parent),
  572. RMLUI_LUAGETTER(Element, offset_top),
  573. RMLUI_LUAGETTER(Element, offset_width),
  574. RMLUI_LUAGETTER(Element, owner_document),
  575. RMLUI_LUAGETTER(Element, parent_node),
  576. RMLUI_LUAGETTER(Element, previous_sibling),
  577. RMLUI_LUAGETTER(Element, scroll_height),
  578. RMLUI_LUAGETTER(Element, scroll_left),
  579. RMLUI_LUAGETTER(Element, scroll_top),
  580. RMLUI_LUAGETTER(Element, scroll_width),
  581. RMLUI_LUAGETTER(Element, style),
  582. RMLUI_LUAGETTER(Element, tag_name),
  583. {nullptr, nullptr},
  584. };
  585. luaL_Reg ElementSetters[] = {
  586. RMLUI_LUASETTER(Element, class_name),
  587. RMLUI_LUASETTER(Element, id),
  588. RMLUI_LUASETTER(Element, inner_rml),
  589. RMLUI_LUASETTER(Element, scroll_left),
  590. RMLUI_LUASETTER(Element, scroll_top),
  591. {nullptr, nullptr},
  592. };
  593. RMLUI_LUATYPE_DEFINE(Element)
  594. template <>
  595. void ExtraInit<ElementPtr>(lua_State* /*L*/, int /*metatable_index*/)
  596. {
  597. return;
  598. }
  599. RegType<ElementPtr> ElementPtrMethods[] = {
  600. {nullptr, nullptr},
  601. };
  602. luaL_Reg ElementPtrGetters[] = {
  603. {nullptr, nullptr},
  604. };
  605. luaL_Reg ElementPtrSetters[] = {
  606. {nullptr, nullptr},
  607. };
  608. RMLUI_LUATYPE_DEFINE(ElementPtr)
  609. } // namespace Lua
  610. } // namespace Rml