summaryrefslogtreecommitdiffstats
path: root/editor
diff options
context:
space:
mode:
authorEugene Yang <eugene87222@gmail.com>2024-02-24 19:19:15 +0800
committerEugene Yang <eugene87222@gmail.com>2024-04-04 11:39:47 +0800
commitc5cab60b90d18f1d7a910a5d0a36397adaf007e8 (patch)
treea0e4df0b6045c7bd1edc894045aa11c68448ee11 /editor
parent9c626b623619d89ce3e02a8422a4de977e016d1b (diff)
downloadredot-engine-c5cab60b90d18f1d7a910a5d0a36397adaf007e8.tar.gz
Fix broken layout of asset library page
Diffstat (limited to 'editor')
-rw-r--r--editor/plugins/asset_library_editor_plugin.cpp25
-rw-r--r--editor/plugins/asset_library_editor_plugin.h1
2 files changed, 18 insertions, 8 deletions
diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp
index 459c5e8b31..395be532c4 100644
--- a/editor/plugins/asset_library_editor_plugin.cpp
+++ b/editor/plugins/asset_library_editor_plugin.cpp
@@ -55,7 +55,9 @@ static inline void setup_http_request(HTTPRequest *request) {
}
void EditorAssetLibraryItem::configure(const String &p_title, int p_asset_id, const String &p_category, int p_category_id, const String &p_author, int p_author_id, const String &p_cost) {
- title->set_text(p_title);
+ title_text = p_title;
+ title->set_text(title_text);
+ title->set_tooltip_text(title_text);
asset_id = p_asset_id;
category->set_text(p_category);
category_id = p_category_id;
@@ -66,16 +68,15 @@ void EditorAssetLibraryItem::configure(const String &p_title, int p_asset_id, co
// TODO: Refactor this method to use the TextServer.
void EditorAssetLibraryItem::clamp_width(int p_max_width) {
- int text_pixel_width = title->get_button_font().ptr()->get_string_size(title->get_text()).x * EDSCALE;
-
- String full_text = title->get_text();
- title->set_tooltip_text(full_text);
+ int text_pixel_width = title->get_button_font()->get_string_size(title_text).x * EDSCALE;
if (text_pixel_width > p_max_width) {
// Truncate title text to within the current column width.
- int max_length = p_max_width / (text_pixel_width / full_text.length());
- String truncated_text = full_text.left(max_length - 3) + "...";
+ int max_length = p_max_width / (text_pixel_width / title_text.length());
+ String truncated_text = title_text.left(max_length - 3) + "...";
title->set_text(truncated_text);
+ } else {
+ title->set_text(title_text);
}
}
@@ -1525,7 +1526,15 @@ void EditorAssetLibrary::_update_asset_items_columns() {
asset_items->set_columns(new_columns);
}
- asset_items_column_width = (get_size().x / new_columns) - (100 * EDSCALE);
+ asset_items_column_width = (get_size().x / new_columns) - (120 * EDSCALE);
+
+ for (int i = 0; i < asset_items->get_child_count(); i++) {
+ EditorAssetLibraryItem *item = Object::cast_to<EditorAssetLibraryItem>(asset_items->get_child(i));
+ if (!item || !item->is_visible()) {
+ continue;
+ }
+ item->clamp_width(asset_items_column_width);
+ }
}
void EditorAssetLibrary::_set_library_message(const String &p_message) {
diff --git a/editor/plugins/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h
index d4a1411c18..16b784d629 100644
--- a/editor/plugins/asset_library_editor_plugin.h
+++ b/editor/plugins/asset_library_editor_plugin.h
@@ -62,6 +62,7 @@ class EditorAssetLibraryItem : public PanelContainer {
LinkButton *author = nullptr;
Label *price = nullptr;
+ String title_text;
int asset_id = 0;
int category_id = 0;
int author_id = 0;