mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03: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:
@@ -32,10 +32,10 @@
|
||||
#include "scene/resources/text_line.h"
|
||||
|
||||
Size2 ProgressBar::get_minimum_size() const {
|
||||
Ref<StyleBox> bg = get_theme_stylebox("bg");
|
||||
Ref<StyleBox> fg = get_theme_stylebox("fg");
|
||||
Ref<Font> font = get_theme_font("font");
|
||||
int font_size = get_theme_font_size("font_size");
|
||||
Ref<StyleBox> bg = get_theme_stylebox(SNAME("bg"));
|
||||
Ref<StyleBox> fg = get_theme_stylebox(SNAME("fg"));
|
||||
Ref<Font> font = get_theme_font(SNAME("font"));
|
||||
int font_size = get_theme_font_size(SNAME("font_size"));
|
||||
|
||||
Size2 minimum_size = bg->get_minimum_size();
|
||||
minimum_size.height = MAX(minimum_size.height, fg->get_minimum_size().height);
|
||||
@@ -53,11 +53,11 @@ Size2 ProgressBar::get_minimum_size() const {
|
||||
|
||||
void ProgressBar::_notification(int p_what) {
|
||||
if (p_what == NOTIFICATION_DRAW) {
|
||||
Ref<StyleBox> bg = get_theme_stylebox("bg");
|
||||
Ref<StyleBox> fg = get_theme_stylebox("fg");
|
||||
Ref<Font> font = get_theme_font("font");
|
||||
int font_size = get_theme_font_size("font_size");
|
||||
Color font_color = get_theme_color("font_color");
|
||||
Ref<StyleBox> bg = get_theme_stylebox(SNAME("bg"));
|
||||
Ref<StyleBox> fg = get_theme_stylebox(SNAME("fg"));
|
||||
Ref<Font> font = get_theme_font(SNAME("font"));
|
||||
int font_size = get_theme_font_size(SNAME("font_size"));
|
||||
Color font_color = get_theme_color(SNAME("font_color"));
|
||||
|
||||
draw_style_box(bg, Rect2(Point2(), get_size()));
|
||||
float r = get_as_ratio();
|
||||
@@ -75,8 +75,8 @@ void ProgressBar::_notification(int p_what) {
|
||||
String txt = TS->format_number(itos(int(get_as_ratio() * 100))) + TS->percent_sign();
|
||||
TextLine tl = TextLine(txt, font, font_size);
|
||||
Vector2 text_pos = (Point2(get_size().width - tl.get_size().x, get_size().height - tl.get_size().y) / 2).round();
|
||||
Color font_outline_color = get_theme_color("font_outline_color");
|
||||
int outline_size = get_theme_constant("outline_size");
|
||||
Color font_outline_color = get_theme_color(SNAME("font_outline_color"));
|
||||
int outline_size = get_theme_constant(SNAME("outline_size"));
|
||||
if (outline_size > 0 && font_outline_color.a > 0) {
|
||||
tl.draw_outline(get_canvas_item(), text_pos, outline_size, font_outline_color);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user