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

feat: Display complete window title when hovering over search bar

This commit is contained in:
WerWolv 2023-12-14 13:50:26 +01:00
parent 2ebd3c6f35
commit c1f76be3b7
4 changed files with 26 additions and 13 deletions

View File

@ -250,7 +250,7 @@ namespace hex {
EVENT_DEF(EventStoreContentRemoved, const std::fs::path&);
EVENT_DEF(EventImHexClosing);
EVENT_DEF(EventAchievementUnlocked, const Achievement&);
EVENT_DEF(EventSearchBoxClicked);
EVENT_DEF(EventSearchBoxClicked, u32);
EVENT_DEF(EventViewOpened, View*);
EVENT_DEF(EventProviderDataModified, prv::Provider *, u64, u64, const u8*);

View File

@ -49,7 +49,7 @@ namespace hex {
GLFWwindow *m_window = nullptr;
std::string m_windowTitle;
std::string m_windowTitle, m_windowTitleFull;
double m_lastStartFrameTime = 0;
double m_lastFrameTime = 0;

View File

@ -111,30 +111,33 @@ namespace hex {
// Handle updating the window title
RequestUpdateWindowTitle::subscribe(this, [this] {
std::string prefix, postfix;
std::string title = "ImHex";
if (ProjectFile::hasPath()) {
// If a project is open, show the project name instead of the file name
title = "Project " + hex::limitStringLength(ProjectFile::getPath().stem().string(), 32);
prefix = "Project ";
title = ProjectFile::getPath().stem().string();
if (ImHexApi::Provider::isDirty())
title += " (*)";
postfix += " (*)";
} else if (ImHexApi::Provider::isValid()) {
auto provider = ImHexApi::Provider::get();
if (provider != nullptr) {
title = hex::limitStringLength(provider->getName(), 32);
title = provider->getName();
if (provider->isDirty())
title += " (*)";
postfix += " (*)";
if (!provider->isWritable())
title += " (Read Only)";
postfix += " (Read Only)";
}
}
this->m_windowTitle = title;
this->m_windowTitle = prefix + hex::limitStringLength(title, 32) + postfix;
this->m_windowTitleFull = prefix + title + postfix;
if (this->m_window != nullptr) {
if (title != "ImHex")
@ -322,9 +325,17 @@ namespace hex {
ImGui::SetCursorPos(searchBoxPos);
if (ImGui::Button(this->m_windowTitle.c_str(), searchBoxSize)) {
EventSearchBoxClicked::post();
EventSearchBoxClicked::post(ImGuiMouseButton_Left);
}
if (ImGui::IsItemClicked(ImGuiMouseButton_Right))
EventSearchBoxClicked::post(ImGuiMouseButton_Right);
ImGui::PushTextWrapPos(300_scaled);
if (!this->m_windowTitleFull.empty())
ImGui::SetItemTooltip(this->m_windowTitleFull.c_str());
ImGui::PopTextWrapPos();
ImGui::PopStyleVar(3);
ImGui::PopStyleColor(3);
}

View File

@ -13,10 +13,12 @@ namespace hex::plugin::builtin {
this->m_justOpened = true;
});
EventSearchBoxClicked::subscribe([this] {
RequestOpenPopup::post("hex.builtin.view.command_palette.name"_lang);
this->m_commandPaletteOpen = true;
this->m_justOpened = true;
EventSearchBoxClicked::subscribe([this](ImGuiMouseButton button) {
if (button == ImGuiMouseButton_Left) {
RequestOpenPopup::post("hex.builtin.view.command_palette.name"_lang);
this->m_commandPaletteOpen = true;
this->m_justOpened = true;
}
});
}