Signed-off-by: falkTX <falktx@falktx.com>tags/22.07
| @@ -1 +1 @@ | |||
| Subproject commit 02216aba747685fe3d8c1e7b95d7fc008249fee2 | |||
| Subproject commit f022c766bd315b5bb22800b9ab78a4e1ec991edc | |||
| @@ -504,7 +504,4 @@ void ImGuiWidget::drawFramebufferCommon(const Vec& fbSize, const float scaleFact | |||
| ImGui_ImplOpenGL2_RenderDrawData(data); | |||
| #endif | |||
| } | |||
| // FIXME | |||
| io.KeysDown[GLFW_KEY_DELETE] = io.KeysDown[GLFW_KEY_BACKSPACE] = io.KeysDown[GLFW_KEY_ENTER] = false; | |||
| } | |||
| @@ -136,7 +136,11 @@ struct Initializer | |||
| { | |||
| using namespace rack; | |||
| #ifdef DISTRHO_OS_WASM | |||
| settings::allowCursorLock = true; | |||
| #else | |||
| settings::allowCursorLock = false; | |||
| #endif | |||
| settings::autoCheckUpdates = false; | |||
| settings::autosaveInterval = 0; | |||
| settings::devMode = true; | |||
| @@ -110,7 +110,12 @@ struct FileButton : MenuButton { | |||
| menu->cornerFlags = BND_CORNER_TOP; | |||
| menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y)); | |||
| menu->addChild(createMenuItem("New", RACK_MOD_CTRL_NAME "+N", []() { | |||
| #ifndef DISTRHO_OS_WASM | |||
| const char* const NewShortcut = RACK_MOD_CTRL_NAME "+N"; | |||
| #else | |||
| const char* const NewShortcut = ""; | |||
| #endif | |||
| menu->addChild(createMenuItem("New", NewShortcut, []() { | |||
| patchUtils::loadTemplateDialog(); | |||
| })); | |||
| @@ -523,7 +528,9 @@ struct ViewButton : MenuButton { | |||
| menu->addChild(new ui::MenuSeparator); | |||
| menu->addChild(createMenuLabel("Parameters")); | |||
| // menu->addChild(createBoolPtrMenuItem("Lock cursor while dragging", "", &settings::allowCursorLock)); | |||
| #ifdef DISTRHO_OS_WASM | |||
| menu->addChild(createBoolPtrMenuItem("Lock cursor while dragging", "", &settings::allowCursorLock)); | |||
| #endif | |||
| static const std::vector<std::string> knobModeLabels = { | |||
| "Linear", | |||
| @@ -550,6 +557,16 @@ struct ViewButton : MenuButton { | |||
| menu->addChild(new ui::MenuSeparator); | |||
| menu->addChild(createMenuLabel("Window")); | |||
| #ifdef DISTRHO_OS_WASM | |||
| const bool fullscreen = APP->window->isFullScreen(); | |||
| std::string fullscreenText = "F11"; | |||
| if (fullscreen) | |||
| fullscreenText += " " CHECKMARK_STRING; | |||
| menu->addChild(createMenuItem("Fullscreen", fullscreenText, [=]() { | |||
| APP->window->setFullScreen(!fullscreen); | |||
| })); | |||
| #endif | |||
| menu->addChild(createBoolPtrMenuItem("Invert zoom", "", &settings::invertZoom)); | |||
| static const std::vector<std::string> rateLimitLabels = { | |||
| @@ -360,6 +360,12 @@ void Scene::onHoverKey(const HoverKeyEvent& e) { | |||
| window::generateScreenshot(); | |||
| e.consume(this); | |||
| } | |||
| #ifdef DISTRHO_OS_WASM | |||
| if (e.key == GLFW_KEY_F11 && (e.mods & RACK_MOD_MASK) == 0) { | |||
| APP->window->setFullScreen(!APP->window->isFullScreen()); | |||
| e.consume(this); | |||
| } | |||
| #endif | |||
| // Module selections | |||
| if (e.keyName == "a" && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||
| @@ -62,6 +62,10 @@ | |||
| # include "src/Resources.hpp" | |||
| #endif | |||
| #ifdef DISTRHO_OS_WASM | |||
| # include <emscripten/html5.h> | |||
| #endif | |||
| namespace rack { | |||
| namespace window { | |||
| @@ -172,7 +176,11 @@ struct Window::Internal { | |||
| Internal() | |||
| : hiddenApp(false), | |||
| hiddenWindow(hiddenApp) { hiddenApp.idle(); } | |||
| hiddenWindow(hiddenApp) | |||
| { | |||
| hiddenWindow.setIgnoringKeyRepeat(true); | |||
| hiddenApp.idle(); | |||
| } | |||
| }; | |||
| @@ -224,6 +232,10 @@ Window::Window() { | |||
| if (uiFont != nullptr) | |||
| bndSetFont(uiFont->handle); | |||
| #ifdef DISTRHO_OS_WASM | |||
| emscripten_lock_orientation(EMSCRIPTEN_ORIENTATION_LANDSCAPE_PRIMARY); | |||
| #endif | |||
| } | |||
| void WindowSetPluginUI(Window* const window, DISTRHO_NAMESPACE::UI* const ui) | |||
| @@ -536,7 +548,7 @@ void Window::step() { | |||
| #ifdef STBI_WRITE_NO_STDIO | |||
| Window__downscaleBitmap(pixelsWithOffset, winWidth, winHeight); | |||
| stbi_write_png_to_func(Window__writeImagePNG, internal->ui, | |||
| winWidth, winHeight, depth, pixelsWithOffset, stride); | |||
| winWidth, winHeight, depth, pixelsWithOffset, stride); | |||
| #else | |||
| stbi_write_png("screenshot.png", winWidth, winHeight, depth, pixelsWithOffset, stride); | |||
| #endif | |||
| @@ -572,14 +584,31 @@ void Window::close() { | |||
| void Window::cursorLock() { | |||
| #ifdef DISTRHO_OS_WASM | |||
| if (!settings::allowCursorLock) | |||
| return; | |||
| emscripten_request_pointerlock(internal->ui->getWindow().getApp().getClassName(), false); | |||
| #endif | |||
| } | |||
| void Window::cursorUnlock() { | |||
| #ifdef DISTRHO_OS_WASM | |||
| if (!settings::allowCursorLock) | |||
| return; | |||
| emscripten_exit_pointerlock(); | |||
| #endif | |||
| } | |||
| bool Window::isCursorLocked() { | |||
| #ifdef DISTRHO_OS_WASM | |||
| EmscriptenPointerlockChangeEvent status; | |||
| if (emscripten_get_pointerlock_status(&status) == EMSCRIPTEN_RESULT_SUCCESS) | |||
| return status.isActive; | |||
| #endif | |||
| return false; | |||
| } | |||
| @@ -589,19 +618,29 @@ int Window::getMods() { | |||
| } | |||
| void Window::setFullScreen(bool) { | |||
| void Window::setFullScreen(const bool fullscreen) { | |||
| #ifdef DISTRHO_OS_WASM | |||
| if (fullscreen) | |||
| emscripten_request_fullscreen(internal->ui->getWindow().getApp().getClassName(), false); | |||
| else | |||
| emscripten_exit_fullscreen(); | |||
| #endif | |||
| } | |||
| bool Window::isFullScreen() { | |||
| #if defined(CARDINAL_TRANSPARENT_SCREENSHOTS) && !defined(DGL_USE_GLES) | |||
| #ifdef DISTRHO_OS_WASM | |||
| EmscriptenFullscreenChangeEvent status; | |||
| if (emscripten_get_fullscreen_status(&status) == EMSCRIPTEN_RESULT_SUCCESS) | |||
| return status.isFullscreen; | |||
| return false; | |||
| #elif defined(CARDINAL_TRANSPARENT_SCREENSHOTS) && !defined(DGL_USE_GLES) | |||
| return internal->generateScreenshotStep != kScreenshotStepNone; | |||
| #else | |||
| return false; | |||
| #endif | |||
| } | |||
| double Window::getMonitorRefreshRate() { | |||
| return internal->monitorRefreshRate; | |||
| } | |||