-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
… multi-components width in tight space (#7120, #7121) + extra tweak color ColorEdit4() label. Amend 86512ea, 3464662
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5128,8 +5128,6 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag | |
const ImGuiStyle& style = g.Style; | ||
const float square_sz = GetFrameHeight(); | ||
const float w_full = CalcItemWidth(); | ||
const float w_button = (flags & ImGuiColorEditFlags_NoSmallPreview) ? 0.0f : (square_sz + style.ItemInnerSpacing.x); | ||
const float w_inputs = w_full - w_button; | ||
const char* label_display_end = FindRenderedTextEnd(label); | ||
g.NextItemData.ClearFlags(); | ||
|
||
|
@@ -5164,6 +5162,8 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag | |
const bool alpha = (flags & ImGuiColorEditFlags_NoAlpha) == 0; | ||
const bool hdr = (flags & ImGuiColorEditFlags_HDR) != 0; | ||
const int components = alpha ? 4 : 3; | ||
const float w_button = (flags & ImGuiColorEditFlags_NoSmallPreview) ? 0.0f : (square_sz + style.ItemInnerSpacing.x); | ||
const float w_inputs = ImMax(w_full - w_button, 1.0f * components); | ||
This comment has been minimized.
Sorry, something went wrong.
Nahor
Contributor
|
||
|
||
// Convert to the formats we need | ||
float f[4] = { col[0], col[1], col[2], alpha ? col[3] : 1.0f }; | ||
|
@@ -5211,7 +5211,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag | |
if (n > 0) | ||
SameLine(0, style.ItemInnerSpacing.x); | ||
float next_split = IM_TRUNC(w_items * (n + 1) / components); | ||
SetNextItemWidth(next_split - prev_split); | ||
SetNextItemWidth(ImMax(next_split - prev_split, 1.0f)); | ||
prev_split = next_split; | ||
|
||
// FIXME: When ImGuiColorEditFlags_HDR flag is passed HS values snap in weird ways when SV values go below 0. | ||
|
Alternatively, you could have
w_items = ImMax(components, w_full - style.ItemInnerSpacing.x * (components - 1));
Pros:
Cons: