#include "./object_store_ui.hpp" #include #include #include #include "./os_comps.hpp" #include namespace MM { template<> void ComponentEditorWidget(entt::basic_registry& registry, Object entity) { auto& c = registry.get(entity); const auto str = bin2hex(c.v); if (ImGui::SmallButton("copy")) { ImGui::SetClipboardText(str.c_str()); } ImGui::SameLine(); ImGui::TextUnformatted(str.c_str()); } #if 0 template<> void ComponentEditorWidget(entt::basic_registry& registry, Object entity) { auto& c = registry.get(entity); ImGui::Text("Total size: %lu", c.total_size); if (ImGui::BeginTable("file list", 2, ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_SizingFixedFit)) { ImGui::TableSetupColumn("name", ImGuiTableColumnFlags_WidthStretch); ImGui::TableSetupColumn("size", ImGuiTableColumnFlags_WidthFixed); ImGui::TableHeadersRow(); for (const auto& entry : c.file_list) { ImGui::TableNextColumn(); ImGui::TextUnformatted(entry.file_name.c_str()); ImGui::TableNextColumn(); ImGui::Text("%lu", entry.file_size); } ImGui::EndTable(); } } template<> void ComponentEditorWidget(entt::basic_registry& registry, Object entity) { auto& c = registry.get(entity); if (ImGui::BeginTable("file list", 1, ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_SizingFixedFit)) { ImGui::TableSetupColumn("name", ImGuiTableColumnFlags_WidthStretch); //ImGui::TableSetupColumn("size", ImGuiTableColumnFlags_WidthFixed); ImGui::TableHeadersRow(); for (const auto& entry : c.file_list) { ImGui::TableNextColumn(); ImGui::TextUnformatted(entry.c_str()); } ImGui::EndTable(); } } #endif template<> void ComponentEditorWidget(entt::basic_registry& registry, Object entity) { auto& c = registry.get(entity); if (!c.file_name.empty()) { ImGui::Text("file name: %s", c.file_name.c_str()); } ImGui::Text("file size: %lu", c.file_size); } template<> void ComponentEditorWidget(entt::basic_registry& registry, Object entity) { auto& c = registry.get(entity); if (!c.file_path.empty()) { ImGui::Text("file path: %s", c.file_path.c_str()); } } template<> void ComponentEditorWidget(entt::basic_registry& registry, Object entity) { auto& c = registry.get(entity); ImGui::Text("upload rate : %.1f bytes/s", c.rate_up); ImGui::Text("download rate: %.1f bytes/s", c.rate_down); ImGui::Text("total bytes uploaded : %lu bytes", c.total_up); ImGui::Text("total bytes downloaded: %lu bytes", c.total_down); } } // MM ObjectStoreUI::ObjectStoreUI( ObjectStore2& os ) : _os(os) { _ee.show_window = false; _ee.registerComponent("ID"); _ee.registerComponent("DataCompressionType"); _ee.registerComponent("Ephemeral::FilePath"); _ee.registerComponent("File::SingleInfo"); _ee.registerComponent("File::SingleInfoLocal"); _ee.registerComponent("File::Collection"); _ee.registerComponent("File::CollectionInfo"); _ee.registerComponent("File::CollectionInfoLocal"); _ee.registerComponent("File::LocalHaveBitset"); _ee.registerComponent("File::RemoteHaveBitset"); _ee.registerComponent("Ephemeral::File::DownloadPriority"); _ee.registerComponent("Ephemeral::File::ReadHeadHint"); _ee.registerComponent("Ephemeral::File::TransferStats"); _ee.registerComponent("Ephemeral::File::TransferStatsSeparated"); } void ObjectStoreUI::render(void) { { // main window menubar injection // assumes the window "tomato" was rendered already by cg if (ImGui::Begin("tomato")) { if (ImGui::BeginMenuBar()) { ImGui::Separator(); if (ImGui::BeginMenu("ObjectStore")) { if (ImGui::MenuItem("Inspector")) { _ee.show_window = true; } ImGui::EndMenu(); } ImGui::EndMenuBar(); } } ImGui::End(); } static Object selected_ent {entt::null}; _ee.renderSimpleCombo(_os.registry(), selected_ent); }