Skip to content

Commit 4cd6a4b

Browse files
committed
Merge remote-tracking branch 'origin/main' into remove_this_eq
2 parents f1289a2 + 8c9a2f7 commit 4cd6a4b

33 files changed

+787
-531
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
## [Unreleased]
44

5+
### Fixed
6+
7+
- Legend title bottomPadding extended.
8+
9+
### Added
10+
11+
- New style parameter for the legend scrolling.
12+
513
## [0.12.1] - 2024-08-22
614

715
### Fixed

src/apps/qutils/canvas.cpp

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ void BaseCanvas::init(QPaintDevice *device)
9292

9393
void BaseCanvas::setBrushColor(const Gfx::Color &color)
9494
{
95-
brush = QBrush(toQColor(color));
96-
painter.setBrush(brush);
95+
painter.setBrush(toQColor(color));
96+
painter.setPen(brushToPen(painter.brush()));
9797
}
9898

9999
void BaseCanvas::setLineColor(const Gfx::Color &color)
@@ -162,12 +162,6 @@ void BaseCanvas::setFont(const Gfx::Font &newFont)
162162
painter.setFont(fromGfxFont(newFont, painter.font()));
163163
}
164164

165-
void BaseCanvas::setTextColor(const Gfx::Color &color)
166-
{
167-
textPen = colorToPen(color);
168-
painter.setPen(textPen);
169-
}
170-
171165
void BaseCanvas::beginDropShadow() {}
172166

173167
void BaseCanvas::setDropShadowBlur(double) {}
@@ -199,29 +193,28 @@ void BaseCanvas::rectangle(const Geom::Rect &rect)
199193

200194
void BaseCanvas::text(const Geom::Rect &rect, const std::string &text)
201195
{
202-
painter.setPen(textPen);
196+
painter.setPen(brushToPen(painter.brush()));
203197
painter.drawText(toQRect(rect),
204198
Qt::AlignLeft,
205199
QString::fromStdString(text));
206200
}
207201

208-
void BaseCanvas::setBrushGradient(const Geom::Line &line,
209-
const Gfx::ColorGradient &gradient)
202+
void BaseCanvas::setBrushGradient(const Gfx::LinearGradient &gradient)
210203
{
211-
QLinearGradient qGradient(toQPoint(line.begin),
212-
toQPoint(line.end));
213-
for (auto stop : gradient.stops) {
214-
qGradient.setColorAt(stop.pos, toQColor(stop.value));
215-
}
204+
QLinearGradient qGradient(toQPoint(gradient.line.begin),
205+
toQPoint(gradient.line.end));
206+
for (auto &&[pos, value] : gradient.colors.stops)
207+
qGradient.setColorAt(pos, toQColor(value));
216208
painter.setBrush(QBrush(qGradient));
209+
painter.setPen(brushToPen(painter.brush()));
217210
}
218211

219-
QPen BaseCanvas::colorToPen(const Gfx::Color &color)
212+
QPen BaseCanvas::colorToPen(const Gfx::Color &color) const
220213
{
221214
return brushToPen(QBrush(toQColor(color)));
222215
}
223216

224-
QPen BaseCanvas::brushToPen(const QBrush &brush)
217+
QPen BaseCanvas::brushToPen(const QBrush &brush) const
225218
{
226219
auto pen = painter.pen();
227220
pen.setBrush(brush);

src/apps/qutils/canvas.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class BaseCanvas : public Gfx::ICanvas, public Vizzu::Draw::Painter
2626
void setLineColor(const Gfx::Color &color) override;
2727
void setLineWidth(double width) override;
2828
void setFont(const Gfx::Font &newFont) override;
29-
void setTextColor(const Gfx::Color &color) override;
3029

3130
void beginDropShadow() override;
3231
void setDropShadowBlur(double radius) override;
@@ -47,8 +46,8 @@ class BaseCanvas : public Gfx::ICanvas, public Vizzu::Draw::Painter
4746
void text(const Geom::Rect &rect,
4847
const std::string &text) override;
4948

50-
void setBrushGradient(const Geom::Line &line,
51-
const Gfx::ColorGradient &gradient) override;
49+
void setBrushGradient(
50+
const Gfx::LinearGradient &gradient) override;
5251

5352
void frameBegin() override {}
5453
void frameEnd() override {}
@@ -70,11 +69,9 @@ class BaseCanvas : public Gfx::ICanvas, public Vizzu::Draw::Painter
7069
QFont font;
7170
QPainterPath polygon;
7271
QPen linePen;
73-
QPen textPen;
74-
QBrush brush;
7572

76-
QPen colorToPen(const Gfx::Color &color);
77-
QPen brushToPen(const QBrush &brush);
73+
[[nodiscard]] QPen colorToPen(const Gfx::Color &color) const;
74+
[[nodiscard]] QPen brushToPen(const QBrush &brush) const;
7875
};
7976

8077
using Canvas = BaseCanvas;

src/apps/weblib/jscriptcanvas.cpp

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,6 @@ void JScriptCanvas::setFont(const Gfx::Font &font)
8585
}
8686
}
8787

