summaryrefslogtreecommitdiff
path: root/tools/editor
diff options
context:
space:
mode:
Diffstat (limited to 'tools/editor')
-rw-r--r--tools/editor/create_dialog.cpp23
-rw-r--r--tools/editor/create_dialog.h5
-rw-r--r--tools/editor/editor_help.cpp158
-rw-r--r--tools/editor/editor_help.h17
-rw-r--r--tools/editor/editor_node.cpp2
-rw-r--r--tools/editor/plugins/script_editor_plugin.cpp29
-rw-r--r--tools/editor/plugins/script_editor_plugin.h9
-rw-r--r--tools/editor/project_settings.cpp42
-rw-r--r--tools/editor/property_editor.cpp174
-rw-r--r--tools/editor/property_editor.h4
-rw-r--r--tools/editor/property_selector.cpp598
-rw-r--r--tools/editor/property_selector.h55
12 files changed, 1052 insertions, 64 deletions
diff --git a/tools/editor/create_dialog.cpp b/tools/editor/create_dialog.cpp
index b0cdd79798..5aac8bff09 100644
--- a/tools/editor/create_dialog.cpp
+++ b/tools/editor/create_dialog.cpp
@@ -140,7 +140,7 @@ void CreateDialog::_update_search() {
search_options->clear();
-
+ help_bit->set_text("");
/*
TreeItem *root = search_options->create_item();
_parse_fs(EditorFileSystem::get_singleton()->get_filesystem());
@@ -336,11 +336,27 @@ String CreateDialog::get_base_type() const {
return base_type;
}
+void CreateDialog::_item_selected() {
+
+ TreeItem *item = search_options->get_selected();
+ if (!item)
+ return;
+
+ String name = item->get_text(0);
+
+ if (!EditorHelp::get_doc_data()->class_list.has(name))
+ return;
+
+ help_bit->set_text(EditorHelp::get_doc_data()->class_list[name].brief_description);
+
+}
+
void CreateDialog::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_text_changed"),&CreateDialog::_text_changed);
ObjectTypeDB::bind_method(_MD("_confirmed"),&CreateDialog::_confirmed);
ObjectTypeDB::bind_method(_MD("_sbox_input"),&CreateDialog::_sbox_input);
+ ObjectTypeDB::bind_method(_MD("_item_selected"),&CreateDialog::_item_selected);
ADD_SIGNAL(MethodInfo("create"));
@@ -364,9 +380,14 @@ CreateDialog::CreateDialog() {
register_text_enter(search_box);
set_hide_on_ok(false);
search_options->connect("item_activated",this,"_confirmed");
+ search_options->connect("cell_selected",this,"_item_selected");
// search_options->set_hide_root(true);
base_type="Object";
+ help_bit = memnew( EditorHelpBit );
+ vbc->add_margin_child(TTR("Description:"),help_bit);
+ help_bit->connect("request_hide",this,"_closed");
+
}
diff --git a/tools/editor/create_dialog.h b/tools/editor/create_dialog.h
index 8957479beb..41156b538a 100644
--- a/tools/editor/create_dialog.h
+++ b/tools/editor/create_dialog.h
@@ -34,6 +34,7 @@
#include "scene/gui/tree.h"
#include "scene/gui/line_edit.h"
#include "scene/gui/label.h"
+#include "editor_help.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
@@ -49,6 +50,10 @@ class CreateDialog : public ConfirmationDialog {
Tree *search_options;
String base_type;
+ EditorHelpBit *help_bit;
+
+ void _item_selected();
+
void _update_search();
void _sbox_input(const InputEvent& p_ie);
diff --git a/tools/editor/editor_help.cpp b/tools/editor/editor_help.cpp
index 4ab86ad512..8f486ba0c2 100644
--- a/tools/editor/editor_help.cpp
+++ b/tools/editor/editor_help.cpp
@@ -31,7 +31,7 @@
#include "editor_settings.h"
#include "os/keyboard.h"
#include "doc_data_compressed.h"
-
+#include "tools/editor/plugins/script_editor_plugin.h"
#include "os/keyboard.h"
@@ -1256,16 +1256,20 @@ void EditorHelp::_help_callback(const String& p_topic) {
}
-void EditorHelp::_add_text(const String& p_bbcode) {
- /*class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/text_color"));
- class_desc->push_font( get_font("normal","Fonts") );
- class_desc->push_indent(1);*/
+static void _add_text_to_rt(const String& p_bbcode,RichTextLabel *p_rt) {
+
+ DocData *doc = EditorHelp::get_doc_data();
+ String base_path;
+
+ /*p_rt->push_color(EditorSettings::get_singleton()->get("text_editor/text_color"));
+ p_rt->push_font( get_font("normal","Fonts") );
+ p_rt->push_indent(1);*/
int pos = 0;
- Ref<Font> doc_font = get_font("doc","EditorFonts");
- Ref<Font> doc_code_font = get_font("doc_source","EditorFonts");
+ Ref<Font> doc_font = p_rt->get_font("doc","EditorFonts");
+ Ref<Font> doc_code_font = p_rt->get_font("doc_source","EditorFonts");
String bbcode=p_bbcode.replace("\t"," ").replace("\r"," ").strip_edges();
@@ -1333,7 +1337,7 @@ void EditorHelp::_add_text(const String& p_bbcode) {
brk_pos=bbcode.length();
if (brk_pos > pos) {
- class_desc->add_text(bbcode.substr(pos,brk_pos-pos));
+ p_rt->add_text(bbcode.substr(pos,brk_pos-pos));
}
@@ -1344,7 +1348,7 @@ void EditorHelp::_add_text(const String& p_bbcode) {
if (brk_end==-1) {
//no close, add the rest
- class_desc->add_text(bbcode.substr(brk_pos,bbcode.length()-brk_pos));
+ p_rt->add_text(bbcode.substr(brk_pos,bbcode.length()-brk_pos));
break;
}
@@ -1362,7 +1366,7 @@ void EditorHelp::_add_text(const String& p_bbcode) {
}
if (!tag_ok) {
- class_desc->add_text("[");
+ p_rt->add_text("[");
pos++;
continue;
}
@@ -1370,32 +1374,32 @@ void EditorHelp::_add_text(const String& p_bbcode) {
tag_stack.pop_front();
pos=brk_end+1;
if (tag!="/img")
- class_desc->pop();
+ p_rt->pop();
} else if (tag.begins_with("method ")) {
String m = tag.substr(7,tag.length());
- class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color"));
- class_desc->push_meta("@"+m);
- class_desc->add_text(m+"()");
- class_desc->pop();
- class_desc->pop();
+ p_rt->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color"));
+ p_rt->push_meta("@"+m);
+ p_rt->add_text(m+"()");
+ p_rt->pop();
+ p_rt->pop();
pos=brk_end+1;
} else if (doc->class_list.has(tag)) {
- class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color"));
- class_desc->push_meta("#"+tag);
- class_desc->add_text(tag);
- class_desc->pop();
- class_desc->pop();
+ p_rt->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color"));
+ p_rt->push_meta("#"+tag);
+ p_rt->add_text(tag);
+ p_rt->pop();
+ p_rt->pop();
pos=brk_end+1;
} else if (tag=="b") {
//use bold font
- class_desc->push_font(doc_code_font);
+ p_rt->push_font(doc_code_font);
pos=brk_end+1;
tag_stack.push_front(tag);
} else if (tag=="i") {
@@ -1406,37 +1410,37 @@ void EditorHelp::_add_text(const String& p_bbcode) {
text_color.r*=1.1;
text_color.g*=1.1;
text_color.b*=1.1;
- class_desc->push_color(text_color);
- //class_desc->push_font(get_font("italic","Fonts"));
+ p_rt->push_color(text_color);
+ //p_rt->push_font(get_font("italic","Fonts"));
pos=brk_end+1;
tag_stack.push_front(tag);
} else if (tag=="code" || tag=="codeblock") {
//use monospace font
- class_desc->push_font(doc_code_font);
+ p_rt->push_font(doc_code_font);
pos=brk_end+1;
tag_stack.push_front(tag);
} else if (tag=="center") {
//use monospace font
- class_desc->push_align(RichTextLabel::ALIGN_CENTER);
+ p_rt->push_align(RichTextLabel::ALIGN_CENTER);
pos=brk_end+1;
tag_stack.push_front(tag);
} else if (tag=="br") {
//use monospace font
- class_desc->add_newline();
+ p_rt->add_newline();
pos=brk_end+1;
} else if (tag=="u") {
//use underline
- class_desc->push_underline();
+ p_rt->push_underline();
pos=brk_end+1;
tag_stack.push_front(tag);
} else if (tag=="s") {
//use strikethrough (not supported underline instead)
- class_desc->push_underline();
+ p_rt->push_underline();
pos=brk_end+1;
tag_stack.push_front(tag);
@@ -1447,14 +1451,14 @@ void EditorHelp::_add_text(const String& p_bbcode) {
if (end==-1)
end=bbcode.length();
String url = bbcode.substr(brk_end+1,end-brk_end-1);
- class_desc->push_meta(url);
+ p_rt->push_meta(url);
pos=brk_end+1;
tag_stack.push_front(tag);
} else if (tag.begins_with("url=")) {
String url = tag.substr(4,tag.length());
- class_desc->push_meta(url);
+ p_rt->push_meta(url);
pos=brk_end+1;
tag_stack.push_front("url");
} else if (tag=="img") {
@@ -1467,7 +1471,7 @@ void EditorHelp::_add_text(const String& p_bbcode) {
Ref<Texture> texture = ResourceLoader::load(base_path+"/"+image,"Texture");
if (texture.is_valid())
- class_desc->add_image(texture);
+ p_rt->add_image(texture);
pos=end;
tag_stack.push_front(tag);
@@ -1515,7 +1519,7 @@ void EditorHelp::_add_text(const String& p_bbcode) {
- class_desc->push_color(color);
+ p_rt->push_color(color);
pos=brk_end+1;
tag_stack.push_front("color");
@@ -1526,9 +1530,9 @@ void EditorHelp::_add_text(const String& p_bbcode) {
Ref<Font> font = ResourceLoader::load(base_path+"/"+fnt,"Font");
if (font.is_valid())
- class_desc->push_font(font);
+ p_rt->push_font(font);
else {
- class_desc->push_font(doc_font);
+ p_rt->push_font(doc_font);
}
pos=brk_end+1;
@@ -1537,15 +1541,23 @@ void EditorHelp::_add_text(const String& p_bbcode) {
} else {
- class_desc->add_text("["); //ignore
+ p_rt->add_text("["); //ignore
pos=brk_pos+1;
}
}
- /*class_desc->pop();
- class_desc->pop();
- class_desc->pop();*/
+ /*p_rt->pop();
+ p_rt->pop();
+ p_rt->pop();*/
+
+}
+
+
+void EditorHelp::_add_text(const String& p_bbcode) {
+
+
+ _add_text_to_rt(p_bbcode,class_desc);
}
@@ -1703,3 +1715,71 @@ EditorHelp::~EditorHelp() {
}
+/////////////
+
+
+
+void EditorHelpBit::_go_to_help(String p_what) {
+
+ EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT);
+ ScriptEditor::get_singleton()->goto_help(p_what);
+ emit_signal("request_hide");
+}
+
+void EditorHelpBit::_meta_clicked(String p_select) {
+
+
+ // print_line("LINK: "+p_select);
+ if (p_select.begins_with("#")) {
+ //_goto_desc(p_select.substr(1,p_select.length()));
+ _go_to_help("class_name:"+p_select.substr(1,p_select.length()));
+ return;
+ } else if (p_select.begins_with("@")) {
+
+ String m = p_select.substr(1,p_select.length());
+
+ if (m.find(".")!=-1) {
+ //must go somewhere else
+
+ _go_to_help("class_method:"+m.get_slice(".",0)+":"+m.get_slice(".",0));
+ } else {
+//
+ // if (!method_line.has(m))
+ // return;
+ //class_desc->scroll_to_line(method_line[m]);
+ }
+
+ }
+
+
+}
+
+void EditorHelpBit::_bind_methods() {
+
+ ObjectTypeDB::bind_method("_meta_clicked",&EditorHelpBit::_meta_clicked);
+ ADD_SIGNAL(MethodInfo("request_hide"));
+}
+
+void EditorHelpBit::_notification(int p_what){
+
+ if (p_what==NOTIFICATION_ENTER_TREE) {
+ add_style_override("panel",get_stylebox("normal","TextEdit"));
+ }
+}
+
+
+void EditorHelpBit::set_text(const String& p_text) {
+
+ rich_text->clear();
+ _add_text_to_rt(p_text,rich_text);
+}
+
+EditorHelpBit::EditorHelpBit() {
+
+ rich_text = memnew( RichTextLabel );
+ add_child(rich_text);
+ rich_text->set_area_as_parent_rect(8*EDSCALE);
+ rich_text->connect("meta_clicked",this,"_meta_clicked");
+ set_custom_minimum_size(Size2(0,70*EDSCALE));
+
+}
diff --git a/tools/editor/editor_help.h b/tools/editor/editor_help.h
index c3d19894df..b0dc2809fe 100644
--- a/tools/editor/editor_help.h
+++ b/tools/editor/editor_help.h
@@ -200,6 +200,23 @@ public:
+class EditorHelpBit : public Panel {
+ OBJ_TYPE( EditorHelpBit, Panel);
+
+ RichTextLabel *rich_text;
+ void _go_to_help(String p_what);
+ void _meta_clicked(String p_what);
+
+
+protected:
+
+ static void _bind_methods();
+ void _notification(int p_what);
+public:
+
+ void set_text(const String& p_text);
+ EditorHelpBit();
+};
#endif // EDITOR_HELP_H
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp
index 85c560bf9d..ea553c5597 100644
--- a/tools/editor/editor_node.cpp
+++ b/tools/editor/editor_node.cpp
@@ -1673,7 +1673,7 @@ void EditorNode::_edit_current() {
if (main_plugin) {
- if (main_plugin!=editor_plugin_screen) {
+ if (main_plugin!=editor_plugin_screen && (!ScriptEditor::get_singleton() || !ScriptEditor::get_singleton()->is_visible() || ScriptEditor::get_singleton()->can_take_away_focus())) {
// update screen main_plugin
diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp
index 74c8ac9766..fdb7856b83 100644
--- a/tools/editor/plugins/script_editor_plugin.cpp
+++ b/tools/editor/plugins/script_editor_plugin.cpp
@@ -987,6 +987,20 @@ void ScriptEditor::_notification(int p_what) {
}
+bool ScriptEditor::can_take_away_focus() const {
+
+ int selected = tab_container->get_current_tab();
+ if (selected<0 || selected>=tab_container->get_child_count())
+ return true;
+
+ ScriptEditorBase *current = tab_container->get_child(selected)->cast_to<ScriptEditorBase>();
+ if (!current)
+ return true;
+
+
+ return current->can_lose_focus_on_node_selection();
+
+}
void ScriptEditor::close_builtin_scripts_from_scene(const String& p_scene) {
@@ -1397,7 +1411,7 @@ void ScriptEditor::_update_script_names() {
-void ScriptEditor::edit(const Ref<Script>& p_script) {
+void ScriptEditor::edit(const Ref<Script>& p_script, bool p_grab_focus) {
if (p_script.is_null())
return;
@@ -1471,7 +1485,9 @@ void ScriptEditor::edit(const Ref<Script>& p_script) {
}
- _go_to_tab(tab_container->get_tab_count()-1);
+ if (p_grab_focus) {
+ _go_to_tab(tab_container->get_tab_count()-1);
+ }
@@ -1932,6 +1948,13 @@ void ScriptEditor::_help_search(String p_text) {
help_search_dialog->popup(p_text);
}
+void ScriptEditor::_open_script_request(const String& p_path) {
+
+ Ref<Script> script = ResourceLoader::load(p_path);
+ if (script.is_valid()) {
+ script_editor->edit(script,false);
+ }
+}
int ScriptEditor::script_editor_func_count=0;
CreateScriptEditorFunc ScriptEditor::script_editor_funcs[ScriptEditor::SCRIPT_EDITOR_FUNC_MAX];
@@ -2208,6 +2231,8 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
edit_pass=0;
trim_trailing_whitespace_on_save = false;
+
+ ScriptServer::edit_request_func=_open_script_request;
}
diff --git a/tools/editor/plugins/script_editor_plugin.h b/tools/editor/plugins/script_editor_plugin.h
index 5cb70e13d7..1a23ffed72 100644
--- a/tools/editor/plugins/script_editor_plugin.h
+++ b/tools/editor/plugins/script_editor_plugin.h
@@ -101,6 +101,7 @@ public:
virtual void add_callback(const String& p_function,StringArray p_args)=0;
virtual void update_settings()=0;
virtual void set_debugger_active(bool p_active)=0;
+ virtual bool can_lose_focus_on_node_selection() { return true; }
virtual void set_tooltip_request_func(String p_method,Object* p_obj)=0;
virtual Control *get_edit_menu()=0;
@@ -285,6 +286,8 @@ class ScriptEditor : public VBoxContainer {
int file_dialog_option;
void _file_dialog_action(String p_file);
+ static void _open_script_request(const String& p_path);
+
static ScriptEditor *script_editor;
protected:
void _notification(int p_what);
@@ -297,7 +300,7 @@ public:
void apply_scripts() const;
void ensure_select_current();
- void edit(const Ref<Script>& p_script);
+ void edit(const Ref<Script>& p_script,bool p_grab_focus=true);
Dictionary get_state() const;
void set_state(const Dictionary& p_state);
@@ -320,6 +323,10 @@ public:
void close_builtin_scripts_from_scene(const String& p_scene);
+ void goto_help(const String& p_desc) { _help_class_goto(p_desc); }
+
+ bool can_take_away_focus() const;
+
ScriptEditorDebugger *get_debugger() { return debugger; }
void set_live_auto_reload_running_scripts(bool p_enabled);
diff --git a/tools/editor/project_settings.cpp b/tools/editor/project_settings.cpp
index e8d22143ee..03eec960d2 100644
--- a/tools/editor/project_settings.cpp
+++ b/tools/editor/project_settings.cpp
@@ -337,7 +337,7 @@ void ProjectSettings::_add_item(int p_item){
device_index->add_item(TTR("Button 7"));
device_index->add_item(TTR("Button 8"));
device_index->add_item(TTR("Button 9"));
- device_input->popup_centered(Size2(350,95));
+ device_input->popup_centered_minsize(Size2(350,95));
} break;
case InputEvent::JOYSTICK_MOTION: {
@@ -349,12 +349,12 @@ void ProjectSettings::_add_item(int p_item){
String desc = _axis_names[i];
device_index->add_item(TTR("Axis")+" "+itos(i/2)+" "+(i&1?"+":"-")+desc);
}
- device_input->popup_centered(Size2(350,95));
+ device_input->popup_centered_minsize(Size2(350,95));
} break;
case InputEvent::JOYSTICK_BUTTON: {
- device_id->set_val(0);
+ device_id->set_val(3);
device_index_label->set_text(TTR("Joystick Button Index:"));
device_index->clear();
@@ -362,7 +362,7 @@ void ProjectSettings::_add_item(int p_item){
device_index->add_item(itos(i)+": "+String(_button_names[i]));
}
- device_input->popup_centered(Size2(350,95));
+ device_input->popup_centered_minsize(Size2(350,95));
} break;
default:{}
@@ -1432,30 +1432,32 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
device_input->get_ok()->set_text(TTR("Add"));
device_input->connect("confirmed",this,"_device_input_add");
- l = memnew( Label );
- l->set_text(TTR("Device:"));
- l->set_pos(Point2(15,10));
- device_input->add_child(l);
+ hbc = memnew( HBoxContainer );
+ device_input->add_child(hbc);
+ device_input->set_child_rect(hbc);
+
+ VBoxContainer *vbc_left = memnew( VBoxContainer );
+ hbc->add_child(vbc_left);
l = memnew( Label );
- l->set_text(TTR("Index:"));
- l->set_pos(Point2(90,10));
- device_input->add_child(l);
- device_index_label=l;
+ l->set_text(TTR("Device:"));
+ vbc_left->add_child(l);
device_id = memnew( SpinBox );
- device_id->set_pos(Point2(20,30));
- device_id->set_size(Size2(70,10));
device_id->set_val(0);
+ vbc_left->add_child(device_id);
- device_input->add_child(device_id);
+ VBoxContainer *vbc_right = memnew( VBoxContainer );
+ hbc->add_child(vbc_right);
+ vbc_right->set_h_size_flags(SIZE_EXPAND_FILL);
- device_index = memnew( OptionButton );
- device_index->set_pos(Point2(95,30));
- device_index->set_size(Size2(300,10));
- device_index->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,10);
+ l = memnew( Label );
+ l->set_text(TTR("Index:"));
+ vbc_right->add_child(l);
+ device_index_label=l;
- device_input->add_child(device_index);
+ device_index = memnew( OptionButton );
+ vbc_right->add_child(device_index);
/*
save = memnew( Button );
diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp
index 0518018e5a..9fc9d52aa1 100644
--- a/tools/editor/property_editor.cpp
+++ b/tools/editor/property_editor.cpp
@@ -46,6 +46,7 @@
#include "scene/main/viewport.h"
#include "editor_file_system.h"
#include "create_dialog.h"
+#include "property_selector.h"
void CustomPropertyEditor::_notification(int p_what) {
@@ -83,6 +84,11 @@ void CustomPropertyEditor::_menu_option(int p_which) {
v=val;
emit_signal("variant_changed");
+ } else if (hint==PROPERTY_HINT_ENUM) {
+
+ v=p_which;
+ emit_signal("variant_changed");
+
}
} break;
case Variant::OBJECT: {
@@ -282,6 +288,16 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
switch(type) {
+ case Variant::BOOL: {
+
+ CheckBox *c=checks20[0];
+ c->set_text("True");
+ c->set_pos(Vector2(4,4));
+ c->set_pressed(v);
+ c->show();
+ set_size(checks20[0]->get_pos()+checks20[0]->get_size()+Vector2(4,4)*EDSCALE);
+
+ } break;
case Variant::INT:
case Variant::REAL: {
@@ -322,9 +338,24 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
set_size(Size2(70,35)*EDSCALE);
}
+ } else if (hint==PROPERTY_HINT_ENUM) {
+
+ menu->clear();
+ Vector<String> options = hint_text.split(",");
+ for(int i=0;i<options.size();i++) {
+ menu->add_item(options[i],i);
+ }
+ menu->set_pos(get_pos());
+ menu->popup();
+ hide();
+ updating=false;
+ return false;
+
} else if (hint==PROPERTY_HINT_ALL_FLAGS) {
+ checks20[0]->set_text("");
+
uint32_t flgs = v;
for(int i=0;i<2;i++) {
@@ -438,6 +469,7 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
} else if (hint==PROPERTY_HINT_TYPE_STRING) {
+
if (!create_dialog) {
create_dialog = memnew( CreateDialog );
create_dialog->connect("create",this,"_create_dialog_callback");
@@ -452,6 +484,112 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
create_dialog->popup(false);
hide();
+ updating=false;
+ return false;
+
+
+ } else if (hint==PROPERTY_HINT_METHOD_OF_VARIANT_TYPE) {
+#define MAKE_PROPSELECT if (!property_select) { property_select = memnew(PropertySelector); property_select->connect("selected",this,"_create_selected_property"); add_child(property_select); } hide();
+
+ MAKE_PROPSELECT;
+
+ Variant::Type type=Variant::NIL;
+ for(int i=0;i<Variant::VARIANT_MAX;i++) {
+ if (hint_text==Variant::get_type_name(Variant::Type(i))) {
+ type=Variant::Type(i);
+ }
+ }
+ if (type)
+ property_select->select_method_from_basic_type(type,v);
+ updating=false;
+ return false;
+
+ } else if (hint==PROPERTY_HINT_METHOD_OF_BASE_TYPE) {
+ MAKE_PROPSELECT
+
+ property_select->select_method_from_base_type(hint_text,v);
+
+ updating=false;
+ return false;
+
+ } else if (hint==PROPERTY_HINT_METHOD_OF_INSTANCE) {
+
+ MAKE_PROPSELECT
+
+ Object *instance = ObjectDB::get_instance(hint_text.to_int64());
+ if (instance)
+ property_select->select_method_from_instance(instance,v);
+ updating=false;
+ return false;
+
+ } else if (hint==PROPERTY_HINT_METHOD_OF_SCRIPT) {
+ MAKE_PROPSELECT
+
+ Object *obj = ObjectDB::get_instance(hint_text.to_int64());
+ if (obj && obj->cast_to<Script>()) {
+ property_select->select_method_from_script(obj->cast_to<Script>(),v);
+ }
+
+ updating=false;
+ return false;
+
+ } else if (hint==PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE) {
+
+ MAKE_PROPSELECT
+ Variant::Type type=Variant::NIL;
+ String tname=hint_text;
+ if (tname.find(".")!=-1)
+ tname=tname.get_slice(".",0);
+ for(int i=0;i<Variant::VARIANT_MAX;i++) {
+ if (tname==Variant::get_type_name(Variant::Type(i))) {
+ type=Variant::Type(Variant::Type(i));
+ }
+ }
+ InputEvent::Type iet = InputEvent::NONE;
+ if (hint_text.find(".")!=-1) {
+ iet=InputEvent::Type(int(hint_text.get_slice(".",1).to_int()));
+ }
+ if (type)
+ property_select->select_property_from_basic_type(type,iet,v);
+
+ updating=false;
+ return false;
+
+ } else if (hint==PROPERTY_HINT_PROPERTY_OF_BASE_TYPE) {
+
+ MAKE_PROPSELECT
+
+ property_select->select_property_from_base_type(hint_text,v);
+
+ updating=false;
+ return false;
+
+ } else if (hint==PROPERTY_HINT_PROPERTY_OF_INSTANCE) {
+
+ Object *instance = ObjectDB::get_instance(hint_text.to_int64());
+ if (instance)
+ property_select->select_property_from_instance(instance,v);
+
+ updating=false;
+ return false;
+
+ } else if (hint==PROPERTY_HINT_PROPERTY_OF_SCRIPT) {
+ MAKE_PROPSELECT
+
+ Object *obj = ObjectDB::get_instance(hint_text.to_int64());
+ if (obj && obj->cast_to<Script>()) {
+ property_select->select_property_from_script(obj->cast_to<Script>(),v);
+ }
+
+ updating=false;
+ return false;
+
+ } else if (hint==PROPERTY_HINT_TYPE_STRING) {
+ if (!create_dialog) {
+ create_dialog = memnew( CreateDialog );
+ create_dialog->connect("create",this,"_create_dialog_callback");
+ add_child(create_dialog);
+ }
} else {
List<String> names;
@@ -1009,6 +1147,10 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
return;
switch(type) {
+ case Variant::BOOL: {
+ v=checks20[0]->is_pressed();
+ emit_signal("variant_changed");
+ } break;
case Variant::INT: {
if (hint==PROPERTY_HINT_ALL_FLAGS) {
@@ -1043,6 +1185,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
file->clear_filters();
+
if (hint_text!="") {
Vector<String> extensions=hint_text.split(",");
for(int i=0;i<extensions.size();i++) {
@@ -1360,6 +1503,13 @@ void CustomPropertyEditor::_create_dialog_callback() {
emit_signal("variant_changed");
}
+void CustomPropertyEditor::_create_selected_property(const String& p_prop) {
+
+
+ v=p_prop;
+ emit_signal("variant_changed");
+}
+
void CustomPropertyEditor::_modified(String p_string) {
if (updating)
@@ -1753,6 +1903,7 @@ void CustomPropertyEditor::_bind_methods() {
ObjectTypeDB::bind_method( "_text_edit_changed",&CustomPropertyEditor::_text_edit_changed);
ObjectTypeDB::bind_method( "_menu_option",&CustomPropertyEditor::_menu_option);
ObjectTypeDB::bind_method( "_create_dialog_callback",&CustomPropertyEditor::_create_dialog_callback);
+ ObjectTypeDB::bind_method( "_create_selected_property",&CustomPropertyEditor::_create_selected_property);
@@ -1877,6 +2028,7 @@ CustomPropertyEditor::CustomPropertyEditor() {
slider->connect("value_changed",this,"_range_modified");
create_dialog = NULL;
+ property_select = NULL;
}
bool PropertyEditor::_might_be_in_instance() {
@@ -2150,6 +2302,19 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String& p
p_item->set_text(1,obj->get(p_name));
}
+ if ( p_hint==PROPERTY_HINT_METHOD_OF_VARIANT_TYPE ||
+ p_hint==PROPERTY_HINT_METHOD_OF_BASE_TYPE ||
+ p_hint==PROPERTY_HINT_METHOD_OF_INSTANCE ||
+ p_hint==PROPERTY_HINT_METHOD_OF_SCRIPT ||
+ p_hint==PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE ||
+ p_hint==PROPERTY_HINT_PROPERTY_OF_BASE_TYPE ||
+ p_hint==PROPERTY_HINT_PROPERTY_OF_INSTANCE ||
+ p_hint==PROPERTY_HINT_PROPERTY_OF_SCRIPT ) {
+
+ p_item->set_text(1,obj->get(p_name));
+ }
+
+
if (p_hint==PROPERTY_HINT_ENUM) {
Vector<String> strings = p_hint_text.split(",");
@@ -3172,6 +3337,14 @@ void PropertyEditor::update_tree() {
} break;
+ case PROPERTY_HINT_METHOD_OF_VARIANT_TYPE: ///< a property of a type
+ case PROPERTY_HINT_METHOD_OF_BASE_TYPE: ///< a method of a base type
+ case PROPERTY_HINT_METHOD_OF_INSTANCE: ///< a method of an instance
+ case PROPERTY_HINT_METHOD_OF_SCRIPT: ///< a method of a script & base
+ case PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE: ///< a property of a type
+ case PROPERTY_HINT_PROPERTY_OF_BASE_TYPE: ///< a property of a base type
+ case PROPERTY_HINT_PROPERTY_OF_INSTANCE: ///< a property of an instance
+ case PROPERTY_HINT_PROPERTY_OF_SCRIPT: ///< a property of a script & base
case PROPERTY_HINT_TYPE_STRING: {
item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM);
@@ -3181,6 +3354,7 @@ void PropertyEditor::update_tree() {
item->set_text(1,obj->get(p.name));
} break;
+
default: {
item->set_cell_mode( 1, TreeItem::CELL_MODE_STRING );
diff --git a/tools/editor/property_editor.h b/tools/editor/property_editor.h
index d911aae883..6c6c309d32 100644
--- a/tools/editor/property_editor.h
+++ b/tools/editor/property_editor.h
@@ -49,6 +49,8 @@
class PropertyValueEvaluator;
class CreateDialog;
+class PropertySelector;
+
class CustomPropertyEditor : public Popup {
OBJ_TYPE( CustomPropertyEditor, Popup );
@@ -103,6 +105,7 @@ class CustomPropertyEditor : public Popup {
Control *easing_draw;
CreateDialog *create_dialog;
+ PropertySelector *property_select;
Object* owner;
@@ -120,6 +123,7 @@ class CustomPropertyEditor : public Popup {
void _action_pressed(int p_which);
void _type_create_selected(int p_idx);
void _create_dialog_callback();
+ void _create_selected_property(const String &p_prop);
void _color_changed(const Color& p_color);
diff --git a/tools/editor/property_selector.cpp b/tools/editor/property_selector.cpp
new file mode 100644
index 0000000000..20b72240d9
--- /dev/null
+++ b/tools/editor/property_selector.cpp
@@ -0,0 +1,598 @@
+#include "property_selector.h"
+#include "editor_scale.h"
+
+#include "os/keyboard.h"
+
+void PropertySelector::_text_changed(const String& p_newtext) {
+
+ _update_search();
+}
+
+void PropertySelector::_sbox_input(const InputEvent& p_ie) {
+
+ if (p_ie.type==InputEvent::KEY) {
+
+ switch(p_ie.key.scancode) {
+ case KEY_UP:
+ case KEY_DOWN:
+ case KEY_PAGEUP:
+ case KEY_PAGEDOWN: {
+
+ search_options->call("_input_event", p_ie);
+ search_box->accept_event();
+
+ TreeItem *root = search_options->get_root();
+ if (!root->get_children())
+ break;
+
+ TreeItem *current = search_options->get_selected();
+
+ TreeItem *item = search_options->get_next_selected(root);
+ while (item) {
+ item->deselect(0);
+ item = search_options->get_next_selected(item);
+ }
+
+ current->select(0);
+
+ } break;
+ }
+ }
+}
+
+
+void PropertySelector::_update_search() {
+
+
+ if (properties)
+ set_title(TTR("Select Property"));
+ else
+ set_title(TTR("Select Method"));
+
+ search_options->clear();
+ help_bit->set_text("");
+
+
+ TreeItem *root = search_options->create_item();
+
+
+ if (properties) {
+
+ List<PropertyInfo> props;
+
+ if (instance) {
+ instance->get_property_list(&props,true);
+ } else if (type!=Variant::NIL) {
+ Variant v;
+ if (type==Variant::INPUT_EVENT) {
+ InputEvent ie;
+ ie.type=event_type;
+ v=ie;
+ } else {
+ Variant::CallError ce;
+ v=Variant::construct(type,NULL,0,ce);
+ }
+
+ v.get_property_list(&props);
+ } else {
+
+
+ Object *obj = ObjectDB::get_instance(script);
+ if (obj && obj->cast_to<Script>()) {
+
+ props.push_back(PropertyInfo(Variant::NIL,"Script Variables",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_CATEGORY));
+ obj->cast_to<Script>()->get_script_property_list(&props);
+ }
+
+ StringName base=base_type;
+ while(base) {
+ props.push_back(PropertyInfo(Variant::NIL,base,PROPERTY_HINT_NONE,"",PROPERTY_USAGE_CATEGORY));
+ ObjectTypeDB::get_property_list(base,&props,true);
+ base=ObjectTypeDB::type_inherits_from(base);
+ }
+
+ }
+
+ TreeItem *category=NULL;
+
+ bool found=false;
+
+ Ref<Texture> type_icons[Variant::VARIANT_MAX]={
+ Control::get_icon("MiniVariant","EditorIcons"),
+ Control::get_icon("MiniBoolean","EditorIcons"),
+ Control::get_icon("MiniInteger","EditorIcons"),
+ Control::get_icon("MiniFloat","EditorIcons"),
+ Control::get_icon("MiniString","EditorIcons"),
+ Control::get_icon("MiniVector2","EditorIcons"),
+ Control::get_icon("MiniRect2","EditorIcons"),
+ Control::get_icon("MiniVector3","EditorIcons"),
+ Control::get_icon("MiniMatrix2","EditorIcons"),
+ Control::get_icon("MiniPlane","EditorIcons"),
+ Control::get_icon("MiniQuat","EditorIcons"),
+ Control::get_icon("MiniAabb","EditorIcons"),
+ Control::get_icon("MiniMatrix3","EditorIcons"),
+ Control::get_icon("MiniTransform","EditorIcons"),
+ Control::get_icon("MiniColor","EditorIcons"),
+ Control::get_icon("MiniImage","EditorIcons"),
+ Control::get_icon("MiniPath","EditorIcons"),
+ Control::get_icon("MiniRid","EditorIcons"),
+ Control::get_icon("MiniObject","EditorIcons"),
+ Control::get_icon("MiniInput","EditorIcons"),
+ Control::get_icon("MiniDictionary","EditorIcons"),
+ Control::get_icon("MiniArray","EditorIcons"),
+ Control::get_icon("MiniRawArray","EditorIcons"),
+ Control::get_icon("MiniIntArray","EditorIcons"),
+ Control::get_icon("MiniFloatArray","EditorIcons"),
+ Control::get_icon("MiniStringArray","EditorIcons"),
+ Control::get_icon("MiniVector2Array","EditorIcons"),
+ Control::get_icon("MiniVector3Array","EditorIcons"),
+ Control::get_icon("MiniColorArray","EditorIcons")
+ };
+
+
+ for (List<PropertyInfo>::Element *E=props.front();E;E=E->next()) {
+ if (E->get().usage==PROPERTY_USAGE_CATEGORY) {
+ if (category && category->get_children()==NULL) {
+ memdelete(category); //old category was unused
+ }
+ category = search_options->create_item(root);
+ category->set_text(0,E->get().name);
+ category->set_selectable(0,false);
+
+ Ref<Texture> icon;
+ if (E->get().name=="Script Variables") {
+ icon=get_icon("Script","EditorIcons");
+ } else if (has_icon(E->get().name,"EditorIcons")) {
+ icon=get_icon(E->get().name,"EditorIcons");
+ } else {
+ icon=get_icon("Object","EditorIcons");
+ }
+ category->set_icon(0,icon);
+ continue;
+ }
+
+ if (!(E->get().usage&PROPERTY_USAGE_EDITOR))
+ continue;
+
+ if (search_box->get_text()!=String() && E->get().name.find(search_box->get_text())==-1)
+ continue;
+ TreeItem *item = search_options->create_item(category?category:root);
+ item->set_text(0,E->get().name);
+ item->set_metadata(0,E->get().name);
+ item->set_icon(0,type_icons[E->get().type]);
+
+ if (!found && search_box->get_text()!=String() && E->get().name.find(search_box->get_text())!=-1) {
+ item->select(0);
+ found=true;
+ }
+
+ item->set_selectable(0,true);
+ }
+
+ if (category && category->get_children()==NULL) {
+ memdelete(category); //old category was unused
+ }
+ } else {
+
+ List<MethodInfo> methods;
+
+ if (type!=Variant::NIL) {
+ Variant v;
+ Variant::CallError ce;
+ v=Variant::construct(type,NULL,0,ce);
+ v.get_method_list(&methods);
+ } else {
+
+
+ Object *obj = ObjectDB::get_instance(script);
+ if (obj && obj->cast_to<Script>()) {
+
+ methods.push_back(MethodInfo("*Script Methods"));
+ obj->cast_to<Script>()->get_script_method_list(&methods);
+ }
+
+ StringName base=base_type;
+ while(base) {
+ methods.push_back(MethodInfo("*"+String(base)));
+ ObjectTypeDB::get_method_list(base,&methods,true);
+ base=ObjectTypeDB::type_inherits_from(base);
+ }
+
+ }
+
+ TreeItem *category=NULL;
+
+ bool found=false;
+ bool script_methods=false;
+
+ for (List<MethodInfo>::Element *E=methods.front();E;E=E->next()) {
+ if (E->get().name.begins_with("*")) {
+ if (category && category->get_children()==NULL) {
+ memdelete(category); //old category was unused
+ }
+ category = search_options->create_item(root);
+ category->set_text(0,E->get().name.replace_first("*",""));
+ category->set_selectable(0,false);
+
+ Ref<Texture> icon;
+ script_methods=false;
+ if (E->get().name=="*Script Methods") {
+ icon=get_icon("Script","EditorIcons");
+ script_methods=true;
+ } else if (has_icon(E->get().name,"EditorIcons")) {
+ icon=get_icon(E->get().name,"EditorIcons");
+ } else {
+ icon=get_icon("Object","EditorIcons");
+ }
+ category->set_icon(0,icon);
+
+ continue;
+ }
+
+ String name = E->get().name.get_slice(":",0);
+ if (!script_methods && name.begins_with("_") && !(E->get().flags&METHOD_FLAG_VIRTUAL))
+ continue;
+
+ if (search_box->get_text()!=String() && name.find(search_box->get_text())==-1)
+ continue;
+
+ TreeItem *item = search_options->create_item(category?category:root);
+
+ MethodInfo mi=E->get();
+
+ String desc;
+ if (mi.name.find(":")!=-1) {
+ desc=mi.name.get_slice(":",1)+" ";
+ mi.name=mi.name.get_slice(":",0);
+ } else if (mi.return_val.type!=Variant::NIL)
+ desc=Variant::get_type_name(mi.return_val.type);
+ else
+ desc="void ";
+
+
+
+ desc+=" "+mi.name+" ( ";
+
+ for(int i=0;i<mi.arguments.size();i++) {
+
+ if (i>0)
+ desc+=", ";
+
+ if (mi.arguments[i].type==Variant::NIL)
+ desc+="var ";
+ else if (mi.arguments[i].name.find(":")!=-1) {
+ desc+=mi.arguments[i].name.get_slice(":",1)+" ";
+ mi.arguments[i].name=mi.arguments[i].name.get_slice(":",0);
+ } else
+ desc+=Variant::get_type_name(mi.arguments[i].type)+" ";
+
+ desc+=mi.arguments[i].name;
+
+ }
+
+ desc+=" )";
+
+ item->set_text(0,desc);
+ item->set_metadata(0,name);
+ item->set_selectable(0,true);
+
+ if (!found && search_box->get_text()!=String() && name.find(search_box->get_text())!=-1) {
+ item->select(0);
+ found=true;
+ }
+
+ }
+
+ if (category && category->get_children()==NULL) {
+ memdelete(category); //old category was unused
+ }
+
+ }
+
+ get_ok()->set_disabled(root->get_children()==NULL);
+
+}
+
+
+
+void PropertySelector::_confirmed() {
+
+ TreeItem *ti = search_options->get_selected();
+ if (!ti)
+ return;
+ emit_signal("selected",ti->get_metadata(0));
+ hide();
+}
+
+void PropertySelector::_item_selected() {
+
+ help_bit->set_text("");
+
+ TreeItem *item=search_options->get_selected();
+ if (!item)
+ return;
+ String name = item->get_metadata(0);
+
+ String class_type;
+ if (properties && type==Variant::INPUT_EVENT) {
+
+ switch(event_type) {
+ case InputEvent::NONE: class_type="InputEvent"; break;
+ case InputEvent::KEY: class_type="InputEventKey"; break;
+ case InputEvent::MOUSE_MOTION: class_type="InputEventMouseMotion"; break;
+ case InputEvent::MOUSE_BUTTON: class_type="InputEventMouseButton"; break;
+ case InputEvent::JOYSTICK_MOTION: class_type="InputEventJoystickMotion"; break;
+ case InputEvent::JOYSTICK_BUTTON: class_type="InputEventJoystickButton"; break;
+ case InputEvent::SCREEN_TOUCH: class_type="InputEventScreenTouch"; break;
+ case InputEvent::SCREEN_DRAG: class_type="InputEventScreenDrag"; break;
+ case InputEvent::ACTION: class_type="InputEventAction"; break;
+ default: {}
+ }
+
+ } else if (type) {
+ class_type=Variant::get_type_name(type);
+
+ } else {
+ class_type=base_type;
+ }
+
+ DocData *dd=EditorHelp::get_doc_data();
+ String text;
+
+
+ if (properties) {
+
+ String at_class=class_type;
+
+
+
+ while(at_class!=String()) {
+
+
+ Map<String,DocData::ClassDoc>::Element *E=dd->class_list.find(at_class);
+ if (E) {
+ for(int i=0;i<E->get().properties.size();i++) {
+ if (E->get().properties[i].name==name) {
+ text=E->get().properties[i].description;
+ }
+ }
+ }
+
+ at_class=ObjectTypeDB::type_inherits_from(at_class);
+ }
+
+ if (text==String()) {
+
+ StringName setter;
+ StringName type;
+ if (ObjectTypeDB::get_setter_and_type_for_property(class_type,name,type,setter)) {
+ Map<String,DocData::ClassDoc>::Element *E=dd->class_list.find(type);
+ if (E) {
+ for(int i=0;i<E->get().methods.size();i++) {
+ if (E->get().methods[i].name==setter.operator String()) {
+ text=E->get().methods[i].description;
+ }
+ }
+ }
+
+
+ }
+ }
+
+ } else {
+
+
+ String at_class=class_type;
+
+ while(at_class!=String()) {
+
+ Map<String,DocData::ClassDoc>::Element *E=dd->class_list.find(at_class);
+ if (E) {
+ for(int i=0;i<E->get().methods.size();i++) {
+ if (E->get().methods[i].name==name) {
+ text=E->get().methods[i].description;
+ }
+ }
+ }
+
+ at_class=ObjectTypeDB::type_inherits_from(at_class);
+ }
+ }
+
+
+ if (text==String())
+ return;
+
+ help_bit->set_text(text);
+
+}
+
+
+void PropertySelector::_notification(int p_what) {
+
+ if (p_what==NOTIFICATION_ENTER_TREE) {
+
+ connect("confirmed",this,"_confirmed");
+
+ }
+}
+
+
+
+void PropertySelector::select_method_from_base_type(const String& p_base,const String& p_current) {
+
+ base_type=p_base;
+ selected=p_current;
+ type=Variant::NIL;
+ script=0;
+ properties=false;
+ instance=NULL;
+
+ popup_centered_ratio(0.6);
+ search_box->set_text("");
+ search_box->grab_focus();
+ _update_search();
+}
+
+void PropertySelector::select_method_from_script(const Ref<Script>& p_script,const String& p_current){
+
+ ERR_FAIL_COND( p_script.is_null() );
+ base_type=p_script->get_instance_base_type();
+ selected=p_current;
+ type=Variant::NIL;
+ script=p_script->get_instance_ID();
+ properties=false;
+ instance=NULL;
+
+ popup_centered_ratio(0.6);
+ search_box->set_text("");
+ search_box->grab_focus();
+ _update_search();
+
+}
+void PropertySelector::select_method_from_basic_type(Variant::Type p_type, const String &p_current){
+
+ ERR_FAIL_COND(p_type==Variant::NIL);
+ base_type="";
+ selected=p_current;
+ type=p_type;
+ script=0;
+ properties=false;
+ instance=NULL;
+
+ popup_centered_ratio(0.6);
+ search_box->set_text("");
+ search_box->grab_focus();
+ _update_search();
+
+}
+
+void PropertySelector::select_method_from_instance(Object* p_instance, const String &p_current){
+
+
+ base_type=p_instance->get_type();
+ selected=p_current;
+ type=Variant::NIL;
+ script=0;
+ {
+ Ref<Script> scr = p_instance->get_script();
+ if (scr.is_valid())
+ script=scr->get_instance_ID();
+ }
+ properties=false;
+ instance=NULL;
+
+ popup_centered_ratio(0.6);
+ search_box->set_text("");
+ search_box->grab_focus();
+ _update_search();
+
+}
+
+
+void PropertySelector::select_property_from_base_type(const String& p_base,const String& p_current) {
+
+ base_type=p_base;
+ selected=p_current;
+ type=Variant::NIL;
+ script=0;
+ properties=true;
+ instance=NULL;
+
+ popup_centered_ratio(0.6);
+ search_box->set_text("");
+ search_box->grab_focus();
+ _update_search();
+}
+
+void PropertySelector::select_property_from_script(const Ref<Script>& p_script,const String& p_current){
+
+ ERR_FAIL_COND( p_script.is_null() );
+
+ base_type=p_script->get_instance_base_type();
+ selected=p_current;
+ type=Variant::NIL;
+ script=p_script->get_instance_ID();
+ properties=true;
+ instance=NULL;
+
+ popup_centered_ratio(0.6);
+ search_box->set_text("");
+ search_box->grab_focus();
+ _update_search();
+
+}
+void PropertySelector::select_property_from_basic_type(Variant::Type p_type, InputEvent::Type p_event_type, const String &p_current){
+
+ ERR_FAIL_COND(p_type==Variant::NIL);
+ base_type="";
+ selected=p_current;
+ type=p_type;
+ event_type=p_event_type;
+ script=0;
+ properties=true;
+ instance=NULL;
+
+ popup_centered_ratio(0.6);
+ search_box->set_text("");
+ search_box->grab_focus();
+ _update_search();
+
+}
+
+void PropertySelector::select_property_from_instance(Object* p_instance, const String &p_current){
+
+
+ base_type="";
+ selected=p_current;
+ type=Variant::NIL;
+ script=0;
+ properties=true;
+ instance=p_instance;
+
+ popup_centered_ratio(0.6);
+ search_box->set_text("");
+ search_box->grab_focus();
+ _update_search();
+
+}
+
+void PropertySelector::_bind_methods() {
+
+ ObjectTypeDB::bind_method(_MD("_text_changed"),&PropertySelector::_text_changed);
+ ObjectTypeDB::bind_method(_MD("_confirmed"),&PropertySelector::_confirmed);
+ ObjectTypeDB::bind_method(_MD("_sbox_input"),&PropertySelector::_sbox_input);
+ ObjectTypeDB::bind_method(_MD("_item_selected"),&PropertySelector::_item_selected);
+
+ ADD_SIGNAL(MethodInfo("selected",PropertyInfo(Variant::STRING,"name")));
+
+}
+
+
+PropertySelector::PropertySelector() {
+
+
+ VBoxContainer *vbc = memnew( VBoxContainer );
+ add_child(vbc);
+ set_child_rect(vbc);
+ search_box = memnew( LineEdit );
+ vbc->add_margin_child(TTR("Search:"),search_box);
+ search_box->connect("text_changed",this,"_text_changed");
+ search_box->connect("input_event",this,"_sbox_input");
+ search_options = memnew( Tree );
+ vbc->add_margin_child(TTR("Matches:"),search_options,true);
+ get_ok()->set_text(TTR("Open"));
+ get_ok()->set_disabled(true);
+ register_text_enter(search_box);
+ set_hide_on_ok(false);
+ search_options->connect("item_activated",this,"_confirmed");
+ search_options->connect("cell_selected",this,"_item_selected");
+ search_options->set_hide_root(true);
+ search_options->set_hide_folding(true);
+
+ help_bit = memnew( EditorHelpBit );
+ vbc->add_margin_child(TTR("Description:"),help_bit);
+ help_bit->connect("request_hide",this,"_closed");
+
+
+}
diff --git a/tools/editor/property_selector.h b/tools/editor/property_selector.h
new file mode 100644
index 0000000000..f7f0e7e167
--- /dev/null
+++ b/tools/editor/property_selector.h
@@ -0,0 +1,55 @@
+#ifndef PROPERTYSELECTOR_H
+#define PROPERTYSELECTOR_H
+
+#include "tools/editor/property_editor.h"
+#include "scene/gui/rich_text_label.h"
+#include "editor_help.h"
+
+class PropertySelector : public ConfirmationDialog {
+ OBJ_TYPE(PropertySelector,ConfirmationDialog )
+
+
+ LineEdit *search_box;
+ Tree *search_options;
+
+ void _update_search();
+
+ void _sbox_input(const InputEvent& p_ie);
+
+ void _confirmed();
+ void _text_changed(const String& p_newtext);
+
+ EditorHelpBit *help_bit;
+
+ bool properties;
+ String selected;
+ Variant::Type type;
+ InputEvent::Type event_type;
+ String base_type;
+ ObjectID script;
+ Object *instance;
+
+ void _item_selected();
+protected:
+ void _notification(int p_what);
+ static void _bind_methods();
+
+
+
+public:
+
+
+ void select_method_from_base_type(const String& p_base,const String& p_current="");
+ void select_method_from_script(const Ref<Script>& p_script,const String& p_current="");
+ void select_method_from_basic_type(Variant::Type p_type,const String& p_current="");
+ void select_method_from_instance(Object* p_instance, const String &p_current="");
+
+ void select_property_from_base_type(const String& p_base,const String& p_current="");
+ void select_property_from_script(const Ref<Script>& p_script,const String& p_current="");
+ void select_property_from_basic_type(Variant::Type p_type,InputEvent::Type p_event_type,const String& p_current="");
+ void select_property_from_instance(Object* p_instance, const String &p_current="");
+
+ PropertySelector();
+};
+
+#endif // PROPERTYSELECTOR_H