Merge branch 'develop' into feature/grid-layout

This commit is contained in:
Martín Lucas Golini
2026-06-02 02:05:03 -03:00
7 changed files with 342 additions and 312 deletions

View File

@@ -1,57 +0,0 @@
#ifndef EE_GRAPHICS_LINEARGRADIENTDRAWABLE_HPP
#define EE_GRAPHICS_LINEARGRADIENTDRAWABLE_HPP
#include <eepp/graphics/drawable.hpp>
#include <eepp/system/color.hpp>
#include <vector>
namespace EE { namespace Graphics {
class EE_API LinearGradientDrawable : public Drawable {
public:
struct ColorStop {
Float position{ 0 }; /* 0.0 to 1.0 */
Color color;
ColorStop() : color( Color::White ) {}
ColorStop( Float pos, const Color& col ) : position( pos ), color( col ) {}
};
static LinearGradientDrawable* New();
static LinearGradientDrawable* NewRepeating();
LinearGradientDrawable( Drawable::Type drawableType = LINEARGRADIENT );
virtual Sizef getSize();
virtual Sizef getPixelsSize();
virtual void draw();
virtual void draw( const Vector2f& position );
virtual void draw( const Vector2f& position, const Sizef& size );
virtual bool isStateful() { return false; }
const std::vector<ColorStop>& getColorStops() const;
void setColorStops( std::vector<ColorStop> stops );
Float getAngle() const;
void setAngle( Float angleDegrees );
void setSize( const Sizef& size );
bool isRepeating() const;
protected:
std::vector<ColorStop> mColorStops;
Float mAngle{ 180.f }; /* CSS angle: 0=to top, 90=to right, 180=to bottom (default) */
Sizef mSize;
};
}} // namespace EE::Graphics
#endif

View File

@@ -0,0 +1,72 @@
#ifndef EE_UI_LINEARGRADIENTDRAWABLE_HPP
#define EE_UI_LINEARGRADIENTDRAWABLE_HPP
#include <eepp/graphics/drawable.hpp>
#include <eepp/system/color.hpp>
#include <eepp/ui/css/stylesheetlength.hpp>
#include <vector>
namespace EE { namespace UI {
class EE_API LinearGradientDrawable : public Graphics::Drawable {
public:
using Length = CSS::StyleSheetLength;
using GradientUnit = CSS::StyleSheetLength::Unit;
struct ColorStop {
Color color;
Float value{ 0 };
GradientUnit unit{ CSS::StyleSheetLength::Percentage };
ColorStop() : color( Color::White ) {}
ColorStop( Float val, const Color& col, GradientUnit u = CSS::StyleSheetLength::Percentage ) :
value( val ), color( col ), unit( u ) {}
Float getNormalized( Float gradientLineLength ) const {
if ( unit == CSS::StyleSheetLength::Percentage )
return eemax( 0.f, value ) / 100.f;
if ( gradientLineLength > 0.0001f )
return eemax( 0.f, value ) / gradientLineLength;
return 0.f;
}
};
static LinearGradientDrawable* New();
static LinearGradientDrawable* NewRepeating();
LinearGradientDrawable(
Graphics::Drawable::Type drawableType = Graphics::Drawable::LINEARGRADIENT );
virtual Sizef getSize();
virtual Sizef getPixelsSize();
virtual void draw();
virtual void draw( const Vector2f& position );
virtual void draw( const Vector2f& position, const Sizef& size );
virtual bool isStateful() { return false; }
const std::vector<ColorStop>& getColorStops() const;
void setColorStops( std::vector<ColorStop> stops );
Float getAngle() const;
void setAngle( Float angleDegrees );
void setSize( const Sizef& size );
bool isRepeating() const;
protected:
std::vector<ColorStop> mColorStops;
Float mAngle{ 180.f };
Sizef mSize;
};
}} // namespace EE::UI
#endif

View File

@@ -1,20 +1,35 @@
#ifndef EE_GRAPHICS_RADIALGRADIENTDRAWABLE_HPP
#define EE_GRAPHICS_RADIALGRADIENTDRAWABLE_HPP
#ifndef EE_UI_RADIALGRADIENTDRAWABLE_HPP
#define EE_UI_RADIALGRADIENTDRAWABLE_HPP
#include <eepp/graphics/drawable.hpp>
#include <eepp/system/color.hpp>
#include <eepp/ui/css/stylesheetlength.hpp>
#include <eepp/ui/lineargradientdrawable.hpp>
#include <vector>
namespace EE { namespace Graphics {
namespace EE { namespace UI {
class EE_API RadialGradientDrawable : public Drawable {
class EE_API RadialGradientDrawable : public Graphics::Drawable {
public:
using Length = CSS::StyleSheetLength;
using GradientUnit = CSS::StyleSheetLength::Unit;
struct ColorStop {
Float position{ 0 };
Color color;
Float value{ 0 };
GradientUnit unit{ CSS::StyleSheetLength::Percentage };
ColorStop() : color( Color::White ) {}
ColorStop( Float pos, const Color& col ) : position( pos ), color( col ) {}
ColorStop( Float val, const Color& col, GradientUnit u = CSS::StyleSheetLength::Percentage ) :
value( val ), color( col ), unit( u ) {}
Float getNormalized( Float gradientRayLength ) const {
if ( unit == CSS::StyleSheetLength::Percentage )
return eemax( 0.f, value ) / 100.f;
if ( gradientRayLength > 0.0001f )
return eemax( 0.f, value ) / gradientRayLength;
return 0.f;
}
};
enum ShapeType { CIRCLE, ELLIPSE };
@@ -23,7 +38,8 @@ class EE_API RadialGradientDrawable : public Drawable {
static RadialGradientDrawable* New();
static RadialGradientDrawable* NewRepeating();
RadialGradientDrawable( Drawable::Type drawableType = RADIALGRADIENT );
RadialGradientDrawable(
Graphics::Drawable::Type drawableType = Graphics::Drawable::RADIALGRADIENT );
virtual Sizef getSize();
@@ -65,6 +81,6 @@ class EE_API RadialGradientDrawable : public Drawable {
Sizef mSize;
};
}} // namespace EE::Graphics
}} // namespace EE::UI
#endif