diff options
author | Clifford Wolf <clifford@clifford.at> | 2018-11-09 12:57:14 +0100 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2018-11-09 12:57:14 +0100 |
commit | 66dd17664c08aca17b53d2853558121aa9e702e4 (patch) | |
tree | b6bc5dd919e5f525ec7328861b81f616673a1ea6 /3rdparty/qtimgui/QtImGui.cpp | |
parent | e91241f10d68fcaaf0a81fa77e9a91666120ccee (diff) | |
parent | 15d9b3d3cc05656e58d01ba2f97ec92b6daaee1c (diff) | |
download | nextpnr-66dd17664c08aca17b53d2853558121aa9e702e4.tar.gz nextpnr-66dd17664c08aca17b53d2853558121aa9e702e4.tar.bz2 nextpnr-66dd17664c08aca17b53d2853558121aa9e702e4.zip |
Merge branch 'master' of github.com:YosysHQ/nextpnr into router_improve
Diffstat (limited to '3rdparty/qtimgui/QtImGui.cpp')
-rw-r--r-- | 3rdparty/qtimgui/QtImGui.cpp | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/3rdparty/qtimgui/QtImGui.cpp b/3rdparty/qtimgui/QtImGui.cpp new file mode 100644 index 00000000..6f5b0480 --- /dev/null +++ b/3rdparty/qtimgui/QtImGui.cpp @@ -0,0 +1,78 @@ +#include "QtImGui.h" +#include "ImGuiRenderer.h" +#include <QWindow> +#ifdef QT_WIDGETS_LIB +#include <QWidget> +#endif + +namespace QtImGui { + +#ifdef QT_WIDGETS_LIB + +namespace { + +class QWidgetWindowWrapper : public WindowWrapper { +public: + QWidgetWindowWrapper(QWidget *w) : w(w) {} + void installEventFilter(QObject *object) override { + return w->installEventFilter(object); + } + QSize size() const override { + return w->size(); + } + qreal devicePixelRatio() const override { + return w->devicePixelRatio(); + } + bool isActive() const override { + return w->isActiveWindow(); + } + QPoint mapFromGlobal(const QPoint &p) const override { + return w->mapFromGlobal(p); + } +private: + QWidget *w; +}; + +} + +void initialize(QWidget *window) { + ImGuiRenderer::instance()->initialize(new QWidgetWindowWrapper(window)); +} + +#endif + +namespace { + +class QWindowWindowWrapper : public WindowWrapper { +public: + QWindowWindowWrapper(QWindow *w) : w(w) {} + void installEventFilter(QObject *object) override { + return w->installEventFilter(object); + } + QSize size() const override { + return w->size(); + } + qreal devicePixelRatio() const override { + return w->devicePixelRatio(); + } + bool isActive() const override { + return w->isActive(); + } + QPoint mapFromGlobal(const QPoint &p) const override { + return w->mapFromGlobal(p); + } +private: + QWindow *w; +}; + +} + +void initialize(QWindow *window) { + ImGuiRenderer::instance()->initialize(new QWindowWindowWrapper(window)); +} + +void newFrame() { + ImGuiRenderer::instance()->newFrame(); +} + +} |