From 40f61f4775481140a731cc9e08d6a5ca3d6f44d7 Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Thu, 20 Jul 2023 22:03:04 -0400 Subject: [PATCH 1/5] Fix scene scripting api mismatch signatures --- Editor/resources/Scripts/Scene.wren | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Editor/resources/Scripts/Scene.wren b/Editor/resources/Scripts/Scene.wren index 1464c3c3..a5f0eb65 100644 --- a/Editor/resources/Scripts/Scene.wren +++ b/Editor/resources/Scripts/Scene.wren @@ -4,7 +4,7 @@ import "Nuake:Math" for Vector3 class Scene { foreign static GetEntityID(name) - foreign static AddEntity(name) + foreign static CreateEntity(name) foreign static AddPrefab(prefabPath) static GetEntity(name) { From ed8998301abdb2de9ae35e000a4e39d25d706552 Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Thu, 20 Jul 2023 22:17:54 -0400 Subject: [PATCH 2/5] Removed hide bar button --- Nuake/src/Window.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Nuake/src/Window.cpp b/Nuake/src/Window.cpp index 29b92506..2a3f2e5b 100644 --- a/Nuake/src/Window.cpp +++ b/Nuake/src/Window.cpp @@ -236,6 +236,7 @@ namespace Nuake ImGui::StyleColorsDark(); ImGuiStyle& s = ImGui::GetStyle(); + s.WindowMenuButtonPosition = ImGuiDir_None; s.FrameRounding = 2.0f; s.GrabRounding = 2.0f; s.CellPadding = ImVec2(8, 8); From 14ff25809407ca748abc17c1512fab2d790abf58 Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Fri, 21 Jul 2023 00:11:49 -0400 Subject: [PATCH 3/5] Updated style for file browser --- Editor/src/Windows/FileSystemUI.cpp | 78 +++++++++++++++++++++++++---- Nuake/src/Window.cpp | 7 ++- 2 files changed, 72 insertions(+), 13 deletions(-) diff --git a/Editor/src/Windows/FileSystemUI.cpp b/Editor/src/Windows/FileSystemUI.cpp index 1a07bf03..7a43c250 100644 --- a/Editor/src/Windows/FileSystemUI.cpp +++ b/Editor/src/Windows/FileSystemUI.cpp @@ -61,16 +61,16 @@ namespace Nuake void FileSystemUI::EditorInterfaceDrawFiletree(Ref dir) { - ImGuiTreeNodeFlags base_flags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_SpanAvailWidth; + ImGuiTreeNodeFlags base_flags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_FramePadding; //if (is_selected) - std::string icon = ICON_FA_FOLDER; if (m_CurrentDirectory == dir) base_flags |= ImGuiTreeNodeFlags_Selected; if (dir->Directories.size() <= 0) - base_flags = ImGuiTreeNodeFlags_Leaf; + base_flags |= ImGuiTreeNodeFlags_Leaf; - bool open = ImGui::TreeNodeEx(dir->name.c_str(), base_flags); + std::string icon = ICON_FA_FOLDER; + bool open = ImGui::TreeNodeEx((icon + " " + dir->name.c_str()).c_str(), base_flags); if (ImGui::IsItemClicked()) m_CurrentDirectory = dir; @@ -324,16 +324,19 @@ namespace Nuake ImVec2 avail = ImGui::GetContentRegionAvail(); Splitter(true, 4.0f, &sz1, &sz2, 100, 8, avail.y); - if (ImGui::BeginChild("Tree browser", ImVec2(sz1, avail.y))) + ImVec4* colors = ImGui::GetStyle().Colors; + ImGui::PushStyleColor(ImGuiCol_ChildBg, colors[ImGuiCol_TitleBgCollapsed]); + ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 8); + if (ImGui::BeginChild("Tree browser", ImVec2(sz1, avail.y), true)) { - ImGuiTreeNodeFlags base_flags = ImGuiTreeNodeFlags_SpanAvailWidth | ImGuiTreeNodeFlags_DefaultOpen; + ImGuiTreeNodeFlags base_flags = ImGuiTreeNodeFlags_SpanAvailWidth | ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_FramePadding; bool is_selected = m_CurrentDirectory == FileSystem::RootDirectory; if (is_selected) base_flags |= ImGuiTreeNodeFlags_Selected; std::string icon = ICON_FA_FOLDER; - bool open = ImGui::TreeNodeEx((icon + " " + "Project files").c_str(), base_flags); + bool open = ImGui::TreeNodeEx((icon + " Project files").c_str(), base_flags); if (ImGui::IsItemClicked()) { m_CurrentDirectory = FileSystem::RootDirectory; @@ -348,6 +351,8 @@ namespace Nuake } } + ImGui::PopStyleVar(); + ImGui::PopStyleColor(); ImGui::EndChild(); ImGui::SameLine(); @@ -368,31 +373,82 @@ namespace Nuake if (ImGui::BeginChild("Wrapper", avail)) { avail.y = 30; - if (ImGui::BeginChild("Path", avail)) + if (ImGui::BeginChild("Path", avail, true)) { - if (ImGui::Button("Refresh")) + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); + + const auto buttonSize = ImVec2(24, 24); + std::string refreshIcon = ICON_FA_SYNC_ALT; + if (ImGui::Button((refreshIcon).c_str(), buttonSize)) { RefreshFileBrowser(); } ImGui::SameLine(); + + if (ImGui::Button((std::string(ICON_FA_ANGLE_LEFT)).c_str(), buttonSize)) + { + if (m_CurrentDirectory != FileSystem::RootDirectory) + { + m_CurrentDirectory = m_CurrentDirectory->Parent; + } + } + + ImGui::SameLine(); + + if (ImGui::Button((std::string(ICON_FA_ANGLE_RIGHT)).c_str(), buttonSize)) + { + + } + + ImGui::SameLine(); + + ImGui::PushStyleColor(ImGuiCol_ChildBg, colors[ImGuiCol_TitleBgCollapsed]); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4, 4)); + ImGui::BeginChild("pathBrowser", ImVec2(ImGui::GetContentRegionAvailWidth(), 24)); for (int i = paths.size() - 1; i > 0; i--) { if (i != paths.size()) ImGui::SameLine(); - if (ImGui::Button(paths[i]->name.c_str())) + std::string pathLabel; + if (i == paths.size() - 1) + { + pathLabel = "Project files"; + } + else + { + pathLabel = paths[i]->name; + } + + if (ImGui::Button(pathLabel.c_str())) + { m_CurrentDirectory = paths[i]; + } ImGui::SameLine(); ImGui::Text("/"); } + + ImGui::EndChild(); + ImGui::PopStyleVar(); + ImGui::PopStyleVar(); + ImGui::PopStyleColor(); + ImGui::PopStyleColor(); } + ImGui::EndChild(); + ImDrawList* drawList = ImGui::GetWindowDrawList(); + ImGui::GetWindowDrawList()->AddLine(ImVec2(ImGui::GetCursorPosX(), ImGui::GetCursorPosY()), ImVec2(ImGui::GetContentRegionAvailWidth(), ImGui::GetCursorPosY()), IM_COL32(255, 0, 0, 255), 1.0f); + + ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(0, 0)); avail = ImGui::GetContentRegionAvail(); - if (ImGui::BeginChild("Content", avail)) + bool child = ImGui::BeginChild("Content", avail); + ImGui::PopStyleVar(); + if (child) { int width = avail.x; ImVec2 buttonSize = ImVec2(80, 80); diff --git a/Nuake/src/Window.cpp b/Nuake/src/Window.cpp index 2a3f2e5b..62ce9665 100644 --- a/Nuake/src/Window.cpp +++ b/Nuake/src/Window.cpp @@ -240,8 +240,10 @@ namespace Nuake s.FrameRounding = 2.0f; s.GrabRounding = 2.0f; s.CellPadding = ImVec2(8, 8); - s.WindowPadding = ImVec2(8, 8); + s.WindowPadding = ImVec2(2, 2); s.ScrollbarRounding = 9.0f; + s.ScrollbarSize = 15.0f; + s.GrabMinSize = 32.0f; s.TabRounding = 0; s.WindowRounding = 0; s.ChildRounding = 0; @@ -252,6 +254,7 @@ namespace Nuake s.ItemInnerSpacing = ImVec2(4, 4); s.TabRounding = 4.0f; s.WindowBorderSize = 0.0f; + s.IndentSpacing = 12.0f; s.ChildBorderSize = 0.0f; ImVec4* colors = ImGui::GetStyle().Colors; @@ -269,7 +272,7 @@ namespace Nuake colors[ImGuiCol_TitleBgActive] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f); colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f); colors[ImGuiCol_MenuBarBg] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f); - colors[ImGuiCol_ScrollbarBg] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f); + colors[ImGuiCol_ScrollbarBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.00f); colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.34f, 0.34f, 0.34f, 1.00f); colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.29f, 0.29f, 0.29f, 1.00f); colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.16f, 0.16f, 0.16f, 1.00f); From c748b9a21836da67fdc2086a02849c939609054a Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Fri, 21 Jul 2023 00:18:01 -0400 Subject: [PATCH 4/5] Using font manager for folder icons --- Editor/src/Windows/FileSystemUI.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Editor/src/Windows/FileSystemUI.cpp b/Editor/src/Windows/FileSystemUI.cpp index 7a43c250..eb059fc1 100644 --- a/Editor/src/Windows/FileSystemUI.cpp +++ b/Editor/src/Windows/FileSystemUI.cpp @@ -86,7 +86,7 @@ namespace Nuake void FileSystemUI::DrawDirectory(Ref directory) { - ImGui::PushFont(EditorInterface::bigIconFont); + ImGui::PushFont(FontManager::GetFont(Icons)); const char* icon = ICON_FA_FOLDER; const std::string id = ICON_FA_FOLDER + std::string("##") + directory->name; if (ImGui::Button(id.c_str(), ImVec2(100, 100))) From 46a531fd7d6a29bbae32c8f8a4f5108d67b73c1b Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Fri, 21 Jul 2023 15:31:52 -0400 Subject: [PATCH 5/5] Better filesystem ui --- Editor/src/Windows/FileSystemUI.cpp | 33 +++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/Editor/src/Windows/FileSystemUI.cpp b/Editor/src/Windows/FileSystemUI.cpp index eb059fc1..d75531c3 100644 --- a/Editor/src/Windows/FileSystemUI.cpp +++ b/Editor/src/Windows/FileSystemUI.cpp @@ -44,8 +44,6 @@ const std::string TEMPLATE_SCRIPT_SECOND = R"( is ScriptableEntity { namespace Nuake { - - // TODO: add filetree in same panel void FileSystemUI::Draw() { @@ -336,11 +334,13 @@ namespace Nuake base_flags |= ImGuiTreeNodeFlags_Selected; std::string icon = ICON_FA_FOLDER; - bool open = ImGui::TreeNodeEx((icon + " Project files").c_str(), base_flags); + ImGui::PushFont(FontManager::GetFont(Bold)); + bool open = ImGui::TreeNodeEx("PROJECT", base_flags); if (ImGui::IsItemClicked()) { m_CurrentDirectory = FileSystem::RootDirectory; } + ImGui::PopFont(); if (open) { @@ -377,7 +377,7 @@ namespace Nuake { ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); - const auto buttonSize = ImVec2(24, 24); + const auto buttonSize = ImVec2(26, 26); std::string refreshIcon = ICON_FA_SYNC_ALT; if (ImGui::Button((refreshIcon).c_str(), buttonSize)) { @@ -386,6 +386,7 @@ namespace Nuake ImGui::SameLine(); + const auto cursorStart = ImGui::GetCursorPosX(); if (ImGui::Button((std::string(ICON_FA_ANGLE_LEFT)).c_str(), buttonSize)) { if (m_CurrentDirectory != FileSystem::RootDirectory) @@ -396,17 +397,20 @@ namespace Nuake ImGui::SameLine(); + const auto cursorEnd = ImGui::GetCursorPosX(); + const auto buttonWidth = cursorEnd - cursorStart; if (ImGui::Button((std::string(ICON_FA_ANGLE_RIGHT)).c_str(), buttonSize)) { - + // TODO } + const uint32_t numButtonAfterPathBrowser = 2; ImGui::SameLine(); ImGui::PushStyleColor(ImGuiCol_ChildBg, colors[ImGuiCol_TitleBgCollapsed]); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4, 4)); - ImGui::BeginChild("pathBrowser", ImVec2(ImGui::GetContentRegionAvailWidth(), 24)); + ImGui::BeginChild("pathBrowser", ImVec2(ImGui::GetContentRegionAvailWidth() - (numButtonAfterPathBrowser * buttonWidth) - 4.0, 24)); for (int i = paths.size() - 1; i > 0; i--) { if (i != paths.size()) @@ -435,7 +439,22 @@ namespace Nuake ImGui::PopStyleVar(); ImGui::PopStyleVar(); ImGui::PopStyleColor(); - ImGui::PopStyleColor(); + + ImGui::SameLine(); + + if (ImGui::Button((std::string(ICON_FA_FOLDER_OPEN)).c_str(), buttonSize)) + { + OS::ShowInFileExplorer(m_CurrentDirectory->fullPath); + } + + ImGui::SameLine(); + + if (ImGui::Button((std::string(ICON_FA_ELLIPSIS_V)).c_str(), buttonSize)) + { + // TODO + } + + ImGui::PopStyleColor(); // Button color } ImGui::EndChild();