@@ -157,14 +157,22 @@ void DrawLegend::drawDimension(const Info &info) const
157157 < info.markerWindowRect .y ().getMin ())
158158 continue ;
159159
160+ const auto needGradient =
161+ itemRect.y ().getMax ()
162+ > info.markerWindowRect .y ().getMax () - info.fadeHeight
163+ || itemRect.y ().getMin ()
164+ < info.markerWindowRect .y ().getMin ()
165+ + info.fadeHeight ;
166+
160167 const auto alpha{Math::FuzzyBool{value.second .weight }
161168 && Math::FuzzyBool{info.weight }};
162169
163170 drawMarker (info,
164171 value.second .categoryValue ,
165172 colorBuilder.render (value.second .colorBase )
166173 * double {alpha},
167- getMarkerRect (info, itemRect));
174+ getMarkerRect (info, itemRect),
175+ needGradient);
168176
169177 value.second .label .visit (
170178 [&](::Anim::InterpolateIndex, const auto &weighted)
@@ -185,7 +193,10 @@ void DrawLegend::drawDimension(const Info &info) const
185193 alpha
186194 && Math::FuzzyBool{weighted.weight }},
187195 .gradient =
188- std::ref (info.colorGradientSetter )});
196+ needGradient
197+ ? std::ref (info.colorGradientSetter )
198+ : decltype (DrawLabel::Options::
199+ gradient){}});
189200 });
190201 }
191202}
@@ -222,11 +233,16 @@ Geom::TransformedRect DrawLegend::getLabelRect(const Info &info,
222233void DrawLegend::drawMarker (const Info &info,
223234 std::string_view categoryValue,
224235 const Gfx::Color &color,
225- const Geom::Rect &rect) const
236+ const Geom::Rect &rect,
237+ bool needGradient) const
226238{
227239 info.canvas .save ();
228240
229- info.colorGradientSetter (info.canvas , {}, color);
241+ if (needGradient)
242+ info.colorGradientSetter (info.canvas , {}, color);
243+ else
244+ info.canvas .setBrushColor (color);
245+
230246 info.canvas .setLineColor (color);
231247 info.canvas .setLineWidth (0 );
232248
0 commit comments