| 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 | |
| 31 | #ifndef ANIMATION_TRACK_EDITOR_PLUGINS_H |
| 32 | #define ANIMATION_TRACK_EDITOR_PLUGINS_H |
| 33 | |
| 34 | #include "editor/animation_track_editor.h" |
| 35 | |
| 36 | class AnimationTrackEditBool : public AnimationTrackEdit { |
| 37 | GDCLASS(AnimationTrackEditBool, AnimationTrackEdit); |
| 38 | Ref<Texture2D> icon_checked; |
| 39 | Ref<Texture2D> icon_unchecked; |
| 40 | |
| 41 | public: |
| 42 | virtual int get_key_height() const override; |
| 43 | virtual Rect2 get_key_rect(int p_index, float p_pixels_sec) override; |
| 44 | virtual bool is_key_selectable_by_distance() const override; |
| 45 | 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; |
| 46 | }; |
| 47 | |
| 48 | class AnimationTrackEditColor : public AnimationTrackEdit { |
| 49 | GDCLASS(AnimationTrackEditColor, AnimationTrackEdit); |
| 50 | |
| 51 | public: |
| 52 | virtual int get_key_height() const override; |
| 53 | virtual Rect2 get_key_rect(int p_index, float p_pixels_sec) override; |
| 54 | virtual bool is_key_selectable_by_distance() const override; |
| 55 | 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; |
| 56 | 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; |
| 57 | }; |
| 58 | |
| 59 | class AnimationTrackEditAudio : public AnimationTrackEdit { |
| 60 | GDCLASS(AnimationTrackEditAudio, AnimationTrackEdit); |
| 61 | |
| 62 | ObjectID id; |
| 63 | |
| 64 | void _preview_changed(ObjectID p_which); |
| 65 | |
| 66 | protected: |
| 67 | static void _bind_methods(); |
| 68 | |
| 69 | public: |
| 70 | virtual int get_key_height() const override; |
| 71 | virtual Rect2 get_key_rect(int p_index, float p_pixels_sec) override; |
| 72 | virtual bool is_key_selectable_by_distance() const override; |
| 73 | 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; |
| 74 | |
| 75 | void set_node(Object *p_object); |
| 76 | |
| 77 | AnimationTrackEditAudio(); |
| 78 | }; |
| 79 | |
| 80 | class AnimationTrackEditSpriteFrame : public AnimationTrackEdit { |
| 81 | GDCLASS(AnimationTrackEditSpriteFrame, AnimationTrackEdit); |
| 82 | |
| 83 | ObjectID id; |
| 84 | bool is_coords = false; |
| 85 | |
| 86 | public: |
| 87 | virtual int get_key_height() const override; |
| 88 | virtual Rect2 get_key_rect(int p_index, float p_pixels_sec) override; |
| 89 | virtual bool is_key_selectable_by_distance() const override; |
| 90 | 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; |
| 91 | |
| 92 | void set_node(Object *p_object); |
| 93 | void set_as_coords(); |
| 94 | |
| 95 | AnimationTrackEditSpriteFrame() {} |
| 96 | }; |
| 97 | |
| 98 | class AnimationTrackEditSubAnim : public AnimationTrackEdit { |
| 99 | GDCLASS(AnimationTrackEditSubAnim, AnimationTrackEdit); |
| 100 | |
| 101 | ObjectID id; |
| 102 | |
| 103 | public: |
| 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 | |
| 109 | void set_node(Object *p_object); |
| 110 | }; |
| 111 | |
| 112 | class AnimationTrackEditTypeAudio : public AnimationTrackEdit { |
| 113 | GDCLASS(AnimationTrackEditTypeAudio, AnimationTrackEdit); |
| 114 | |
| 115 | void _preview_changed(ObjectID p_which); |
| 116 | |
| 117 | bool len_resizing = false; |
| 118 | bool len_resizing_start = false; |
| 119 | int len_resizing_index = 0; |
| 120 | float len_resizing_from_px = 0.0f; |
| 121 | float len_resizing_rel = 0.0f; |
| 122 | bool over_drag_position = false; |
| 123 | |
| 124 | protected: |
| 125 | static void _bind_methods(); |
| 126 | |
| 127 | public: |
| 128 | virtual void gui_input(const Ref<InputEvent> &p_event) override; |
| 129 | |
| 130 | virtual bool can_drop_data(const Point2 &p_point, const Variant &p_data) const override; |
| 131 | virtual void drop_data(const Point2 &p_point, const Variant &p_data) override; |
| 132 | |
| 133 | virtual int get_key_height() const override; |
| 134 | virtual Rect2 get_key_rect(int p_index, float p_pixels_sec) override; |
| 135 | virtual bool is_key_selectable_by_distance() const override; |
| 136 | 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; |
| 137 | |
| 138 | virtual CursorShape get_cursor_shape(const Point2 &p_pos) const override; |
| 139 | |
| 140 | AnimationTrackEditTypeAudio(); |
| 141 | }; |
| 142 | |
| 143 | class AnimationTrackEditTypeAnimation : public AnimationTrackEdit { |
| 144 | GDCLASS(AnimationTrackEditTypeAnimation, AnimationTrackEdit); |
| 145 | |
| 146 | ObjectID id; |
| 147 | |
| 148 | public: |
| 149 | virtual int get_key_height() const override; |
| 150 | virtual Rect2 get_key_rect(int p_index, float p_pixels_sec) override; |
| 151 | virtual bool is_key_selectable_by_distance() const override; |
| 152 | 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; |
| 153 | |
| 154 | void set_node(Object *p_object); |
| 155 | AnimationTrackEditTypeAnimation(); |
| 156 | }; |
| 157 | |
| 158 | class AnimationTrackEditVolumeDB : public AnimationTrackEdit { |
| 159 | GDCLASS(AnimationTrackEditVolumeDB, AnimationTrackEdit); |
| 160 | |
| 161 | public: |
| 162 | virtual void draw_bg(int p_clip_left, int p_clip_right) override; |
| 163 | virtual void draw_fg(int p_clip_left, int p_clip_right) override; |
| 164 | virtual int get_key_height() const override; |
| 165 | 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; |
| 166 | }; |
| 167 | |
| 168 | class AnimationTrackEditDefaultPlugin : public AnimationTrackEditPlugin { |
| 169 | GDCLASS(AnimationTrackEditDefaultPlugin, AnimationTrackEditPlugin); |
| 170 | |
| 171 | public: |
| 172 | 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; |
| 173 | virtual AnimationTrackEdit *create_audio_track_edit() override; |
| 174 | virtual AnimationTrackEdit *create_animation_track_edit(Object *p_object) override; |
| 175 | }; |
| 176 | |
| 177 | #endif // ANIMATION_TRACK_EDITOR_PLUGINS_H |
| 178 | |