2023-01-05 13:25:55 +01:00
|
|
|
/**************************************************************************/
|
|
|
|
/* editor_audio_buses.h */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
|
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/**************************************************************************/
|
2018-01-05 00:50:27 +01:00
|
|
|
|
2022-05-02 16:28:25 +02:00
|
|
|
#ifndef EDITOR_AUDIO_BUSES_H
|
|
|
|
#define EDITOR_AUDIO_BUSES_H
|
2017-01-21 23:00:25 +01:00
|
|
|
|
2022-02-12 02:46:22 +01:00
|
|
|
#include "editor/editor_plugin.h"
|
2017-01-21 23:00:25 +01:00
|
|
|
#include "scene/gui/box_container.h"
|
|
|
|
#include "scene/gui/button.h"
|
2019-02-11 06:50:55 +01:00
|
|
|
#include "scene/gui/control.h"
|
2017-03-05 16:44:50 +01:00
|
|
|
#include "scene/gui/line_edit.h"
|
2017-08-11 01:07:24 +02:00
|
|
|
#include "scene/gui/menu_button.h"
|
2017-03-05 16:44:50 +01:00
|
|
|
#include "scene/gui/option_button.h"
|
|
|
|
#include "scene/gui/panel.h"
|
2017-01-21 23:00:25 +01:00
|
|
|
#include "scene/gui/panel_container.h"
|
2017-03-05 16:44:50 +01:00
|
|
|
#include "scene/gui/scroll_container.h"
|
2017-01-21 23:00:25 +01:00
|
|
|
#include "scene/gui/slider.h"
|
2020-12-14 21:10:09 +01:00
|
|
|
#include "scene/gui/texture_progress_bar.h"
|
2017-01-21 23:00:25 +01:00
|
|
|
#include "scene/gui/texture_rect.h"
|
|
|
|
#include "scene/gui/tree.h"
|
|
|
|
|
|
|
|
class EditorAudioBuses;
|
2022-11-11 20:12:48 +01:00
|
|
|
class EditorFileDialog;
|
2017-01-21 23:00:25 +01:00
|
|
|
|
|
|
|
class EditorAudioBus : public PanelContainer {
|
2019-03-19 19:35:57 +01:00
|
|
|
GDCLASS(EditorAudioBus, PanelContainer);
|
2017-01-21 23:00:25 +01:00
|
|
|
|
2019-06-11 20:43:37 +02:00
|
|
|
Ref<Texture2D> disabled_vu;
|
2022-04-04 15:06:57 +02:00
|
|
|
LineEdit *track_name = nullptr;
|
|
|
|
MenuButton *bus_options = nullptr;
|
|
|
|
VSlider *slider = nullptr;
|
2017-08-22 23:27:17 +02:00
|
|
|
|
|
|
|
int cc;
|
2018-12-07 17:38:40 +01:00
|
|
|
static const int CHANNELS_MAX = 4;
|
2017-08-22 23:27:17 +02:00
|
|
|
|
|
|
|
struct {
|
2020-11-24 10:12:55 +01:00
|
|
|
bool prev_active = false;
|
2017-08-22 23:27:17 +02:00
|
|
|
|
2020-11-24 10:12:55 +01:00
|
|
|
float peak_l = 0;
|
|
|
|
float peak_r = 0;
|
2017-08-22 23:27:17 +02:00
|
|
|
|
2020-12-14 21:10:09 +01:00
|
|
|
TextureProgressBar *vu_l = nullptr;
|
|
|
|
TextureProgressBar *vu_r = nullptr;
|
2018-12-07 17:38:40 +01:00
|
|
|
} channel[CHANNELS_MAX];
|
2017-08-22 23:27:17 +02:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
OptionButton *send = nullptr;
|
2017-01-21 23:00:25 +01:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
PopupMenu *effect_options = nullptr;
|
|
|
|
PopupMenu *bus_popup = nullptr;
|
|
|
|
PopupMenu *delete_effect_popup = nullptr;
|
2017-01-21 23:00:25 +01:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
Panel *audio_value_preview_box = nullptr;
|
|
|
|
Label *audio_value_preview_label = nullptr;
|
|
|
|
Timer *preview_timer = nullptr;
|
2019-02-11 06:50:55 +01:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
Button *solo = nullptr;
|
|
|
|
Button *mute = nullptr;
|
|
|
|
Button *bypass = nullptr;
|
2017-01-21 23:00:25 +01:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
Tree *effects = nullptr;
|
2017-01-21 23:00:25 +01:00
|
|
|
|
2022-02-15 15:56:58 +01:00
|
|
|
bool updating_bus = false;
|
2017-09-25 08:12:18 +02:00
|
|
|
bool is_master;
|
2022-02-15 15:56:58 +01:00
|
|
|
mutable bool hovering_drop = false;
|
2017-09-25 08:12:18 +02:00
|
|
|
|
2021-08-22 17:37:22 +02:00
|
|
|
virtual void gui_input(const Ref<InputEvent> &p_event) override;
|
2020-09-17 03:37:12 +02:00
|
|
|
void _effects_gui_input(Ref<InputEvent> p_event);
|
2017-08-26 16:42:28 +02:00
|
|
|
void _bus_popup_pressed(int p_option);
|
2017-01-24 03:12:08 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void _name_changed(const String &p_new_name);
|
2017-01-21 23:00:25 +01:00
|
|
|
void _name_focus_exit() { _name_changed(track_name->get_text()); }
|
2019-02-11 06:50:55 +01:00
|
|
|
void _volume_changed(float p_normalized);
|
|
|
|
float _normalized_volume_to_scaled_db(float normalized);
|
|
|
|
float _scaled_db_to_normalized_volume(float db);
|
|
|
|
void _show_value(float slider_value);
|
|
|
|
void _hide_value_preview();
|
2017-01-21 23:00:25 +01:00
|
|
|
void _solo_toggled();
|
|
|
|
void _mute_toggled();
|
|
|
|
void _bypass_toggled();
|
|
|
|
void _send_selected(int p_which);
|
|
|
|
void _effect_edited();
|
|
|
|
void _effect_add(int p_which);
|
|
|
|
void _effect_selected();
|
2017-01-25 00:11:13 +01:00
|
|
|
void _delete_effect_pressed(int p_option);
|
2021-09-18 09:33:18 +02:00
|
|
|
void _effect_rmb(const Vector2 &p_pos, MouseButton p_button);
|
2018-12-07 17:38:40 +01:00
|
|
|
void _update_visible_channels();
|
2017-01-24 03:12:08 +01:00
|
|
|
|
2020-07-10 12:34:39 +02:00
|
|
|
virtual Variant get_drag_data(const Point2 &p_point) override;
|
|
|
|
virtual bool can_drop_data(const Point2 &p_point, const Variant &p_data) const override;
|
|
|
|
virtual void drop_data(const Point2 &p_point, const Variant &p_data) override;
|
2017-01-24 03:12:08 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
|
|
|
|
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
|
|
|
|
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
|
2017-01-24 04:19:31 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
friend class EditorAudioBuses;
|
2017-01-21 23:00:25 +01:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
EditorAudioBuses *buses = nullptr;
|
2017-01-21 23:00:25 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
void _notification(int p_what);
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
public:
|
2017-01-21 23:00:25 +01:00
|
|
|
void update_bus();
|
|
|
|
void update_send();
|
|
|
|
|
2020-04-02 01:20:12 +02:00
|
|
|
EditorAudioBus(EditorAudioBuses *p_buses = nullptr, bool p_is_master = false);
|
2017-01-21 23:00:25 +01:00
|
|
|
};
|
|
|
|
|
2019-06-08 07:26:39 +02:00
|
|
|
class EditorAudioBusDrop : public Control {
|
|
|
|
GDCLASS(EditorAudioBusDrop, Control);
|
2017-01-24 03:12:08 +01:00
|
|
|
|
2020-07-10 12:34:39 +02:00
|
|
|
virtual bool can_drop_data(const Point2 &p_point, const Variant &p_data) const override;
|
|
|
|
virtual void drop_data(const Point2 &p_point, const Variant &p_data) override;
|
2017-01-24 03:12:08 +01:00
|
|
|
|
2022-02-15 15:56:58 +01:00
|
|
|
mutable bool hovering_drop = false;
|
2019-06-08 07:26:39 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
protected:
|
2017-01-24 03:12:08 +01:00
|
|
|
static void _bind_methods();
|
2019-06-08 07:26:39 +02:00
|
|
|
void _notification(int p_what);
|
2017-01-24 03:12:08 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
public:
|
2017-01-24 03:12:08 +01:00
|
|
|
EditorAudioBusDrop();
|
|
|
|
};
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
class EditorAudioBuses : public VBoxContainer {
|
2019-03-19 19:35:57 +01:00
|
|
|
GDCLASS(EditorAudioBuses, VBoxContainer);
|
2017-01-21 23:00:25 +01:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
HBoxContainer *top_hb = nullptr;
|
2017-01-21 23:00:25 +01:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
ScrollContainer *bus_scroll = nullptr;
|
|
|
|
HBoxContainer *bus_hb = nullptr;
|
2017-01-21 23:00:25 +01:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
EditorAudioBusDrop *drop_end = nullptr;
|
2017-01-24 03:12:08 +01:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
Label *file = nullptr;
|
2019-06-08 07:26:39 +02:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
Button *add = nullptr;
|
|
|
|
Button *load = nullptr;
|
|
|
|
Button *save_as = nullptr;
|
|
|
|
Button *_default = nullptr;
|
|
|
|
Button *_new = nullptr;
|
2017-01-25 18:30:40 +01:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
Timer *save_timer = nullptr;
|
2017-01-25 18:30:40 +01:00
|
|
|
String edited_path;
|
|
|
|
|
2023-03-07 17:22:58 +01:00
|
|
|
bool renaming_buses = false;
|
|
|
|
void _set_renaming_buses(bool p_renaming);
|
|
|
|
|
2017-01-21 23:00:25 +01:00
|
|
|
void _add_bus();
|
|
|
|
void _update_buses();
|
|
|
|
void _update_bus(int p_index);
|
|
|
|
void _update_sends();
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void _delete_bus(Object *p_which);
|
2017-01-25 18:30:40 +01:00
|
|
|
void _duplicate_bus(int p_which);
|
2017-09-07 02:11:31 +02:00
|
|
|
void _reset_bus_volume(Object *p_which);
|
2017-01-25 18:30:40 +01:00
|
|
|
|
2017-01-24 03:12:08 +01:00
|
|
|
void _request_drop_end();
|
2017-03-05 16:44:50 +01:00
|
|
|
void _drop_at_index(int p_bus, int p_index);
|
2017-01-21 23:00:25 +01:00
|
|
|
|
2017-01-25 18:30:40 +01:00
|
|
|
void _server_save();
|
|
|
|
|
|
|
|
void _select_layout();
|
|
|
|
void _load_layout();
|
|
|
|
void _save_as_layout();
|
|
|
|
void _load_default_layout();
|
|
|
|
void _new_layout();
|
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
EditorFileDialog *file_dialog = nullptr;
|
2022-05-02 16:28:25 +02:00
|
|
|
bool new_layout = false;
|
2017-01-25 18:30:40 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void _file_dialog_callback(const String &p_string);
|
2017-01-25 18:30:40 +01:00
|
|
|
|
2017-01-21 23:00:25 +01:00
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
void _notification(int p_what);
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
public:
|
|
|
|
void open_layout(const String &p_path);
|
2017-01-21 23:00:25 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
static EditorAudioBuses *register_editor();
|
2017-01-21 23:00:25 +01:00
|
|
|
|
|
|
|
EditorAudioBuses();
|
|
|
|
};
|
|
|
|
|
2019-02-11 06:50:55 +01:00
|
|
|
class EditorAudioMeterNotches : public Control {
|
|
|
|
GDCLASS(EditorAudioMeterNotches, Control);
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct AudioNotch {
|
2020-11-24 10:12:55 +01:00
|
|
|
float relative_position = 0;
|
|
|
|
float db_value = 0;
|
|
|
|
bool render_db_value = false;
|
2019-02-11 06:50:55 +01:00
|
|
|
|
|
|
|
_FORCE_INLINE_ AudioNotch(float r_pos, float db_v, bool rndr_val) {
|
|
|
|
relative_position = r_pos;
|
|
|
|
db_value = db_v;
|
|
|
|
render_db_value = rndr_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
_FORCE_INLINE_ AudioNotch(const AudioNotch &n) {
|
|
|
|
relative_position = n.relative_position;
|
|
|
|
db_value = n.db_value;
|
|
|
|
render_db_value = n.render_db_value;
|
|
|
|
}
|
|
|
|
|
2021-11-30 15:19:26 +01:00
|
|
|
_FORCE_INLINE_ void operator=(const EditorAudioMeterNotches::AudioNotch &n) {
|
Fix few GCC9 warnings:
thirdparty/assimp/include/assimp/material.inl: In member function 'aiReturn aiMaterial::Get(const char*, unsigned int, unsigned int, aiColor3D&) const':
thirdparty/assimp/include/assimp/material.inl:176:33: error: implicitly-declared 'aiColor3D& aiColor3D::operator=(const aiColor3D&)' is deprecated [-Werror=deprecated-copy]
176 | pOut = aiColor3D(c.r,c.g,c.b);
modules/dds/texture_loader_dds.cpp:167:50: error: comparison of integer expressions of different signedness: 'uint32_t' {aka 'unsigned int'} and 'int' [-Werror=sign-compare]
167 | if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("DXT1")) {
| ^
[ 28%] modules/dds/texture_loader_dds.cpp:170:57: error: comparison of integer expressions of different signedness: 'uint32_t' {aka 'unsigned int'} and 'int' [-Werror=sign-compare]
170 | } else if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("DXT3")) {
| ^
modules/dds/texture_loader_dds.cpp:174:57: error: comparison of integer expressions of different signedness: 'uint32_t' {aka 'unsigned int'} and 'int' [-Werror=sign-compare]
174 | } else if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("DXT5")) {
| ^
modules/dds/texture_loader_dds.cpp:177:57: error: comparison of integer expressions of different signedness: 'uint32_t' {aka 'unsigned int'} and 'int' [-Werror=sign-compare]
177 | } else if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("ATI1")) {
| ^
modules/dds/texture_loader_dds.cpp:180:57: error: comparison of integer expressions of different signedness: 'uint32_t' {aka 'unsigned int'} and 'int' [-Werror=sign-compare]
180 | } else if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("ATI2")) {
| ^
modules/dds/texture_loader_dds.cpp:183:57: error: comparison of integer expressions of different signedness: 'uint32_t' {aka 'unsigned int'} and 'int' [-Werror=sign-compare]
183 | } else if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("A2XY")) {
| ^
thirdparty/assimp/include/assimp/material.inl: In member function 'aiReturn aiMaterial::Get(const char*, unsigned int, unsigned int, aiColor3D&) const':
thirdparty/assimp/include/assimp/material.inl:176:33: error: implicitly-declared 'aiColor3D& aiColor3D::operator=(const aiColor3D&)' is deprecated [-Werror=deprecated-copy]
176 | pOut = aiColor3D(c.r,c.g,c.b);
2019-07-02 13:23:31 +02:00
|
|
|
relative_position = n.relative_position;
|
|
|
|
db_value = n.db_value;
|
|
|
|
render_db_value = n.render_db_value;
|
|
|
|
}
|
|
|
|
|
2019-02-11 06:50:55 +01:00
|
|
|
_FORCE_INLINE_ AudioNotch() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
List<AudioNotch> notches;
|
|
|
|
|
2023-04-03 18:01:11 +02:00
|
|
|
struct ThemeCache {
|
|
|
|
Color notch_color;
|
|
|
|
|
|
|
|
Ref<Font> font;
|
|
|
|
int font_size = 0;
|
|
|
|
} theme_cache;
|
|
|
|
|
2019-02-11 06:50:55 +01:00
|
|
|
public:
|
2021-05-27 09:58:44 +02:00
|
|
|
const float line_length = 5.0f;
|
|
|
|
const float label_space = 2.0f;
|
|
|
|
const float btm_padding = 9.0f;
|
|
|
|
const float top_padding = 5.0f;
|
2019-02-11 06:50:55 +01:00
|
|
|
|
2019-06-08 07:26:39 +02:00
|
|
|
void add_notch(float p_normalized_offset, float p_db_value, bool p_render_value = false);
|
2020-07-10 12:34:39 +02:00
|
|
|
Size2 get_minimum_size() const override;
|
2019-02-11 06:50:55 +01:00
|
|
|
|
|
|
|
private:
|
2023-04-03 18:01:11 +02:00
|
|
|
virtual void _update_theme_item_cache() override;
|
|
|
|
|
2019-02-11 06:50:55 +01:00
|
|
|
static void _bind_methods();
|
|
|
|
void _notification(int p_what);
|
|
|
|
void _draw_audio_notches();
|
|
|
|
|
|
|
|
public:
|
2023-04-03 18:01:11 +02:00
|
|
|
EditorAudioMeterNotches() {}
|
2019-02-11 06:50:55 +01:00
|
|
|
};
|
|
|
|
|
2017-01-25 18:30:40 +01:00
|
|
|
class AudioBusesEditorPlugin : public EditorPlugin {
|
2017-03-05 16:44:50 +01:00
|
|
|
GDCLASS(AudioBusesEditorPlugin, EditorPlugin);
|
2017-01-25 18:30:40 +01:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
EditorAudioBuses *audio_bus_editor = nullptr;
|
2017-01-25 18:30:40 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
public:
|
2020-07-10 12:34:39 +02:00
|
|
|
virtual String get_name() const override { return "SampleLibrary"; }
|
|
|
|
bool has_main_screen() const override { return false; }
|
|
|
|
virtual void edit(Object *p_node) override;
|
|
|
|
virtual bool handles(Object *p_node) const override;
|
|
|
|
virtual void make_visible(bool p_visible) override;
|
2017-01-25 18:30:40 +01:00
|
|
|
|
|
|
|
AudioBusesEditorPlugin(EditorAudioBuses *p_node);
|
|
|
|
~AudioBusesEditorPlugin();
|
|
|
|
};
|
|
|
|
|
2022-05-02 16:28:25 +02:00
|
|
|
#endif // EDITOR_AUDIO_BUSES_H
|