Merge pull request #61215 from aaronfranke/pm-size-tweaks

This commit is contained in:
Rémi Verschelde 2022-05-20 14:38:38 +02:00 committed by GitHub
commit c95c9ab1c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 6 deletions

View File

@ -161,7 +161,7 @@ EditorAbout::EditorAbout() {
TabContainer *tc = memnew(TabContainer);
tc->set_tab_alignment(TabBar::ALIGNMENT_CENTER);
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

@ -1379,6 +1379,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() {
ADD_SIGNAL(MethodInfo("install_asset", PropertyInfo(Variant::STRING, "zip_path"), PropertyInfo(Variant::STRING, "name")));
}
@ -1446,6 +1450,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
search_hb2->add_child(sort);
sort->set_h_size_flags(Control::SIZE_EXPAND_FILL);
sort->set_clip_text(true);
sort->connect("item_selected", callable_mp(this, &EditorAssetLibrary::_rerun_search));
search_hb2->add_child(memnew(VSeparator));
@ -1455,6 +1460,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
categories->add_item(TTR("All"));
search_hb2->add_child(categories);
categories->set_h_size_flags(Control::SIZE_EXPAND_FILL);
categories->set_clip_text(true);
categories->connect("item_selected", callable_mp(this, &EditorAssetLibrary::_rerun_search));
search_hb2->add_child(memnew(VSeparator));
@ -1468,6 +1474,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
search_hb2->add_child(repository);
repository->set_h_size_flags(Control::SIZE_EXPAND_FILL);
repository->set_clip_text(true);
search_hb2->add_child(memnew(VSeparator));

View File

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

View File

@ -1884,6 +1884,16 @@ void ProjectManager::_notification(int p_what) {
if (open_templates->is_visible()) {
open_templates->popup_centered();
}
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: {
@ -2567,14 +2577,14 @@ ProjectManager::ProjectManager() {
tabs->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
tabs->connect("tab_changed", callable_mp(this, &ProjectManager::_on_tab_changed));
HBoxContainer *projects_hb = memnew(HBoxContainer);
projects_hb->set_name(TTR("Local Projects"));
tabs->add_child(projects_hb);
local_projects_hb = memnew(HBoxContainer);
local_projects_hb->set_name(TTR("Local Projects"));
tabs->add_child(local_projects_hb);
{
// Projects + search bar
VBoxContainer *search_tree_vb = memnew(VBoxContainer);
projects_hb->add_child(search_tree_vb);
local_projects_hb->add_child(search_tree_vb);
search_tree_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
HBoxContainer *hb = memnew(HBoxContainer);
@ -2630,7 +2640,7 @@ ProjectManager::ProjectManager() {
// Project tab side bar
VBoxContainer *tree_vb = memnew(VBoxContainer);
tree_vb->set_custom_minimum_size(Size2(120, 120));
projects_hb->add_child(tree_vb);
local_projects_hb->add_child(tree_vb);
Button *create = memnew(Button);
create->set_text(TTR("New Project"));

View File

@ -70,6 +70,7 @@ class ProjectManager : public Control {
Button *erase_missing_btn = nullptr;
Button *about_btn = nullptr;
HBoxContainer *local_projects_hb = nullptr;
EditorAssetLibrary *asset_library = nullptr;
EditorFileDialog *scan_dir = nullptr;