|
|
@@ -897,7 +897,6 @@ bool ImGui::Checkbox(const char* label, bool* v)
|
|
|
|
|
|
const float square_sz = GetFrameHeight();
|
|
|
const ImVec2 pos = window->DC.CursorPos;
|
|
|
- const ImRect check_bb(pos, pos + ImVec2(square_sz, square_sz));
|
|
|
const ImRect total_bb(pos, pos + ImVec2(square_sz + (label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f), label_size.y + style.FramePadding.y * 2.0f));
|
|
|
ItemSize(total_bb, style.FramePadding.y);
|
|
|
if (!ItemAdd(total_bb, id))
|
|
|
@@ -911,6 +910,7 @@ bool ImGui::Checkbox(const char* label, bool* v)
|
|
|
MarkItemEdited(id);
|
|
|
}
|
|
|
|
|
|
+ const ImRect check_bb(pos, pos + ImVec2(square_sz, square_sz));
|
|
|
RenderNavHighlight(total_bb, id);
|
|
|
RenderFrame(check_bb.Min, check_bb.Max, GetColorU32((held && hovered) ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg), true, style.FrameRounding);
|
|
|
if (*v)
|
|
|
@@ -1855,7 +1855,6 @@ bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* v, floa
|
|
|
|
|
|
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 inner_bb(frame_bb.Min + style.FramePadding, frame_bb.Max - style.FramePadding);
|
|
|
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));
|
|
|
|
|
|
ItemSize(total_bb, style.FramePadding.y);
|
|
|
@@ -1910,7 +1909,7 @@ bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* v, floa
|
|
|
RenderTextClipped(frame_bb.Min, frame_bb.Max, value_buf, value_buf_end, NULL, ImVec2(0.5f, 0.5f));
|
|
|
|
|
|
if (label_size.x > 0.0f)
|
|
|
- RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, inner_bb.Min.y), label);
|
|
|
+ RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
|
|
|
|
|
|
IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags);
|
|
|
return value_changed;
|
|
|
@@ -5032,7 +5031,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
|
|
|
// Fill horizontal space.
|
|
|
ImVec2 window_padding = window->WindowPadding;
|
|
|
float max_x = (flags & ImGuiSelectableFlags_SpanAllColumns) ? GetWindowContentRegionMax().x : GetContentRegionMax().x;
|
|
|
- float w_draw = ImMax(label_size.x, window->Pos.x + max_x - window_padding.x - window->DC.CursorPos.x);
|
|
|
+ float w_draw = ImMax(label_size.x, window->Pos.x + max_x - window_padding.x - pos.x);
|
|
|
ImVec2 size_draw((size_arg.x != 0 && !(flags & ImGuiSelectableFlags_DrawFillAvailWidth)) ? size_arg.x : w_draw, size_arg.y != 0.0f ? size_arg.y : size.y);
|
|
|
ImRect bb(pos, pos + size_draw);
|
|
|
if (size_arg.x == 0.0f || (flags & ImGuiSelectableFlags_DrawFillAvailWidth))
|
|
|
@@ -5230,7 +5229,7 @@ bool ImGui::ListBox(const char* label, int* current_item, bool (*items_getter)(v
|
|
|
// - PlotHistogram()
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
-void ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size)
|
|
|
+void ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 frame_size)
|
|
|
{
|
|
|
ImGuiWindow* window = GetCurrentWindow();
|
|
|
if (window->SkipItems)
|
|
|
@@ -5238,20 +5237,21 @@ void ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_ge
|
|
|
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
const ImGuiStyle& style = g.Style;
|
|
|
+ const ImGuiID id = window->GetID(label);
|
|
|
|
|
|
const ImVec2 label_size = CalcTextSize(label, NULL, true);
|
|
|
- if (graph_size.x == 0.0f)
|
|
|
- graph_size.x = CalcItemWidth();
|
|
|
- if (graph_size.y == 0.0f)
|
|
|
- graph_size.y = label_size.y + (style.FramePadding.y * 2);
|
|
|
+ if (frame_size.x == 0.0f)
|
|
|
+ frame_size.x = CalcItemWidth();
|
|
|
+ if (frame_size.y == 0.0f)
|
|
|
+ frame_size.y = label_size.y + (style.FramePadding.y * 2);
|
|
|
|
|
|
- const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(graph_size.x, graph_size.y));
|
|
|
+ const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + frame_size);
|
|
|
const ImRect inner_bb(frame_bb.Min + style.FramePadding, frame_bb.Max - style.FramePadding);
|
|
|
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));
|
|
|
ItemSize(total_bb, style.FramePadding.y);
|
|
|
if (!ItemAdd(total_bb, 0, &frame_bb))
|
|
|
return;
|
|
|
- const bool hovered = ItemHoverable(inner_bb, 0);
|
|
|
+ const bool hovered = ItemHoverable(frame_bb, id);
|
|
|
|
|
|
// Determine scale from values if not specified
|
|
|
if (scale_min == FLT_MAX || scale_max == FLT_MAX)
|
|
|
@@ -5274,12 +5274,12 @@ void ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_ge
|
|
|
|
|
|
if (values_count > 0)
|
|
|
{
|
|
|
- int res_w = ImMin((int)graph_size.x, values_count) + ((plot_type == ImGuiPlotType_Lines) ? -1 : 0);
|
|
|
+ int res_w = ImMin((int)frame_size.x, values_count) + ((plot_type == ImGuiPlotType_Lines) ? -1 : 0);
|
|
|
int item_count = values_count + ((plot_type == ImGuiPlotType_Lines) ? -1 : 0);
|
|
|
|
|
|
// Tooltip on hover
|
|
|
int v_hovered = -1;
|
|
|
- if (hovered)
|
|
|
+ if (hovered && inner_bb.Contains(g.IO.MousePos))
|
|
|
{
|
|
|
const float t = ImClamp((g.IO.MousePos.x - inner_bb.Min.x) / (inner_bb.Max.x - inner_bb.Min.x), 0.0f, 0.9999f);
|
|
|
const int v_idx = (int)(t * item_count);
|