animation_track_editor_plugins.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. protected:
  57. static void _bind_methods();
  58. public:
  59. virtual int get_key_height() const override;
  60. virtual Rect2 get_key_rect(int p_index, float p_pixels_sec) override;
  61. virtual bool is_key_selectable_by_distance() const override;
  62. 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;
  63. void set_node(Object *p_object);
  64. AnimationTrackEditAudio();
  65. };
  66. class AnimationTrackEditSpriteFrame : public AnimationTrackEdit {
  67. GDCLASS(AnimationTrackEditSpriteFrame, AnimationTrackEdit);
  68. ObjectID id;
  69. bool is_coords = false;
  70. public:
  71. virtual int get_key_height() const override;
  72. virtual Rect2 get_key_rect(int p_index, float p_pixels_sec) override;
  73. virtual bool is_key_selectable_by_distance() const override;
  74. 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;
  75. void set_node(Object *p_object);
  76. void set_as_coords();
  77. AnimationTrackEditSpriteFrame() {}
  78. };
  79. class AnimationTrackEditSubAnim : public AnimationTrackEdit {
  80. GDCLASS(AnimationTrackEditSubAnim, AnimationTrackEdit);
  81. ObjectID id;
  82. public:
  83. virtual int get_key_height() const override;
  84. virtual Rect2 get_key_rect(int p_index, float p_pixels_sec) override;
  85. virtual bool is_key_selectable_by_distance() const override;
  86. 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;
  87. void set_node(Object *p_object);
  88. };
  89. class AnimationTrackEditTypeAudio : public AnimationTrackEdit {
  90. GDCLASS(AnimationTrackEditTypeAudio, AnimationTrackEdit);
  91. void _preview_changed(ObjectID p_which);
  92. bool len_resizing = false;
  93. bool len_resizing_start = false;
  94. int len_resizing_index = 0;
  95. float len_resizing_from_px = 0.0f;
  96. float len_resizing_rel = 0.0f;
  97. bool over_drag_position = false;
  98. protected:
  99. static void _bind_methods();
  100. public:
  101. virtual void gui_input(const Ref<InputEvent> &p_event) override;
  102. virtual bool can_drop_data(const Point2 &p_point, const Variant &p_data) const override;
  103. virtual void drop_data(const Point2 &p_point, const Variant &p_data) override;
  104. virtual int get_key_height() const override;
  105. virtual Rect2 get_key_rect(int p_index, float p_pixels_sec) override;
  106. virtual bool is_key_selectable_by_distance() const override;
  107. 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;
  108. virtual CursorShape get_cursor_shape(const Point2 &p_pos) const override;
  109. AnimationTrackEditTypeAudio();
  110. };
  111. class AnimationTrackEditTypeAnimation : public AnimationTrackEdit {
  112. GDCLASS(AnimationTrackEditTypeAnimation, AnimationTrackEdit);
  113. ObjectID id;
  114. public:
  115. virtual int get_key_height() const override;
  116. virtual Rect2 get_key_rect(int p_index, float p_pixels_sec) override;
  117. virtual bool is_key_selectable_by_distance() const override;
  118. 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;
  119. void set_node(Object *p_object);
  120. AnimationTrackEditTypeAnimation();
  121. };
  122. class AnimationTrackEditVolumeDB : public AnimationTrackEdit {
  123. GDCLASS(AnimationTrackEditVolumeDB, AnimationTrackEdit);
  124. public:
  125. virtual void draw_bg(int p_clip_left, int p_clip_right) override;
  126. virtual void draw_fg(int p_clip_left, int p_clip_right) override;
  127. virtual int get_key_height() const override;
  128. 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;
  129. };
  130. class AnimationTrackEditDefaultPlugin : public AnimationTrackEditPlugin {
  131. GDCLASS(AnimationTrackEditDefaultPlugin, AnimationTrackEditPlugin);
  132. public:
  133. 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;
  134. virtual AnimationTrackEdit *create_audio_track_edit() override;
  135. virtual AnimationTrackEdit *create_animation_track_edit(Object *p_object) override;
  136. };
  137. #endif // ANIMATION_TRACK_EDITOR_PLUGINS_H