wip stream manager ui rework

This commit is contained in:
Green Sky 2024-09-19 13:43:39 +02:00
parent 8cdf2a2ca3
commit 9f62e01ab8
No known key found for this signature in database
2 changed files with 145 additions and 56 deletions

View File

@ -139,7 +139,7 @@ float DebugVideoTap::render(void) {
// list sources dropdown to connect too // list sources dropdown to connect too
std::string preview_label {"none"}; std::string preview_label {"none"};
if (static_cast<bool>(_selected_src)) { if (static_cast<bool>(_selected_src)) {
preview_label = std::to_string(entt::to_integral(_selected_src.entity())) + " (" + _selected_src.get<Components::StreamSource>().name + ")"; preview_label = std::to_string(entt::to_integral(entt::to_entity(_selected_src.entity()))) + " (" + _selected_src.get<Components::StreamSource>().name + ")";
} }
if (ImGui::BeginCombo("selected source", preview_label.c_str())) { if (ImGui::BeginCombo("selected source", preview_label.c_str())) {
@ -151,7 +151,7 @@ float DebugVideoTap::render(void) {
if (ss.frame_type_name != entt::type_name<SDLVideoFrame>::value()) { if (ss.frame_type_name != entt::type_name<SDLVideoFrame>::value()) {
continue; continue;
} }
std::string label = std::to_string(entt::to_integral(oc)) + " (" + ss.name + ")"; std::string label = std::to_string(entt::to_integral(entt::to_entity(oc))) + " (" + ss.name + ")";
if (ImGui::Selectable(label.c_str())) { if (ImGui::Selectable(label.c_str())) {
switchTo({_os.registry(), oc}); switchTo({_os.registry(), oc});
} }

View File

@ -20,20 +20,64 @@ void StreamManagerUI::render(void) {
ImGui::SeparatorText("Sources"); ImGui::SeparatorText("Sources");
// TODO: tables of id, button connect->to, name, type
// list sources // list sources
if (ImGui::BeginTable("sources_and_sinks", 4, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_BordersInnerV)) {
ImGui::TableSetupColumn("id");
ImGui::TableSetupColumn("name");
ImGui::TableSetupColumn("##conn");
ImGui::TableSetupColumn("type");
ImGui::TableHeadersRow();
for (const auto& [oc, ss] : _os.registry().view<Components::StreamSource>().each()) { for (const auto& [oc, ss] : _os.registry().view<Components::StreamSource>().each()) {
ImGui::Text("src %d (%s)[%s]", entt::to_integral(entt::to_entity(oc)), ss.name.c_str(), ss.frame_type_name.c_str()); //ImGui::Text("src %d (%s)[%s]", entt::to_integral(entt::to_entity(oc)), ss.name.c_str(), ss.frame_type_name.c_str());
ImGui::TableNextColumn();
ImGui::Text("%d", entt::to_integral(entt::to_entity(oc)));
const auto *ssrc = _os.registry().try_get<Components::StreamSource>(oc);
ImGui::TableNextColumn();
ImGui::TextUnformatted(ssrc!=nullptr?ssrc->name.c_str():"none");
ImGui::TableNextColumn();
if (ImGui::SmallButton("->")) {
// TODO: list type sinks
}
ImGui::TableNextColumn();
ImGui::TextUnformatted(ssrc!=nullptr?ssrc->frame_type_name.c_str():"???");
}
ImGui::EndTable();
} }
ImGui::SeparatorText("Sinks"); ImGui::SeparatorText("Sinks");
// list sinks // list sinks
for (const auto& [oc, ss] : _os.registry().view<Components::StreamSink>().each()) { if (ImGui::BeginTable("sources_and_sinks", 4, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_BordersInnerV)) {
ImGui::PushID(entt::to_integral(oc)); ImGui::TableSetupColumn("id");
ImGui::Text("sink %d (%s)[%s]", entt::to_integral(entt::to_entity(oc)), ss.name.c_str(), ss.frame_type_name.c_str()); ImGui::TableSetupColumn("name");
ImGui::TableSetupColumn("##conn");
ImGui::TableSetupColumn("type");
ImGui::TableHeadersRow();
for (const auto& [oc, ss] : _os.registry().view<Components::StreamSink>().each()) {
//ImGui::Text("sink %d (%s)[%s]", entt::to_integral(entt::to_entity(oc)), ss.name.c_str(), ss.frame_type_name.c_str());
//ImGui::PushID(entt::to_integral(oc));
ImGui::TableNextColumn();
ImGui::Text("%d", entt::to_integral(entt::to_entity(oc)));
const auto *ssink = _os.registry().try_get<Components::StreamSink>(oc);
ImGui::TableNextColumn();
ImGui::TextUnformatted(ssink!=nullptr?ssink->name.c_str():"none");
ImGui::TableNextColumn();
if (ImGui::SmallButton("->")) {
// TODO: list type sinks
}
if (ImGui::BeginPopupContextItem("sink_connect")) { if (ImGui::BeginPopupContextItem("sink_connect")) {
if (ImGui::BeginMenu("connect video", ss.frame_type_name == entt::type_name<SDLVideoFrame>::value())) { if (ImGui::BeginMenu("connect video", ss.frame_type_name == entt::type_name<SDLVideoFrame>::value())) {
for (const auto& [oc_src, s_src] : _os.registry().view<Components::StreamSource>().each()) { for (const auto& [oc_src, s_src] : _os.registry().view<Components::StreamSource>().each()) {
@ -86,16 +130,61 @@ void StreamManagerUI::render(void) {
} }
ImGui::EndPopup(); ImGui::EndPopup();
} }
ImGui::PopID();
ImGui::TableNextColumn();
ImGui::TextUnformatted(ssink!=nullptr?ssink->frame_type_name.c_str():"???");
//ImGui::PopID();
}
ImGui::EndTable();
} }
ImGui::SeparatorText("Connections"); ImGui::SeparatorText("Connections");
// TODO: table of id, button disconnect, context x->y, from name, to name, type?
// list connections // list connections
if (ImGui::BeginTable("connections", 6, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_BordersInnerV)) {
ImGui::TableSetupColumn("##id"); // TODO: remove?
ImGui::TableSetupColumn("##disco");
ImGui::TableSetupColumn("##qdesc");
ImGui::TableSetupColumn("from");
ImGui::TableSetupColumn("to");
ImGui::TableSetupColumn("type");
ImGui::TableHeadersRow();
for (const auto& con : _sm._connections) { for (const auto& con : _sm._connections) {
ImGui::Text("con %d->%d", entt::to_integral(entt::to_entity(con->src.entity())), entt::to_integral(entt::to_entity(con->sink.entity()))); //ImGui::Text("con %d->%d", entt::to_integral(entt::to_entity(con->src.entity())), entt::to_integral(entt::to_entity(con->sink.entity())));
ImGui::TableNextColumn();
ImGui::Text("%d", -1); // do connections have ids?
ImGui::TableNextColumn();
if (ImGui::SmallButton("X")) {
// TODO: disconnect
}
ImGui::TableNextColumn();
ImGui::Text("%d->%d", entt::to_integral(entt::to_entity(con->src.entity())), entt::to_integral(entt::to_entity(con->sink.entity())));
const auto *ssrc = con->src.try_get<Components::StreamSource>();
ImGui::TableNextColumn();
ImGui::TextUnformatted(ssrc!=nullptr?ssrc->name.c_str():"none");
const auto *ssink = con->sink.try_get<Components::StreamSink>();
ImGui::TableNextColumn();
ImGui::TextUnformatted(ssink!=nullptr?ssink->name.c_str():"none");
ImGui::TableNextColumn();
ImGui::TextUnformatted(
(ssrc!=nullptr)?
ssrc->frame_type_name.c_str():
(ssink!=nullptr)?
ssink->frame_type_name.c_str()
:"???"
);
}
ImGui::EndTable();
} }
} }
ImGui::End(); ImGui::End();