Reduce time spent with UI context
Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
parent
fe8ea81dc2
commit
c0d839f7af
1 changed files with 12 additions and 24 deletions
|
@ -129,8 +129,6 @@ protected:
|
||||||
|
|
||||||
bool onMouse(const MouseEvent& ev) override
|
bool onMouse(const MouseEvent& ev) override
|
||||||
{
|
{
|
||||||
const ScopedContext sc(this);
|
|
||||||
|
|
||||||
int button;
|
int button;
|
||||||
int mods = 0;
|
int mods = 0;
|
||||||
int action = ev.press ? GLFW_PRESS : GLFW_RELEASE;
|
int action = ev.press ? GLFW_PRESS : GLFW_RELEASE;
|
||||||
|
@ -197,40 +195,31 @@ protected:
|
||||||
#endif
|
#endif
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const ScopedContext sc(this);
|
||||||
return fContext->event->handleButton(fLastMousePos, button, action, mods);
|
return fContext->event->handleButton(fLastMousePos, button, action, mods);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool onMotion(const MotionEvent& ev) override
|
bool onMotion(const MotionEvent& ev) override
|
||||||
{
|
{
|
||||||
const ScopedContext sc(this);
|
const rack::math::Vec mousePos = rack::math::Vec(ev.pos.getX(), ev.pos.getY()).div(getScaleFactor()).round();
|
||||||
|
const rack::math::Vec mouseDelta = mousePos.minus(fLastMousePos);
|
||||||
rack::math::Vec mousePos = rack::math::Vec(ev.pos.getX(), ev.pos.getY()).div(getScaleFactor()).round();
|
|
||||||
// .div(ctx->window->pixelRatio / ctx->window->windowRatio).round();
|
|
||||||
rack::math::Vec mouseDelta = mousePos.minus(fLastMousePos);
|
|
||||||
|
|
||||||
/*
|
|
||||||
// Workaround for GLFW warping mouse to a different position when the cursor is locked or unlocked.
|
|
||||||
if (ctx->window->internal->ignoreNextMouseDelta)
|
|
||||||
{
|
|
||||||
ctx->window->internal->ignoreNextMouseDelta = false;
|
|
||||||
mouseDelta = rack::math::Vec();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
fLastMousePos = mousePos;
|
fLastMousePos = mousePos;
|
||||||
|
|
||||||
|
const ScopedContext sc(this);
|
||||||
return fContext->event->handleHover(mousePos, mouseDelta);
|
return fContext->event->handleHover(mousePos, mouseDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool onScroll(const ScrollEvent& ev) override
|
bool onScroll(const ScrollEvent& ev) override
|
||||||
{
|
{
|
||||||
const ScopedContext sc(this);
|
|
||||||
|
|
||||||
rack::math::Vec scrollDelta = rack::math::Vec(ev.delta.getX(), ev.delta.getY());
|
rack::math::Vec scrollDelta = rack::math::Vec(ev.delta.getX(), ev.delta.getY());
|
||||||
#ifdef DISTRHO_OS_MAC
|
#ifdef DISTRHO_OS_MAC
|
||||||
scrollDelta = scrollDelta.mult(10.0);
|
scrollDelta = scrollDelta.mult(10.0);
|
||||||
#else
|
#else
|
||||||
scrollDelta = scrollDelta.mult(50.0);
|
scrollDelta = scrollDelta.mult(50.0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const ScopedContext sc(this);
|
||||||
return fContext->event->handleScroll(fLastMousePos, scrollDelta);
|
return fContext->event->handleScroll(fLastMousePos, scrollDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,14 +229,11 @@ protected:
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const ScopedContext sc(this);
|
const ScopedContext sc(this);
|
||||||
|
|
||||||
return fContext->event->handleText(fLastMousePos, ev.character);
|
return fContext->event->handleText(fLastMousePos, ev.character);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool onKeyboard(const KeyboardEvent& ev) override
|
bool onKeyboard(const KeyboardEvent& ev) override
|
||||||
{
|
{
|
||||||
const ScopedContext sc(this);
|
|
||||||
|
|
||||||
int key;
|
int key;
|
||||||
int mods = 0;
|
int mods = 0;
|
||||||
int action = ev.press ? GLFW_PRESS : GLFW_RELEASE;
|
int action = ev.press ? GLFW_PRESS : GLFW_RELEASE;
|
||||||
|
@ -324,15 +310,17 @@ protected:
|
||||||
if (ev.mod & kModifierAlt)
|
if (ev.mod & kModifierAlt)
|
||||||
mods |= GLFW_MOD_ALT;
|
mods |= GLFW_MOD_ALT;
|
||||||
|
|
||||||
|
const ScopedContext sc(this);
|
||||||
return fContext->event->handleKey(fLastMousePos, key, ev.keycode, action, mods);
|
return fContext->event->handleKey(fLastMousePos, key, ev.keycode, action, mods);
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiFocus(const bool focus, CrossingMode) override
|
void uiFocus(const bool focus, CrossingMode) override
|
||||||
{
|
{
|
||||||
const ScopedContext sc(this);
|
if (focus)
|
||||||
|
return;
|
||||||
|
|
||||||
if (! focus)
|
const ScopedContext sc(this);
|
||||||
fContext->event->handleLeave();
|
fContext->event->handleLeave();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue