summaryrefslogtreecommitdiff
path: root/tools/editor/editor_help.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/editor/editor_help.cpp')
-rw-r--r--tools/editor/editor_help.cpp100
1 files changed, 85 insertions, 15 deletions
diff --git a/tools/editor/editor_help.cpp b/tools/editor/editor_help.cpp
index 19e65f3844..819da4bb45 100644
--- a/tools/editor/editor_help.cpp
+++ b/tools/editor/editor_help.cpp
@@ -43,6 +43,7 @@ void EditorHelpSearch::popup(const String& p_term) {
if (p_term!="") {
search_box->set_text(p_term);
search_box->select_all();
+ _update_search();
} else
search_box->clear();
search_box->grab_focus();
@@ -70,7 +71,6 @@ void EditorHelpSearch::_sbox_input(const InputEvent& p_ie) {
void EditorHelpSearch::_update_search() {
-
search_options->clear();
search_options->set_hide_root(true);
@@ -123,8 +123,10 @@ void EditorHelpSearch::_update_search() {
cicon=def_icon;
for(int i=0;i<c.methods.size();i++) {
-
- if (c.methods[i].name.findn(term)!=-1) {
+ if( (term.begins_with(".") && c.methods[i].name.begins_with(term.right(1)))
+ || (term.ends_with("(") && c.methods[i].name.ends_with(term.left(term.length()-1).strip_edges()))
+ || (term.begins_with(".") && term.ends_with("(") && c.methods[i].name==term.substr(1,term.length()-2).strip_edges())
+ || c.methods[i].name.findn(term)!=-1) {
TreeItem *item = search_options->create_item(root);
item->set_metadata(0,"class_method:"+E->key()+":"+c.methods[i].name);
@@ -166,6 +168,18 @@ void EditorHelpSearch::_update_search() {
}
}
+ for(int i=0;i<c.theme_properties.size();i++) {
+
+ if (c.theme_properties[i].name.findn(term)!=-1) {
+
+ TreeItem *item = search_options->create_item(root);
+ item->set_metadata(0,"class_theme_item:"+E->key()+":"+c.theme_properties[i].name);
+ item->set_text(0,E->key()+"."+c.theme_properties[i].name+" (Theme Item)");
+ item->set_icon(0,cicon);
+ }
+ }
+
+
}
//same but descriptions
@@ -249,6 +263,7 @@ void EditorHelpSearch::_confirmed() {
String mdata=ti->get_metadata(0);
emit_signal("go_to_help",mdata);
+ editor->call("_editor_select",3); // in case EditorHelpSearch beeen invoked on top of other editor window
// go to that
hide();
}
@@ -318,10 +333,14 @@ DocData *EditorHelp::doc=NULL;
void EditorHelp::_unhandled_key_input(const InputEvent& p_ev) {
- if (is_visible() && p_ev.key.mod.control && p_ev.key.scancode==KEY_F) {
+ if (!is_visible())
+ return;
+ if ( p_ev.key.mod.control && p_ev.key.scancode==KEY_F) {
search->grab_focus();
search->select_all();
+ } else if (p_ev.key.mod.shift && p_ev.key.scancode==KEY_F1) {
+ class_search->popup();
}
}
@@ -399,7 +418,6 @@ void EditorHelp::_class_list_select(const String& p_select) {
void EditorHelp::_class_desc_select(const String& p_select) {
if (p_select.begins_with("#")) {
-
_goto_desc(p_select.substr(1,p_select.length()));
return;
} else if (p_select.begins_with("@")) {
@@ -454,15 +472,19 @@ void EditorHelp::_scroll_changed(double p_scroll) {
history[p].scroll=p_scroll;
}
-void EditorHelp::_goto_desc(const String& p_class,bool p_update_history,int p_vscr) {
+Error EditorHelp::_goto_desc(const String& p_class,bool p_update_history,int p_vscr) {
- ERR_FAIL_COND(!doc->class_list.has(p_class));
+ //ERR_FAIL_COND(!doc->class_list.has(p_class));
+ if (!doc->class_list.has(p_class))
+ return ERR_DOES_NOT_EXIST;
if (tree_item_map.has(p_class)) {
+ select_locked = true;
tree_item_map[p_class]->select(0);
class_list->ensure_cursor_is_visible();
}
+
class_desc->show();
//tabs->set_current_tab(PAGE_CLASS_DESC);
edited_class->set_pressed(true);
@@ -470,7 +492,7 @@ void EditorHelp::_goto_desc(const String& p_class,bool p_update_history,int p_vs
description_line=0;
if (p_class==edited_class->get_text())
- return; //already there
+ return OK; //already there
scroll_locked=true;
@@ -488,7 +510,6 @@ void EditorHelp::_goto_desc(const String& p_class,bool p_update_history,int p_vs
class_desc->clear();
method_line.clear();
-
edited_class->set_text(p_class);
//edited_class->show();
@@ -657,7 +678,48 @@ void EditorHelp::_goto_desc(const String& p_class,bool p_update_history,int p_vs
}
+ if (cd.theme_properties.size()) {
+
+
+ class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color"));
+ class_desc->push_font(doc_title_font);
+ class_desc->add_text("GUI Theme Items:");
+ class_desc->pop();
+ class_desc->pop();
+ class_desc->add_newline();
+
+ class_desc->push_indent(1);
+ //class_desc->add_newline();
+
+ for(int i=0;i<cd.theme_properties.size();i++) {
+
+ theme_property_line[cd.theme_properties[i].name]=class_desc->get_line_count()-2; //gets overriden if description
+ class_desc->push_font(doc_code_font);
+ _add_type(cd.theme_properties[i].type);
+ class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/text_color"));
+ class_desc->add_text(" "+cd.theme_properties[i].name);
+ class_desc->pop();
+ class_desc->pop();
+
+ if (cd.theme_properties[i].description!="") {
+ class_desc->push_font(doc_font);
+ class_desc->add_text(" ");
+ class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/comment_color"));
+ class_desc->add_text(cd.theme_properties[i].description);
+ class_desc->pop();
+ class_desc->pop();
+
+ }
+
+ class_desc->add_newline();
+ }
+
+ class_desc->add_newline();
+ class_desc->pop();
+
+
+ }
if (cd.signals.size()) {
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color"));
@@ -858,13 +920,16 @@ void EditorHelp::_goto_desc(const String& p_class,bool p_update_history,int p_vs
scroll_locked=false;
+ return OK;
}
void EditorHelp::_request_help(const String& p_string) {
-
- _goto_desc(p_string);
-
-
+ Error err = _goto_desc(p_string);
+ if (err==OK) {
+ editor->call("_editor_select",3);
+ } else {
+ class_search->popup(p_string);
+ }
//100 palabras
}
@@ -893,6 +958,10 @@ void EditorHelp::_help_callback(const String& p_topic) {
if (property_line.has(name))
line=property_line[name];
+ } else if (what=="class_theme_item") {
+
+ if (theme_property_line.has(name))
+ line=theme_property_line[name];
} else if (what=="class_constant") {
if (constant_line.has(name))
@@ -1219,8 +1288,10 @@ void EditorHelp::_notification(int p_what) {
void EditorHelp::_tree_item_selected() {
- if (select_locked)
+ if (select_locked) {
+ select_locked = false;
return;
+ }
TreeItem *s=class_list->get_selected();
if (!s)
return;
@@ -1268,7 +1339,6 @@ EditorHelp::EditorHelp(EditorNode *p_editor) {
edited_class->hide();
b->set_toggle_mode(true);
b->connect("pressed",this,"_button_pressed",make_binds(PAGE_CLASS_DESC));
- edited_class->hide();
b = memnew( Button );
b->set_text("Search in Classes");