This commit is contained in:
2018-10-08 12:45:06 +02:00
7 changed files with 89 additions and 22 deletions

View File

@@ -202,6 +202,7 @@
<ClCompile Include="src\node_dialog_layer_rename.cpp" /> <ClCompile Include="src\node_dialog_layer_rename.cpp" />
<ClCompile Include="src\node_dialog_open.cpp" /> <ClCompile Include="src\node_dialog_open.cpp" />
<ClCompile Include="src\node_dialog_picker.cpp" /> <ClCompile Include="src\node_dialog_picker.cpp" />
<ClCompile Include="src\node_dialog_resize.cpp" />
<ClCompile Include="src\node_icon.cpp" /> <ClCompile Include="src\node_icon.cpp" />
<ClCompile Include="src\node_image.cpp" /> <ClCompile Include="src\node_image.cpp" />
<ClCompile Include="src\node_image_texture.cpp" /> <ClCompile Include="src\node_image_texture.cpp" />
@@ -320,6 +321,7 @@
<ClInclude Include="src\node_dialog_layer_rename.h" /> <ClInclude Include="src\node_dialog_layer_rename.h" />
<ClInclude Include="src\node_dialog_open.h" /> <ClInclude Include="src\node_dialog_open.h" />
<ClInclude Include="src\node_dialog_picker.h" /> <ClInclude Include="src\node_dialog_picker.h" />
<ClInclude Include="src\node_dialog_resize.h" />
<ClInclude Include="src\node_icon.h" /> <ClInclude Include="src\node_icon.h" />
<ClInclude Include="src\node_image.h" /> <ClInclude Include="src\node_image.h" />
<ClInclude Include="src\node_image_texture.h" /> <ClInclude Include="src\node_image_texture.h" />

View File

@@ -261,6 +261,9 @@
<ClCompile Include="src\node_usermanual.cpp"> <ClCompile Include="src\node_usermanual.cpp">
<Filter>Source Files\ui</Filter> <Filter>Source Files\ui</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="src\node_dialog_resize.cpp">
<Filter>Source Files\ui</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="src\app.h"> <ClInclude Include="src\app.h">
@@ -467,6 +470,9 @@
<ClInclude Include="src\node_usermanual.h"> <ClInclude Include="src\node_usermanual.h">
<Filter>Header Files\ui</Filter> <Filter>Header Files\ui</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="src\node_dialog_resize.h">
<Filter>Header Files\ui</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="PanoPainter.rc"> <ResourceCompile Include="PanoPainter.rc">

View File

@@ -400,7 +400,7 @@
<border width="400" color="0 0 0 .9" pad="10" dir="col"> <border width="400" color="0 0 0 .9" pad="10" dir="col">
<border dir="row" align="center" height="30" color=".2 .2 .2 1"> <border dir="row" align="center" height="30" color=".2 .2 .2 1">
<text text="New name: " font-face="arial" font-size="11" margin="0 5 0 5"/> <text text="New name: " font-face="arial" font-size="11" margin="0 5 0 5"/>
<text-input id="txt-input" justify="center" pad="5" grow="1" height="30" color=".3"/> <text-input id="txt-input" align="center" pad="5" grow="1" height="30" color=".3"/>
</border> </border>
<node height="40" grow="1" dir="row" align="flex-end" justify="flex-end"> <node height="40" grow="1" dir="row" align="flex-end" justify="flex-end">
<button id="btn-ok" text="Rename Layer" width="110" height="30" margin="0 10 0 0"/> <button id="btn-ok" text="Rename Layer" width="110" height="30" margin="0 10 0 0"/>
@@ -539,7 +539,7 @@
<border width="400" color="0 0 0 .9" pad="10" dir="col"> <border width="400" color="0 0 0 .9" pad="10" dir="col">
<border dir="row" align="center" height="30" color=".2 .2 .2 1"> <border dir="row" align="center" height="30" color=".2 .2 .2 1">
<text text="Project name: " font-face="arial" font-size="11" margin="0 5 0 5"/> <text text="Project name: " font-face="arial" font-size="11" margin="0 5 0 5"/>
<text-input id="txt-input" justify="center" pad="5" grow="1" height="30" color=".3"/> <text-input id="txt-input" align="center" pad="5" grow="1" height="30" color=".3"/>
</border> </border>
<text os="win,osx" id="path" text="Workind dir: path" text-wrap-width="470" font-face="arial" font-size="11" margin="10 5 10 5"/> <text os="win,osx" id="path" text="Workind dir: path" text-wrap-width="470" font-face="arial" font-size="11" margin="10 5 10 5"/>
<node height="40" grow="1" dir="row" align="flex-end" justify="flex-end"> <node height="40" grow="1" dir="row" align="flex-end" justify="flex-end">

