theme.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764
  1. /*************************************************************************/
  2. /* theme.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #include "theme.h"
  31. #include "core/os/file_access.h"
  32. #include "core/print_string.h"
  33. Ref<Theme> Theme::default_theme;
  34. void Theme::_emit_theme_changed() {
  35. emit_changed();
  36. }
  37. bool Theme::_set(const StringName &p_name, const Variant &p_value) {
  38. String sname = p_name;
  39. if (sname.find("/") != -1) {
  40. String type = sname.get_slicec('/', 1);
  41. String node_type = sname.get_slicec('/', 0);
  42. String name = sname.get_slicec('/', 2);
  43. if (type == "icons") {
  44. set_icon(name, node_type, p_value);
  45. } else if (type == "styles") {
  46. set_stylebox(name, node_type, p_value);
  47. } else if (type == "fonts") {
  48. set_font(name, node_type, p_value);
  49. } else if (type == "colors") {
  50. set_color(name, node_type, p_value);
  51. } else if (type == "constants") {
  52. set_constant(name, node_type, p_value);
  53. } else
  54. return false;
  55. return true;
  56. }
  57. return false;
  58. }
  59. bool Theme::_get(const StringName &p_name, Variant &r_ret) const {
  60. String sname = p_name;
  61. if (sname.find("/") != -1) {
  62. String type = sname.get_slicec('/', 1);
  63. String node_type = sname.get_slicec('/', 0);
  64. String name = sname.get_slicec('/', 2);
  65. if (type == "icons") {
  66. if (!has_icon(name, node_type))
  67. r_ret = Ref<Texture>();
  68. else
  69. r_ret = get_icon(name, node_type);
  70. } else if (type == "styles") {
  71. if (!has_stylebox(name, node_type))
  72. r_ret = Ref<StyleBox>();
  73. else
  74. r_ret = get_stylebox(name, node_type);
  75. } else if (type == "fonts") {
  76. if (!has_font(name, node_type))
  77. r_ret = Ref<Font>();
  78. else
  79. r_ret = get_font(name, node_type);
  80. } else if (type == "colors") {
  81. r_ret = get_color(name, node_type);
  82. } else if (type == "constants") {
  83. r_ret = get_constant(name, node_type);
  84. } else
  85. return false;
  86. return true;
  87. }
  88. return false;
  89. }
  90. void Theme::_get_property_list(List<PropertyInfo> *p_list) const {
  91. List<PropertyInfo> list;
  92. const StringName *key = NULL;
  93. while ((key = icon_map.next(key))) {
  94. const StringName *key2 = NULL;
  95. while ((key2 = icon_map[*key].next(key2))) {
  96. list.push_back(PropertyInfo(Variant::OBJECT, String() + *key + "/icons/" + *key2, PROPERTY_HINT_RESOURCE_TYPE, "Texture", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_STORE_IF_NULL));
  97. }
  98. }
  99. key = NULL;
  100. while ((key = style_map.next(key))) {
  101. const StringName *key2 = NULL;
  102. while ((key2 = style_map[*key].next(key2))) {
  103. list.push_back(PropertyInfo(Variant::OBJECT, String() + *key + "/styles/" + *key2, PROPERTY_HINT_RESOURCE_TYPE, "StyleBox", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_STORE_IF_NULL));
  104. }
  105. }
  106. key = NULL;
  107. while ((key = font_map.next(key))) {
  108. const StringName *key2 = NULL;
  109. while ((key2 = font_map[*key].next(key2))) {
  110. list.push_back(PropertyInfo(Variant::OBJECT, String() + *key + "/fonts/" + *key2, PROPERTY_HINT_RESOURCE_TYPE, "Font", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_STORE_IF_NULL));
  111. }
  112. }
  113. key = NULL;
  114. while ((key = color_map.next(key))) {
  115. const StringName *key2 = NULL;
  116. while ((key2 = color_map[*key].next(key2))) {
  117. list.push_back(PropertyInfo(Variant::COLOR, String() + *key + "/colors/" + *key2));
  118. }
  119. }
  120. key = NULL;
  121. while ((key = constant_map.next(key))) {
  122. const StringName *key2 = NULL;
  123. while ((key2 = constant_map[*key].next(key2))) {
  124. list.push_back(PropertyInfo(Variant::INT, String() + *key + "/constants/" + *key2));
  125. }
  126. }
  127. list.sort();
  128. for (List<PropertyInfo>::Element *E = list.front(); E; E = E->next()) {
  129. p_list->push_back(E->get());
  130. }
  131. }
  132. Ref<Theme> Theme::get_default() {
  133. return default_theme;
  134. }
  135. void Theme::set_default_theme_font(const Ref<Font> &p_default_font) {
  136. if (default_theme_font == p_default_font)
  137. return;
  138. if (default_theme_font.is_valid()) {
  139. default_theme_font->disconnect("changed", this, "_emit_theme_changed");
  140. }
  141. default_theme_font = p_default_font;
  142. if (default_theme_font.is_valid()) {
  143. default_theme_font->connect("changed", this, "_emit_theme_changed", varray(), CONNECT_REFERENCE_COUNTED);
  144. }
  145. _change_notify();
  146. emit_changed();
  147. }
  148. Ref<Font> Theme::get_default_theme_font() const {
  149. return default_theme_font;
  150. }
  151. void Theme::set_default(const Ref<Theme> &p_default) {
  152. default_theme = p_default;
  153. }
  154. Ref<Texture> Theme::default_icon;
  155. Ref<StyleBox> Theme::default_style;
  156. Ref<Font> Theme::default_font;
  157. void Theme::set_default_icon(const Ref<Texture> &p_icon) {
  158. default_icon = p_icon;
  159. }
  160. void Theme::set_default_style(const Ref<StyleBox> &p_style) {
  161. default_style = p_style;
  162. }
  163. void Theme::set_default_font(const Ref<Font> &p_font) {
  164. default_font = p_font;
  165. }
  166. void Theme::set_icon(const StringName &p_name, const StringName &p_type, const Ref<Texture> &p_icon) {
  167. //ERR_FAIL_COND(p_icon.is_null());
  168. bool new_value = !icon_map.has(p_type) || !icon_map[p_type].has(p_name);
  169. if (icon_map[p_type].has(p_name) && icon_map[p_type][p_name].is_valid()) {
  170. icon_map[p_type][p_name]->disconnect("changed", this, "_emit_theme_changed");
  171. }
  172. icon_map[p_type][p_name] = p_icon;
  173. if (p_icon.is_valid()) {
  174. icon_map[p_type][p_name]->connect("changed", this, "_emit_theme_changed", varray(), CONNECT_REFERENCE_COUNTED);
  175. }
  176. if (new_value) {
  177. _change_notify();
  178. emit_changed();
  179. }
  180. }
  181. Ref<Texture> Theme::get_icon(const StringName &p_name, const StringName &p_type) const {
  182. if (icon_map.has(p_type) && icon_map[p_type].has(p_name) && icon_map[p_type][p_name].is_valid()) {
  183. return icon_map[p_type][p_name];
  184. } else {
  185. return default_icon;
  186. }
  187. }
  188. bool Theme::has_icon(const StringName &p_name, const StringName &p_type) const {
  189. return (icon_map.has(p_type) && icon_map[p_type].has(p_name) && icon_map[p_type][p_name].is_valid());
  190. }
  191. void Theme::clear_icon(const StringName &p_name, const StringName &p_type) {
  192. ERR_FAIL_COND(!icon_map.has(p_type));
  193. ERR_FAIL_COND(!icon_map[p_type].has(p_name));
  194. if (icon_map[p_type][p_name].is_valid()) {
  195. icon_map[p_type][p_name]->disconnect("changed", this, "_emit_theme_changed");
  196. }
  197. icon_map[p_type].erase(p_name);
  198. _change_notify();
  199. emit_changed();
  200. }
  201. void Theme::get_icon_list(StringName p_type, List<StringName> *p_list) const {
  202. if (!icon_map.has(p_type))
  203. return;
  204. const StringName *key = NULL;
  205. while ((key = icon_map[p_type].next(key))) {
  206. p_list->push_back(*key);
  207. }
  208. }
  209. void Theme::set_shader(const StringName &p_name, const StringName &p_type, const Ref<Shader> &p_shader) {
  210. bool new_value = !shader_map.has(p_type) || !shader_map[p_type].has(p_name);
  211. shader_map[p_type][p_name] = p_shader;
  212. if (new_value) {
  213. _change_notify();
  214. emit_changed();
  215. }
  216. }
  217. Ref<Shader> Theme::get_shader(const StringName &p_name, const StringName &p_type) const {
  218. if (shader_map.has(p_type) && shader_map[p_type].has(p_name) && shader_map[p_type][p_name].is_valid()) {
  219. return shader_map[p_type][p_name];
  220. } else {
  221. return NULL;
  222. }
  223. }
  224. bool Theme::has_shader(const StringName &p_name, const StringName &p_type) const {
  225. return (shader_map.has(p_type) && shader_map[p_type].has(p_name) && shader_map[p_type][p_name].is_valid());
  226. }
  227. void Theme::clear_shader(const StringName &p_name, const StringName &p_type) {
  228. ERR_FAIL_COND(!shader_map.has(p_type));
  229. ERR_FAIL_COND(!shader_map[p_type].has(p_name));
  230. shader_map[p_type].erase(p_name);
  231. _change_notify();
  232. emit_changed();
  233. }
  234. void Theme::get_shader_list(const StringName &p_type, List<StringName> *p_list) const {
  235. if (!shader_map.has(p_type))
  236. return;
  237. const StringName *key = NULL;
  238. while ((key = shader_map[p_type].next(key))) {
  239. p_list->push_back(*key);
  240. }
  241. }
  242. void Theme::set_stylebox(const StringName &p_name, const StringName &p_type, const Ref<StyleBox> &p_style) {
  243. //ERR_FAIL_COND(p_style.is_null());
  244. bool new_value = !style_map.has(p_type) || !style_map[p_type].has(p_name);
  245. if (style_map[p_type].has(p_name) && style_map[p_type][p_name].is_valid()) {
  246. style_map[p_type][p_name]->disconnect("changed", this, "_emit_theme_changed");
  247. }
  248. style_map[p_type][p_name] = p_style;
  249. if (p_style.is_valid()) {
  250. style_map[p_type][p_name]->connect("changed", this, "_emit_theme_changed", varray(), CONNECT_REFERENCE_COUNTED);
  251. }
  252. if (new_value)
  253. _change_notify();
  254. emit_changed();
  255. }
  256. Ref<StyleBox> Theme::get_stylebox(const StringName &p_name, const StringName &p_type) const {
  257. if (style_map.has(p_type) && style_map[p_type].has(p_name) && style_map[p_type][p_name].is_valid()) {
  258. return style_map[p_type][p_name];
  259. } else {
  260. return default_style;
  261. }
  262. }
  263. bool Theme::has_stylebox(const StringName &p_name, const StringName &p_type) const {
  264. return (style_map.has(p_type) && style_map[p_type].has(p_name) && style_map[p_type][p_name].is_valid());
  265. }
  266. void Theme::clear_stylebox(const StringName &p_name, const StringName &p_type) {
  267. ERR_FAIL_COND(!style_map.has(p_type));
  268. ERR_FAIL_COND(!style_map[p_type].has(p_name));
  269. if (style_map[p_type][p_name].is_valid()) {
  270. style_map[p_type][p_name]->disconnect("changed", this, "_emit_theme_changed");
  271. }
  272. style_map[p_type].erase(p_name);
  273. _change_notify();
  274. emit_changed();
  275. }
  276. void Theme::get_stylebox_list(StringName p_type, List<StringName> *p_list) const {
  277. if (!style_map.has(p_type))
  278. return;
  279. const StringName *key = NULL;
  280. while ((key = style_map[p_type].next(key))) {
  281. p_list->push_back(*key);
  282. }
  283. }
  284. void Theme::get_stylebox_types(List<StringName> *p_list) const {
  285. const StringName *key = NULL;
  286. while ((key = style_map.next(key))) {
  287. p_list->push_back(*key);
  288. }
  289. }
  290. void Theme::set_font(const StringName &p_name, const StringName &p_type, const Ref<Font> &p_font) {
  291. //ERR_FAIL_COND(p_font.is_null());
  292. bool new_value = !font_map.has(p_type) || !font_map[p_type].has(p_name);
  293. if (font_map[p_type][p_name].is_valid()) {
  294. font_map[p_type][p_name]->disconnect("changed", this, "_emit_theme_changed");
  295. }
  296. font_map[p_type][p_name] = p_font;
  297. if (p_font.is_valid()) {
  298. font_map[p_type][p_name]->connect("changed", this, "_emit_theme_changed", varray(), CONNECT_REFERENCE_COUNTED);
  299. }
  300. if (new_value) {
  301. _change_notify();
  302. emit_changed();
  303. }
  304. }
  305. Ref<Font> Theme::get_font(const StringName &p_name, const StringName &p_type) const {
  306. if (font_map.has(p_type) && font_map[p_type].has(p_name) && font_map[p_type][p_name].is_valid())
  307. return font_map[p_type][p_name];
  308. else if (default_theme_font.is_valid())
  309. return default_theme_font;
  310. else
  311. return default_font;
  312. }
  313. bool Theme::has_font(const StringName &p_name, const StringName &p_type) const {
  314. return (font_map.has(p_type) && font_map[p_type].has(p_name) && font_map[p_type][p_name].is_valid());
  315. }
  316. void Theme::clear_font(const StringName &p_name, const StringName &p_type) {
  317. ERR_FAIL_COND(!font_map.has(p_type));
  318. ERR_FAIL_COND(!font_map[p_type].has(p_name));
  319. if (font_map[p_type][p_name].is_valid()) {
  320. font_map[p_type][p_name]->disconnect("changed", this, "_emit_theme_changed");
  321. }
  322. font_map[p_type].erase(p_name);
  323. _change_notify();
  324. emit_changed();
  325. }
  326. void Theme::get_font_list(StringName p_type, List<StringName> *p_list) const {
  327. if (!font_map.has(p_type))
  328. return;
  329. const StringName *key = NULL;
  330. while ((key = font_map[p_type].next(key))) {
  331. p_list->push_back(*key);
  332. }
  333. }
  334. void Theme::set_color(const StringName &p_name, const StringName &p_type, const Color &p_color) {
  335. bool new_value = !color_map.has(p_type) || !color_map[p_type].has(p_name);
  336. color_map[p_type][p_name] = p_color;
  337. if (new_value) {
  338. _change_notify();
  339. emit_changed();
  340. }
  341. }
  342. Color Theme::get_color(const StringName &p_name, const StringName &p_type) const {
  343. if (color_map.has(p_type) && color_map[p_type].has(p_name))
  344. return color_map[p_type][p_name];
  345. else
  346. return Color();
  347. }
  348. bool Theme::has_color(const StringName &p_name, const StringName &p_type) const {
  349. return (color_map.has(p_type) && color_map[p_type].has(p_name));
  350. }
  351. void Theme::clear_color(const StringName &p_name, const StringName &p_type) {
  352. ERR_FAIL_COND(!color_map.has(p_type));
  353. ERR_FAIL_COND(!color_map[p_type].has(p_name));
  354. color_map[p_type].erase(p_name);
  355. _change_notify();
  356. emit_changed();
  357. }
  358. void Theme::get_color_list(StringName p_type, List<StringName> *p_list) const {
  359. if (!color_map.has(p_type))
  360. return;
  361. const StringName *key = NULL;
  362. while ((key = color_map[p_type].next(key))) {
  363. p_list->push_back(*key);
  364. }
  365. }
  366. void Theme::set_constant(const StringName &p_name, const StringName &p_type, int p_constant) {
  367. bool new_value = !constant_map.has(p_type) || !constant_map[p_type].has(p_name);
  368. constant_map[p_type][p_name] = p_constant;
  369. if (new_value) {
  370. _change_notify();
  371. emit_changed();
  372. }
  373. }
  374. int Theme::get_constant(const StringName &p_name, const StringName &p_type) const {
  375. if (constant_map.has(p_type) && constant_map[p_type].has(p_name))
  376. return constant_map[p_type][p_name];
  377. else {
  378. return 0;
  379. }
  380. }
  381. bool Theme::has_constant(const StringName &p_name, const StringName &p_type) const {
  382. return (constant_map.has(p_type) && constant_map[p_type].has(p_name));
  383. }
  384. void Theme::clear_constant(const StringName &p_name, const StringName &p_type) {
  385. ERR_FAIL_COND(!constant_map.has(p_type));
  386. ERR_FAIL_COND(!constant_map[p_type].has(p_name));
  387. constant_map[p_type].erase(p_name);
  388. _change_notify();
  389. emit_changed();
  390. }
  391. void Theme::get_constant_list(StringName p_type, List<StringName> *p_list) const {
  392. if (!constant_map.has(p_type))
  393. return;
  394. const StringName *key = NULL;
  395. while ((key = constant_map[p_type].next(key))) {
  396. p_list->push_back(*key);
  397. }
  398. }
  399. void Theme::clear() {
  400. //these need disconnecting
  401. {
  402. const StringName *K = NULL;
  403. while ((K = icon_map.next(K))) {
  404. const StringName *L = NULL;
  405. while ((L = icon_map[*K].next(L))) {
  406. icon_map[*K][*L]->disconnect("changed", this, "_emit_theme_changed");
  407. }
  408. }
  409. }
  410. {
  411. const StringName *K = NULL;
  412. while ((K = style_map.next(K))) {
  413. const StringName *L = NULL;
  414. while ((L = style_map[*K].next(L))) {
  415. style_map[*K][*L]->disconnect("changed", this, "_emit_theme_changed");
  416. }
  417. }
  418. }
  419. {
  420. const StringName *K = NULL;
  421. while ((K = font_map.next(K))) {
  422. const StringName *L = NULL;
  423. while ((L = font_map[*K].next(L))) {
  424. font_map[*K][*L]->disconnect("changed", this, "_emit_theme_changed");
  425. }
  426. }
  427. }
  428. icon_map.clear();
  429. style_map.clear();
  430. font_map.clear();
  431. shader_map.clear();
  432. color_map.clear();
  433. constant_map.clear();
  434. _change_notify();
  435. emit_changed();
  436. }
  437. void Theme::copy_default_theme() {
  438. Ref<Theme> default_theme = get_default();
  439. //these need reconnecting, so add normally
  440. {
  441. const StringName *K = NULL;
  442. while ((K = default_theme->icon_map.next(K))) {
  443. const StringName *L = NULL;
  444. while ((L = default_theme->icon_map[*K].next(L))) {
  445. set_icon(*K, *L, default_theme->icon_map[*K][*L]);
  446. }
  447. }
  448. }
  449. {
  450. const StringName *K = NULL;
  451. while ((K = default_theme->style_map.next(K))) {
  452. const StringName *L = NULL;
  453. while ((L = default_theme->style_map[*K].next(L))) {
  454. set_stylebox(*K, *L, default_theme->style_map[*K][*L]);
  455. }
  456. }
  457. }
  458. {
  459. const StringName *K = NULL;
  460. while ((K = default_theme->font_map.next(K))) {
  461. const StringName *L = NULL;
  462. while ((L = default_theme->font_map[*K].next(L))) {
  463. set_font(*K, *L, default_theme->font_map[*K][*L]);
  464. }
  465. }
  466. }
  467. //these are ok to just copy
  468. color_map = default_theme->color_map;
  469. constant_map = default_theme->constant_map;
  470. shader_map = default_theme->shader_map;
  471. _change_notify();
  472. emit_changed();
  473. }
  474. void Theme::get_type_list(List<StringName> *p_list) const {
  475. Set<StringName> types;
  476. const StringName *key = NULL;
  477. while ((key = icon_map.next(key))) {
  478. types.insert(*key);
  479. }
  480. key = NULL;
  481. while ((key = style_map.next(key))) {
  482. types.insert(*key);
  483. }
  484. key = NULL;
  485. while ((key = font_map.next(key))) {
  486. types.insert(*key);
  487. }
  488. key = NULL;
  489. while ((key = color_map.next(key))) {
  490. types.insert(*key);
  491. }
  492. key = NULL;
  493. while ((key = constant_map.next(key))) {
  494. types.insert(*key);
  495. }
  496. for (Set<StringName>::Element *E = types.front(); E; E = E->next()) {
  497. p_list->push_back(E->get());
  498. }
  499. }
  500. void Theme::_bind_methods() {
  501. ClassDB::bind_method(D_METHOD("set_icon", "name", "type", "texture"), &Theme::set_icon);
  502. ClassDB::bind_method(D_METHOD("get_icon", "name", "type"), &Theme::get_icon);
  503. ClassDB::bind_method(D_METHOD("has_icon", "name", "type"), &Theme::has_icon);
  504. ClassDB::bind_method(D_METHOD("clear_icon", "name", "type"), &Theme::clear_icon);
  505. ClassDB::bind_method(D_METHOD("get_icon_list", "type"), &Theme::_get_icon_list);
  506. ClassDB::bind_method(D_METHOD("set_stylebox", "name", "type", "texture"), &Theme::set_stylebox);
  507. ClassDB::bind_method(D_METHOD("get_stylebox", "name", "type"), &Theme::get_stylebox);
  508. ClassDB::bind_method(D_METHOD("has_stylebox", "name", "type"), &Theme::has_stylebox);
  509. ClassDB::bind_method(D_METHOD("clear_stylebox", "name", "type"), &Theme::clear_stylebox);
  510. ClassDB::bind_method(D_METHOD("get_stylebox_list", "type"), &Theme::_get_stylebox_list);
  511. ClassDB::bind_method(D_METHOD("get_stylebox_types"), &Theme::_get_stylebox_types);
  512. ClassDB::bind_method(D_METHOD("set_font", "name", "type", "font"), &Theme::set_font);
  513. ClassDB::bind_method(D_METHOD("get_font", "name", "type"), &Theme::get_font);
  514. ClassDB::bind_method(D_METHOD("has_font", "name", "type"), &Theme::has_font);
  515. ClassDB::bind_method(D_METHOD("clear_font", "name", "type"), &Theme::clear_font);
  516. ClassDB::bind_method(D_METHOD("get_font_list", "type"), &Theme::_get_font_list);
  517. ClassDB::bind_method(D_METHOD("set_color", "name", "type", "color"), &Theme::set_color);
  518. ClassDB::bind_method(D_METHOD("get_color", "name", "type"), &Theme::get_color);
  519. ClassDB::bind_method(D_METHOD("has_color", "name", "type"), &Theme::has_color);
  520. ClassDB::bind_method(D_METHOD("clear_color", "name", "type"), &Theme::clear_color);
  521. ClassDB::bind_method(D_METHOD("get_color_list", "type"), &Theme::_get_color_list);
  522. ClassDB::bind_method(D_METHOD("set_constant", "name", "type", "constant"), &Theme::set_constant);
  523. ClassDB::bind_method(D_METHOD("get_constant", "name", "type"), &Theme::get_constant);
  524. ClassDB::bind_method(D_METHOD("has_constant", "name", "type"), &Theme::has_constant);
  525. ClassDB::bind_method(D_METHOD("clear_constant", "name", "type"), &Theme::clear_constant);
  526. ClassDB::bind_method(D_METHOD("get_constant_list", "type"), &Theme::_get_constant_list);
  527. ClassDB::bind_method(D_METHOD("clear"), &Theme::clear);
  528. ClassDB::bind_method(D_METHOD("set_default_font", "font"), &Theme::set_default_theme_font);
  529. ClassDB::bind_method(D_METHOD("get_default_font"), &Theme::get_default_theme_font);
  530. ClassDB::bind_method(D_METHOD("get_type_list", "type"), &Theme::_get_type_list);
  531. ClassDB::bind_method(D_METHOD("_emit_theme_changed"), &Theme::_emit_theme_changed);
  532. ClassDB::bind_method("copy_default_theme", &Theme::copy_default_theme);
  533. ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "default_font", PROPERTY_HINT_RESOURCE_TYPE, "Font"), "set_default_font", "get_default_font");
  534. }
  535. Theme::Theme() {
  536. }
  537. Theme::~Theme() {
  538. }