mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 20:07:01 +00:00
ColorEdit4: Fixed not returning true when clicking on the Original/Ref color in Picker spawned from ColorEdit4 + shallow tidying up (#346)
This commit is contained in:
parent
7537dff806
commit
6c82572a35
15
imgui.cpp
15
imgui.cpp
@ -9239,12 +9239,13 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|||||||
if (!(flags & ImGuiColorEditFlags_NoInputs))
|
if (!(flags & ImGuiColorEditFlags_NoInputs))
|
||||||
SameLine(0, style.ItemInnerSpacing.x);
|
SameLine(0, style.ItemInnerSpacing.x);
|
||||||
|
|
||||||
const ImVec4 col_display(col[0], col[1], col[2], alpha ? col[3] : 1.0f); // 1.0f
|
const ImVec4 col_v4(col[0], col[1], col[2], alpha ? col[3] : 1.0f);
|
||||||
if (ColorButton("##ColorButton", col_display, flags))
|
if (ColorButton("##ColorButton", col_v4, flags))
|
||||||
{
|
{
|
||||||
if (!(flags & ImGuiColorEditFlags_NoPicker))
|
if (!(flags & ImGuiColorEditFlags_NoPicker))
|
||||||
{
|
{
|
||||||
g.ColorPickerRef = ImVec4(col[0], col[1], col[2], alpha ? col[3] : 1.0f);
|
// Store current color and open a picker
|
||||||
|
g.ColorPickerRef = col_v4;
|
||||||
OpenPopup("picker");
|
OpenPopup("picker");
|
||||||
SetNextWindowPos(window->DC.LastItemRect.GetBL() + ImVec2(-1,style.ItemSpacing.y));
|
SetNextWindowPos(window->DC.LastItemRect.GetBL() + ImVec2(-1,style.ItemSpacing.y));
|
||||||
}
|
}
|
||||||
@ -9267,7 +9268,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|||||||
ImGuiColorEditFlags picker_flags = (flags & picker_flags_to_forward) | (ImGuiColorEditFlags_RGB | ImGuiColorEditFlags_HSV | ImGuiColorEditFlags_HEX) | ImGuiColorEditFlags_NoLabel;
|
ImGuiColorEditFlags picker_flags = (flags & picker_flags_to_forward) | (ImGuiColorEditFlags_RGB | ImGuiColorEditFlags_HSV | ImGuiColorEditFlags_HEX) | ImGuiColorEditFlags_NoLabel;
|
||||||
if ((flags & ImGuiColorEditFlags_NoRefColor) == 0)
|
if ((flags & ImGuiColorEditFlags_NoRefColor) == 0)
|
||||||
picker_flags |= ImGuiColorEditFlags_NoColorSquare;
|
picker_flags |= ImGuiColorEditFlags_NoColorSquare;
|
||||||
PushItemWidth(square_sz * 12.0f);
|
PushItemWidth(square_sz * 12.0f); // Use 256 + bar sizes?
|
||||||
value_changed |= ColorPicker4("##picker", col, picker_flags);
|
value_changed |= ColorPicker4("##picker", col, picker_flags);
|
||||||
PopItemWidth();
|
PopItemWidth();
|
||||||
if ((flags & ImGuiColorEditFlags_NoRefColor) == 0)
|
if ((flags & ImGuiColorEditFlags_NoRefColor) == 0)
|
||||||
@ -9275,12 +9276,12 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|||||||
SameLine();
|
SameLine();
|
||||||
BeginGroup();
|
BeginGroup();
|
||||||
Text("Current");
|
Text("Current");
|
||||||
ColorButton("##current", col_display, ImGuiColorEditFlags_NoTooltip|ImGuiColorEditFlags_AlphaPreviewHalf, ImVec2(square_sz * 3, square_sz * 2));
|
ColorButton("##current", col_v4, ImGuiColorEditFlags_NoTooltip|ImGuiColorEditFlags_AlphaPreviewHalf, ImVec2(square_sz * 3, square_sz * 2));
|
||||||
Text("Original");
|
Text("Original");
|
||||||
if (ColorButton("##original", g.ColorPickerRef, ImGuiColorEditFlags_NoTooltip|ImGuiColorEditFlags_AlphaPreviewHalf, ImVec2(square_sz * 3, square_sz * 2)))
|
if (ColorButton("##original", g.ColorPickerRef, ImGuiColorEditFlags_NoTooltip|ImGuiColorEditFlags_AlphaPreviewHalf, ImVec2(square_sz * 3, square_sz * 2)))
|
||||||
{
|
{
|
||||||
memcpy(col, &g.ColorPickerRef, (alpha ? 4 : 3) * sizeof(float));
|
memcpy(col, &g.ColorPickerRef, components * sizeof(float));
|
||||||
value_changed = 0;
|
value_changed = true;
|
||||||
}
|
}
|
||||||
EndGroup();
|
EndGroup();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user