Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jmorton06 committed Jul 9, 2021
1 parent d0900fc commit 890a5ac
Show file tree
Hide file tree
Showing 342 changed files with 589 additions and 907 deletions.
103 changes: 71 additions & 32 deletions Editor/Source/AssetWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ namespace Lumos
m_Name = "AssetWindow";
m_SimpleName = "Assets";

//TODO: Get Project path from editor
#ifdef LUMOS_PLATFORM_IOS
m_BaseDirPath = "Assets";
#else
m_BaseDirPath = ROOT_DIR "/Sandbox/Assets";
m_BaseDirPath = ROOT_DIR "/ExampleProject/Assets";
#endif
m_CurrentDirPath = m_BaseDirPath;
m_PreviousDirPath = m_CurrentDirPath;
Expand Down Expand Up @@ -244,34 +245,71 @@ namespace Lumos
int shownIndex = 0;

float xAvail = ImGui::GetContentRegionAvail().x;
m_GridItemsPerRow = (int)floor(xAvail / 70.0f);

m_GridItemsPerRow = (int)floor(xAvail / m_GridSize);
m_GridItemsPerRow = Maths::Max(1, m_GridItemsPerRow);

for(int i = 0; i < m_CurrentDir.size(); i++)
if(m_IsInListView)
{
if(m_CurrentDir.size() > 0)
{
if(!m_ShowHiddenFiles && Lumos::StringUtilities::IsHiddenFile(m_CurrentDir[i].filename))
{
continue;
}

if(m_Filter.IsActive())
{
if(!m_Filter.PassFilter(m_CurrentDir[i].filename.c_str()))
{
continue;
}
}

bool doubleClicked = RenderFile(i, !m_CurrentDir[i].isFile, shownIndex, !m_IsInListView);

if(doubleClicked)
break;
shownIndex++;
}
for(int i = 0; i < m_CurrentDir.size(); i++)
{
if(m_CurrentDir.size() > 0)
{
if(!m_ShowHiddenFiles && Lumos::StringUtilities::IsHiddenFile(m_CurrentDir[i].filename))
{
continue;
}

if(m_Filter.IsActive())
{
if(!m_Filter.PassFilter(m_CurrentDir[i].filename.c_str()))
{
continue;
}
}

bool doubleClicked = RenderFile(i, !m_CurrentDir[i].isFile, shownIndex, !m_IsInListView);

if(doubleClicked)
break;
shownIndex++;
}
}

}
else
{
if (ImGui::BeginTable("assetTable", m_GridItemsPerRow))
{
{
for(int i = 0; i < m_CurrentDir.size(); i++)
{
if(m_CurrentDir.size() > 0)
{
if(!m_ShowHiddenFiles && Lumos::StringUtilities::IsHiddenFile(m_CurrentDir[i].filename))
{
continue;
}

if(m_Filter.IsActive())
{
if(!m_Filter.PassFilter(m_CurrentDir[i].filename.c_str()))
{
continue;
}
}

bool doubleClicked = RenderFile(i, !m_CurrentDir[i].isFile, shownIndex, !m_IsInListView);

if(doubleClicked)
break;
shownIndex++;
}
}
}
ImGui::EndTable();
}
}

ImGui::EndChild();
}
ImGui::EndChild();
Expand Down Expand Up @@ -314,7 +352,7 @@ namespace Lumos
}
ImGui::EndMenuBar();
}

ImGui::End();
}
}
Expand Down Expand Up @@ -433,23 +471,24 @@ namespace Lumos

auto fileID = GetParsedAssetID(m_CurrentDir[dirIndex].fileType);

if(ImGui::Button(folder ? ICON_MDI_FOLDER : m_Editor->GetIconFontIcon(m_CurrentDir[dirIndex].absolutePath), ImVec2(70.0f, 70.0f)))
if(ImGui::Button(folder ? ICON_MDI_FOLDER : m_Editor->GetIconFontIcon(m_CurrentDir[dirIndex].absolutePath), ImVec2(m_GridSize, m_GridSize)))
{
}

if(ImGui::IsMouseDoubleClicked(0))
if(ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))
{
doubleClicked = true;
}

auto& fname = m_CurrentDir[dirIndex].filename;
auto newFname = StripExtras(fname);

ImGui::TextWrapped("%s", newFname.c_str());
ImGui::TextUnformatted(newFname.c_str());
ImGui::EndGroup();

if((shownIndex + 1) % m_GridItemsPerRow != 0)
ImGui::SameLine();

ImGui::TableNextColumn();
// if((shownIndex + 1) % m_GridItemsPerRow != 0)
// ImGui::SameLine();

//ImGui::SameLine();

Expand Down
1 change: 1 addition & 0 deletions Editor/Source/AssetWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ namespace Lumos
bool m_UpdateBreadCrumbs;
bool m_ShowHiddenFiles;
int m_GridItemsPerRow;
float m_GridSize = 128.0f;

ImGuiTextFilter m_Filter;

Expand Down
4 changes: 2 additions & 2 deletions Editor/Source/ConsoleWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Lumos
uint16_t ConsoleWindow::s_MessageBufferCapacity = 200;
uint16_t ConsoleWindow::s_MessageBufferSize = 0;
uint16_t ConsoleWindow::s_MessageBufferBegin = 0;
std::vector<Ref<ConsoleWindow::Message>> ConsoleWindow::s_MessageBuffer = std::vector<Ref<ConsoleWindow::Message>>(200);
std::vector<SharedRef<ConsoleWindow::Message>> ConsoleWindow::s_MessageBuffer = std::vector<SharedRef<ConsoleWindow::Message>>(200);
bool ConsoleWindow::s_AllowScrollingToBottom = true;
bool ConsoleWindow::s_RequestScrollToBottom = false;

Expand All @@ -21,7 +21,7 @@ namespace Lumos
s_MessageBufferRenderFilter = Message::Level::Trace | Message::Level::Info | Message::Level::Debug | Message::Level::Warn | Message::Level::Error | Message::Level::Critical;
}

void ConsoleWindow::AddMessage(const Ref<Message>& message)
void ConsoleWindow::AddMessage(const SharedRef<Message>& message)
{
LUMOS_PROFILE_FUNCTION();
if(message->m_Level == 0)
Expand Down
4 changes: 2 additions & 2 deletions Editor/Source/ConsoleWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace Lumos
static void Flush();
void OnImGui() override;

static void AddMessage(const Ref<Message>& message);
static void AddMessage(const SharedRef<Message>& message);

private:
void ImGuiRenderHeader();
Expand All @@ -58,7 +58,7 @@ namespace Lumos
static uint16_t s_MessageBufferCapacity;
static uint16_t s_MessageBufferSize;
static uint16_t s_MessageBufferBegin;
static std::vector<Ref<Message>> s_MessageBuffer;
static std::vector<SharedRef<Message>> s_MessageBuffer;
static bool s_AllowScrollingToBottom;
static bool s_RequestScrollToBottom;
static uint32_t s_MessageBufferRenderFilter;
Expand Down
Loading

0 comments on commit 890a5ac

Please sign in to comment.