canvas_item.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. /**************************************************************************/
  2. /* canvas_item.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  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 CANVAS_ITEM_H
  31. #define CANVAS_ITEM_H
  32. #include "scene/main/node.h"
  33. #include "scene/resources/font.h"
  34. class CanvasLayer;
  35. class MultiMesh;
  36. class StyleBox;
  37. class Window;
  38. class World2D;
  39. class CanvasItem : public Node {
  40. GDCLASS(CanvasItem, Node);
  41. friend class CanvasLayer;
  42. public:
  43. enum TextureFilter {
  44. TEXTURE_FILTER_PARENT_NODE,
  45. TEXTURE_FILTER_NEAREST,
  46. TEXTURE_FILTER_LINEAR,
  47. TEXTURE_FILTER_NEAREST_WITH_MIPMAPS,
  48. TEXTURE_FILTER_LINEAR_WITH_MIPMAPS,
  49. TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC,
  50. TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC,
  51. TEXTURE_FILTER_MAX
  52. };
  53. enum TextureRepeat {
  54. TEXTURE_REPEAT_PARENT_NODE,
  55. TEXTURE_REPEAT_DISABLED,
  56. TEXTURE_REPEAT_ENABLED,
  57. TEXTURE_REPEAT_MIRROR,
  58. TEXTURE_REPEAT_MAX,
  59. };
  60. enum ClipChildrenMode {
  61. CLIP_CHILDREN_DISABLED,
  62. CLIP_CHILDREN_ONLY,
  63. CLIP_CHILDREN_AND_DRAW,
  64. CLIP_CHILDREN_MAX,
  65. };
  66. private:
  67. mutable SelfList<Node>
  68. xform_change;
  69. RID canvas_item;
  70. StringName canvas_group;
  71. CanvasLayer *canvas_layer = nullptr;
  72. Color modulate = Color(1, 1, 1, 1);
  73. Color self_modulate = Color(1, 1, 1, 1);
  74. List<CanvasItem *> children_items;
  75. List<CanvasItem *>::Element *C = nullptr;
  76. int light_mask = 1;
  77. uint32_t visibility_layer = 1;
  78. int z_index = 0;
  79. bool z_relative = true;
  80. bool y_sort_enabled = false;
  81. Window *window = nullptr;
  82. bool visible = true;
  83. bool parent_visible_in_tree = false;
  84. bool pending_update = false;
  85. bool top_level = false;
  86. bool drawing = false;
  87. bool block_transform_notify = false;
  88. bool behind = false;
  89. bool use_parent_material = false;
  90. bool notify_local_transform = false;
  91. bool notify_transform = false;
  92. bool hide_clip_children = false;
  93. ClipChildrenMode clip_children_mode = CLIP_CHILDREN_DISABLED;
  94. mutable RS::CanvasItemTextureFilter texture_filter_cache = RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR;
  95. mutable RS::CanvasItemTextureRepeat texture_repeat_cache = RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED;
  96. TextureFilter texture_filter = TEXTURE_FILTER_PARENT_NODE;
  97. TextureRepeat texture_repeat = TEXTURE_REPEAT_PARENT_NODE;
  98. Ref<Material> material;
  99. mutable HashMap<StringName, Variant> instance_shader_parameters;
  100. mutable HashMap<StringName, StringName> instance_shader_parameter_property_remap;
  101. mutable Transform2D global_transform;
  102. mutable MTFlag global_invalid;
  103. _FORCE_INLINE_ bool _is_global_invalid() const { return is_group_processing() ? global_invalid.mt.is_set() : global_invalid.st; }
  104. void _set_global_invalid(bool p_invalid) const;
  105. void _top_level_raise_self();
  106. void _propagate_visibility_changed(bool p_parent_visible_in_tree);
  107. void _handle_visibility_change(bool p_visible);
  108. virtual void _top_level_changed();
  109. virtual void _top_level_changed_on_parent();
  110. void _redraw_callback();
  111. void _enter_canvas();
  112. void _exit_canvas();
  113. void _window_visibility_changed();
  114. void _notify_transform(CanvasItem *p_node);
  115. virtual void _physics_interpolated_changed() override;
  116. static CanvasItem *current_item_drawn;
  117. friend class Viewport;
  118. void _refresh_texture_repeat_cache() const;
  119. void _update_texture_repeat_changed(bool p_propagate);
  120. void _refresh_texture_filter_cache() const;
  121. void _update_texture_filter_changed(bool p_propagate);
  122. void _notify_transform_deferred();
  123. const StringName *_instance_shader_parameter_get_remap(const StringName &p_name) const;
  124. protected:
  125. bool _set(const StringName &p_name, const Variant &p_value);
  126. bool _get(const StringName &p_name, Variant &r_ret) const;
  127. void _get_property_list(List<PropertyInfo> *p_list) const;
  128. virtual void _update_self_texture_repeat(RS::CanvasItemTextureRepeat p_texture_repeat);
  129. virtual void _update_self_texture_filter(RS::CanvasItemTextureFilter p_texture_filter);
  130. _FORCE_INLINE_ void _notify_transform() {
  131. _notify_transform(this);
  132. if (is_inside_tree() && !block_transform_notify && notify_local_transform) {
  133. notification(NOTIFICATION_LOCAL_TRANSFORM_CHANGED);
  134. }
  135. }
  136. void item_rect_changed(bool p_size_changed = true);
  137. void set_canvas_item_use_identity_transform(bool p_enable);
  138. void _notification(int p_what);
  139. static void _bind_methods();
  140. #ifndef DISABLE_DEPRECATED
  141. void _draw_circle_bind_compat_84472(const Point2 &p_pos, real_t p_radius, const Color &p_color);
  142. void _draw_rect_bind_compat_84523(const Rect2 &p_rect, const Color &p_color, bool p_filled, real_t p_width);
  143. 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);
  144. void _draw_multiline_bind_compat_84523(const Vector<Point2> &p_points, const Color &p_color, real_t p_width);
  145. void _draw_multiline_colors_bind_compat_84523(const Vector<Point2> &p_points, const Vector<Color> &p_colors, real_t p_width);
  146. static void _bind_compatibility_methods();
  147. #endif // DISABLE_DEPRECATED
  148. void _validate_property(PropertyInfo &p_property) const;
  149. _FORCE_INLINE_ void set_hide_clip_children(bool p_value) { hide_clip_children = p_value; }
  150. GDVIRTUAL0(_draw)
  151. public:
  152. enum {
  153. NOTIFICATION_TRANSFORM_CHANGED = SceneTree::NOTIFICATION_TRANSFORM_CHANGED, //unique
  154. NOTIFICATION_DRAW = 30,
  155. NOTIFICATION_VISIBILITY_CHANGED = 31,
  156. NOTIFICATION_ENTER_CANVAS = 32,
  157. NOTIFICATION_EXIT_CANVAS = 33,
  158. NOTIFICATION_LOCAL_TRANSFORM_CHANGED = 35,
  159. NOTIFICATION_WORLD_2D_CHANGED = 36,
  160. };
  161. /* EDITOR AND DEBUGGING */
  162. #ifdef TOOLS_ENABLED
  163. // Save and restore a CanvasItem state
  164. virtual void _edit_set_state(const Dictionary &p_state) {}
  165. virtual Dictionary _edit_get_state() const { return Dictionary(); }
  166. // Used to move the node
  167. virtual void _edit_set_position(const Point2 &p_position) = 0;
  168. virtual Point2 _edit_get_position() const = 0;
  169. // Used to scale the node
  170. virtual void _edit_set_scale(const Size2 &p_scale) = 0;
  171. virtual Size2 _edit_get_scale() const = 0;
  172. // Used to rotate the node
  173. virtual bool _edit_use_rotation() const { return false; }
  174. virtual void _edit_set_rotation(real_t p_rotation) {}
  175. virtual real_t _edit_get_rotation() const { return 0.0; }
  176. // Used to resize/move the node
  177. virtual void _edit_set_rect(const Rect2 &p_rect) {}
  178. virtual Size2 _edit_get_minimum_size() const { return Size2(-1, -1); } // LOOKS WEIRD
  179. // Used to set a pivot
  180. virtual bool _edit_use_pivot() const { return false; }
  181. virtual void _edit_set_pivot(const Point2 &p_pivot) {}
  182. virtual Point2 _edit_get_pivot() const { return Point2(); }
  183. virtual Transform2D _edit_get_transform() const;
  184. #endif // TOOLS_ENABLED
  185. #ifdef DEBUG_ENABLED
  186. // Those need to be available in debug runtime, to allow for node selection.
  187. // Select the node.
  188. virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
  189. // Used to resize/move the node.
  190. virtual bool _edit_use_rect() const { return false; } // Maybe replace with _edit_get_editmode().
  191. virtual Rect2 _edit_get_rect() const { return Rect2(0, 0, 0, 0); }
  192. #endif // DEBUG_ENABLED
  193. void update_draw_order();
  194. /* VISIBILITY */
  195. void set_visible(bool p_visible);
  196. bool is_visible() const;
  197. bool is_visible_in_tree() const;
  198. void show();
  199. void hide();
  200. void queue_redraw();
  201. void move_to_front();
  202. void set_clip_children_mode(ClipChildrenMode p_clip_mode);
  203. ClipChildrenMode get_clip_children_mode() const;
  204. virtual void set_light_mask(int p_light_mask);
  205. int get_light_mask() const;
  206. void set_modulate(const Color &p_modulate);
  207. Color get_modulate() const;
  208. Color get_modulate_in_tree() const;
  209. virtual void set_self_modulate(const Color &p_self_modulate);
  210. Color get_self_modulate() const;
  211. void set_visibility_layer(uint32_t p_visibility_layer);
  212. uint32_t get_visibility_layer() const;
  213. void set_visibility_layer_bit(uint32_t p_visibility_layer, bool p_enable);
  214. bool get_visibility_layer_bit(uint32_t p_visibility_layer) const;
  215. /* ORDERING */
  216. virtual void set_z_index(int p_z);
  217. int get_z_index() const;
  218. int get_effective_z_index() const;
  219. void set_z_as_relative(bool p_enabled);
  220. bool is_z_relative() const;
  221. virtual void set_y_sort_enabled(bool p_enabled);
  222. virtual bool is_y_sort_enabled() const;
  223. /* DRAWING API */
  224. 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);
  225. 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);
  226. void draw_polyline(const Vector<Point2> &p_points, const Color &p_color, real_t p_width = -1.0, bool p_antialiased = false);
  227. void draw_polyline_colors(const Vector<Point2> &p_points, const Vector<Color> &p_colors, real_t p_width = -1.0, bool p_antialiased = false);
  228. 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);
  229. void draw_multiline(const Vector<Point2> &p_points, const Color &p_color, real_t p_width = -1.0, bool p_antialiased = false);
  230. void draw_multiline_colors(const Vector<Point2> &p_points, const Vector<Color> &p_colors, real_t p_width = -1.0, bool p_antialiased = false);
  231. 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);
  232. 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);
  233. void draw_texture(const Ref<Texture2D> &p_texture, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1, 1));
  234. void draw_texture_rect(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false);
  235. void draw_texture_rect_region(const Ref<Texture2D> &p_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);
  236. void draw_msdf_texture_rect_region(const Ref<Texture2D> &p_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);
  237. void draw_lcd_texture_rect_region(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1));
  238. void draw_style_box(const Ref<StyleBox> &p_style_box, const Rect2 &p_rect);
  239. void draw_primitive(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture2D> p_texture = Ref<Texture2D>());
  240. 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>());
  241. 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>());
  242. void draw_mesh(const Ref<Mesh> &p_mesh, const Ref<Texture2D> &p_texture, const Transform2D &p_transform = Transform2D(), const Color &p_modulate = Color(1, 1, 1));
  243. void draw_multimesh(const Ref<MultiMesh> &p_multimesh, const Ref<Texture2D> &p_texture);
  244. void draw_string(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;
  245. void draw_multiline_string(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;
  246. void draw_string_outline(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;
  247. void draw_multiline_string_outline(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;
  248. void draw_char(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;
  249. void draw_char_outline(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;
  250. void draw_set_transform(const Point2 &p_offset, real_t p_rot = 0.0, const Size2 &p_scale = Size2(1.0, 1.0));
  251. void draw_set_transform_matrix(const Transform2D &p_matrix);
  252. void draw_animation_slice(double p_animation_length, double p_slice_begin, double p_slice_end, double p_offset = 0);
  253. void draw_end_animation();
  254. static CanvasItem *get_current_item_drawn();
  255. /* RECT / TRANSFORM */
  256. void set_as_top_level(bool p_top_level);
  257. bool is_set_as_top_level() const;
  258. void set_draw_behind_parent(bool p_enable);
  259. bool is_draw_behind_parent_enabled() const;
  260. CanvasItem *get_parent_item() const;
  261. virtual Transform2D get_transform() const = 0;
  262. virtual Transform2D get_global_transform() const;
  263. virtual Transform2D get_global_transform_const() const;
  264. virtual Transform2D get_global_transform_with_canvas() const;
  265. virtual Transform2D get_screen_transform() const;
  266. CanvasItem *get_top_level() const;
  267. _FORCE_INLINE_ RID get_canvas_item() const {
  268. return canvas_item;
  269. }
  270. void set_block_transform_notify(bool p_enable);
  271. bool is_block_transform_notify_enabled() const;
  272. Transform2D get_canvas_transform() const;
  273. Transform2D get_viewport_transform() const;
  274. Rect2 get_viewport_rect() const;
  275. RID get_viewport_rid() const;
  276. RID get_canvas() const;
  277. ObjectID get_canvas_layer_instance_id() const;
  278. Ref<World2D> get_world_2d() const;
  279. virtual void set_material(const Ref<Material> &p_material);
  280. Ref<Material> get_material() const;
  281. void set_instance_shader_parameter(const StringName &p_name, const Variant &p_value);
  282. Variant get_instance_shader_parameter(const StringName &p_name) const;
  283. virtual void set_use_parent_material(bool p_use_parent_material);
  284. bool get_use_parent_material() const;
  285. Ref<InputEvent> make_input_local(const Ref<InputEvent> &p_event) const;
  286. Vector2 make_canvas_position_local(const Vector2 &screen_point) const;
  287. Vector2 get_global_mouse_position() const;
  288. Vector2 get_local_mouse_position() const;
  289. void set_notify_local_transform(bool p_enable);
  290. bool is_local_transform_notification_enabled() const;
  291. void set_notify_transform(bool p_enable);
  292. bool is_transform_notification_enabled() const;
  293. void force_update_transform();
  294. virtual void set_texture_filter(TextureFilter p_texture_filter);
  295. TextureFilter get_texture_filter() const;
  296. virtual void set_texture_repeat(TextureRepeat p_texture_repeat);
  297. TextureRepeat get_texture_repeat() const;
  298. TextureFilter get_texture_filter_in_tree() const;
  299. TextureRepeat get_texture_repeat_in_tree() const;
  300. // Used by control nodes to retrieve the parent's anchorable area
  301. virtual Rect2 get_anchorable_rect() const { return Rect2(0, 0, 0, 0); }
  302. int get_canvas_layer() const;
  303. CanvasLayer *get_canvas_layer_node() const;
  304. CanvasItem();
  305. ~CanvasItem();
  306. };
  307. VARIANT_ENUM_CAST(CanvasItem::TextureFilter)
  308. VARIANT_ENUM_CAST(CanvasItem::TextureRepeat)
  309. VARIANT_ENUM_CAST(CanvasItem::ClipChildrenMode)
  310. class CanvasTexture : public Texture2D {
  311. GDCLASS(CanvasTexture, Texture2D);
  312. OBJ_SAVE_TYPE(Texture2D); // Saves derived classes with common type so they can be interchanged.
  313. Ref<Texture2D> diffuse_texture;
  314. Ref<Texture2D> normal_texture;
  315. Ref<Texture2D> specular_texture;
  316. Color specular = Color(1, 1, 1, 1);
  317. real_t shininess = 1.0;
  318. RID canvas_texture;
  319. CanvasItem::TextureFilter texture_filter = CanvasItem::TEXTURE_FILTER_PARENT_NODE;
  320. CanvasItem::TextureRepeat texture_repeat = CanvasItem::TEXTURE_REPEAT_PARENT_NODE;
  321. protected:
  322. static void _bind_methods();
  323. public:
  324. void set_diffuse_texture(const Ref<Texture2D> &p_diffuse);
  325. Ref<Texture2D> get_diffuse_texture() const;
  326. void set_normal_texture(const Ref<Texture2D> &p_normal);
  327. Ref<Texture2D> get_normal_texture() const;
  328. void set_specular_texture(const Ref<Texture2D> &p_specular);
  329. Ref<Texture2D> get_specular_texture() const;
  330. void set_specular_color(const Color &p_color);
  331. Color get_specular_color() const;
  332. void set_specular_shininess(real_t p_shininess);
  333. real_t get_specular_shininess() const;
  334. void set_texture_filter(CanvasItem::TextureFilter p_filter);
  335. CanvasItem::TextureFilter get_texture_filter() const;
  336. void set_texture_repeat(CanvasItem::TextureRepeat p_repeat);
  337. CanvasItem::TextureRepeat get_texture_repeat() const;
  338. virtual int get_width() const override;
  339. virtual int get_height() const override;
  340. virtual bool is_pixel_opaque(int p_x, int p_y) const override;
  341. virtual bool has_alpha() const override;
  342. virtual Ref<Image> get_image() const override;
  343. virtual RID get_rid() const override;
  344. CanvasTexture();
  345. ~CanvasTexture();
  346. };
  347. #endif // CANVAS_ITEM_H