|
@@ -8,18 +8,26 @@
|
|
|
#include <vector>
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "saura/cmd/sandbox/client/client.hpp"
|
|
#include "saura/cmd/sandbox/client/client.hpp"
|
|
|
|
|
+#include "saura/cmd/sandbox/folder/folder.hpp"
|
|
|
#include "server/server.hpp"
|
|
#include "server/server.hpp"
|
|
|
|
|
|
|
|
namespace saura {
|
|
namespace saura {
|
|
|
struct SandboxApp : AppBase {
|
|
struct SandboxApp : AppBase {
|
|
|
std::shared_ptr<ServerAPI> server_api_ctx;
|
|
std::shared_ptr<ServerAPI> server_api_ctx;
|
|
|
std::vector<ClientInfo> clients;
|
|
std::vector<ClientInfo> clients;
|
|
|
|
|
+ Folder category_root;
|
|
|
|
|
|
|
|
void start() override {
|
|
void start() override {
|
|
|
spdlog::info("Sandbox start!");
|
|
spdlog::info("Sandbox start!");
|
|
|
|
|
|
|
|
this->server_api_ctx = std::make_shared<ServerAPI>();
|
|
this->server_api_ctx = std::make_shared<ServerAPI>();
|
|
|
this->clients = server_api_ctx->fetch_clients(10, 0);
|
|
this->clients = server_api_ctx->fetch_clients(10, 0);
|
|
|
|
|
+
|
|
|
|
|
+ category_root = Folder("root");
|
|
|
|
|
+ category_root.add("A");
|
|
|
|
|
+ category_root.add("B");
|
|
|
|
|
+ category_root.add("C");
|
|
|
|
|
+ category_root.print();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void update(double dt) override {
|
|
void update(double dt) override {
|
|
@@ -33,15 +41,92 @@ struct SandboxApp : AppBase {
|
|
|
ImGui::Text("%s", this->get_title().c_str());
|
|
ImGui::Text("%s", this->get_title().c_str());
|
|
|
|
|
|
|
|
if (ImGui::BeginTabBar("Tabs")) {
|
|
if (ImGui::BeginTabBar("Tabs")) {
|
|
|
- // Tab 1
|
|
|
|
|
- if (ImGui::BeginTabItem(u8"Главная")) {
|
|
|
|
|
|
|
+ if (ImGui::BeginTabItem("Главная")) {
|
|
|
ImGui::Text("Welcome to Tab 1 content!");
|
|
ImGui::Text("Welcome to Tab 1 content!");
|
|
|
ImGui::Button("Click me in Tab 1");
|
|
ImGui::Button("Click me in Tab 1");
|
|
|
ImGui::EndTabItem();
|
|
ImGui::EndTabItem();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // Tab 2
|
|
|
|
|
- if (ImGui::BeginTabItem(u8"Клиенты")) {
|
|
|
|
|
|
|
+ if (ImGui::BeginTabItem("Категории")) {
|
|
|
|
|
+ static bool req_open_ppm = false;
|
|
|
|
|
+ static bool is_add_node = false;
|
|
|
|
|
+ static int32_t selected_node = -1;
|
|
|
|
|
+
|
|
|
|
|
+ if (ImGui::TreeNodeEx("Root Node", 0)) {
|
|
|
|
|
+ if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) {
|
|
|
|
|
+ req_open_ppm = true;
|
|
|
|
|
+ selected_node = -1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < category_root.children.size(); i++) {
|
|
|
|
|
+ auto &category = category_root.children[i];
|
|
|
|
|
+
|
|
|
|
|
+ ImGuiTreeNodeFlags node_flags = ImGuiTreeNodeFlags_OpenOnArrow |
|
|
|
|
|
+ ImGuiTreeNodeFlags_SpanAvailWidth;
|
|
|
|
|
+ bool open = ImGui::TreeNodeEx((void *)(intptr_t)(i), node_flags,
|
|
|
|
|
+ "%s", category.name.c_str());
|
|
|
|
|
+
|
|
|
|
|
+ if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) {
|
|
|
|
|
+ spdlog::info("Clieked: {}", i);
|
|
|
|
|
+
|
|
|
|
|
+ req_open_ppm = true;
|
|
|
|
|
+ selected_node = i;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (open) {
|
|
|
|
|
+ ImGui::TreePop();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ ImGui::TreePop();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (req_open_ppm) {
|
|
|
|
|
+ req_open_ppm = false;
|
|
|
|
|
+ ImGui::OpenPopup("category/ppm");
|
|
|
|
|
+ ImGui::SetNextWindowPos(
|
|
|
|
|
+ {ImGui::GetMousePos().x, ImGui::GetMousePos().y});
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (ImGui::BeginPopupModal("category/ppm", nullptr,
|
|
|
|
|
+
|
|
|
|
|
+ ImGuiWindowFlags_NoMove |
|
|
|
|
|
+ ImGuiWindowFlags_NoSavedSettings |
|
|
|
|
|
+ ImGuiWindowFlags_AlwaysAutoResize |
|
|
|
|
|
+ ImGuiWindowFlags_NoDecoration)) {
|
|
|
|
|
+ if (!is_add_node) {
|
|
|
|
|
+ if (ImGui::Button("Создать", ImVec2(120, 0))) {
|
|
|
|
|
+ is_add_node = true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (selected_node != -1 &&
|
|
|
|
|
+ ImGui::Button("Удалить", ImVec2(120, 0))) {
|
|
|
|
|
+ category_root.remove_at(selected_node);
|
|
|
|
|
+ ImGui::CloseCurrentPopup();
|
|
|
|
|
+ selected_node = -1;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ static char buf[1024] = {};
|
|
|
|
|
+
|
|
|
|
|
+ ImGui::InputText("Name", buf, sizeof(buf));
|
|
|
|
|
+
|
|
|
|
|
+ if (ImGui::Button("Создать", ImVec2(120, 0))) {
|
|
|
|
|
+ category_root.add(std::string(buf));
|
|
|
|
|
+ is_add_node = false;
|
|
|
|
|
+ ImGui::CloseCurrentPopup();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (ImGui::Button("Отмена", ImVec2(120, 0))) {
|
|
|
|
|
+ is_add_node = false;
|
|
|
|
|
+ ImGui::CloseCurrentPopup();
|
|
|
|
|
+ }
|
|
|
|
|
+ ImGui::EndPopup();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ImGui::EndTabItem();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (ImGui::BeginTabItem("Клиенты")) {
|
|
|
ImGuiTableFlags flags =
|
|
ImGuiTableFlags flags =
|
|
|
ImGuiTableFlags_Resizable | ImGuiTableFlags_Borders |
|
|
ImGuiTableFlags_Resizable | ImGuiTableFlags_Borders |
|
|
|
ImGuiTableFlags_SizingStretchProp | ImGuiTableFlags_ScrollY;
|
|
ImGuiTableFlags_SizingStretchProp | ImGuiTableFlags_ScrollY;
|
|
@@ -74,12 +159,9 @@ struct SandboxApp : AppBase {
|
|
|
ImGui::Separator();
|
|
ImGui::Separator();
|
|
|
|
|
|
|
|
if (ImGui::Button("Close", ImVec2(120, 0))) {
|
|
if (ImGui::Button("Close", ImVec2(120, 0))) {
|
|
|
- ImGui::CloseCurrentPopup(); // Function to close the currently
|
|
|
|
|
- // open popup
|
|
|
|
|
|
|
+ ImGui::CloseCurrentPopup();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- ImGui::EndPopup(); // Must be called if BeginPopupModal returned
|
|
|
|
|
- // true
|
|
|
|
|
|
|
+ ImGui::EndPopup();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (ImGui::BeginTable("MyDataTable", 9, flags)) {
|
|
if (ImGui::BeginTable("MyDataTable", 9, flags)) {
|
|
@@ -152,8 +234,7 @@ struct SandboxApp : AppBase {
|
|
|
ImGui::EndTabItem();
|
|
ImGui::EndTabItem();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // Tab 3
|
|
|
|
|
- if (ImGui::BeginTabItem(u8"Настройки")) {
|
|
|
|
|
|
|
+ if (ImGui::BeginTabItem("Настройки")) {
|
|
|
ImGui::Text("Hello from the third tab.");
|
|
ImGui::Text("Hello from the third tab.");
|
|
|
ImGui::EndTabItem();
|
|
ImGui::EndTabItem();
|
|
|
}
|
|
}
|