diff options
author | Yuri Sizov <yuris@humnom.net> | 2024-01-30 17:35:46 +0100 |
---|---|---|
committer | Yuri Sizov <yuris@humnom.net> | 2024-01-30 17:52:01 +0100 |
commit | bac037b1e0adc20aa37f2920f586ed9f8ec0e3f0 (patch) | |
tree | 214d9486d2eeda9824a5ce4fc149f553e83ef50a /editor | |
parent | 7496f99060d7655cbf974dba3851838faba629d4 (diff) | |
download | redot-engine-bac037b1e0adc20aa37f2920f586ed9f8ec0e3f0.tar.gz |
Improve the project manager UI
Diffstat (limited to 'editor')
-rw-r--r-- | editor/icons/ProjectList.svg | 1 | ||||
-rw-r--r-- | editor/icons/TitleBarLogo.svg | 1 | ||||
-rw-r--r-- | editor/project_manager.cpp | 300 | ||||
-rw-r--r-- | editor/project_manager.h | 44 |
4 files changed, 220 insertions, 126 deletions
diff --git a/editor/icons/ProjectList.svg b/editor/icons/ProjectList.svg new file mode 100644 index 0000000000..ee72c39c7d --- /dev/null +++ b/editor/icons/ProjectList.svg @@ -0,0 +1 @@ +<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m1 1v14h14v-14zm3 7c1.104 0 2 .896 2 2s-.896 2-2 2-2-.896-2-2 .896-2 2-2zm9 1v2h-6v-2zm-9-7c1.104 0 2 .896 2 2s-.896 2-2 2-2-.896-2-2 .896-2 2-2zm3 1h6v2h-6z" fill="#e0e0e0" fill-rule="nonzero"/></svg> diff --git a/editor/icons/TitleBarLogo.svg b/editor/icons/TitleBarLogo.svg new file mode 100644 index 0000000000..65bb367c61 --- /dev/null +++ b/editor/icons/TitleBarLogo.svg @@ -0,0 +1 @@ +<svg clip-rule="evenodd" fill-rule="evenodd" stroke-linejoin="round" viewBox="0 0 100 24" xmlns="http://www.w3.org/2000/svg"><path d="m40.122 11.514c-1.211-.019-2.597.234-2.597.234v2.364h1.393l-.015 1.052c0 .391-.387.587-1.159.587s-1.454-.328-2.045-.979c-.594-.654-.889-1.609-.889-2.867 0-1.261.288-2.19.865-2.79.577-.599 1.331-.899 2.261-.899.411.003.821.067 1.214.191.42.128.701.247.844.358.142.116.276.17.405.17.127 0 .332-.149.616-.45.286-.299.542-.754.767-1.359.224-.61.337-1.076.337-1.407 0-.328-.007-.555-.023-.674-.314-.345-.895-.618-1.744-.821-.845-.204-1.794-.304-2.844-.304-2.309 0-4.115.728-5.419 2.181-1.305 1.455-1.957 3.344-1.957 5.668 0 2.729.667 4.798 2.001 6.207 1.335 1.41 3.089 2.113 5.263 2.113 1.169 0 2.207-.101 3.114-.303.908-.202 1.511-.409 1.811-.619l.09-7.038c0-.408-1.079-.594-2.289-.615zm11.157-3.284c-.719 0-1.321.33-1.81.989-.487.66-.731 1.585-.731 2.776 0 1.193.232 2.108.698 2.745.465.638 1.075.957 1.832.957s1.372-.323 1.844-.969c.472-.644.709-1.566.709-2.766s-.244-2.122-.731-2.767c-.487-.643-1.091-.965-1.811-.965m-.011 11.85c-2.106 0-3.823-.689-5.15-2.067-1.326-1.38-1.989-3.393-1.989-6.039 0-2.647.67-4.652 2.011-6.017 1.343-1.364 3.074-2.046 5.196-2.046 2.121 0 3.835.67 5.138 2.014 1.306 1.341 1.957 3.374 1.957 6.094 0 2.721-.666 4.745-2.001 6.073-1.335 1.325-3.055 1.988-5.162 1.988m13.502-11.694v6.727c0 .314.023.512.068.595s.18.124.404.124c.826 0 1.451-.308 1.879-.923.428-.614.64-1.637.64-3.069s-.222-2.366-.663-2.799c-.442-.435-1.144-.655-2.103-.655zm-4.317 10.436v-13.492c0-.376.093-.672.282-.891.186-.217.43-.326.73-.326h3.756c2.383 0 4.194.601 5.429 1.801 1.238 1.199 1.857 3.087 1.857 5.666 0 5.517-2.354 8.276-7.063 8.276h-3.845c-.763 0-1.147-.344-1.147-1.034m20.734-10.592c-.72 0-1.325.33-1.812.989-.486.66-.73 1.585-.73 2.776 0 1.193.233 2.108.697 2.745.464.638 1.076.957 1.833.957s1.372-.323 1.844-.969c.472-.644.709-1.566.709-2.766s-.244-2.122-.731-2.767c-.487-.643-1.09-.965-1.81-.965m-.012 11.85c-2.107 0-3.823-.689-5.15-2.067-1.327-1.38-1.99-3.393-1.99-6.039 0-2.647.671-4.652 2.012-6.017 1.343-1.364 3.074-2.046 5.196-2.046s3.834.67 5.138 2.014c1.305 1.341 1.957 3.374 1.957 6.094 0 2.721-.667 4.745-2.002 6.073-1.334 1.325-3.055 1.988-5.161 1.988m15.587-.552c0 .298-.741.449-2.226.449-1.484 0-2.228-.151-2.228-.449v-11.29h-2.698c-.255 0-.434-.345-.539-1.036-.045-.335-.067-.673-.066-1.011 0-.344.021-.682.065-1.012.105-.688.285-1.036.54-1.036h9.783c.255 0 .434.347.541 1.036.089.671.089 1.352 0 2.023-.107.691-.286 1.036-.541 1.036h-2.631z" fill="#fff" fill-rule="nonzero"/><path d="m2.644 9.821v7.76c0 6.683 19.71 6.611 19.71-.072v-7.628c.485-.629.937-1.283 1.356-1.961-.565-.952-1.235-1.824-2.009-2.615-.695.323-1.356.702-1.986 1.138-.646-.597-1.356-1.114-2.131-1.55.113-.823.178-1.647.194-2.47-.952-.451-1.945-.79-2.978-1.017-.42.695-.791 1.413-1.114 2.155-.791-.112-1.582-.112-2.373 0-.323-.742-.694-1.46-1.114-2.155-1.033.227-2.026.566-2.979 1.017.017.824.081 1.647.194 2.47-.775.436-1.485.953-2.131 1.55-.629-.436-1.291-.815-1.985-1.138-.775.791-1.445 1.662-2.01 2.615.42.678.872 1.271 1.356 1.901z" fill="none" stroke="#fff" stroke-width="2"/><g fill="#fff" fill-rule="nonzero"><path d="m2.644 15.838 3.681.339c.193.016.315.129.363.339l.097 1.622 3.196.243.194-1.478c.032-.177.153-.298.363-.363h3.923c.21.064.331.186.363.363l.194 1.478 3.196-.243.097-1.622c.048-.21.169-.323.363-.339l3.68-.339-.024.799-3.244.29-.121 1.671c-.033.162-.146.267-.339.315l-3.923.267c-.194 0-.323-.089-.388-.267l-.242-1.574h-3.147l-.243 1.574c-.064.178-.193.267-.387.267l-3.922-.267c-.194-.048-.307-.153-.34-.315l-.121-1.671-3.269-.29z" stroke="#fff" stroke-linejoin="miter"/><path d="m11.801 13.556-.001-2.082c.073-.824 1.332-.824 1.405 0v2.082c-.072.823-1.332.823-1.404 0zm-4.463-3.735c1.203 0 2.18.976 2.18 2.179s-.977 2.179-2.18 2.179-2.179-.976-2.179-2.179.976-2.179 2.179-2.179zm10.322 0c1.203 0 2.18.976 2.18 2.179s-.977 2.179-2.18 2.179c-1.202 0-2.179-.976-2.179-2.179s.977-2.179 2.179-2.179z"/></g></svg> diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index d18e5a237f..1f2e0839d3 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -52,7 +52,6 @@ #include "editor/themes/editor_scale.h" #include "editor/themes/editor_theme_manager.h" #include "main/main.h" -#include "scene/gui/center_container.h" #include "scene/gui/check_box.h" #include "scene/gui/color_rect.h" #include "scene/gui/flow_container.h" @@ -75,49 +74,60 @@ ProjectManager *ProjectManager::singleton = nullptr; void ProjectManager::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_TRANSLATION_CHANGED: - case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: { - settings_hb->set_anchors_and_offsets_preset(Control::PRESET_TOP_RIGHT); - queue_redraw(); - } break; - case NOTIFICATION_ENTER_TREE: { Engine::get_singleton()->set_editor_hint(false); } break; case NOTIFICATION_THEME_CHANGED: { + const int top_bar_separation = get_theme_constant(SNAME("top_bar_separation"), EditorStringName(Editor)); + root_container->add_theme_constant_override("margin_left", top_bar_separation); + root_container->add_theme_constant_override("margin_top", top_bar_separation); + root_container->add_theme_constant_override("margin_bottom", top_bar_separation); + root_container->add_theme_constant_override("margin_right", top_bar_separation); + main_vbox->add_theme_constant_override("separation", top_bar_separation); + background_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("Background"), EditorStringName(EditorStyles))); - loading_label->add_theme_font_override("font", get_theme_font(SNAME("bold"), EditorStringName(EditorFonts))); - search_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("search_panel"), SNAME("ProjectManager"))); - - // Top bar. - search_box->set_right_icon(get_editor_theme_icon(SNAME("Search"))); - language_btn->set_icon(get_editor_theme_icon(SNAME("Environment"))); - - // Sidebar. - create_btn->set_icon(get_editor_theme_icon(SNAME("Add"))); - import_btn->set_icon(get_editor_theme_icon(SNAME("Load"))); - scan_btn->set_icon(get_editor_theme_icon(SNAME("Search"))); - open_btn->set_icon(get_editor_theme_icon(SNAME("Edit"))); - run_btn->set_icon(get_editor_theme_icon(SNAME("Play"))); - rename_btn->set_icon(get_editor_theme_icon(SNAME("Rename"))); - manage_tags_btn->set_icon(get_editor_theme_icon("Script")); - erase_btn->set_icon(get_editor_theme_icon(SNAME("Remove"))); - erase_missing_btn->set_icon(get_editor_theme_icon(SNAME("Clear"))); - create_tag_btn->set_icon(get_editor_theme_icon("Add")); - - tag_error->add_theme_color_override("font_color", get_theme_color("error_color", EditorStringName(Editor))); - tag_edit_error->add_theme_color_override("font_color", get_theme_color("error_color", EditorStringName(Editor))); - - create_btn->add_theme_constant_override("h_separation", get_theme_constant(SNAME("sidebar_button_icon_separation"), SNAME("ProjectManager"))); - import_btn->add_theme_constant_override("h_separation", get_theme_constant(SNAME("sidebar_button_icon_separation"), SNAME("ProjectManager"))); - scan_btn->add_theme_constant_override("h_separation", get_theme_constant(SNAME("sidebar_button_icon_separation"), SNAME("ProjectManager"))); - open_btn->add_theme_constant_override("h_separation", get_theme_constant(SNAME("sidebar_button_icon_separation"), SNAME("ProjectManager"))); - run_btn->add_theme_constant_override("h_separation", get_theme_constant(SNAME("sidebar_button_icon_separation"), SNAME("ProjectManager"))); - rename_btn->add_theme_constant_override("h_separation", get_theme_constant(SNAME("sidebar_button_icon_separation"), SNAME("ProjectManager"))); - manage_tags_btn->add_theme_constant_override("h_separation", get_theme_constant(SNAME("sidebar_button_icon_separation"), SNAME("ProjectManager"))); - erase_btn->add_theme_constant_override("h_separation", get_theme_constant(SNAME("sidebar_button_icon_separation"), SNAME("ProjectManager"))); - erase_missing_btn->add_theme_constant_override("h_separation", get_theme_constant(SNAME("sidebar_button_icon_separation"), SNAME("ProjectManager"))); + main_view_container->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("TabContainer"))); + + title_bar_logo->set_icon(get_editor_theme_icon(SNAME("TitleBarLogo"))); + + _set_main_view_icon(MAIN_VIEW_PROJECTS, get_editor_theme_icon(SNAME("ProjectList"))); + _set_main_view_icon(MAIN_VIEW_ASSETLIB, get_editor_theme_icon(SNAME("AssetLib"))); + + // Project list. + { + loading_label->add_theme_font_override("font", get_theme_font(SNAME("bold"), EditorStringName(EditorFonts))); + search_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("search_panel"), SNAME("ProjectManager"))); + + // Top bar. + search_box->set_right_icon(get_editor_theme_icon(SNAME("Search"))); + language_btn->set_icon(get_editor_theme_icon(SNAME("Environment"))); + + // Sidebar. + create_btn->set_icon(get_editor_theme_icon(SNAME("Add"))); + import_btn->set_icon(get_editor_theme_icon(SNAME("Load"))); + scan_btn->set_icon(get_editor_theme_icon(SNAME("Search"))); + open_btn->set_icon(get_editor_theme_icon(SNAME("Edit"))); + run_btn->set_icon(get_editor_theme_icon(SNAME("Play"))); + rename_btn->set_icon(get_editor_theme_icon(SNAME("Rename"))); + manage_tags_btn->set_icon(get_editor_theme_icon("Script")); + erase_btn->set_icon(get_editor_theme_icon(SNAME("Remove"))); + erase_missing_btn->set_icon(get_editor_theme_icon(SNAME("Clear"))); + create_tag_btn->set_icon(get_editor_theme_icon("Add")); + + tag_error->add_theme_color_override("font_color", get_theme_color("error_color", EditorStringName(Editor))); + tag_edit_error->add_theme_color_override("font_color", get_theme_color("error_color", EditorStringName(Editor))); + + create_btn->add_theme_constant_override("h_separation", get_theme_constant(SNAME("sidebar_button_icon_separation"), SNAME("ProjectManager"))); + import_btn->add_theme_constant_override("h_separation", get_theme_constant(SNAME("sidebar_button_icon_separation"), SNAME("ProjectManager"))); + scan_btn->add_theme_constant_override("h_separation", get_theme_constant(SNAME("sidebar_button_icon_separation"), SNAME("ProjectManager"))); + open_btn->add_theme_constant_override("h_separation", get_theme_constant(SNAME("sidebar_button_icon_separation"), SNAME("ProjectManager"))); + run_btn->add_theme_constant_override("h_separation", get_theme_constant(SNAME("sidebar_button_icon_separation"), SNAME("ProjectManager"))); + rename_btn->add_theme_constant_override("h_separation", get_theme_constant(SNAME("sidebar_button_icon_separation"), SNAME("ProjectManager"))); + manage_tags_btn->add_theme_constant_override("h_separation", get_theme_constant(SNAME("sidebar_button_icon_separation"), SNAME("ProjectManager"))); + erase_btn->add_theme_constant_override("h_separation", get_theme_constant(SNAME("sidebar_button_icon_separation"), SNAME("ProjectManager"))); + erase_missing_btn->add_theme_constant_override("h_separation", get_theme_constant(SNAME("sidebar_button_icon_separation"), SNAME("ProjectManager"))); + } // Asset library popup. if (asset_library) { @@ -126,23 +136,6 @@ void ProjectManager::_notification(int p_what) { } } break; - case NOTIFICATION_RESIZED: { - if (open_templates && open_templates->is_visible()) { - open_templates->popup_centered(); - } - if (asset_library) { - real_t size = get_size().x / EDSCALE; - // Adjust names of tabs to fit the new size. - if (size < 650) { - local_projects_vb->set_name(TTR("Local")); - asset_library->set_name(TTR("Asset Library")); - } else { - local_projects_vb->set_name(TTR("Local Projects")); - asset_library->set_name(TTR("Asset Library Projects")); - } - } - } break; - case NOTIFICATION_READY: { int default_sorting = (int)EDITOR_GET("project_manager/sorting_order"); filter_option->select(default_sorting); @@ -237,17 +230,68 @@ void ProjectManager::_update_size_limits() { } } -void ProjectManager::_show_about() { - about->popup_centered(Size2(780, 500) * EDSCALE); +Button *ProjectManager::_add_main_view(MainViewTab p_id, const String &p_name, const Ref<Texture2D> &p_icon, Control *p_view_control) { + ERR_FAIL_INDEX_V(p_id, MAIN_VIEW_MAX, nullptr); + ERR_FAIL_COND_V(main_view_map.has(p_id), nullptr); + ERR_FAIL_COND_V(main_view_toggle_map.has(p_id), nullptr); + + Button *toggle_button = memnew(Button); + toggle_button->set_flat(true); + toggle_button->set_theme_type_variation("MainScreenButton"); + toggle_button->set_toggle_mode(true); + toggle_button->set_button_group(main_view_toggles_group); + toggle_button->set_text(p_name); + toggle_button->connect("pressed", callable_mp(this, &ProjectManager::_select_main_view).bind((int)p_id)); + + main_view_toggles->add_child(toggle_button); + main_view_toggle_map[p_id] = toggle_button; + + _set_main_view_icon(p_id, p_icon); + + p_view_control->set_visible(false); + main_view_container->add_child(p_view_control); + main_view_map[p_id] = p_view_control; + + return toggle_button; } -void ProjectManager::_version_button_pressed() { - DisplayServer::get_singleton()->clipboard_set(version_btn->get_text()); +void ProjectManager::_set_main_view_icon(MainViewTab p_id, const Ref<Texture2D> &p_icon) { + ERR_FAIL_INDEX(p_id, MAIN_VIEW_MAX); + ERR_FAIL_COND(!main_view_toggle_map.has(p_id)); + + Button *toggle_button = main_view_toggle_map[p_id]; + + Ref<Texture2D> old_icon = toggle_button->get_icon(); + if (old_icon.is_valid()) { + old_icon->disconnect_changed(callable_mp((Control *)toggle_button, &Control::update_minimum_size)); + } + + if (p_icon.is_valid()) { + toggle_button->set_icon(p_icon); + // Make sure the control is updated if the icon is reimported. + p_icon->connect_changed(callable_mp((Control *)toggle_button, &Control::update_minimum_size)); + } else { + toggle_button->set_icon(Ref<Texture2D>()); + } } -void ProjectManager::_on_tab_changed(int p_tab) { +void ProjectManager::_select_main_view(int p_id) { + MainViewTab view_id = (MainViewTab)p_id; + + ERR_FAIL_INDEX(view_id, MAIN_VIEW_MAX); + ERR_FAIL_COND(!main_view_map.has(view_id)); + ERR_FAIL_COND(!main_view_toggle_map.has(view_id)); + + if (current_main_view != view_id) { + main_view_toggle_map[current_main_view]->set_pressed_no_signal(false); + main_view_map[current_main_view]->set_visible(false); + current_main_view = view_id; + } + main_view_toggle_map[current_main_view]->set_pressed_no_signal(true); + main_view_map[current_main_view]->set_visible(true); + #ifndef ANDROID_ENABLED - if (p_tab == 0) { // Projects + if (current_main_view == MAIN_VIEW_PROJECTS && search_box->is_inside_tree()) { // Automatically grab focus when the user moves from the Templates tab // back to the Projects tab. search_box->grab_focus(); @@ -258,9 +302,13 @@ void ProjectManager::_on_tab_changed(int p_tab) { #endif } +void ProjectManager::_show_about() { + about->popup_centered(Size2(780, 500) * EDSCALE); +} + void ProjectManager::_open_asset_library() { asset_library->disable_community_support(); - tabs->set_current_tab(1); + _select_main_view(MAIN_VIEW_ASSETLIB); } // Quick settings. @@ -292,6 +340,12 @@ void ProjectManager::_dim_window() { set_modulate(dim_color); } +// Footer. + +void ProjectManager::_version_button_pressed() { + DisplayServer::get_singleton()->clipboard_set(version_btn->get_text()); +} + // Project list. void ProjectManager::_scan_projects() { @@ -607,7 +661,7 @@ void ProjectManager::_on_search_term_changed(const String &p_term) { } void ProjectManager::_on_search_term_submitted(const String &p_text) { - if (tabs->get_current_tab() != 0) { + if (current_main_view != MAIN_VIEW_PROJECTS) { return; } @@ -790,7 +844,7 @@ void ProjectManager::shortcut_input(const Ref<InputEvent> &p_ev) { } #endif - if (tabs->get_current_tab() != 0) { + if (current_main_view != MAIN_VIEW_PROJECTS) { return; } @@ -970,51 +1024,44 @@ ProjectManager::ProjectManager() { add_child(background_panel); background_panel->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT); - VBoxContainer *vb = memnew(VBoxContainer); - background_panel->add_child(vb); - vb->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT, Control::PRESET_MODE_MINSIZE, 8 * EDSCALE); + root_container = memnew(MarginContainer); + add_child(root_container); + root_container->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT); - Control *center_box = memnew(Control); - center_box->set_v_size_flags(Control::SIZE_EXPAND_FILL); - vb->add_child(center_box); + main_vbox = memnew(VBoxContainer); + root_container->add_child(main_vbox); - tabs = memnew(TabContainer); - tabs->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT); - center_box->add_child(tabs); - tabs->connect("tab_changed", callable_mp(this, &ProjectManager::_on_tab_changed)); - - // Quick settings. + // Title bar. { - settings_hb = memnew(HBoxContainer); - settings_hb->set_alignment(BoxContainer::ALIGNMENT_END); - settings_hb->set_h_grow_direction(Control::GROW_DIRECTION_BEGIN); - settings_hb->set_anchors_and_offsets_preset(Control::PRESET_TOP_RIGHT); + title_bar = memnew(HBoxContainer); + main_vbox->add_child(title_bar); - // A VBoxContainer that contains a dummy Control node to adjust the LinkButton's vertical position. - VBoxContainer *spacer_vb = memnew(VBoxContainer); - settings_hb->add_child(spacer_vb); + title_bar_logo = memnew(Button); + title_bar_logo->set_flat(true); + title_bar->add_child(title_bar_logo); + title_bar_logo->connect("pressed", callable_mp(this, &ProjectManager::_show_about)); - Control *v_spacer = memnew(Control); - spacer_vb->add_child(v_spacer); + HBoxContainer *left_spacer = memnew(HBoxContainer); + left_spacer->set_mouse_filter(Control::MOUSE_FILTER_PASS); + left_spacer->set_h_size_flags(Control::SIZE_EXPAND_FILL); + title_bar->add_child(left_spacer); - version_btn = memnew(LinkButton); - String hash = String(VERSION_HASH); - if (hash.length() != 0) { - hash = " " + vformat("[%s]", hash.left(9)); - } - version_btn->set_text("v" VERSION_FULL_BUILD + hash); - // Fade the version label to be less prominent, but still readable. - version_btn->set_self_modulate(Color(1, 1, 1, 0.6)); - version_btn->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER); - version_btn->set_tooltip_text(TTR("Click to copy.")); - version_btn->connect("pressed", callable_mp(this, &ProjectManager::_version_button_pressed)); - spacer_vb->add_child(version_btn); + main_view_toggles = memnew(HBoxContainer); + title_bar->add_child(main_view_toggles); - // Add a small horizontal spacer between the version and language buttons - // to distinguish them. - Control *h_spacer = memnew(Control); - settings_hb->add_child(h_spacer); + main_view_toggles_group.instantiate(); + Control *right_spacer = memnew(Control); + right_spacer->set_mouse_filter(Control::MOUSE_FILTER_PASS); + right_spacer->set_h_size_flags(Control::SIZE_EXPAND_FILL); + title_bar->add_child(right_spacer); + + quick_settings_hbox = memnew(HBoxContainer); + title_bar->add_child(quick_settings_hbox); + } + + // Quick settings. + { language_btn = memnew(OptionButton); language_btn->set_focus_mode(Control::FOCUS_NONE); language_btn->set_fit_to_longest_item(false); @@ -1023,7 +1070,6 @@ ProjectManager::ProjectManager() { #ifdef ANDROID_ENABLED // The language selection dropdown doesn't work on Android (as the setting isn't saved), see GH-60353. // Also, the dropdown it spawns is very tall and can't be scrolled without a hardware mouse. - // Hiding the language selection dropdown also leaves more space for the version label to display. language_btn->hide(); #endif @@ -1050,15 +1096,18 @@ ProjectManager::ProjectManager() { } } - settings_hb->add_child(language_btn); - center_box->add_child(settings_hb); + quick_settings_hbox->add_child(language_btn); } + main_view_container = memnew(PanelContainer); + main_view_container->set_v_size_flags(Control::SIZE_EXPAND_FILL); + main_vbox->add_child(main_view_container); + // Project list view. { local_projects_vb = memnew(VBoxContainer); - local_projects_vb->set_name(TTR("Local Projects")); - tabs->add_child(local_projects_vb); + local_projects_vb->set_name("LocalProjectsTab"); + _add_main_view(MAIN_VIEW_PROJECTS, TTR("Projects"), Ref<Texture2D>(), local_projects_vb); // Project list's top bar. { @@ -1178,23 +1227,41 @@ ProjectManager::ProjectManager() { erase_missing_btn->set_text(TTR("Remove Missing")); erase_missing_btn->connect("pressed", callable_mp(this, &ProjectManager::_erase_missing_projects)); tree_vb->add_child(erase_missing_btn); - - tree_vb->add_spacer(); - - about_btn = memnew(Button); - about_btn->set_text(TTR("About")); - about_btn->connect("pressed", callable_mp(this, &ProjectManager::_show_about)); - tree_vb->add_child(about_btn); } } + // Asset library view. if (AssetLibraryEditorPlugin::is_available()) { asset_library = memnew(EditorAssetLibrary(true)); - asset_library->set_name(TTR("Asset Library Projects")); - tabs->add_child(asset_library); + asset_library->set_name("AssetLibraryTab"); + _add_main_view(MAIN_VIEW_ASSETLIB, TTR("Asset Library"), Ref<Texture2D>(), asset_library); asset_library->connect("install_asset", callable_mp(this, &ProjectManager::_install_project)); } else { - print_verbose("Asset Library not available (due to using Web editor, or SSL support disabled)."); + VBoxContainer *asset_library_filler = memnew(VBoxContainer); + asset_library_filler->set_name("AssetLibraryTab"); + Button *asset_library_toggle = _add_main_view(MAIN_VIEW_ASSETLIB, TTR("Asset Library"), Ref<Texture2D>(), asset_library_filler); + asset_library_toggle->set_disabled(true); + asset_library_toggle->set_tooltip_text(TTR("Asset Library not available (due to using Web editor, or because SSL support disabled).")); + } + + // Footer bar. + { + HBoxContainer *footer_bar = memnew(HBoxContainer); + footer_bar->set_alignment(BoxContainer::ALIGNMENT_END); + main_vbox->add_child(footer_bar); + + version_btn = memnew(LinkButton); + String hash = String(VERSION_HASH); + if (hash.length() != 0) { + hash = " " + vformat("[%s]", hash.left(9)); + } + version_btn->set_text("v" VERSION_FULL_BUILD + hash); + // Fade the version label to be less prominent, but still readable. + version_btn->set_self_modulate(Color(1, 1, 1, 0.6)); + version_btn->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER); + version_btn->set_tooltip_text(TTR("Click to copy the version information.")); + version_btn->connect("pressed", callable_mp(this, &ProjectManager::_version_button_pressed)); + footer_bar->add_child(version_btn); } // Dialogs. @@ -1386,6 +1453,7 @@ ProjectManager::ProjectManager() { } _update_size_limits(); + _select_main_view(MAIN_VIEW_PROJECTS); } ProjectManager::~ProjectManager() { diff --git a/editor/project_manager.h b/editor/project_manager.h index 7ed8df8a9d..ffccac1858 100644 --- a/editor/project_manager.h +++ b/editor/project_manager.h @@ -41,11 +41,13 @@ class EditorFileDialog; class HFlowContainer; class LineEdit; class LinkButton; +class MarginContainer; class OptionButton; class PanelContainer; class ProjectDialog; class ProjectList; class TabContainer; +class VBoxContainer; class ProjectManager : public Control { GDCLASS(ProjectManager, Control); @@ -65,21 +67,39 @@ class ProjectManager : public Control { void _update_size_limits(); + MarginContainer *root_container = nullptr; Panel *background_panel = nullptr; - Button *about_btn = nullptr; - LinkButton *version_btn = nullptr; + VBoxContainer *main_vbox = nullptr; - ConfirmationDialog *open_templates = nullptr; - EditorAbout *about = nullptr; + HBoxContainer *title_bar = nullptr; + Button *title_bar_logo = nullptr; + HBoxContainer *main_view_toggles = nullptr; + HBoxContainer *quick_settings_hbox = nullptr; - void _show_about(); - void _version_button_pressed(); + enum MainViewTab { + MAIN_VIEW_PROJECTS, + MAIN_VIEW_ASSETLIB, + MAIN_VIEW_MAX + }; + + MainViewTab current_main_view = MAIN_VIEW_PROJECTS; + HashMap<MainViewTab, Control *> main_view_map; + HashMap<MainViewTab, Button *> main_view_toggle_map; + + PanelContainer *main_view_container = nullptr; + Ref<ButtonGroup> main_view_toggles_group; + + Button *_add_main_view(MainViewTab p_id, const String &p_name, const Ref<Texture2D> &p_icon, Control *p_view_control); + void _set_main_view_icon(MainViewTab p_id, const Ref<Texture2D> &p_icon); + void _select_main_view(int p_id); - TabContainer *tabs = nullptr; VBoxContainer *local_projects_vb = nullptr; EditorAssetLibrary *asset_library = nullptr; - void _on_tab_changed(int p_tab); + ConfirmationDialog *open_templates = nullptr; + EditorAbout *about = nullptr; + + void _show_about(); void _open_asset_library(); // Quick settings. @@ -91,6 +111,12 @@ class ProjectManager : public Control { void _restart_confirm(); void _dim_window(); + // Footer. + + LinkButton *version_btn = nullptr; + + void _version_button_pressed(); + // Project list. ProjectList *_project_list = nullptr; @@ -121,8 +147,6 @@ class ProjectManager : public Control { ConfirmationDialog *multi_open_ask = nullptr; ConfirmationDialog *multi_run_ask = nullptr; - HBoxContainer *settings_hb = nullptr; - AcceptDialog *run_error_diag = nullptr; AcceptDialog *dialog_error = nullptr; ProjectDialog *npdialog = nullptr; |