2 * Copyright 2006-2007, Haiku.
3 * Distributed under the terms of the MIT License.
6 * Stephan Aßmus <superstippi@gmx.de>
8 #ifndef GRADIENT_TRANSFORMABLE_H
9 #define GRADIENT_TRANSFORMABLE_H
13 # include <Archivable.h>
14 # include <Referenceable.h>
16 # include "Observable.h"
17 #endif // ICON_O_MATIC
19 #include "IconBuild.h"
20 #include "Transformable.h"
22 #include <GraphicsDefs.h>
37 enum interpolation_type
{
38 INTERPOLATION_LINEAR
= 0,
47 class Gradient
: public BArchivable
,
49 public BReferenceable
,
50 public Transformable
{
52 class Gradient
: public Transformable
{
56 Gradient(bool empty
= false);
57 Gradient(BMessage
* archive
);
58 Gradient(const Gradient
& other
);
62 status_t
Archive(BMessage
* into
, bool deep
= true) const;
64 inline void Notify() {}
67 Gradient
& operator=(const Gradient
& other
);
69 bool operator==(const Gradient
& other
) const;
70 bool operator!=(const Gradient
& other
) const;
71 bool ColorStepsAreEqual(
72 const Gradient
& other
) const;
74 void SetColors(const Gradient
& other
);
77 int32
AddColor(const rgb_color
& color
, float offset
);
78 bool AddColor(const BGradient::ColorStop
& color
,
81 bool RemoveColor(int32 index
);
83 bool SetColor(int32 index
,
84 const BGradient::ColorStop
& step
);
85 bool SetColor(int32 index
, const rgb_color
& color
);
86 bool SetOffset(int32 index
, float offset
);
88 int32
CountColors() const;
89 BGradient::ColorStop
* ColorAt(int32 index
) const;
90 BGradient::ColorStop
* ColorAtFast(int32 index
) const;
92 void SetType(gradients_type type
);
93 gradients_type
Type() const
96 void SetInterpolation(interpolation_type type
);
97 interpolation_type
Interpolation() const
98 { return fInterpolation
; }
100 void SetInheritTransformation(bool inherit
);
101 bool InheritTransformation() const
102 { return fInheritTransformation
; }
104 void MakeGradient(uint32
* colors
,
107 void FitToBounds(const BRect
& bounds
);
108 BRect
GradientArea() const;
109 virtual void TransformationChanged();
111 void PrintToStream() const;
117 gradients_type fType
;
118 interpolation_type fInterpolation
;
119 bool fInheritTransformation
;
126 #endif // GRADIENT_TRANSFORMABLE_H