hide cursor on canvas, add mouse focus event, brush preview solid when small

This commit is contained in:
2019-03-06 20:39:27 +01:00
parent 5eba9f1227
commit 3296de98cc
15 changed files with 194 additions and 24 deletions

View File

@@ -40,6 +40,8 @@ std::condition_variable render_cv;
int gl_count = 0;
std::deque<std::packaged_task<void()>> tasklist;
std::mutex task_mutex;
std::deque<std::packaged_task<void()>> main_tasklist;
std::mutex main_task_mutex;
float timer_stylus = 0;
float timer_ink_touch = 0;
float timer_ink_pen = 0;
@@ -67,6 +69,10 @@ std::string GetLastErrorAsString()
void destroy_window()
{
std::lock_guard<std::mutex> lock(main_task_mutex);
main_tasklist.emplace_back([=] {
SendMessage(hWnd, WM_USER_CLOSE, 0, 0);
});
SendMessage(hWnd, WM_USER_CLOSE, 0, 0);
}
@@ -122,6 +128,14 @@ void async_unlock()
}
}
void win32_show_cursor(bool visible)
{
std::lock_guard<std::mutex> lock(main_task_mutex);
main_tasklist.emplace_back([=] {
ShowCursor(visible);
});
}
std::string win32_open_file(const char* filter)
{
OPENFILENAMEA ofn;
@@ -810,6 +824,24 @@ int main(int argc, char** argv)
TranslateMessage(&msg);
}
// list of tasks for the main thread
{
std::deque<std::packaged_task<void()>> working_list;
{
std::lock_guard<std::mutex> lock(main_task_mutex);
working_list = std::move(main_tasklist);
}
if (!working_list.empty())
{
while (!working_list.empty())
{
working_list.front()();
working_list.pop_front();
}
}
}
if (!tasklist.empty())
render_cv.notify_all();
}