View File

@@ -5,7 +5,8 @@
void displayKeyboard(android_app* mApplication, bool pShow); void displayKeyboard(android_app* mApplication, bool pShow);
void pick_file(android_app* mApplication, std::function<void(std::string)> callback); void pick_file(android_app* mApplication, std::function<void(std::string)> callback);
#elif _WIN32 #elif _WIN32
std::string win32_open_file(); std::string win32_open_file(const char* filter);
std::string win32_open_dir();
#endif #endif
@@ -64,7 +65,7 @@ void App::pick_image(std::function<void(std::string path)> callback)
#elif __ANDROID__ #elif __ANDROID__
pick_file(and_app, callback); pick_file(and_app, callback);
#elif _WIN32 #elif _WIN32
std::string path = win32_open_file(); std::string path = win32_open_file("Image Files (*.jpg, *.png)\0*.jpg;*.png");
if (!path.empty()) if (!path.empty())
callback(path); callback(path);
#endif #endif
@@ -89,7 +90,21 @@ void App::pick_file(std::vector<std::string> types, std::function<void (std::str
#elif __ANDROID__ #elif __ANDROID__
pick_file(and_app, callback); pick_file(and_app, callback);
#elif _WIN32 #elif _WIN32
std::string path = win32_open_file(); std::string filter = "Image Files (";
bool first_type = true;
for (auto& t : types)
{
filter += std::string(first_type ? "" : " ,") + "*." + t;
first_type = false;
}
filter += ")\0";
first_type = true;
for (auto& t : types)
{
filter += std::string(first_type ? "" : ";") + "*." + t;
first_type = false;
}
std::string path = win32_open_file(filter.c_str());
if (!path.empty()) if (!path.empty())
callback(path); callback(path);
#endif #endif
@@ -110,9 +125,9 @@ void App::pick_dir(std::function<void(std::string path)> callback)
// NOT IMPLEMENTED // NOT IMPLEMENTED
#elif _WIN32 #elif _WIN32
// TODO: to be implemented // TODO: to be implemented
// std::string path = win32_open_file(); std::string path = win32_open_dir();
// if (!path.empty()) if (!path.empty())
// callback(path); callback(path);
#endif #endif
} }

View File

