9 #define FORCE_HIDE_WINDOW 0
10 #define NDEVR_SPECIAL_GRAPHICS_WINDOW 1
11 #define USE_WINDOW_WIDGET 0
13 typedef QFrame BaseWindowContainer;
14#elif defined(Q_OS_WASM)
16 #define FORCE_HIDE_WINDOW 0
17 #define USE_WINDOW_WIDGET 0
18 #define NDEVR_SPECIAL_GRAPHICS_WINDOW 0
19 typedef QFrame BaseWindowContainer;
22 #define FORCE_HIDE_WINDOW 0
23 #define USE_WINDOW_WIDGET 0
24 #define NDEVR_SPECIAL_GRAPHICS_WINDOW 1
25 typedef QFrame BaseWindowContainer;
42 : BaseWindowContainer(parent)
63 m_window->setVisible(QWindow::Visibility::Hidden);
70 return Qt::WindowFlags();
73 return Qt::WindowFlags();
74 #elif defined(Q_OS_WASM)
75 return Qt::WindowFlags(Qt::WindowStaysOnBottomHint | Qt::Widget | Qt::WindowDoesNotAcceptFocus);
77 return Qt::WindowFlags();
87 return mapToGlobal(QPoint(0, 0));
107#if NDEVR_SPECIAL_GRAPHICS_WINDOW
108 QHBoxLayout* layout =
new QHBoxLayout();
109 layout->setContentsMargins(0, 0, 0, 0);
114#if NDEVR_SPECIAL_GRAPHICS_WINDOW
134 m_window->setVisible(QWindow::Visibility::Hidden);
135#if NDEVR_SPECIAL_GRAPHICS_WINDOW
136 QHBoxLayout* layout =
new QHBoxLayout();
137 layout->setContentsMargins(0, 0, 0, 0);
143#if NDEVR_SPECIAL_GRAPHICS_WINDOW
155#if !NDEVR_SPECIAL_GRAPHICS_WINDOW
169#if !NDEVR_SPECIAL_GRAPHICS_WINDOW
197 BaseWindowContainer::paintEvent(
event);
203#if !NDEVR_SPECIAL_GRAPHICS_WINDOW
226 QEvent::Type event_type =
event->type();
233 m_window->setVisibility(QWindow::Visibility::Windowed);
239 m_window->setVisibility(QWindow::Visibility::Hidden);
247 return BaseWindowContainer::event(
event);
258 void setVisible(
bool visible)
override
260 BaseWindowContainer::setVisible(visible);
264 m_window->setVisible(visible ? QWindow::Visibility::Windowed
265 : QWindow::Visibility::Hidden);
269 void resizeEvent(QResizeEvent* resize_event)
override
271 BaseWindowContainer::resizeEvent(resize_event);
272 QSize s = resize_event->size();
A (hacky) class for storing a window into a container.
QPoint windowOffset() const
Returns the global position offset for the embedded window.
void setWindow(QWindow *window)
Sets a QWindow as the contained window, wrapping it in a QWidget container.
bool event(QEvent *event) override
Handles show/hide events and forwards all events to the optional event forwarder.
QWindow * m_window
The embedded QWindow, if set via setWindow().
static Qt::WindowFlags windowFlags()
Returns the platform-specific window flags for the embedded window.
void setWidget(QWidget *window)
Sets a QWidget as the contained child widget.
virtual void updateSize()
Updates the geometry of the embedded container to match this widget's size and position.
QSize m_last_paint_size
The size at the last paint event, used for incremental repainting.
QWidget * m_container
The QWidget wrapping the embedded window or set directly via setWidget().
WindowContainer(QWidget *parent=nullptr)
Constructs a WindowContainer with an optional parent.
void visibleHack()
Workaround to force proper visibility of the embedded window on some platforms.
QTimer * m_location_timer
Timer used on some platforms to poll and update window position.
void paintEvent(QPaintEvent *event) override
Handles paint events, updating the embedded window size on non-special-window platforms.
std::function< bool(QEvent *event)> m_event_forwarder
Optional callback that receives all events for custom handling.
void setEventForwarder(const std::function< bool(QEvent *event)> &forwarder)
Sets a callback function that receives all events for custom processing.
The primary namespace for the NDEVR SDK.