fix audo connection for sinks and add a try catch block for the file sorting

This commit is contained in:
Green Sky 2024-09-29 18:24:34 +02:00
parent ce6febdc29
commit 28be54ac97
No known key found for this signature in database
3 changed files with 55 additions and 51 deletions

View File

@ -111,56 +111,60 @@ void FileSelector::render(void) {
}
}
// do sorting here
// TODO: cache the result (lol)
if (ImGuiTableSortSpecs* sorts_specs = ImGui::TableGetSortSpecs(); sorts_specs != nullptr && sorts_specs->SpecsCount >= 1) {
switch (static_cast<SortID>(sorts_specs->Specs->ColumnUserID)) {
break; case SortID::name:
if (sorts_specs->Specs->SortDirection == ImGuiSortDirection_Descending) {
std::sort(dirs.begin(), dirs.end(), [](const auto& a, const auto& b) -> bool {
return a.path() < b.path();
});
std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool {
return a.path().filename() < b.path().filename();
});
} else {
std::sort(dirs.begin(), dirs.end(), [](const auto& a, const auto& b) -> bool {
return a.path() > b.path();
});
std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool {
return a.path().filename() > b.path().filename();
});
}
break; case SortID::size:
if (sorts_specs->Specs->SortDirection == ImGuiSortDirection_Descending) {
// TODO: sort dirs?
std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool {
return a.file_size() < b.file_size();
});
} else {
// TODO: sort dirs?
std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool {
return a.file_size() > b.file_size();
});
}
break; case SortID::date:
if (sorts_specs->Specs->SortDirection == ImGuiSortDirection_Descending) {
std::sort(dirs.begin(), dirs.end(), [](const auto& a, const auto& b) -> bool {
return a.last_write_time() < b.last_write_time();
});
std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool {
return a.last_write_time() < b.last_write_time();
});
} else {
std::sort(dirs.begin(), dirs.end(), [](const auto& a, const auto& b) -> bool {
return a.last_write_time() > b.last_write_time();
});
std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool {
return a.last_write_time() > b.last_write_time();
});
}
break; default: ;
try {
// do sorting here
// TODO: cache the result (lol)
if (ImGuiTableSortSpecs* sorts_specs = ImGui::TableGetSortSpecs(); sorts_specs != nullptr && sorts_specs->SpecsCount >= 1) {
switch (static_cast<SortID>(sorts_specs->Specs->ColumnUserID)) {
break; case SortID::name:
if (sorts_specs->Specs->SortDirection == ImGuiSortDirection_Descending) {
std::sort(dirs.begin(), dirs.end(), [](const auto& a, const auto& b) -> bool {
return a.path() < b.path();
});
std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool {
return a.path().filename() < b.path().filename();
});
} else {
std::sort(dirs.begin(), dirs.end(), [](const auto& a, const auto& b) -> bool {
return a.path() > b.path();
});
std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool {
return a.path().filename() > b.path().filename();
});
}
break; case SortID::size:
if (sorts_specs->Specs->SortDirection == ImGuiSortDirection_Descending) {
// TODO: sort dirs?
std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool {
return a.file_size() < b.file_size();
});
} else {
// TODO: sort dirs?
std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool {
return a.file_size() > b.file_size();
});
}
break; case SortID::date:
if (sorts_specs->Specs->SortDirection == ImGuiSortDirection_Descending) {
std::sort(dirs.begin(), dirs.end(), [](const auto& a, const auto& b) -> bool {
return a.last_write_time() < b.last_write_time();
});
std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool {
return a.last_write_time() < b.last_write_time();
});
} else {
std::sort(dirs.begin(), dirs.end(), [](const auto& a, const auto& b) -> bool {
return a.last_write_time() > b.last_write_time();
});
std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) -> bool {
return a.last_write_time() > b.last_write_time();
});
}
break; default: ;
}
}
} catch (...) {
// we likely saw a file disapear
}
for (auto const& dir_entry : dirs) {

View File

@ -168,7 +168,7 @@ bool StreamManager::onEvent(const ObjectStore::Events::ObjectConstruct& e) {
auto it_d_src = _default_sources.find(e.e.get<Components::StreamSink>().frame_type_name);
if (it_d_src != _default_sources.cend()) {
// TODO: threaded
connect(e.e, it_d_src->second);
connect(it_d_src->second, e.e);
}
}
}

View File

@ -126,7 +126,7 @@ void StreamManagerUI::render(void) {
if (_os.registry().all_of<Components::TagDefaultTarget>(oc)) {
ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg1, ImGui::GetColorU32(ImVec4{0.6f, 0.f, 0.6f, 0.25f}));
} else if (_os.registry().all_of<Components::TagDefaultTarget>(oc)) {
} else if (_os.registry().all_of<Components::TagConnectToDefault>(oc)) {
ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg1, ImGui::GetColorU32(ImVec4{0.6f, 0.6f, 0.f, 0.25f}));
}