texture_progress.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*************************************************************************/
  2. /* texture_progress.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2017 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. };
  50. void set_fill_mode(int p_fill);
  51. int get_fill_mode();
  52. void set_radial_initial_angle(float p_angle);
  53. float get_radial_initial_angle();
  54. void set_fill_degrees(float p_angle);
  55. float get_fill_degrees();
  56. void set_radial_center_offset(const Point2 &p_off);
  57. Point2 get_radial_center_offset();
  58. void set_under_texture(const Ref<Texture> &p_texture);
  59. Ref<Texture> get_under_texture() const;
  60. void set_progress_texture(const Ref<Texture> &p_texture);
  61. Ref<Texture> get_progress_texture() const;
  62. void set_over_texture(const Ref<Texture> &p_texture);
  63. Ref<Texture> get_over_texture() const;
  64. void set_stretch_margin(Margin p_margin, int p_size);
  65. int get_stretch_margin(Margin p_margin) const;
  66. void set_nine_patch_stretch(bool p_stretch);
  67. bool get_nine_patch_stretch() const;
  68. Size2 get_minimum_size() const;
  69. TextureProgress();
  70. private:
  71. FillMode mode;
  72. float rad_init_angle;
  73. float rad_max_degrees;
  74. Point2 rad_center_off;
  75. bool nine_patch_stretch;
  76. int stretch_margin[4];
  77. Point2 unit_val_to_uv(float val);
  78. Point2 get_relative_center();
  79. void draw_nine_patch_stretched(const Ref<Texture> &p_texture, FillMode p_mode, double p_ratio);
  80. };
  81. VARIANT_ENUM_CAST(TextureProgress::FillMode);
  82. #endif // TEXTURE_PROGRESS_H