diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-01-24 20:11:13 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-01-24 20:12:23 -0300 |
commit | e8d34365085c2321acb0bd35aabbad293c74e744 (patch) | |
tree | e97ae67d26e1f459530bad31958e0071305de42c /tools/editor | |
parent | 838490ce5d8d5d34932919834e2c22aa65e4a20b (diff) |
delete bus effects is now possible
Diffstat (limited to 'tools/editor')
-rw-r--r-- | tools/editor/editor_audio_buses.cpp | 44 | ||||
-rw-r--r-- | tools/editor/editor_audio_buses.h | 4 |
2 files changed, 47 insertions, 1 deletions
diff --git a/tools/editor/editor_audio_buses.cpp b/tools/editor/editor_audio_buses.cpp index 4df748101c..425477890e 100644 --- a/tools/editor/editor_audio_buses.cpp +++ b/tools/editor/editor_audio_buses.cpp @@ -538,6 +538,41 @@ void EditorAudioBus::drop_data_fw(const Point2& p_point,const Variant& p_data,Co } +void EditorAudioBus::_delete_effect_pressed(int p_option) { + + TreeItem * item = effects->get_selected(); + if (!item) + return; + + if (item->get_metadata(0).get_type()!=Variant::INT) + return; + + int index = item->get_metadata(0); + + UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); + ur->create_action("Delete Bus Effect"); + ur->add_do_method(AudioServer::get_singleton(),"remove_bus_effect",get_index(),index); + ur->add_undo_method(AudioServer::get_singleton(),"add_bus_effect",get_index(),AudioServer::get_singleton()->get_bus_effect(get_index(),index),index); + ur->add_undo_method(AudioServer::get_singleton(),"set_bus_effect_enabled",get_index(),index,AudioServer::get_singleton()->is_bus_effect_enabled(get_index(),index)); + ur->add_do_method(buses,"_update_bus",get_index()); + ur->add_undo_method(buses,"_update_bus",get_index()); + ur->commit_action(); + + +} + +void EditorAudioBus::_effect_rmb(const Vector2& p_pos) { + + TreeItem * item = effects->get_selected(); + if (!item) + return; + + if (item->get_metadata(0).get_type()!=Variant::INT) + return; + + delete_effect_popup->set_pos(get_global_mouse_pos()); + delete_effect_popup->popup(); +} void EditorAudioBus::_bind_methods() { @@ -558,6 +593,8 @@ void EditorAudioBus::_bind_methods() { ClassDB::bind_method("get_drag_data_fw",&EditorAudioBus::get_drag_data_fw); ClassDB::bind_method("can_drop_data_fw",&EditorAudioBus::can_drop_data_fw); ClassDB::bind_method("drop_data_fw",&EditorAudioBus::drop_data_fw); + ClassDB::bind_method("_delete_effect_pressed",&EditorAudioBus::_delete_effect_pressed); + ClassDB::bind_method("_effect_rmb",&EditorAudioBus::_effect_rmb); @@ -645,7 +682,8 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses) { effects->connect("cell_selected",this,"_effect_selected"); effects->set_edit_checkbox_cell_only_when_checkbox_is_pressed(true); effects->set_drag_forwarding(this); - + effects->connect("item_rmb_selected",this,"_effect_rmb"); + effects->set_allow_rmb_select(true); send = memnew( OptionButton ); send->set_clip_text(true); @@ -680,6 +718,10 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses) { add_child(delete_popup); delete_popup->connect("index_pressed",this,"_delete_pressed"); + delete_effect_popup = memnew( PopupMenu ); + delete_effect_popup->add_item("Delete Effect"); + add_child(delete_effect_popup); + delete_effect_popup->connect("index_pressed",this,"_delete_effect_pressed"); } diff --git a/tools/editor/editor_audio_buses.h b/tools/editor/editor_audio_buses.h index 5a3d25a143..c6621c08d8 100644 --- a/tools/editor/editor_audio_buses.h +++ b/tools/editor/editor_audio_buses.h @@ -35,6 +35,7 @@ class EditorAudioBus : public PanelContainer { PopupMenu *effect_options; PopupMenu *delete_popup; + PopupMenu *delete_effect_popup; Button *solo; Button *mute; @@ -57,6 +58,9 @@ class EditorAudioBus : public PanelContainer { void _effect_edited(); void _effect_add(int p_which); void _effect_selected(); + void _delete_effect_pressed(int p_option); + void _effect_rmb(const Vector2& p_pos); + virtual Variant get_drag_data(const Point2& p_point); virtual bool can_drop_data(const Point2& p_point,const Variant& p_data) const; |