Skip to content

ImGuiColorEdit4 Preview Button same color #1578

@LegendaryB

Description

@LegendaryB

Hey,

im currently trying to use or modify the ImGui ColorEdit4
I have this controls:

ImGui::ColorEdit4("Counter-Terrorists", &g_Configuration.Visuals.Glow.ct_color, ImGuiColorEditFlags_NoInputs);
ImGui::ColorEdit4("Terrorists", &g_Configuration.Visuals.Glow.t_color, ImGuiColorEditFlags_NoInputs);
ImGui::ColorEdit4("Bomb Carrier", &g_Configuration.Visuals.Glow.bomb_carrier_color, ImGuiColorEditFlags_NoInputs);
ImGui::ColorEdit4("C4 Planted", &g_Configuration.Visuals.Glow.c4_planted_color, ImGuiColorEditFlags_NoInputs);
ImGui::ColorEdit4("Weapons", &g_Configuration.Visuals.Glow.weapon_color, ImGuiColorEditFlags_NoInputs);
ImGui::ColorEdit4("Chickens", &g_Configuration.Visuals.Glow.chicken_color, ImGuiColorEditFlags_NoInputs);

My first custom implementation looked like this(working for ColorPicker4) :

bool ImGui::ColorEdit4(const char* label, Color * v, ImGuiColorEditFlags flags)
{
	static float color[4] = { v->Red, v->Green, v->Blue, v->Alpha };

	if (ImGui::ColorEdit4(label, color, flags)) {
		v->Red = color[0];
		v->Green = color[1];
		v->Blue = color[2];
		v->Alpha = color[3];

		return true;
	}
	return false;
}

I have implemented the ColorEdit4 custom control like this. The "binding" or value update process is working. But the preview button color is the same on all buttons. Can you provide a fix for this? Or a tip?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions