#define DALI_TOOLKIT_INTERNAL_GRADIENT_H
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*/
-//EXTERNAL INCLUDES
+// EXTERNAL INCLUDES
#include <dali/public-api/common/dali-vector.h>
-#include <dali/public-api/images/buffer-image.h>
#include <dali/public-api/math/matrix3.h>
#include <dali/public-api/object/ref-object.h>
#include <dali/public-api/rendering/texture.h>
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/gradient-visual-properties.h>
+
namespace Dali
{
-
class Vector4;
namespace Toolkit
{
-
namespace Internal
{
-
/**
* Gradients consist of continuously smooth color transitions along a vector from one color to another,
* possibly followed by additional transitions along the same vector to other colors.
{
public:
/**
- * Defines the coordinate system of the attributes
- * (start and end position for linear gradient, circle center and radius for radial gradient)
- */
- enum GradientUnits
- {
- USER_SPACE_ON_USE,
- OBJECT_BOUNDING_BOX
- };
-
- /**
- * Indicates what happens if the gradient starts or ends inside the bounds of the object being painted by the gradient.
- */
- enum SpreadMethod
- {
- PAD, // use the terminal colors of the gradient to fill the remainder of the target region
- REPEAT, // reflect the gradient pattern start-to-end, end-to-start, start-to-end, etc. continuously until the target rectangle is filled
- REFLECT // repeat the gradient pattern start-to-end, start-to-end, start-to-end, etc. continuously until the target region is filled
- };
-
- /**
* The stop node tells the gradient what color it should be at certain position.
*/
struct GradientStop
{
- GradientStop( float offset, const Vector4& color )
- : mOffset( offset ), mStopColor( color )
- {}
+ GradientStop(float offset, const Vector4& color)
+ : mOffset(offset),
+ mStopColor(color)
+ {
+ }
bool operator<(const GradientStop& rhs) const
{
return mOffset < rhs.mOffset;
}
- float mOffset; // A value ranging from 0 to 1 to indicate where the gradient stop is placed.
- Vector4 mStopColor; // The color to use at this gradient stop
+ float mOffset; // A value ranging from 0 to 1 to indicate where the gradient stop is placed.
+ Vector4 mStopColor; // The color to use at this gradient stop
};
public:
-
/**
* Add a gradient stop.
*
* Set the coordinate system used by the gradient attributes.
* @param[in] gradientUnits The the attributes are defined using the current user coordinate system or the bounding box of the shape.
*/
- void SetGradientUnits( GradientUnits gradientUnits );
+ void SetGradientUnits(Toolkit::GradientVisual::Units::Type gradientUnits);
/**
* Get the coordinate system used by the gradient attributes.
* @return USER_SPACE_ON_USE or OBJECT_BOUNDING_BOX
*/
- GradientUnits GetGradientUnits() const;
+ Toolkit::GradientVisual::Units::Type GetGradientUnits() const;
/**
* Indicates what happens if the gradient starts or ends inside the bounds of the target rectangle.
*
* @param[in] spread The method to fill the remainder of target region which is outside the gradient bounds
*/
- void SetSpreadMethod( SpreadMethod spread );
+ void SetSpreadMethod(Toolkit::GradientVisual::SpreadMethod::Type spread);
/**
* Get the filling method for the the remainder of target region which is outside the gradient boun.
* @return PAD, REFLECT or REPEAT
*/
- SpreadMethod GetSpreadMethod() const;
+ Toolkit::GradientVisual::SpreadMethod::Type GetSpreadMethod() const;
/**
* Get the transformation matrix to align the vertices with the gradient line/circle
Dali::Texture GenerateLookupTexture();
private:
-
/**
* Estimate the resolution of the lookup texture.
* Note: Only call this function after the gradient stops are sorted in order.
unsigned int EstimateTextureResolution();
protected:
-
/**
* Construct a new Gradient object
* Called in the constructor of subclasses
virtual ~Gradient();
// Undefined
- Gradient( const Gradient& gradient );
+ Gradient(const Gradient& gradient);
// Undefined
- Gradient& operator=( const Gradient& handle );
+ Gradient& operator=(const Gradient& handle);
protected:
-
- Vector<GradientStop> mGradientStops;
- Matrix3 mAlignmentTransform;
- GradientUnits mGradientUnits;
- SpreadMethod mSpreadMethod;
-
+ Vector<GradientStop> mGradientStops;
+ Matrix3 mAlignmentTransform;
+ Toolkit::GradientVisual::Units::Type mGradientUnits;
+ Toolkit::GradientVisual::SpreadMethod::Type mSpreadMethod;
};
} // namespace Internal