Merge pull request #81905 from ckaiser/feature/project_settings_add_consistency

Improve "Add" button consistency in Project Settings
This commit is contained in:
Rémi Verschelde 2024-01-15 13:21:34 +01:00
commit 9c91fbedfb
No known key found for this signature in database
GPG Key ID: C3336907360768E1
6 changed files with 41 additions and 6 deletions

View File

@ -36,6 +36,7 @@
#include "editor/event_listener_line_edit.h"
#include "editor/input_event_configuration_dialog.h"
#include "scene/gui/check_button.h"
#include "scene/gui/separator.h"
#include "scene/gui/tree.h"
#include "scene/scene_string_names.h"
@ -357,6 +358,7 @@ void ActionMapEditor::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
action_list_search->set_right_icon(get_editor_theme_icon(SNAME("Search")));
add_button->set_icon(get_editor_theme_icon(SNAME("Add")));
if (!actions_cache.is_empty()) {
update_action_list();
}
@ -570,6 +572,8 @@ ActionMapEditor::ActionMapEditor() {
// Disable the button and set its tooltip.
_add_edit_text_changed(add_edit->get_text());
add_hbox->add_child(memnew(VSeparator));
show_builtin_actions_checkbutton = memnew(CheckButton);
show_builtin_actions_checkbutton->set_text(TTR("Show Built-in Actions"));
show_builtin_actions_checkbutton->connect("toggled", callable_mp(this, &ActionMapEditor::set_show_builtin_actions));

View File

@ -65,6 +65,7 @@ void EditorAutoloadSettings::_notification(int p_what) {
case NOTIFICATION_THEME_CHANGED: {
browse_button->set_icon(get_editor_theme_icon(SNAME("Folder")));
add_autoload->set_icon(get_editor_theme_icon(SNAME("Add")));
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {

View File

@ -45,6 +45,9 @@ void GroupSettingsEditor::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
update_groups();
} break;
case NOTIFICATION_THEME_CHANGED: {
add_button->set_icon(get_editor_theme_icon(SNAME("Add")));
} break;
}
}

View File

@ -556,6 +556,8 @@ void ProjectSettingsEditor::_update_action_map_editor() {
}
void ProjectSettingsEditor::_update_theme() {
add_button->set_icon(get_editor_theme_icon(SNAME("Add")));
del_button->set_icon(get_editor_theme_icon(SNAME("Remove")));
search_box->set_right_icon(get_editor_theme_icon(SNAME("Search")));
restart_close_button->set_icon(get_editor_theme_icon(SNAME("Close")));
restart_container->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree")));

View File

@ -344,15 +344,29 @@ static Variant create_var(RS::GlobalShaderParameterType p_type) {
}
}
void ShaderGlobalsEditor::_variable_added() {
String var = variable_name->get_text().strip_edges();
if (var.is_empty() || !var.is_valid_identifier()) {
EditorNode::get_singleton()->show_warning(TTR("Please specify a valid shader uniform identifier name."));
return;
String ShaderGlobalsEditor::_check_new_variable_name(const String &p_variable_name) {
if (p_variable_name.is_empty()) {
return TTR("Name cannot be empty.");
}
if (!p_variable_name.is_valid_identifier()) {
return TTR("Name must be a valid identifier.");
}
return "";
}
void ShaderGlobalsEditor::_variable_name_text_changed(const String &p_variable_name) {
const String &warning = _check_new_variable_name(p_variable_name.strip_edges());
variable_add->set_tooltip_text(warning);
variable_add->set_disabled(!warning.is_empty());
}
void ShaderGlobalsEditor::_variable_added() {
String var = variable_name->get_text().strip_edges();
if (RenderingServer::get_singleton()->global_shader_parameter_get(var).get_type() != Variant::NIL) {
EditorNode::get_singleton()->show_warning(vformat(TTR("Global shader parameter '%s' already exists'"), var));
EditorNode::get_singleton()->show_warning(vformat(TTR("Global shader parameter '%s' already exists."), var));
return;
}
@ -416,6 +430,10 @@ void ShaderGlobalsEditor::_notification(int p_what) {
}
} break;
case NOTIFICATION_THEME_CHANGED: {
variable_add->set_icon(get_editor_theme_icon(SNAME("Add")));
} break;
case NOTIFICATION_PREDELETE: {
inspector->edit(nullptr);
} break;
@ -431,6 +449,9 @@ ShaderGlobalsEditor::ShaderGlobalsEditor() {
add_menu_hb->add_child(memnew(Label(TTR("Name:"))));
variable_name = memnew(LineEdit);
variable_name->set_h_size_flags(SIZE_EXPAND_FILL);
variable_name->set_clear_button_enabled(true);
variable_name->connect("text_changed", callable_mp(this, &ShaderGlobalsEditor::_variable_name_text_changed));
add_menu_hb->add_child(variable_name);
add_menu_hb->add_child(memnew(Label(TTR("Type:"))));
@ -443,6 +464,7 @@ ShaderGlobalsEditor::ShaderGlobalsEditor() {
}
variable_add = memnew(Button(TTR("Add")));
variable_add->set_disabled(true);
add_menu_hb->add_child(variable_add);
variable_add->connect("pressed", callable_mp(this, &ShaderGlobalsEditor::_variable_added));

View File

@ -49,6 +49,9 @@ class ShaderGlobalsEditor : public VBoxContainer {
OptionButton *variable_type = nullptr;
Button *variable_add = nullptr;
String _check_new_variable_name(const String &p_variable_name);
void _variable_name_text_changed(const String &p_variable_name);
void _variable_added();
void _variable_deleted(const String &p_variable);
void _changed();