Improve "Add" button consistency in Project Settings
* Adds an icon to all the input-adjacent add/remove buttons * Adds a separator next to the action map "add" button * Changes the Shader Globals editor to be consistent with the others * Adds a clear button to the shader global name input
This commit is contained in:
parent
12ee58d8bc
commit
1910f91f17
@ -36,6 +36,7 @@
|
|||||||
#include "editor/event_listener_line_edit.h"
|
#include "editor/event_listener_line_edit.h"
|
||||||
#include "editor/input_event_configuration_dialog.h"
|
#include "editor/input_event_configuration_dialog.h"
|
||||||
#include "scene/gui/check_button.h"
|
#include "scene/gui/check_button.h"
|
||||||
|
#include "scene/gui/separator.h"
|
||||||
#include "scene/gui/tree.h"
|
#include "scene/gui/tree.h"
|
||||||
#include "scene/scene_string_names.h"
|
#include "scene/scene_string_names.h"
|
||||||
|
|
||||||
@ -357,6 +358,7 @@ void ActionMapEditor::_notification(int p_what) {
|
|||||||
case NOTIFICATION_ENTER_TREE:
|
case NOTIFICATION_ENTER_TREE:
|
||||||
case NOTIFICATION_THEME_CHANGED: {
|
case NOTIFICATION_THEME_CHANGED: {
|
||||||
action_list_search->set_right_icon(get_editor_theme_icon(SNAME("Search")));
|
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()) {
|
if (!actions_cache.is_empty()) {
|
||||||
update_action_list();
|
update_action_list();
|
||||||
}
|
}
|
||||||
@ -570,6 +572,8 @@ ActionMapEditor::ActionMapEditor() {
|
|||||||
// Disable the button and set its tooltip.
|
// Disable the button and set its tooltip.
|
||||||
_add_edit_text_changed(add_edit->get_text());
|
_add_edit_text_changed(add_edit->get_text());
|
||||||
|
|
||||||
|
add_hbox->add_child(memnew(VSeparator));
|
||||||
|
|
||||||
show_builtin_actions_checkbutton = memnew(CheckButton);
|
show_builtin_actions_checkbutton = memnew(CheckButton);
|
||||||
show_builtin_actions_checkbutton->set_text(TTR("Show Built-in Actions"));
|
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));
|
show_builtin_actions_checkbutton->connect("toggled", callable_mp(this, &ActionMapEditor::set_show_builtin_actions));
|
||||||
|
@ -65,6 +65,7 @@ void EditorAutoloadSettings::_notification(int p_what) {
|
|||||||
|
|
||||||
case NOTIFICATION_THEME_CHANGED: {
|
case NOTIFICATION_THEME_CHANGED: {
|
||||||
browse_button->set_icon(get_editor_theme_icon(SNAME("Folder")));
|
browse_button->set_icon(get_editor_theme_icon(SNAME("Folder")));
|
||||||
|
add_autoload->set_icon(get_editor_theme_icon(SNAME("Add")));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case NOTIFICATION_VISIBILITY_CHANGED: {
|
case NOTIFICATION_VISIBILITY_CHANGED: {
|
||||||
|
@ -45,6 +45,9 @@ void GroupSettingsEditor::_notification(int p_what) {
|
|||||||
case NOTIFICATION_ENTER_TREE: {
|
case NOTIFICATION_ENTER_TREE: {
|
||||||
update_groups();
|
update_groups();
|
||||||
} break;
|
} break;
|
||||||
|
case NOTIFICATION_THEME_CHANGED: {
|
||||||
|
add_button->set_icon(get_editor_theme_icon(SNAME("Add")));
|
||||||
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -556,6 +556,8 @@ void ProjectSettingsEditor::_update_action_map_editor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ProjectSettingsEditor::_update_theme() {
|
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")));
|
search_box->set_right_icon(get_editor_theme_icon(SNAME("Search")));
|
||||||
restart_close_button->set_icon(get_editor_theme_icon(SNAME("Close")));
|
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")));
|
restart_container->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree")));
|
||||||
|
@ -344,15 +344,29 @@ static Variant create_var(RS::GlobalShaderParameterType p_type) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderGlobalsEditor::_variable_added() {
|
String ShaderGlobalsEditor::_check_new_variable_name(const String &p_variable_name) {
|
||||||
String var = variable_name->get_text().strip_edges();
|
if (p_variable_name.is_empty()) {
|
||||||
if (var.is_empty() || !var.is_valid_identifier()) {
|
return TTR("Name cannot be empty.");
|
||||||
EditorNode::get_singleton()->show_warning(TTR("Please specify a valid shader uniform identifier name."));
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,6 +430,10 @@ void ShaderGlobalsEditor::_notification(int p_what) {
|
|||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case NOTIFICATION_THEME_CHANGED: {
|
||||||
|
variable_add->set_icon(get_editor_theme_icon(SNAME("Add")));
|
||||||
|
} break;
|
||||||
|
|
||||||
case NOTIFICATION_PREDELETE: {
|
case NOTIFICATION_PREDELETE: {
|
||||||
inspector->edit(nullptr);
|
inspector->edit(nullptr);
|
||||||
} break;
|
} break;
|
||||||
@ -431,6 +449,9 @@ ShaderGlobalsEditor::ShaderGlobalsEditor() {
|
|||||||
add_menu_hb->add_child(memnew(Label(TTR("Name:"))));
|
add_menu_hb->add_child(memnew(Label(TTR("Name:"))));
|
||||||
variable_name = memnew(LineEdit);
|
variable_name = memnew(LineEdit);
|
||||||
variable_name->set_h_size_flags(SIZE_EXPAND_FILL);
|
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(variable_name);
|
||||||
|
|
||||||
add_menu_hb->add_child(memnew(Label(TTR("Type:"))));
|
add_menu_hb->add_child(memnew(Label(TTR("Type:"))));
|
||||||
@ -443,6 +464,7 @@ ShaderGlobalsEditor::ShaderGlobalsEditor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
variable_add = memnew(Button(TTR("Add")));
|
variable_add = memnew(Button(TTR("Add")));
|
||||||
|
variable_add->set_disabled(true);
|
||||||
add_menu_hb->add_child(variable_add);
|
add_menu_hb->add_child(variable_add);
|
||||||
variable_add->connect("pressed", callable_mp(this, &ShaderGlobalsEditor::_variable_added));
|
variable_add->connect("pressed", callable_mp(this, &ShaderGlobalsEditor::_variable_added));
|
||||||
|
|
||||||
|
@ -49,6 +49,9 @@ class ShaderGlobalsEditor : public VBoxContainer {
|
|||||||
OptionButton *variable_type = nullptr;
|
OptionButton *variable_type = nullptr;
|
||||||
Button *variable_add = 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_added();
|
||||||
void _variable_deleted(const String &p_variable);
|
void _variable_deleted(const String &p_variable);
|
||||||
void _changed();
|
void _changed();
|
||||||
|
Loading…
Reference in New Issue
Block a user