Use LW_NAME in TreeSearch where appropriate

This commit is contained in:
Alexander Montag 2024-09-28 17:45:17 +00:00
parent a31b8b7520
commit acb2bcc901
3 changed files with 12 additions and 6 deletions

View File

@ -49,7 +49,7 @@ void TreeSearchPanel::_initialize_controls() {
line_edit_search->set_placeholder(TTR("Search tree"));
close_button->set_theme_type_variation("FlatButton");
close_button->set_theme_type_variation(LW_NAME(FlatButton));
// positioning and sizing
set_anchors_and_offsets_preset(LayoutPreset::PRESET_BOTTOM_WIDE);
@ -222,11 +222,11 @@ void TreeSearch::_draw_highlight_item(TreeItem *p_tree_item, Rect2 p_rect, Calla
Vector2 substring_before_size = font->get_string_size(substring_before, HORIZONTAL_ALIGNMENT_LEFT, -1.f, font_size);
// stylebox
Ref<StyleBox> stylebox = p_tree_item->get_tree()->get_theme_stylebox("Focus");
Ref<StyleBox> stylebox = p_tree_item->get_tree()->get_theme_stylebox(LW_NAME(Focus));
ERR_FAIL_NULL(stylebox);
// extract separation
float h_sep = p_tree_item->get_tree()->get_theme_constant("h_separation");
float h_sep = p_tree_item->get_tree()->get_theme_constant(LW_NAME(h_separation));
// compose draw rect
const Vector2 PADDING = Vector2(4., 2.);
@ -247,9 +247,9 @@ void TreeSearch::_draw_highlight_item(TreeItem *p_tree_item, Rect2 p_rect, Calla
// second part: draw number
int num_mat = number_matches.has(p_tree_item) ? number_matches.get(p_tree_item) : 0;
if (num_mat > 0) {
float h_sep = p_tree_item->get_tree()->get_theme_constant("h_separation");
Ref<Font> font = tree_reference->get_theme_font("font");
float font_size = tree_reference->get_theme_font_size("font") * 0.75;
float h_sep = p_tree_item->get_tree()->get_theme_constant(LW_NAME(h_separation));
Ref<Font> font = tree_reference->get_theme_font(LW_NAME(font));
float font_size = tree_reference->get_theme_font_size(LW_NAME(font)) * 0.75;
String num_string = String::num_int64(num_mat);
Vector2 string_size = font->get_string_size(num_string, HORIZONTAL_ALIGNMENT_CENTER, -1, font_size);

View File

@ -67,6 +67,8 @@ LimboStringNames::LimboStringNames() {
exited = SN("exited");
favorite_tasks_changed = SN("favorite_tasks_changed");
Favorites = SN("Favorites");
FlatButton = SN("FlatButton");
Focus = SN("Focus");
focus_exited = SN("focus_exited");
font = SN("font");
font_color = SN("font_color");
@ -78,6 +80,7 @@ LimboStringNames::LimboStringNames() {
GuiTreeArrowRight = SN("GuiTreeArrowRight");
HeaderSmall = SN("HeaderSmall");
Help = SN("Help");
h_separation = SN("h_separation");
icon_max_width = SN("icon_max_width");
class_icon_size = SN("class_icon_size");
id_pressed = SN("id_pressed");

View File

@ -83,6 +83,8 @@ public:
StringName exited;
StringName favorite_tasks_changed;
StringName Favorites;
StringName FlatButton;
StringName Focus;
StringName focus_exited;
StringName font_color;
StringName font_size;
@ -94,6 +96,7 @@ public:
StringName GuiTreeArrowRight;
StringName HeaderSmall;
StringName Help;
StringName h_separation;
StringName icon_max_width;
StringName class_icon_size;
StringName id_pressed;