implement wheel on web
This commit is contained in:
@@ -101,11 +101,19 @@ void CanvasOnPointerUp(std::string type, float x, float y, int button)
|
|||||||
|
|
||||||
void CanvasOnPointerMove(std::string type, float x, float y, float f)
|
void CanvasOnPointerMove(std::string type, float x, float y, float f)
|
||||||
{
|
{
|
||||||
|
g_cursor_pos = { x, y };
|
||||||
app.ui_task_async([=]{
|
app.ui_task_async([=]{
|
||||||
app.mouse_move(x, y, f, StringToType(type), false);
|
app.mouse_move(x, y, f, StringToType(type), false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CanvasOnWheel(float y)
|
||||||
|
{
|
||||||
|
app.ui_task_async([=]{
|
||||||
|
app.mouse_scroll(g_cursor_pos.x, g_cursor_pos.y, y);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void StartApp()
|
void StartApp()
|
||||||
{
|
{
|
||||||
App::I = &app;
|
App::I = &app;
|
||||||
@@ -133,6 +141,7 @@ EMSCRIPTEN_BINDINGS(TaskCallback_bind) {
|
|||||||
function("CanvasOnPointerDown", &CanvasOnPointerDown);
|
function("CanvasOnPointerDown", &CanvasOnPointerDown);
|
||||||
function("CanvasOnPointerUp", &CanvasOnPointerUp);
|
function("CanvasOnPointerUp", &CanvasOnPointerUp);
|
||||||
function("CanvasOnPointerMove", &CanvasOnPointerMove);
|
function("CanvasOnPointerMove", &CanvasOnPointerMove);
|
||||||
|
function("CanvasOnWheel", &CanvasOnWheel);
|
||||||
function("StartApp", &StartApp);
|
function("StartApp", &StartApp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,13 +257,16 @@ int main()
|
|||||||
Module.CanvasOnPointerMove(event.pointerType, event.layerX, event.layerY, f);
|
Module.CanvasOnPointerMove(event.pointerType, event.layerX, event.layerY, f);
|
||||||
};
|
};
|
||||||
Module.canvas.onpointerdown = function(event) {
|
Module.canvas.onpointerdown = function(event) {
|
||||||
console.log(event);
|
|
||||||
f = event.pointerType == "pen" ? event.pressure : 1.0;
|
f = event.pointerType == "pen" ? event.pressure : 1.0;
|
||||||
Module.CanvasOnPointerDown(event.pointerType, event.layerX, event.layerY, f, event.button);
|
Module.CanvasOnPointerDown(event.pointerType, event.layerX, event.layerY, f, event.button);
|
||||||
};
|
};
|
||||||
Module.canvas.onpointerup = function(event) {
|
Module.canvas.onpointerup = function(event) {
|
||||||
Module.CanvasOnPointerUp(event.pointerType, event.layerX, event.layerY, event.button);
|
Module.CanvasOnPointerUp(event.pointerType, event.layerX, event.layerY, event.button);
|
||||||
};
|
};
|
||||||
|
Module.canvas.onwheel = function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
Module.CanvasOnWheel(-event.deltaY / 100.0);
|
||||||
|
};
|
||||||
Module.canvas.style.touchAction = 'none';
|
Module.canvas.style.touchAction = 'none';
|
||||||
Module.js_fs_synching = false;
|
Module.js_fs_synching = false;
|
||||||
FS.mkdir('/PanoPainter');
|
FS.mkdir('/PanoPainter');
|
||||||
|
|||||||
Reference in New Issue
Block a user