Tweaks to improve the Project Manager display at small sizes

This commit is contained in:
Aaron Franke 2022-05-19 23:57:10 -05:00 committed by Hugo Locurcio
parent 67208ae80b
commit 08a397c4b7
No known key found for this signature in database
GPG Key ID: 39E8F8BE30B0A49C
5 changed files with 25 additions and 11 deletions

View File

@ -154,7 +154,7 @@ EditorAbout::EditorAbout() {
hbc->add_child(version_info_vbc);
TabContainer *tc = memnew(TabContainer);
tc->set_custom_minimum_size(Size2(950, 400) * EDSCALE);
tc->set_custom_minimum_size(Size2(400, 200) * EDSCALE);
tc->set_v_size_flags(Control::SIZE_EXPAND_FILL);
vbc->add_child(tc);

View File

@ -1341,6 +1341,10 @@ void EditorAssetLibrary::disable_community_support() {
support->get_popup()->set_item_checked(SUPPORT_COMMUNITY, false);
}
void EditorAssetLibrary::set_columns(const int p_columns) {
asset_items->set_columns(p_columns);
}
void EditorAssetLibrary::_bind_methods() {
ClassDB::bind_method("_http_request_completed", &EditorAssetLibrary::_http_request_completed);
ClassDB::bind_method("_select_asset", &EditorAssetLibrary::_select_asset);
@ -1426,8 +1430,8 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
search_hb2->add_child(sort);
sort->set_h_size_flags(SIZE_EXPAND_FILL);
sort->set_clip_text(true);
sort->connect("item_selected", this, "_rerun_search");
search_hb2->add_child(memnew(VSeparator));
search_hb2->add_child(memnew(Label(TTR("Category:") + " ")));
@ -1435,6 +1439,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
categories->add_item(TTR("All"));
search_hb2->add_child(categories);
categories->set_h_size_flags(SIZE_EXPAND_FILL);
categories->set_clip_text(true);
categories->connect("item_selected", this, "_rerun_search");
search_hb2->add_child(memnew(VSeparator));
@ -1448,6 +1453,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
search_hb2->add_child(repository);
repository->set_h_size_flags(SIZE_EXPAND_FILL);
repository->set_clip_text(true);
search_hb2->add_child(memnew(VSeparator));

View File

@ -303,6 +303,7 @@ protected:
public:
void disable_community_support();
void set_columns(int p_columns);
EditorAssetLibrary(bool p_templates_only = false);
};

View File

@ -1772,6 +1772,16 @@ void ProjectManager::_notification(int p_what) {
if (open_templates->is_visible()) {
open_templates->popup_centered_minsize();
}
real_t size = get_size().x / EDSCALE;
asset_library->set_columns(size < 1000 ? 1 : 2);
// Adjust names of tabs to fit the new size.
if (size < 650) {
local_projects_hb->set_name(TTR("Local"));
asset_library->set_name(TTR("Asset Library"));
} else {
local_projects_hb->set_name(TTR("Local Projects"));
asset_library->set_name(TTR("Asset Library Projects"));
}
} break;
case NOTIFICATION_READY: {
if (_project_list->get_project_count() == 0 && StreamPeerSSL::is_available()) {
@ -2449,15 +2459,12 @@ ProjectManager::ProjectManager() {
tabs->set_tab_align(TabContainer::ALIGN_LEFT);
tabs->connect("tab_changed", this, "_on_tab_changed");
HBoxContainer *tree_hb = memnew(HBoxContainer);
projects_hb = tree_hb;
projects_hb->set_name(TTR("Local Projects"));
tabs->add_child(tree_hb);
local_projects_hb = memnew(HBoxContainer);
local_projects_hb->set_name(TTR("Local Projects"));
tabs->add_child(local_projects_hb);
VBoxContainer *search_tree_vb = memnew(VBoxContainer);
tree_hb->add_child(search_tree_vb);
local_projects_hb->add_child(search_tree_vb);
search_tree_vb->set_h_size_flags(SIZE_EXPAND_FILL);
HBoxContainer *sort_filters = memnew(HBoxContainer);
@ -2507,7 +2514,7 @@ ProjectManager::ProjectManager() {
VBoxContainer *tree_vb = memnew(VBoxContainer);
tree_vb->set_custom_minimum_size(Size2(120, 120));
tree_hb->add_child(tree_vb);
local_projects_hb->add_child(tree_vb);
Button *open = memnew(Button);
open->set_text(TTR("Edit"));

View File

@ -77,7 +77,7 @@ class ProjectManager : public Control {
AcceptDialog *dialog_error;
ProjectDialog *npdialog;
HBoxContainer *projects_hb;
HBoxContainer *local_projects_hb;
TabContainer *tabs;
ProjectList *_project_list;