ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
61.17k stars 10.31k forks source link

TabItem 'Unsaved document' bullet rendered too low #6862

Closed alektron closed 1 year ago

alektron commented 1 year ago

Version/Branch of Dear ImGui:

Version: 1.90 WIP (18992) Branch: docking

Back-ends: (tested with) example_win32_directx11, custom backend Operating System: Windows 10

Issue (regression): TabBarItems with the ImGuiTabItemFlags_UnsavedDocument flag set has the dot/bullet rendered too low: image

The reason seems to be a change in TabItemLabelAndCloseButton in imgui_widgets.cpp. (introduced into docking when merging from master in 676497fe, I did not investigate further where exactly in master).

When calculating button_pos the frame_padding.y gets added to the y value. The tab close button seems to have been adjusted by removing the surrounding Push/PopStyleVar(FramePadding).

//PushStyleVar(ImGuiStyleVar_FramePadding, frame_padding);
if (CloseButton(close_button_id, button_pos))
    close_button_pressed = true;
//PopStyleVar();

However the unsaved document bullet still has a + g.Style.FramePadding * 2.0f added to its bounds. This then affects bb.GetCenter().

const ImRect bullet_bb(button_pos, button_pos + ImVec2(button_sz, button_sz) + g.Style.FramePadding * 2.0f);
RenderBullet(draw_list, bullet_bb.GetCenter(), GetColorU32(ImGuiCol_Text));
ocornut commented 1 year ago

This was indeed broken by 4a814244. I pushed the fix e5ca535 now. I confirmed this cherry-pick fine in docking until we merge it (usually once a week).

Thank you!