improve dialog browse, wrap ui task for every Node method that modifies the children list, update the ui every time the scene tree changes, restore fps and stylus state on win, fix bucket tool, fix snapshop restore, init in ui thread

This commit is contained in:
2019-07-10 21:08:14 +02:00
parent 4cbf0c47b4
commit 48c39c4ef2
10 changed files with 293 additions and 131 deletions

View File

@@ -18,6 +18,10 @@
#include "abr.h"
#include "settings.h"
#include <iomanip>
#include <ctime>
#include <sstream>
#define WM_USER_CLOSE (WM_USER + 1)
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
@@ -31,6 +35,7 @@ std::mutex gl_mutex;
std::mutex async_mutex;
std::thread::id gl_thread;
std::map<kKey, int> vkey_map;
static wchar_t window_title[512];
std::thread hmd_renderer;
int vr_frames = 0;
@@ -159,6 +164,44 @@ void async_unlock()
}
}
void win32_update_stylus(float dt)
{
timer_stylus += dt;
timer_ink_touch += dt;
timer_ink_pen += dt;
if (timer_stylus > 0.1 && (WacomTablet::I.m_stylus || WacomTablet::I.m_eraser))
{
WacomTablet::I.m_stylus = false;
WacomTablet::I.m_eraser = false;
App::I.redraw = true;
}
if (timer_ink_pen > 0.1 && WacomTablet::I.m_ink_pen)
{
WacomTablet::I.m_ink_pen = false;
App::I.redraw = true;
}
if (timer_ink_touch > 0.1 && WacomTablet::I.m_ink_touch)
{
WacomTablet::I.m_ink_touch = false;
App::I.redraw = true;
}
}
void win32_update_fps(int frames)
{
static wchar_t title_fps[512];
if (App::I.vr_active)
swprintf_s(title_fps, L"%s - %d fps - %d vr fps", window_title, frames, vr_frames);
else
swprintf_s(title_fps, L"%s - %d fps", window_title, frames);
std::lock_guard<std::mutex> lock(main_task_mutex);
main_tasklist.emplace_back([] {
SetWindowText(hWnd, title_fps);
});
}
void win32_show_cursor(bool visible)
{
std::lock_guard<std::mutex> lock(main_task_mutex);
@@ -476,9 +519,14 @@ static void SetupExceptionHandler()
BT_AddLogFile(wpath);
BT_SetPreErrHandler([](INT_PTR){
if (Canvas::I)
if (Canvas::I && Canvas::I->m_unsaved)
{
auto path = App::I.data_path + "/recovery.ppi";
auto t = std::time(nullptr);
auto tm = *std::localtime(&t);
std::ostringstream oss;
oss << std::put_time(&tm, "%d-%m-%Y %H-%M-%S");
auto path = App::I.data_path + "/" + App::I.doc_name + "-recovery (" + oss.str() + ").ppi";
Canvas::I->project_save_thread(path);
static char abspath[MAX_PATH];
GetFullPathNameA(path.c_str(), MAX_PATH, abspath, NULL);
@@ -845,7 +893,6 @@ int main(int argc, char** argv)
LOG("GL vendor: %s", glGetString(GL_VENDOR));
LOG("GL renderer: %s", glGetString(GL_RENDERER));
static wchar_t window_title[512];
swprintf_s(window_title, L"PanoPainter %s (%s)", g_version_number_w,
str2wstr((char*)glGetString(GL_RENDERER)).c_str());
@@ -934,7 +981,7 @@ int main(int argc, char** argv)
#endif
LOG("init app");
App::I.init();
// App::I.init();
if (!sandboxed)
{