editor_audio_buses.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /*************************************************************************/
  2. /* editor_audio_buses.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
  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 EDITORAUDIOBUSES_H
  31. #define EDITORAUDIOBUSES_H
  32. #include "editor/editor_file_dialog.h"
  33. #include "editor_plugin.h"
  34. #include "scene/gui/box_container.h"
  35. #include "scene/gui/button.h"
  36. #include "scene/gui/line_edit.h"
  37. #include "scene/gui/menu_button.h"
  38. #include "scene/gui/option_button.h"
  39. #include "scene/gui/panel.h"
  40. #include "scene/gui/panel_container.h"
  41. #include "scene/gui/scroll_container.h"
  42. #include "scene/gui/slider.h"
  43. #include "scene/gui/texture_progress.h"
  44. #include "scene/gui/texture_rect.h"
  45. #include "scene/gui/tool_button.h"
  46. #include "scene/gui/tree.h"
  47. class EditorAudioBuses;
  48. class EditorAudioBus : public PanelContainer {
  49. GDCLASS(EditorAudioBus, PanelContainer)
  50. Ref<Texture> disabled_vu;
  51. LineEdit *track_name;
  52. MenuButton *bus_options;
  53. VSlider *slider;
  54. int cc;
  55. struct {
  56. bool prev_active;
  57. float peak_l;
  58. float peak_r;
  59. TextureProgress *vu_l;
  60. TextureProgress *vu_r;
  61. } channel[4];
  62. TextureRect *scale;
  63. OptionButton *send;
  64. PopupMenu *effect_options;
  65. PopupMenu *bus_popup;
  66. PopupMenu *delete_effect_popup;
  67. Button *solo;
  68. Button *mute;
  69. Button *bypass;
  70. Tree *effects;
  71. bool updating_bus;
  72. bool is_master;
  73. void _gui_input(const Ref<InputEvent> &p_event);
  74. void _bus_popup_pressed(int p_option);
  75. void _name_changed(const String &p_new_name);
  76. void _name_focus_exit() { _name_changed(track_name->get_text()); }
  77. void _volume_db_changed(float p_db);
  78. void _solo_toggled();
  79. void _mute_toggled();
  80. void _bypass_toggled();
  81. void _send_selected(int p_which);
  82. void _effect_edited();
  83. void _effect_add(int p_which);
  84. void _effect_selected();
  85. void _delete_effect_pressed(int p_option);
  86. void _effect_rmb(const Vector2 &p_pos);
  87. virtual Variant get_drag_data(const Point2 &p_point);
  88. virtual bool can_drop_data(const Point2 &p_point, const Variant &p_data) const;
  89. virtual void drop_data(const Point2 &p_point, const Variant &p_data);
  90. Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
  91. bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
  92. void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
  93. friend class EditorAudioBuses;
  94. EditorAudioBuses *buses;
  95. protected:
  96. static void _bind_methods();
  97. void _notification(int p_what);
  98. public:
  99. void update_bus();
  100. void update_send();
  101. EditorAudioBus(EditorAudioBuses *p_buses = NULL, bool p_is_master = false);
  102. };
  103. class EditorAudioBusDrop : public Panel {
  104. GDCLASS(EditorAudioBusDrop, Panel);
  105. virtual bool can_drop_data(const Point2 &p_point, const Variant &p_data) const;
  106. virtual void drop_data(const Point2 &p_point, const Variant &p_data);
  107. protected:
  108. static void _bind_methods();
  109. public:
  110. EditorAudioBusDrop();
  111. };
  112. class EditorAudioBuses : public VBoxContainer {
  113. GDCLASS(EditorAudioBuses, VBoxContainer)
  114. HBoxContainer *top_hb;
  115. Button *add;
  116. ScrollContainer *bus_scroll;
  117. HBoxContainer *bus_hb;
  118. EditorAudioBusDrop *drop_end;
  119. Button *file;
  120. Button *load;
  121. Button *save_as;
  122. Button *_default;
  123. Button *_new;
  124. Timer *save_timer;
  125. String edited_path;
  126. void _add_bus();
  127. void _update_buses();
  128. void _update_bus(int p_index);
  129. void _update_sends();
  130. void _delete_bus(Object *p_which);
  131. void _duplicate_bus(int p_which);
  132. void _reset_bus_volume(Object *p_which);
  133. void _request_drop_end();
  134. void _drop_at_index(int p_bus, int p_index);
  135. void _server_save();
  136. void _select_layout();
  137. void _load_layout();
  138. void _save_as_layout();
  139. void _load_default_layout();
  140. void _new_layout();
  141. EditorFileDialog *file_dialog;
  142. bool new_layout;
  143. void _file_dialog_callback(const String &p_string);
  144. protected:
  145. static void _bind_methods();
  146. void _notification(int p_what);
  147. public:
  148. void open_layout(const String &p_path);
  149. static EditorAudioBuses *register_editor();
  150. EditorAudioBuses();
  151. };
  152. class AudioBusesEditorPlugin : public EditorPlugin {
  153. GDCLASS(AudioBusesEditorPlugin, EditorPlugin);
  154. EditorAudioBuses *audio_bus_editor;
  155. public:
  156. virtual String get_name() const { return "SampleLibrary"; }
  157. bool has_main_screen() const { return false; }
  158. virtual void edit(Object *p_node);
  159. virtual bool handles(Object *p_node) const;
  160. virtual void make_visible(bool p_visible);
  161. AudioBusesEditorPlugin(EditorAudioBuses *p_node);
  162. ~AudioBusesEditorPlugin();
  163. };
  164. #endif // EDITORAUDIOBUSES_H