Skip to content

Commit

Permalink
Adding some folder icons
Browse files Browse the repository at this point in the history
Added folder icons, running into the texture problem with ImGui. Need to figure out how to avoid that.
Probably need to delete decriptor sets somehow or something
  • Loading branch information
tomheeleynz committed Sep 4, 2022
1 parent f4b8db5 commit fdbd0e6
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 3 deletions.
11 changes: 11 additions & 0 deletions Arcane/src/Arcane/ImGui/PlatformImGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ namespace Arcane::UI
ImGui::Image((ImTextureID)ImGui_ImplVulkan_AddTexture(textureInfo.sampler, textureInfo.imageView, textureInfo.imageLayout), ImVec2{ 512, 512 });
}

bool ImageButton(ImTextureID id, ImVec2 size)
{
return ImGui::ImageButton(id, size);
}

bool ImageButton(Texture* texture, ImVec2 size)
{
ImTextureID id = AddTexture(texture);
return ImGui::ImageButton(id, size);
}

ImTextureID AddTexture(Texture* texture)
{
VulkanTexture* vulkanTexture = static_cast<VulkanTexture*>(texture);
Expand Down
13 changes: 12 additions & 1 deletion Arcane/src/Arcane/ImGui/PlatformImGui.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,20 @@

namespace Arcane::UI
{
//////////////////////////////////////////
/// Images
//////////////////////////////////////////
void Image(ImTextureID id, ImVec2 size);
void Image(Texture* texture);


//////////////////////////////////////////
/// Image Buttons
//////////////////////////////////////////
bool ImageButton(ImTextureID id, ImVec2 size);
bool ImageButton(Texture* texture, ImVec2 size);



ImTextureID AddTexture(Texture* texture);
ImTextureID AddTexture(Framebuffer* frameBuffer);
}
Binary file added EnchantingTable/src/Icons/folder_icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 14 additions & 1 deletion EnchantingTable/src/Panels/FileBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
FileBrowserPanel::FileBrowserPanel()
{
m_Watcher = new Arcane::FileWatcher("./src/Assets", std::chrono::milliseconds(5000));
m_Icons["Folder"] = Arcane::Texture::Create("./src/Icons/folder_icon.png");
}

void FileBrowserPanel::OnUpdate()
Expand All @@ -25,11 +26,23 @@ void FileBrowserPanel::OnUpdate()
}
}
else {
if (ImGui::Button(path.first.c_str())) {

ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.0f, 0.0f, 0.0f, 0.0f));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(1.0f, 1.0f, 1.0f, 0.3f));

if (Arcane::UI::ImageButton(m_Icons["Folder"], {50, 50})) {
m_Watcher->SetDirectory(path.second.relativePath);
}

ImGui::PopStyleColor(2);
ImGui::Text(path.second.relativePath.stem().string().c_str());
}
}
}
ImGui::End();
}

std::string FileBrowserPanel::GetIconType(std::string extension)
{
return std::string();
}
6 changes: 5 additions & 1 deletion EnchantingTable/src/Panels/FileBrowser.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once
#include <Arcane.h>
#include <imgui.h>
#include <string>

class FileBrowserPanel
{
Expand All @@ -9,6 +10,9 @@ class FileBrowserPanel

void OnUpdate();
private:
Arcane::FileWatcher* m_Watcher;
std::string GetIconType(std::string extension);

private:
Arcane::FileWatcher* m_Watcher;
std::map<std::string, Arcane::Texture*> m_Icons;
};

0 comments on commit fdbd0e6

Please sign in to comment.