texture_progress.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*************************************************************************/
  2. /* texture_progress.h */
  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. #ifndef TEXTURE_PROGRESS_H
  31. #define TEXTURE_PROGRESS_H
  32. #include "scene/gui/range.h"
  33. class TextureProgress : public Range {
  34. GDCLASS(TextureProgress, Range);
  35. Ref<Texture> under;
  36. Ref<Texture> progress;
  37. Ref<Texture> over;
  38. protected:
  39. static void _bind_methods();
  40. void _notification(int p_what);
  41. public:
  42. enum FillMode {
  43. FILL_LEFT_TO_RIGHT = 0,
  44. FILL_RIGHT_TO_LEFT,
  45. FILL_TOP_TO_BOTTOM,
  46. FILL_BOTTOM_TO_TOP,
  47. FILL_CLOCKWISE,
  48. FILL_COUNTER_CLOCKWISE,
  49. FILL_BILINEAR_LEFT_AND_RIGHT,
  50. FILL_BILINEAR_TOP_AND_BOTTOM,
  51. FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE
  52. };
  53. void set_fill_mode(int p_fill);
  54. int get_fill_mode();
  55. void set_radial_initial_angle(float p_angle);
  56. float get_radial_initial_angle();
  57. void set_fill_degrees(float p_angle);
  58. float get_fill_degrees();
  59. void set_radial_center_offset(const Point2 &p_off);
  60. Point2 get_radial_center_offset();
  61. void set_under_texture(const Ref<Texture> &p_texture);
  62. Ref<Texture> get_under_texture() const;
  63. void set_progress_texture(const Ref<Texture> &p_texture);
  64. Ref<Texture> get_progress_texture() const;
  65. void set_over_texture(const Ref<Texture> &p_texture);
  66. Ref<Texture> get_over_texture() const;
  67. void set_stretch_margin(Margin p_margin, int p_size);
  68. int get_stretch_margin(Margin p_margin) const;
  69. void set_nine_patch_stretch(bool p_stretch);
  70. bool get_nine_patch_stretch() const;
  71. void set_tint_under(const Color &p_tint);
  72. Color get_tint_under() const;
  73. void set_tint_progress(const Color &p_tint);
  74. Color get_tint_progress() const;
  75. void set_tint_over(const Color &p_tint);
  76. Color get_tint_over() const;
  77. Size2 get_minimum_size() const;
  78. TextureProgress();
  79. private:
  80. FillMode mode;
  81. float rad_init_angle;
  82. float rad_max_degrees;
  83. Point2 rad_center_off;
  84. bool nine_patch_stretch;
  85. int stretch_margin[4];
  86. Color tint_under, tint_progress, tint_over;
  87. Point2 unit_val_to_uv(float val);
  88. Point2 get_relative_center();
  89. void draw_nine_patch_stretched(const Ref<Texture> &p_texture, FillMode p_mode, double p_ratio, const Color &p_modulate);
  90. };
  91. VARIANT_ENUM_CAST(TextureProgress::FillMode);
  92. #endif // TEXTURE_PROGRESS_H