forked from hoffstadt/DearPyGui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmvDebugWindow.cpp
More file actions
65 lines (53 loc) · 2 KB
/
mvDebugWindow.cpp
File metadata and controls
65 lines (53 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "mvDebugWindow.h"
#include "mvContext.h"
#include <misc/cpp/imgui_stdlib.h>
#include "mvItemRegistry.h"
#include "dearpygui.h"
mvDebugWindow::mvDebugWindow()
{
m_windowflags = ImGuiWindowFlags_NoSavedSettings;
m_width = 700;
m_height = 500;
for (const auto& item : GetModuleParsers())
m_commands.emplace_back(item.first, item.second.documentation);
}
void mvDebugWindow::drawWidgets()
{
static std::string commandstring;
ImGuiIO& io = ImGui::GetIO();
static size_t commandselection = 0;
const char* commanddoc = m_commands[commandselection].second.c_str();
static ImGuiTextFilter filter;
filter.Draw();
ImGui::PushItemWidth(-1);
ImGui::BeginChild("CommandsChild##debug", ImVec2(400.0f, 400.0f), ImGuiChildFlags_Border);
ImGui::PushStyleColor(ImGuiCol_Text, { 1.0f, 1.0f, 0.0f, 1.0f });
for (size_t i = 0; i < m_commands.size(); i++)
{
auto& item = m_commands[i];
if (filter.PassFilter(item.first.c_str()))
{
if (ImGui::Selectable(item.first.c_str(), i == commandselection))
commandselection = i;
}
}
ImGui::PopStyleColor();
ImGui::EndChild();
ImGui::SameLine();
ImGui::BeginChild("CommandsDoc##debug", ImVec2(-1.0f, 400.0f), ImGuiChildFlags_Border);
ImGui::PushStyleColor(ImGuiCol_Text, { 1.0f, 0.0f, 1.0f, 1.0f });
ImGui::PushTextWrapPos(500);
ImGui::Text("%s", commanddoc);
ImGui::PopStyleColor();
ImGui::PopTextWrapPos();
ImGui::EndChild();
ImGui::InputTextMultiline("Command##debug", &commandstring, ImVec2(-1, -50));
ImGui::PopItemWidth();
if (ImGui::Button("Run##debug"))
{
std::string command = "from dearpygui.dearpygui import *\nfrom dearpygui.demo import *\n" + commandstring;
mvSubmitCallback([=]() {
PyRun_SimpleString(command.c_str());
});
}
}