mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 07:17:42 -05: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:
@@ -76,8 +76,8 @@ void SplitContainer::_resort() {
|
||||
bool second_expanded = (vertical ? second->get_v_size_flags() : second->get_h_size_flags()) & SIZE_EXPAND;
|
||||
|
||||
// Determine the separation between items
|
||||
Ref<Texture2D> g = get_theme_icon("grabber");
|
||||
int sep = get_theme_constant("separation");
|
||||
Ref<Texture2D> g = get_theme_icon(SNAME("grabber"));
|
||||
int sep = get_theme_constant(SNAME("separation"));
|
||||
sep = (dragger_visibility != DRAGGER_HIDDEN_COLLAPSED) ? MAX(sep, vertical ? g->get_height() : g->get_width()) : 0;
|
||||
|
||||
// Compute the minimum size
|
||||
@@ -131,8 +131,8 @@ Size2 SplitContainer::get_minimum_size() const {
|
||||
/* Calculate MINIMUM SIZE */
|
||||
|
||||
Size2i minimum;
|
||||
Ref<Texture2D> g = get_theme_icon("grabber");
|
||||
int sep = get_theme_constant("separation");
|
||||
Ref<Texture2D> g = get_theme_icon(SNAME("grabber"));
|
||||
int sep = get_theme_constant(SNAME("separation"));
|
||||
sep = (dragger_visibility != DRAGGER_HIDDEN_COLLAPSED) ? MAX(sep, vertical ? g->get_height() : g->get_width()) : 0;
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
@@ -173,7 +173,7 @@ void SplitContainer::_notification(int p_what) {
|
||||
} break;
|
||||
case NOTIFICATION_MOUSE_EXIT: {
|
||||
mouse_inside = false;
|
||||
if (get_theme_constant("autohide")) {
|
||||
if (get_theme_constant(SNAME("autohide"))) {
|
||||
update();
|
||||
}
|
||||
} break;
|
||||
@@ -182,7 +182,7 @@ void SplitContainer::_notification(int p_what) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (collapsed || (!dragging && !mouse_inside && get_theme_constant("autohide"))) {
|
||||
if (collapsed || (!dragging && !mouse_inside && get_theme_constant(SNAME("autohide")))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -190,8 +190,8 @@ void SplitContainer::_notification(int p_what) {
|
||||
return;
|
||||
}
|
||||
|
||||
int sep = dragger_visibility != DRAGGER_HIDDEN_COLLAPSED ? get_theme_constant("separation") : 0;
|
||||
Ref<Texture2D> tex = get_theme_icon("grabber");
|
||||
int sep = dragger_visibility != DRAGGER_HIDDEN_COLLAPSED ? get_theme_constant(SNAME("separation")) : 0;
|
||||
Ref<Texture2D> tex = get_theme_icon(SNAME("grabber"));
|
||||
Size2 size = get_size();
|
||||
|
||||
if (vertical) {
|
||||
@@ -218,7 +218,7 @@ void SplitContainer::_gui_input(const Ref<InputEvent> &p_event) {
|
||||
if (mb.is_valid()) {
|
||||
if (mb->get_button_index() == MOUSE_BUTTON_LEFT) {
|
||||
if (mb->is_pressed()) {
|
||||
int sep = get_theme_constant("separation");
|
||||
int sep = get_theme_constant(SNAME("separation"));
|
||||
|
||||
if (vertical) {
|
||||
if (mb->get_position().y > middle_sep && mb->get_position().y < middle_sep + sep) {
|
||||
@@ -244,14 +244,14 @@ void SplitContainer::_gui_input(const Ref<InputEvent> &p_event) {
|
||||
if (mm.is_valid()) {
|
||||
bool mouse_inside_state = false;
|
||||
if (vertical) {
|
||||
mouse_inside_state = mm->get_position().y > middle_sep && mm->get_position().y < middle_sep + get_theme_constant("separation");
|
||||
mouse_inside_state = mm->get_position().y > middle_sep && mm->get_position().y < middle_sep + get_theme_constant(SNAME("separation"));
|
||||
} else {
|
||||
mouse_inside_state = mm->get_position().x > middle_sep && mm->get_position().x < middle_sep + get_theme_constant("separation");
|
||||
mouse_inside_state = mm->get_position().x > middle_sep && mm->get_position().x < middle_sep + get_theme_constant(SNAME("separation"));
|
||||
}
|
||||
|
||||
if (mouse_inside != mouse_inside_state) {
|
||||
mouse_inside = mouse_inside_state;
|
||||
if (get_theme_constant("autohide")) {
|
||||
if (get_theme_constant(SNAME("autohide"))) {
|
||||
update();
|
||||
}
|
||||
}
|
||||
@@ -267,7 +267,7 @@ void SplitContainer::_gui_input(const Ref<InputEvent> &p_event) {
|
||||
}
|
||||
should_clamp_split_offset = true;
|
||||
queue_sort();
|
||||
emit_signal("dragged", get_split_offset());
|
||||
emit_signal(SNAME("dragged"), get_split_offset());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ Control::CursorShape SplitContainer::get_cursor_shape(const Point2 &p_pos) const
|
||||
}
|
||||
|
||||
if (!collapsed && _getch(0) && _getch(1) && dragger_visibility == DRAGGER_VISIBLE) {
|
||||
int sep = get_theme_constant("separation");
|
||||
int sep = get_theme_constant(SNAME("separation"));
|
||||
|
||||
if (vertical) {
|
||||
if (p_pos.y > middle_sep && p_pos.y < middle_sep + sep) {
|
||||
|
||||
Reference in New Issue
Block a user