You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-06 12:20:30 +00:00
Optimize StringName usage
* Added a new macro SNAME() that constructs and caches a local stringname. * Subsequent usages use the cached version. * Since these use a global static variable, a second refcounter of static usages need to be kept for cleanup time. * Replaced all theme usages by this new macro. * Replace all signal emission usages by this new macro. * Replace all call_deferred usages by this new macro. This is part of ongoing work to optimize GUI and the editor.
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
|
||||
void FontDataPreview::_notification(int p_what) {
|
||||
if (p_what == NOTIFICATION_DRAW) {
|
||||
Color text_color = get_theme_color("font_color", "Label");
|
||||
Color text_color = get_theme_color(SNAME("font_color"), SNAME("Label"));
|
||||
Color line_color = text_color;
|
||||
line_color.a *= 0.6;
|
||||
Vector2 pos = (get_size() - line->get_size()) / 2;
|
||||
@@ -127,7 +127,7 @@ FontDataPreview::FontDataPreview() {
|
||||
void FontDataEditor::_notification(int p_what) {
|
||||
if (p_what == NOTIFICATION_SORT_CHILDREN) {
|
||||
int split_width = get_name_split_ratio() * get_size().width;
|
||||
button->set_size(Size2(get_theme_icon("Add", "EditorIcons")->get_width(), get_size().height));
|
||||
button->set_size(Size2(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))->get_width(), get_size().height));
|
||||
if (is_layout_rtl()) {
|
||||
if (le != nullptr) {
|
||||
fit_child_in_rect(le, Rect2(Vector2(split_width, 0), Size2(split_width, get_size().height)));
|
||||
@@ -145,7 +145,7 @@ void FontDataEditor::_notification(int p_what) {
|
||||
}
|
||||
if (p_what == NOTIFICATION_DRAW) {
|
||||
int split_width = get_name_split_ratio() * get_size().width;
|
||||
Color dark_color = get_theme_color("dark_color_2", "Editor");
|
||||
Color dark_color = get_theme_color(SNAME("dark_color_2"), SNAME("Editor"));
|
||||
if (is_layout_rtl()) {
|
||||
draw_rect(Rect2(Vector2(0, 0), Size2(split_width, get_size().height)), dark_color);
|
||||
} else {
|
||||
@@ -154,9 +154,9 @@ void FontDataEditor::_notification(int p_what) {
|
||||
}
|
||||
if (p_what == NOTIFICATION_THEME_CHANGED) {
|
||||
if (le != nullptr) {
|
||||
button->set_icon(get_theme_icon("Add", "EditorIcons"));
|
||||
button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
|
||||
} else {
|
||||
button->set_icon(get_theme_icon("Remove", "EditorIcons"));
|
||||
button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
|
||||
}
|
||||
queue_sort();
|
||||
}
|
||||
@@ -187,12 +187,12 @@ void FontDataEditor::init_lang_add() {
|
||||
le->set_editable(true);
|
||||
add_child(le);
|
||||
|
||||
button->set_icon(get_theme_icon("Add", "EditorIcons"));
|
||||
button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
|
||||
button->connect("pressed", callable_mp(this, &FontDataEditor::add_lang));
|
||||
}
|
||||
|
||||
void FontDataEditor::init_lang_edit() {
|
||||
button->set_icon(get_theme_icon("Remove", "EditorIcons"));
|
||||
button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
|
||||
button->connect("pressed", callable_mp(this, &FontDataEditor::remove_lang));
|
||||
chk->connect("toggled", callable_mp(this, &FontDataEditor::toggle_lang));
|
||||
}
|
||||
@@ -204,12 +204,12 @@ void FontDataEditor::init_script_add() {
|
||||
le->set_editable(true);
|
||||
add_child(le);
|
||||
|
||||
button->set_icon(get_theme_icon("Add", "EditorIcons"));
|
||||
button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
|
||||
button->connect("pressed", callable_mp(this, &FontDataEditor::add_script));
|
||||
}
|
||||
|
||||
void FontDataEditor::init_script_edit() {
|
||||
button->set_icon(get_theme_icon("Remove", "EditorIcons"));
|
||||
button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
|
||||
button->connect("pressed", callable_mp(this, &FontDataEditor::remove_script));
|
||||
chk->connect("toggled", callable_mp(this, &FontDataEditor::toggle_script));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user