diff --git a/implot.cpp b/implot.cpp index f2f7f40c..aeb22a10 100644 --- a/implot.cpp +++ b/implot.cpp @@ -661,6 +661,134 @@ int LegendSortingComp(const void* _a, const void* _b) { return strcmp(label_a,label_b); } +// Marker geometry (duplicated from implot_items.cpp for legend rendering) +static const ImVec2 MARKER_FILL_CIRCLE[10] = {ImVec2(1.0f, 0.0f), ImVec2(0.809017f, 0.58778524f),ImVec2(0.30901697f, 0.95105654f),ImVec2(-0.30901703f, 0.9510565f),ImVec2(-0.80901706f, 0.5877852f),ImVec2(-1.0f, 0.0f),ImVec2(-0.80901694f, -0.58778536f),ImVec2(-0.3090171f, -0.9510565f),ImVec2(0.30901712f, -0.9510565f),ImVec2(0.80901694f, -0.5877853f)}; +static const ImVec2 MARKER_FILL_SQUARE[4] = {ImVec2(1.0f, 1.0f), ImVec2(1.0f, -1.0f), ImVec2(-1.0f, -1.0f), ImVec2(-1.0f, 1.0f)}; +static const ImVec2 MARKER_FILL_DIAMOND[4] = {ImVec2(1.0f, 0.0f), ImVec2(0.0f, -1.0f), ImVec2(-1.0f, 0.0f), ImVec2(0.0f, 1.0f)}; +static const ImVec2 MARKER_FILL_UP[3] = {ImVec2(0.0f, 1.0f), ImVec2(-1.0f, -1.0f), ImVec2(1.0f, -1.0f)}; +static const ImVec2 MARKER_FILL_DOWN[3] = {ImVec2(0.0f, -1.0f), ImVec2(-1.0f, 1.0f), ImVec2(1.0f, 1.0f)}; +static const ImVec2 MARKER_FILL_LEFT[3] = {ImVec2(-1.0f, 0.0f), ImVec2(1.0f, 1.0f), ImVec2(1.0f, -1.0f)}; +static const ImVec2 MARKER_FILL_RIGHT[3] = {ImVec2(1.0f, 0.0f), ImVec2(-1.0f, -1.0f), ImVec2(-1.0f, 1.0f)}; + +void RenderMarkerGeneral(ImDrawList& DrawList, const ImVec2& c, float size, ImPlotMarker marker, bool rend_fill, ImU32 col_fill, bool rend_line, ImU32 col_line, float weight) { + ImVec2 points[10]; + int count = 0; + const ImVec2* shape = nullptr; + + // Get marker shape + switch (marker) { + case ImPlotMarker_Circle: shape = MARKER_FILL_CIRCLE; count = 10; break; + case ImPlotMarker_Square: shape = MARKER_FILL_SQUARE; count = 4; break; + case ImPlotMarker_Diamond: shape = MARKER_FILL_DIAMOND; count = 4; break; + case ImPlotMarker_Up: shape = MARKER_FILL_UP; count = 3; break; + case ImPlotMarker_Down: shape = MARKER_FILL_DOWN; count = 3; break; + case ImPlotMarker_Left: shape = MARKER_FILL_LEFT; count = 3; break; + case ImPlotMarker_Right: shape = MARKER_FILL_RIGHT; count = 3; break; + default: return; // Unknown marker + } + + // Transform points + for (int i = 0; i < count; ++i) { + points[i].x = c.x + shape[i].x * size; + points[i].y = c.y + shape[i].y * size; + } + + // Render fill + if (rend_fill && count > 0) { + DrawList.AddConvexPolyFilled(points, count, col_fill); + } + + // Render outline + if (rend_line && count > 0) { + DrawList.AddPolyline(points, count, col_line, ImDrawFlags_Closed, weight); + } + + // Special cases for line-only markers + if (rend_line) { + switch (marker) { + case ImPlotMarker_Plus: { + DrawList.AddLine(ImVec2(c.x - size, c.y), ImVec2(c.x + size, c.y), col_line, weight); + DrawList.AddLine(ImVec2(c.x, c.y - size), ImVec2(c.x, c.y + size), col_line, weight); + break; + } + case ImPlotMarker_Cross: { + DrawList.AddLine(ImVec2(c.x - size, c.y - size), ImVec2(c.x + size, c.y + size), col_line, weight); + DrawList.AddLine(ImVec2(c.x + size, c.y - size), ImVec2(c.x - size, c.y + size), col_line, weight); + break; + } + case ImPlotMarker_Asterisk: { + DrawList.AddLine(ImVec2(c.x - size, c.y), ImVec2(c.x + size, c.y), col_line, weight); + DrawList.AddLine(ImVec2(c.x, c.y - size), ImVec2(c.x, c.y + size), col_line, weight); + DrawList.AddLine(ImVec2(c.x - size, c.y - size), ImVec2(c.x + size, c.y + size), col_line, weight); + DrawList.AddLine(ImVec2(c.x + size, c.y - size), ImVec2(c.x - size, c.y + size), col_line, weight); + break; + } + } + } +} + +void RenderLegendIcon(ImDrawList& DrawList, const ImRect& icon_bb, const ImPlotItem* item, ImU32 col_icon) { + const float icon_center_x = (icon_bb.Min.x + icon_bb.Max.x) * 0.5f; + const float icon_center_y = (icon_bb.Min.y + icon_bb.Max.y) * 0.5f; + const ImVec2 icon_center(icon_center_x, icon_center_y); + + // Extract alpha from col_icon to apply same modulation to stored colors + float alpha = ((col_icon >> IM_COL32_A_SHIFT) & 0xFF) / 255.0f; + + ImU32 line_col = ImAlphaU32(item->LineColor, alpha); + ImU32 fill_col = ImAlphaU32(item->FillColor, alpha); + ImU32 marker_line_col = ImAlphaU32(item->MarkerLineColor, alpha); + ImU32 marker_fill_col = ImAlphaU32(item->MarkerFillColor, alpha); + + // Render based on icon type + switch (item->LegendIconType) { + case ImPlotLegendIconType_Line: { + // Horizontal line only + ImVec2 line_start(icon_bb.Min.x, icon_center_y); + ImVec2 line_end(icon_bb.Max.x, icon_center_y); + DrawList.AddLine(line_start, line_end, line_col, item->LegendLineWeight); + break; + } + case ImPlotLegendIconType_LineMarkers: { + // Horizontal line with marker at center + ImVec2 line_start(icon_bb.Min.x, icon_center_y); + ImVec2 line_end(icon_bb.Max.x, icon_center_y); + DrawList.AddLine(line_start, line_end, line_col, item->LegendLineWeight); + const float marker_size = icon_bb.GetWidth() * 0.25f; + const bool rend_marker_fill = (item->MarkerFillColor & IM_COL32_A_MASK) != 0; + const bool rend_marker_line = (item->MarkerLineColor & IM_COL32_A_MASK) != 0; + RenderMarkerGeneral(DrawList, icon_center, marker_size, item->Marker, + rend_marker_fill, marker_fill_col, rend_marker_line, marker_line_col, item->LegendLineWeight); + break; + } + case ImPlotLegendIconType_Markers: { + // Single marker at center + const float marker_size = icon_bb.GetWidth() * 0.5f; + const bool rend_marker_fill = (item->MarkerFillColor & IM_COL32_A_MASK) != 0; + const bool rend_marker_line = (item->MarkerLineColor & IM_COL32_A_MASK) != 0; + RenderMarkerGeneral(DrawList, icon_center, marker_size, item->Marker, + rend_marker_fill, marker_fill_col, rend_marker_line, marker_line_col, item->LegendLineWeight); + break; + } + case ImPlotLegendIconType_Fill: { + // Filled square + DrawList.AddRectFilled(icon_bb.Min, icon_bb.Max, fill_col); + break; + } + case ImPlotLegendIconType_FillLine: { + // Filled square with outline + DrawList.AddRectFilled(icon_bb.Min, icon_bb.Max, fill_col); + DrawList.AddRect(icon_bb.Min, icon_bb.Max, line_col, 0.0f, 0, item->LegendLineWeight); + break; + } + default: { + // Fallback: solid square + DrawList.AddRectFilled(icon_bb.Min, icon_bb.Max, col_icon); + break; + } + } +} + bool ShowLegendEntries(ImPlotItemGroup& items, const ImRect& legend_bb, bool hovered, const ImVec2& pad, const ImVec2& spacing, bool vertical, ImDrawList& DrawList) { // vars const float txt_ht = ImGui::GetTextLineHeight(); @@ -740,7 +868,7 @@ bool ShowLegendEntries(ImPlotItemGroup& items, const ImRect& legend_bb, bool hov else col_icon = item->Show ? col_item : col_txt_dis; - DrawList.AddRectFilled(icon_bb.Min, icon_bb.Max, col_icon); + RenderLegendIcon(DrawList, icon_bb, item, col_icon); const char* text_display_end = ImGui::FindRenderedTextEnd(label, nullptr); if (label != text_display_end) DrawList.AddText(top_left + ImVec2(icon_size, 0), item->Show ? col_txt_hl : col_txt_dis, label, text_display_end); diff --git a/implot_demo.cpp b/implot_demo.cpp index 88a87e7a..692842c7 100644 --- a/implot_demo.cpp +++ b/implot_demo.cpp @@ -2596,7 +2596,7 @@ void PlotCandlestick(const char* label_id, const double* xs, const double* opens } // begin plot item - if (ImPlot::BeginItem(label_id)) { + if (ImPlot::BeginItem(label_id, ImPlotLegendIconType_FillLine)) { // override legend icon color ImPlot::GetCurrentItem()->Color = IM_COL32(64,64,64,255); // fit data if requested diff --git a/implot_internal.h b/implot_internal.h index da49cedb..ee08e306 100644 --- a/implot_internal.h +++ b/implot_internal.h @@ -967,26 +967,55 @@ struct ImPlotAlignmentData { void Reset() { PadA = PadB = PadAMax = PadBMax = 0; } }; +// Legend icon types +enum ImPlotLegendIconType_ { + ImPlotLegendIconType_Line, // Horizontal line (line plots) + ImPlotLegendIconType_LineMarkers, // Horizontal line with marker (line plots with markers) + ImPlotLegendIconType_Markers, // Single marker (scatter plots) + ImPlotLegendIconType_Fill, // Filled square (shaded plots, pie charts) + ImPlotLegendIconType_FillLine // Filled square with outline (bars, histograms) +}; + // State information for Plot items struct ImPlotItem { - ImGuiID ID; - ImU32 Color; - ImPlotMarker Marker; - ImRect LegendHoverRect; - int NameOffset; - bool Show; - bool LegendHovered; - bool SeenThisFrame; + ImGuiID ID; + ImU32 Color; + ImU32 LineColor; + ImU32 FillColor; + ImU32 MarkerLineColor; + ImU32 MarkerFillColor; + ImPlotMarker Marker; + ImPlotItemFlags LegendFlags; + ImPlotLegendIconType_ LegendIconType; + ImRect LegendHoverRect; + int NameOffset; + bool Show; + bool LegendHovered; + bool SeenThisFrame; + bool LegendRenderLine; + bool LegendRenderFill; + bool LegendRenderMarkers; + float LegendLineWeight; ImPlotItem() { - ID = 0; - Color = IM_COL32_WHITE; - Marker = ImPlotMarker_None; - NameOffset = -1; - Show = true; - SeenThisFrame = false; - LegendHovered = false; + ID = 0; + Color = IM_COL32_WHITE; + LineColor = IM_COL32_WHITE; + FillColor = IM_COL32_WHITE; + MarkerLineColor = IM_COL32_WHITE; + MarkerFillColor = IM_COL32_WHITE; + Marker = ImPlotMarker_None; + LegendFlags = ImPlotItemFlags_None; + LegendIconType = ImPlotLegendIconType_Line; + NameOffset = -1; + Show = true; + SeenThisFrame = false; + LegendHovered = false; + LegendRenderLine = false; + LegendRenderFill = false; + LegendRenderMarkers = false; + LegendLineWeight = 1.0f; } ~ImPlotItem() { ID = 0; } @@ -1333,12 +1362,12 @@ IMPLOT_API void ShowSubplotsContextMenu(ImPlotSubplot& subplot); //----------------------------------------------------------------------------- // Begins a new item. Returns false if the item should not be plotted. Pushes PlotClipRect. -IMPLOT_API bool BeginItem(const char* label_id, const ImPlotSpec& spec = ImPlotSpec(), const ImVec4& item_col = IMPLOT_AUTO_COL, ImPlotMarker item_mkr = ImPlotMarker_Invalid); +IMPLOT_API bool BeginItem(const char* label_id, ImPlotLegendIconType_ icon_type, const ImPlotSpec& spec = ImPlotSpec(), const ImVec4& item_col = IMPLOT_AUTO_COL, ImPlotMarker item_mkr = ImPlotMarker_Invalid); // Same as above but with fitting functionality. template -bool BeginItemEx(const char* label_id, const _Fitter& fitter, const ImPlotSpec& spec, const ImVec4& item_col = IMPLOT_AUTO_COL, ImPlotMarker item_mkr = ImPlotMarker_Invalid) { - if (BeginItem(label_id, spec, item_col, item_mkr)) { +bool BeginItemEx(const char* label_id, ImPlotLegendIconType_ icon_type, const _Fitter& fitter, const ImPlotSpec& spec, const ImVec4& item_col = IMPLOT_AUTO_COL, ImPlotMarker item_mkr = ImPlotMarker_Invalid) { + if (BeginItem(label_id, icon_type, spec, item_col, item_mkr)) { ImPlotPlot& plot = *GetCurrentPlot(); if (plot.FitThisFrame && !ImHasFlag(spec.Flags, ImPlotItemFlags_NoFit)) fitter.Fit(plot.Axes[plot.CurrentX], plot.Axes[plot.CurrentY]); diff --git a/implot_items.cpp b/implot_items.cpp index 1af0cd2c..e66d577a 100644 --- a/implot_items.cpp +++ b/implot_items.cpp @@ -405,7 +405,7 @@ constexpr float ITEM_HIGHLIGHT_LINE_SCALE = 2.0f; constexpr float ITEM_HIGHLIGHT_MARK_SCALE = 1.25f; // Begins a new item. Returns false if the item should not be plotted. -bool BeginItem(const char* label_id, const ImPlotSpec& spec, const ImVec4& item_col, ImPlotMarker item_mkr) { +bool BeginItem(const char* label_id, ImPlotLegendIconType_ icon_type, const ImPlotSpec& spec, const ImVec4& item_col, ImPlotMarker item_mkr) { ImPlotContext& gp = *GImPlot; IM_ASSERT_USER_ERROR(gp.CurrentPlot != nullptr, "PlotX() needs to be called between BeginPlot() and EndPlot()!"); SetupLock(); @@ -475,6 +475,18 @@ bool BeginItem(const char* label_id, const ImPlotSpec& spec, const ImVec4& item_ s.RenderMarkerLine = s.Spec.MarkerLineColor.w > 0 && s.Spec.LineWeight > 0; s.RenderMarkerFill = s.Spec.MarkerFillColor.w > 0; s.RenderMarkers = s.Spec.Marker >= 0 && (s.RenderMarkerFill || s.RenderMarkerLine); + // store legend icon data + item->LineColor = ImGui::ColorConvertFloat4ToU32(s.Spec.LineColor); + item->FillColor = ImGui::ColorConvertFloat4ToU32(s.Spec.FillColor); + item->MarkerLineColor = ImGui::ColorConvertFloat4ToU32(s.Spec.MarkerLineColor); + item->MarkerFillColor = ImGui::ColorConvertFloat4ToU32(s.Spec.MarkerFillColor); + item->Marker = s.Spec.Marker; + item->LegendFlags = s.Spec.Flags; + item->LegendRenderLine = s.RenderLine; + item->LegendRenderFill = s.RenderFill; + item->LegendRenderMarkers = s.RenderMarkers; + item->LegendLineWeight = s.Spec.LineWeight; + item->LegendIconType = icon_type; // push rendering clip rect PushPlotClipRect(); return true; @@ -1777,7 +1789,8 @@ void RenderMarkers(const _Getter& getter, ImPlotMarker marker, float size, bool template void PlotLineEx(const char* label_id, const _Getter& getter, const ImPlotSpec& spec) { - if (BeginItemEx(label_id, Fitter1<_Getter>(getter), spec, spec.LineColor, spec.Marker)) { + ImPlotLegendIconType_ icon_type = (spec.Marker != ImPlotMarker_None) ? ImPlotLegendIconType_LineMarkers : ImPlotLegendIconType_Line; + if (BeginItemEx(label_id, icon_type, Fitter1<_Getter>(getter), spec, spec.LineColor, spec.Marker)) { if (getter.Count <= 0) { EndItem(); return; @@ -1854,7 +1867,7 @@ template void PlotScatterEx(const char* label_id, const Getter& getter, const ImPlotSpec& spec) { // force scatter to render a marker even if none ImPlotMarker marker = spec.Marker == ImPlotMarker_None ? ImPlotMarker_Auto: spec.Marker; - if (BeginItemEx(label_id, Fitter1(getter), spec, spec.LineColor, marker)) { + if (BeginItemEx(label_id, ImPlotLegendIconType_Markers, Fitter1(getter), spec, spec.LineColor, marker)) { if (getter.Count <= 0) { EndItem(); return; @@ -1903,7 +1916,7 @@ void PlotScatterG(const char* label_id, ImPlotGetter getter_func, void* data, in template void PlotBubblesEx(const char* label_id, const Getter& getter, const ImPlotSpec& spec) { - if (BeginItemEx(label_id, FitterBubbles1(getter), spec, spec.FillColor, spec.Marker)) { + if (BeginItemEx(label_id, ImPlotLegendIconType_FillLine, FitterBubbles1(getter), spec, spec.FillColor, spec.Marker)) { if (getter.Count <= 0) { EndItem(); return; @@ -1947,7 +1960,8 @@ CALL_INSTANTIATE_FOR_NUMERIC_TYPES() template void PlotStairsEx(const char* label_id, const Getter& getter, const ImPlotSpec& spec) { - if (BeginItemEx(label_id, Fitter1(getter), spec, spec.LineColor, spec.Marker)) { + ImPlotLegendIconType_ icon_type = (spec.Marker != ImPlotMarker_None) ? ImPlotLegendIconType_LineMarkers : ImPlotLegendIconType_Line; + if (BeginItemEx(label_id, icon_type, Fitter1(getter), spec, spec.LineColor, spec.Marker)) { if (getter.Count <= 0) { EndItem(); return; @@ -2011,7 +2025,7 @@ void PlotStairsG(const char* label_id, ImPlotGetter getter_func, void* data, int template void PlotShadedEx(const char* label_id, const Getter1& getter1, const Getter2& getter2, const ImPlotSpec& spec) { - if (BeginItemEx(label_id, Fitter2(getter1,getter2), spec, spec.FillColor)) { + if (BeginItemEx(label_id, ImPlotLegendIconType_Fill, Fitter2(getter1,getter2), spec, spec.FillColor)) { if (getter1.Count <= 0 || getter2.Count <= 0) { EndItem(); return; @@ -2075,7 +2089,7 @@ void PlotShadedG(const char* label_id, ImPlotGetter getter_func1, void* data1, I template void PlotBarsVEx(const char* label_id, const Getter1& getter1, const Getter2 getter2, double width, const ImPlotSpec& spec) { - if (BeginItemEx(label_id, FitterBarV(getter1,getter2,width), spec, spec.FillColor)) { + if (BeginItemEx(label_id, ImPlotLegendIconType_FillLine, FitterBarV(getter1,getter2,width), spec, spec.FillColor)) { if (getter1.Count <= 0 || getter2.Count <= 0) { EndItem(); return; @@ -2099,7 +2113,7 @@ void PlotBarsVEx(const char* label_id, const Getter1& getter1, const Getter2 get template void PlotBarsHEx(const char* label_id, const Getter1& getter1, const Getter2& getter2, double height, const ImPlotSpec& spec) { - if (BeginItemEx(label_id, FitterBarH(getter1,getter2,height), spec, spec.FillColor)) { + if (BeginItemEx(label_id, ImPlotLegendIconType_FillLine, FitterBarH(getter1,getter2,height), spec, spec.FillColor)) { if (getter1.Count <= 0 || getter2.Count <= 0) { EndItem(); return; @@ -2263,7 +2277,7 @@ CALL_INSTANTIATE_FOR_NUMERIC_TYPES() template void PlotErrorBarsVEx(const char* label_id, const _GetterPos& getter_pos, const _GetterNeg& getter_neg, const ImPlotSpec& spec) { - if (BeginItemEx(label_id, Fitter2<_GetterPos,_GetterNeg>(getter_pos, getter_neg), spec, IMPLOT_AUTO_COL)) { + if (BeginItemEx(label_id, ImPlotLegendIconType_Line, Fitter2<_GetterPos,_GetterNeg>(getter_pos, getter_neg), spec, IMPLOT_AUTO_COL)) { if (getter_pos.Count <= 0 || getter_neg.Count <= 0) { EndItem(); return; @@ -2288,7 +2302,7 @@ void PlotErrorBarsVEx(const char* label_id, const _GetterPos& getter_pos, const template void PlotErrorBarsHEx(const char* label_id, const _GetterPos& getter_pos, const _GetterNeg& getter_neg, const ImPlotSpec& spec) { - if (BeginItemEx(label_id, Fitter2<_GetterPos,_GetterNeg>(getter_pos, getter_neg), spec, IMPLOT_AUTO_COL)) { + if (BeginItemEx(label_id, ImPlotLegendIconType_Line, Fitter2<_GetterPos,_GetterNeg>(getter_pos, getter_neg), spec, IMPLOT_AUTO_COL)) { if (getter_pos.Count <= 0 || getter_neg.Count <= 0) { EndItem(); return; @@ -2351,7 +2365,8 @@ CALL_INSTANTIATE_FOR_NUMERIC_TYPES() template void PlotStemsEx(const char* label_id, const _GetterM& getter_mark, const _GetterB& getter_base, const ImPlotSpec& spec) { - if (BeginItemEx(label_id, Fitter2<_GetterM,_GetterB>(getter_mark,getter_base), spec, spec.LineColor, spec.Marker)) { + ImPlotLegendIconType_ icon_type = (spec.Marker != ImPlotMarker_None) ? ImPlotLegendIconType_LineMarkers : ImPlotLegendIconType_Line; + if (BeginItemEx(label_id, icon_type, Fitter2<_GetterM,_GetterB>(getter_mark,getter_base), spec, spec.LineColor, spec.Marker)) { if (getter_mark.Count <= 0 || getter_base.Count <= 0) { EndItem(); return; @@ -2419,7 +2434,7 @@ void PlotInfLines(const char* label_id, const T* values, int count, const ImPlot if (ImHasFlag(spec.Flags, ImPlotInfLinesFlags_Horizontal)) { GetterXY> getter_min(IndexerConst(lims.X.Min),IndexerIdx(values,count,spec.Offset,Stride(spec)),count); GetterXY> getter_max(IndexerConst(lims.X.Max),IndexerIdx(values,count,spec.Offset,Stride(spec)),count); - if (BeginItemEx(label_id, FitterY>>(getter_min), spec, spec.LineColor)) { + if (BeginItemEx(label_id, ImPlotLegendIconType_Line, FitterY>>(getter_min), spec, spec.LineColor)) { if (count <= 0) { EndItem(); return; @@ -2434,7 +2449,7 @@ void PlotInfLines(const char* label_id, const T* values, int count, const ImPlot else { GetterXY,IndexerConst> get_min(IndexerIdx(values,count,spec.Offset,Stride(spec)),IndexerConst(lims.Y.Min),count); GetterXY,IndexerConst> get_max(IndexerIdx(values,count,spec.Offset,Stride(spec)),IndexerConst(lims.Y.Max),count); - if (BeginItemEx(label_id, FitterX,IndexerConst>>(get_min), spec, spec.LineColor)) { + if (BeginItemEx(label_id, ImPlotLegendIconType_Line, FitterX,IndexerConst>>(get_min), spec, spec.LineColor)) { if (count <= 0) { EndItem(); return; @@ -2551,7 +2566,7 @@ void PlotPieChartEx(const char* const label_ids[], IndexerIdx indexer, ImPlot if (!skip) a1 = a0 + 2 * IM_PI * percent; - if (BeginItemEx(label_ids[i], FitterRect(Pmin, Pmax), spec)) { + if (BeginItemEx(label_ids[i], ImPlotLegendIconType_Fill, FitterRect(Pmin, Pmax), spec)) { const bool hovered = ImPlot::IsLegendEntryHovered(label_ids[i]) && ImHasFlag(spec.Flags, ImPlotPieChartFlags_Exploding); if (sum > 0.0) { ImU32 col = GetCurrentItem()->Color; @@ -2778,7 +2793,7 @@ void RenderHeatmap(ImDrawList& draw_list, IndexerIdx indexer, int rows, int c template void PlotHeatmap(const char* label_id, const T* values, int rows, int cols, double scale_min, double scale_max, const char* fmt, const ImPlotPoint& bounds_min, const ImPlotPoint& bounds_max, const ImPlotSpec& spec) { - if (BeginItemEx(label_id, FitterRect(bounds_min, bounds_max), spec)) { + if (BeginItemEx(label_id, ImPlotLegendIconType_Fill, FitterRect(bounds_min, bounds_max), spec)) { if (rows <= 0 || cols <= 0) { EndItem(); return; @@ -2948,7 +2963,7 @@ double PlotHistogram2D(const char* label_id, const T* xs, const T* ys, int count max_count *= scale; } - if (BeginItemEx(label_id, FitterRect(range), spec)) { + if (BeginItemEx(label_id, ImPlotLegendIconType_FillLine, FitterRect(range), spec)) { if (y_bins <= 0 || x_bins <= 0) { EndItem(); return max_count; @@ -2973,7 +2988,7 @@ CALL_INSTANTIATE_FOR_NUMERIC_TYPES() template void PlotDigitalEx(const char* label_id, Getter getter, const ImPlotSpec& spec) { - if (BeginItem(label_id, spec, spec.FillColor)) { + if (BeginItem(label_id, ImPlotLegendIconType_Fill, spec, spec.FillColor)) { ImPlotContext& gp = *GImPlot; ImDrawList& draw_list = *GetPlotDrawList(); const ImPlotNextItemData& s = GetItemData(); @@ -3055,7 +3070,7 @@ void PlotImage(const char* label_id, ImTextureRef tex_ref, const ImPlotPoint& bm #else void PlotImage(const char* label_id, ImTextureID tex_ref, const ImPlotPoint& bmin, const ImPlotPoint& bmax, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& tint_col, const ImPlotSpec& spec) { #endif - if (BeginItemEx(label_id, FitterRect(bmin,bmax), spec)) { + if (BeginItemEx(label_id, ImPlotLegendIconType_Fill, FitterRect(bmin,bmax), spec)) { ImU32 tint_col32 = ImGui::ColorConvertFloat4ToU32(tint_col); GetCurrentItem()->Color = tint_col32; ImDrawList& draw_list = *GetPlotDrawList(); @@ -3105,7 +3120,7 @@ void PlotText(const char* text, double x, double y, const ImVec2& pixel_offset, //----------------------------------------------------------------------------- void PlotDummy(const char* label_id, const ImPlotSpec& spec) { - if (BeginItem(label_id, spec)) + if (BeginItem(label_id, ImPlotLegendIconType_Fill, spec)) EndItem(); }