Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve "Add" button consistency in Project Settings #81905

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions editor/action_map_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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));
Expand Down
1 change: 1 addition & 0 deletions editor/editor_autoload_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
3 changes: 3 additions & 0 deletions editor/group_settings_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
2 changes: 2 additions & 0 deletions editor/project_settings_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")));
Expand Down
32 changes: 27 additions & 5 deletions editor/shader_globals_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,15 +344,29 @@ static Variant create_var(RS::GlobalShaderParameterType p_type) {
}
}

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 (var.is_empty() || !var.is_valid_identifier()) {
EditorNode::get_singleton()->show_warning(TTR("Please specify a valid shader uniform identifier name."));
return;
}

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;
}

Expand Down Expand Up @@ -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;
Expand All @@ -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:"))));
Expand All @@ -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));

Expand Down
3 changes: 3 additions & 0 deletions editor/shader_globals_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading