|
|
@@ -2393,7 +2393,6 @@ void ImGui::NewFrame()
|
|
|
}
|
|
|
|
|
|
// Pressing TAB activate widget focus
|
|
|
- // NB: Don't discard FocusedWindow if it isn't active, so that a window that go on/off programatically won't lose its keyboard focus.
|
|
|
if (g.ActiveId == 0 && g.NavWindow != NULL && g.NavWindow->Active && IsKeyPressedMap(ImGuiKey_Tab, false))
|
|
|
g.NavWindow->FocusIdxTabRequestNext = 0;
|
|
|
|
|
|
@@ -5464,6 +5463,7 @@ void ImGui::SetScrollHere(float center_y_ratio)
|
|
|
|
|
|
void ImGui::SetKeyboardFocusHere(int offset)
|
|
|
{
|
|
|
+ IM_ASSERT(offset >= -1); // -1 is allowed but not below
|
|
|
ImGuiWindow* window = GetCurrentWindow();
|
|
|
window->FocusIdxAllRequestNext = window->FocusIdxAllCounter + 1 + offset;
|
|
|
window->FocusIdxTabRequestNext = INT_MAX;
|
|
|
@@ -5558,6 +5558,7 @@ void ImGui::TextUnformatted(const char* text, const char* text_end)
|
|
|
if (text_end == NULL)
|
|
|
text_end = text + strlen(text); // FIXME-OPT
|
|
|
|
|
|
+ const ImVec2 text_pos(window->DC.CursorPos.x, window->DC.CursorPos.y + window->DC.CurrentLineTextBaseOffset);
|
|
|
const float wrap_pos_x = window->DC.TextWrapPos;
|
|
|
const bool wrap_enabled = wrap_pos_x >= 0.0f;
|
|
|
if (text_end - text > 2000 && !wrap_enabled)
|
|
|
@@ -5568,7 +5569,6 @@ void ImGui::TextUnformatted(const char* text, const char* text_end)
|
|
|
// We also don't vertically center the text within the line full height, which is unlikely to matter because we are likely the biggest and only item on the line.
|
|
|
const char* line = text;
|
|
|
const float line_height = GetTextLineHeight();
|
|
|
- const ImVec2 text_pos = window->DC.CursorPos + ImVec2(0.0f, window->DC.CurrentLineTextBaseOffset);
|
|
|
const ImRect clip_rect = window->ClipRect;
|
|
|
ImVec2 text_size(0,0);
|
|
|
|
|
|
@@ -5642,7 +5642,6 @@ void ImGui::TextUnformatted(const char* text, const char* text_end)
|
|
|
const ImVec2 text_size = CalcTextSize(text_begin, text_end, false, wrap_width);
|
|
|
|
|
|
// Account of baseline offset
|
|
|
- ImVec2 text_pos(window->DC.CursorPos.x, window->DC.CursorPos.y + window->DC.CurrentLineTextBaseOffset);
|
|
|
ImRect bb(text_pos, text_pos + text_size);
|
|
|
ItemSize(text_size);
|
|
|
if (!ItemAdd(bb, NULL))
|
|
|
@@ -5659,10 +5658,9 @@ void ImGui::AlignFirstTextHeightToWidgets()
|
|
|
if (window->SkipItems)
|
|
|
return;
|
|
|
|
|
|
- // Declare a dummy item size to that upcoming items that are smaller will center-align on the newly expanded line height.
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
- ItemSize(ImVec2(0, g.FontSize + g.Style.FramePadding.y*2), g.Style.FramePadding.y);
|
|
|
- SameLine(0, 0);
|
|
|
+ window->DC.CurrentLineHeight = ImMax(window->DC.CurrentLineHeight, g.FontSize + g.Style.FramePadding.y * 2);
|
|
|
+ window->DC.CurrentLineTextBaseOffset = ImMax(window->DC.CurrentLineTextBaseOffset, g.Style.FramePadding.y);
|
|
|
}
|
|
|
|
|
|
// Add a label+text combo aligned to other label+value widgets
|
|
|
@@ -9289,15 +9287,18 @@ bool ImGui::ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFl
|
|
|
ImVec4 col_without_alpha(col.x, col.y, col.z, 1.0f);
|
|
|
float grid_step = ImMin(size.x, size.y) / 2.99f;
|
|
|
float rounding = ImMin(g.Style.FrameRounding, grid_step * 0.5f);
|
|
|
+ ImRect bb_inner = bb;
|
|
|
+ float off = -0.75f; // The border (using Col_FrameBg) tends to look off when color is near-opaque and rounding is enabled. This offset seemed like a good middleground to reduce those artefacts.
|
|
|
+ bb_inner.Expand(off);
|
|
|
if ((flags & ImGuiColorEditFlags_AlphaPreviewHalf) && col.w < 1.0f)
|
|
|
{
|
|
|
- float mid_x = (float)(int)((bb.Min.x + bb.Max.x) * 0.5f + 0.5f);
|
|
|
- RenderColorRectWithAlphaCheckerboard(ImVec2(bb.Min.x + grid_step, bb.Min.y), bb.Max, GetColorU32(col), grid_step, ImVec2(-grid_step, 0.0f), rounding, ImGuiCorner_TopRight|ImGuiCorner_BotRight);
|
|
|
- window->DrawList->AddRectFilled(bb.Min, ImVec2(mid_x, bb.Max.y), GetColorU32(col_without_alpha), rounding, ImGuiCorner_TopLeft|ImGuiCorner_BotLeft);
|
|
|
+ float mid_x = (float)(int)((bb_inner.Min.x + bb_inner.Max.x) * 0.5f + 0.5f);
|
|
|
+ RenderColorRectWithAlphaCheckerboard(ImVec2(bb_inner.Min.x + grid_step, bb_inner.Min.y), bb_inner.Max, GetColorU32(col), grid_step, ImVec2(-grid_step + off, off), rounding, ImGuiCorner_TopRight|ImGuiCorner_BotRight);
|
|
|
+ window->DrawList->AddRectFilled(bb_inner.Min, ImVec2(mid_x, bb_inner.Max.y), GetColorU32(col_without_alpha), rounding, ImGuiCorner_TopLeft|ImGuiCorner_BotLeft);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- RenderColorRectWithAlphaCheckerboard(bb.Min, bb.Max, GetColorU32((flags & ImGuiColorEditFlags_AlphaPreview) ? col : col_without_alpha), grid_step, ImVec2(0,0), rounding);
|
|
|
+ RenderColorRectWithAlphaCheckerboard(bb_inner.Min, bb_inner.Max, GetColorU32((flags & ImGuiColorEditFlags_AlphaPreview) ? col : col_without_alpha), grid_step, ImVec2(off, off), rounding);
|
|
|
}
|
|
|
if (window->Flags & ImGuiWindowFlags_ShowBorders)
|
|
|
RenderFrameBorder(bb.Min, bb.Max, rounding);
|