-
-
Notifications
You must be signed in to change notification settings - Fork 11.7k
ColorButton doesn't display color the same as ImageButton. It ignores alpha. #8335
Copy link
Copy link
Closed
Labels
Description
Version/Branch of Dear ImGui:
Version 1.91.5, Branch: Docking
Back-ends:
imgui_impl_sfml.cpp sfml/2.6.2
Compiler, OS:
Windows 10, MSVC 2022
Full config/build information:
Dear ImGui 1.91.5 (19150)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=199711
define: _WIN32
define: _WIN64
define: _MSC_VER=1942
define: _MSVC_LANG=202004
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
--------------------------------
io.BackendPlatformName: imgui_impl_sfml
io.BackendRendererName: NULL
io.ConfigFlags: 0x00000080
DockingEnable
io.ConfigViewportsNoDecoration
io.ConfigNavCaptureKeyboard
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigWindowsMoveFromTitleBarOnly
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x00000007
HasGamepad
HasMouseCursors
HasSetMousePos
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 1024,1024
io.DisplaySize: 1920.00,1057.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------
style.WindowPadding: 8.00,8.00
style.WindowBorderSize: 1.00
style.FramePadding: 4.00,3.00
style.FrameRounding: 0.00
style.FrameBorderSize: 0.00
style.ItemSpacing: 8.00,4.00
style.ItemInnerSpacing: 4.00,4.00
Details:
I was trying to make a legend so people could hover over a ImGui::ColorButton, and see what the color means. But I noticed that ImGui::ColorButton doesn't display colors the same as ImGui::ImageButton. ImGuiCol_Button has a 40% alpha channel. So the ImGui::ImageButton appears darker on a black background. ImGui::ColorButton discards the alpha and shows up brighter.
From imgui_draw.cpp
colors[ImGuiCol_Button] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f);Screenshots/Video:
Minimal, Complete and Verifiable Example code:
// Here's some code anyone can copy and paste to reproduce your issue
ImGui::Begin("Example Bug");
ImGui::ColorButton("##ButtonRegular", ImGui::GetStyle().Colors[ImGuiCol_Button], ImGuiColorEditFlags_NoTooltip | ImGuiColorEditFlags_NoDragDrop);
//tool tip code here
//I just through the below code together to show a imagebutton with a transparent texture. SFML-imgui has overloads to take SFML types.
static std::shared_ptr<sf::RenderTexture> testTexture = []() {
auto t = std::make_shared<sf::RenderTexture>();
t->create(1, 1);
t->clear(sf::Color::Transparent);
t->display();
return t;
}();
ImGui::ImageButton("##Test", *testTexture.get(), sf::Vector2f(50, 50));
ImGui::End();from imgui-SFML.cpp
/////////////// Image Button Overloads for sf::RenderTexture
bool ImageButton(const char* id, const sf::RenderTexture& texture, const sf::Vector2f& size,
const sf::Color& bgColor, const sf::Color& tintColor) {
ImTextureID textureID =
convertGLTextureHandleToImTextureID(texture.getTexture().getNativeHandle());
return ImGui::ImageButton(id, textureID, ImVec2(size.x, size.y), ImVec2(0, 1),
ImVec2(1, 0), // flipped vertically, because textures in
// sf::RenderTexture are stored this way
toImColor(bgColor), toImColor(tintColor));
}Reactions are currently unavailable
