-Merged Script and Help tabs

-Help tabs can be opened many at the same time
-Color temperatures for opened scripts
-Dominant script opening when switching scene tab
This commit is contained in:
Juan Linietsky 2015-11-17 09:46:08 -03:00
parent 8420c24f7f
commit 081a236c67
14 changed files with 1362 additions and 796 deletions

View file

@ -243,7 +243,9 @@ void VideoStreamPlaybackTheora::set_file(const String& p_file) {
/* Only interested in Vorbis/Theora streams */
int stateflag = 0;
int audio_track_skip=audio_track;
int audio_track_skip=audio_track;
while(!stateflag){
int ret=buffer_data();
if(ret==0)break;
@ -270,14 +272,18 @@ void VideoStreamPlaybackTheora::set_file(const String& p_file) {
theora_p=1;
}else if(!vorbis_p && vorbis_synthesis_headerin(&vi,&vc,&op)>=0){
/* it is vorbis */
if (audio_track_skip) {
vorbis_info_clear(&vi);
vorbis_comment_clear(&vc);
audio_track_skip--;
} else {
copymem(&vo,&test,sizeof(test));
vorbis_p=1;
}
if (audio_track_skip) {
vorbis_info_clear(&vi);
vorbis_comment_clear(&vc);
ogg_stream_clear(&test);
vorbis_info_init(&vi);
vorbis_comment_init(&vc);
audio_track_skip--;
} else {
copymem(&vo,&test,sizeof(test));
vorbis_p=1;
}
}else{
/* whatever it is, we don't care about it */
ogg_stream_clear(&test);

View file

@ -235,6 +235,37 @@ int ItemList::get_current() const {
return current;
}
void ItemList::move_item(int p_item,int p_to_pos) {
ERR_FAIL_INDEX(p_item,items.size());
ERR_FAIL_INDEX(p_to_pos,items.size()+1);
Item it=items[p_item];
items.remove(p_item);;
if (p_to_pos>p_item) {
p_to_pos--;
}
if (p_to_pos>=items.size()) {
items.push_back(it);
} else {
items.insert(p_to_pos,it);
}
if (current<0) {
//do none
} if (p_item==current) {
current=p_to_pos;
} else if (p_to_pos>p_item && current>p_item && current<p_to_pos) {
current--;
} else if (p_to_pos<p_item && current<p_item && current>p_to_pos) {
current++;
}
update();
}
int ItemList::get_item_count() const{

View file

@ -101,6 +101,7 @@ public:
void set_current(int p_current);
int get_current() const;
void move_item(int p_item,int p_to_pos);
int get_item_count() const;
void remove_item(int p_idx);

View file

@ -54,6 +54,8 @@ void MenuButton::_unhandled_key_input(InputEvent p_event) {
int item = popup->find_item_by_accelerator(code);
if (item>=0 && ! popup->is_item_disabled(item))
popup->activate_item(item);
/*

View file

@ -719,7 +719,7 @@ void RichTextLabel::_input_event(InputEvent p_event) {
case InputEvent::KEY: {
const InputEventKey &k=p_event.key;
if (k.pressed) {
if (k.pressed && !k.mod.alt && !k.mod.shift && !k.mod.command && !k.mod.meta) {
bool handled=true;
switch(k.scancode) {
case KEY_PAGEUP: {
@ -765,6 +765,7 @@ void RichTextLabel::_input_event(InputEvent p_event) {
default: handled=false;
}
if (handled)
accept_event();
}

View file

@ -384,12 +384,12 @@ void VideoPlayer::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_buffering_msec","msec"),&VideoPlayer::set_buffering_msec);
ObjectTypeDB::bind_method(_MD("get_buffering_msec"),&VideoPlayer::get_buffering_msec);
ADD_PROPERTY( PropertyInfo(Variant::INT, "stream/audio_track",PROPERTY_HINT_RANGE,"0,128,1"), _SCS("set_audio_track"), _SCS("get_audio_track") );
ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream/stream", PROPERTY_HINT_RESOURCE_TYPE,"VideoStream"), _SCS("set_stream"), _SCS("get_stream") );
// ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/loop"), _SCS("set_loop"), _SCS("has_loop") );
ADD_PROPERTY( PropertyInfo(Variant::REAL, "stream/volume_db", PROPERTY_HINT_RANGE,"-80,24,0.01"), _SCS("set_volume_db"), _SCS("get_volume_db") );
ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/autoplay"), _SCS("set_autoplay"), _SCS("has_autoplay") );
ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/paused"), _SCS("set_paused"), _SCS("is_paused") );
ADD_PROPERTY( PropertyInfo(Variant::INT, "stream/audio_track",PROPERTY_HINT_RANGE,"0,128,1"), _SCS("set_audio_track"), _SCS("get_audio_track") );
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "expand" ), _SCS("set_expand"),_SCS("has_expand") );
}

View file

@ -188,6 +188,7 @@ void make_default_theme() {
// Font Colors
Color control_font_color = Color::html("e0e0e0");
Color control_font_color_lower = Color::html("a0a0a0");
Color control_font_color_low = Color::html("b0b0b0");
Color control_font_color_hover = Color::html("f0f0f0");
Color control_font_color_disabled = Color(0.9,0.9,0.9,0.2);
@ -273,7 +274,7 @@ void make_default_theme() {
t->set_color("font_color_hover","ToolButton", control_font_color_hover );
t->set_color("font_color_disabled","ToolButton", Color(0.9,0.95,1,0.3) );
t->set_constant("hseparation","ToolButton", 0 );
t->set_constant("hseparation","ToolButton", 3 );
@ -649,7 +650,7 @@ void make_default_theme() {
t->set_constant("icon_margin","ItemList",4);
t->set_constant("line_separation","ItemList",2);
t->set_font("font","ItemList", default_font );
t->set_color("font_color","ItemList", control_font_color_low );
t->set_color("font_color","ItemList", control_font_color_lower );
t->set_color("font_color_selected","ItemList", control_font_color_pressed );
t->set_color("guide_color","ItemList", Color(0,0,0,0.1) );
t->set_stylebox("selected","ItemList", item_selected_oof );

View file

@ -618,7 +618,7 @@ CodeTextEditor::CodeTextEditor() {
line_col = memnew( Label );
add_child(line_col);
line_col->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_END,135);
line_col->set_anchor_and_margin(MARGIN_TOP,ANCHOR_END,20);
line_col->set_anchor_and_margin(MARGIN_TOP,ANCHOR_END,15);
line_col->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END,1);
line_col->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,5);
//line_col->set_align(Label::ALIGN_RIGHT);
@ -637,7 +637,7 @@ CodeTextEditor::CodeTextEditor() {
error = memnew( Label );
add_child(error);
error->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN,5);
error->set_anchor_and_margin(MARGIN_TOP,ANCHOR_END,20);
error->set_anchor_and_margin(MARGIN_TOP,ANCHOR_END,15);
error->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END,1);
error->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,130);
error->hide();

View file

@ -300,9 +300,9 @@ void EditorHelpSearch::_bind_methods() {
}
EditorHelpSearch::EditorHelpSearch(EditorNode *p_editor) {
EditorHelpSearch::EditorHelpSearch() {
editor=p_editor;
editor=EditorNode::get_singleton();
VBoxContainer *vbc = memnew( VBoxContainer );
add_child(vbc);
set_child_rect(vbc);
@ -318,17 +318,138 @@ EditorHelpSearch::EditorHelpSearch(EditorNode *p_editor) {
search_box->connect("input_event",this,"_sbox_input");
search_options = memnew( Tree );
vbc->add_margin_child("Matches:",search_options,true);
get_ok()->set_text("View");
get_ok()->set_text("Open");
get_ok()->set_disabled(true);
register_text_enter(search_box);
set_hide_on_ok(false);
search_options->connect("item_activated",this,"_confirmed");
set_title("Search Classes");
// search_options->set_hide_root(true);
}
/////////////////////////////////
////////////////////////////////////
/// /////////////////////////////////
void EditorHelpIndex::add_type(const String& p_type,HashMap<String,TreeItem*>& p_types,TreeItem *p_root) {
if (p_types.has(p_type))
return;
// if (!ObjectTypeDB::is_type(p_type,base) || p_type==base)
// return;
String inherits=EditorHelp::get_doc_data()->class_list[p_type].inherits;
TreeItem *parent=p_root;
if (inherits.length()) {
if (!p_types.has(inherits)) {
add_type(inherits,p_types,p_root);
}
if (p_types.has(inherits) )
parent=p_types[inherits];
}
TreeItem *item = class_list->create_item(parent);
item->set_metadata(0,p_type);
item->set_tooltip(0,EditorHelp::get_doc_data()->class_list[p_type].brief_description);
item->set_text(0,p_type);
if (has_icon(p_type,"EditorIcons")) {
item->set_icon(0, get_icon(p_type,"EditorIcons"));
}
p_types[p_type]=item;
}
void EditorHelpIndex::_tree_item_selected() {
TreeItem *s=class_list->get_selected();
if (!s)
return;
emit_signal("open_class",s->get_text(0));
hide();
//_goto_desc(s->get_text(0));
}
void EditorHelpIndex::select_class(const String& p_class) {
if (!tree_item_map.has(p_class))
return;
tree_item_map[p_class]->select(0);
class_list->ensure_cursor_is_visible();
}
void EditorHelpIndex::_notification(int p_what) {
if (p_what==NOTIFICATION_ENTER_TREE) {
class_list->clear();
tree_item_map.clear();
TreeItem *root = class_list->create_item();
class_list->set_hide_root(true);
connect("confirmed",this,"_tree_item_selected");
for(Map<String,DocData::ClassDoc>::Element *E=EditorHelp::get_doc_data()->class_list.front();E;E=E->next()) {
add_type(E->key(),tree_item_map,root);
}
}
}
void EditorHelpIndex::_bind_methods() {
ObjectTypeDB::bind_method("_tree_item_selected",&EditorHelpIndex::_tree_item_selected);
ObjectTypeDB::bind_method("select_class",&EditorHelpIndex::select_class);
ADD_SIGNAL( MethodInfo("open_class"));
}
EditorHelpIndex::EditorHelpIndex() {
VBoxContainer *vbc = memnew( VBoxContainer );
add_child(vbc);
set_child_rect(vbc);
class_list = memnew( Tree );
vbc->add_margin_child("Class List: ",class_list,true);
class_list->set_v_size_flags(SIZE_EXPAND_FILL);
class_list->connect("item_activated",this,"_tree_item_selected");
get_ok()->set_text("Open");
}
/////////////////////////////////
////////////////////////////////////
/// /////////////////////////////////
DocData *EditorHelp::doc=NULL;
void EditorHelp::_unhandled_key_input(const InputEvent& p_ev) {
@ -339,8 +460,6 @@ void EditorHelp::_unhandled_key_input(const InputEvent& p_ev) {
search->grab_focus();
search->select_all();
} else if (p_ev.key.mod.shift && p_ev.key.scancode==KEY_F1) {
class_search->popup();
}
}
@ -351,17 +470,19 @@ void EditorHelp::_search(const String&) {
String stext=search->get_text();
bool keep = prev_search==stext && class_list->get_selected() && prev_search_page==class_list->get_selected()->get_text(0);
bool keep = prev_search==stext;
class_desc->search(stext, keep);
bool ret = class_desc->search(stext, keep);
if (!ret) {
class_desc->search(stext, false);
}
prev_search=stext;
if (class_list->get_selected())
prev_search_page=class_list->get_selected()->get_text(0);
}
#if 0
void EditorHelp::_button_pressed(int p_idx) {
if (p_idx==PAGE_CLASS_LIST) {
@ -399,16 +520,11 @@ void EditorHelp::_button_pressed(int p_idx) {
} else if (p_idx==PAGE_SEARCH) {
_search("");
} else if (p_idx==CLASS_SEARCH) {
class_search->popup();
}
}
#endif
void EditorHelp::_class_list_select(const String& p_select) {
@ -417,16 +533,28 @@ void EditorHelp::_class_list_select(const String& p_select) {
void EditorHelp::_class_desc_select(const String& p_select) {
// print_line("LINK: "+p_select);
if (p_select.begins_with("#")) {
_goto_desc(p_select.substr(1,p_select.length()));
//_goto_desc(p_select.substr(1,p_select.length()));
emit_signal("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 (!method_line.has(m))
return;
class_desc->scroll_to_line(method_line[m]);
return;
if (m.find(".")!=-1) {
//must go somewhere else
emit_signal("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]);
}
}
@ -449,68 +577,40 @@ void EditorHelp::_add_type(const String& p_type) {
}
void EditorHelp::_update_history_buttons() {
back->set_disabled(history_pos<2);
forward->set_disabled(history_pos>=history.size());
}
void EditorHelp::_scroll_changed(double p_scroll) {
if (scroll_locked)
return;
int p = history_pos -1;
if (p<0 || p>=history.size())
return;
if (class_desc->get_v_scroll()->is_hidden())
p_scroll=0;
history[p].scroll=p_scroll;
//history[p].scroll=p_scroll;
}
Error EditorHelp::_goto_desc(const String& p_class,bool p_update_history,int p_vscr) {
Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
//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)) {
//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);
class_list_button->set_pressed(false);
description_line=0;
if (p_class==edited_class->get_text())
if (p_class==edited_class)
return OK; //already there
scroll_locked=true;
if (p_update_history) {
history.resize(history_pos);
history_pos++;
History h;
h.c=p_class;
h.scroll=0;
history.push_back(h);
_update_history_buttons();
class_desc->get_v_scroll()->set_val(0);
}
class_desc->clear();
method_line.clear();
edited_class->set_text(p_class);
edited_class=p_class;
//edited_class->show();
@ -925,10 +1025,7 @@ Error EditorHelp::_goto_desc(const String& p_class,bool p_update_history,int p_v
}
if (!p_update_history) {
class_desc->get_v_scroll()->set_val(history[history_pos-1].scroll);
}
scroll_locked=false;
@ -939,8 +1036,6 @@ void EditorHelp::_request_help(const String& p_string) {
Error err = _goto_desc(p_string);
if (err==OK) {
editor->call("_editor_select",3);
} else {
class_search->popup(p_string);
}
//100 palabras
}
@ -1209,63 +1304,11 @@ void EditorHelp::_add_text(const String& p_bbcode) {
}
void EditorHelp::add_type(const String& p_type,HashMap<String,TreeItem*>& p_types,TreeItem *p_root) {
if (p_types.has(p_type))
return;
// if (!ObjectTypeDB::is_type(p_type,base) || p_type==base)
// return;
String inherits=doc->class_list[p_type].inherits;
TreeItem *parent=p_root;
if (inherits.length()) {
if (!p_types.has(inherits)) {
add_type(inherits,p_types,p_root);
}
if (p_types.has(inherits) )
parent=p_types[inherits];
}
TreeItem *item = class_list->create_item(parent);
item->set_metadata(0,p_type);
item->set_tooltip(0,doc->class_list[p_type].brief_description);
item->set_text(0,p_type);
if (has_icon(p_type,"EditorIcons")) {
item->set_icon(0, get_icon(p_type,"EditorIcons"));
}
p_types[p_type]=item;
}
void EditorHelp::_update_doc() {
class_list->clear();
List<StringName> type_list;
tree_item_map.clear();
TreeItem *root = class_list->create_item();
class_list->set_hide_root(true);
List<StringName>::Element *I=type_list.front();
for(Map<String,DocData::ClassDoc>::Element *E=doc->class_list.front();E;E=E->next()) {
add_type(E->key(),tree_item_map,root);
}
}
@ -1289,8 +1332,8 @@ void EditorHelp::_notification(int p_what) {
case NOTIFICATION_READY: {
forward->set_icon(get_icon("Forward","EditorIcons"));
back->set_icon(get_icon("Back","EditorIcons"));
// forward->set_icon(get_icon("Forward","EditorIcons"));
// back->set_icon(get_icon("Back","EditorIcons"));
_update_doc();
editor->connect("request_help",this,"_request_help");
@ -1298,226 +1341,121 @@ void EditorHelp::_notification(int p_what) {
}
}
void EditorHelp::_tree_item_selected() {
if (select_locked) {
select_locked = false;
return;
}
TreeItem *s=class_list->get_selected();
if (!s)
return;
select_locked=true;
_goto_desc(s->get_text(0));
select_locked=false;
void EditorHelp::go_to_help(const String& p_help) {
_help_callback(p_help);
}
void EditorHelp::go_to_class(const String& p_class,int p_scroll) {
_goto_desc(p_class,p_scroll);
}
void EditorHelp::popup_search() {
search_dialog->popup_centered(Size2(250,80));
search->grab_focus();
}
void EditorHelp::_search_cbk() {
_search(search->get_text());
}
String EditorHelp::get_class_name() {
return edited_class;
}
void EditorHelp::search_again() {
_search(prev_search);
}
int EditorHelp::get_scroll() const {
return class_desc->get_v_scroll()->get_val();
}
void EditorHelp::set_scroll(int p_scroll) {
class_desc->get_v_scroll()->set_val(p_scroll);
}
void EditorHelp::_bind_methods() {
ObjectTypeDB::bind_method("_class_list_select",&EditorHelp::_class_list_select);
ObjectTypeDB::bind_method("_class_desc_select",&EditorHelp::_class_desc_select);
ObjectTypeDB::bind_method("_button_pressed",&EditorHelp::_button_pressed);
// ObjectTypeDB::bind_method("_button_pressed",&EditorHelp::_button_pressed);
ObjectTypeDB::bind_method("_scroll_changed",&EditorHelp::_scroll_changed);
ObjectTypeDB::bind_method("_request_help",&EditorHelp::_request_help);
ObjectTypeDB::bind_method("_unhandled_key_input",&EditorHelp::_unhandled_key_input);
ObjectTypeDB::bind_method("_search",&EditorHelp::_search);
ObjectTypeDB::bind_method("_tree_item_selected",&EditorHelp::_tree_item_selected);
ObjectTypeDB::bind_method("_search_cbk",&EditorHelp::_search_cbk);
ObjectTypeDB::bind_method("_help_callback",&EditorHelp::_help_callback);
ADD_SIGNAL(MethodInfo("go_to_help"));
}
EditorHelp::EditorHelp(EditorNode *p_editor) {
EditorHelp::EditorHelp() {
editor=p_editor;
editor=EditorNode::get_singleton();
VBoxContainer *vbc = this;
HBoxContainer *panel_hb = memnew( HBoxContainer );
Button *b = memnew( Button );
b->set_text("Class List");
panel_hb->add_child(b);
vbc->add_child(panel_hb);
b->set_toggle_mode(true);
b->set_pressed(true);
b->connect("pressed",this,"_button_pressed",make_binds(PAGE_CLASS_LIST));
class_list_button=b;
class_list_button->hide();
b = memnew( Button );
b->set_text("Class");
panel_hb->add_child(b);
edited_class=b;
edited_class->hide();
b->set_toggle_mode(true);
b->connect("pressed",this,"_button_pressed",make_binds(PAGE_CLASS_DESC));
b = memnew( Button );
b->set_text("Search in Classes");
panel_hb->add_child(b);
b->connect("pressed",this,"_button_pressed",make_binds(CLASS_SEARCH));
Control *expand = memnew( Control );
expand->set_h_size_flags(SIZE_EXPAND_FILL);
panel_hb->add_child(expand);
b = memnew( Button );
panel_hb->add_child(b);
back=b;
b->connect("pressed",this,"_button_pressed",make_binds(PAGE_CLASS_PREV));
b = memnew( Button );
panel_hb->add_child(b);
forward=b;
b->connect("pressed",this,"_button_pressed",make_binds(PAGE_CLASS_NEXT));
Separator *hs = memnew( VSeparator );
panel_hb->add_child(hs);
Control *ec = memnew( Control );
ec->set_custom_minimum_size(Size2(200,1));
panel_hb->add_child(ec);
search = memnew( LineEdit );
ec->add_child(search);
search->set_area_as_parent_rect();
search->connect("text_entered",this,"_search");
b = memnew( Button );
b->set_text("Find");
panel_hb->add_child(b);
b->connect("pressed",this,"_button_pressed",make_binds(PAGE_SEARCH));
hs = memnew( VSeparator );
panel_hb->add_child(hs);
h_split = memnew( HSplitContainer );
h_split->set_v_size_flags(SIZE_EXPAND_FILL);
vbc->add_child(h_split);
class_list = memnew( Tree );
h_split->add_child(class_list);
//class_list->connect("meta_clicked",this,"_class_list_select");
//class_list->set_selection_enabled(true);
{
PanelContainer *pc = memnew( PanelContainer );
Panel *pc = memnew( Panel );
Ref<StyleBoxFlat> style( memnew( StyleBoxFlat ) );
style->set_bg_color( EditorSettings::get_singleton()->get("text_editor/background_color") );
style->set_default_margin(MARGIN_LEFT,20);
style->set_default_margin(MARGIN_TOP,20);
pc->set_v_size_flags(SIZE_EXPAND_FILL);
pc->add_style_override("panel", style); //get_stylebox("normal","TextEdit"));
h_split->add_child(pc);
vbc->add_child(pc);
class_desc = memnew( RichTextLabel );
pc->add_child(class_desc);
class_desc->set_area_as_parent_rect(8);
class_desc->connect("meta_clicked",this,"_class_desc_select");
}
class_desc->get_v_scroll()->connect("value_changed",this,"_scroll_changed");
class_desc->set_selection_enabled(true);
editor=p_editor;
history_pos=0;
scroll_locked=false;
select_locked=false;
set_process_unhandled_key_input(true);
h_split->set_split_offset(200);
class_list->connect("cell_selected",this,"_tree_item_selected");
class_desc->hide();
class_search = memnew( EditorHelpSearch(editor) );
search_dialog = memnew( ConfirmationDialog );
add_child(search_dialog);
VBoxContainer *search_vb = memnew( VBoxContainer );
search_dialog->add_child(search_vb);
search_dialog->set_child_rect(search_vb);
search = memnew( LineEdit );
search_dialog->register_text_enter(search);
search_vb->add_margin_child("Search Text",search);
search_dialog->get_ok()->set_text("Find");
search_dialog->connect("confirmed",this,"_search_cbk");
search_dialog->set_hide_on_ok(false);
search_dialog->set_self_opacity(0.8);
/*class_search = memnew( EditorHelpSearch(editor) );
editor->get_gui_base()->add_child(class_search);
class_search->connect("go_to_help",this,"_help_callback");
class_search->connect("go_to_help",this,"_help_callback");*/
// prev_search_page=-1;
}
EditorHelp::~EditorHelp() {
if (doc)
memdelete(doc);
}
void EditorHelpPlugin::edit(Object *p_object) {
if (!p_object->cast_to<Script>())
return;
//editor_help->edit(p_object->cast_to<Script>());
}
bool EditorHelpPlugin::handles(Object *p_object) const {
return false;
}
void EditorHelpPlugin::make_visible(bool p_visible) {
if (p_visible) {
editor_help->show();
} else {
editor_help->hide();
}
}
void EditorHelpPlugin::selected_notify() {
//editor_help->ensure_select_current();
}
Dictionary EditorHelpPlugin::get_state() const {
return Dictionary();
}
void EditorHelpPlugin::set_state(const Dictionary& p_state) {
//editor_help->set_state(p_state);
}
void EditorHelpPlugin::clear() {
//editor_help->clear();
}
void EditorHelpPlugin::save_external_data() {
//editor_help->save_external_data();
}
void EditorHelpPlugin::apply_changes() {
//editor_help->apply_helps();
}
void EditorHelpPlugin::restore_global_state() {
//if (bool(EDITOR_DEF("text_editor/restore_helps_on_load",true))) {
// editor_help->_load_files_state();
//}
}
void EditorHelpPlugin::save_global_state() {
//if (bool(EDITOR_DEF("text_editor/restore_helps_on_load",true))) {
// editor_help->_save_files_state();
// }
}
EditorHelpPlugin::EditorHelpPlugin(EditorNode *p_node) {
editor=p_node;
editor_help = memnew( EditorHelp(p_node) );
editor->get_viewport()->add_child(editor_help);
editor_help->set_area_as_parent_rect();
editor_help->hide();
}
EditorHelpPlugin::~EditorHelpPlugin()
{
}

View file

@ -70,9 +70,29 @@ public:
void popup(const String& p_term="");
EditorHelpSearch(EditorNode *p_editor);
EditorHelpSearch();
};
class EditorHelpIndex : public ConfirmationDialog {
OBJ_TYPE( EditorHelpIndex, ConfirmationDialog );
Tree *class_list;
HashMap<String,TreeItem*> tree_item_map;
void _tree_item_selected();
void add_type(const String& p_type,HashMap<String,TreeItem*>& p_types,TreeItem *p_root);
protected:
void _notification(int p_what);
static void _bind_methods();
public:
void select_class(const String& p_class);
EditorHelpIndex();
};
class EditorHelp : public VBoxContainer {
@ -91,17 +111,11 @@ class EditorHelp : public VBoxContainer {
};
struct History {
String c;
int scroll;
};
Vector<History> history;
int history_pos;
bool select_locked;
String prev_search;
String prev_search_page;
String edited_class;
EditorNode *editor;
Map<String,int> method_line;
@ -111,21 +125,17 @@ class EditorHelp : public VBoxContainer {
Map<String,int> constant_line;
int description_line;
Tree *class_list;
RichTextLabel *class_desc;
HSplitContainer *h_split;
static DocData *doc;
Button *class_list_button;
Button *edited_class;
Button *back;
Button *forward;
ConfirmationDialog *search_dialog;
LineEdit *search;
String base_path;
HashMap<String,TreeItem*> tree_item_map;
String base_path;
void _help_callback(const String& p_topic);
@ -133,25 +143,24 @@ class EditorHelp : public VBoxContainer {
void _add_text(const String& p_text);
bool scroll_locked;
void _button_pressed(int p_idx);
//void _button_pressed(int p_idx);
void _add_type(const String& p_type);
void _scroll_changed(double p_scroll);
void _class_list_select(const String& p_select);
void _class_desc_select(const String& p_select);
Error _goto_desc(const String& p_class,bool p_update_history=true,int p_vscr=-1);
void _update_history_buttons();
Error _goto_desc(const String& p_class, int p_vscr=-1);
//void _update_history_buttons();
void _update_doc();
void _request_help(const String& p_string);
void _search(const String& p_str);
void _search_cbk();
void _unhandled_key_input(const InputEvent& p_ev);
void add_type(const String& p_type,HashMap<String,TreeItem*>& p_types,TreeItem *p_root);
void _tree_item_selected();
EditorHelpSearch *class_search;
protected:
@ -163,41 +172,25 @@ public:
static void generate_doc();
static DocData *get_doc_data() { return doc; }
EditorHelp(EditorNode *p_editor=NULL);
void go_to_help(const String& p_help);
void go_to_class(const String& p_class,int p_scroll=0);
void popup_search();
void search_again();
String get_class_name();
void set_focused() { class_desc->grab_focus(); }
int get_scroll() const;
void set_scroll(int p_scroll);
EditorHelp();
~EditorHelp();
};
class EditorHelpPlugin : public EditorPlugin {
OBJ_TYPE( EditorHelpPlugin, EditorPlugin );
EditorHelp *editor_help;
EditorNode *editor;
public:
virtual String get_name() const { return "Help"; }
bool has_main_screen() const { return true; }
virtual void edit(Object *p_node);
virtual bool handles(Object *p_node) const;
virtual void make_visible(bool p_visible);
virtual void selected_notify();
Dictionary get_state() const;
virtual void set_state(const Dictionary& p_state);
virtual void clear();
virtual void save_external_data();
virtual void apply_changes();
virtual void restore_global_state();
virtual void save_global_state();
EditorHelpPlugin(EditorNode *p_node);
~EditorHelpPlugin();
};
#endif // EDITOR_HELP_H

View file

@ -163,12 +163,12 @@ void EditorNode::_unhandled_input(const InputEvent& p_event) {
switch(p_event.key.scancode) {
case KEY_F1:
/*case KEY_F1:
if (!p_event.key.mod.shift && !p_event.key.mod.command)
_editor_select(3);
break;
case KEY_F2: _editor_select(0); break;
case KEY_F3: _editor_select(1); break;
break;*/
case KEY_F1: _editor_select(0); break;
case KEY_F2: _editor_select(1); break;
case KEY_F4: _editor_select(2); break;
case KEY_F5: _menu_option_confirm((p_event.key.mod.control&&p_event.key.mod.shift)?RUN_PLAY_CUSTOM_SCENE:RUN_PLAY,true); break;
case KEY_F6: _menu_option_confirm(RUN_PLAY_SCENE,true); break;
@ -2846,7 +2846,7 @@ Control* EditorNode::get_viewport() {
void EditorNode::_editor_select(int p_which) {
static bool selecting=false;
if (selecting)
if (selecting || changing_scene)
return;
selecting=true;
@ -3223,9 +3223,14 @@ Dictionary EditorNode::_get_main_scene_state() {
void EditorNode::_set_main_scene_state(Dictionary p_state) {
//print_line("set current 7 ");
changing_scene=false;
#if 0
if (p_state.has("main_tab")) {
int idx = p_state["main_tab"];
print_line("comes with tab: "+itos(idx));
int current=-1;
for(int i=0;i<editor_table.size();i++) {
if (editor_plugin_screen==editor_table[i]) {
@ -3234,12 +3239,41 @@ void EditorNode::_set_main_scene_state(Dictionary p_state) {
}
}
if (idx<2 && current<2) {
//only set tab for 2D and 3D
_editor_select(p_state["main_tab"]);
_editor_select(idx);
//print_line(" setting main tab: "+itos(p_state["main_tab"]));
}
}
#else
if (get_edited_scene()) {
int current=-1;
for(int i=0;i<editor_table.size();i++) {
if (editor_plugin_screen==editor_table[i]) {
current=i;
break;
}
}
if (current<2) {
//use heuristic instead
int n2d=0,n3d=0;
_find_node_types(get_edited_scene(),n2d,n3d);
if (n2d>n3d) {
_editor_select(0);
} else if (n3d>n2d) {
_editor_select(1);
}
}
}
#endif
if (p_state.has("scene_tree_offset"))
scene_tree_dock->get_tree_editor()->get_scene_tree()->get_vscroll_bar()->set_val(p_state["scene_tree_offset"]);
@ -3248,6 +3282,12 @@ void EditorNode::_set_main_scene_state(Dictionary p_state) {
//print_line("set current 8 ");
//this should only happen at the very end
//changing_scene=true; //avoid script change from opening editor
ScriptEditor::get_singleton()->get_debugger()->update_live_edit_root();
ScriptEditor::get_singleton()->set_scene_root_script( editor_data.get_scene_root_script(editor_data.get_edited_scene()) );
//changing_scene=false;
}
@ -3312,8 +3352,6 @@ void EditorNode::set_current_scene(int p_idx) {
call_deferred("_set_main_scene_state",state); //do after everything else is done setting up
//print_line("set current 6 ");
changing_scene=false;
ScriptEditor::get_singleton()->get_debugger()->update_live_edit_root();
}
@ -5493,7 +5531,6 @@ EditorNode::EditorNode() {
add_editor_plugin( memnew( CanvasItemEditorPlugin(this) ) );
add_editor_plugin( memnew( SpatialEditorPlugin(this) ) );
add_editor_plugin( memnew( ScriptEditorPlugin(this) ) );
add_editor_plugin( memnew( EditorHelpPlugin(this) ) );
add_editor_plugin( memnew( AnimationPlayerEditorPlugin(this) ) );
add_editor_plugin( memnew( ShaderGraphEditorPlugin(this,true) ) );
add_editor_plugin( memnew( ShaderGraphEditorPlugin(this,false) ) );
@ -5669,6 +5706,7 @@ EditorNode::EditorNode() {
EditorNode::~EditorNode() {
memdelete( EditorHelp::get_doc_data() );
memdelete(editor_selection);
memdelete(file_server);
EditorSettings::destroy();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 822 B

After

Width:  |  Height:  |  Size: 841 B

File diff suppressed because it is too large Load diff

View file

@ -41,6 +41,7 @@
#include "tools/editor/code_editor.h"
#include "scene/gui/split_container.h"
#include "scene/gui/item_list.h"
#include "tools/editor/editor_help.h"
class ScriptEditorQuickOpen : public ConfirmationDialog {
@ -141,6 +142,9 @@ class ScriptEditor : public VBoxContainer {
SEARCH_REPLACE,
SEARCH_LOCATE_FUNCTION,
SEARCH_GOTO_LINE,
SEARCH_HELP,
SEARCH_CLASSES,
SEARCH_WEBSITE,
DEBUG_TOGGLE_BREAKPOINT,
DEBUG_NEXT,
DEBUG_STEP,
@ -150,6 +154,8 @@ class ScriptEditor : public VBoxContainer {
HELP_CONTEXTUAL,
WINDOW_MOVE_LEFT,
WINDOW_MOVE_RIGHT,
WINDOW_NEXT,
WINDOW_PREV,
WINDOW_SELECT_BASE=100
};
@ -157,11 +163,17 @@ class ScriptEditor : public VBoxContainer {
MenuButton *file_menu;
MenuButton *edit_menu;
MenuButton *search_menu;
MenuButton *script_search_menu;
MenuButton *debug_menu;
MenuButton *help_menu;
Timer *autosave_timer;
uint64_t idle;
Button *help_search;
Button *site_search;
Button *class_search;
EditorHelpSearch *help_search_dialog;
ItemList *script_list;
HSplitContainer *script_split;
TabContainer *tab_container;
@ -172,6 +184,27 @@ class ScriptEditor : public VBoxContainer {
ScriptEditorDebugger* debugger;
ToolButton *scripts_visible;
TextureFrame *script_icon;
Label *script_name_label;
ToolButton *script_back;
ToolButton *script_forward;
struct ScriptHistory {
Control *control;
int scroll_pos;
int cursor_column;
int cursor_row;
};
Vector<ScriptHistory> history;
int history_pos;
EditorHelpIndex *help_index;
void _tab_changed(int p_which);
void _menu_option(int p_optin);
@ -201,6 +234,8 @@ class ScriptEditor : public VBoxContainer {
void _editor_pause();
void _editor_stop();
int edit_pass;
void _add_callback(Object *p_obj, const String& p_function, const StringArray& p_args);
void _res_saved_callback(const Ref<Resource>& p_res);
@ -224,8 +259,20 @@ class ScriptEditor : public VBoxContainer {
void _script_split_dragged(float);
void _history_forward();
void _history_back();
bool waiting_update_names;
void _help_class_open(const String& p_class);
void _help_class_goto(const String& p_desc);
void _update_history_arrows();
void _go_to_tab(int p_idx);
void _update_history_pos(int p_new_pos);
void _update_script_colors();
static ScriptEditor *script_editor;
protected:
void _notification(int p_what);
@ -253,6 +300,8 @@ public:
void set_window_layout(Ref<ConfigFile> p_layout);
void get_window_layout(Ref<ConfigFile> p_layout);
void set_scene_root_script( Ref<Script> p_script );
ScriptEditorDebugger *get_debugger() { return debugger; }
ScriptEditor(EditorNode *p_editor);