88-
void JScriptCanvas::setTextColor(const Gfx::Color &color)
89-
{
90-
if (color != brushColor) {
91-
brushColor = color;
92-
::canvas_setBrushColor(this,
93-
color.red,
94-
color.green,
95-
color.blue,
96-
color.alpha);
97-
}
98-
}
99-
10088
void JScriptCanvas::beginDropShadow()
10189
{
10290
::canvas_beginDropShadow(this);
@@ -182,10 +170,11 @@ void JScriptCanvas::text(const Geom::Rect &rect,
182170
text.c_str());
183171
}
184172

185-
void JScriptCanvas::setBrushGradient(const Geom::Line &line,
186-
const Gfx::ColorGradient &gradient)
173+
void JScriptCanvas::setBrushGradient(
174+
const Gfx::LinearGradient &gradient)
187175
{
188-
typedef decltype(gradient.stops)::value_type Stop;
176+
typedef decltype(gradient.colors.stops)::value_type Stop;
177+
static_assert(sizeof(double) == 8);
189178
static_assert(sizeof(Stop) == sizeof(double) * 5);
190179

191180
static_assert(offsetof(Stop, pos) == 0);
@@ -200,12 +189,12 @@ void JScriptCanvas::setBrushGradient(const Geom::Line &line,
200189
std::is_same_v<decltype(Stop::value.alpha), double>);
201190

202191
::canvas_setBrushGradient(this,
203-
line.begin.x,
204-
line.begin.y,
205-
line.end.x,
206-
line.end.y,
207-
gradient.stops.size(),
208-
gradient.stops.data());
192+
gradient.line.begin.x,
193+
gradient.line.begin.y,
194+
gradient.line.end.x,
195+
gradient.line.end.y,
196+
gradient.colors.stops.size(),
197+
gradient.colors.stops.data());
209198
}
210199

211200
void JScriptCanvas::frameEnd() { ::canvas_frameEnd(this); }

src/apps/weblib/jscriptcanvas.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ class JScriptCanvas : public Gfx::ICanvas, public Draw::Painter
2323
void setLineColor(const Gfx::Color &color) override;
2424
void setLineWidth(double width) override;
2525
void setFont(const Gfx::Font &font) override;
26-
void setTextColor(const Gfx::Color &color) override;
2726

2827
void beginDropShadow() override;
2928
void setDropShadowBlur(double radius) override;
@@ -45,8 +44,8 @@ class JScriptCanvas : public Gfx::ICanvas, public Draw::Painter
4544
void text(const Geom::Rect &rect,
4645
const std::string &text) override;
4746

48-
void setBrushGradient(const Geom::Line &line,
49-
const Gfx::ColorGradient &gradient) override;
47+
void setBrushGradient(
48+
const Gfx::LinearGradient &gradient) override;
5049

5150
void frameBegin() override;
5251
void frameEnd() override;

src/apps/weblib/ts-api/events.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ export interface Caption extends TextElement {
124124
export interface Legend extends Element {
125125
tagName: 'legend'
126126
channel: string
127+
scrollTop: number
128+
scrollHeight: number
127129
}
128130

129131
/** Logo element of the chart. */

src/apps/weblib/typeschema-api/styles.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ definitions:
3232

3333
NumberScale:
3434
description: |
35-
Number scale for human readable big number formats.
35+
Number scale for human-readable big number formats.
3636
There are built in formats:
3737
- SI Symbols: k, M, G, ...
3838
- Short scale with US abbreviations: K, M, B, T
@@ -524,6 +524,10 @@ definitions:
524524
marker:
525525
$ref: LegendMarker
526526
nullable: true
527+
translateY:
528+
description: Vertical translation of the marker list.
529+
$ref: Length
530+
nullable: true
527531

528532
ColorStop:
529533
description: |

src/base/anim/easinggradient.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "base/math/segmentedfunc.h"
1010
#include "base/math/segmentedfunc.tpp"
1111

12-
template struct Math::SegmentedFunction<double>;
12+
template struct Math::SegmentedFunction<double, Anim::EasingGradient>;
1313

1414
namespace Anim
1515
{

src/base/anim/easinggradient.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@
99
namespace Anim
1010
{
1111

12-
class EasingGradient : protected Math::SegmentedFunction<double>
12+
class EasingGradient :
13+
protected Math::SegmentedFunction<double, EasingGradient>
1314
{
1415
public:
15-
using Math::SegmentedFunction<double>::SegmentedFunction;
16+
friend struct SegmentedFunction;
17+
using SegmentedFunction::SegmentedFunction;
1618

17-
static EasingGradient Bezier(const Geom::Point &p1,
19+
[[nodiscard]] static EasingGradient Bezier(const Geom::Point &p1,
1820
const Geom::Point &p2,
1921
size_t stepCount = 10);
2022

21-
double operator()(double t) const { return at(t); }
23+
using SegmentedFunction::operator();
2224
};
2325

2426
}

src/base/conv/auto_json.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,24 @@ struct JSONObj : protected JSONRepeat<'{', '}'>
325325
}
326326
return std::move(*this);
327327
}
328+
329+
template <class T> JSONObj &&mergeObj(const T &obj) &&
330+
{
331+
auto pre_size = json.size();
332+
333+
staticObj(obj);
334+
335+
json.pop_back();
336+
337+
if (pre_size + 1 == json.size())
338+
json.pop_back();
339+
else if (was)
340+
json[pre_size] = ',';
341+
else
342+
was = true;
343+
344+
return std::move(*this);
345+
}
328346
};
329347

330348
struct JSONArr : protected JSONRepeat<'[', ']'>

0 commit comments

Comments
 (0)