animation_track_editor_plugins.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /**************************************************************************/
  2. /* animation_track_editor_plugins.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. #pragma once
  31. #include "editor/animation/animation_track_editor.h"
  32. class AnimationTrackEditBool : public AnimationTrackEdit {
  33. GDCLASS(AnimationTrackEditBool, AnimationTrackEdit);
  34. Ref<Texture2D> icon_checked;
  35. Ref<Texture2D> icon_unchecked;
  36. public:
  37. virtual int get_key_height() const override;
  38. virtual Rect2 get_key_rect(int p_index, float p_pixels_sec) override;
  39. virtual bool is_key_selectable_by_distance() const override;
  40. virtual void draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) override;
  41. };
  42. class AnimationTrackEditColor : public AnimationTrackEdit {
  43. GDCLASS(AnimationTrackEditColor, AnimationTrackEdit);
  44. public:
  45. virtual int get_key_height() const override;
  46. virtual Rect2 get_key_rect(int p_index, float p_pixels_sec) override;
  47. virtual bool is_key_selectable_by_distance() const override;
  48. virtual void draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) override;
  49. virtual void draw_key_link(int p_index, float p_pixels_sec, int p_x, int p_next_x, int p_clip_left, int p_clip_right) override;
  50. };
  51. class AnimationTrackEditAudio : public AnimationTrackEdit {
  52. GDCLASS(AnimationTrackEditAudio, AnimationTrackEdit);
  53. ObjectID id;
  54. void _preview_changed(ObjectID p_which);
  55. public:
  56. virtual int get_key_height() const override;
  57. virtual Rect2 get_key_rect(int p_index, float p_pixels_sec) override;
  58. virtual bool is_key_selectable_by_distance() const override;
  59. virtual void draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) override;
  60. void set_node(Object *p_object);
  61. AnimationTrackEditAudio();
  62. };
  63. class AnimationTrackEditSpriteFrame : public AnimationTrackEdit {
  64. GDCLASS(AnimationTrackEditSpriteFrame, AnimationTrackEdit);
  65. ObjectID id;
  66. bool is_coords = false;
  67. public:
  68. virtual int get_key_height() const override;
  69. virtual Rect2 get_key_rect(int p_index, float p_pixels_sec) override;
  70. virtual bool is_key_selectable_by_distance() const override;
  71. virtual void draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) override;
  72. void set_node(Object *p_object);
  73. void set_as_coords();
  74. };
  75. class AnimationTrackEditSubAnim : public AnimationTrackEdit {
  76. GDCLASS(AnimationTrackEditSubAnim, AnimationTrackEdit);
  77. ObjectID id;
  78. public:
  79. virtual int get_key_height() const override;
  80. virtual Rect2 get_key_rect(int p_index, float p_pixels_sec) override;
  81. virtual bool is_key_selectable_by_distance() const override;
  82. virtual void draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) override;
  83. void set_node(Object *p_object);
  84. };
  85. class AnimationTrackEditTypeAudio : public AnimationTrackEdit {
  86. GDCLASS(AnimationTrackEditTypeAudio, AnimationTrackEdit);
  87. void _preview_changed(ObjectID p_which);
  88. bool len_resizing = false;
  89. bool len_resizing_start = false;
  90. int len_resizing_index = 0;
  91. float len_resizing_from_px = 0.0f;
  92. float len_resizing_rel = 0.0f;
  93. bool over_drag_position = false;
  94. public:
  95. virtual void gui_input(const Ref<InputEvent> &p_event) override;
  96. virtual bool can_drop_data(const Point2 &p_point, const Variant &p_data) const override;
  97. virtual void drop_data(const Point2 &p_point, const Variant &p_data) override;
  98. virtual int get_key_height() const override;
  99. virtual Rect2 get_key_rect(int p_index, float p_pixels_sec) override;
  100. virtual bool is_key_selectable_by_distance() const override;
  101. virtual void draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) override;
  102. virtual CursorShape get_cursor_shape(const Point2 &p_pos) const override;
  103. AnimationTrackEditTypeAudio();
  104. };
  105. class AnimationTrackEditTypeAnimation : public AnimationTrackEdit {
  106. GDCLASS(AnimationTrackEditTypeAnimation, AnimationTrackEdit);
  107. ObjectID id;
  108. public:
  109. virtual int get_key_height() const override;
  110. virtual Rect2 get_key_rect(int p_index, float p_pixels_sec) override;
  111. virtual bool is_key_selectable_by_distance() const override;
  112. virtual void draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) override;
  113. void set_node(Object *p_object);
  114. };
  115. class AnimationTrackEditVolumeDB : public AnimationTrackEdit {
  116. GDCLASS(AnimationTrackEditVolumeDB, AnimationTrackEdit);
  117. public:
  118. virtual void draw_bg(int p_clip_left, int p_clip_right) override;
  119. virtual void draw_fg(int p_clip_left, int p_clip_right) override;
  120. virtual int get_key_height() const override;
  121. virtual void draw_key_link(int p_index, float p_pixels_sec, int p_x, int p_next_x, int p_clip_left, int p_clip_right) override;
  122. };
  123. class AnimationTrackEditDefaultPlugin : public AnimationTrackEditPlugin {
  124. GDCLASS(AnimationTrackEditDefaultPlugin, AnimationTrackEditPlugin);
  125. public:
  126. virtual AnimationTrackEdit *create_value_track_edit(Object *p_object, Variant::Type p_type, const String &p_property, PropertyHint p_hint, const String &p_hint_string, int p_usage) override;
  127. virtual AnimationTrackEdit *create_audio_track_edit() override;
  128. virtual AnimationTrackEdit *create_animation_track_edit(Object *p_object) override;
  129. };