animation_track_editor_plugins.h 7.4 KB

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