Skip to content

Commit

Permalink
ColorEdit4: Further tweaks for very small sizes. (#7120, #7121)
Browse files Browse the repository at this point in the history
  • Loading branch information
ocornut committed Dec 20, 2023
1 parent 0bd6489 commit 036a6c8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Other changes:
to allow passing through multiple widgets easily. (#3092, #5759, #787)
- DragScalarN, SliderScalarN, InputScalarN, PushMultiItemsWidths: improve multi-components
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
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.
Expand Down
5 changes: 3 additions & 2 deletions imgui_widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5127,8 +5127,8 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
const float square_sz = GetFrameHeight();
const float w_full = CalcItemWidth();
const char* label_display_end = FindRenderedTextEnd(label);
float w_full = CalcItemWidth();
g.NextItemData.ClearFlags();

BeginGroup();
Expand Down Expand Up @@ -5163,7 +5163,8 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
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);
const float w_inputs = ImMax(w_full - w_button, 1.0f);
w_full = w_inputs + w_button;

// Convert to the formats we need
float f[4] = { col[0], col[1], col[2], alpha ? col[3] : 1.0f };
Expand Down

0 comments on commit 036a6c8

Please sign in to comment.