ColorEdit4: Empty label doesn't add InnerSpacing, like other widgets (ref #346)

docking
ocornut 9 years ago
parent b6fe5eb4b4
commit 94dc3df956

@ -8521,7 +8521,6 @@ bool ImGui::ColorEdit4(const char* label, float col[4], bool alpha)
edit_mode = g.ColorEditModeStorage.GetInt(id, 0) % 3; edit_mode = g.ColorEditModeStorage.GetInt(id, 0) % 3;
float f[4] = { col[0], col[1], col[2], col[3] }; float f[4] = { col[0], col[1], col[2], col[3] };
if (edit_mode == ImGuiColorEditMode_HSV) if (edit_mode == ImGuiColorEditMode_HSV)
ImGui::ColorConvertRGBtoHSV(f[0], f[1], f[2], f[0], f[1], f[2]); ImGui::ColorConvertRGBtoHSV(f[0], f[1], f[2], f[0], f[1], f[2]);
@ -8610,15 +8609,15 @@ bool ImGui::ColorEdit4(const char* label, float col[4], bool alpha)
const char* button_titles[3] = { "RGB", "HSV", "HEX" }; const char* button_titles[3] = { "RGB", "HSV", "HEX" };
if (ButtonEx(button_titles[edit_mode], ImVec2(0,0), ImGuiButtonFlags_DontClosePopups)) if (ButtonEx(button_titles[edit_mode], ImVec2(0,0), ImGuiButtonFlags_DontClosePopups))
g.ColorEditModeStorage.SetInt(id, (edit_mode + 1) % 3); // Don't set local copy of 'edit_mode' right away! g.ColorEditModeStorage.SetInt(id, (edit_mode + 1) % 3); // Don't set local copy of 'edit_mode' right away!
ImGui::SameLine();
} }
else
const char* label_display_end = FindTextDisplayEnd(label);
if (label != label_display_end)
{ {
ImGui::SameLine(0, style.ItemInnerSpacing.x); ImGui::SameLine(0, (window->DC.ColorEditMode == ImGuiColorEditMode_UserSelectShowButton) ? -1.0f : style.ItemInnerSpacing.x);
ImGui::TextUnformatted(label, label_display_end);
} }
ImGui::TextUnformatted(label, FindTextDisplayEnd(label));
// Convert back // Convert back
for (int n = 0; n < 4; n++) for (int n = 0; n < 4; n++)
f[n] = i[n] / 255.0f; f[n] = i[n] / 255.0f;

Loading…
Cancel
Save