|
@@ -1,4 +1,4 @@
|
|
|
-// dear imgui, v1.92.5
|
|
|
|
|
|
|
+// dear imgui, v1.92.6 WIP
|
|
|
// (widgets code)
|
|
// (widgets code)
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -1037,6 +1037,8 @@ bool ImGui::ScrollbarEx(const ImRect& bb_frame, ImGuiID id, ImGuiAxis axis, ImS6
|
|
|
|
|
|
|
|
// V denote the main, longer axis of the scrollbar (= height for a vertical scrollbar)
|
|
// V denote the main, longer axis of the scrollbar (= height for a vertical scrollbar)
|
|
|
const float scrollbar_size_v = (axis == ImGuiAxis_X) ? bb.GetWidth() : bb.GetHeight();
|
|
const float scrollbar_size_v = (axis == ImGuiAxis_X) ? bb.GetWidth() : bb.GetHeight();
|
|
|
|
|
+ if (scrollbar_size_v < 1.0f)
|
|
|
|
|
+ return false;
|
|
|
|
|
|
|
|
// Calculate the height of our grabbable box. It generally represent the amount visible (vs the total scrollable amount)
|
|
// Calculate the height of our grabbable box. It generally represent the amount visible (vs the total scrollable amount)
|
|
|
// But we maintain a minimum size in pixel to allow for the user to still aim inside.
|
|
// But we maintain a minimum size in pixel to allow for the user to still aim inside.
|
|
@@ -1438,7 +1440,10 @@ void ImGui::ProgressBar(float fraction, const ImVec2& size_arg, const char* over
|
|
|
// Render
|
|
// Render
|
|
|
RenderFrame(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
|
|
RenderFrame(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
|
|
|
bb.Expand(ImVec2(-style.FrameBorderSize, -style.FrameBorderSize));
|
|
bb.Expand(ImVec2(-style.FrameBorderSize, -style.FrameBorderSize));
|
|
|
- RenderRectFilledRangeH(window->DrawList, bb, GetColorU32(ImGuiCol_PlotHistogram), fill_n0, fill_n1, style.FrameRounding);
|
|
|
|
|
|
|
+ float fill_x0 = ImLerp(bb.Min.x, bb.Max.x, fill_n0);
|
|
|
|
|
+ float fill_x1 = ImLerp(bb.Min.x, bb.Max.x, fill_n1);
|
|
|
|
|
+ if (fill_x0 < fill_x1)
|
|
|
|
|
+ RenderRectFilledInRangeH(window->DrawList, bb, GetColorU32(ImGuiCol_PlotHistogram), fill_x0, fill_x1, style.FrameRounding);
|
|
|
|
|
|
|
|
// Default displaying the fraction as percentage string, but user can override it
|
|
// Default displaying the fraction as percentage string, but user can override it
|
|
|
// Don't display text for indeterminate bars by default
|
|
// Don't display text for indeterminate bars by default
|
|
@@ -1454,7 +1459,7 @@ void ImGui::ProgressBar(float fraction, const ImVec2& size_arg, const char* over
|
|
|
ImVec2 overlay_size = CalcTextSize(overlay, NULL);
|
|
ImVec2 overlay_size = CalcTextSize(overlay, NULL);
|
|
|
if (overlay_size.x > 0.0f)
|
|
if (overlay_size.x > 0.0f)
|
|
|
{
|
|
{
|
|
|
- float text_x = is_indeterminate ? (bb.Min.x + bb.Max.x - overlay_size.x) * 0.5f : ImLerp(bb.Min.x, bb.Max.x, fill_n1) + style.ItemSpacing.x;
|
|
|
|
|
|
|
+ float text_x = is_indeterminate ? (bb.Min.x + bb.Max.x - overlay_size.x) * 0.5f : fill_x1 + style.ItemSpacing.x;
|
|
|
RenderTextClipped(ImVec2(ImClamp(text_x, bb.Min.x, bb.Max.x - overlay_size.x - style.ItemInnerSpacing.x), bb.Min.y), bb.Max, overlay, NULL, &overlay_size, ImVec2(0.0f, 0.5f), &bb);
|
|
RenderTextClipped(ImVec2(ImClamp(text_x, bb.Min.x, bb.Max.x - overlay_size.x - style.ItemInnerSpacing.x), bb.Min.y), bb.Max, overlay, NULL, &overlay_size, ImVec2(0.0f, 0.5f), &bb);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -1832,7 +1837,7 @@ static int IMGUI_CDECL ShrinkWidthItemComparer(const void* lhs, const void* rhs)
|
|
|
const ImGuiShrinkWidthItem* b = (const ImGuiShrinkWidthItem*)rhs;
|
|
const ImGuiShrinkWidthItem* b = (const ImGuiShrinkWidthItem*)rhs;
|
|
|
if (int d = (int)(b->Width - a->Width))
|
|
if (int d = (int)(b->Width - a->Width))
|
|
|
return d;
|
|
return d;
|
|
|
- return (b->Index - a->Index);
|
|
|
|
|
|
|
+ return b->Index - a->Index;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Shrink excess width from a set of item, by removing width from the larger items first.
|
|
// Shrink excess width from a set of item, by removing width from the larger items first.
|
|
@@ -2235,6 +2240,11 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*old_getter)(void*
|
|
|
// - RoundScalarWithFormat<>()
|
|
// - RoundScalarWithFormat<>()
|
|
|
//-------------------------------------------------------------------------
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
+static const ImU32 GDefaultRgbaColorMarkers[4] =
|
|
|
|
|
+{
|
|
|
|
|
+ IM_COL32(240,20,20,255), IM_COL32(20,240,20,255), IM_COL32(20,20,240,255), IM_COL32(140,140,140,255)
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
static const ImGuiDataTypeInfo GDataTypeInfo[] =
|
|
static const ImGuiDataTypeInfo GDataTypeInfo[] =
|
|
|
{
|
|
{
|
|
|
{ sizeof(char), "S8", "%d", "%d" }, // ImGuiDataType_S8
|
|
{ sizeof(char), "S8", "%d", "%d" }, // ImGuiDataType_S8
|
|
@@ -2683,6 +2693,7 @@ bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* p_data,
|
|
|
const ImGuiStyle& style = g.Style;
|
|
const ImGuiStyle& style = g.Style;
|
|
|
const ImGuiID id = window->GetID(label);
|
|
const ImGuiID id = window->GetID(label);
|
|
|
const float w = CalcItemWidth();
|
|
const float w = CalcItemWidth();
|
|
|
|
|
+ const ImU32 color_marker = (g.NextItemData.HasFlags & ImGuiNextItemDataFlags_HasColorMarker) ? g.NextItemData.ColorMarker : 0;
|
|
|
|
|
|
|
|
const ImVec2 label_size = CalcTextSize(label, NULL, true);
|
|
const ImVec2 label_size = CalcTextSize(label, NULL, true);
|
|
|
const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y * 2.0f));
|
|
const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y * 2.0f));
|
|
@@ -2751,7 +2762,10 @@ bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* p_data,
|
|
|
// Draw frame
|
|
// Draw frame
|
|
|
const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
|
|
const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
|
|
|
RenderNavCursor(frame_bb, id);
|
|
RenderNavCursor(frame_bb, id);
|
|
|
- RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, true, style.FrameRounding);
|
|
|
|
|
|
|
+ RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, false, style.FrameRounding);
|
|
|
|
|
+ if (color_marker != 0 && style.ColorMarkerSize > 0.0f)
|
|
|
|
|
+ RenderColorComponentMarker(frame_bb, GetColorU32(color_marker), style.FrameRounding);
|
|
|
|
|
+ RenderFrameBorder(frame_bb.Min, frame_bb.Max, g.Style.FrameRounding);
|
|
|
|
|
|
|
|
// Drag behavior
|
|
// Drag behavior
|
|
|
const bool value_changed = DragBehavior(id, data_type, p_data, v_speed, p_min, p_max, format, flags);
|
|
const bool value_changed = DragBehavior(id, data_type, p_data, v_speed, p_min, p_max, format, flags);
|
|
@@ -2789,6 +2803,8 @@ bool ImGui::DragScalarN(const char* label, ImGuiDataType data_type, void* p_data
|
|
|
PushID(i);
|
|
PushID(i);
|
|
|
if (i > 0)
|
|
if (i > 0)
|
|
|
SameLine(0, g.Style.ItemInnerSpacing.x);
|
|
SameLine(0, g.Style.ItemInnerSpacing.x);
|
|
|
|
|
+ if (flags & ImGuiSliderFlags_ColorMarkers)
|
|
|
|
|
+ SetNextItemColorMarker(GDefaultRgbaColorMarkers[i]);
|
|
|
value_changed |= DragScalar("", data_type, p_data, v_speed, p_min, p_max, format, flags);
|
|
value_changed |= DragScalar("", data_type, p_data, v_speed, p_min, p_max, format, flags);
|
|
|
PopID();
|
|
PopID();
|
|
|
PopItemWidth();
|
|
PopItemWidth();
|
|
@@ -3302,6 +3318,7 @@ bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* p_dat
|
|
|
const ImGuiStyle& style = g.Style;
|
|
const ImGuiStyle& style = g.Style;
|
|
|
const ImGuiID id = window->GetID(label);
|
|
const ImGuiID id = window->GetID(label);
|
|
|
const float w = CalcItemWidth();
|
|
const float w = CalcItemWidth();
|
|
|
|
|
+ const ImU32 color_marker = (g.NextItemData.HasFlags & ImGuiNextItemDataFlags_HasColorMarker) ? g.NextItemData.ColorMarker : 0;
|
|
|
|
|
|
|
|
const ImVec2 label_size = CalcTextSize(label, NULL, true);
|
|
const ImVec2 label_size = CalcTextSize(label, NULL, true);
|
|
|
const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y * 2.0f));
|
|
const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y * 2.0f));
|
|
@@ -3352,7 +3369,10 @@ bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* p_dat
|
|
|
// Draw frame
|
|
// Draw frame
|
|
|
const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
|
|
const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
|
|
|
RenderNavCursor(frame_bb, id);
|
|
RenderNavCursor(frame_bb, id);
|
|
|
- RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, true, g.Style.FrameRounding);
|
|
|
|
|
|
|
+ RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, false, style.FrameRounding);
|
|
|
|
|
+ if (color_marker != 0 && style.ColorMarkerSize > 0.0f)
|
|
|
|
|
+ RenderColorComponentMarker(frame_bb, GetColorU32(color_marker), style.FrameRounding);
|
|
|
|
|
+ RenderFrameBorder(frame_bb.Min, frame_bb.Max, g.Style.FrameRounding);
|
|
|
|
|
|
|
|
// Slider behavior
|
|
// Slider behavior
|
|
|
ImRect grab_bb;
|
|
ImRect grab_bb;
|
|
@@ -3396,6 +3416,8 @@ bool ImGui::SliderScalarN(const char* label, ImGuiDataType data_type, void* v, i
|
|
|
PushID(i);
|
|
PushID(i);
|
|
|
if (i > 0)
|
|
if (i > 0)
|
|
|
SameLine(0, g.Style.ItemInnerSpacing.x);
|
|
SameLine(0, g.Style.ItemInnerSpacing.x);
|
|
|
|
|
+ if (flags & ImGuiSliderFlags_ColorMarkers)
|
|
|
|
|
+ SetNextItemColorMarker(GDefaultRgbaColorMarkers[i]);
|
|
|
value_changed |= SliderScalar("", data_type, v, v_min, v_max, format, flags);
|
|
value_changed |= SliderScalar("", data_type, v, v_min, v_max, format, flags);
|
|
|
PopID();
|
|
PopID();
|
|
|
PopItemWidth();
|
|
PopItemWidth();
|
|
@@ -5794,8 +5816,10 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|
|
{
|
|
{
|
|
|
// RGB/HSV 0..255 Sliders
|
|
// RGB/HSV 0..255 Sliders
|
|
|
const float w_items = w_inputs - style.ItemInnerSpacing.x * (components - 1);
|
|
const float w_items = w_inputs - style.ItemInnerSpacing.x * (components - 1);
|
|
|
|
|
+ const float w_per_component = IM_TRUNC(w_items / components);
|
|
|
|
|
+ const bool draw_color_marker = (flags & (ImGuiColorEditFlags_DisplayHSV | ImGuiColorEditFlags_NoColorMarkers)) == 0;
|
|
|
|
|
|
|
|
- const bool hide_prefix = (IM_TRUNC(w_items / components) <= CalcTextSize((flags & ImGuiColorEditFlags_Float) ? "M:0.000" : "M:000").x);
|
|
|
|
|
|
|
+ const bool hide_prefix = draw_color_marker || (w_per_component <= CalcTextSize((flags & ImGuiColorEditFlags_Float) ? "M:0.000" : "M:000").x);
|
|
|
static const char* ids[4] = { "##X", "##Y", "##Z", "##W" };
|
|
static const char* ids[4] = { "##X", "##Y", "##Z", "##W" };
|
|
|
static const char* fmt_table_int[3][4] =
|
|
static const char* fmt_table_int[3][4] =
|
|
|
{
|
|
{
|
|
@@ -5810,6 +5834,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|
|
{ "H:%0.3f", "S:%0.3f", "V:%0.3f", "A:%0.3f" } // Long display for HSVA
|
|
{ "H:%0.3f", "S:%0.3f", "V:%0.3f", "A:%0.3f" } // Long display for HSVA
|
|
|
};
|
|
};
|
|
|
const int fmt_idx = hide_prefix ? 0 : (flags & ImGuiColorEditFlags_DisplayHSV) ? 2 : 1;
|
|
const int fmt_idx = hide_prefix ? 0 : (flags & ImGuiColorEditFlags_DisplayHSV) ? 2 : 1;
|
|
|
|
|
+ const ImGuiSliderFlags drag_flags = draw_color_marker ? ImGuiSliderFlags_ColorMarkers : ImGuiSliderFlags_None;
|
|
|
|
|
|
|
|
float prev_split = 0.0f;
|
|
float prev_split = 0.0f;
|
|
|
for (int n = 0; n < components; n++)
|
|
for (int n = 0; n < components; n++)
|
|
@@ -5819,16 +5844,18 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|
|
float next_split = IM_TRUNC(w_items * (n + 1) / components);
|
|
float next_split = IM_TRUNC(w_items * (n + 1) / components);
|
|
|
SetNextItemWidth(ImMax(next_split - prev_split, 1.0f));
|
|
SetNextItemWidth(ImMax(next_split - prev_split, 1.0f));
|
|
|
prev_split = next_split;
|
|
prev_split = next_split;
|
|
|
|
|
+ if (draw_color_marker)
|
|
|
|
|
+ SetNextItemColorMarker(GDefaultRgbaColorMarkers[n]);
|
|
|
|
|
|
|
|
// FIXME: When ImGuiColorEditFlags_HDR flag is passed HS values snap in weird ways when SV values go below 0.
|
|
// FIXME: When ImGuiColorEditFlags_HDR flag is passed HS values snap in weird ways when SV values go below 0.
|
|
|
if (flags & ImGuiColorEditFlags_Float)
|
|
if (flags & ImGuiColorEditFlags_Float)
|
|
|
{
|
|
{
|
|
|
- value_changed |= DragFloat(ids[n], &f[n], 1.0f / 255.0f, 0.0f, hdr ? 0.0f : 1.0f, fmt_table_float[fmt_idx][n]);
|
|
|
|
|
|
|
+ value_changed |= DragFloat(ids[n], &f[n], 1.0f / 255.0f, 0.0f, hdr ? 0.0f : 1.0f, fmt_table_float[fmt_idx][n], drag_flags);
|
|
|
value_changed_as_float |= value_changed;
|
|
value_changed_as_float |= value_changed;
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- value_changed |= DragInt(ids[n], &i[n], 1.0f, 0, hdr ? 0 : 255, fmt_table_int[fmt_idx][n]);
|
|
|
|
|
|
|
+ value_changed |= DragInt(ids[n], &i[n], 1.0f, 0, hdr ? 0 : 255, fmt_table_int[fmt_idx][n], drag_flags);
|
|
|
}
|
|
}
|
|
|
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
|
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
|
|
OpenPopupOnItemClick("context", ImGuiPopupFlags_MouseButtonRight);
|
|
OpenPopupOnItemClick("context", ImGuiPopupFlags_MouseButtonRight);
|
|
@@ -6789,7 +6816,6 @@ static void TreeNodeStoreStackData(ImGuiTreeNodeFlags flags, float x1)
|
|
|
window->DC.TreeRecordsClippedNodesY2Mask |= (1 << window->DC.TreeDepth);
|
|
window->DC.TreeRecordsClippedNodesY2Mask |= (1 << window->DC.TreeDepth);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// When using public API, currently 'id == storage_id' is always true, but we separate the values to facilitate advanced user code doing storage queries outside of UI loop.
|
|
|
|
|
bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end)
|
|
bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end)
|
|
|
{
|
|
{
|
|
|
ImGuiWindow* window = GetCurrentWindow();
|
|
ImGuiWindow* window = GetCurrentWindow();
|
|
@@ -6798,26 +6824,28 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
|
|
|
|
|
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
|
const ImGuiStyle& style = g.Style;
|
|
const ImGuiStyle& style = g.Style;
|
|
|
|
|
+
|
|
|
|
|
+ // When not framed, we vertically increase height up to typical framed widget height
|
|
|
const bool display_frame = (flags & ImGuiTreeNodeFlags_Framed) != 0;
|
|
const bool display_frame = (flags & ImGuiTreeNodeFlags_Framed) != 0;
|
|
|
- const ImVec2 padding = (display_frame || (flags & ImGuiTreeNodeFlags_FramePadding)) ? style.FramePadding : ImVec2(style.FramePadding.x, ImMin(window->DC.CurrLineTextBaseOffset, style.FramePadding.y));
|
|
|
|
|
|
|
+ const bool use_frame_padding = (display_frame || (flags & ImGuiTreeNodeFlags_FramePadding));
|
|
|
|
|
+ const ImVec2 padding = use_frame_padding ? style.FramePadding : ImVec2(style.FramePadding.x, ImMin(window->DC.CurrLineTextBaseOffset, style.FramePadding.y));
|
|
|
|
|
|
|
|
if (!label_end)
|
|
if (!label_end)
|
|
|
label_end = FindRenderedTextEnd(label);
|
|
label_end = FindRenderedTextEnd(label);
|
|
|
const ImVec2 label_size = CalcTextSize(label, label_end, false);
|
|
const ImVec2 label_size = CalcTextSize(label, label_end, false);
|
|
|
|
|
|
|
|
const float text_offset_x = g.FontSize + (display_frame ? padding.x * 3 : padding.x * 2); // Collapsing arrow width + Spacing
|
|
const float text_offset_x = g.FontSize + (display_frame ? padding.x * 3 : padding.x * 2); // Collapsing arrow width + Spacing
|
|
|
- const float text_offset_y = ImMax(padding.y, window->DC.CurrLineTextBaseOffset); // Latch before ItemSize changes it
|
|
|
|
|
|
|
+ const float text_offset_y = use_frame_padding ? ImMax(style.FramePadding.y, window->DC.CurrLineTextBaseOffset) : window->DC.CurrLineTextBaseOffset; // Latch before ItemSize changes it
|
|
|
const float text_width = g.FontSize + label_size.x + padding.x * 2; // Include collapsing arrow
|
|
const float text_width = g.FontSize + label_size.x + padding.x * 2; // Include collapsing arrow
|
|
|
|
|
|
|
|
- // We vertically grow up to current line height up the typical widget height.
|
|
|
|
|
- const float frame_height = ImMax(ImMin(window->DC.CurrLineSize.y, g.FontSize + style.FramePadding.y * 2), label_size.y + padding.y * 2);
|
|
|
|
|
|
|
+ const float frame_height = label_size.y + padding.y * 2;
|
|
|
const bool span_all_columns = (flags & ImGuiTreeNodeFlags_SpanAllColumns) != 0 && (g.CurrentTable != NULL);
|
|
const bool span_all_columns = (flags & ImGuiTreeNodeFlags_SpanAllColumns) != 0 && (g.CurrentTable != NULL);
|
|
|
const bool span_all_columns_label = (flags & ImGuiTreeNodeFlags_LabelSpanAllColumns) != 0 && (g.CurrentTable != NULL);
|
|
const bool span_all_columns_label = (flags & ImGuiTreeNodeFlags_LabelSpanAllColumns) != 0 && (g.CurrentTable != NULL);
|
|
|
ImRect frame_bb;
|
|
ImRect frame_bb;
|
|
|
frame_bb.Min.x = span_all_columns ? window->ParentWorkRect.Min.x : (flags & ImGuiTreeNodeFlags_SpanFullWidth) ? window->WorkRect.Min.x : window->DC.CursorPos.x;
|
|
frame_bb.Min.x = span_all_columns ? window->ParentWorkRect.Min.x : (flags & ImGuiTreeNodeFlags_SpanFullWidth) ? window->WorkRect.Min.x : window->DC.CursorPos.x;
|
|
|
- frame_bb.Min.y = window->DC.CursorPos.y;
|
|
|
|
|
|
|
+ frame_bb.Min.y = window->DC.CursorPos.y + (text_offset_y - padding.y);
|
|
|
frame_bb.Max.x = span_all_columns ? window->ParentWorkRect.Max.x : (flags & ImGuiTreeNodeFlags_SpanLabelWidth) ? window->DC.CursorPos.x + text_width + padding.x : window->WorkRect.Max.x;
|
|
frame_bb.Max.x = span_all_columns ? window->ParentWorkRect.Max.x : (flags & ImGuiTreeNodeFlags_SpanLabelWidth) ? window->DC.CursorPos.x + text_width + padding.x : window->WorkRect.Max.x;
|
|
|
- frame_bb.Max.y = window->DC.CursorPos.y + frame_height;
|
|
|
|
|
|
|
+ frame_bb.Max.y = window->DC.CursorPos.y + (text_offset_y - padding.y) + frame_height;
|
|
|
if (display_frame)
|
|
if (display_frame)
|
|
|
{
|
|
{
|
|
|
const float outer_extend = IM_TRUNC(window->WindowPadding.x * 0.5f); // Framed header expand a little outside of current limits
|
|
const float outer_extend = IM_TRUNC(window->WindowPadding.x * 0.5f); // Framed header expand a little outside of current limits
|
|
@@ -9205,7 +9233,8 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
|
|
|
// The reference position stored in popup_pos will be used by Begin() to find a suitable position for the child menu,
|
|
// The reference position stored in popup_pos will be used by Begin() to find a suitable position for the child menu,
|
|
|
// However the final position is going to be different! It is chosen by FindBestWindowPosForPopup().
|
|
// However the final position is going to be different! It is chosen by FindBestWindowPosForPopup().
|
|
|
// e.g. Menus tend to overlap each other horizontally to amplify relative Z-ordering.
|
|
// e.g. Menus tend to overlap each other horizontally to amplify relative Z-ordering.
|
|
|
- ImVec2 popup_pos, pos = window->DC.CursorPos;
|
|
|
|
|
|
|
+ ImVec2 popup_pos;
|
|
|
|
|
+ ImVec2 pos = window->DC.CursorPos;
|
|
|
PushID(label);
|
|
PushID(label);
|
|
|
if (!enabled)
|
|
if (!enabled)
|
|
|
BeginDisabled();
|
|
BeginDisabled();
|
|
@@ -9219,34 +9248,34 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
|
|
|
// Menu inside a horizontal menu bar
|
|
// Menu inside a horizontal menu bar
|
|
|
// Selectable extend their highlight by half ItemSpacing in each direction.
|
|
// Selectable extend their highlight by half ItemSpacing in each direction.
|
|
|
// For ChildMenu, the popup position will be overwritten by the call to FindBestWindowPosForPopup() in Begin()
|
|
// For ChildMenu, the popup position will be overwritten by the call to FindBestWindowPosForPopup() in Begin()
|
|
|
- popup_pos = ImVec2(pos.x - 1.0f - IM_TRUNC(style.ItemSpacing.x * 0.5f), pos.y - style.FramePadding.y + window->MenuBarHeight);
|
|
|
|
|
window->DC.CursorPos.x += IM_TRUNC(style.ItemSpacing.x * 0.5f);
|
|
window->DC.CursorPos.x += IM_TRUNC(style.ItemSpacing.x * 0.5f);
|
|
|
PushStyleVarX(ImGuiStyleVar_ItemSpacing, style.ItemSpacing.x * 2.0f);
|
|
PushStyleVarX(ImGuiStyleVar_ItemSpacing, style.ItemSpacing.x * 2.0f);
|
|
|
float w = label_size.x;
|
|
float w = label_size.x;
|
|
|
- ImVec2 text_pos(window->DC.CursorPos.x + offsets->OffsetLabel, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset);
|
|
|
|
|
|
|
+ ImVec2 text_pos(window->DC.CursorPos.x + offsets->OffsetLabel, pos.y + window->DC.CurrLineTextBaseOffset);
|
|
|
pressed = Selectable("", menu_is_open, selectable_flags, ImVec2(w, label_size.y));
|
|
pressed = Selectable("", menu_is_open, selectable_flags, ImVec2(w, label_size.y));
|
|
|
LogSetNextTextDecoration("[", "]");
|
|
LogSetNextTextDecoration("[", "]");
|
|
|
RenderText(text_pos, label);
|
|
RenderText(text_pos, label);
|
|
|
PopStyleVar();
|
|
PopStyleVar();
|
|
|
window->DC.CursorPos.x += IM_TRUNC(style.ItemSpacing.x * (-1.0f + 0.5f)); // -1 spacing to compensate the spacing added when Selectable() did a SameLine(). It would also work to call SameLine() ourselves after the PopStyleVar().
|
|
window->DC.CursorPos.x += IM_TRUNC(style.ItemSpacing.x * (-1.0f + 0.5f)); // -1 spacing to compensate the spacing added when Selectable() did a SameLine(). It would also work to call SameLine() ourselves after the PopStyleVar().
|
|
|
|
|
+ popup_pos = ImVec2(pos.x - 1.0f - IM_TRUNC(style.ItemSpacing.x * 0.5f), text_pos.y - style.FramePadding.y + window->MenuBarHeight);
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
// Menu inside a regular/vertical menu
|
|
// Menu inside a regular/vertical menu
|
|
|
// (In a typical menu window where all items are BeginMenu() or MenuItem() calls, extra_w will always be 0.0f.
|
|
// (In a typical menu window where all items are BeginMenu() or MenuItem() calls, extra_w will always be 0.0f.
|
|
|
// Only when they are other items sticking out we're going to add spacing, yet only register minimum width into the layout system.)
|
|
// Only when they are other items sticking out we're going to add spacing, yet only register minimum width into the layout system.)
|
|
|
- popup_pos = ImVec2(pos.x, pos.y - style.WindowPadding.y);
|
|
|
|
|
float icon_w = (icon && icon[0]) ? CalcTextSize(icon, NULL).x : 0.0f;
|
|
float icon_w = (icon && icon[0]) ? CalcTextSize(icon, NULL).x : 0.0f;
|
|
|
float checkmark_w = IM_TRUNC(g.FontSize * 1.20f);
|
|
float checkmark_w = IM_TRUNC(g.FontSize * 1.20f);
|
|
|
float min_w = window->DC.MenuColumns.DeclColumns(icon_w, label_size.x, 0.0f, checkmark_w); // Feedback to next frame
|
|
float min_w = window->DC.MenuColumns.DeclColumns(icon_w, label_size.x, 0.0f, checkmark_w); // Feedback to next frame
|
|
|
float extra_w = ImMax(0.0f, GetContentRegionAvail().x - min_w);
|
|
float extra_w = ImMax(0.0f, GetContentRegionAvail().x - min_w);
|
|
|
- ImVec2 text_pos(window->DC.CursorPos.x + offsets->OffsetLabel, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset);
|
|
|
|
|
|
|
+ ImVec2 text_pos(window->DC.CursorPos.x, pos.y + window->DC.CurrLineTextBaseOffset);
|
|
|
pressed = Selectable("", menu_is_open, selectable_flags | ImGuiSelectableFlags_SpanAvailWidth, ImVec2(min_w, label_size.y));
|
|
pressed = Selectable("", menu_is_open, selectable_flags | ImGuiSelectableFlags_SpanAvailWidth, ImVec2(min_w, label_size.y));
|
|
|
LogSetNextTextDecoration("", ">");
|
|
LogSetNextTextDecoration("", ">");
|
|
|
- RenderText(text_pos, label);
|
|
|
|
|
|
|
+ RenderText(ImVec2(text_pos.x + offsets->OffsetLabel, text_pos.y), label);
|
|
|
if (icon_w > 0.0f)
|
|
if (icon_w > 0.0f)
|
|
|
- RenderText(pos + ImVec2(offsets->OffsetIcon, 0.0f), icon);
|
|
|
|
|
- RenderArrow(window->DrawList, pos + ImVec2(offsets->OffsetMark + extra_w + g.FontSize * 0.30f, 0.0f), GetColorU32(ImGuiCol_Text), ImGuiDir_Right);
|
|
|
|
|
|
|
+ RenderText(ImVec2(text_pos.x + offsets->OffsetIcon, text_pos.y), icon);
|
|
|
|
|
+ RenderArrow(window->DrawList, ImVec2(text_pos.x + offsets->OffsetMark + extra_w + g.FontSize * 0.30f, text_pos.y), GetColorU32(ImGuiCol_Text), ImGuiDir_Right);
|
|
|
|
|
+ popup_pos = ImVec2(pos.x, text_pos.y - style.WindowPadding.y);
|
|
|
}
|
|
}
|
|
|
if (!enabled)
|
|
if (!enabled)
|
|
|
EndDisabled();
|
|
EndDisabled();
|
|
@@ -9447,21 +9476,22 @@ bool ImGui::MenuItemEx(const char* label, const char* icon, const char* shortcut
|
|
|
float checkmark_w = IM_TRUNC(g.FontSize * 1.20f);
|
|
float checkmark_w = IM_TRUNC(g.FontSize * 1.20f);
|
|
|
float min_w = window->DC.MenuColumns.DeclColumns(icon_w, label_size.x, shortcut_w, checkmark_w); // Feedback for next frame
|
|
float min_w = window->DC.MenuColumns.DeclColumns(icon_w, label_size.x, shortcut_w, checkmark_w); // Feedback for next frame
|
|
|
float stretch_w = ImMax(0.0f, GetContentRegionAvail().x - min_w);
|
|
float stretch_w = ImMax(0.0f, GetContentRegionAvail().x - min_w);
|
|
|
|
|
+ ImVec2 text_pos(pos.x, pos.y + window->DC.CurrLineTextBaseOffset);
|
|
|
pressed = Selectable("", false, selectable_flags | ImGuiSelectableFlags_SpanAvailWidth, ImVec2(min_w, label_size.y));
|
|
pressed = Selectable("", false, selectable_flags | ImGuiSelectableFlags_SpanAvailWidth, ImVec2(min_w, label_size.y));
|
|
|
if (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_Visible)
|
|
if (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_Visible)
|
|
|
{
|
|
{
|
|
|
- RenderText(pos + ImVec2(offsets->OffsetLabel, 0.0f), label);
|
|
|
|
|
|
|
+ RenderText(text_pos + ImVec2(offsets->OffsetLabel, 0.0f), label);
|
|
|
if (icon_w > 0.0f)
|
|
if (icon_w > 0.0f)
|
|
|
- RenderText(pos + ImVec2(offsets->OffsetIcon, 0.0f), icon);
|
|
|
|
|
|
|
+ RenderText(text_pos + ImVec2(offsets->OffsetIcon, 0.0f), icon);
|
|
|
if (shortcut_w > 0.0f)
|
|
if (shortcut_w > 0.0f)
|
|
|
{
|
|
{
|
|
|
PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]);
|
|
PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]);
|
|
|
LogSetNextTextDecoration("(", ")");
|
|
LogSetNextTextDecoration("(", ")");
|
|
|
- RenderText(pos + ImVec2(offsets->OffsetShortcut + stretch_w, 0.0f), shortcut, NULL, false);
|
|
|
|
|
|
|
+ RenderText(text_pos + ImVec2(offsets->OffsetShortcut + stretch_w, 0.0f), shortcut, NULL, false);
|
|
|
PopStyleColor();
|
|
PopStyleColor();
|
|
|
}
|
|
}
|
|
|
if (selected)
|
|
if (selected)
|
|
|
- RenderCheckMark(window->DrawList, pos + ImVec2(offsets->OffsetMark + stretch_w + g.FontSize * 0.40f, g.FontSize * 0.134f * 0.5f), GetColorU32(ImGuiCol_Text), g.FontSize * 0.866f);
|
|
|
|
|
|
|
+ RenderCheckMark(window->DrawList, text_pos + ImVec2(offsets->OffsetMark + stretch_w + g.FontSize * 0.40f, g.FontSize * 0.134f * 0.5f), GetColorU32(ImGuiCol_Text), g.FontSize * 0.866f);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
IMGUI_TEST_ENGINE_ITEM_INFO(g.LastItemData.ID, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Checkable | (selected ? ImGuiItemStatusFlags_Checked : 0));
|
|
IMGUI_TEST_ENGINE_ITEM_INFO(g.LastItemData.ID, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Checkable | (selected ? ImGuiItemStatusFlags_Checked : 0));
|
|
@@ -9773,8 +9803,9 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
|
|
ImQsort(tab_bar->Tabs.Data, tab_bar->Tabs.Size, sizeof(ImGuiTabItem), TabItemComparerBySection);
|
|
ImQsort(tab_bar->Tabs.Data, tab_bar->Tabs.Size, sizeof(ImGuiTabItem), TabItemComparerBySection);
|
|
|
|
|
|
|
|
// Calculate spacing between sections
|
|
// Calculate spacing between sections
|
|
|
- sections[0].Spacing = sections[0].TabCount > 0 && (sections[1].TabCount + sections[2].TabCount) > 0 ? g.Style.ItemInnerSpacing.x : 0.0f;
|
|
|
|
|
- sections[1].Spacing = sections[1].TabCount > 0 && sections[2].TabCount > 0 ? g.Style.ItemInnerSpacing.x : 0.0f;
|
|
|
|
|
|
|
+ const float tab_spacing = g.Style.ItemInnerSpacing.x;
|
|
|
|
|
+ sections[0].Spacing = sections[0].TabCount > 0 && (sections[1].TabCount + sections[2].TabCount) > 0 ? tab_spacing : 0.0f;
|
|
|
|
|
+ sections[1].Spacing = sections[1].TabCount > 0 && sections[2].TabCount > 0 ? tab_spacing : 0.0f;
|
|
|
|
|
|
|
|
// Setup next selected tab
|
|
// Setup next selected tab
|
|
|
ImGuiID scroll_to_tab_id = 0;
|
|
ImGuiID scroll_to_tab_id = 0;
|
|
@@ -9835,8 +9866,8 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
|
|
|
|
|
|
|
int section_n = TabItemGetSectionIdx(tab);
|
|
int section_n = TabItemGetSectionIdx(tab);
|
|
|
ImGuiTabBarSection* section = §ions[section_n];
|
|
ImGuiTabBarSection* section = §ions[section_n];
|
|
|
- section->Width += tab->ContentWidth + (section_n == curr_section_n ? g.Style.ItemInnerSpacing.x : 0.0f);
|
|
|
|
|
- section->WidthAfterShrinkMinWidth += ImMin(tab->ContentWidth, shrink_min_width) + (section_n == curr_section_n ? g.Style.ItemInnerSpacing.x : 0.0f);
|
|
|
|
|
|
|
+ section->Width += tab->ContentWidth + (section_n == curr_section_n ? tab_spacing : 0.0f);
|
|
|
|
|
+ section->WidthAfterShrinkMinWidth += ImMin(tab->ContentWidth, shrink_min_width) + (section_n == curr_section_n ? tab_spacing : 0.0f);
|
|
|
curr_section_n = section_n;
|
|
curr_section_n = section_n;
|
|
|
|
|
|
|
|
// Store data so we can build an array sorted by width if we need to shrink tabs down
|
|
// Store data so we can build an array sorted by width if we need to shrink tabs down
|
|
@@ -10141,6 +10172,7 @@ void ImGui::TabBarQueueReorderFromMousePos(ImGuiTabBar* tab_bar, ImGuiTabItem* s
|
|
|
if ((tab_bar->Flags & ImGuiTabBarFlags_Reorderable) == 0)
|
|
if ((tab_bar->Flags & ImGuiTabBarFlags_Reorderable) == 0)
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
|
|
+ const float tab_spacing = g.Style.ItemInnerSpacing.x;
|
|
|
const bool is_central_section = (src_tab->Flags & ImGuiTabItemFlags_SectionMask_) == 0;
|
|
const bool is_central_section = (src_tab->Flags & ImGuiTabItemFlags_SectionMask_) == 0;
|
|
|
const float bar_offset = tab_bar->BarRect.Min.x - (is_central_section ? tab_bar->ScrollingTarget : 0);
|
|
const float bar_offset = tab_bar->BarRect.Min.x - (is_central_section ? tab_bar->ScrollingTarget : 0);
|
|
|
|
|
|
|
@@ -10159,8 +10191,8 @@ void ImGui::TabBarQueueReorderFromMousePos(ImGuiTabBar* tab_bar, ImGuiTabItem* s
|
|
|
dst_idx = i;
|
|
dst_idx = i;
|
|
|
|
|
|
|
|
// Include spacing after tab, so when mouse cursor is between tabs we would not continue checking further tabs that are not hovered.
|
|
// Include spacing after tab, so when mouse cursor is between tabs we would not continue checking further tabs that are not hovered.
|
|
|
- const float x1 = bar_offset + dst_tab->Offset - g.Style.ItemInnerSpacing.x;
|
|
|
|
|
- const float x2 = bar_offset + dst_tab->Offset + dst_tab->Width + g.Style.ItemInnerSpacing.x;
|
|
|
|
|
|
|
+ const float x1 = bar_offset + dst_tab->Offset - tab_spacing;
|
|
|
|
|
+ const float x2 = bar_offset + dst_tab->Offset + dst_tab->Width + tab_spacing;
|
|
|
//GetForegroundDrawList()->AddRect(ImVec2(x1, tab_bar->BarRect.Min.y), ImVec2(x2, tab_bar->BarRect.Max.y), IM_COL32(255, 0, 0, 255));
|
|
//GetForegroundDrawList()->AddRect(ImVec2(x1, tab_bar->BarRect.Min.y), ImVec2(x2, tab_bar->BarRect.Max.y), IM_COL32(255, 0, 0, 255));
|
|
|
if ((dir < 0 && mouse_pos.x > x1) || (dir > 0 && mouse_pos.x < x2))
|
|
if ((dir < 0 && mouse_pos.x > x1) || (dir > 0 && mouse_pos.x < x2))
|
|
|
break;
|
|
break;
|