Make asset library's column count dynamic
(cherry picked from commit d65eb592b0
)
This commit is contained in:
parent
995281ca90
commit
77a9f3d4d8
|
@ -617,6 +617,10 @@ void EditorAssetLibrary::_notification(int p_what) {
|
||||||
filter->set_clear_button_enabled(true);
|
filter->set_clear_button_enabled(true);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case NOTIFICATION_RESIZED: {
|
||||||
|
_update_asset_items_columns();
|
||||||
|
} break;
|
||||||
|
|
||||||
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
|
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
|
||||||
_update_repository_options();
|
_update_repository_options();
|
||||||
setup_http_request(request);
|
setup_http_request(request);
|
||||||
|
@ -1208,7 +1212,7 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
|
||||||
library_vb->add_child(asset_top_page);
|
library_vb->add_child(asset_top_page);
|
||||||
|
|
||||||
asset_items = memnew(GridContainer);
|
asset_items = memnew(GridContainer);
|
||||||
asset_items->set_columns(2);
|
_update_asset_items_columns();
|
||||||
asset_items->add_constant_override("hseparation", 10 * EDSCALE);
|
asset_items->add_constant_override("hseparation", 10 * EDSCALE);
|
||||||
asset_items->add_constant_override("vseparation", 10 * EDSCALE);
|
asset_items->add_constant_override("vseparation", 10 * EDSCALE);
|
||||||
|
|
||||||
|
@ -1340,12 +1344,17 @@ void EditorAssetLibrary::_install_external_asset(String p_zip_path, String p_tit
|
||||||
emit_signal("install_asset", p_zip_path, p_title);
|
emit_signal("install_asset", p_zip_path, p_title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorAssetLibrary::disable_community_support() {
|
void EditorAssetLibrary::_update_asset_items_columns() {
|
||||||
support->get_popup()->set_item_checked(SUPPORT_COMMUNITY, false);
|
int new_columns = get_size().x / (450.0 * EDSCALE);
|
||||||
|
new_columns = MAX(1, new_columns);
|
||||||
|
|
||||||
|
if (new_columns != asset_items->get_columns()) {
|
||||||
|
asset_items->set_columns(new_columns);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorAssetLibrary::set_columns(const int p_columns) {
|
void EditorAssetLibrary::disable_community_support() {
|
||||||
asset_items->set_columns(p_columns);
|
support->get_popup()->set_item_checked(SUPPORT_COMMUNITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorAssetLibrary::_bind_methods() {
|
void EditorAssetLibrary::_bind_methods() {
|
||||||
|
@ -1522,7 +1531,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
|
||||||
library_vb->add_child(asset_top_page);
|
library_vb->add_child(asset_top_page);
|
||||||
|
|
||||||
asset_items = memnew(GridContainer);
|
asset_items = memnew(GridContainer);
|
||||||
asset_items->set_columns(2);
|
_update_asset_items_columns();
|
||||||
asset_items->add_constant_override("hseparation", 10 * EDSCALE);
|
asset_items->add_constant_override("hseparation", 10 * EDSCALE);
|
||||||
asset_items->add_constant_override("vseparation", 10 * EDSCALE);
|
asset_items->add_constant_override("vseparation", 10 * EDSCALE);
|
||||||
|
|
||||||
|
|
|
@ -294,6 +294,8 @@ class EditorAssetLibrary : public PanelContainer {
|
||||||
|
|
||||||
void _install_external_asset(String p_zip_path, String p_title);
|
void _install_external_asset(String p_zip_path, String p_title);
|
||||||
|
|
||||||
|
void _update_asset_items_columns();
|
||||||
|
|
||||||
friend class EditorAssetLibraryItemDescription;
|
friend class EditorAssetLibraryItemDescription;
|
||||||
friend class EditorAssetLibraryItem;
|
friend class EditorAssetLibraryItem;
|
||||||
|
|
||||||
|
@ -303,7 +305,6 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void disable_community_support();
|
void disable_community_support();
|
||||||
void set_columns(int p_columns);
|
|
||||||
|
|
||||||
EditorAssetLibrary(bool p_templates_only = false);
|
EditorAssetLibrary(bool p_templates_only = false);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1779,7 +1779,6 @@ void ProjectManager::_notification(int p_what) {
|
||||||
}
|
}
|
||||||
if (asset_library) {
|
if (asset_library) {
|
||||||
real_t size = get_size().x / EDSCALE;
|
real_t size = get_size().x / EDSCALE;
|
||||||
asset_library->set_columns(size < 1000 ? 1 : 2);
|
|
||||||
// Adjust names of tabs to fit the new size.
|
// Adjust names of tabs to fit the new size.
|
||||||
if (size < 650) {
|
if (size < 650) {
|
||||||
local_projects_hb->set_name(TTR("Local"));
|
local_projects_hb->set_name(TTR("Local"));
|
||||||
|
|
Loading…
Reference in New Issue