| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "scene/gui/range.h" |
| 34 |
|
| 35 |
class TextureProgressBar : public Range { |
| 36 |
GDCLASS(TextureProgressBar, Range); |
| 37 |
|
| 38 |
Ref<Texture2D> under; |
| 39 |
Ref<Texture2D> progress; |
| 40 |
Ref<Texture2D> over; |
| 41 |
|
| 42 |
protected: |
| 43 |
static void _bind_methods(); |
| 44 |
void _notification(int p_what); |
| 45 |
void _validate_property(PropertyInfo &p_property) const; |
| 46 |
|
| 47 |
public: |
| 48 |
enum FillMode { |
| 49 |
FILL_LEFT_TO_RIGHT = 0, |
| 50 |
FILL_RIGHT_TO_LEFT, |
| 51 |
FILL_TOP_TO_BOTTOM, |
| 52 |
FILL_BOTTOM_TO_TOP, |
| 53 |
FILL_CLOCKWISE, |
| 54 |
FILL_COUNTER_CLOCKWISE, |
| 55 |
FILL_BILINEAR_LEFT_AND_RIGHT, |
| 56 |
FILL_BILINEAR_TOP_AND_BOTTOM, |
| 57 |
FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE, |
| 58 |
FILL_MODE_MAX, |
| 59 |
}; |
| 60 |
|
| 61 |
void set_fill_mode(int p_fill); |
| 62 |
int get_fill_mode(); |
| 63 |
|
| 64 |
void set_progress_offset(Point2 p_offset); |
| 65 |
Point2 get_progress_offset() const; |
| 66 |
|
| 67 |
void set_radial_initial_angle(float p_angle); |
| 68 |
float get_radial_initial_angle(); |
| 69 |
|
| 70 |
void set_fill_degrees(float p_angle); |
| 71 |
float get_fill_degrees(); |
| 72 |
|
| 73 |
void set_radial_center_offset(const Point2 &p_off); |
| 74 |
Point2 get_radial_center_offset(); |
| 75 |
|
| 76 |
void set_under_texture(const Ref<Texture2D> &p_texture); |
| 77 |
Ref<Texture2D> get_under_texture() const; |
| 78 |
|
| 79 |
void set_progress_texture(const Ref<Texture2D> &p_texture); |
| 80 |
Ref<Texture2D> get_progress_texture() const; |
| 81 |
|
| 82 |
void set_over_texture(const Ref<Texture2D> &p_texture); |
| 83 |
Ref<Texture2D> get_over_texture() const; |
| 84 |
|
| 85 |
void set_stretch_margin(Side p_side, int p_size); |
| 86 |
int get_stretch_margin(Side p_side) const; |
| 87 |
|
| 88 |
void set_nine_patch_stretch(bool p_stretch); |
| 89 |
bool get_nine_patch_stretch() const; |
| 90 |
|
| 91 |
void set_tint_under(const Color &p_tint); |
| 92 |
Color get_tint_under() const; |
| 93 |
|
| 94 |
void set_tint_progress(const Color &p_tint); |
| 95 |
Color get_tint_progress() const; |
| 96 |
|
| 97 |
void set_tint_over(const Color &p_tint); |
| 98 |
Color get_tint_over() const; |
| 99 |
|
| 100 |
Size2 get_minimum_size() const override; |
| 101 |
|
| 102 |
TextureProgressBar(); |
| 103 |
|
| 104 |
private: |
| 105 |
FillMode mode = FILL_LEFT_TO_RIGHT; |
| 106 |
Point2 progress_offset; |
| 107 |
float rad_init_angle = 0.0; |
| 108 |
float rad_max_degrees = 360.0; |
| 109 |
Point2 rad_center_off; |
| 110 |
bool nine_patch_stretch = false; |
| 111 |
int stretch_margin[4] = {}; |
| 112 |
Color tint_under = Color(1, 1, 1); |
| 113 |
Color tint_progress = Color(1, 1, 1); |
| 114 |
Color tint_over = Color(1, 1, 1); |
| 115 |
|
| 116 |
void _set_texture(Ref<Texture2D> *p_destination, const Ref<Texture2D> &p_texture); |
| 117 |
void _texture_changed(); |
| 118 |
Point2 unit_val_to_uv(float val); |
| 119 |
Point2 get_relative_center(); |
| 120 |
void draw_nine_patch_stretched(const Ref<Texture2D> &p_texture, FillMode p_mode, double p_ratio, const Color &p_modulate); |
| 121 |
}; |
| 122 |
|
| 123 |
VARIANT_ENUM_CAST(TextureProgressBar::FillMode); |