mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2026-04-18 22:32:44 +00:00
removed scrolling due to bug + Fixed file source
This commit is contained in:
@@ -3,14 +3,14 @@
|
||||
#include <options.h>
|
||||
#include <filesystem>
|
||||
|
||||
FileSelect::FileSelect(std::string defaultPath, char* filter) {
|
||||
FileSelect::FileSelect(std::string defaultPath) {
|
||||
path = defaultPath;
|
||||
strcpy(_filter, filter);
|
||||
pathValid = std::filesystem::is_regular_file(path);
|
||||
strcpy(strPath, path.c_str());
|
||||
}
|
||||
|
||||
void FileSelect::render(std::string id) {
|
||||
bool FileSelect::render(std::string id) {
|
||||
bool _pathChanged = false;
|
||||
#ifdef _WIN32
|
||||
float menuColumnWidth = ImGui::GetContentRegionAvailWidth();
|
||||
float buttonWidth = ImGui::CalcTextSize("...").x + 20.0f;
|
||||
@@ -59,6 +59,15 @@ void FileSelect::render(std::string id) {
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
#endif
|
||||
_pathChanged |= pathChanged;
|
||||
pathChanged = false;
|
||||
return _pathChanged;
|
||||
}
|
||||
|
||||
void FileSelect::setPath(std::string path) {
|
||||
this->path = path;
|
||||
pathValid = std::filesystem::is_regular_file(path);
|
||||
strcpy(strPath, path.c_str());
|
||||
}
|
||||
|
||||
std::string FileSelect::expandString(std::string input) {
|
||||
@@ -70,45 +79,35 @@ bool FileSelect::pathIsValid() {
|
||||
return pathValid;
|
||||
}
|
||||
|
||||
bool FileSelect::pathChanged() {
|
||||
if (_pathChanged) {
|
||||
_pathChanged = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
#ifdef _WIN32
|
||||
|
||||
void FileSelect::setWindowsFilter(COMDLG_FILTERSPEC* filt, int n) {
|
||||
filter = filt;
|
||||
filterCount = n;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
void FileSelect::windowsWorker() {
|
||||
OPENFILENAMEA ofn; // common dialog box structure
|
||||
char szFile[2048]; // buffer for file name
|
||||
HWND hwnd; // owner window
|
||||
HANDLE hf; // file handle
|
||||
IFileOpenDialog *pFileOpen;
|
||||
HRESULT hr;
|
||||
|
||||
// Initialize OPENFILENAME
|
||||
ZeroMemory(&ofn, sizeof(ofn));
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = GetFocus();
|
||||
ofn.lpstrFile = (LPSTR)szFile;
|
||||
// Set lpstrFile[0] to '\0' so that GetOpenFileName does not
|
||||
// use the contents of szFile to initialize itself.
|
||||
ofn.lpstrFile[0] = '\0';
|
||||
ofn.nMaxFile = sizeof(szFile);
|
||||
ofn.lpstrFilter = (LPCSTR)_filter;
|
||||
ofn.nFilterIndex = 1;
|
||||
ofn.lpstrFileTitle = NULL;
|
||||
ofn.nMaxFileTitle = 0;
|
||||
ofn.lpstrInitialDir = NULL;
|
||||
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_EXTENSIONDIFFERENT;
|
||||
// Create the FileOpenDialog object.
|
||||
hr = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_ALL, IID_IFileOpenDialog, reinterpret_cast<void**>(&pFileOpen));
|
||||
|
||||
if (filter != NULL) { pFileOpen->SetFileTypes(filterCount, filter); }
|
||||
|
||||
// Display the Open dialog box.
|
||||
|
||||
if (GetOpenFileNameA(&ofn)==TRUE) {
|
||||
strcpy(strPath, szFile);
|
||||
_pathChanged = true;
|
||||
hr = pFileOpen->Show(NULL);
|
||||
if (SUCCEEDED(hr)) {
|
||||
PWSTR pszFilePath;
|
||||
IShellItem *pItem;
|
||||
hr = pFileOpen->GetResult(&pItem);
|
||||
hr = pItem->GetDisplayName(SIGDN_FILESYSPATH, &pszFilePath);
|
||||
wcstombs(strPath, pszFilePath, 2048);
|
||||
CoTaskMemFree(pszFilePath);
|
||||
path = std::string(strPath);
|
||||
pathChanged = true;
|
||||
}
|
||||
|
||||
pathValid = std::filesystem::is_regular_file(strPath);
|
||||
pathValid = std::filesystem::is_regular_file(path);
|
||||
dialogOpen = false;
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user