mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-18 06:06:35 +00:00
ColorEdit4: Picker spawned from ColorEdit4 has a preview for original/previous color with revert button - WIP not really happy with it being in ColorEdit4 code (#346)
This commit is contained in:
parent
6bc1572d31
commit
7537dff806
17
imgui.cpp
17
imgui.cpp
@ -9244,6 +9244,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
||||
{
|
||||
if (!(flags & ImGuiColorEditFlags_NoPicker))
|
||||
{
|
||||
g.ColorPickerRef = ImVec4(col[0], col[1], col[2], alpha ? col[3] : 1.0f);
|
||||
OpenPopup("picker");
|
||||
SetNextWindowPos(window->DC.LastItemRect.GetBL() + ImVec2(-1,style.ItemSpacing.y));
|
||||
}
|
||||
@ -9264,9 +9265,25 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
||||
float square_sz = ColorSquareSize();
|
||||
ImGuiColorEditFlags picker_flags_to_forward = ImGuiColorEditFlags_Float | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaBar | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf;
|
||||
ImGuiColorEditFlags picker_flags = (flags & picker_flags_to_forward) | (ImGuiColorEditFlags_RGB | ImGuiColorEditFlags_HSV | ImGuiColorEditFlags_HEX) | ImGuiColorEditFlags_NoLabel;
|
||||
if ((flags & ImGuiColorEditFlags_NoRefColor) == 0)
|
||||
picker_flags |= ImGuiColorEditFlags_NoColorSquare;
|
||||
PushItemWidth(square_sz * 12.0f);
|
||||
value_changed |= ColorPicker4("##picker", col, picker_flags);
|
||||
PopItemWidth();
|
||||
if ((flags & ImGuiColorEditFlags_NoRefColor) == 0)
|
||||
{
|
||||
SameLine();
|
||||
BeginGroup();
|
||||
Text("Current");
|
||||
ColorButton("##current", col_display, ImGuiColorEditFlags_NoTooltip|ImGuiColorEditFlags_AlphaPreviewHalf, ImVec2(square_sz * 3, square_sz * 2));
|
||||
Text("Original");
|
||||
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));
|
||||
value_changed = 0;
|
||||
}
|
||||
EndGroup();
|
||||
}
|
||||
EndPopup();
|
||||
}
|
||||
|
||||
|
@ -433,6 +433,7 @@ struct ImGuiContext
|
||||
ImFont InputTextPasswordFont;
|
||||
ImGuiID ScalarAsInputTextId; // Temporary text input when CTRL+clicking on a slider, etc.
|
||||
ImGuiStorage ColorEditModeStorage; // Store user selection of color edit mode
|
||||
ImVec4 ColorPickerRef;
|
||||
float DragCurrentValue; // Currently dragged value, always float, not rounded by end-user precision settings
|
||||
ImVec2 DragLastMouseDelta;
|
||||
float DragSpeedDefaultRatio; // If speed == 0.0f, uses (max-min) * DragSpeedDefaultRatio
|
||||
|
Loading…
Reference in New Issue
Block a user