Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor: Fix AssetLib is not updating size and stuck #86051

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions editor/plugins/asset_library_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "core/input/input.h"
#include "core/io/json.h"
#include "core/io/stream_peer_tls.h"
#include "core/math/vector2.h"
#include "core/os/keyboard.h"
#include "core/version.h"
#include "editor/editor_node.h"
Expand All @@ -56,6 +57,7 @@ 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->set_tooltip_text(p_title);
asset_id = p_asset_id;
category->set_text(p_category);
category_id = p_category_id;
Expand All @@ -66,16 +68,18 @@ 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_tooltip(Point2());

String full_text = title->get_text();
title->set_tooltip_text(full_text);
int text_pixel_width = title->get_button_font().ptr()->get_string_size(full_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) + "...";
title->set_text(truncated_text);
} else {
// Set title text to full text if we have enough room.
title->set_text(full_text);
}
}

Expand Down Expand Up @@ -639,6 +643,9 @@ void EditorAssetLibrary::_notification(int p_what) {

case NOTIFICATION_RESIZED: {
_update_asset_items_columns();
for (int i = 0; i < asset_items->get_child_count(); i++) {
static_cast<EditorAssetLibraryItem *>(asset_items->get_child(i))->clamp_width(asset_items_column_width);
}
} break;

case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
Expand Down
Loading