fix android compile, fix windows system info log, implement touch/stylus events on windows

This commit is contained in:
2018-10-08 21:13:44 +02:00
parent 365af43891
commit dba5eef824
9 changed files with 65 additions and 33 deletions

1
.gitignore vendored
View File

@@ -26,3 +26,4 @@ android/release
PanoPainterPackage/_pkginfo.txt
PanoPainterPackage/AppPackages/
PanoPainterPackage/BundleArtifacts/
Thumbs.db

View File

@@ -270,7 +270,7 @@ JNIEXPORT void JNICALL Java_com_omixlab_panopainter_MainActivity_pickExternalCal
}
}
void pick_file(android_app* mApplication, std::function<void(std::string)> callback)
void android_pick_file(android_app* mApplication, std::function<void(std::string)> callback)
{
// Attaches the current thread to the JVM.
jint lResult;
@@ -941,9 +941,6 @@ static void engine_handle_cmd(struct android_app* app, int32_t cmd) {
void android_main(struct android_app* state) {
struct engine engine;
// Make sure glue isn't stripped.
app_dummy();
memset(&engine, 0, sizeof(engine));
state->userData = &engine;
state->onAppCmd = engine_handle_cmd;

View File

@@ -8,6 +8,11 @@ branch = check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"]).rstrip().dec
shorthash = check_output(["git", "log", "--pretty=format:%h", "-n 1"]).rstrip().decode("utf-8")
revcount = int(check_output(["git", "rev-list", "--count", "HEAD"]))
tag = check_output(["git", "describe", "--tags", "--abbrev=0"]).rstrip().decode("utf-8")
if (len(sys.argv) < 2)
print "Version generation failed, target not specified. Define release/debug."
exit(0)
config = sys.argv[2].lower()
version = "%s.%d (%s-%s-%s)" % (tag, revcount, shorthash, branch, config)

View File

@@ -3,7 +3,7 @@
#ifdef __ANDROID__
void displayKeyboard(android_app* mApplication, bool pShow);
void pick_file(android_app* mApplication, std::function<void(std::string)> callback);
void android_pick_file(android_app* mApplication, std::function<void(std::string)> callback);
#elif _WIN32
std::string win32_open_file(const char* filter);
std::string win32_open_dir();
@@ -63,7 +63,7 @@ void App::pick_image(std::function<void(std::string path)> callback)
callback(path);
});
#elif __ANDROID__
pick_file(and_app, callback);
android_pick_file(and_app, callback);
#elif _WIN32
std::string path = win32_open_file("Image Files (*.jpg, *.png)\0*.jpg;*.png");
if (!path.empty())
@@ -88,7 +88,7 @@ void App::pick_file(std::vector<std::string> types, std::function<void (std::str
callback(path);
});
#elif __ANDROID__
pick_file(and_app, callback);
//android_pick_file(and_app, callback);
#elif _WIN32
std::string filter = "Image Files (";
bool first_type = true;

View File

@@ -122,7 +122,7 @@ void LogRemote::log(const wchar_t* format, ...)
//use converter (.to_bytes: wstr->str, .from_bytes: str->wstr)
//std::string converted_str = converter.to_bytes(string_to_convert);
m_mq.Post(std::move(converted));
m_mq.Post(std::string(converted));
if (m_logfile.is_open())
{
auto line = converted + "\n";

View File

@@ -264,7 +264,8 @@ static void SetupExceptionHandler()
BT_SetFlags(BTF_DETAILEDMODE | BTF_ATTACHREPORT | BTF_SCREENCAPTURE);
// = BugTrapServer ===========================================
BT_SetSupportServer(_T("omigamedev.ddns.net"), 8088);
//BT_SetSupportServer(_T("omigamedev.ddns.net"), 8088);
BT_SetSupportEMail(_T("info@panopainter.com"));
// - or -
//BT_SetSupportServer(_T("127.0.0.1"), 9999);
@@ -454,6 +455,12 @@ int main(int argc, char** argv)
}
}
// link: https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-registertouchwindow
if (RegisterTouchWindow(hWnd, 0) == 0)
{
LOG("RegisterTouchWindow error: %s", GetLastErrorAsString().c_str());
}
auto monitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
auto x = unsigned{};
auto y = unsigned{};
@@ -520,7 +527,6 @@ int main(int argc, char** argv)
async_lock();
while (!working_list.empty())
{
working_list.front()();
working_list.pop_front();
}
@@ -589,6 +595,12 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
static bool leftDown = false;
static DWORD lastTime;
static POINT lastPoint;
auto extra = GetMessageExtraInfo();
auto pointer_source = WacomTablet::I.m_stylus ? kEventSource::Stylus : kEventSource::Mouse;
if ((extra & 0xFFFFFF00) == 0xFF515700)
pointer_source = kEventSource::Touch;
switch (msg)
{
case WM_USER_CLOSE:
@@ -624,13 +636,29 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
}
case WM_ACTIVATE:
{
std::lock_guard<std::mutex> lock(task_mutex);
tasklist.emplace_back([=] {
int active = GET_WM_ACTIVATE_STATE(wp, lp);
WacomTablet::I.set_focus(active);
});
break;
}
// case WM_TOUCH:
// {
// std::lock_guard<std::mutex> lock(task_mutex);
// tasklist.emplace_back([=] {
// //LOG("touch");
// });
// break;
// }
case WT_PACKET:
{
std::lock_guard<std::mutex> lock(task_mutex);
tasklist.emplace_back([=] {
WacomTablet::I.handle_message(hWnd, msg, wp, lp);
});
break;
}
case WM_SYSKEYDOWN:
case WM_KEYDOWN:
{
@@ -660,45 +688,45 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
case WM_MOUSEMOVE:
{
std::lock_guard<std::mutex> lock(task_mutex);
tasklist.emplace_back([lp, p = WacomTablet::I.get_pressure()]{
App::I.mouse_move((float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), p, kEventSource::Mouse);
tasklist.emplace_back([lp, pointer_source, p = WacomTablet::I.get_pressure()]{
App::I.mouse_move((float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), p, pointer_source);
});
}
break;
case WM_LBUTTONDOWN:
SetCapture(hWnd);
{
std::lock_guard<std::mutex> lock(task_mutex);
tasklist.emplace_back([lp, p = WacomTablet::I.get_pressure()]{
App::I.mouse_down(0, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), p, kEventSource::Mouse);
tasklist.emplace_back([lp, pointer_source, hWnd, p = WacomTablet::I.get_pressure()]{
SetCapture(hWnd);
App::I.mouse_down(0, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), p, pointer_source);
});
}
break;
case WM_LBUTTONUP:
WacomTablet::I.reset_pressure();
ReleaseCapture();
{
std::lock_guard<std::mutex> lock(task_mutex);
tasklist.emplace_back([lp]{
App::I.mouse_up(0, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), kEventSource::Mouse);
tasklist.emplace_back([lp, pointer_source]{
WacomTablet::I.reset_pressure();
ReleaseCapture();
App::I.mouse_up(0, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), pointer_source);
});
}
break;
case WM_RBUTTONDOWN:
SetCapture(hWnd);
{
std::lock_guard<std::mutex> lock(task_mutex);
tasklist.emplace_back([lp]{
App::I.mouse_down(1, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), 1.f, kEventSource::Mouse);
tasklist.emplace_back([lp, pointer_source, hWnd]{
SetCapture(hWnd);
App::I.mouse_down(1, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), 1.f, pointer_source);
});
}
break;
case WM_RBUTTONUP:
ReleaseCapture();
{
std::lock_guard<std::mutex> lock(task_mutex);
tasklist.emplace_back([lp]{
App::I.mouse_up(1, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), kEventSource::Mouse);
tasklist.emplace_back([lp, pointer_source]{
ReleaseCapture();
App::I.mouse_up(1, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), pointer_source);
});
}
break;

View File

@@ -72,6 +72,7 @@ void NodeButton::parse_attributes(kAttribute ka, const tinyxml2::XMLAttribute* a
color_normal = m_border->m_color;
color_hover = glm::clamp(m_border->m_color + glm::vec4(.1, .1, .1, 0), {0,0,0,0}, {1,1,1,1});
color_down = glm::clamp(m_border->m_color + glm::vec4(.2, .2, .2, 0), {0,0,0,0}, {1,1,1,1});
break;
case kAttribute::Padding:
case kAttribute::Width:
case kAttribute::Height:

View File

@@ -49,11 +49,11 @@ kEventResult NodeButtonCustom::handle_event(Event* e)
mouse_capture();
break;
case kEventType::MouseUpL:
#if defined(__IOS__) || defined(__ANDROID__)
m_color = color_normal;
#else
// if using touch or stylus, unfocus the button
if (((MouseEvent*)e)->m_source == kEventSource::Mouse)
m_color = m_mouse_inside ? color_hover : color_normal;
#endif
else
m_color = color_normal;
mouse_release();
if (m_mouse_inside && on_click != nullptr)
on_click(this);

View File

@@ -14,5 +14,5 @@ public:
NodeText* m_title;
virtual Node* clone_instantiate() const override;
virtual void init() override;
virtual kEventResult handle_event(Event* e);
virtual kEventResult handle_event(Event* e) override;
};