theme_db.h 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*************************************************************************/
  2. /* theme_db.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2022 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. #ifndef THEME_DB_H
  31. #define THEME_DB_H
  32. #include "core/object/class_db.h"
  33. #include "core/object/ref_counted.h"
  34. class Font;
  35. class StyleBox;
  36. class Texture2D;
  37. class Theme;
  38. class ThemeDB : public Object {
  39. GDCLASS(ThemeDB, Object);
  40. static ThemeDB *singleton;
  41. // Universal Theme resources used when no other theme has the item.
  42. Ref<Theme> default_theme;
  43. Ref<Theme> project_theme;
  44. // Universal default values, final fallback for every theme.
  45. float fallback_base_scale;
  46. Ref<Font> fallback_font;
  47. int fallback_font_size;
  48. Ref<Texture2D> fallback_icon;
  49. Ref<StyleBox> fallback_stylebox;
  50. protected:
  51. static void _bind_methods();
  52. public:
  53. void initialize_theme();
  54. void initialize_theme_noproject();
  55. // Universal Theme resources
  56. void set_default_theme(const Ref<Theme> &p_default);
  57. Ref<Theme> get_default_theme();
  58. void set_project_theme(const Ref<Theme> &p_project_default);
  59. Ref<Theme> get_project_theme();
  60. // Universal default values.
  61. void set_fallback_base_scale(float p_base_scale);
  62. float get_fallback_base_scale();
  63. void set_fallback_font(const Ref<Font> &p_font);
  64. Ref<Font> get_fallback_font();
  65. void set_fallback_font_size(int p_font_size);
  66. int get_fallback_font_size();
  67. void set_fallback_icon(const Ref<Texture2D> &p_icon);
  68. Ref<Texture2D> get_fallback_icon();
  69. void set_fallback_stylebox(const Ref<StyleBox> &p_stylebox);
  70. Ref<StyleBox> get_fallback_stylebox();
  71. static ThemeDB *get_singleton();
  72. ThemeDB();
  73. ~ThemeDB();
  74. };
  75. #endif // THEME_DB_H