summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/base/classes.xml20
-rw-r--r--tools/editor/editor_node.cpp22
-rw-r--r--tools/editor/editor_node.h1
-rw-r--r--tools/editor/editor_plugin.cpp12
-rw-r--r--tools/editor/editor_plugin.h3
5 files changed, 48 insertions, 10 deletions
diff --git a/doc/base/classes.xml b/doc/base/classes.xml
index 12948d4489..4b623ea590 100644
--- a/doc/base/classes.xml
+++ b/doc/base/classes.xml
@@ -10261,21 +10261,18 @@ Returns an empty String "" at the end of the list.
remove your custom controls too.
</description>
</method>
- <method name="add_control_to_bottom_dock">
+ <method name="add_control_to_bottom_panel">
<argument index="0" name="control" type="Control">
</argument>
<argument index="1" name="title" type="String">
</argument>
<description>
- Add a control to the bottom dock (together with
+ Add a control to the bottom panel (together with
Output, Debug, Animation, etc).
- Please remember that you have to manage the
- visibility of your custom controls yourself (and likely
- hide it after adding it).
-
If your plugin is being removed, also make sure to
- remove your custom controls too.
+ remove your control by calling [method
+ remove_control_from_bottom_panel].
</description>
</method>
<method name="add_control_to_dock">
@@ -10305,6 +10302,15 @@ Returns an empty String "" at the end of the list.
the layout and remove it cleanly.
</description>
</method>
+ <method name="remove_control_from_bottom_panel">
+ <argument index="0" name="control" type="Control">
+ </argument>
+ <description>
+ Remove the control from the bottom panel. Don't forget
+ to call this if you added one, so the editor can
+ remove it cleanly.
+ </description>
+ </method>
<method name="add_custom_type">
<argument index="0" name="type" type="String">
</argument>
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp
index 4666a49655..c10f1e97fb 100644
--- a/tools/editor/editor_node.cpp
+++ b/tools/editor/editor_node.cpp
@@ -4810,6 +4810,28 @@ void EditorNode::raise_bottom_panel_item(Control *p_item) {
}
+void EditorNode::remove_bottom_panel_item(Control *p_item) {
+
+ for(int i=0;i<bottom_panel_items.size();i++) {
+
+ if (bottom_panel_items[i].control==p_item) {
+ if (p_item->is_visible()) {
+ _bottom_panel_switch(false,0);
+ }
+ bottom_panel_vb->remove_child(bottom_panel_items[i].control);
+ bottom_panel_hb->remove_child(bottom_panel_items[i].button);
+ memdelete( bottom_panel_items[i].button );
+ bottom_panel_items.remove(i);
+ break;
+ }
+ }
+
+ for(int i=0;i<bottom_panel_items.size();i++) {
+ bottom_panel_items[i].button->disconnect("toggled",this,"_bottom_panel_switch");
+ bottom_panel_items[i].button->connect("toggled",this,"_bottom_panel_switch",varray(i));
+ }
+}
+
void EditorNode::_bottom_panel_switch(bool p_enable,int p_idx) {
ERR_FAIL_INDEX(p_idx,bottom_panel_items.size());
diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h
index b5d3e536db..9fd8d07aef 100644
--- a/tools/editor/editor_node.h
+++ b/tools/editor/editor_node.h
@@ -691,6 +691,7 @@ public:
void make_bottom_panel_item_visible(Control *p_item);
void raise_bottom_panel_item(Control *p_item);
void hide_bottom_panel();
+ void remove_bottom_panel_item(Control *p_item);
EditorNode();
~EditorNode();
diff --git a/tools/editor/editor_plugin.cpp b/tools/editor/editor_plugin.cpp
index 89b9c59287..dc46361251 100644
--- a/tools/editor/editor_plugin.cpp
+++ b/tools/editor/editor_plugin.cpp
@@ -43,7 +43,7 @@ void EditorPlugin::remove_custom_type(const String& p_type){
}
-void EditorPlugin::add_control_to_bottom_dock(Control *p_control, const String &p_title) {
+void EditorPlugin::add_control_to_bottom_panel(Control *p_control, const String &p_title) {
EditorNode::get_singleton()->add_bottom_panel_item(p_title,p_control);
}
@@ -62,6 +62,13 @@ void EditorPlugin::remove_control_from_docks(Control *p_control) {
}
+void EditorPlugin::remove_control_from_bottom_panel(Control *p_control) {
+
+ ERR_FAIL_NULL(p_control);
+ EditorNode::get_singleton()->remove_bottom_panel_item(p_control);
+
+}
+
void EditorPlugin::add_control_to_container(CustomControlContainer p_location,Control *p_control) {
switch(p_location) {
@@ -270,9 +277,10 @@ Control *EditorPlugin::get_base_control() {
void EditorPlugin::_bind_methods() {
ObjectTypeDB::bind_method(_MD("add_control_to_container","container","control:Control"),&EditorPlugin::add_control_to_container);
- ObjectTypeDB::bind_method(_MD("add_control_to_bottom_dock","control:Control","title"),&EditorPlugin::add_control_to_bottom_dock);
+ ObjectTypeDB::bind_method(_MD("add_control_to_bottom_panel","control:Control","title"),&EditorPlugin::add_control_to_bottom_panel);
ObjectTypeDB::bind_method(_MD("add_control_to_dock","slot","control:Control"),&EditorPlugin::add_control_to_dock);
ObjectTypeDB::bind_method(_MD("remove_control_from_docks","control:Control"),&EditorPlugin::remove_control_from_docks);
+ ObjectTypeDB::bind_method(_MD("remove_control_from_bottom_panel","control:Control"),&EditorPlugin::remove_control_from_bottom_panel);
ObjectTypeDB::bind_method(_MD("add_custom_type","type","base","script:Script","icon:Texture"),&EditorPlugin::add_custom_type);
ObjectTypeDB::bind_method(_MD("remove_custom_type","type"),&EditorPlugin::remove_custom_type);
diff --git a/tools/editor/editor_plugin.h b/tools/editor/editor_plugin.h
index 75a3b3b26f..a7460d7fde 100644
--- a/tools/editor/editor_plugin.h
+++ b/tools/editor/editor_plugin.h
@@ -91,9 +91,10 @@ public:
//TODO: send a resoucre for editing to the editor node?
void add_control_to_container(CustomControlContainer p_location, Control *p_control);
- void add_control_to_bottom_dock(Control *p_control, const String &p_title);
+ void add_control_to_bottom_panel(Control *p_control, const String &p_title);
void add_control_to_dock(DockSlot p_slot,Control *p_control);
void remove_control_from_docks(Control *p_control);
+ void remove_control_from_bottom_panel(Control *p_control);
virtual Ref<SpatialEditorGizmo> create_spatial_gizmo(Spatial* p_spatial);
virtual bool forward_input_event(const InputEvent& p_event);