Skip to content

Commit a4b532b

Browse files
committed
Fix fontparent setter bug
1 parent 510c08c commit a4b532b

File tree

8 files changed

+19
-6
lines changed

8 files changed

+19
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- Split chart count negative values too.
1010
- Split chart handled when same dimension on main and sub axis.
1111
- Add record didn't handle when a measure got an empty string.
12+
- Fix no fontparent set bug.
1213

1314
### Changed
1415

src/chart/animator/keyframe.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ void Keyframe::prepareActual()
7171
prepareActualMarkersInfo();
7272

7373
actual = std::make_shared<Gen::Plot>(*source);
74+
actual->getStyle().setup();
7475
actual->detachOptions();
7576
}
7677

@@ -92,6 +93,7 @@ void Keyframe::copyTarget()
9293
if (!targetCopy) {
9394
targetCopy = target;
9495
target = std::make_shared<Gen::Plot>(*targetCopy);
96+
target->getStyle().setup();
9597
target->detachOptions();
9698
}
9799
}

src/chart/generator/plot.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ Plot::Plot(PlotOptionsPtr opts, Styles::Chart style) :
5858
guides(*opts),
5959
options(std::move(opts)),
6060
style(std::move(style))
61-
{}
61+
{
62+
this->style.setup();
63+
}
6264

6365
void Plot::detachOptions()
6466
{

src/chart/main/chart.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Chart::Chart() :
2929
*events.animation.begin,
3030
*events.animation.complete)
3131
{
32+
computedStyles.setup();
3233
animator.onDraw.attach(
3334
[this](const Gen::PlotPtr &actPlot)
3435
{
@@ -72,8 +73,9 @@ void Chart::animate(Anim::Animation::OnComplete &&onComplete)
7273
}
7374
else {
7475
*nextOptions = prevOptions;
75-
actStyles = prevStyles;
76+
setStyles(prevStyles);
7677
computedStyles = plot->getStyle();
78+
computedStyles.setup();
7779
}
7880
});
7981

@@ -132,6 +134,7 @@ Gen::PlotPtr Chart::plot(const Gen::PlotOptionsPtr &options)
132134
Styles::Sheet::setAfterStyles(*res, layout.boundary.size);
133135

134136
computedStyles = res->getStyle();
137+
computedStyles.setup();
135138

136139
return res;
137140
}

src/chart/main/style.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ struct FontParentSetter
584584
{}
585585
};
586586

587-
void Chart::setup()
587+
void Chart::setup() &
588588
{
589589
Refl::visit(FontParentSetter{this}, *this);
590590
fontParent = &getDefaultFont();

src/chart/main/style.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ struct Chart : Padding, Box, Font, ChartParams
401401
static const Gfx::ColorPalette &getDefaultColorPalette();
402402
static Chart def();
403403

404-
void setup();
404+
void setup() &;
405405
};
406406

407407
}

src/chart/main/stylesheet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Chart Sheet::getFullParams(const Gen::PlotOptionsPtr &options,
5151
void Sheet::calcDefaults(const Geom::Size &size)
5252
{
5353
defaultParams = Chart::def();
54+
defaultParams.setup();
5455

5556
defaultParams.fontSize = Gfx::Length{baseFontSize(size, true)};
5657

@@ -219,7 +220,6 @@ void Sheet::setData()
219220
void Sheet::setAfterStyles(Gen::Plot &plot, const Geom::Size &size)
220221
{
221222
auto &style = plot.getStyle();
222-
style.setup();
223223

224224
if (auto &xLabel =
225225
style.plot

src/chart/main/stylesheet.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ class Sheet : public Style::Sheet<Chart>
2727
{
2828
public:
2929
using Base = Style::Sheet<Chart>;
30-
using Base::Sheet;
30+
31+
Sheet(Chart &&defaultParams, Chart &activeParams) :
32+
Base(std::move(defaultParams), activeParams)
33+
{
34+
this->defaultParams.setup();
35+
}
3136

3237
Chart getFullParams(const Gen::PlotOptionsPtr &options,
3338
const Geom::Size &size);

0 commit comments

Comments
 (0)