Skip to content

Commit

Permalink
[render] add WINDOW_MANAGER_ID to all Window Managers
Browse files Browse the repository at this point in the history
  • Loading branch information
alemuntoni committed Jan 8, 2025
1 parent 934dfc5 commit 4a3aa67
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 4 deletions.
13 changes: 10 additions & 3 deletions vclib/render/include/vclib/glfw/window_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

#include "input.h"

// #include <vclib/render/interfaces/event_manager_i.h>
#include <vclib/render/concepts/renderer.h>
#include <vclib/render/window_managers.h>
#include <vclib/space/core/point.h>

#if defined(__linux__)
Expand Down Expand Up @@ -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)
{
Expand Down
14 changes: 13 additions & 1 deletion vclib/render/include/vclib/qt/widget_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

#include "input.h"

//#include <vclib/render/interfaces/event_manager_i.h>
#include <vclib/render/concepts/renderer.h>
#include <vclib/render/window_managers.h>
#include <vclib/space/core/point.h>

#if defined(VCLIB_RENDER_BACKEND_BGFX)
Expand Down Expand Up @@ -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(
Expand Down
10 changes: 10 additions & 0 deletions vclib/render/include/vclib/render/concepts/window_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -92,6 +100,8 @@ concept WindowManagerConcept =
uint u) {
typename RemoveRef<T>::ParentType;

{ RemoveRef<T>::WINDOW_MANAGER_ID } -> std::same_as<const uint&>;

RemoveRef<T>();
RemoveRef<T>(pPtr);
RemoveRef<T>(s, u, u);
Expand Down
48 changes: 48 additions & 0 deletions vclib/render/include/vclib/render/window_managers.h
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 4a3aa67

Please sign in to comment.