editor_audio_buses.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 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. static const int CHANNELS_MAX = 4;
  56. struct {
  57. bool prev_active;
  58. float peak_l;
  59. float peak_r;
  60. TextureProgress *vu_l;
  61. TextureProgress *vu_r;
  62. } channel[CHANNELS_MAX];
  63. TextureRect *scale;
  64. OptionButton *send;
  65. PopupMenu *effect_options;
  66. PopupMenu *bus_popup;
  67. PopupMenu *delete_effect_popup;
  68. Button *solo;
  69. Button *mute;
  70. Button *bypass;
  71. Tree *effects;
  72. bool updating_bus;
  73. bool is_master;
  74. void _gui_input(const Ref<InputEvent> &p_event);
  75. void _bus_popup_pressed(int p_option);
  76. void _name_changed(const String &p_new_name);
  77. void _name_focus_exit() { _name_changed(track_name->get_text()); }
  78. void _volume_db_changed(float p_db);
  79. void _solo_toggled();
  80. void _mute_toggled();
  81. void _bypass_toggled();
  82. void _send_selected(int p_which);
  83. void _effect_edited();
  84. void _effect_add(int p_which);
  85. void _effect_selected();
  86. void _delete_effect_pressed(int p_option);
  87. void _effect_rmb(const Vector2 &p_pos);
  88. void _update_visible_channels();
  89. virtual Variant get_drag_data(const Point2 &p_point);
  90. virtual bool can_drop_data(const Point2 &p_point, const Variant &p_data) const;
  91. virtual void drop_data(const Point2 &p_point, const Variant &p_data);
  92. Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
  93. bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
  94. void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
  95. friend class EditorAudioBuses;
  96. EditorAudioBuses *buses;
  97. protected:
  98. static void _bind_methods();
  99. void _notification(int p_what);
  100. public:
  101. void update_bus();
  102. void update_send();
  103. EditorAudioBus(EditorAudioBuses *p_buses = NULL, bool p_is_master = false);
  104. };
  105. class EditorAudioBusDrop : public Panel {
  106. GDCLASS(EditorAudioBusDrop, Panel);
  107. virtual bool can_drop_data(const Point2 &p_point, const Variant &p_data) const;
  108. virtual void drop_data(const Point2 &p_point, const Variant &p_data);
  109. protected:
  110. static void _bind_methods();
  111. public:
  112. EditorAudioBusDrop();
  113. };
  114. class EditorAudioBuses : public VBoxContainer {
  115. GDCLASS(EditorAudioBuses, VBoxContainer)
  116. HBoxContainer *top_hb;
  117. Button *add;
  118. ScrollContainer *bus_scroll;
  119. HBoxContainer *bus_hb;
  120. EditorAudioBusDrop *drop_end;
  121. Button *file;
  122. Button *load;
  123. Button *save_as;
  124. Button *_default;
  125. Button *_new;
  126. Timer *save_timer;
  127. String edited_path;
  128. void _add_bus();
  129. void _update_buses();
  130. void _update_bus(int p_index);
  131. void _update_sends();
  132. void _delete_bus(Object *p_which);
  133. void _duplicate_bus(int p_which);
  134. void _reset_bus_volume(Object *p_which);
  135. void _request_drop_end();
  136. void _drop_at_index(int p_bus, int p_index);
  137. void _server_save();
  138. void _select_layout();
  139. void _load_layout();
  140. void _save_as_layout();
  141. void _load_default_layout();
  142. void _new_layout();
  143. EditorFileDialog *file_dialog;
  144. bool new_layout;
  145. void _file_dialog_callback(const String &p_string);
  146. protected:
  147. static void _bind_methods();
  148. void _notification(int p_what);
  149. public:
  150. void open_layout(const String &p_path);
  151. static EditorAudioBuses *register_editor();
  152. EditorAudioBuses();
  153. };
  154. class AudioBusesEditorPlugin : public EditorPlugin {
  155. GDCLASS(AudioBusesEditorPlugin, EditorPlugin);
  156. EditorAudioBuses *audio_bus_editor;
  157. public:
  158. virtual String get_name() const { return "SampleLibrary"; }
  159. bool has_main_screen() const { return false; }
  160. virtual void edit(Object *p_node);
  161. virtual bool handles(Object *p_node) const;
  162. virtual void make_visible(bool p_visible);
  163. AudioBusesEditorPlugin(EditorAudioBuses *p_node);
  164. ~AudioBusesEditorPlugin();
  165. };
  166. #endif // EDITORAUDIOBUSES_H