diff options
author | Miodrag Milanović <mmicko@gmail.com> | 2018-10-26 17:27:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-26 17:27:47 +0200 |
commit | 757dcd2a5277ef65d9ce4ff7b118e6072edbb71a (patch) | |
tree | 27c31559c02d6fb8e57d032f54daf190591e61e0 /3rdparty/qtimgui/QtImGui.cpp | |
parent | 40a8e17db63ec0fea417f6fc1b1711ddbdec5330 (diff) | |
parent | 62a615a17d9b69f3b727d59ed13e297ace610778 (diff) | |
download | nextpnr-757dcd2a5277ef65d9ce4ff7b118e6072edbb71a.tar.gz nextpnr-757dcd2a5277ef65d9ce4ff7b118e6072edbb71a.tar.bz2 nextpnr-757dcd2a5277ef65d9ce4ff7b118e6072edbb71a.zip |
Merge pull request #96 from YosysHQ/imgui
Imgui integration
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(); +} + +} |