Skip to content

Commit ac2a201

Browse files
committed
Drawingcontext Style,Events renamed.
1 parent 61b8421 commit ac2a201

File tree

7 files changed

+50
-50
lines changed

7 files changed

+50
-50
lines changed

src/chart/rendering/drawaxes.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void drawAxes::drawAxis(Gen::ChannelId axisIndex)
5959
const char *element =
6060
axisIndex == Gen::ChannelId::x ? "plot.xAxis" : "plot.yAxis";
6161

62-
auto lineBaseColor = *style.plot.getAxis(axisIndex).color
62+
auto lineBaseColor = *rootStyle.plot.getAxis(axisIndex).color
6363
* static_cast<double>(plot.anyAxisSet);
6464

6565
if (lineBaseColor.alpha <= 0) return;
@@ -73,7 +73,7 @@ void drawAxes::drawAxis(Gen::ChannelId axisIndex)
7373
canvas.setLineColor(lineColor);
7474
canvas.setLineWidth(1.0);
7575

76-
if (events.plot.axis.base->invoke(
76+
if (rootEvents.plot.axis.base->invoke(
7777
Events::OnLineDrawParam(element, line))) {
7878
painter.drawLine(line);
7979
}
@@ -86,7 +86,7 @@ Geom::Point drawAxes::getTitleBasePos(Gen::ChannelId axisIndex,
8686
typedef Styles::AxisTitle::Position Pos;
8787
typedef Styles::AxisTitle::VPosition VPos;
8888

89-
const auto &titleStyle = style.plot.getAxis(axisIndex).title;
89+
const auto &titleStyle = rootStyle.plot.getAxis(axisIndex).title;
9090

9191
double orthogonal;
9292

@@ -117,7 +117,7 @@ Geom::Point drawAxes::getTitleOffset(Gen::ChannelId axisIndex,
117117
int index,
118118
bool fades) const
119119
{
120-
const auto &titleStyle = style.plot.getAxis(axisIndex).title;
120+
const auto &titleStyle = rootStyle.plot.getAxis(axisIndex).title;
121121

122122
auto calcSide = [](int, auto side)
123123
{
@@ -161,7 +161,7 @@ void drawAxes::drawTitle(Gen::ChannelId axisIndex)
161161
? "plot.xAxis.title"
162162
: "plot.yAxis.title";
163163

164-
const auto &titleStyle = style.plot.getAxis(axisIndex).title;
164+
const auto &titleStyle = rootStyle.plot.getAxis(axisIndex).title;
165165

166166
auto fades = titleStyle.position->interpolates()
167167
|| titleStyle.vposition->interpolates()
@@ -240,7 +240,7 @@ void drawAxes::drawTitle(Gen::ChannelId axisIndex)
240240
drawLabel(Geom::Rect(Geom::Point(), size),
241241
title.value,
242242
titleStyle,
243-
events.plot.axis.title,
243+
rootEvents.plot.axis.title,
244244
std::move(param),
245245
canvas,
246246
drawLabel::Options(false, 1.0, upsideDown));
@@ -254,7 +254,7 @@ void drawAxes::drawDimensionLabels(bool horizontal)
254254
{
255255
auto axisIndex = horizontal ? Gen::ChannelId::x : Gen::ChannelId::y;
256256

257-
const auto &labelStyle = style.plot.getAxis(axisIndex).label;
257+
const auto &labelStyle = rootStyle.plot.getAxis(axisIndex).label;
258258

259259
auto textColor = *labelStyle.color;
260260
if (textColor.alpha == 0.0) return;
@@ -281,7 +281,7 @@ void drawAxes::drawDimensionLabel(bool horizontal,
281281
horizontal ? "plot.xAxis.label" : "plot.yAxis.label";
282282
auto &enabled = horizontal ? plot.guides.x : plot.guides.y;
283283
auto axisIndex = horizontal ? Gen::ChannelId::x : Gen::ChannelId::y;
284-
const auto &labelStyle = style.plot.getAxis(axisIndex).label;
284+
const auto &labelStyle = rootStyle.plot.getAxis(axisIndex).label;
285285
auto textColor = *labelStyle.color;
286286

287287
auto text = it->second.label;
@@ -331,7 +331,7 @@ void drawAxes::drawDimensionLabel(bool horizontal,
331331
text,
332332
posDir,
333333
labelStyle,
334-
events.plot.axis.label,
334+
rootEvents.plot.axis.label,
335335
std::move(Events::Events::OnTextDrawParam(element)),
336336
0,
337337
textColor * weight * position.weight,

src/chart/rendering/drawguides.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void drawGuides::draw(bool horizontal)
1717
{
1818
auto axisId = horizontal ? Gen::ChannelId::x : Gen::ChannelId::y;
1919

20-
const auto &guideStyle = style.plot.getAxis(axisId).guides;
20+
const auto &guideStyle = rootStyle.plot.getAxis(axisId).guides;
2121

2222
auto baseColor = *guideStyle.color;
2323
if (baseColor.alpha == 0) return;
@@ -61,7 +61,7 @@ void drawGuides::drawGuide(bool horizontal,
6161

6262
canvas.setLineColor(color);
6363
Geom::Line line(relMax, relMax + normal);
64-
if (events.plot.axis.guide->invoke(
64+
if (rootEvents.plot.axis.guide->invoke(
6565
Events::OnLineDrawParam(element, line)))
6666
painter.drawLine(line);
6767
}

src/chart/rendering/drawingcontext.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ class DrawingContext
2626
canvas(canvas),
2727
painter(*static_cast<Painter *>(canvas.getPainter())),
2828
options(*plot.getOptions()),
29-
style(plot.getStyle()),
30-
events(events),
31-
layout(layout)
29+
rootStyle(plot.getStyle()),
30+
rootEvents(events),
31+
layout(layout)
3232
{
33-
auto plotArea = style.plot.contentRect
34-
(layout.plot, style.calculatedSize());
33+
auto plotArea = rootStyle.plot.contentRect
34+
(layout.plot, rootStyle.calculatedSize());
3535

3636
coordSys = CoordinateSystem(
3737
plotArea,
@@ -48,8 +48,8 @@ class DrawingContext
4848
Gfx::ICanvas &canvas;
4949
Painter &painter;
5050
const Gen::Options &options;
51-
const Styles::Chart &style;
52-
const Events::Draw &events;
51+
const Styles::Chart &rootStyle;
52+
const Events::Draw &rootEvents;
5353
const Layout &layout;
5454
};
5555

src/chart/rendering/drawinterlacing.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void drawInterlacing::draw(bool horizontal, bool text)
2424
auto axisIndex = horizontal ? Gen::ChannelId::y : Gen::ChannelId::x;
2525

2626
auto interlacingColor =
27-
*style.plot.getAxis(axisIndex).interlacing.color;
27+
*rootStyle.plot.getAxis(axisIndex).interlacing.color;
2828

2929
if (!text && interlacingColor.alpha <= 0.0) return;
3030

@@ -93,7 +93,7 @@ void drawInterlacing::draw(
9393

9494
auto axisIndex = horizontal ? Gen::ChannelId::y : Gen::ChannelId::x;
9595

96-
auto &axisStyle = style.plot.getAxis(axisIndex);
96+
auto &axisStyle = rootStyle.plot.getAxis(axisIndex);
9797

9898
const auto &axis = plot.axises.at(axisIndex);
9999

@@ -208,7 +208,7 @@ void drawInterlacing::draw(
208208
horizontal ? "plot.yAxis.interlacing"
209209
: "plot.xAxis.interlacing";
210210

211-
if (events.plot.axis.interlacing->invoke(
211+
if (rootEvents.plot.axis.interlacing->invoke(
212212
Events::OnRectDrawParam(element, rect))) {
213213
painter.drawPolygon(points);
214214
}
@@ -229,7 +229,7 @@ void drawInterlacing::drawDataLabel(
229229
const char *element =
230230
horizontal ? "plot.yAxis.label" : "plot.xAxis.label";
231231
auto axisIndex = horizontal ? Gen::ChannelId::y : Gen::ChannelId::x;
232-
auto &labelStyle = style.plot.getAxis(axisIndex).label;
232+
auto &labelStyle = rootStyle.plot.getAxis(axisIndex).label;
233233

234234
auto str = Text::SmartString::fromNumber(value,
235235
*labelStyle.numberFormat,
@@ -279,7 +279,7 @@ void drawInterlacing::drawDataLabel(
279279
str,
280280
posDir,
281281
labelStyle,
282-
events.plot.axis.label,
282+
rootEvents.plot.axis.label,
283283
std::move(Events::Events::OnTextDrawParam(element)),
284284
0,
285285
textColor * position.weight,
@@ -294,7 +294,7 @@ void drawInterlacing::drawSticks(double tickIntensity,
294294
const char *element =
295295
horizontal ? "plot.yAxis.tick" : "plot.xAxis.tick";
296296
auto axisIndex = horizontal ? Gen::ChannelId::y : Gen::ChannelId::x;
297-
auto &axisStyle = style.plot.getAxis(axisIndex);
297+
auto &axisStyle = rootStyle.plot.getAxis(axisIndex);
298298
const auto &tickStyle = axisStyle.ticks;
299299

300300
auto tickLength = tickStyle.length->get(
@@ -333,7 +333,7 @@ void drawInterlacing::drawSticks(double tickIntensity,
333333
}
334334
});
335335

336-
if (events.plot.axis.tick->invoke(
336+
if (rootEvents.plot.axis.tick->invoke(
337337
Events::OnLineDrawParam(element, tickLine))) {
338338
canvas.line(tickLine);
339339
}

src/chart/rendering/drawitem.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void drawItem::drawLines(const Styles::Guide &style,
4242
canvas.setLineColor(lineColor);
4343
auto axisPoint = blended.center.xComp() + origo.yComp();
4444
Geom::Line line(axisPoint, blended.center);
45-
if (events.plot.marker.guide->invoke(
45+
if (rootEvents.plot.marker.guide->invoke(
4646
Events::OnLineDrawParam("plot.marker.guide.x",
4747
line,
4848
marker.idx))) {
@@ -58,7 +58,7 @@ void drawItem::drawLines(const Styles::Guide &style,
5858
canvas.setLineColor(lineColor);
5959
auto axisPoint = blended.center.yComp() + origo.xComp();
6060
Geom::Line line(blended.center, axisPoint);
61-
if (events.plot.marker.guide->invoke(
61+
if (rootEvents.plot.marker.guide->invoke(
6262
Events::OnLineDrawParam("plot.marker.guide.y",
6363
line,
6464
marker.idx))) {
@@ -181,7 +181,7 @@ void drawItem::draw(const DrawItem &drawItem,
181181
auto colors = getColor(drawItem, factor);
182182

183183
canvas.setLineColor(colors.first);
184-
canvas.setLineWidth(*style.plot.marker.borderWidth);
184+
canvas.setLineWidth(*rootStyle.plot.marker.borderWidth);
185185
canvas.setBrushColor(colors.second);
186186

187187
auto boundary = drawItem.getBoundary();
@@ -196,7 +196,7 @@ void drawItem::draw(const DrawItem &drawItem,
196196
auto p0 = coordSys.convert(line.begin);
197197
auto p1 = coordSys.convert(line.end);
198198

199-
if (events.plot.marker.base->invoke(
199+
if (rootEvents.plot.marker.base->invoke(
200200
Events::OnLineDrawParam("plot.marker",
201201
Geom::Line(p0, p1),
202202
drawItem.marker.idx))) {
@@ -208,7 +208,7 @@ void drawItem::draw(const DrawItem &drawItem,
208208
}
209209
}
210210
else {
211-
if (events.plot.marker.base->invoke(
211+
if (rootEvents.plot.marker.base->invoke(
212212
Events::OnRectDrawParam("plot.marker",
213213
rect,
214214
drawItem.marker.idx))) {
@@ -230,7 +230,7 @@ void drawItem::drawLabel(const DrawItem &drawItem, size_t index)
230230
auto text = getLabelText(index);
231231
if (text.empty()) return;
232232

233-
auto &labelStyle = style.plot.marker.label;
233+
auto &labelStyle = rootStyle.plot.marker.label;
234234

235235
auto labelPos = labelStyle.position->combine<Geom::Line>(
236236
[&](int, const auto &position)
@@ -250,7 +250,7 @@ void drawItem::drawLabel(const DrawItem &drawItem, size_t index)
250250
text,
251251
labelPos,
252252
labelStyle,
253-
events.plot.marker.label,
253+
rootEvents.plot.marker.label,
254254
std::move(param),
255255
centered,
256256
textColor,
@@ -259,7 +259,7 @@ void drawItem::drawLabel(const DrawItem &drawItem, size_t index)
259259

260260
std::string drawItem::getLabelText(size_t index) const
261261
{
262-
auto &labelStyle = style.plot.marker.label;
262+
auto &labelStyle = rootStyle.plot.marker.label;
263263
auto &values = marker.label.values;
264264

265265
auto needsInterpolation = marker.label.count == 2
@@ -318,14 +318,14 @@ std::pair<Gfx::Color, Gfx::Color> drawItem::getColor(
318318
{
319319
auto selectedColor = getSelectedColor();
320320

321-
auto borderAlpha = *style.plot.marker.borderOpacity;
322-
auto fillAlpha = *style.plot.marker.fillOpacity;
321+
auto borderAlpha = *rootStyle.plot.marker.borderOpacity;
322+
auto fillAlpha = *rootStyle.plot.marker.fillOpacity;
323323

324324
auto fakeBgColor =
325-
(*style.backgroundColor + *style.plot.backgroundColor)
325+
(*rootStyle.backgroundColor + *rootStyle.plot.backgroundColor)
326326
.transparent(1.0);
327327

328-
auto borderColor = style.plot.marker.borderOpacityMode->combine<
328+
auto borderColor = rootStyle.plot.marker.borderOpacityMode->combine<
329329
Gfx::Color>(
330330
[&](int, const auto &mode)
331331
{

src/chart/rendering/drawlegend.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ drawLegend::drawLegend(const DrawingContext &context,
1212
Gen::ChannelId channelType,
1313
double weight) :
1414
DrawingContext(context),
15-
events(context.events.legend),
16-
style(context.style.legend),
15+
events(context.rootEvents.legend),
16+
style(context.rootStyle.legend),
1717
type(channelType),
1818
weight(weight)
1919
{
2020
contentRect =
2121
style.contentRect(layout.legend,
22-
context.style.calculatedSize());
22+
context.rootStyle.calculatedSize());
2323
itemHeight = drawLabel::getHeight(style.label, canvas);
2424
titleHeight = drawLabel::getHeight(style.title, canvas);
2525

src/chart/rendering/drawplot.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ drawPlot::drawPlot(const DrawingContext &context) :
1717
{
1818
drawBackground(layout.plot,
1919
canvas,
20-
style.plot,
21-
events.plot.background,
20+
rootStyle.plot,
21+
rootEvents.plot.background,
2222
Events::OnRectDrawParam("plot"));
2323

2424
drawArea(false);
2525
drawAxes(*this).drawBase();
2626

27-
auto clip = style.plot.overflow == Styles::Overflow::hidden;
27+
auto clip = rootStyle.plot.overflow == Styles::Overflow::hidden;
2828

2929
if (clip) clipPlotArea();
3030

@@ -64,18 +64,18 @@ void drawPlot::drawArea(bool clip)
6464

6565
Events::OnRectDrawParam eventObj("plot.area", rect);
6666

67-
if (!style.plot.areaColor->isTransparent()) {
68-
canvas.setBrushColor(*style.plot.areaColor);
69-
canvas.setLineColor(*style.plot.areaColor);
67+
if (!rootStyle.plot.areaColor->isTransparent()) {
68+
canvas.setBrushColor(*rootStyle.plot.areaColor);
69+
canvas.setLineColor(*rootStyle.plot.areaColor);
7070
canvas.setLineWidth(0);
71-
if (!events.plot.area
72-
|| events.plot.area->invoke(std::move(eventObj))) {
71+
if (!rootEvents.plot.area
72+
|| rootEvents.plot.area->invoke(std::move(eventObj))) {
7373
painter.drawPolygon(points, false);
7474
}
7575
canvas.setLineWidth(0);
7676
}
77-
else if (events.plot.area)
78-
events.plot.area->invoke(std::move(eventObj));
77+
else if (rootEvents.plot.area)
78+
rootEvents.plot.area->invoke(std::move(eventObj));
7979
}
8080
}
8181

0 commit comments

Comments
 (0)