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

Text color of disabled menu item is incorrect #4478

Closed
paladin-t opened this issue Aug 25, 2021 · 4 comments
Closed

Text color of disabled menu item is incorrect #4478

paladin-t opened this issue Aug 25, 2021 · 4 comments
Labels
menus menu bars, menu items

Comments

@paladin-t
Copy link

Version/Branch of Dear ImGui:

Version: 1.84.2
Branch: master

Back-end/Renderer/Compiler/OS

Back-ends: any
Compiler: any
Operating System: any

My Issue/Question:

bool ImGui::MenuItemEx(const char* label, const char* icon, const char* shortcut, bool selected, bool enabled)
{
	...
	if (!enabled)
		BeginDisabled(true);
	...
	RenderText(...);
	...
	if (!enabled)
		EndDisabled();
	...
}

void ImGui::RenderText(ImVec2 pos, const char* text, const char* text_end, bool hide_text_after_hash)
{
	...
	window->DrawList->AddText(g.Font, g.FontSize, pos, GetColorU32(ImGuiCol_Text), text, text_display_end);
	...
}

It always uses ImGuiCol_Text.

@ocornut ocornut added the menus menu bars, menu items label Aug 25, 2021
@ocornut
Copy link
Owner

ocornut commented Aug 25, 2021

As per #211 we introduced a general purpose "Disabled" mode and this introduced a little inconsistency.
MenuItem() are using ImGuiCol_Text + the Disabled modifier (style.DisabledAlpha).

This makes the existence of ImGuiCol_TextDisabled a little odd and maybe to be reworked/removed/redesigned.

I presume you are having an issue because your value for ImGuiCol_TextDisabled was e.g. using a different Hue than your value for ImGuiCol_Text ? How do things look in your style?

@paladin-t
Copy link
Author

Thank you for your reply.

In this case, calling GetColorU32(ImGuiCol_Text) left the second parameter float alpha_mul omitted, which defaults to 1.0f. I don't think DisabledAlpha affects here.

ImU32 ImGui::GetColorU32(ImGuiCol idx, float alpha_mul/* = 1.0f*/)
{
    ImGuiStyle& style = GImGui->Style;
    ImVec4 c = style.Colors[idx];
    c.w *= style.Alpha * alpha_mul;
    return ColorConvertFloat4ToU32(c);
}

It looks like:

1

well it should be:

2

This issue remains despite how I adjust DisabledAlpha.

@ocornut
Copy link
Owner

ocornut commented Aug 26, 2021

I don't think DisabledAlpha affects here.

DisabledAlpha is baked into style.Alpha when going in Disabled mode.

Are you sure you are on 1.84.2 and not on 1.84 or 1.84.1 ?
There was a bug at some point which got fixed.

@paladin-t
Copy link
Author

After debugging, it's a bug of my part, solved now. Thank you for your time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
menus menu bars, menu items
Projects
None yet
Development

No branches or pull requests

2 participants