| 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/main/node.h" |
| 34 |
#include "scene/resources/font.h" |
| 35 |
#include "servers/rendering/rendering_server.h" |
| 36 |
|
| 37 |
class CanvasLayer; |
| 38 |
class MultiMesh; |
| 39 |
class StyleBox; |
| 40 |
class SubViewport; |
| 41 |
class Window; |
| 42 |
class World2D; |
| 43 |
|
| 44 |
class CanvasItem : public Node { |
| 45 |
GDCLASS(CanvasItem, Node); |
| 46 |
|
| 47 |
friend class CanvasLayer; |
| 48 |
|
| 49 |
public: |
| 50 |
static constexpr AncestralClass static_ancestral_class = AncestralClass::CANVAS_ITEM; |
| 51 |
|
| 52 |
enum TextureFilter { |
| 53 |
TEXTURE_FILTER_PARENT_NODE, |
| 54 |
TEXTURE_FILTER_NEAREST, |
| 55 |
TEXTURE_FILTER_LINEAR, |
| 56 |
TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, |
| 57 |
TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, |
| 58 |
TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, |
| 59 |
TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, |
| 60 |
TEXTURE_FILTER_MAX |
| 61 |
}; |
| 62 |
|
| 63 |
enum TextureRepeat { |
| 64 |
TEXTURE_REPEAT_PARENT_NODE, |
| 65 |
TEXTURE_REPEAT_DISABLED, |
| 66 |
TEXTURE_REPEAT_ENABLED, |
| 67 |
TEXTURE_REPEAT_MIRROR, |
| 68 |
TEXTURE_REPEAT_MAX, |
| 69 |
}; |
| 70 |
|
| 71 |
enum ClipChildrenMode { |
| 72 |
CLIP_CHILDREN_DISABLED, |
| 73 |
CLIP_CHILDREN_ONLY, |
| 74 |
CLIP_CHILDREN_AND_DRAW, |
| 75 |
CLIP_CHILDREN_MAX, |
| 76 |
}; |
| 77 |
|
| 78 |
private: |
| 79 |
mutable SelfList<Node> |
| 80 |
xform_change; |
| 81 |
|
| 82 |
RID canvas_item; |
| 83 |
StringName canvas_group; |
| 84 |
|
| 85 |
CanvasLayer *canvas_layer = nullptr; |
| 86 |
|
| 87 |
Color modulate = Color(1, 1, 1, 1); |
| 88 |
Color self_modulate = Color(1, 1, 1, 1); |
| 89 |
|
| 90 |
struct Data { |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
LocalVector<CanvasItem *> canvas_item_children; |
| 95 |
uint32_t index_in_parent = UINT32_MAX; |
| 96 |
} data; |
| 97 |
|
| 98 |
int light_mask = 1; |
| 99 |
uint32_t visibility_layer = 1; |
| 100 |
|
| 101 |
int z_index = 0; |
| 102 |
bool z_relative = true; |
| 103 |
bool y_sort_enabled = false; |
| 104 |
|
| 105 |
Window *window = nullptr; |
| 106 |
bool visible = true; |
| 107 |
bool parent_visible_in_tree = false; |
| 108 |
bool pending_update = false; |
| 109 |
bool draw_commands_dirty = false; |
| 110 |
bool top_level = false; |
| 111 |
bool drawing = false; |
| 112 |
bool block_transform_notify = false; |
| 113 |
bool behind = false; |
| 114 |
bool use_parent_material = false; |
| 115 |
bool notify_local_transform = false; |
| 116 |
bool notify_transform = false; |
| 117 |
bool hide_clip_children = false; |
| 118 |
|
| 119 |
ClipChildrenMode clip_children_mode = CLIP_CHILDREN_DISABLED; |
| 120 |
|
| 121 |
mutable RS::CanvasItemTextureFilter texture_filter_cache = RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR; |
| 122 |
mutable RS::CanvasItemTextureRepeat texture_repeat_cache = RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED; |
| 123 |
TextureFilter texture_filter = TEXTURE_FILTER_PARENT_NODE; |
| 124 |
TextureRepeat texture_repeat = TEXTURE_REPEAT_PARENT_NODE; |
| 125 |
|
| 126 |
Ref<Material> material; |
| 127 |
mutable HashMap<StringName, Variant> instance_shader_parameters; |
| 128 |
mutable HashMap<StringName, StringName> instance_shader_parameter_property_remap; |
| 129 |
|
| 130 |
mutable Transform2D global_transform; |
| 131 |
mutable MTFlag global_invalid; |
| 132 |
|
| 133 |
_FORCE_INLINE_ bool _is_global_invalid() const { return is_group_processing() ? global_invalid.mt.is_set() : global_invalid.st; } |
| 134 |
void _set_global_invalid(bool p_invalid) const; |
| 135 |
|
| 136 |
void _top_level_raise_self(); |
| 137 |
|
| 138 |
void _propagate_visibility_changed(bool p_parent_visible_in_tree); |
| 139 |
void _handle_visibility_change(bool p_visible); |
| 140 |
|
| 141 |
virtual void _top_level_changed(); |
| 142 |
virtual void _top_level_changed_on_parent(); |
| 143 |
|
| 144 |
void _redraw_callback(); |
| 145 |
|
| 146 |
void _enter_canvas(); |
| 147 |
void _exit_canvas(); |
| 148 |
|
| 149 |
void _window_visibility_changed(); |
| 150 |
|
| 151 |
void _notify_transform(CanvasItem *p_node); |
| 152 |
|
| 153 |
static CanvasItem *current_item_drawn; |
| 154 |
friend class Viewport; |
| 155 |
void _refresh_texture_repeat_cache() const; |
| 156 |
void _update_texture_repeat_changed(bool p_propagate); |
| 157 |
void _refresh_texture_filter_cache() const; |
| 158 |
void _update_texture_filter_changed(bool p_propagate); |
| 159 |
|
| 160 |
void _notify_transform_deferred(); |
| 161 |
const StringName *_instance_shader_parameter_get_remap(const StringName &p_name) const; |
| 162 |
|
| 163 |
protected: |
| 164 |
bool _set(const StringName &p_name, const Variant &p_value); |
| 165 |
bool _get(const StringName &p_name, Variant &r_ret) const; |
| 166 |
void _get_property_list(List<PropertyInfo> *p_list) const; |
| 167 |
|
| 168 |
virtual void _physics_interpolated_changed() override; |
| 169 |
|
| 170 |
virtual void _update_self_texture_repeat(RS::CanvasItemTextureRepeat p_texture_repeat); |
| 171 |
virtual void _update_self_texture_filter(RS::CanvasItemTextureFilter p_texture_filter); |
| 172 |
|
| 173 |
_FORCE_INLINE_ void _notify_transform() { |
| 174 |
_notify_transform(this); |
| 175 |
if (is_inside_tree() && !block_transform_notify && notify_local_transform) { |
| 176 |
notification(NOTIFICATION_LOCAL_TRANSFORM_CHANGED); |
| 177 |
} |
| 178 |
} |
| 179 |
|
| 180 |
void item_rect_changed(bool p_size_changed = true); |
| 181 |
|
| 182 |
void set_canvas_item_use_identity_transform(bool p_enable); |
| 183 |
|
| 184 |
void _notification(int p_what); |
| 185 |
static void _bind_methods(); |
| 186 |
|
| 187 |
#ifndef DISABLE_DEPRECATED |
| 188 |
void _draw_string_bind_compat_104872(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment = HORIZONTAL_ALIGNMENT_LEFT, float p_width = -1, int p_font_size = Font::DEFAULT_FONT_SIZE, const Color &p_modulate = Color(1.0, 1.0, 1.0), BitField<TextServer::JustificationFlag> p_jst_flags = TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND, TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL) const; |
| 189 |
void _draw_multiline_string_bind_compat_104872(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment = HORIZONTAL_ALIGNMENT_LEFT, float p_width = -1, int p_font_size = Font::DEFAULT_FONT_SIZE, int p_max_lines = -1, const Color &p_modulate = Color(1.0, 1.0, 1.0), BitField<TextServer::LineBreakFlag> p_brk_flags = TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND, BitField<TextServer::JustificationFlag> p_jst_flags = TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND, TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL) const; |
| 190 |
void _draw_string_outline_bind_compat_104872(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment = HORIZONTAL_ALIGNMENT_LEFT, float p_width = -1, int p_font_size = Font::DEFAULT_FONT_SIZE, int p_size = 1, const Color &p_modulate = Color(1.0, 1.0, 1.0), BitField<TextServer::JustificationFlag> p_jst_flags = TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND, TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL) const; |
| 191 |
void _draw_multiline_string_outline_bind_compat_104872(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment = HORIZONTAL_ALIGNMENT_LEFT, float p_width = -1, int p_font_size = Font::DEFAULT_FONT_SIZE, int p_max_lines = -1, int p_size = 1, const Color &p_modulate = Color(1.0, 1.0, 1.0), BitField<TextServer::LineBreakFlag> p_brk_flags = TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND, BitField<TextServer::JustificationFlag> p_jst_flags = TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND, TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL) const; |
| 192 |
void _draw_char_bind_compat_104872(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_char, int p_font_size = Font::DEFAULT_FONT_SIZE, const Color &p_modulate = Color(1.0, 1.0, 1.0)) const; |
| 193 |
void _draw_char_outline_bind_compat_104872(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_char, int p_font_size = Font::DEFAULT_FONT_SIZE, int p_size = 1, const Color &p_modulate = Color(1.0, 1.0, 1.0)) const; |
| 194 |
void _draw_circle_bind_compat_84472(const Point2 &p_pos, real_t p_radius, const Color &p_color); |
| 195 |
void _draw_rect_bind_compat_84523(const Rect2 &p_rect, const Color &p_color, bool p_filled, real_t p_width); |
| 196 |
void _draw_dashed_line_bind_compat_84523(const Point2 &p_from, const Point2 &p_to, const Color &p_color, real_t p_width, real_t p_dash, bool p_aligned); |
| 197 |
void _draw_multiline_bind_compat_84523(const Vector<Point2> &p_points, const Color &p_color, real_t p_width); |
| 198 |
void _draw_multiline_colors_bind_compat_84523(const Vector<Point2> &p_points, const Vector<Color> &p_colors, real_t p_width); |
| 199 |
static void _bind_compatibility_methods(); |
| 200 |
#endif |
| 201 |
|
| 202 |
void _validate_property(PropertyInfo &p_property) const; |
| 203 |
|
| 204 |
_FORCE_INLINE_ void set_hide_clip_children(bool p_value) { hide_clip_children = p_value; } |
| 205 |
|
| 206 |
GDVIRTUAL0(_draw) |
| 207 |
|
| 208 |
public: |
| 209 |
enum { |
| 210 |
NOTIFICATION_TRANSFORM_CHANGED = SceneTree::NOTIFICATION_TRANSFORM_CHANGED, |
| 211 |
NOTIFICATION_DRAW = 30, |
| 212 |
NOTIFICATION_VISIBILITY_CHANGED = 31, |
| 213 |
NOTIFICATION_ENTER_CANVAS = 32, |
| 214 |
NOTIFICATION_EXIT_CANVAS = 33, |
| 215 |
NOTIFICATION_LOCAL_TRANSFORM_CHANGED = 35, |
| 216 |
NOTIFICATION_WORLD_2D_CHANGED = 36, |
| 217 |
}; |
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
#ifdef TOOLS_ENABLED |
| 222 |
|
| 223 |
virtual void _edit_set_state(const Dictionary &p_state) {} |
| 224 |
virtual Dictionary _edit_get_state() const { return Dictionary(); } |
| 225 |
|
| 226 |
|
| 227 |
virtual void _edit_set_position(const Point2 &p_position) = 0; |
| 228 |
virtual Point2 _edit_get_position() const = 0; |
| 229 |
|
| 230 |
|
| 231 |
virtual void _edit_set_scale(const Size2 &p_scale) = 0; |
| 232 |
virtual Size2 _edit_get_scale() const = 0; |
| 233 |
|
| 234 |
|
| 235 |
virtual bool _edit_use_rotation() const { return false; } |
| 236 |
virtual void _edit_set_rotation(real_t p_rotation) {} |
| 237 |
virtual real_t _edit_get_rotation() const { return 0.0; } |
| 238 |
|
| 239 |
|
| 240 |
virtual void _edit_set_rect(const Rect2 &p_rect) {} |
| 241 |
virtual Size2 _edit_get_minimum_size() const { return Size2(-1, -1); } |
| 242 |
|
| 243 |
|
| 244 |
virtual bool _edit_use_pivot() const { return false; } |
| 245 |
virtual void _edit_set_pivot(const Point2 &p_pivot) {} |
| 246 |
virtual Point2 _edit_get_pivot() const { return Point2(); } |
| 247 |
|
| 248 |
virtual Transform2D _edit_get_transform() const; |
| 249 |
#endif |
| 250 |
|
| 251 |
#ifdef DEBUG_ENABLED |
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const; |
| 256 |
|
| 257 |
|
| 258 |
virtual bool _edit_use_rect() const { return false; } |
| 259 |
virtual Rect2 _edit_get_rect() const { return Rect2(0, 0, 0, 0); } |
| 260 |
#endif |
| 261 |
|
| 262 |
void update_draw_order(); |
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
void set_visible(bool p_visible); |
| 267 |
bool is_visible() const; |
| 268 |
bool is_visible_in_tree() const; |
| 269 |
void show(); |
| 270 |
void hide(); |
| 271 |
|
| 272 |
void queue_redraw(); |
| 273 |
void move_to_front(); |
| 274 |
|
| 275 |
void set_clip_children_mode(ClipChildrenMode p_clip_mode); |
| 276 |
ClipChildrenMode get_clip_children_mode() const; |
| 277 |
|
| 278 |
virtual void set_light_mask(int p_light_mask); |
| 279 |
int get_light_mask() const; |
| 280 |
|
| 281 |
void set_modulate(const Color &p_modulate); |
| 282 |
Color get_modulate() const; |
| 283 |
Color get_modulate_in_tree() const; |
| 284 |
|
| 285 |
virtual void set_self_modulate(const Color &p_self_modulate); |
| 286 |
Color get_self_modulate() const; |
| 287 |
|
| 288 |
void set_visibility_layer(uint32_t p_visibility_layer); |
| 289 |
uint32_t get_visibility_layer() const; |
| 290 |
|
| 291 |
void set_visibility_layer_bit(uint32_t p_visibility_layer, bool p_enable); |
| 292 |
bool get_visibility_layer_bit(uint32_t p_visibility_layer) const; |
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
virtual void set_z_index(int p_z); |
| 297 |
int get_z_index() const; |
| 298 |
int get_effective_z_index() const; |
| 299 |
|
| 300 |
void set_z_as_relative(bool p_enabled); |
| 301 |
bool is_z_relative() const; |
| 302 |
|
| 303 |
virtual void set_y_sort_enabled(bool p_enabled); |
| 304 |
virtual bool is_y_sort_enabled() const; |
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
void draw_dashed_line(const Point2 &p_from, const Point2 &p_to, const Color &p_color, real_t p_width = -1.0, real_t p_dash = 2.0, bool p_aligned = true, bool p_antialiased = false); |
| 309 |
void draw_line(const Point2 &p_from, const Point2 &p_to, const Color &p_color, real_t p_width = -1.0, bool p_antialiased = false); |
| 310 |
void draw_polyline(const Vector<Point2> &p_points, const Color &p_color, real_t p_width = -1.0, bool p_antialiased = false); |
| 311 |
void draw_polyline_colors(const Vector<Point2> &p_points, const Vector<Color> &p_colors, real_t p_width = -1.0, bool p_antialiased = false); |
| 312 |
void draw_ellipse_arc(const Vector2 &p_center, real_t p_major, real_t p_minor, real_t p_start_angle, real_t p_end_angle, int p_point_count, const Color &p_color, real_t p_width = -1.0, bool p_antialiased = false); |
| 313 |
void draw_arc(const Vector2 &p_center, real_t p_radius, real_t p_start_angle, real_t p_end_angle, int p_point_count, const Color &p_color, real_t p_width = -1.0, bool p_antialiased = false); |
| 314 |
void draw_multiline(const Vector<Point2> &p_points, const Color &p_color, real_t p_width = -1.0, bool p_antialiased = false); |
| 315 |
void draw_multiline_colors(const Vector<Point2> &p_points, const Vector<Color> &p_colors, real_t p_width = -1.0, bool p_antialiased = false); |
| 316 |
void draw_rect(const Rect2 &p_rect, const Color &p_color, bool p_filled = true, real_t p_width = -1.0, bool p_antialiased = false); |
| 317 |
void draw_ellipse(const Point2 &p_pos, real_t p_major, real_t p_minor, const Color &p_color, bool p_filled = true, real_t p_width = -1.0, bool p_antialiased = false); |
| 318 |
void draw_circle(const Point2 &p_pos, real_t p_radius, const Color &p_color, bool p_filled = true, real_t p_width = -1.0, bool p_antialiased = false); |
| 319 |
void draw_texture(RequiredParam<Texture2D> rp_texture, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1, 1)); |
| 320 |
void draw_texture_rect(RequiredParam<Texture2D> rp_texture, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false); |
| 321 |
void draw_texture_rect_region(RequiredParam<Texture2D> rp_texture, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, bool p_clip_uv = false); |
| 322 |
void draw_msdf_texture_rect_region(RequiredParam<Texture2D> rp_texture, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), double p_outline = 0.0, double p_pixel_range = 4.0, double p_scale = 1.0); |
| 323 |
void draw_lcd_texture_rect_region(RequiredParam<Texture2D> rp_texture, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1)); |
| 324 |
void draw_style_box(RequiredParam<StyleBox> rp_style_box, const Rect2 &p_rect); |
| 325 |
void draw_primitive(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture2D> p_texture = Ref<Texture2D>()); |
| 326 |
void draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture2D> p_texture = Ref<Texture2D>()); |
| 327 |
void draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture2D> p_texture = Ref<Texture2D>()); |
| 328 |
|
| 329 |
void draw_mesh(RequiredParam<Mesh> rp_mesh, const Ref<Texture2D> &p_texture, const Transform2D &p_transform = Transform2D(), const Color &p_modulate = Color(1, 1, 1)); |
| 330 |
void draw_multimesh(RequiredParam<MultiMesh> rp_multimesh, const Ref<Texture2D> &p_texture); |
| 331 |
|
| 332 |
void draw_string(RequiredParam<Font> rp_font, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment = HORIZONTAL_ALIGNMENT_LEFT, float p_width = -1, int p_font_size = Font::DEFAULT_FONT_SIZE, const Color &p_modulate = Color(1.0, 1.0, 1.0), BitField<TextServer::JustificationFlag> p_jst_flags = TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND, TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL, float p_oversampling = 0.0) const; |
| 333 |
void draw_multiline_string(RequiredParam<Font> rp_font, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment = HORIZONTAL_ALIGNMENT_LEFT, float p_width = -1, int p_font_size = Font::DEFAULT_FONT_SIZE, int p_max_lines = -1, const Color &p_modulate = Color(1.0, 1.0, 1.0), BitField<TextServer::LineBreakFlag> p_brk_flags = TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND, BitField<TextServer::JustificationFlag> p_jst_flags = TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND, TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL, float p_oversampling = 0.0) const; |
| 334 |
|
| 335 |
void draw_string_outline(RequiredParam<Font> rp_font, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment = HORIZONTAL_ALIGNMENT_LEFT, float p_width = -1, int p_font_size = Font::DEFAULT_FONT_SIZE, int p_size = 1, const Color &p_modulate = Color(1.0, 1.0, 1.0), BitField<TextServer::JustificationFlag> p_jst_flags = TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND, TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL, float p_oversampling = 0.0) const; |
| 336 |
void draw_multiline_string_outline(RequiredParam<Font> rp_font, const Point2 &p_pos, const String &p_text, HorizontalAlignment p_alignment = HORIZONTAL_ALIGNMENT_LEFT, float p_width = -1, int p_font_size = Font::DEFAULT_FONT_SIZE, int p_max_lines = -1, int p_size = 1, const Color &p_modulate = Color(1.0, 1.0, 1.0), BitField<TextServer::LineBreakFlag> p_brk_flags = TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND, BitField<TextServer::JustificationFlag> p_jst_flags = TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_WORD_BOUND, TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL, float p_oversampling = 0.0) const; |
| 337 |
|
| 338 |
void draw_char(RequiredParam<Font> rp_font, const Point2 &p_pos, const String &p_char, int p_font_size = Font::DEFAULT_FONT_SIZE, const Color &p_modulate = Color(1.0, 1.0, 1.0), float p_oversampling = 0.0) const; |
| 339 |
void draw_char_outline(RequiredParam<Font> rp_font, const Point2 &p_pos, const String &p_char, int p_font_size = Font::DEFAULT_FONT_SIZE, int p_size = 1, const Color &p_modulate = Color(1.0, 1.0, 1.0), float p_oversampling = 0.0) const; |
| 340 |
|
| 341 |
void draw_set_transform(const Point2 &p_offset, real_t p_rot = 0.0, const Size2 &p_scale = Size2(1.0, 1.0)); |
| 342 |
void draw_set_transform_matrix(const Transform2D &p_matrix); |
| 343 |
void draw_animation_slice(double p_animation_length, double p_slice_begin, double p_slice_end, double p_offset = 0); |
| 344 |
void draw_end_animation(); |
| 345 |
|
| 346 |
static CanvasItem *get_current_item_drawn(); |
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
void set_as_top_level(bool p_top_level); |
| 351 |
bool is_set_as_top_level() const; |
| 352 |
|
| 353 |
void set_draw_behind_parent(bool p_enable); |
| 354 |
bool is_draw_behind_parent_enabled() const; |
| 355 |
|
| 356 |
CanvasItem *get_parent_item() const; |
| 357 |
|
| 358 |
virtual Transform2D get_transform() const = 0; |
| 359 |
|
| 360 |
virtual Transform2D get_global_transform() const; |
| 361 |
virtual Transform2D get_global_transform_const() const; |
| 362 |
virtual Transform2D get_global_transform_with_canvas() const; |
| 363 |
virtual Transform2D get_screen_transform() const; |
| 364 |
|
| 365 |
CanvasItem *get_top_level() const; |
| 366 |
_FORCE_INLINE_ RID get_canvas_item() const { |
| 367 |
return canvas_item; |
| 368 |
} |
| 369 |
|
| 370 |
void set_block_transform_notify(bool p_enable); |
| 371 |
bool is_block_transform_notify_enabled() const; |
| 372 |
|
| 373 |
Transform2D get_canvas_transform() const; |
| 374 |
Transform2D get_viewport_transform() const; |
| 375 |
Rect2 get_viewport_rect() const; |
| 376 |
RID get_viewport_rid() const; |
| 377 |
RID get_canvas() const; |
| 378 |
ObjectID get_canvas_layer_instance_id() const; |
| 379 |
Ref<World2D> get_world_2d() const; |
| 380 |
|
| 381 |
virtual void set_material(const Ref<Material> &p_material); |
| 382 |
Ref<Material> get_material() const; |
| 383 |
|
| 384 |
void set_instance_shader_parameter(const StringName &p_name, const Variant &p_value); |
| 385 |
Variant get_instance_shader_parameter(const StringName &p_name) const; |
| 386 |
|
| 387 |
virtual void set_use_parent_material(bool p_use_parent_material); |
| 388 |
bool get_use_parent_material() const; |
| 389 |
|
| 390 |
RequiredResult<InputEvent> make_input_local(RequiredParam<InputEvent> rp_event) const; |
| 391 |
Vector2 make_canvas_position_local(const Vector2 &screen_point) const; |
| 392 |
|
| 393 |
Vector2 get_global_mouse_position() const; |
| 394 |
Vector2 get_local_mouse_position() const; |
| 395 |
|
| 396 |
void set_notify_local_transform(bool p_enable); |
| 397 |
bool is_local_transform_notification_enabled() const; |
| 398 |
|
| 399 |
void set_notify_transform(bool p_enable); |
| 400 |
bool is_transform_notification_enabled() const; |
| 401 |
|
| 402 |
void force_update_transform(); |
| 403 |
|
| 404 |
virtual void set_texture_filter(TextureFilter p_texture_filter); |
| 405 |
TextureFilter get_texture_filter() const; |
| 406 |
|
| 407 |
virtual void set_texture_repeat(TextureRepeat p_texture_repeat); |
| 408 |
TextureRepeat get_texture_repeat() const; |
| 409 |
|
| 410 |
TextureFilter get_texture_filter_in_tree() const; |
| 411 |
TextureRepeat get_texture_repeat_in_tree() const; |
| 412 |
|
| 413 |
|
| 414 |
virtual Rect2 get_anchorable_rect() const { return Rect2(0, 0, 0, 0); } |
| 415 |
|
| 416 |
int get_canvas_layer() const; |
| 417 |
CanvasLayer *get_canvas_layer_node() const; |
| 418 |
|
| 419 |
virtual PackedStringArray get_configuration_warnings() const override; |
| 420 |
|
| 421 |
CanvasItem(); |
| 422 |
~CanvasItem(); |
| 423 |
}; |
| 424 |
|
| 425 |
VARIANT_ENUM_CAST(CanvasItem::TextureFilter) |
| 426 |
VARIANT_ENUM_CAST(CanvasItem::TextureRepeat) |
| 427 |
VARIANT_ENUM_CAST(CanvasItem::ClipChildrenMode) |
| 428 |
|
| 429 |
class CanvasTexture : public Texture2D { |
| 430 |
GDCLASS(CanvasTexture, Texture2D); |
| 431 |
OBJ_SAVE_TYPE(Texture2D); |
| 432 |
|
| 433 |
Ref<Texture2D> diffuse_texture; |
| 434 |
Ref<Texture2D> normal_texture; |
| 435 |
Ref<Texture2D> specular_texture; |
| 436 |
Color specular = Color(1, 1, 1, 1); |
| 437 |
real_t shininess = 1.0; |
| 438 |
|
| 439 |
RID canvas_texture; |
| 440 |
|
| 441 |
CanvasItem::TextureFilter texture_filter = CanvasItem::TEXTURE_FILTER_PARENT_NODE; |
| 442 |
CanvasItem::TextureRepeat texture_repeat = CanvasItem::TEXTURE_REPEAT_PARENT_NODE; |
| 443 |
|
| 444 |
protected: |
| 445 |
static void _bind_methods(); |
| 446 |
|
| 447 |
public: |
| 448 |
void set_diffuse_texture(const Ref<Texture2D> &p_diffuse); |
| 449 |
Ref<Texture2D> get_diffuse_texture() const; |
| 450 |
|
| 451 |
void set_normal_texture(const Ref<Texture2D> &p_normal); |
| 452 |
Ref<Texture2D> get_normal_texture() const; |
| 453 |
|
| 454 |
void set_specular_texture(const Ref<Texture2D> &p_specular); |
| 455 |
Ref<Texture2D> get_specular_texture() const; |
| 456 |
|
| 457 |
void set_specular_color(const Color &p_color); |
| 458 |
Color get_specular_color() const; |
| 459 |
|
| 460 |
void set_specular_shininess(real_t p_shininess); |
| 461 |
real_t get_specular_shininess() const; |
| 462 |
|
| 463 |
void set_texture_filter(CanvasItem::TextureFilter p_filter); |
| 464 |
CanvasItem::TextureFilter get_texture_filter() const; |
| 465 |
|
| 466 |
void set_texture_repeat(CanvasItem::TextureRepeat p_repeat); |
| 467 |
CanvasItem::TextureRepeat get_texture_repeat() const; |
| 468 |
|
| 469 |
virtual int get_width() const override; |
| 470 |
virtual int get_height() const override; |
| 471 |
|
| 472 |
virtual bool is_pixel_opaque(int p_x, int p_y) const override; |
| 473 |
virtual bool has_alpha() const override; |
| 474 |
|
| 475 |
virtual Ref<Image> get_image() const override; |
| 476 |
|
| 477 |
virtual RID get_rid() const override; |
| 478 |
|
| 479 |
CanvasTexture(); |
| 480 |
~CanvasTexture(); |
| 481 |
}; |