feat: Added provider information to search bar hover tooltip
This commit is contained in:
parent
4e5a7ba483
commit
51010096bb
@ -334,6 +334,41 @@ namespace hex::plugin::builtin {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void drawProviderTooltip(const prv::Provider *provider) {
|
||||||
|
if (ImGuiExt::InfoTooltip()) {
|
||||||
|
ImGui::BeginTooltip();
|
||||||
|
|
||||||
|
ImGuiExt::TextFormatted("{}", provider->getName().c_str());
|
||||||
|
|
||||||
|
const auto &description = provider->getDataDescription();
|
||||||
|
if (!description.empty()) {
|
||||||
|
ImGui::Separator();
|
||||||
|
if (ImGui::GetIO().KeyShift && !description.empty()) {
|
||||||
|
|
||||||
|
if (ImGui::BeginTable("information", 2, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_RowBg | ImGuiTableFlags_NoKeepColumnsVisible, ImVec2(400_scaled, 0))) {
|
||||||
|
ImGui::TableSetupColumn("type");
|
||||||
|
ImGui::TableSetupColumn("value", ImGuiTableColumnFlags_WidthStretch);
|
||||||
|
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
|
||||||
|
for (auto &[name, value] : description) {
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGuiExt::TextFormatted("{}", name);
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGuiExt::TextFormattedWrapped("{}", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::EndTable();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ImGuiExt::TextFormattedDisabled("hex.builtin.provider.tooltip.show_more"_lang);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::EndTooltip();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void addToolbarItems() {
|
void addToolbarItems() {
|
||||||
ShortcutManager::addGlobalShortcut(AllowWhileTyping + ALT + CTRLCMD + Keys::Left, "hex.builtin.shortcut.prev_provider", []{
|
ShortcutManager::addGlobalShortcut(AllowWhileTyping + ALT + CTRLCMD + Keys::Left, "hex.builtin.shortcut.prev_provider", []{
|
||||||
auto currIndex = ImHexApi::Provider::getCurrentProviderIndex();
|
auto currIndex = ImHexApi::Provider::getCurrentProviderIndex();
|
||||||
@ -379,6 +414,7 @@ namespace hex::plugin::builtin {
|
|||||||
alwaysShowProviderTabs = value.get<bool>(false);
|
alwaysShowProviderTabs = value.get<bool>(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Toolbar items
|
||||||
ContentRegistry::Interface::addToolbarItem([] {
|
ContentRegistry::Interface::addToolbarItem([] {
|
||||||
std::set<const ContentRegistry::Interface::impl::MenuItem*, MenuItemSorter> menuItems;
|
std::set<const ContentRegistry::Interface::impl::MenuItem*, MenuItemSorter> menuItems;
|
||||||
|
|
||||||
@ -456,38 +492,7 @@ namespace hex::plugin::builtin {
|
|||||||
lastSelectedProvider = i;
|
lastSelectedProvider = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGuiExt::InfoTooltip()) {
|
drawProviderTooltip(tabProvider);
|
||||||
ImGui::BeginTooltip();
|
|
||||||
|
|
||||||
ImGuiExt::TextFormatted("{}", tabProvider->getName().c_str());
|
|
||||||
|
|
||||||
const auto &description = tabProvider->getDataDescription();
|
|
||||||
if (!description.empty()) {
|
|
||||||
ImGui::Separator();
|
|
||||||
if (ImGui::GetIO().KeyShift && !description.empty()) {
|
|
||||||
|
|
||||||
if (ImGui::BeginTable("information", 2, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_RowBg | ImGuiTableFlags_NoKeepColumnsVisible, ImVec2(400_scaled, 0))) {
|
|
||||||
ImGui::TableSetupColumn("type");
|
|
||||||
ImGui::TableSetupColumn("value", ImGuiTableColumnFlags_WidthStretch);
|
|
||||||
|
|
||||||
ImGui::TableNextRow();
|
|
||||||
|
|
||||||
for (auto &[name, value] : description) {
|
|
||||||
ImGui::TableNextColumn();
|
|
||||||
ImGuiExt::TextFormatted("{}", name);
|
|
||||||
ImGui::TableNextColumn();
|
|
||||||
ImGuiExt::TextFormattedWrapped("{}", value);
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::EndTable();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ImGuiExt::TextFormattedDisabled("hex.builtin.provider.tooltip.show_more"_lang);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::EndTooltip();
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
|
|
||||||
|
@ -17,6 +17,9 @@
|
|||||||
|
|
||||||
namespace hex::plugin::builtin {
|
namespace hex::plugin::builtin {
|
||||||
|
|
||||||
|
// Function that draws the provider popup, defiend in the ui_items.cpp file
|
||||||
|
void drawProviderTooltip(const prv::Provider *provider);
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
std::string s_windowTitle, s_windowTitleFull;
|
std::string s_windowTitle, s_windowTitleFull;
|
||||||
@ -70,58 +73,58 @@ namespace hex::plugin::builtin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void drawSidebar(ImVec2 dockSpaceSize, ImVec2 sidebarPos, float sidebarWidth) {
|
void drawSidebar(ImVec2 dockSpaceSize, ImVec2 sidebarPos, float sidebarWidth) {
|
||||||
static i32 openWindow = -1;
|
static i32 openWindow = -1;
|
||||||
u32 index = 0;
|
u32 index = 0;
|
||||||
ImGui::PushID("SideBarWindows");
|
ImGui::PushID("SideBarWindows");
|
||||||
for (const auto &[icon, callback, enabledCallback] : ContentRegistry::Interface::impl::getSidebarItems()) {
|
for (const auto &[icon, callback, enabledCallback] : ContentRegistry::Interface::impl::getSidebarItems()) {
|
||||||
ImGui::SetCursorPosY(sidebarPos.y + sidebarWidth * index);
|
ImGui::SetCursorPosY(sidebarPos.y + sidebarWidth * index);
|
||||||
|
|
||||||
ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetColorU32(ImGuiCol_MenuBarBg));
|
ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetColorU32(ImGuiCol_MenuBarBg));
|
||||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImGui::GetColorU32(ImGuiCol_ScrollbarGrabActive));
|
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImGui::GetColorU32(ImGuiCol_ScrollbarGrabActive));
|
||||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImGui::GetColorU32(ImGuiCol_ScrollbarGrabHovered));
|
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImGui::GetColorU32(ImGuiCol_ScrollbarGrabHovered));
|
||||||
|
|
||||||
ImGui::BeginDisabled(!(ImHexApi::Provider::isValid() && enabledCallback()));
|
ImGui::BeginDisabled(!(ImHexApi::Provider::isValid() && enabledCallback()));
|
||||||
{
|
{
|
||||||
if (ImGui::Button(icon.c_str(), ImVec2(sidebarWidth, sidebarWidth))) {
|
if (ImGui::Button(icon.c_str(), ImVec2(sidebarWidth, sidebarWidth))) {
|
||||||
if (static_cast<u32>(openWindow) == index)
|
if (static_cast<u32>(openWindow) == index)
|
||||||
openWindow = -1;
|
openWindow = -1;
|
||||||
else
|
else
|
||||||
openWindow = index;
|
openWindow = index;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ImGui::EndDisabled();
|
|
||||||
|
|
||||||
ImGui::PopStyleColor(3);
|
|
||||||
|
|
||||||
auto sideBarFocused = ImGui::IsWindowFocused();
|
|
||||||
|
|
||||||
bool open = static_cast<u32>(openWindow) == index;
|
|
||||||
if (open) {
|
|
||||||
|
|
||||||
ImGui::SetNextWindowPos(ImGui::GetWindowPos() + sidebarPos + ImVec2(sidebarWidth - 1_scaled, -1_scaled));
|
|
||||||
ImGui::SetNextWindowSize(ImVec2(0, dockSpaceSize.y + 5_scaled));
|
|
||||||
|
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 1);
|
|
||||||
ImGui::PushStyleColor(ImGuiCol_WindowShadow, 0x00000000);
|
|
||||||
if (ImGui::Begin("SideBarWindow", &open, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse)) {
|
|
||||||
if (ImGui::BeginChild("##Content", ImVec2(), ImGuiChildFlags_ResizeX)) {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
ImGui::EndChild();
|
|
||||||
|
|
||||||
if (!ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows) && !sideBarFocused) {
|
|
||||||
openWindow = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ImGui::End();
|
|
||||||
ImGui::PopStyleVar();
|
|
||||||
ImGui::PopStyleColor();
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::NewLine();
|
|
||||||
index++;
|
|
||||||
}
|
}
|
||||||
ImGui::PopID();
|
ImGui::EndDisabled();
|
||||||
|
|
||||||
|
ImGui::PopStyleColor(3);
|
||||||
|
|
||||||
|
auto sideBarFocused = ImGui::IsWindowFocused();
|
||||||
|
|
||||||
|
bool open = static_cast<u32>(openWindow) == index;
|
||||||
|
if (open) {
|
||||||
|
|
||||||
|
ImGui::SetNextWindowPos(ImGui::GetWindowPos() + sidebarPos + ImVec2(sidebarWidth - 1_scaled, -1_scaled));
|
||||||
|
ImGui::SetNextWindowSize(ImVec2(0, dockSpaceSize.y + 5_scaled));
|
||||||
|
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 1);
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_WindowShadow, 0x00000000);
|
||||||
|
if (ImGui::Begin("SideBarWindow", &open, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse)) {
|
||||||
|
if (ImGui::BeginChild("##Content", ImVec2(), ImGuiChildFlags_ResizeX)) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
ImGui::EndChild();
|
||||||
|
|
||||||
|
if (!ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows) && !sideBarFocused) {
|
||||||
|
openWindow = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::End();
|
||||||
|
ImGui::PopStyleVar();
|
||||||
|
ImGui::PopStyleColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::NewLine();
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawTitleBar() {
|
void drawTitleBar() {
|
||||||
@ -228,8 +231,16 @@ namespace hex::plugin::builtin {
|
|||||||
EventSearchBoxClicked::post(ImGuiMouseButton_Right);
|
EventSearchBoxClicked::post(ImGuiMouseButton_Right);
|
||||||
|
|
||||||
ImGui::PushTextWrapPos(300_scaled);
|
ImGui::PushTextWrapPos(300_scaled);
|
||||||
if (!s_windowTitleFull.empty())
|
|
||||||
ImGui::SetItemTooltip("%s", s_windowTitleFull.c_str());
|
if (auto provider = ImHexApi::Provider::get(); provider != nullptr) {
|
||||||
|
drawProviderTooltip(ImHexApi::Provider::get());
|
||||||
|
} else {
|
||||||
|
if (ImGuiExt::InfoTooltip()) {
|
||||||
|
ImGui::BeginTooltip();
|
||||||
|
ImGui::TextUnformatted(s_windowTitleFull.c_str());
|
||||||
|
ImGui::EndTooltip();
|
||||||
|
}
|
||||||
|
}
|
||||||
ImGui::PopTextWrapPos();
|
ImGui::PopTextWrapPos();
|
||||||
|
|
||||||
ImGui::PopStyleVar(3);
|
ImGui::PopStyleVar(3);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user