canvas_layer.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*************************************************************************/
  2. /* canvas_layer.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2020 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 CANVAS_LAYER_H
  31. #define CANVAS_LAYER_H
  32. #include "scene/main/node.h"
  33. #include "scene/resources/world_2d.h"
  34. class Viewport;
  35. class CanvasLayer : public Node {
  36. OBJ_TYPE(CanvasLayer, Node);
  37. bool locrotscale_dirty;
  38. Vector2 ofs;
  39. Size2 scale;
  40. real_t rot;
  41. int layer;
  42. Matrix32 transform;
  43. Ref<World2D> canvas;
  44. ObjectID custom_viewport_id; // to check validity
  45. Viewport *custom_viewport;
  46. RID viewport;
  47. Viewport *vp;
  48. // Deprecated, should be removed in a future version.
  49. void _set_rotationd(real_t p_rotation);
  50. real_t _get_rotationd() const;
  51. void _update_xform();
  52. void _update_locrotscale();
  53. protected:
  54. void _notification(int p_what);
  55. static void _bind_methods();
  56. public:
  57. void set_layer(int p_xform);
  58. int get_layer() const;
  59. void set_transform(const Matrix32 &p_xform);
  60. Matrix32 get_transform() const;
  61. void set_offset(const Vector2 &p_offset);
  62. Vector2 get_offset() const;
  63. void set_rotation(real_t p_radians);
  64. real_t get_rotation() const;
  65. void set_rotationd(real_t p_degrees);
  66. real_t get_rotationd() const;
  67. void set_scale(const Size2 &p_scale);
  68. Size2 get_scale() const;
  69. Ref<World2D> get_world_2d() const;
  70. Size2 get_viewport_size() const;
  71. RID get_viewport() const;
  72. void set_custom_viewport(Node *p_viewport);
  73. Node *get_custom_viewport() const;
  74. CanvasLayer();
  75. };
  76. #endif // CANVAS_LAYER_H