hide cursor on canvas, add mouse focus event, brush preview solid when small
This commit is contained in:
32
src/main.cpp
32
src/main.cpp
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user