animation_editor_plugin.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*************************************************************************/
  2. /* animation_editor_plugin.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* http://www.godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  9. /* */
  10. /* Permission is hereby granted, free of charge, to any person obtaining */
  11. /* a copy of this software and associated documentation files (the */
  12. /* "Software"), to deal in the Software without restriction, including */
  13. /* without limitation the rights to use, copy, modify, merge, publish, */
  14. /* distribute, sublicense, and/or sell copies of the Software, and to */
  15. /* permit persons to whom the Software is furnished to do so, subject to */
  16. /* the following conditions: */
  17. /* */
  18. /* The above copyright notice and this permission notice shall be */
  19. /* included in all copies or substantial portions of the Software. */
  20. /* */
  21. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  22. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  23. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  24. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  25. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  26. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  27. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  28. /*************************************************************************/
  29. #ifndef ANIMATION_EDITOR_PLUGIN_H
  30. #define ANIMATION_EDITOR_PLUGIN_H
  31. #include "scene/resources/animation.h"
  32. #include "scene/gui/texture_frame.h"
  33. #include "scene/gui/option_button.h"
  34. #include "tools/editor/editor_node.h"
  35. #include "tools/editor/property_editor.h"
  36. #include "undo_redo.h"
  37. class AnimationEditor_TrackEditor;
  38. class AnimationEditor : public Control {
  39. OBJ_TYPE( AnimationEditor, Control );
  40. Panel *panel;
  41. Ref<Animation> animation;
  42. Button *add_track;
  43. Button *remove_track;
  44. Button *move_up_track;
  45. Button *move_down_track;
  46. Button *add_key;
  47. Button *remove_key;
  48. LineEdit *key_time;
  49. OptionButton *track_type;
  50. OptionButton *key_type;
  51. TextureFrame *time_icon;
  52. Tree *tracks;
  53. PropertyEditor *key_editor;
  54. AnimationEditor_TrackEditor *track_editor;
  55. int selected_track;
  56. void _track_selected();
  57. void _track_added();
  58. void _track_removed();
  59. void _track_moved_up();
  60. void _track_moved_down();
  61. void _track_path_changed();
  62. void _key_added();
  63. void _key_removed();
  64. void _update_track_keys();
  65. void update_anim();
  66. UndoRedo *undo_redo;
  67. void _internal_set_selected_track(int p_which,const Ref<Animation>& p_anim);
  68. void _internal_check_update(Ref<Animation> p_anim);
  69. friend class AnimationEditor_TrackEditor;
  70. void _internal_set_key(int p_track, float p_time, float p_transition,const Variant& p_value);
  71. void _internal_set_interpolation_type(int p_track,Animation::InterpolationType p_type);
  72. protected:
  73. void _notification(int p_what);
  74. static void _bind_methods();
  75. public:
  76. void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo=p_undo_redo; }
  77. void edit(const Ref<Animation>& p_animation);
  78. AnimationEditor();
  79. ~AnimationEditor();
  80. };
  81. class AnimationEditorPlugin : public EditorPlugin {
  82. OBJ_TYPE( AnimationEditorPlugin, EditorPlugin );
  83. AnimationEditor *animation_editor;
  84. EditorNode *editor;
  85. public:
  86. virtual String get_name() const { return "Animation"; }
  87. bool has_main_screen() const { return false; }
  88. virtual void edit(Object *p_node);
  89. virtual bool handles(Object *p_node) const;
  90. virtual void make_visible(bool p_visible);
  91. AnimationEditorPlugin(EditorNode *p_node);
  92. };
  93. #endif