| 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 "core/io/resource.h" |
| 34 |
#include "font.h" |
| 35 |
#include "scene/property_list_helper.h" |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
class LabelSettings : public Resource { |
| 40 |
GDCLASS(LabelSettings, Resource); |
| 41 |
|
| 42 |
public: |
| 43 |
struct StackedOutlineData { |
| 44 |
int32_t size = 0; |
| 45 |
Color color; |
| 46 |
}; |
| 47 |
struct StackedShadowData { |
| 48 |
Vector2i offset = Vector2i(1, 1); |
| 49 |
Color color; |
| 50 |
int32_t outline_size = 0; |
| 51 |
}; |
| 52 |
|
| 53 |
private: |
| 54 |
real_t line_spacing = 3; |
| 55 |
real_t paragraph_spacing = 0; |
| 56 |
|
| 57 |
Ref<Font> font; |
| 58 |
int font_size = Font::DEFAULT_FONT_SIZE; |
| 59 |
Color font_color = Color(1, 1, 1); |
| 60 |
|
| 61 |
int outline_size = 0; |
| 62 |
Color outline_color = Color(1, 1, 1); |
| 63 |
|
| 64 |
int shadow_size = 1; |
| 65 |
Color shadow_color = Color(0, 0, 0, 0); |
| 66 |
Vector2 shadow_offset = Vector2(1, 1); |
| 67 |
|
| 68 |
Vector<StackedOutlineData> stacked_outline_data; |
| 69 |
Vector<StackedShadowData> stacked_shadow_data; |
| 70 |
|
| 71 |
static inline PropertyListHelper stacked_outline_base_property_helper; |
| 72 |
static inline PropertyListHelper stacked_shadow_base_property_helper; |
| 73 |
PropertyListHelper stacked_outline_property_helper; |
| 74 |
PropertyListHelper stacked_shadow_property_helper; |
| 75 |
|
| 76 |
void _font_changed(); |
| 77 |
|
| 78 |
protected: |
| 79 |
static void _bind_methods(); |
| 80 |
bool _set(const StringName &p_name, const Variant &p_value) { |
| 81 |
return stacked_outline_property_helper.property_set_value(p_name, p_value) || stacked_shadow_property_helper.property_set_value(p_name, p_value); |
| 82 |
} |
| 83 |
bool _get(const StringName &p_name, Variant &r_ret) const { |
| 84 |
return stacked_outline_property_helper.property_get_value(p_name, r_ret) || stacked_shadow_property_helper.property_get_value(p_name, r_ret); |
| 85 |
} |
| 86 |
void _get_property_list(List<PropertyInfo> *p_list) const { |
| 87 |
stacked_outline_property_helper.get_property_list(p_list); |
| 88 |
stacked_shadow_property_helper.get_property_list(p_list); |
| 89 |
} |
| 90 |
bool _property_can_revert(const StringName &p_name) const { |
| 91 |
return stacked_outline_property_helper.property_can_revert(p_name) || stacked_shadow_property_helper.property_can_revert(p_name); |
| 92 |
} |
| 93 |
bool _property_get_revert(const StringName &p_name, Variant &r_property) const { |
| 94 |
return stacked_outline_property_helper.property_get_revert(p_name, r_property) || stacked_shadow_property_helper.property_get_revert(p_name, r_property); |
| 95 |
} |
| 96 |
|
| 97 |
public: |
| 98 |
void set_line_spacing(real_t p_spacing); |
| 99 |
real_t get_line_spacing() const; |
| 100 |
|
| 101 |
void set_paragraph_spacing(real_t p_spacing); |
| 102 |
real_t get_paragraph_spacing() const; |
| 103 |
|
| 104 |
void set_font(const Ref<Font> &p_font); |
| 105 |
Ref<Font> get_font() const; |
| 106 |
|
| 107 |
void set_font_size(int p_size); |
| 108 |
int get_font_size() const; |
| 109 |
|
| 110 |
void set_font_color(const Color &p_color); |
| 111 |
Color get_font_color() const; |
| 112 |
|
| 113 |
void set_outline_size(int p_size); |
| 114 |
int get_outline_size() const; |
| 115 |
|
| 116 |
void set_outline_color(const Color &p_color); |
| 117 |
Color get_outline_color() const; |
| 118 |
|
| 119 |
void set_shadow_size(int p_size); |
| 120 |
int get_shadow_size() const; |
| 121 |
|
| 122 |
void set_shadow_color(const Color &p_color); |
| 123 |
Color get_shadow_color() const; |
| 124 |
|
| 125 |
void set_shadow_offset(const Vector2 &p_offset); |
| 126 |
Vector2 get_shadow_offset() const; |
| 127 |
|
| 128 |
Vector<StackedOutlineData> get_stacked_outline_data() const; |
| 129 |
int get_stacked_outline_count() const; |
| 130 |
void set_stacked_outline_count(int p_count); |
| 131 |
void add_stacked_outline(int p_index = -1); |
| 132 |
void move_stacked_outline(int p_from_index, int p_to_position); |
| 133 |
void remove_stacked_outline(int p_index); |
| 134 |
void set_stacked_outline_size(int p_index, int p_size); |
| 135 |
int get_stacked_outline_size(int p_index) const; |
| 136 |
void set_stacked_outline_color(int p_index, const Color &p_color); |
| 137 |
Color get_stacked_outline_color(int p_index) const; |
| 138 |
|
| 139 |
Vector<StackedShadowData> get_stacked_shadow_data() const; |
| 140 |
int get_stacked_shadow_count() const; |
| 141 |
void set_stacked_shadow_count(int p_count); |
| 142 |
void add_stacked_shadow(int p_index = -1); |
| 143 |
void move_stacked_shadow(int p_from_index, int p_to_position); |
| 144 |
void remove_stacked_shadow(int p_index); |
| 145 |
void set_stacked_shadow_offset(int p_index, const Vector2 &p_offset); |
| 146 |
Vector2 get_stacked_shadow_offset(int p_index) const; |
| 147 |
void set_stacked_shadow_color(int p_index, const Color &p_color); |
| 148 |
Color get_stacked_shadow_color(int p_index) const; |
| 149 |
void set_stacked_shadow_outline_size(int p_index, int p_size); |
| 150 |
int get_stacked_shadow_outline_size(int p_index) const; |
| 151 |
|
| 152 |
LabelSettings() { |
| 153 |
stacked_outline_property_helper.setup_for_instance(stacked_outline_base_property_helper, this); |
| 154 |
stacked_shadow_property_helper.setup_for_instance(stacked_shadow_base_property_helper, this); |
| 155 |
} |
| 156 |
}; |