mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 19:50:05 +00:00
Add imgui debug window, still need to use unique contexts
This commit is contained in:
parent
b18692657a
commit
cd01bb70b6
10 changed files with 325 additions and 3 deletions
45
scwx-qt/source/scwx/qt/ui/imgui_debug_dialog.cpp
Normal file
45
scwx-qt/source/scwx/qt/ui/imgui_debug_dialog.cpp
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
#include "imgui_debug_dialog.hpp"
|
||||
#include "ui_imgui_debug_dialog.h"
|
||||
|
||||
#include <scwx/qt/ui/imgui_debug_widget.hpp>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
namespace ui
|
||||
{
|
||||
|
||||
static const std::string logPrefix_ = "scwx::qt::ui::imgui_debug_dialog";
|
||||
|
||||
class ImGuiDebugDialogImpl
|
||||
{
|
||||
public:
|
||||
explicit ImGuiDebugDialogImpl() : imGuiDebugWidget_ {nullptr} {}
|
||||
~ImGuiDebugDialogImpl() = default;
|
||||
|
||||
ImGuiDebugWidget* imGuiDebugWidget_;
|
||||
};
|
||||
|
||||
ImGuiDebugDialog::ImGuiDebugDialog(QWidget* parent) :
|
||||
QDialog(parent),
|
||||
p {std::make_unique<ImGuiDebugDialogImpl>()},
|
||||
ui(new Ui::ImGuiDebugDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// ImGui Debug Widget
|
||||
p->imGuiDebugWidget_ = new ImGuiDebugWidget(this);
|
||||
p->imGuiDebugWidget_->setSizePolicy(QSizePolicy::Policy::Expanding,
|
||||
QSizePolicy::Policy::Expanding);
|
||||
ui->verticalLayout->insertWidget(0, p->imGuiDebugWidget_);
|
||||
}
|
||||
|
||||
ImGuiDebugDialog::~ImGuiDebugDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
36
scwx-qt/source/scwx/qt/ui/imgui_debug_dialog.hpp
Normal file
36
scwx-qt/source/scwx/qt/ui/imgui_debug_dialog.hpp
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ImGuiDebugDialog;
|
||||
}
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
namespace ui
|
||||
{
|
||||
|
||||
class ImGuiDebugDialogImpl;
|
||||
|
||||
class ImGuiDebugDialog : public QDialog
|
||||
{
|
||||
private:
|
||||
Q_DISABLE_COPY(ImGuiDebugDialog)
|
||||
|
||||
public:
|
||||
explicit ImGuiDebugDialog(QWidget* parent = nullptr);
|
||||
~ImGuiDebugDialog();
|
||||
|
||||
private:
|
||||
friend class ImGuiDebugDialogImpl;
|
||||
std::unique_ptr<ImGuiDebugDialogImpl> p;
|
||||
Ui::ImGuiDebugDialog* ui;
|
||||
};
|
||||
|
||||
} // namespace ui
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
104
scwx-qt/source/scwx/qt/ui/imgui_debug_dialog.ui
Normal file
104
scwx-qt/source/scwx/qt/ui/imgui_debug_dialog.ui
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ImGuiDebugDialog</class>
|
||||
<widget class="QDialog" name="ImGuiDebugDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>570</width>
|
||||
<height>760</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>ImGui Debug</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QFrame" name="bottomFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="contextLabel">
|
||||
<property name="text">
|
||||
<string>Context</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="contextComboBox"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>ImGuiDebugDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>ImGuiDebugDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
56
scwx-qt/source/scwx/qt/ui/imgui_debug_widget.cpp
Normal file
56
scwx-qt/source/scwx/qt/ui/imgui_debug_widget.cpp
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#include <scwx/qt/ui/imgui_debug_widget.hpp>
|
||||
|
||||
#include <imgui.h>
|
||||
#include <backends/imgui_impl_opengl3.h>
|
||||
#include <backends/imgui_impl_qt.hpp>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
namespace ui
|
||||
{
|
||||
|
||||
static const std::string logPrefix_ = "scwx::qt::ui::imgui_debug_widget";
|
||||
|
||||
class ImGuiDebugWidgetImpl
|
||||
{
|
||||
public:
|
||||
explicit ImGuiDebugWidgetImpl(ImGuiDebugWidget* self) : self_ {self}
|
||||
{
|
||||
// ImGui Configuration
|
||||
auto& io = ImGui::GetIO();
|
||||
|
||||
// Initialize Qt backend
|
||||
ImGui_ImplQt_RegisterWidget(self_);
|
||||
}
|
||||
~ImGuiDebugWidgetImpl() {}
|
||||
|
||||
ImGuiDebugWidget* self_;
|
||||
};
|
||||
|
||||
ImGuiDebugWidget::ImGuiDebugWidget(QWidget* parent) :
|
||||
QOpenGLWidget(parent), p {std::make_unique<ImGuiDebugWidgetImpl>(this)}
|
||||
{
|
||||
}
|
||||
|
||||
void ImGuiDebugWidget::initializeGL() {}
|
||||
|
||||
void ImGuiDebugWidget::paintGL()
|
||||
{
|
||||
ImGui_ImplQt_NewFrame(this);
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
|
||||
ImGui::NewFrame();
|
||||
|
||||
ImGui::ShowDemoWindow();
|
||||
|
||||
ImGui::Render();
|
||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||
}
|
||||
|
||||
ImGuiDebugWidget::~ImGuiDebugWidget() {}
|
||||
|
||||
} // namespace ui
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
38
scwx-qt/source/scwx/qt/ui/imgui_debug_widget.hpp
Normal file
38
scwx-qt/source/scwx/qt/ui/imgui_debug_widget.hpp
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#pragma once
|
||||
|
||||
#include <QOpenGLWidget>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ImGuiDebugWidget;
|
||||
}
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
namespace ui
|
||||
{
|
||||
|
||||
class ImGuiDebugWidgetImpl;
|
||||
|
||||
class ImGuiDebugWidget : public QOpenGLWidget
|
||||
{
|
||||
private:
|
||||
Q_DISABLE_COPY(ImGuiDebugWidget)
|
||||
|
||||
public:
|
||||
explicit ImGuiDebugWidget(QWidget* parent = nullptr);
|
||||
~ImGuiDebugWidget();
|
||||
|
||||
void initializeGL() override;
|
||||
void paintGL() override;
|
||||
|
||||
private:
|
||||
friend class ImGuiDebugWidgetImpl;
|
||||
std::unique_ptr<ImGuiDebugWidgetImpl> p;
|
||||
};
|
||||
|
||||
} // namespace ui
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
Loading…
Add table
Add a link
Reference in a new issue