mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Improve loading UX in the asset library
The asset library will now fade when loading pages instead of displaying a progress bar, which is a more common design pattern when browsing an online resource's pages. A "Loading..." text will be displayed before the first page loads.
This commit is contained in:
parent
791d7f78b5
commit
f524dc5da6
2 changed files with 15 additions and 31 deletions
|
@ -600,33 +600,15 @@ void EditorAssetLibrary::_notification(int p_what) {
|
||||||
case NOTIFICATION_PROCESS: {
|
case NOTIFICATION_PROCESS: {
|
||||||
|
|
||||||
HTTPClient::Status s = request->get_http_client_status();
|
HTTPClient::Status s = request->get_http_client_status();
|
||||||
bool visible = s != HTTPClient::STATUS_DISCONNECTED;
|
const bool loading = s != HTTPClient::STATUS_DISCONNECTED;
|
||||||
|
|
||||||
if (visible != load_status->is_visible()) {
|
if (loading) {
|
||||||
load_status->set_visible(visible);
|
library_scroll->set_modulate(Color(1, 1, 1, 0.5));
|
||||||
|
} else {
|
||||||
|
library_scroll->set_modulate(Color(1, 1, 1, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visible) {
|
const bool no_downloads = downloads_hb->get_child_count() == 0;
|
||||||
switch (s) {
|
|
||||||
|
|
||||||
case HTTPClient::STATUS_RESOLVING: {
|
|
||||||
load_status->set_value(0.1);
|
|
||||||
} break;
|
|
||||||
case HTTPClient::STATUS_CONNECTING: {
|
|
||||||
load_status->set_value(0.2);
|
|
||||||
} break;
|
|
||||||
case HTTPClient::STATUS_REQUESTING: {
|
|
||||||
load_status->set_value(0.3);
|
|
||||||
} break;
|
|
||||||
case HTTPClient::STATUS_BODY: {
|
|
||||||
load_status->set_value(0.4);
|
|
||||||
} break;
|
|
||||||
default: {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool no_downloads = downloads_hb->get_child_count() == 0;
|
|
||||||
if (no_downloads == downloads_scroll->is_visible()) {
|
if (no_downloads == downloads_scroll->is_visible()) {
|
||||||
downloads_scroll->set_visible(!no_downloads);
|
downloads_scroll->set_visible(!no_downloads);
|
||||||
}
|
}
|
||||||
|
@ -1157,6 +1139,10 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
|
||||||
_search();
|
_search();
|
||||||
} break;
|
} break;
|
||||||
case REQUESTING_SEARCH: {
|
case REQUESTING_SEARCH: {
|
||||||
|
|
||||||
|
// The loading text only needs to be displayed before the first page is loaded
|
||||||
|
library_loading->hide();
|
||||||
|
|
||||||
if (asset_items) {
|
if (asset_items) {
|
||||||
memdelete(asset_items);
|
memdelete(asset_items);
|
||||||
}
|
}
|
||||||
|
@ -1472,6 +1458,10 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
|
||||||
|
|
||||||
library_vb_border->add_child(library_vb);
|
library_vb_border->add_child(library_vb);
|
||||||
|
|
||||||
|
library_loading = memnew(Label(TTR("Loading...")));
|
||||||
|
library_loading->set_align(Label::ALIGN_CENTER);
|
||||||
|
library_vb->add_child(library_loading);
|
||||||
|
|
||||||
asset_top_page = memnew(HBoxContainer);
|
asset_top_page = memnew(HBoxContainer);
|
||||||
library_vb->add_child(asset_top_page);
|
library_vb->add_child(asset_top_page);
|
||||||
|
|
||||||
|
@ -1494,12 +1484,6 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
|
||||||
|
|
||||||
library_vb->add_constant_override("separation", 20 * EDSCALE);
|
library_vb->add_constant_override("separation", 20 * EDSCALE);
|
||||||
|
|
||||||
load_status = memnew(ProgressBar);
|
|
||||||
load_status->set_min(0);
|
|
||||||
load_status->set_max(1);
|
|
||||||
load_status->set_step(0.001);
|
|
||||||
library_main->add_child(load_status);
|
|
||||||
|
|
||||||
error_hb = memnew(HBoxContainer);
|
error_hb = memnew(HBoxContainer);
|
||||||
library_main->add_child(error_hb);
|
library_main->add_child(error_hb);
|
||||||
error_label = memnew(Label);
|
error_label = memnew(Label);
|
||||||
|
|
|
@ -186,13 +186,13 @@ class EditorAssetLibrary : public PanelContainer {
|
||||||
PanelContainer *library_scroll_bg;
|
PanelContainer *library_scroll_bg;
|
||||||
ScrollContainer *library_scroll;
|
ScrollContainer *library_scroll;
|
||||||
VBoxContainer *library_vb;
|
VBoxContainer *library_vb;
|
||||||
|
Label *library_loading;
|
||||||
LineEdit *filter;
|
LineEdit *filter;
|
||||||
OptionButton *categories;
|
OptionButton *categories;
|
||||||
OptionButton *repository;
|
OptionButton *repository;
|
||||||
OptionButton *sort;
|
OptionButton *sort;
|
||||||
ToolButton *reverse;
|
ToolButton *reverse;
|
||||||
Button *search;
|
Button *search;
|
||||||
ProgressBar *load_status;
|
|
||||||
HBoxContainer *error_hb;
|
HBoxContainer *error_hb;
|
||||||
TextureRect *error_tr;
|
TextureRect *error_tr;
|
||||||
Label *error_label;
|
Label *error_label;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue