From ad8f208bdbcd9d3334c4d57d2e5554dfdb3a36d0 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 23 Aug 2016 19:29:07 -0300 Subject: Proper function/property selection in visual script editing for property. This one has an ordered list, built-in description, search, etc. --- tools/editor/property_selector.cpp | 609 +++++++++++++++++++++++++++++++++++++ 1 file changed, 609 insertions(+) create mode 100644 tools/editor/property_selector.cpp (limited to 'tools/editor/property_selector.cpp') diff --git a/tools/editor/property_selector.cpp b/tools/editor/property_selector.cpp new file mode 100644 index 000000000..dd13476f8 --- /dev/null +++ b/tools/editor/property_selector.cpp @@ -0,0 +1,609 @@ +#include "property_selector.h" +#include "editor_scale.h" + +#include "os/keyboard.h" +#include "editor_help.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(); + rich_text->clear(); + + + TreeItem *root = search_options->create_item(); + + + if (properties) { + + List 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