C++ API: Make LinearGradientBrush and GradientStop private API

This commit is contained in:
Simon Hausmann 2021-07-02 15:34:16 +02:00
parent 9819f7f6b7
commit adeb192f6e
3 changed files with 20 additions and 7 deletions

View file

@ -15,8 +15,11 @@ LICENSE END */
namespace sixtyfps {
namespace private_api {
using cbindgen_private::types::GradientStop;
/// \private
/// LinearGradientBrush represents a gradient for a brush that is a linear sequence of color stops,
/// that are aligned at a specific angle.
class LinearGradientBrush
@ -50,12 +53,12 @@ public:
private:
cbindgen_private::types::LinearGradientBrush inner;
friend class Brush;
friend class sixtyfps::Brush;
static SharedVector<GradientStop>
static SharedVector<private_api::GradientStop>
make_linear_gradient(float angle, const GradientStop *firstStop, int stopCount)
{
SharedVector<GradientStop> gradient;
SharedVector<private_api::GradientStop> gradient;
gradient.push_back({ Color::from_argb_encoded(0).inner, angle });
for (int i = 0; i < stopCount; ++i, ++firstStop)
gradient.push_back(*firstStop);
@ -63,6 +66,8 @@ private:
}
};
}
/// Brush is used to declare how to fill or outline shapes, such as rectangles, paths or text. A
/// brush is either a solid color or a linear gradient.
class Brush
@ -72,8 +77,12 @@ public:
Brush() : Brush(Color {}) { }
/// Constructs a new brush that is of color \a color.
Brush(const Color &color) : data(Inner::SolidColor(color.inner)) { }
/// \private
/// Constructs a new brush that is the gradient \a gradient.
Brush(const LinearGradientBrush &gradient) : data(Inner::LinearGradient(gradient.inner)) { }
Brush(const private_api::LinearGradientBrush &gradient)
: data(Inner::LinearGradient(gradient.inner))
{
}
/// Returns the color of the brush. If the brush is a gradient, this function returns the color
/// of the first stop.

View file

@ -16,6 +16,10 @@ LICENSE END */
namespace sixtyfps {
namespace private_api {
class LinearGradientBrush;
}
class Color;
/// RgbaColor stores the red, green, blue and alpha components of a color
@ -178,7 +182,7 @@ public:
private:
cbindgen_private::types::Color inner;
friend class LinearGradientBrush;
friend class private_api::LinearGradientBrush;
friend class Brush;
};