mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-15 20:08:54 +03:00
Better UI and some optimizations
This commit is contained in:
@@ -141,7 +141,7 @@ void GizmoDrawer::DrawGizmos(Ref<Scene> scene)
|
||||
Nuake::RenderCommand::DrawLines(0, 6);
|
||||
}
|
||||
|
||||
glLineWidth(2.0f);
|
||||
glLineWidth(1.0f);
|
||||
auto boxColliderView = scene->m_Registry.view<TransformComponent, BoxColliderComponent>();
|
||||
for (auto e : boxColliderView)
|
||||
{
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace Nuake {
|
||||
framebuffer->QueueResize(viewportPanelSize);
|
||||
|
||||
Ref<Texture> texture = framebuffer->GetTexture();
|
||||
ImVec2 imagePos = ImGui::GetCursorPos();
|
||||
ImVec2 imagePos = ImGui::GetWindowPos() + ImGui::GetCursorPos();
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
|
||||
m_ViewportPos = { imagePos.x, imagePos.y };
|
||||
@@ -173,7 +173,7 @@ namespace Nuake {
|
||||
|
||||
ImGuizmo::SetDrawlist();
|
||||
ImGuizmo::AllowAxisFlip(true);
|
||||
ImGuizmo::SetRect(imagePos.x + 8.0, imagePos.y + 30.0, viewportPanelSize.x, viewportPanelSize.y);
|
||||
ImGuizmo::SetRect(imagePos.x, imagePos.y + 0.0f, viewportPanelSize.x, viewportPanelSize.y);
|
||||
|
||||
if (m_DrawGrid && !Engine::IsPlayMode())
|
||||
{
|
||||
@@ -298,23 +298,7 @@ namespace Nuake {
|
||||
if (Selection.Type == EditorSelectionType::Entity && Selection.Entity == e)
|
||||
base_flags |= ImGuiTreeNodeFlags_Selected;
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2{ 0.0f, 0.0f });
|
||||
{
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
bool& isVisible = e.GetComponent<VisibilityComponent>().Visible;
|
||||
char* visibilityIcon = isVisible ? ICON_FA_EYE : ICON_FA_EYE_SLASH;
|
||||
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, { 0, 0, 0, 0 });
|
||||
if (ImGui::Button(visibilityIcon, { 40, 40 }))
|
||||
{
|
||||
isVisible = !isVisible;
|
||||
}
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
@@ -428,6 +412,23 @@ namespace Nuake {
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2{ 0.0f, 0.0f });
|
||||
{
|
||||
bool& isVisible = e.GetComponent<VisibilityComponent>().Visible;
|
||||
char* visibilityIcon = isVisible ? ICON_FA_EYE : ICON_FA_EYE_SLASH;
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, { 0, 0, 0, 0 });
|
||||
if (ImGui::Button(visibilityIcon, { 40, 40 }))
|
||||
{
|
||||
isVisible = !isVisible;
|
||||
}
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
if (open)
|
||||
{
|
||||
// Caching list to prevent deletion while iterating.
|
||||
@@ -1041,9 +1042,9 @@ namespace Nuake {
|
||||
{
|
||||
if (ImGui::BeginTable("entity_table", 2, ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_NoBordersInBody | ImGuiTableFlags_SizingStretchProp))
|
||||
{
|
||||
ImGui::TableSetupColumn("Label", ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_IndentEnable);
|
||||
std::string icon = ICON_FA_EYE;
|
||||
ImGui::TableSetupColumn((" " + icon).c_str(), ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_IndentDisable | ImGuiTableColumnFlags_WidthFixed, 32);
|
||||
ImGui::TableSetupColumn("Label", ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_IndentEnable);
|
||||
ImGui::TableHeadersRow();
|
||||
ImGui::TableNextRow();
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace Nuake
|
||||
if (ImGui::IsItemHovered() && ImGui::IsMouseReleased(1))
|
||||
{
|
||||
ImGui::OpenPopup(hoverMenuId.c_str());
|
||||
m_hasClickedOnFile = true;
|
||||
m_HasClickedOnFile = true;
|
||||
}
|
||||
|
||||
const std::string renameId = "Rename" + std::string("##") + hoverMenuId;
|
||||
@@ -252,7 +252,7 @@ namespace Nuake
|
||||
if (ImGui::IsItemHovered() && ImGui::IsMouseReleased(1))
|
||||
{
|
||||
ImGui::OpenPopup(hoverMenuId.c_str());
|
||||
m_hasClickedOnFile = true;
|
||||
m_HasClickedOnFile = true;
|
||||
}
|
||||
|
||||
const std::string openSceneId = "Open Scene" + std::string("##") + hoverMenuId;
|
||||
@@ -414,7 +414,7 @@ namespace Nuake
|
||||
|
||||
void FileSystemUI::DrawContextMenu()
|
||||
{
|
||||
if (!m_hasClickedOnFile && ImGui::IsMouseReleased(1) && ImGui::IsWindowHovered())
|
||||
if (!m_HasClickedOnFile && ImGui::IsMouseReleased(1) && ImGui::IsWindowHovered())
|
||||
{
|
||||
ImGui::OpenPopup("window_hover_menu");
|
||||
}
|
||||
@@ -634,10 +634,10 @@ namespace Nuake
|
||||
ImGui::BeginChild("searchBar", ImVec2(ImGui::GetContentRegionAvail().x - (numButtonAfterPathBrowser * buttonWidth), 24));
|
||||
char buffer[256];
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
std::strncpy(buffer, m_searchKeyWord.c_str(), sizeof(buffer));
|
||||
std::strncpy(buffer, m_SearchKeyword.c_str(), sizeof(buffer));
|
||||
if (ImGui::InputTextEx("##Search", "Asset search & filter ..", buffer, sizeof(buffer), ImVec2(ImGui::GetContentRegionAvail().x, 24), ImGuiInputTextFlags_EscapeClearsAll))
|
||||
{
|
||||
m_searchKeyWord = std::string(buffer);
|
||||
m_SearchKeyword = std::string(buffer);
|
||||
}
|
||||
ImGui::EndChild();
|
||||
|
||||
@@ -692,7 +692,7 @@ namespace Nuake
|
||||
{
|
||||
for (Ref<Directory>& d : m_CurrentDirectory->Directories)
|
||||
{
|
||||
if(String::Sanitize(d->name).find(String::Sanitize(m_searchKeyWord)) != std::string::npos)
|
||||
if(String::Sanitize(d->name).find(String::Sanitize(m_SearchKeyword)) != std::string::npos)
|
||||
{
|
||||
if (i + 1 % amount != 0)
|
||||
ImGui::TableNextColumn();
|
||||
@@ -707,14 +707,18 @@ namespace Nuake
|
||||
|
||||
if (m_CurrentDirectory && m_CurrentDirectory->Files.size() > 0)
|
||||
{
|
||||
for (auto f : m_CurrentDirectory->Files)
|
||||
for (auto& f : m_CurrentDirectory->Files)
|
||||
{
|
||||
if(String::Sanitize(f->GetName()).find(String::Sanitize(m_searchKeyWord)) != std::string::npos)
|
||||
if(m_SearchKeyword.empty() || f->GetName().find(String::Sanitize(m_SearchKeyword)) != std::string::npos)
|
||||
{
|
||||
if (i - 1 % amount != 0 || i == 1)
|
||||
{
|
||||
ImGui::TableNextColumn();
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
}
|
||||
|
||||
DrawFile(f, i);
|
||||
i++;
|
||||
@@ -723,7 +727,7 @@ namespace Nuake
|
||||
}
|
||||
|
||||
DrawContextMenu();
|
||||
m_hasClickedOnFile = false;
|
||||
m_HasClickedOnFile = false;
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
@@ -11,13 +11,13 @@ namespace Nuake {
|
||||
|
||||
public:
|
||||
static Ref<Directory> m_CurrentDirectory;
|
||||
bool m_hasClickedOnFile;
|
||||
std::string m_searchKeyWord;
|
||||
bool m_HasClickedOnFile;
|
||||
std::string m_SearchKeyword;
|
||||
|
||||
FileSystemUI(EditorInterface* editor)
|
||||
{
|
||||
m_CurrentDirectory = FileSystem::RootDirectory;
|
||||
m_hasClickedOnFile = false;
|
||||
m_HasClickedOnFile = false;
|
||||
Editor = editor;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user