diff --git a/doc/changelog.dox b/doc/changelog.dox index dae4cc197..3bd4b0c62 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -90,6 +90,9 @@ See also: @ref Platform::Sdl2Application - Implemented missing resize event support in @ref Platform::Sdl2Application on @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten" +- Ability to modify CSS classes that control layout of + @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten" app canvas using + @ref Platform::Sdl2Application::setContainerCssClass() - Implemented @ref Platform::GlfwApplication::MouseMoveEvent::buttons() for feature parity with @ref Platform::Sdl2Application - Added @ref Platform::Sdl2Application::GLConfiguration::setColorBufferSize() "GLConfiguration::setColorBufferSize()", diff --git a/src/Magnum/Platform/Sdl2Application.cpp b/src/Magnum/Platform/Sdl2Application.cpp index 8beb97cf2..e6cf7ecc5 100644 --- a/src/Magnum/Platform/Sdl2Application.cpp +++ b/src/Magnum/Platform/Sdl2Application.cpp @@ -531,6 +531,15 @@ Vector2i Sdl2Application::framebufferSize() const { return size; } +#ifdef CORRADE_TARGET_EMSCRIPTEN +void Sdl2Application::setContainerCssClass(const std::string& cssClass) { + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wdollar-in-identifier-extension" + EM_ASM_({document.getElementById('container').className = Pointer_stringify($0, $1);}, cssClass.data(), cssClass.size()); + #pragma GCC diagnostic pop +} +#endif + void Sdl2Application::swapBuffers() { #ifndef CORRADE_TARGET_EMSCRIPTEN SDL_GL_SwapWindow(_window); diff --git a/src/Magnum/Platform/Sdl2Application.h b/src/Magnum/Platform/Sdl2Application.h index 4c6387d54..b51d956fe 100644 --- a/src/Magnum/Platform/Sdl2Application.h +++ b/src/Magnum/Platform/Sdl2Application.h @@ -626,6 +626,22 @@ class Sdl2Application { */ Vector2 dpiScaling(const Configuration& configuration) const; + #if defined(CORRADE_TARGET_EMSCRIPTEN) || defined(DOXYGEN_GENERATING_OUTPUT) + /** + * @brief Set container CSS class + * + * Assigns given CSS class to the @cb{.html}
@ce. + * Useful for example to change aspect ratio of the view or stretch it + * to cover the full page. See @ref platforms-html5-layout for more + * information about possible values. Note that this replaces any + * existing class, to set multiple classes separate them with + * whitespace. + * + * @note Only available on @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten". + */ + void setContainerCssClass(const std::string& cssClass); + #endif + protected: /** * @brief Swap buffers