Use ImGui-Addons by gallickgunner as file picker instead

This commit is contained in:
WerWolv
2020-11-17 15:38:24 +01:00
parent a255e062be
commit e40bb5c498
9 changed files with 2509 additions and 744 deletions

View File

@@ -77,11 +77,8 @@ namespace hex {
this->drawGotoPopup();
}
this->m_fileBrowser.Display();
if (this->m_fileBrowser.HasSelected()) {
this->openFile(this->m_fileBrowser.GetSelected().string());
this->m_fileBrowser.ClearSelected();
if (this->m_fileBrowser.showFileDialog("Open File", imgui_addons::ImGuiFileBrowser::DialogMode::OPEN)) {
this->openFile(this->m_fileBrowser.selected_path);
}
}
@@ -128,8 +125,7 @@ namespace hex {
if (ImGui::BeginMenu("File")) {
if (ImGui::MenuItem("Open File...", "CTRL + O")) {
this->m_fileBrowser.SetTitle("Open File");
this->m_fileBrowser.Open();
View::doLater([]{ ImGui::OpenPopup("Open File"); });
}
ImGui::Separator();
@@ -171,8 +167,7 @@ namespace hex {
ImGui::OpenPopup("Goto");
return true;
} else if (mods == GLFW_MOD_CONTROL && key == GLFW_KEY_O) {
this->m_fileBrowser.SetTitle("Open File");
this->m_fileBrowser.Open();
ImGui::OpenPopup("Open File");
return true;
} else if (mods == (GLFW_MOD_CONTROL | GLFW_MOD_ALT) && key == GLFW_KEY_C) {
this->copyBytes();

View File

@@ -22,9 +22,7 @@ namespace hex {
void ViewPattern::createMenu() {
if (ImGui::BeginMenu("File")) {
if (ImGui::MenuItem("Load pattern...")) {
this->m_fileBrowser.SetTitle("Open Hex Pattern");
this->m_fileBrowser.SetTypeFilters({ ".hexpat" });
this->m_fileBrowser.Open();
View::doLater([]{ ImGui::OpenPopup("Open Hex Pattern"); });
}
ImGui::EndMenu();
}
@@ -62,12 +60,9 @@ namespace hex {
}
ImGui::End();
this->m_fileBrowser.Display();
if (this->m_fileBrowser.showFileDialog("Open Hex Pattern", imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, ImVec2(0, 0), ".hexpat")) {
if (this->m_fileBrowser.HasSelected()) {
FILE *file = fopen(this->m_fileBrowser.GetSelected().string().c_str(), "rb");
this->m_fileBrowser.ClearSelected();
FILE *file = fopen(this->m_fileBrowser.selected_path.c_str(), "rb");
if (file != nullptr) {
fseek(file, 0, SEEK_END);