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

Add ForceCloseButton TabItem flag #8387

Closed
tpecholt opened this issue Feb 11, 2025 · 3 comments
Closed

Add ForceCloseButton TabItem flag #8387

tpecholt opened this issue Feb 11, 2025 · 3 comments
Labels
style tabs tab bars, tabs

Comments

@tpecholt
Copy link

tpecholt commented Feb 11, 2025

Version/Branch of Dear ImGui:

Version 1.91.6, Branch: docking

Back-ends:

glfw + opengl3

Compiler, OS:

MSVC 2022

Full config/build information:

No response

Details:

My Issue/Question:

Currently a tab item shows close button only when hovered. In many applications close buttons are showed permanently so it would be nice to support this with an additional flag e.g. ImGuiTabItemFlags_ForceCloseButton.

Screenshots/Video:

Image

Minimal, Complete and Verifiable Example code:

ImGui::BeginTabItem("tab", &isOpen)

@ocornut ocornut added style tabs tab bars, tabs labels Feb 12, 2025
@ocornut
Copy link
Owner

ocornut commented Feb 12, 2025

If anything it would likely be a style settings rather than a per-tab item flag.

ocornut added a commit that referenced this issue Feb 12, 2025
…eButtonMinWidthUnselected. Added TabCloseButtonMinWidthSelected. (#8387)
@ocornut
Copy link
Owner

ocornut commented Feb 12, 2025

I've reworked the design for this with ef7ffaf:

  • (Breaking) Renamed style.TabMinWidthForCloseButton to style.TabCloseButtonMinWidthUnselected.
  • Styles, Tabs: made the Close Button of selected tabs always visible by default, without requiring to hover the tab. (Add ForceCloseButton TabItem flag #8387)
    • Added style.TabCloseButtonMinWidthSelected/TabCloseButtonMinWidthUnselected settings to configure visibility of the Close Button for selected and unselected tabs. (-1: always visible. 0.0f: visible when hovered. >0.0f: visible when hovered if minimum width)
    • Default for selected tabs: TabCloseButtonMinWidthSelected = -1.0f (always visible)
    • Default for unselected tabs: TabCloseButtonMinWidthUnselected = 0.0f (visible when hovered)

I believe the new default might be sufficient for you, but you can change the style to make the close button appears on unselected tabs too.

Let me know if you think this is an acceptable answer for you, or if you feel there is a need to add per-instance settings,

@ocornut ocornut closed this as completed Feb 12, 2025
ocornut added a commit that referenced this issue Feb 12, 2025
@tpecholt
Copy link
Author

This will work well for me. Thanks!

ocornut pushed a commit that referenced this issue Feb 17, 2025
…button visibility. (#8399, #8387)

Main bug has been here since 54a60aa, but it's only ef7ffaf which made it very visible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
style tabs tab bars, tabs
Projects
None yet
Development

No branches or pull requests

3 participants
@tpecholt @ocornut and others