@@ -53,8 +53,6 @@ void DrawLegend::draw(Gfx::ICanvas &canvas,
5353 .titleRect = titleRect,
5454 .markerWindowRect = markerWindowRect,
5555 .fadeHeight = fadeHeight,
56- .yOverflow = {},
57- .yOffset = {},
5856 .type = channelType,
5957 .weight = weight,
6058 .itemHeight = itemHeight,
@@ -64,23 +62,23 @@ void DrawLegend::draw(Gfx::ICanvas &canvas,
6462 .colorGradientSetter = {markerWindowRect.leftSide (),
6563 Gfx::ColorGradient{{
6664 {0.0 , {}},
67- {fadeElementPercent / 2.0 , {}},
6865 {fadeElementPercent, {}},
6966 {1.0 - fadeElementPercent, {}},
70- {1.0 - fadeElementPercent / 2.0 , {}},
7167 {1.0 , {}},
7268 }}}};
7369
74- info.yOverflow = markersLegendFullSize (info) - markerWindowHeight;
75- if (std::signbit (info.yOverflow )) info.yOverflow = 0.0 ;
76- info.yOffset =
77- style.translateY ->get (info.yOverflow , info.itemHeight );
70+ info.properties .scrollHeight = markersLegendFullSize (info);
71+ auto yOverflow =
72+ info.properties .scrollHeight - markerWindowHeight;
73+ if (std::signbit (yOverflow)) yOverflow = 0.0 ;
74+ info.properties .scrollTop =
75+ style.translateY ->get (yOverflow, info.itemHeight );
7876
7977 DrawBackground{{ctx ()}}.draw (canvas,
8078 legendLayout,
8179 style,
8280 *events.background ,
83- Events::Targets::legend (channelType, info.yOverflow ));
81+ Events::Targets::legend (channelType, info.properties ));
8482
8583 canvas.save ();
8684
@@ -108,13 +106,9 @@ void DrawLegend::ColorGradientSetter::operator()(Gfx::ICanvas &canvas,
108106 for (auto &stop : modifiableStops) stop.value = color;
109107
110108 modifiableStops[0 ].value .alpha = 0.0 ;
111- modifiableStops[1 ].value .alpha *= 0.27 ;
112- modifiableStops[4 ].value .alpha *= 0.27 ;
113109 modifiableStops[5 ].value .alpha = 0.0 ;
114110
115- canvas.setBrushGradient (
116- {transform (line.begin ), transform (line.end )},
117- gradient);
111+ canvas.setBrushGradient (transform (line), gradient);
118112}
119113
120114void DrawLegend::drawTitle (const Info &info) const
@@ -136,7 +130,7 @@ void DrawLegend::drawTitle(const Info &info) const
136130 *events.title ,
137131 Events::Targets::legendTitle (title.value ,
138132 info.type ,
139- info.yOverflow ),
133+ info.properties ),
140134 {.alpha = title.weight * info.weight * mul});
141135 });
142136}
@@ -187,7 +181,7 @@ void DrawLegend::drawDimension(const Info &info) const
187181 value.second .categoryValue ,
188182 value.second .categoryValue ,
189183 info.type ,
190- info.yOverflow ),
184+ info.properties ),
191185 {.alpha =
192186 double {
193187 alpha
@@ -204,8 +198,8 @@ void DrawLegend::drawDimension(const Info &info) const
204198Geom::Rect DrawLegend::getItemRect (const Info &info, double index)
205199{
206200 Geom::Rect res = info.markerWindowRect ;
207- res.pos .y +=
208- info. fadeHeight + index * info. itemHeight - info.yOffset ;
201+ res.pos .y += info. fadeHeight + index * info. itemHeight
202+ - info.properties . scrollTop ;
209203 res.size .y = info.itemHeight ;
210204 if (std::signbit (res.size .x )) res.size .x = 0 ;
211205 return res;
@@ -254,7 +248,7 @@ void DrawLegend::drawMarker(const Info &info,
254248 Events::Targets::legendMarker (info.dimension .category ,
255249 categoryValue,
256250 info.type ,
257- info.yOverflow );
251+ info.properties );
258252
259253 if (events.marker ->invoke (
260254 Events::OnRectDrawEvent (*markerElement, {rect, false }))) {
@@ -315,7 +309,7 @@ void DrawLegend::extremaLabel(const Info &info,
315309 *events.label ,
316310 Events::Targets::measLegendLabel (text,
317311 info.type ,
318- info.yOverflow ),
312+ info.properties ),
319313 {.alpha = info.measureWeight * plusWeight});
320314}
321315
@@ -354,7 +348,7 @@ void DrawLegend::colorBar(const Info &info,
354348
355349 auto barElement =
356350 Events::Targets::legendBar (Gen::ChannelId::color,
357- info.yOverflow );
351+ info.properties );
358352
359353 if (events.bar ->invoke (
360354 Events::OnRectDrawEvent (*barElement, {rect, false }))) {
@@ -387,7 +381,7 @@ void DrawLegend::lightnessBar(const Info &info,
387381
388382 auto barElement =
389383 Events::Targets::legendBar (Gen::ChannelId::lightness,
390- info.yOverflow );
384+ info.properties );
391385
392386 if (events.bar ->invoke (
393387 Events::OnRectDrawEvent (*barElement, {rect, false }))) {
@@ -409,7 +403,7 @@ void DrawLegend::sizeBar(const Info &info,
409403 info.canvas .setLineWidth (0 );
410404
411405 auto barElement = Events::Targets::legendBar (Gen::ChannelId::size,
412- info.yOverflow );
406+ info.properties );
413407
414408 if (events.bar ->invoke (
415409 Events::OnRectDrawEvent (*barElement, {rect, false }))) {
0 commit comments