Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 438d960

Browse files
committedJul 31, 2023
Merge pull request #50674 from starry-abyss/master
Reorganize buttons in the project manager
2 parents 54ba3cf + 40eeeb9 commit 438d960

File tree

2 files changed

+44
-42
lines changed

2 files changed

+44
-42
lines changed
 

‎editor/project_manager.cpp

+43-41
Original file line numberDiff line numberDiff line change
@@ -1977,10 +1977,10 @@ void ProjectManager::_notification(int p_what) {
19771977
real_t size = get_size().x / EDSCALE;
19781978
// Adjust names of tabs to fit the new size.
19791979
if (size < 650) {
1980-
local_projects_hb->set_name(TTR("Local"));
1980+
local_projects_vb->set_name(TTR("Local"));
19811981
asset_library->set_name(TTR("Asset Library"));
19821982
} else {
1983-
local_projects_hb->set_name(TTR("Local Projects"));
1983+
local_projects_vb->set_name(TTR("Local Projects"));
19841984
asset_library->set_name(TTR("Asset Library Projects"));
19851985
}
19861986
}
@@ -2845,19 +2845,39 @@ ProjectManager::ProjectManager() {
28452845
tabs->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
28462846
tabs->connect("tab_changed", callable_mp(this, &ProjectManager::_on_tab_changed));
28472847

2848-
local_projects_hb = memnew(HBoxContainer);
2849-
local_projects_hb->set_name(TTR("Local Projects"));
2850-
tabs->add_child(local_projects_hb);
2848+
local_projects_vb = memnew(VBoxContainer);
2849+
local_projects_vb->set_name(TTR("Local Projects"));
2850+
tabs->add_child(local_projects_vb);
28512851

28522852
{
2853-
// Projects + search bar
2854-
VBoxContainer *search_tree_vb = memnew(VBoxContainer);
2855-
local_projects_hb->add_child(search_tree_vb);
2856-
search_tree_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
2857-
2853+
// A bar at top with buttons and options.
28582854
HBoxContainer *hb = memnew(HBoxContainer);
28592855
hb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
2860-
search_tree_vb->add_child(hb);
2856+
local_projects_vb->add_child(hb);
2857+
2858+
create_btn = memnew(Button);
2859+
create_btn->set_text(TTR("New"));
2860+
create_btn->set_shortcut(ED_SHORTCUT("project_manager/new_project", TTR("New Project"), KeyModifierMask::CMD_OR_CTRL | Key::N));
2861+
create_btn->connect("pressed", callable_mp(this, &ProjectManager::_new_project));
2862+
hb->add_child(create_btn);
2863+
2864+
import_btn = memnew(Button);
2865+
import_btn->set_text(TTR("Import"));
2866+
import_btn->set_shortcut(ED_SHORTCUT("project_manager/import_project", TTR("Import Project"), KeyModifierMask::CMD_OR_CTRL | Key::I));
2867+
import_btn->connect("pressed", callable_mp(this, &ProjectManager::_import_project));
2868+
hb->add_child(import_btn);
2869+
2870+
scan_btn = memnew(Button);
2871+
scan_btn->set_text(TTR("Scan"));
2872+
scan_btn->set_shortcut(ED_SHORTCUT("project_manager/scan_projects", TTR("Scan Projects"), KeyModifierMask::CMD_OR_CTRL | Key::S));
2873+
scan_btn->connect("pressed", callable_mp(this, &ProjectManager::_scan_projects));
2874+
hb->add_child(scan_btn);
2875+
2876+
loading_label = memnew(Label(TTR("Loading, please wait...")));
2877+
loading_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
2878+
hb->add_child(loading_label);
2879+
// The loading label is shown later.
2880+
loading_label->hide();
28612881

28622882
search_box = memnew(LineEdit);
28632883
search_box->set_placeholder(TTR("Filter Projects"));
@@ -2867,19 +2887,14 @@ ProjectManager::ProjectManager() {
28672887
search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
28682888
hb->add_child(search_box);
28692889

2870-
loading_label = memnew(Label(TTR("Loading, please wait...")));
2871-
loading_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
2872-
hb->add_child(loading_label);
2873-
// The loading label is shown later.
2874-
loading_label->hide();
2875-
28762890
Label *sort_label = memnew(Label);
28772891
sort_label->set_text(TTR("Sort:"));
28782892
hb->add_child(sort_label);
28792893

28802894
filter_option = memnew(OptionButton);
28812895
filter_option->set_clip_text(true);
28822896
filter_option->set_h_size_flags(Control::SIZE_EXPAND_FILL);
2897+
filter_option->set_stretch_ratio(0.3);
28832898
filter_option->connect("item_selected", callable_mp(this, &ProjectManager::_on_order_option_changed));
28842899
hb->add_child(filter_option);
28852900

@@ -2892,41 +2907,28 @@ ProjectManager::ProjectManager() {
28922907
for (int i = 0; i < sort_filter_titles.size(); i++) {
28932908
filter_option->add_item(sort_filter_titles[i]);
28942909
}
2910+
}
2911+
2912+
{
2913+
// A container for the project list and for the side bar with buttons.
2914+
HBoxContainer *search_tree_hb = memnew(HBoxContainer);
2915+
local_projects_vb->add_child(search_tree_hb);
2916+
search_tree_hb->set_v_size_flags(Control::SIZE_EXPAND_FILL);
28952917

28962918
search_panel = memnew(PanelContainer);
2897-
search_panel->set_v_size_flags(Control::SIZE_EXPAND_FILL);
2898-
search_tree_vb->add_child(search_panel);
2919+
search_panel->set_h_size_flags(Control::SIZE_EXPAND_FILL);
2920+
search_tree_hb->add_child(search_panel);
28992921

29002922
_project_list = memnew(ProjectList);
29012923
_project_list->connect(ProjectList::SIGNAL_SELECTION_CHANGED, callable_mp(this, &ProjectManager::_update_project_buttons));
29022924
_project_list->connect(ProjectList::SIGNAL_PROJECT_ASK_OPEN, callable_mp(this, &ProjectManager::_open_selected_projects_ask));
29032925
_project_list->set_horizontal_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED);
29042926
search_panel->add_child(_project_list);
2905-
}
29062927

2907-
{
2908-
// Project tab side bar
2928+
// The side bar with the edit, run, rename, etc. buttons.
29092929
VBoxContainer *tree_vb = memnew(VBoxContainer);
29102930
tree_vb->set_custom_minimum_size(Size2(120, 120));
2911-
local_projects_hb->add_child(tree_vb);
2912-
2913-
create_btn = memnew(Button);
2914-
create_btn->set_text(TTR("New Project"));
2915-
create_btn->set_shortcut(ED_SHORTCUT("project_manager/new_project", TTR("New Project"), KeyModifierMask::CMD_OR_CTRL | Key::N));
2916-
create_btn->connect("pressed", callable_mp(this, &ProjectManager::_new_project));
2917-
tree_vb->add_child(create_btn);
2918-
2919-
import_btn = memnew(Button);
2920-
import_btn->set_text(TTR("Import"));
2921-
import_btn->set_shortcut(ED_SHORTCUT("project_manager/import_project", TTR("Import Project"), KeyModifierMask::CMD_OR_CTRL | Key::I));
2922-
import_btn->connect("pressed", callable_mp(this, &ProjectManager::_import_project));
2923-
tree_vb->add_child(import_btn);
2924-
2925-
scan_btn = memnew(Button);
2926-
scan_btn->set_text(TTR("Scan"));
2927-
scan_btn->set_shortcut(ED_SHORTCUT("project_manager/scan_projects", TTR("Scan Projects"), KeyModifierMask::CMD_OR_CTRL | Key::S));
2928-
scan_btn->connect("pressed", callable_mp(this, &ProjectManager::_scan_projects));
2929-
tree_vb->add_child(scan_btn);
2931+
search_tree_hb->add_child(tree_vb);
29302932

29312933
tree_vb->add_child(memnew(HSeparator));
29322934

‎editor/project_manager.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ class ProjectManager : public Control {
349349
Button *erase_missing_btn = nullptr;
350350
Button *about_btn = nullptr;
351351

352-
HBoxContainer *local_projects_hb = nullptr;
352+
VBoxContainer *local_projects_vb = nullptr;
353353
EditorAssetLibrary *asset_library = nullptr;
354354

355355
Ref<StyleBox> tag_stylebox;

0 commit comments

Comments
 (0)
Please sign in to comment.