replace flags void* with std::shared_ptr
This commit is contained in:
@@ -190,7 +190,7 @@ void ParseFlags(const WidgetType& type, const std::string& flags,
|
|||||||
windowFlags |= flagMap[flag];
|
windowFlags |= flagMap[flag];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
attributes.flags = new ImGuiWindowFlags(windowFlags);
|
attributes.flags = std::make_unique<ImGuiWindowFlags>(windowFlags);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WidgetType::CollapsingHeader: {
|
case WidgetType::CollapsingHeader: {
|
||||||
@@ -216,7 +216,7 @@ void ParseFlags(const WidgetType& type, const std::string& flags,
|
|||||||
treeFlags |= flagMap[flag];
|
treeFlags |= flagMap[flag];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
attributes.flags = new ImGuiTreeNodeFlags(treeFlags);
|
attributes.flags = std::make_unique<ImGuiTreeNodeFlags>(treeFlags);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WidgetType::Table: {
|
case WidgetType::Table: {
|
||||||
@@ -263,7 +263,7 @@ void ParseFlags(const WidgetType& type, const std::string& flags,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Reserve data to the void* pointer and assign flags
|
// Reserve data to the void* pointer and assign flags
|
||||||
attributes.flags = new ImGuiTableFlags(tableFlags);
|
attributes.flags = std::make_unique<ImGuiTableFlags>(tableFlags);
|
||||||
} break;
|
} break;
|
||||||
case WidgetType::TableSetupColumn: {
|
case WidgetType::TableSetupColumn: {
|
||||||
static std::map<std::string, ImGuiTableColumnFlags> flagMap = {
|
static std::map<std::string, ImGuiTableColumnFlags> flagMap = {
|
||||||
@@ -295,7 +295,7 @@ void ParseFlags(const WidgetType& type, const std::string& flags,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Reserve data to the void* pointer and assign flags
|
// Reserve data to the void* pointer and assign flags
|
||||||
attributes.flags = new ImGuiTableColumnFlags(columnFlags);
|
attributes.flags = std::make_unique<ImGuiTableColumnFlags>(columnFlags);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -379,7 +379,7 @@ void Render(Node& node) {
|
|||||||
case WidgetType::Window: {
|
case WidgetType::Window: {
|
||||||
ImGuiWindowFlags flags = ImGuiWindowFlags_None;
|
ImGuiWindowFlags flags = ImGuiWindowFlags_None;
|
||||||
if (node.attributes.flags) {
|
if (node.attributes.flags) {
|
||||||
flags = *(ImGuiWindowFlags*)node.attributes.flags;
|
flags = *(ImGuiWindowFlags*)node.attributes.flags.get();
|
||||||
}
|
}
|
||||||
if (ImGui::Begin(node.attributes.title.c_str(), nullptr, flags)) {
|
if (ImGui::Begin(node.attributes.title.c_str(), nullptr, flags)) {
|
||||||
for (auto& child : node.children) {
|
for (auto& child : node.children) {
|
||||||
@@ -406,7 +406,7 @@ void Render(Node& node) {
|
|||||||
case WidgetType::CollapsingHeader: {
|
case WidgetType::CollapsingHeader: {
|
||||||
ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_None;
|
ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_None;
|
||||||
if (node.attributes.flags) {
|
if (node.attributes.flags) {
|
||||||
flags = *(ImGuiTreeNodeFlags*)node.attributes.flags;
|
flags = *(ImGuiTreeNodeFlags*)node.attributes.flags.get();
|
||||||
}
|
}
|
||||||
if (ImGui::CollapsingHeader(node.attributes.title.c_str(), flags)) {
|
if (ImGui::CollapsingHeader(node.attributes.title.c_str(), flags)) {
|
||||||
for (auto& child : node.children) {
|
for (auto& child : node.children) {
|
||||||
@@ -433,7 +433,7 @@ void Render(Node& node) {
|
|||||||
case WidgetType::Table: {
|
case WidgetType::Table: {
|
||||||
ImGuiTableFlags flags = ImGuiTableFlags_None;
|
ImGuiTableFlags flags = ImGuiTableFlags_None;
|
||||||
if (node.attributes.flags) {
|
if (node.attributes.flags) {
|
||||||
flags = *(ImGuiTableFlags*)node.attributes.flags;
|
flags = *(ImGuiTableFlags*)node.attributes.flags.get();
|
||||||
}
|
}
|
||||||
if (ImGui::BeginTable(node.attributes.id.c_str(), node.attributes.count,
|
if (ImGui::BeginTable(node.attributes.id.c_str(), node.attributes.count,
|
||||||
flags)) {
|
flags)) {
|
||||||
@@ -446,7 +446,7 @@ void Render(Node& node) {
|
|||||||
case WidgetType::TableSetupColumn: {
|
case WidgetType::TableSetupColumn: {
|
||||||
ImGuiTableColumnFlags flags = ImGuiTableColumnFlags_None;
|
ImGuiTableColumnFlags flags = ImGuiTableColumnFlags_None;
|
||||||
if (node.attributes.flags) {
|
if (node.attributes.flags) {
|
||||||
flags = *(ImGuiTableColumnFlags*)node.attributes.flags;
|
flags = *(ImGuiTableColumnFlags*)node.attributes.flags.get();
|
||||||
}
|
}
|
||||||
ImGui::TableSetupColumn(node.attributes.title.c_str(), flags);
|
ImGui::TableSetupColumn(node.attributes.title.c_str(), flags);
|
||||||
} break;
|
} break;
|
||||||
|
|||||||
@@ -5,7 +5,9 @@
|
|||||||
|
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <iostream>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -96,7 +98,7 @@ struct WidgetAttributes {
|
|||||||
int count = 0; // For Columns
|
int count = 0; // For Columns
|
||||||
ImVec2 size = ImVec2(0, 0); // For BeginChild
|
ImVec2 size = ImVec2(0, 0); // For BeginChild
|
||||||
bool* selected = nullptr; // For Selectable
|
bool* selected = nullptr; // For Selectable
|
||||||
void* flags = nullptr; // For Various
|
std::shared_ptr<void> flags = nullptr; // For Various
|
||||||
void* data = nullptr; // For Various
|
void* data = nullptr; // For Various
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user