ColorEdit4: Further tweaks for very small sizes. (#7120, #7121)

This commit is contained in:
ocornut 2023-12-20 11:06:22 +01:00
parent 0bd6489721
commit 036a6c875e
2 changed files with 4 additions and 2 deletions

View File

@ -72,6 +72,7 @@ Other changes:
to allow passing through multiple widgets easily. (#3092, #5759, #787) to allow passing through multiple widgets easily. (#3092, #5759, #787)
- DragScalarN, SliderScalarN, InputScalarN, PushMultiItemsWidths: improve multi-components - DragScalarN, SliderScalarN, InputScalarN, PushMultiItemsWidths: improve multi-components
width computation to better distribute the error. (#7120, #7121) [@Nahor] width computation to better distribute the error. (#7120, #7121) [@Nahor]
- ColorEdit4: Layout tweaks for very small sizes. (#7120, #7121)
- Menus: Tweaked hover slack logic, adding a timer to avoid situations where a slow vertical - Menus: Tweaked hover slack logic, adding a timer to avoid situations where a slow vertical
movements toward another parent BeginMenu() can keep the wrong child menu open. (#6671, #6926) movements toward another parent BeginMenu() can keep the wrong child menu open. (#6671, #6926)
- Debug Tools: Added DebugFlashStyleColor() to identify a style color. Added to Style Editor. - Debug Tools: Added DebugFlashStyleColor() to identify a style color. Added to Style Editor.

View File

@ -5127,8 +5127,8 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style; const ImGuiStyle& style = g.Style;
const float square_sz = GetFrameHeight(); const float square_sz = GetFrameHeight();
const float w_full = CalcItemWidth();
const char* label_display_end = FindRenderedTextEnd(label); const char* label_display_end = FindRenderedTextEnd(label);
float w_full = CalcItemWidth();
g.NextItemData.ClearFlags(); g.NextItemData.ClearFlags();
BeginGroup(); BeginGroup();
@ -5163,7 +5163,8 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
const bool hdr = (flags & ImGuiColorEditFlags_HDR) != 0; const bool hdr = (flags & ImGuiColorEditFlags_HDR) != 0;
const int components = alpha ? 4 : 3; const int components = alpha ? 4 : 3;
const float w_button = (flags & ImGuiColorEditFlags_NoSmallPreview) ? 0.0f : (square_sz + style.ItemInnerSpacing.x); 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); const float w_inputs = ImMax(w_full - w_button, 1.0f);
w_full = w_inputs + w_button;
// Convert to the formats we need // Convert to the formats we need
float f[4] = { col[0], col[1], col[2], alpha ? col[3] : 1.0f }; float f[4] = { col[0], col[1], col[2], alpha ? col[3] : 1.0f };