mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-12 02:00:58 +01:00
This commit is contained in:
parent
86512eac06
commit
34646627aa
@ -5189,10 +5189,9 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|||||||
if ((flags & (ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_DisplayHSV)) != 0 && (flags & ImGuiColorEditFlags_NoInputs) == 0)
|
if ((flags & (ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_DisplayHSV)) != 0 && (flags & ImGuiColorEditFlags_NoInputs) == 0)
|
||||||
{
|
{
|
||||||
// RGB/HSV 0..255 Sliders
|
// RGB/HSV 0..255 Sliders
|
||||||
const float w_item_one = ImMax(1.0f, IM_TRUNC((w_inputs - (style.ItemInnerSpacing.x) * (components - 1)) / (float)components));
|
const float w_items = w_inputs - style.ItemInnerSpacing.x * (components - 1);
|
||||||
const float w_item_last = ImMax(1.0f, IM_TRUNC(w_inputs - (w_item_one + style.ItemInnerSpacing.x) * (components - 1)));
|
|
||||||
|
|
||||||
const bool hide_prefix = (w_item_one <= CalcTextSize((flags & ImGuiColorEditFlags_Float) ? "M:0.000" : "M:000").x);
|
const bool hide_prefix = (IM_TRUNC(w_items / components) <= CalcTextSize((flags & ImGuiColorEditFlags_Float) ? "M:0.000" : "M:000").x);
|
||||||
static const char* ids[4] = { "##X", "##Y", "##Z", "##W" };
|
static const char* ids[4] = { "##X", "##Y", "##Z", "##W" };
|
||||||
static const char* fmt_table_int[3][4] =
|
static const char* fmt_table_int[3][4] =
|
||||||
{
|
{
|
||||||
@ -5208,11 +5207,14 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|||||||
};
|
};
|
||||||
const int fmt_idx = hide_prefix ? 0 : (flags & ImGuiColorEditFlags_DisplayHSV) ? 2 : 1;
|
const int fmt_idx = hide_prefix ? 0 : (flags & ImGuiColorEditFlags_DisplayHSV) ? 2 : 1;
|
||||||
|
|
||||||
|
float prev_split = 0.0f;
|
||||||
for (int n = 0; n < components; n++)
|
for (int n = 0; n < components; n++)
|
||||||
{
|
{
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
SameLine(0, style.ItemInnerSpacing.x);
|
SameLine(0, style.ItemInnerSpacing.x);
|
||||||
SetNextItemWidth((n + 1 < components) ? w_item_one : w_item_last);
|
float next_split = IM_TRUNC(w_items * (n + 1) / components);
|
||||||
|
SetNextItemWidth(next_split - prev_split);
|
||||||
|
prev_split = next_split;
|
||||||
|
|
||||||
// FIXME: When ImGuiColorEditFlags_HDR flag is passed HS values snap in weird ways when SV values go below 0.
|
// FIXME: When ImGuiColorEditFlags_HDR flag is passed HS values snap in weird ways when SV values go below 0.
|
||||||
if (flags & ImGuiColorEditFlags_Float)
|
if (flags & ImGuiColorEditFlags_Float)
|
||||||
|
Loading…
Reference in New Issue
Block a user