luat_lv_theme.c 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. #include "luat_base.h"
  2. #include "lvgl.h"
  3. #include "luat_lvgl.h"
  4. // void lv_theme_set_act(lv_theme_t* th)
  5. int luat_lv_theme_set_act(lua_State *L) {
  6. LV_DEBUG("CALL lv_theme_set_act");
  7. lv_theme_t* th = (lv_theme_t*)lua_touserdata(L, 1);
  8. lv_theme_set_act(th);
  9. return 0;
  10. }
  11. // lv_theme_t* lv_theme_get_act()
  12. int luat_lv_theme_get_act(lua_State *L) {
  13. LV_DEBUG("CALL lv_theme_get_act");
  14. lv_theme_t* ret = NULL;
  15. ret = lv_theme_get_act();
  16. if (ret) lua_pushlightuserdata(L, ret); else lua_pushnil(L);
  17. return 1;
  18. }
  19. // void lv_theme_apply(lv_obj_t* obj, lv_theme_style_t name)
  20. int luat_lv_theme_apply(lua_State *L) {
  21. LV_DEBUG("CALL lv_theme_apply");
  22. lv_obj_t* obj = (lv_obj_t*)lua_touserdata(L, 1);
  23. lv_theme_style_t name = luaL_checkinteger(L, 2);
  24. // miss arg convert
  25. lv_theme_apply(obj ,name);
  26. return 0;
  27. }
  28. // void lv_theme_copy(lv_theme_t* theme, lv_theme_t* copy)
  29. int luat_lv_theme_copy(lua_State *L) {
  30. LV_DEBUG("CALL lv_theme_copy");
  31. lv_theme_t* theme = (lv_theme_t*)lua_touserdata(L, 1);
  32. lv_theme_t* copy = (lv_theme_t*)lua_touserdata(L, 2);
  33. lv_theme_copy(theme ,copy);
  34. return 0;
  35. }
  36. // void lv_theme_set_base(lv_theme_t* new_theme, lv_theme_t* base)
  37. int luat_lv_theme_set_base(lua_State *L) {
  38. LV_DEBUG("CALL lv_theme_set_base");
  39. lv_theme_t* new_theme = (lv_theme_t*)lua_touserdata(L, 1);
  40. lv_theme_t* base = (lv_theme_t*)lua_touserdata(L, 2);
  41. lv_theme_set_base(new_theme ,base);
  42. return 0;
  43. }
  44. // lv_font_t* lv_theme_get_font_small()
  45. int luat_lv_theme_get_font_small(lua_State *L) {
  46. LV_DEBUG("CALL lv_theme_get_font_small");
  47. lv_font_t* ret = NULL;
  48. ret = lv_theme_get_font_small();
  49. if (ret) lua_pushlightuserdata(L, ret); else lua_pushnil(L);
  50. return 1;
  51. }
  52. // lv_font_t* lv_theme_get_font_normal()
  53. int luat_lv_theme_get_font_normal(lua_State *L) {
  54. LV_DEBUG("CALL lv_theme_get_font_normal");
  55. lv_font_t* ret = NULL;
  56. ret = lv_theme_get_font_normal();
  57. if (ret) lua_pushlightuserdata(L, ret); else lua_pushnil(L);
  58. return 1;
  59. }
  60. // lv_font_t* lv_theme_get_font_subtitle()
  61. int luat_lv_theme_get_font_subtitle(lua_State *L) {
  62. LV_DEBUG("CALL lv_theme_get_font_subtitle");
  63. lv_font_t* ret = NULL;
  64. ret = lv_theme_get_font_subtitle();
  65. if (ret) lua_pushlightuserdata(L, ret); else lua_pushnil(L);
  66. return 1;
  67. }
  68. // lv_font_t* lv_theme_get_font_title()
  69. int luat_lv_theme_get_font_title(lua_State *L) {
  70. LV_DEBUG("CALL lv_theme_get_font_title");
  71. lv_font_t* ret = NULL;
  72. ret = lv_theme_get_font_title();
  73. if (ret) lua_pushlightuserdata(L, ret); else lua_pushnil(L);
  74. return 1;
  75. }
  76. // lv_color_t lv_theme_get_color_primary()
  77. int luat_lv_theme_get_color_primary(lua_State *L) {
  78. LV_DEBUG("CALL lv_theme_get_color_primary");
  79. lv_color_t ret;
  80. ret = lv_theme_get_color_primary();
  81. lua_pushinteger(L, ret.full);
  82. return 1;
  83. }
  84. // lv_color_t lv_theme_get_color_secondary()
  85. int luat_lv_theme_get_color_secondary(lua_State *L) {
  86. LV_DEBUG("CALL lv_theme_get_color_secondary");
  87. lv_color_t ret;
  88. ret = lv_theme_get_color_secondary();
  89. lua_pushinteger(L, ret.full);
  90. return 1;
  91. }
  92. // uint32_t lv_theme_get_flags()
  93. int luat_lv_theme_get_flags(lua_State *L) {
  94. LV_DEBUG("CALL lv_theme_get_flags");
  95. uint32_t ret;
  96. ret = lv_theme_get_flags();
  97. lua_pushinteger(L, ret);
  98. return 1;
  99. }
  100. // lv_theme_t* lv_theme_empty_init(lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags, lv_font_t* font_small, lv_font_t* font_normal, lv_font_t* font_subtitle, lv_font_t* font_title)
  101. int luat_lv_theme_empty_init(lua_State *L) {
  102. LV_DEBUG("CALL lv_theme_empty_init");
  103. lv_color_t color_primary = {0};
  104. color_primary.full = luaL_checkinteger(L, 1);
  105. lv_color_t color_secondary = {0};
  106. color_secondary.full = luaL_checkinteger(L, 2);
  107. uint32_t flags = (uint32_t)luaL_checkinteger(L, 3);
  108. lv_font_t* font_small = (lv_font_t*)lua_touserdata(L, 4);
  109. lv_font_t* font_normal = (lv_font_t*)lua_touserdata(L, 5);
  110. lv_font_t* font_subtitle = (lv_font_t*)lua_touserdata(L, 6);
  111. lv_font_t* font_title = (lv_font_t*)lua_touserdata(L, 7);
  112. lv_theme_t* ret = NULL;
  113. ret = lv_theme_empty_init(color_primary ,color_secondary ,flags ,font_small ,font_normal ,font_subtitle ,font_title);
  114. if (ret) lua_pushlightuserdata(L, ret); else lua_pushnil(L);
  115. return 1;
  116. }
  117. // lv_theme_t* lv_theme_template_init(lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags, lv_font_t* font_small, lv_font_t* font_normal, lv_font_t* font_subtitle, lv_font_t* font_title)
  118. int luat_lv_theme_template_init(lua_State *L) {
  119. LV_DEBUG("CALL lv_theme_template_init");
  120. lv_color_t color_primary = {0};
  121. color_primary.full = luaL_checkinteger(L, 1);
  122. lv_color_t color_secondary = {0};
  123. color_secondary.full = luaL_checkinteger(L, 2);
  124. uint32_t flags = (uint32_t)luaL_checkinteger(L, 3);
  125. lv_font_t* font_small = (lv_font_t*)lua_touserdata(L, 4);
  126. lv_font_t* font_normal = (lv_font_t*)lua_touserdata(L, 5);
  127. lv_font_t* font_subtitle = (lv_font_t*)lua_touserdata(L, 6);
  128. lv_font_t* font_title = (lv_font_t*)lua_touserdata(L, 7);
  129. lv_theme_t* ret = NULL;
  130. ret = lv_theme_template_init(color_primary ,color_secondary ,flags ,font_small ,font_normal ,font_subtitle ,font_title);
  131. if (ret) lua_pushlightuserdata(L, ret); else lua_pushnil(L);
  132. return 1;
  133. }
  134. // lv_theme_t* lv_theme_material_init(lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags, lv_font_t* font_small, lv_font_t* font_normal, lv_font_t* font_subtitle, lv_font_t* font_title)
  135. int luat_lv_theme_material_init(lua_State *L) {
  136. LV_DEBUG("CALL lv_theme_material_init");
  137. lv_color_t color_primary = {0};
  138. color_primary.full = luaL_checkinteger(L, 1);
  139. lv_color_t color_secondary = {0};
  140. color_secondary.full = luaL_checkinteger(L, 2);
  141. uint32_t flags = (uint32_t)luaL_checkinteger(L, 3);
  142. lv_font_t* font_small = (lv_font_t*)lua_touserdata(L, 4);
  143. lv_font_t* font_normal = (lv_font_t*)lua_touserdata(L, 5);
  144. lv_font_t* font_subtitle = (lv_font_t*)lua_touserdata(L, 6);
  145. lv_font_t* font_title = (lv_font_t*)lua_touserdata(L, 7);
  146. lv_theme_t* ret = NULL;
  147. ret = lv_theme_material_init(color_primary ,color_secondary ,flags ,font_small ,font_normal ,font_subtitle ,font_title);
  148. if (ret) lua_pushlightuserdata(L, ret); else lua_pushnil(L);
  149. return 1;
  150. }
  151. // lv_theme_t* lv_theme_mono_init(lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags, lv_font_t* font_small, lv_font_t* font_normal, lv_font_t* font_subtitle, lv_font_t* font_title)
  152. int luat_lv_theme_mono_init(lua_State *L) {
  153. LV_DEBUG("CALL lv_theme_mono_init");
  154. lv_color_t color_primary = {0};
  155. color_primary.full = luaL_checkinteger(L, 1);
  156. lv_color_t color_secondary = {0};
  157. color_secondary.full = luaL_checkinteger(L, 2);
  158. uint32_t flags = (uint32_t)luaL_checkinteger(L, 3);
  159. lv_font_t* font_small = (lv_font_t*)lua_touserdata(L, 4);
  160. lv_font_t* font_normal = (lv_font_t*)lua_touserdata(L, 5);
  161. lv_font_t* font_subtitle = (lv_font_t*)lua_touserdata(L, 6);
  162. lv_font_t* font_title = (lv_font_t*)lua_touserdata(L, 7);
  163. lv_theme_t* ret = NULL;
  164. ret = lv_theme_mono_init(color_primary ,color_secondary ,flags ,font_small ,font_normal ,font_subtitle ,font_title);
  165. if (ret) lua_pushlightuserdata(L, ret); else lua_pushnil(L);
  166. return 1;
  167. }