diff --git a/PanoPainter.vcxproj b/PanoPainter.vcxproj
index 89913b0..b96e741 100644
--- a/PanoPainter.vcxproj
+++ b/PanoPainter.vcxproj
@@ -202,6 +202,7 @@
+
@@ -320,6 +321,7 @@
+
diff --git a/PanoPainter.vcxproj.filters b/PanoPainter.vcxproj.filters
index bb3dd31..44b9b38 100644
--- a/PanoPainter.vcxproj.filters
+++ b/PanoPainter.vcxproj.filters
@@ -261,6 +261,9 @@
Source Files\ui
+
+ Source Files\ui
+
@@ -467,6 +470,9 @@
Header Files\ui
+
+ Header Files\ui
+
diff --git a/data/layout.xml b/data/layout.xml
index 1132bd1..e1bf680 100644
--- a/data/layout.xml
+++ b/data/layout.xml
@@ -400,7 +400,7 @@
-
+
@@ -539,7 +539,7 @@
-
+
diff --git a/src/app_events.cpp b/src/app_events.cpp
index 58546d7..827ae07 100644
--- a/src/app_events.cpp
+++ b/src/app_events.cpp
@@ -5,7 +5,8 @@
void displayKeyboard(android_app* mApplication, bool pShow);
void pick_file(android_app* mApplication, std::function callback);
#elif _WIN32
-std::string win32_open_file();
+std::string win32_open_file(const char* filter);
+std::string win32_open_dir();
#endif
@@ -59,7 +60,7 @@ void App::pick_image(std::function callback)
#elif __ANDROID__
pick_file(and_app, callback);
#elif _WIN32
- std::string path = win32_open_file();
+ std::string path = win32_open_file("Image Files (*.jpg, *.png)\0*.jpg;*.png");
if (!path.empty())
callback(path);
#endif
@@ -84,7 +85,21 @@ void App::pick_file(std::vector types, std::function callback)
// NOT IMPLEMENTED
#elif _WIN32
// TODO: to be implemented
-// std::string path = win32_open_file();
-// if (!path.empty())
-// callback(path);
+ std::string path = win32_open_dir();
+ if (!path.empty())
+ callback(path);
#endif
}
diff --git a/src/main.cpp b/src/main.cpp
index ad3cad3..9a97d1e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -107,14 +107,14 @@ void async_unlock()
}
}
-std::string win32_open_file()
+std::string win32_open_file(const char* filter)
{
OPENFILENAMEA ofn;
char fileName[MAX_PATH] = "";
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hWnd;
- ofn.lpstrFilter = "Image Files (*.jpg, *.png)\0*.jpg;*.png";
+ ofn.lpstrFilter = filter;
ofn.lpstrFile = fileName;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
@@ -127,6 +127,22 @@ std::string win32_open_file()
return "";
}
+std::string win32_open_dir()
+{
+ BROWSEINFOA bi;
+ char Buffer[MAX_PATH];
+ ZeroMemory(Buffer, MAX_PATH);
+ ZeroMemory(&bi, sizeof(bi));
+ bi.hwndOwner = hWnd;
+ bi.pszDisplayName = Buffer;
+ bi.lpszTitle = "Title";
+ bi.ulFlags = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS | BIF_SHAREABLE;
+ LPCITEMIDLIST pFolder = SHBrowseForFolderA(&bi);
+ if (pFolder == NULL) return "";
+ if (!SHGetPathFromIDListA(pFolder, Buffer)) return "";
+ return Buffer;
+}
+
struct async_locker
{
async_locker() { async_lock(); }
@@ -472,12 +488,14 @@ int main(int argc, char** argv)
int frames = 0;
float one_sec = 0;
float render_timer = 0;
+ float frame_timer = 0;
while(running)
{
t1 = GetTickCount();
float dt = (float)(t1 - t0) / 1000.0f;
one_sec += dt;
render_timer += dt;
+ frame_timer += dt;
t0 = t1;
if (one_sec > 1.f)
@@ -507,20 +525,22 @@ int main(int argc, char** argv)
}
std::unique_lock lock(render_mutex);
- if (render_timer > 1.0f / target_fps || App::I.redraw)
+ if (render_timer > 1.0f / target_fps)
{
+ App::I.redraw = true;
render_timer = 0;
- if (App::I.redraw)
- {
- async_lock();
- App::I.redraw = true;
- glBindFramebuffer(GL_FRAMEBUFFER, 0);
- App::I.clear();
- App::I.update(dt);
- SwapBuffers(hDC);
- async_unlock();
- //LOG("swap main");
- }
+ }
+ if (App::I.redraw)
+ {
+ async_lock();
+ App::I.redraw = true;
+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
+ App::I.clear();
+ App::I.update(frame_timer);
+ SwapBuffers(hDC);
+ async_unlock();
+ frame_timer = 0;
+ //LOG("swap main");
}
frames++;
diff --git a/src/node_dialog_browse.cpp b/src/node_dialog_browse.cpp
index ab208b9..6f6a0c9 100644
--- a/src/node_dialog_browse.cpp
+++ b/src/node_dialog_browse.cpp
@@ -82,7 +82,11 @@ void NodeDialogBrowse::init_controls()
LOG("change working path to %s", path.c_str());
async_start();
App::I.work_path = path;
+#ifdef _WIN32
+ GetFullPathNameA(path.c_str(), sizeof(path_buffer), path_buffer, nullptr);
+#else
realpath(path.c_str(), path_buffer);
+#endif
working_path->set_text_format("Destination dir: %s", path_buffer);
search_path = path;
clear_list();
@@ -92,7 +96,11 @@ void NodeDialogBrowse::init_controls()
});
};
working_path = find("path");
+#ifdef _WIN32
+ GetFullPathNameA(App::I.work_path.c_str(), sizeof(path_buffer), path_buffer, nullptr);
+#else
realpath(App::I.work_path.c_str(), path_buffer);
+#endif
working_path->set_text_format("Working dir: %s", path_buffer);
#endif
// if (auto* first = (NodeDialogBrowseItem*)container->get_child_at(0))
diff --git a/src/node_dialog_open.cpp b/src/node_dialog_open.cpp
index fcc83d8..944f4ad 100644
--- a/src/node_dialog_open.cpp
+++ b/src/node_dialog_open.cpp
@@ -202,14 +202,22 @@ void NodeDialogSave::init_controls()
LOG("change working path to %s", path.c_str());
async_start();
App::I.work_path = path;
+#ifdef _WIN32
+ GetFullPathNameA(path.c_str(), sizeof(path_buffer), path_buffer, nullptr);
+#else
realpath(path.c_str(), path_buffer);
+#endif
working_path->set_text_format("Working dir: %s", path_buffer);
async_update();
async_end();
});
};
working_path = find("path");
+#ifdef _WIN32
+ GetFullPathNameA(App::I.work_path.c_str(), sizeof(path_buffer), path_buffer, nullptr);
+#else
realpath(App::I.work_path.c_str(), path_buffer);
+#endif
working_path->set_text_format("Working dir: %s", path_buffer);
#endif
}
@@ -258,14 +266,22 @@ void NodeDialogNewDoc::init_controls()
LOG("change working path to %s", path.c_str());
async_start();
App::I.work_path = path;
+#ifdef _WIN32
+ GetFullPathNameA(path.c_str(), sizeof(path_buffer), path_buffer, nullptr);
+#else
realpath(path.c_str(), path_buffer);
+#endif
working_path->set_text_format("Working dir: %s", path_buffer);
async_update();
async_end();
});
};
working_path = find("path");
+#ifdef _WIN32
+ GetFullPathNameA(App::I.work_path.c_str(), sizeof(path_buffer), path_buffer, nullptr);
+#else
realpath(App::I.work_path.c_str(), path_buffer);
+#endif
working_path->set_text_format("Working dir: %s", path_buffer);
#endif
}