mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-30 13:05:25 -05:00
ui: Change the provider selector from a dropdown to a tab bar
This commit is contained in:
@@ -45,7 +45,7 @@ namespace hex::plugin::builtin {
|
||||
bool providerValid = ImHexApi::Provider::isValid();
|
||||
bool taskRunning = Task::getRunningTaskCount() > 0;
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.menu.file.close"_lang, "", false, providerValid && !taskRunning)) {
|
||||
if (ImGui::MenuItem("hex.builtin.menu.file.close"_lang, "CTRL + W", false, providerValid && !taskRunning)) {
|
||||
EventManager::post<EventFileUnloaded>();
|
||||
ImHexApi::Provider::remove(ImHexApi::Provider::get());
|
||||
}
|
||||
|
||||
@@ -297,26 +297,33 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
|
||||
ImGui::Spacing();
|
||||
ImGui::Spacing();
|
||||
ImGui::Spacing();
|
||||
|
||||
// Provider switcher
|
||||
ImGui::BeginDisabled(!providerValid || tasksRunning);
|
||||
{
|
||||
auto &providers = ImHexApi::Provider::getProviders();
|
||||
|
||||
std::string preview;
|
||||
if (ImHexApi::Provider::isValid())
|
||||
preview = ImHexApi::Provider::get()->getName();
|
||||
|
||||
ImGui::SetNextItemWidth(200_scaled);
|
||||
if (ImGui::BeginCombo("", preview.c_str())) {
|
||||
ImGui::PushStyleColor(ImGuiCol_TabActive, ImGui::GetColorU32(ImGuiCol_MenuBarBg));
|
||||
ImGui::PushStyleColor(ImGuiCol_TabUnfocusedActive, ImGui::GetColorU32(ImGuiCol_MenuBarBg));
|
||||
auto providerSelectorVisible = ImGui::BeginTabBar("provider_switcher", ImGuiTabBarFlags_FittingPolicyScroll | ImGuiTabBarFlags_Reorderable);
|
||||
ImGui::PopStyleColor(2);
|
||||
|
||||
if (providerSelectorVisible) {
|
||||
for (size_t i = 0; i < providers.size(); i++) {
|
||||
if (ImGui::Selectable(providers[i]->getName().c_str())) {
|
||||
bool open = true;
|
||||
if (ImGui::BeginTabItem(providers[i]->getName().c_str(), &open)) {
|
||||
ImHexApi::Provider::setCurrentProvider(i);
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
if (!open) {
|
||||
ImHexApi::Provider::remove(providers[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndCombo();
|
||||
ImGui::EndTabBar();
|
||||
}
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
|
||||
@@ -11,10 +11,6 @@ using namespace std::literals::string_literals;
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
ViewDisassembler::ViewDisassembler() : View("hex.builtin.view.disassembler.name") {
|
||||
EventManager::subscribe<EventDataChanged>(this, [this]() {
|
||||
this->disassemble();
|
||||
});
|
||||
|
||||
EventManager::subscribe<EventRegionSelected>(this, [this](Region region) {
|
||||
if (this->m_shouldMatchSelection) {
|
||||
if (region.address == size_t(-1)) {
|
||||
|
||||
@@ -1250,6 +1250,12 @@ namespace hex::plugin::builtin {
|
||||
});
|
||||
});
|
||||
|
||||
// Close file
|
||||
ShortcutManager::addGlobalShortcut(CTRL + Keys::W, [] {
|
||||
EventManager::post<EventFileUnloaded>();
|
||||
ImHexApi::Provider::remove(ImHexApi::Provider::get());
|
||||
});
|
||||
|
||||
// Undo / Redo
|
||||
ShortcutManager::addShortcut(this, CTRL + Keys::Z, [] {
|
||||
if (ImHexApi::Provider::isValid())
|
||||
|
||||
Reference in New Issue
Block a user