ui: Change the provider selector from a dropdown to a tab bar
This commit is contained in:
parent
376cf6e8fa
commit
7a4541dac7
@ -229,7 +229,7 @@ namespace hex {
|
||||
if (Task::getRunningTaskCount() > 0)
|
||||
return;
|
||||
|
||||
if (index < s_providers.size()) {
|
||||
if (index < s_providers.size() && s_currentProvider != index) {
|
||||
auto oldProvider = get();
|
||||
s_currentProvider = index;
|
||||
EventManager::post<EventProviderChanged>(oldProvider, get());
|
||||
|
@ -185,7 +185,7 @@ namespace hex::init {
|
||||
ImHexApi::System::impl::setGlobalScale(meanScale);
|
||||
ImHexApi::System::impl::setNativeScale(meanScale);
|
||||
|
||||
log::info("Native scaling set to: {:.1}", meanScale);
|
||||
log::info("Native scaling set to: {:.1f}", meanScale);
|
||||
}
|
||||
|
||||
glfwSetWindowSize(this->m_window, 640_scaled, 400_scaled);
|
||||
|
@ -227,16 +227,11 @@ namespace hex {
|
||||
ImGui::Separator();
|
||||
ImGui::SetCursorPosX(8);
|
||||
for (const auto &callback : ContentRegistry::Interface::getFooterItems()) {
|
||||
auto prevIdx = drawList->_VtxCurrentIdx;
|
||||
callback();
|
||||
auto currIdx = drawList->_VtxCurrentIdx;
|
||||
|
||||
// Only draw separator if something was actually drawn
|
||||
if (prevIdx != currIdx) {
|
||||
ImGui::SameLine();
|
||||
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
|
||||
ImGui::SameLine();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
|
||||
ImGui::SameLine();
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -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())
|
||||
|
Loading…
Reference in New Issue
Block a user