@@ -107,14 +107,14 @@ void async_unlock()
} }
} }
std::string win32_open_file() std::string win32_open_file(const char* filter)
{ {
OPENFILENAMEA ofn; OPENFILENAMEA ofn;
char fileName[MAX_PATH] = ""; char fileName[MAX_PATH] = "";
ZeroMemory(&ofn, sizeof(ofn)); ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(OPENFILENAME); ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hWnd; ofn.hwndOwner = hWnd;
ofn.lpstrFilter = "Image Files (*.jpg, *.png)\0*.jpg;*.png"; ofn.lpstrFilter = filter;
ofn.lpstrFile = fileName; ofn.lpstrFile = fileName;
ofn.nMaxFile = MAX_PATH; ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR; ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
@@ -127,6 +127,22 @@ std::string win32_open_file()
return ""; 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 struct async_locker
{ {
async_locker() { async_lock(); } async_locker() { async_lock(); }
@@ -472,12 +488,14 @@ int main(int argc, char** argv)
int frames = 0; int frames = 0;
float one_sec = 0; float one_sec = 0;
float render_timer = 0; float render_timer = 0;
float frame_timer = 0;
while(running) while(running)
{ {
t1 = GetTickCount(); t1 = GetTickCount();
float dt = (float)(t1 - t0) / 1000.0f; float dt = (float)(t1 - t0) / 1000.0f;
one_sec += dt; one_sec += dt;
render_timer += dt; render_timer += dt;
frame_timer += dt;
t0 = t1; t0 = t1;
if (one_sec > 1.f) if (one_sec > 1.f)
@@ -507,20 +525,22 @@ int main(int argc, char** argv)
} }
std::unique_lock<std::mutex> lock(render_mutex); std::unique_lock<std::mutex> 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; render_timer = 0;
if (App::I.redraw) }
{ if (App::I.redraw)
async_lock(); {
App::I.redraw = true; async_lock();
glBindFramebuffer(GL_FRAMEBUFFER, 0); App::I.redraw = true;
App::I.clear(); glBindFramebuffer(GL_FRAMEBUFFER, 0);
App::I.update(dt); App::I.clear();
SwapBuffers(hDC); App::I.update(frame_timer);
async_unlock(); SwapBuffers(hDC);
//LOG("swap main"); async_unlock();
} frame_timer = 0;
//LOG("swap main");
} }
frames++; frames++;

View File

@@ -82,7 +82,11 @@ void NodeDialogBrowse::init_controls()
LOG("change working path to %s", path.c_str()); LOG("change working path to %s", path.c_str());
async_start(); async_start();
App::I.work_path = path; App::I.work_path = path;
#ifdef _WIN32
GetFullPathNameA(path.c_str(), sizeof(path_buffer), path_buffer, nullptr);
#else
realpath(path.c_str(), path_buffer); realpath(path.c_str(), path_buffer);
#endif
working_path->set_text_format("Destination dir: %s", path_buffer); working_path->set_text_format("Destination dir: %s", path_buffer);
search_path = path; search_path = path;
clear_list(); clear_list();
@@ -92,7 +96,11 @@ void NodeDialogBrowse::init_controls()
}); });
}; };
working_path = find<NodeText>("path"); working_path = find<NodeText>("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); realpath(App::I.work_path.c_str(), path_buffer);
#endif
working_path->set_text_format("Working dir: %s", path_buffer); working_path->set_text_format("Working dir: %s", path_buffer);
#endif #endif
// if (auto* first = (NodeDialogBrowseItem*)container->get_child_at(0)) // if (auto* first = (NodeDialogBrowseItem*)container->get_child_at(0))

View File

@@ -202,14 +202,22 @@ void NodeDialogSave::init_controls()
LOG("change working path to %s", path.c_str()); LOG("change working path to %s", path.c_str());
async_start(); async_start();
App::I.work_path = path; App::I.work_path = path;
#ifdef _WIN32
GetFullPathNameA(path.c_str(), sizeof(path_buffer), path_buffer, nullptr);
#else
realpath(path.c_str(), path_buffer); realpath(path.c_str(), path_buffer);
#endif
working_path->set_text_format("Working dir: %s", path_buffer); working_path->set_text_format("Working dir: %s", path_buffer);
async_update(); async_update();
async_end(); async_end();
}); });
}; };
working_path = find<NodeText>("path"); working_path = find<NodeText>("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); realpath(App::I.work_path.c_str(), path_buffer);
#endif
working_path->set_text_format("Working dir: %s", path_buffer); working_path->set_text_format("Working dir: %s", path_buffer);
#endif #endif
} }
@@ -258,14 +266,22 @@ void NodeDialogNewDoc::init_controls()
LOG("change working path to %s", path.c_str()); LOG("change working path to %s", path.c_str());
async_start(); async_start();
App::I.work_path = path; App::I.work_path = path;
#ifdef _WIN32
GetFullPathNameA(path.c_str(), sizeof(path_buffer), path_buffer, nullptr);
#else
realpath(path.c_str(), path_buffer); realpath(path.c_str(), path_buffer);
#endif
working_path->set_text_format("Working dir: %s", path_buffer); working_path->set_text_format("Working dir: %s", path_buffer);
async_update(); async_update();
async_end(); async_end();
}); });
}; };
working_path = find<NodeText>("path"); working_path = find<NodeText>("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); realpath(App::I.work_path.c_str(), path_buffer);
#endif
working_path->set_text_format("Working dir: %s", path_buffer); working_path->set_text_format("Working dir: %s", path_buffer);
#endif #endif
} }