|
@@ -1512,8 +1512,10 @@ bool ImGui::BeginCombo(const char* label, const char* preview_value, ImGuiComboF
|
|
|
SetNextWindowPos(pos);
|
|
|
}
|
|
|
|
|
|
+ // We don't use BeginPopupEx() solely because we have a custom name string, which we could make an argument to BeginPopupEx()
|
|
|
+ ImGuiWindowFlags window_flags = ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_Popup | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoMove;
|
|
|
+
|
|
|
// Horizontally align ourselves with the framed text
|
|
|
- ImGuiWindowFlags window_flags = ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_Popup | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings;
|
|
|
PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(style.FramePadding.x, style.WindowPadding.y));
|
|
|
bool ret = Begin(name, NULL, window_flags);
|
|
|
PopStyleVar();
|
|
@@ -3411,11 +3413,14 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|
|
BeginGroup();
|
|
|
const ImGuiID id = window->GetID(label);
|
|
|
const ImVec2 label_size = CalcTextSize(label, NULL, true);
|
|
|
- ImVec2 size = CalcItemSize(size_arg, CalcItemWidth(), (is_multiline ? g.FontSize * 8.0f : label_size.y) + style.FramePadding.y*2.0f); // Arbitrary default of 8 lines high for multi-line
|
|
|
- const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + size);
|
|
|
- const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? (style.ItemInnerSpacing.x + label_size.x) : 0.0f, 0.0f));
|
|
|
+ const ImVec2 frame_size = CalcItemSize(size_arg, CalcItemWidth(), (is_multiline ? g.FontSize * 8.0f : label_size.y) + style.FramePadding.y*2.0f); // Arbitrary default of 8 lines high for multi-line
|
|
|
+ const ImVec2 total_size = ImVec2(frame_size.x + (label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f), frame_size.y);
|
|
|
+
|
|
|
+ const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + frame_size);
|
|
|
+ const ImRect total_bb(frame_bb.Min, frame_bb.Min + total_size);
|
|
|
|
|
|
ImGuiWindow* draw_window = window;
|
|
|
+ ImVec2 inner_size = frame_size;
|
|
|
if (is_multiline)
|
|
|
{
|
|
|
if (!ItemAdd(total_bb, id, &frame_bb))
|
|
@@ -3430,9 +3435,9 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|
|
EndGroup();
|
|
|
return false;
|
|
|
}
|
|
|
- draw_window = GetCurrentWindow();
|
|
|
+ draw_window = g.CurrentWindow; // Child window
|
|
|
draw_window->DC.NavLayerActiveMaskNext |= draw_window->DC.NavLayerCurrentMask; // This is to ensure that EndChild() will display a navigation highlight
|
|
|
- size.x -= draw_window->ScrollbarSizes.x;
|
|
|
+ inner_size.x -= draw_window->ScrollbarSizes.x;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -3921,7 +3926,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|
|
RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
|
|
|
}
|
|
|
|
|
|
- const ImVec4 clip_rect(frame_bb.Min.x, frame_bb.Min.y, frame_bb.Min.x + size.x, frame_bb.Min.y + size.y); // Not using frame_bb.Max because we have adjusted size
|
|
|
+ const ImVec4 clip_rect(frame_bb.Min.x, frame_bb.Min.y, frame_bb.Min.x + inner_size.x, frame_bb.Min.y + inner_size.y); // Not using frame_bb.Max because we have adjusted size
|
|
|
ImVec2 draw_pos = is_multiline ? draw_window->DC.CursorPos : frame_bb.Min + style.FramePadding;
|
|
|
ImVec2 text_size(0.0f, 0.0f);
|
|
|
|
|
@@ -4002,7 +4007,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|
|
|
|
|
// Store text height (note that we haven't calculated text width at all, see GitHub issues #383, #1224)
|
|
|
if (is_multiline)
|
|
|
- text_size = ImVec2(size.x, line_count * g.FontSize);
|
|
|
+ text_size = ImVec2(inner_size.x, line_count * g.FontSize);
|
|
|
}
|
|
|
|
|
|
// Scroll
|
|
@@ -4011,11 +4016,11 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|
|
// Horizontal scroll in chunks of quarter width
|
|
|
if (!(flags & ImGuiInputTextFlags_NoHorizontalScroll))
|
|
|
{
|
|
|
- const float scroll_increment_x = size.x * 0.25f;
|
|
|
+ const float scroll_increment_x = inner_size.x * 0.25f;
|
|
|
if (cursor_offset.x < state->ScrollX)
|
|
|
state->ScrollX = (float)(int)ImMax(0.0f, cursor_offset.x - scroll_increment_x);
|
|
|
- else if (cursor_offset.x - size.x >= state->ScrollX)
|
|
|
- state->ScrollX = (float)(int)(cursor_offset.x - size.x + scroll_increment_x);
|
|
|
+ else if (cursor_offset.x - inner_size.x >= state->ScrollX)
|
|
|
+ state->ScrollX = (float)(int)(cursor_offset.x - inner_size.x + scroll_increment_x);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -4028,8 +4033,8 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|
|
float scroll_y = draw_window->Scroll.y;
|
|
|
if (cursor_offset.y - g.FontSize < scroll_y)
|
|
|
scroll_y = ImMax(0.0f, cursor_offset.y - g.FontSize);
|
|
|
- else if (cursor_offset.y - size.y >= scroll_y)
|
|
|
- scroll_y = cursor_offset.y - size.y;
|
|
|
+ else if (cursor_offset.y - inner_size.y >= scroll_y)
|
|
|
+ scroll_y = cursor_offset.y - inner_size.y;
|
|
|
draw_pos.y += (draw_window->Scroll.y - scroll_y); // Manipulate cursor pos immediately avoid a frame of lag
|
|
|
draw_window->Scroll.y = scroll_y;
|
|
|
}
|
|
@@ -4103,7 +4108,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|
|
{
|
|
|
// Render text only (no selection, no cursor)
|
|
|
if (is_multiline)
|
|
|
- text_size = ImVec2(size.x, InputTextCalcTextLenAndLineCount(buf_display, &buf_display_end) * g.FontSize); // We don't need width
|
|
|
+ text_size = ImVec2(inner_size.x, InputTextCalcTextLenAndLineCount(buf_display, &buf_display_end) * g.FontSize); // We don't need width
|
|
|
else if (!is_displaying_hint && g.ActiveId == id)
|
|
|
buf_display_end = buf_display + state->CurLenA;
|
|
|
else if (!is_displaying_hint)
|