You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-01 16:38:31 +00:00
Implement name filter to PropertyEditor
- Add search bar to Inspector tab and to Project and Editor settings dialog
This commit is contained in:
@@ -59,6 +59,9 @@ void ProjectSettings::_notification(int p_what) {
|
||||
|
||||
if (p_what==NOTIFICATION_ENTER_TREE) {
|
||||
|
||||
search_button->set_icon(get_icon("Zoom","EditorIcons"));
|
||||
clear_button->set_icon(get_icon("Close","EditorIcons"));
|
||||
|
||||
translation_list->connect("button_pressed",this,"_translation_delete");
|
||||
_update_actions();
|
||||
popup_add->add_icon_item(get_icon("Keyboard","EditorIcons"),"Key",InputEvent::KEY);
|
||||
@@ -1171,6 +1174,31 @@ void ProjectSettings::_update_autoload() {
|
||||
|
||||
}
|
||||
|
||||
void ProjectSettings::_toggle_search_bar(bool p_pressed) {
|
||||
|
||||
globals_editor->set_use_filter(p_pressed);
|
||||
|
||||
if (p_pressed) {
|
||||
|
||||
search_bar->show();
|
||||
add_prop_bar->hide();
|
||||
search_box->grab_focus();
|
||||
search_box->select_all();
|
||||
} else {
|
||||
|
||||
search_bar->hide();
|
||||
add_prop_bar->show();
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectSettings::_clear_search_box() {
|
||||
|
||||
if (search_box->get_text()=="")
|
||||
return;
|
||||
|
||||
search_box->clear();
|
||||
globals_editor->update_tree();
|
||||
}
|
||||
|
||||
void ProjectSettings::_bind_methods() {
|
||||
|
||||
@@ -1212,6 +1240,9 @@ void ProjectSettings::_bind_methods() {
|
||||
ObjectTypeDB::bind_method(_MD("_update_autoload"),&ProjectSettings::_update_autoload);
|
||||
ObjectTypeDB::bind_method(_MD("_autoload_delete"),&ProjectSettings::_autoload_delete);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("_clear_search_box"),&ProjectSettings::_clear_search_box);
|
||||
ObjectTypeDB::bind_method(_MD("_toggle_search_bar"),&ProjectSettings::_toggle_search_bar);
|
||||
|
||||
}
|
||||
|
||||
ProjectSettings::ProjectSettings(EditorData *p_data) {
|
||||
@@ -1232,87 +1263,93 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
|
||||
//tab_container->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN, 15 );
|
||||
//tab_container->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END, 35 );
|
||||
|
||||
Control *props_base = memnew( Control );
|
||||
VBoxContainer *props_base = memnew( VBoxContainer );
|
||||
props_base->set_alignment(BoxContainer::ALIGN_BEGIN);
|
||||
props_base->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
tab_container->add_child(props_base);
|
||||
props_base->set_name("General");
|
||||
globals_editor = memnew( PropertyEditor );
|
||||
props_base->add_child(globals_editor);
|
||||
globals_editor->set_area_as_parent_rect();
|
||||
globals_editor->hide_top_label();
|
||||
globals_editor->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN, 55 );
|
||||
globals_editor->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END, 35 );
|
||||
globals_editor->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN, 5 );
|
||||
globals_editor->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END, 5 );
|
||||
globals_editor->set_capitalize_paths(false);
|
||||
globals_editor->get_scene_tree()->connect("cell_selected",this,"_item_selected");
|
||||
globals_editor->connect("property_toggled",this,"_item_checked");
|
||||
globals_editor->connect("property_edited",this,"_settings_prop_edited");
|
||||
|
||||
HBoxContainer *hbc = memnew( HBoxContainer );
|
||||
hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
props_base->add_child(hbc);
|
||||
|
||||
search_button = memnew( ToolButton );
|
||||
search_button->set_toggle_mode(true);
|
||||
search_button->set_pressed(false);
|
||||
search_button->set_text("Search");
|
||||
hbc->add_child(search_button);
|
||||
search_button->connect("toggled",this,"_toggle_search_bar");
|
||||
|
||||
hbc->add_child( memnew( VSeparator ) );
|
||||
|
||||
add_prop_bar = memnew( HBoxContainer );
|
||||
add_prop_bar->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
hbc->add_child(add_prop_bar);
|
||||
|
||||
Label *l = memnew( Label );
|
||||
props_base->add_child(l);
|
||||
l->set_pos(Point2(6,5));
|
||||
add_prop_bar->add_child(l);
|
||||
l->set_text("Category:");
|
||||
|
||||
|
||||
l = memnew( Label );
|
||||
l->set_anchor(MARGIN_LEFT,ANCHOR_RATIO);
|
||||
props_base->add_child(l);
|
||||
l->set_begin(Point2(0.21,5));
|
||||
l->set_text("Property:");
|
||||
|
||||
l = memnew( Label );
|
||||
l->set_anchor(MARGIN_LEFT,ANCHOR_RATIO);
|
||||
props_base->add_child(l);
|
||||
l->set_begin(Point2(0.51,5));
|
||||
l->set_text("Type:");
|
||||
|
||||
category = memnew( LineEdit );
|
||||
props_base->add_child(category);
|
||||
category->set_anchor(MARGIN_RIGHT,ANCHOR_RATIO);
|
||||
category->set_begin( Point2(5,25) );
|
||||
category->set_end( Point2(0.20,26) );
|
||||
category->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
add_prop_bar->add_child(category);
|
||||
category->connect("text_entered",this,"_item_adds");
|
||||
|
||||
l = memnew( Label );
|
||||
add_prop_bar->add_child(l);
|
||||
l->set_text("Property:");
|
||||
|
||||
property = memnew( LineEdit );
|
||||
props_base->add_child(property);
|
||||
property->set_anchor(MARGIN_LEFT,ANCHOR_RATIO);
|
||||
property->set_anchor(MARGIN_RIGHT,ANCHOR_RATIO);
|
||||
property->set_begin( Point2(0.21,25) );
|
||||
property->set_end( Point2(0.50,26) );
|
||||
property->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
add_prop_bar->add_child(property);
|
||||
property->connect("text_entered",this,"_item_adds");
|
||||
|
||||
l = memnew( Label );
|
||||
add_prop_bar->add_child(l);
|
||||
l->set_text("Type:");
|
||||
|
||||
type = memnew( OptionButton );
|
||||
props_base->add_child(type);
|
||||
type->set_anchor(MARGIN_LEFT,ANCHOR_RATIO);
|
||||
type->set_anchor(MARGIN_RIGHT,ANCHOR_RATIO);
|
||||
type->set_begin( Point2(0.51,25) );
|
||||
type->set_end( Point2(0.70,26) );
|
||||
type->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
add_prop_bar->add_child(type);
|
||||
type->add_item("bool");
|
||||
type->add_item("int");
|
||||
type->add_item("float");
|
||||
type->add_item("string");
|
||||
|
||||
Button *add = memnew( Button );
|
||||
props_base->add_child(add);
|
||||
add->set_anchor(MARGIN_LEFT,ANCHOR_RATIO);
|
||||
add->set_anchor(MARGIN_RIGHT,ANCHOR_RATIO);
|
||||
add->set_begin( Point2(0.71,25) );
|
||||
add->set_end( Point2(0.85,26) );
|
||||
add_prop_bar->add_child(add);
|
||||
add->set_text("Add");
|
||||
add->connect("pressed",this,"_item_add");
|
||||
|
||||
Button *del = memnew( Button );
|
||||
props_base->add_child(del);
|
||||
del->set_anchor(MARGIN_LEFT,ANCHOR_RATIO);
|
||||
del->set_anchor(MARGIN_RIGHT,ANCHOR_END);
|
||||
del->set_begin( Point2(0.86,25) );
|
||||
del->set_end( Point2(5,26) );
|
||||
add_prop_bar->add_child(del);
|
||||
del->set_text("Del");
|
||||
del->connect("pressed",this,"_item_del");
|
||||
|
||||
/*
|
||||
search_bar = memnew( HBoxContainer );
|
||||
search_bar->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
hbc->add_child(search_bar);
|
||||
search_bar->hide();
|
||||
|
||||
search_box = memnew( LineEdit );
|
||||
search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
search_bar->add_child(search_box);
|
||||
|
||||
clear_button = memnew( ToolButton );
|
||||
search_bar->add_child(clear_button);
|
||||
clear_button->connect("pressed",this,"_clear_search_box");
|
||||
|
||||
globals_editor = memnew( PropertyEditor );
|
||||
props_base->add_child(globals_editor);
|
||||
globals_editor->hide_top_label();
|
||||
globals_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
globals_editor->register_text_enter(search_box);
|
||||
globals_editor->set_capitalize_paths(false);
|
||||
globals_editor->get_scene_tree()->connect("cell_selected",this,"_item_selected");
|
||||
globals_editor->connect("property_toggled",this,"_item_checked");
|
||||
globals_editor->connect("property_edited",this,"_settings_prop_edited");
|
||||
|
||||
/*
|
||||
Button *save = memnew( Button );
|
||||
props_base->add_child(save);
|
||||
|
||||
@@ -1325,17 +1362,16 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
|
||||
save->set_text("Save");
|
||||
save->connect("pressed",this,"_save");
|
||||
*/
|
||||
|
||||
hbc = memnew( HBoxContainer );
|
||||
props_base->add_child(hbc);
|
||||
|
||||
popup_platform = memnew( MenuButton );
|
||||
popup_platform->set_text("Copy To Platform..");
|
||||
popup_platform->set_disabled(true);
|
||||
props_base->add_child(popup_platform);
|
||||
hbc->add_child(popup_platform);
|
||||
|
||||
popup_platform->set_anchor(MARGIN_LEFT,ANCHOR_BEGIN);
|
||||
popup_platform->set_anchor(MARGIN_RIGHT,ANCHOR_BEGIN);
|
||||
popup_platform->set_anchor(MARGIN_TOP,ANCHOR_END);
|
||||
popup_platform->set_anchor(MARGIN_BOTTOM,ANCHOR_END);
|
||||
popup_platform->set_begin( Point2(10,28) );
|
||||
popup_platform->set_end( Point2(150,20) );
|
||||
hbc->add_spacer();
|
||||
|
||||
List<StringName> ep;
|
||||
EditorImportExport::get_singleton()->get_export_platforms(&ep);
|
||||
|
||||
Reference in New Issue
Block a user