64eb49fd24
Renamed BGradient::color_step to BGradient::ColorStop as it's called everywhere else. Also renamed BGradient::gradient_type to just BGradient::Type. Renamed BGradient::Type() to GetType(). * Simplification of method names in Painter.cpp. Some not yet complete and yet inactive code to accelerate vertical gradients (bypassing AGG for this special case). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29214 a95241bf-73f2-0310-859d-f6bbb57e9c96
110 lines
2.2 KiB
C++
110 lines
2.2 KiB
C++
/*
|
|
* Copyright 2006-2009, Haiku.
|
|
* Distributed under the terms of the MIT License.
|
|
*
|
|
* Authors:
|
|
* Stephan Aßmus <superstippi@gmx.de>
|
|
* Artur Wyszynski <harakash@gmail.com>
|
|
*/
|
|
|
|
#ifndef _GRADIENT_H
|
|
#define _GRADIENT_H
|
|
|
|
#include <Archivable.h>
|
|
#include <GraphicsDefs.h>
|
|
#include <List.h>
|
|
|
|
|
|
class BMessage;
|
|
class BRect;
|
|
|
|
|
|
class BGradient : public BArchivable {
|
|
public:
|
|
enum Type {
|
|
TYPE_LINEAR = 0,
|
|
TYPE_RADIAL,
|
|
TYPE_RADIAL_FOCUS,
|
|
TYPE_DIAMOND,
|
|
TYPE_CONIC,
|
|
TYPE_NONE
|
|
};
|
|
|
|
struct ColorStop {
|
|
ColorStop(const rgb_color c, float o);
|
|
ColorStop(uint8 r, uint8 g, uint8 b, uint8 a, float o);
|
|
ColorStop(const ColorStop& other);
|
|
ColorStop();
|
|
|
|
bool operator!=(const ColorStop& other) const;
|
|
|
|
rgb_color color;
|
|
float offset;
|
|
};
|
|
|
|
public:
|
|
BGradient();
|
|
BGradient(BMessage* archive);
|
|
virtual ~BGradient();
|
|
|
|
status_t Archive(BMessage* into, bool deep = true) const;
|
|
|
|
BGradient& operator=(const BGradient& other);
|
|
|
|
bool operator==(const BGradient& other) const;
|
|
bool operator!=(const BGradient& other) const;
|
|
bool ColorStopsAreEqual(const BGradient& other) const;
|
|
|
|
void SetColorStops(const BGradient& other);
|
|
|
|
int32 AddColor(const rgb_color& color, float offset);
|
|
bool AddColorStop(const ColorStop& colorStop, int32 index);
|
|
|
|
bool RemoveColor(int32 index);
|
|
|
|
bool SetColorStop(int32 index, const ColorStop& colorStop);
|
|
bool SetColor(int32 index, const rgb_color& color);
|
|
bool SetOffset(int32 index, float offset);
|
|
|
|
int32 CountColorStops() const;
|
|
ColorStop* ColorStopAt(int32 index) const;
|
|
ColorStop* ColorStopAtFast(int32 index) const;
|
|
ColorStop* ColorStops() const;
|
|
void SortColorStopsByOffset();
|
|
|
|
Type GetType() const
|
|
{ return fType; }
|
|
|
|
void MakeEmpty();
|
|
|
|
private:
|
|
friend class BGradientLinear;
|
|
friend class BGradientRadial;
|
|
friend class BGradientRadialFocus;
|
|
friend class BGradientDiamond;
|
|
friend class BGradientConic;
|
|
|
|
union {
|
|
struct {
|
|
float x1, y1, x2, y2;
|
|
} linear;
|
|
struct {
|
|
float cx, cy, radius;
|
|
} radial;
|
|
struct {
|
|
float cx, cy, fx, fy, radius;
|
|
} radial_focus;
|
|
struct {
|
|
float cx, cy;
|
|
} diamond;
|
|
struct {
|
|
float cx, cy, angle;
|
|
} conic;
|
|
} fData;
|
|
|
|
BList fColorStops;
|
|
Type fType;
|
|
};
|
|
|
|
#endif // _GRADIENT_H
|