diff --git a/vclib/render/include/vclib/glfw/window_manager.h b/vclib/render/include/vclib/glfw/window_manager.h index 8679b4b12..ac231aa65 100644 --- a/vclib/render/include/vclib/glfw/window_manager.h +++ b/vclib/render/include/vclib/glfw/window_manager.h @@ -25,8 +25,8 @@ #include "input.h" -// #include #include +#include #include #if defined(__linux__) @@ -83,11 +83,18 @@ class WindowManager public: /** * @brief The ParentType is the type of the parent class. It is used to - * initialize the base class (if any). In the GLFW WindowManager, the parent - * class is void and it is not managed. + * initialize the base class (if any). In the glfw::WindowManager, the + * parent class is void and it is not managed. */ using ParentType = void; + /** + * @brief The WINDOW_MANAGER_ID is the ID of the window manager. It is used + * to identify the window manager implementation (if necessary) by the + * DerivedRenderer class. + */ + static const uint WINDOW_MANAGER_ID = WindowManagerId::GLFW_WINDOW; + WindowManager(ParentType* parent = nullptr) : WindowManager("", 1024, 768, parent) { diff --git a/vclib/render/include/vclib/qt/widget_manager.h b/vclib/render/include/vclib/qt/widget_manager.h index 6074ed5c5..dd5f876fd 100644 --- a/vclib/render/include/vclib/qt/widget_manager.h +++ b/vclib/render/include/vclib/qt/widget_manager.h @@ -25,8 +25,8 @@ #include "input.h" -//#include #include +#include #include #if defined(VCLIB_RENDER_BACKEND_BGFX) @@ -56,8 +56,20 @@ class WidgetManager : #endif public: + /** + * @brief The ParentType is the type of the parent class. It is used to + * initialize the base class (if any). In the qt::WidgetManager, the parent + * class is the QWidget class. + */ using ParentType = QWidget; + /** + * @brief The WINDOW_MANAGER_ID is the ID of the window manager. It is used + * to identify the window manager implementation (if necessary) by the + * DerivedRenderer class. + */ + static const uint WINDOW_MANAGER_ID = WindowManagerId::QT_WIDGET; + WidgetManager(QWidget* parent = nullptr) : Base(parent) { static_assert( diff --git a/vclib/render/include/vclib/render/concepts/window_manager.h b/vclib/render/include/vclib/render/concepts/window_manager.h index c94e7d974..f606ce550 100644 --- a/vclib/render/include/vclib/render/concepts/window_manager.h +++ b/vclib/render/include/vclib/render/concepts/window_manager.h @@ -68,6 +68,14 @@ namespace vcl { * (e.g. Qt). If the parent object is not available, the type should be set to * `void`. * + * @par Static constants + * + * The class must have the following static constants: + * - `WINDOW_MANAGER_ID`: The ID of the window manager. It is used to identify + * the window manager implementation (if necessary) by the DerivedRenderer + * class. It must be a static constant of type `uint`. The value of the constant + * must be equal to one of the values of the @ref vcl::WindowManagerId struct. + * * @par Member functions * * The class must have the following member functions: @@ -92,6 +100,8 @@ concept WindowManagerConcept = uint u) { typename RemoveRef::ParentType; + { RemoveRef::WINDOW_MANAGER_ID } -> std::same_as; + RemoveRef(); RemoveRef(pPtr); RemoveRef(s, u, u); diff --git a/vclib/render/include/vclib/render/window_managers.h b/vclib/render/include/vclib/render/window_managers.h new file mode 100644 index 000000000..c0570ca1a --- /dev/null +++ b/vclib/render/include/vclib/render/window_managers.h @@ -0,0 +1,48 @@ +/***************************************************************************** + * VCLib * + * Visual Computing Library * + * * + * Copyright(C) 2021-2025 * + * Visual Computing Lab * + * ISTI - Italian National Research Council * + * * + * All rights reserved. * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the Mozilla Public License Version 2.0 as published * + * by the Mozilla Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * Mozilla Public License Version 2.0 * + * (https://www.mozilla.org/en-US/MPL/2.0/) for more details. * + ****************************************************************************/ + +#ifndef WINDOW_MANAGERS_H +#define WINDOW_MANAGERS_H + +namespace vcl { + +/** + * @brief The WindowManagerId struct enumerates the window managers that can be + * used to create and manage a window and its events. + * + * The window managers are identified by an unsigned integer value, that + * corresponds to a specific window manager implementation. + */ +struct WindowManagerId +{ + enum Enum { + GLFW_WINDOW, + QT_WIDGET, + // Additional window managers here + + WINDOW_MANAGERS_NUMBER + }; +}; + +} // namespace vcl + +#endif // WINDOW_MANAGERS_H