Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API that returns true if a scrollbar is hovered? #8284

Open
sodamouse opened this issue Jan 2, 2025 · 0 comments
Open

API that returns true if a scrollbar is hovered? #8284

sodamouse opened this issue Jan 2, 2025 · 0 comments

Comments

@sodamouse
Copy link

sodamouse commented Jan 2, 2025

Version/Branch of Dear ImGui:

Version 1.91.5, Branch: docking

Back-ends:

imgui_impl_opengl3.cpp + imgui_impl_glfw.cpp

Compiler, OS:

Windows 11 + MSVC 2022

Full config/build information:

No response

Details:

My Issue/Question:

Hi, I've implemented the following to highlight a table's rows if it is currently being hovered:

ImGuiContext& g   = *ImGui::GetCurrentContext();
ImGuiTable* table = g.CurrentTable;

ImRect rect(table->WorkRect.Min.x, table->RowPosY1, table->WorkRect.Max.x, table->RowPosY2);

bool hover =
    ImGui::IsMouseHoveringRect(rect.Min, rect.Max, false) &&
    ImGui::IsWindowHovered(ImGuiHoveredFlags_None)
;

static constexpr auto SAYVE_COL32_TABLE_HIGHLIGHT = IM_COL32(255,255,255,64);

if (hover)
{
    ImGui::GetForegroundDrawList()->AddRectFilled(
        {rect.Min.x, rect.Min.y},
        {rect.Max.x, rect.Max.y},
        SAYVE_COL32_TABLE_HIGHLIGHT
    );
}

This works really well, except for the case where the OS layer window that holds the application is small, causing the horizontal scrollbar to be drawn. This produces the visual clash shown below:
sayve_YkNtEs8ZHp

The scrollbar is still interactible and functional, but obviously the visual effect is not nice.

I am looking for ideas on how to solve this problem. I was thinking that an API call that would return true if the scroll bar is hovered would solve my problem, but there might be another way to solve this already. Any suggestions are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants