mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-25 00:00:40 +01:00
ColorPicker4: Fixed returning true when holding mouse button on the sat/value/alpha locations. (#1489)
This commit is contained in:
parent
a8c7b1a2a2
commit
0365c524a2
10
imgui.cpp
10
imgui.cpp
@ -9883,7 +9883,7 @@ void ImGui::ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags)
|
|||||||
EndPopup();
|
EndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ColorPickerOptionsPopup(ImGuiColorEditFlags flags, float* ref_col)
|
static void ColorPickerOptionsPopup(ImGuiColorEditFlags flags, const float* ref_col)
|
||||||
{
|
{
|
||||||
bool allow_opt_picker = !(flags & ImGuiColorEditFlags__PickerMask);
|
bool allow_opt_picker = !(flags & ImGuiColorEditFlags__PickerMask);
|
||||||
bool allow_opt_alpha_bar = !(flags & ImGuiColorEditFlags_NoAlpha) && !(flags & ImGuiColorEditFlags_AlphaBar);
|
bool allow_opt_alpha_bar = !(flags & ImGuiColorEditFlags_NoAlpha) && !(flags & ImGuiColorEditFlags_AlphaBar);
|
||||||
@ -10167,6 +10167,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|||||||
flags |= (g.ColorEditOptions & ImGuiColorEditFlags_AlphaBar);
|
flags |= (g.ColorEditOptions & ImGuiColorEditFlags_AlphaBar);
|
||||||
|
|
||||||
// Setup
|
// Setup
|
||||||
|
int components = (flags & ImGuiColorEditFlags_NoAlpha) ? 3 : 4;
|
||||||
bool alpha_bar = (flags & ImGuiColorEditFlags_AlphaBar) && !(flags & ImGuiColorEditFlags_NoAlpha);
|
bool alpha_bar = (flags & ImGuiColorEditFlags_AlphaBar) && !(flags & ImGuiColorEditFlags_NoAlpha);
|
||||||
ImVec2 picker_pos = window->DC.CursorPos;
|
ImVec2 picker_pos = window->DC.CursorPos;
|
||||||
float square_sz = SmallSquareSize();
|
float square_sz = SmallSquareSize();
|
||||||
@ -10176,6 +10177,9 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|||||||
float bar1_pos_x = bar0_pos_x + bars_width + style.ItemInnerSpacing.x;
|
float bar1_pos_x = bar0_pos_x + bars_width + style.ItemInnerSpacing.x;
|
||||||
float bars_triangles_half_sz = (float)(int)(bars_width * 0.20f);
|
float bars_triangles_half_sz = (float)(int)(bars_width * 0.20f);
|
||||||
|
|
||||||
|
float backup_initial_col[4];
|
||||||
|
memcpy(backup_initial_col, col, components * sizeof(float));
|
||||||
|
|
||||||
float wheel_thickness = sv_picker_size * 0.08f;
|
float wheel_thickness = sv_picker_size * 0.08f;
|
||||||
float wheel_r_outer = sv_picker_size * 0.50f;
|
float wheel_r_outer = sv_picker_size * 0.50f;
|
||||||
float wheel_r_inner = wheel_r_outer - wheel_thickness;
|
float wheel_r_inner = wheel_r_outer - wheel_thickness;
|
||||||
@ -10291,7 +10295,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|||||||
ImVec4 ref_col_v4(ref_col[0], ref_col[1], ref_col[2], (flags & ImGuiColorEditFlags_NoAlpha) ? 1.0f : ref_col[3]);
|
ImVec4 ref_col_v4(ref_col[0], ref_col[1], ref_col[2], (flags & ImGuiColorEditFlags_NoAlpha) ? 1.0f : ref_col[3]);
|
||||||
if (ColorButton("##original", ref_col_v4, (flags & (ImGuiColorEditFlags_HDR|ImGuiColorEditFlags_AlphaPreview|ImGuiColorEditFlags_AlphaPreviewHalf|ImGuiColorEditFlags_NoTooltip)), ImVec2(square_sz * 3, square_sz * 2)))
|
if (ColorButton("##original", ref_col_v4, (flags & (ImGuiColorEditFlags_HDR|ImGuiColorEditFlags_AlphaPreview|ImGuiColorEditFlags_AlphaPreviewHalf|ImGuiColorEditFlags_NoTooltip)), ImVec2(square_sz * 3, square_sz * 2)))
|
||||||
{
|
{
|
||||||
memcpy(col, ref_col, ((flags & ImGuiColorEditFlags_NoAlpha) ? 3 : 4) * sizeof(float));
|
memcpy(col, ref_col, components * sizeof(float));
|
||||||
value_changed = true;
|
value_changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -10421,7 +10425,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|||||||
EndGroup();
|
EndGroup();
|
||||||
PopID();
|
PopID();
|
||||||
|
|
||||||
return value_changed;
|
return value_changed && memcmp(backup_initial_col, col, components * sizeof(float));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Horizontal separating line.
|
// Horizontal separating line.
|
||||||
|
Loading…
Reference in New Issue
Block a user