1
0
mirror of synced 2024-11-28 09:30:51 +01:00

fix: Provider tab bar arrow buttons not working

Fixes #1374
This commit is contained in:
WerWolv 2023-10-24 19:29:22 +02:00
parent 4f2d14e220
commit aae5586b5c

View File

@ -157,6 +157,9 @@ namespace hex::plugin::builtin {
ImHexApi::Provider::setCurrentProvider(currIndex + 1);
});
static bool providerJustChanged = true;
EventManager::subscribe<EventProviderChanged>([](auto, auto) { providerJustChanged = true; });
ContentRegistry::Interface::addToolbarItem([] {
auto provider = ImHexApi::Provider::get();
bool providerValid = provider != nullptr;
@ -259,14 +262,23 @@ namespace hex::plugin::builtin {
ImGuiTabItemFlags flags = ImGuiTabItemFlags_NoTooltip;
if (tabProvider->isDirty())
flags |= ImGuiTabItemFlags_UnsavedDocument;
if (i64(i) == selectedProviderIndex)
if (i64(i) == selectedProviderIndex && providerJustChanged) {
flags |= ImGuiTabItemFlags_SetSelected;
providerJustChanged = false;
}
static size_t lastSelectedProvider = 0;
bool isSelected = false;
if (ImGui::BeginTabItem(tabProvider->getName().c_str(), &open, flags)) {
isSelected = true;
ImGui::EndTabItem();
}
if (ImGui::IsItemClicked())
if (isSelected && lastSelectedProvider != i) {
ImHexApi::Provider::setCurrentProvider(i);
lastSelectedProvider = i;
}
if (ImGui::InfoTooltip()) {
ImGui::BeginTooltip();