rich_text_effect.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*************************************************************************/
  2. /* rich_text_effect.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2021 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 RICH_TEXT_EFFECT_H
  31. #define RICH_TEXT_EFFECT_H
  32. #include "core/io/resource.h"
  33. #include "core/object/gdvirtual.gen.inc"
  34. #include "core/object/script_language.h"
  35. class CharFXTransform : public RefCounted {
  36. GDCLASS(CharFXTransform, RefCounted);
  37. protected:
  38. static void _bind_methods();
  39. public:
  40. Vector2i range;
  41. bool visibility = true;
  42. bool outline = false;
  43. Point2 offset;
  44. Color color;
  45. double elapsed_time = 0.0f;
  46. Dictionary environment;
  47. uint32_t glyph_index = 0;
  48. uint16_t glyph_flags = 0;
  49. uint8_t glyph_count = 0;
  50. RID font;
  51. CharFXTransform();
  52. ~CharFXTransform();
  53. Vector2i get_range() { return range; }
  54. void set_range(const Vector2i &p_range) { range = p_range; }
  55. double get_elapsed_time() { return elapsed_time; }
  56. void set_elapsed_time(double p_elapsed_time) { elapsed_time = p_elapsed_time; }
  57. bool is_visible() { return visibility; }
  58. void set_visibility(bool p_visibility) { visibility = p_visibility; }
  59. bool is_outline() { return outline; }
  60. void set_outline(bool p_outline) { outline = p_outline; }
  61. Point2 get_offset() { return offset; }
  62. void set_offset(Point2 p_offset) { offset = p_offset; }
  63. Color get_color() { return color; }
  64. void set_color(Color p_color) { color = p_color; }
  65. uint32_t get_glyph_index() const { return glyph_index; };
  66. void set_glyph_index(uint32_t p_glyph_index) { glyph_index = p_glyph_index; };
  67. uint16_t get_glyph_flags() const { return glyph_index; };
  68. void set_glyph_flags(uint16_t p_glyph_flags) { glyph_flags = p_glyph_flags; };
  69. uint8_t get_glyph_count() const { return glyph_count; };
  70. void set_glyph_count(uint8_t p_glyph_count) { glyph_count = p_glyph_count; };
  71. RID get_font() const { return font; };
  72. void set_font(RID p_font) { font = p_font; };
  73. Dictionary get_environment() { return environment; }
  74. void set_environment(Dictionary p_environment) { environment = p_environment; }
  75. };
  76. class RichTextEffect : public Resource {
  77. GDCLASS(RichTextEffect, Resource);
  78. OBJ_SAVE_TYPE(RichTextEffect);
  79. protected:
  80. static void _bind_methods();
  81. GDVIRTUAL1RC(bool, _process_custom_fx, Ref<CharFXTransform>)
  82. public:
  83. Variant get_bbcode() const;
  84. bool _process_effect_impl(Ref<class CharFXTransform> p_cfx);
  85. RichTextEffect();
  86. };
  87. #endif // RICH_TEXT_EFFECT_H