Make UEFI boot-platform build again
[haiku.git] / headers / os / interface / Gradient.h
blobf84a348ea1d0cdcdf563cb1a8377dfc8c63efc0a
1 /*
2 * Copyright 2006-2009, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _GRADIENT_H
6 #define _GRADIENT_H
9 #include <Archivable.h>
10 #include <GraphicsDefs.h>
11 #include <List.h>
14 class BMessage;
15 class BRect;
18 // WARNING! This is experimental API and may change! Be prepared to
19 // recompile your software in a next version of haiku. In particular,
20 // the offsets are currently specified on [0..255], but may be changed
21 // to the interval [0..1]. This class also does not have any FBC padding,
22 // So your software will definitely break when this class gets new
23 // virtuals. And the object size may change too...
26 class BGradient : public BArchivable {
27 public:
28 enum Type {
29 TYPE_LINEAR = 0,
30 TYPE_RADIAL,
31 TYPE_RADIAL_FOCUS,
32 TYPE_DIAMOND,
33 TYPE_CONIC,
34 TYPE_NONE
37 struct ColorStop {
38 ColorStop(const rgb_color c, float o);
39 ColorStop(uint8 r, uint8 g, uint8 b, uint8 a, float o);
40 ColorStop(const ColorStop& other);
41 ColorStop();
43 bool operator!=(const ColorStop& other) const;
45 rgb_color color;
46 float offset;
49 public:
50 BGradient();
51 BGradient(BMessage* archive);
52 virtual ~BGradient();
54 status_t Archive(BMessage* into,
55 bool deep = true) const;
57 BGradient& operator=(const BGradient& other);
59 bool operator==(const BGradient& other) const;
60 bool operator!=(const BGradient& other) const;
61 bool ColorStopsAreEqual(
62 const BGradient& other) const;
64 void SetColorStops(const BGradient& other);
66 int32 AddColor(const rgb_color& color,
67 float offset);
68 bool AddColorStop(const ColorStop& colorStop,
69 int32 index);
71 bool RemoveColor(int32 index);
73 bool SetColorStop(int32 index,
74 const ColorStop& colorStop);
75 bool SetColor(int32 index, const rgb_color& color);
76 bool SetOffset(int32 index, float offset);
78 int32 CountColorStops() const;
79 ColorStop* ColorStopAt(int32 index) const;
80 ColorStop* ColorStopAtFast(int32 index) const;
81 ColorStop* ColorStops() const;
82 void SortColorStopsByOffset();
84 Type GetType() const
85 { return fType; }
87 void MakeEmpty();
89 private:
90 friend class BGradientLinear;
91 friend class BGradientRadial;
92 friend class BGradientRadialFocus;
93 friend class BGradientDiamond;
94 friend class BGradientConic;
96 union {
97 struct {
98 float x1, y1, x2, y2;
99 } linear;
100 struct {
101 float cx, cy, radius;
102 } radial;
103 struct {
104 float cx, cy, fx, fy, radius;
105 } radial_focus;
106 struct {
107 float cx, cy;
108 } diamond;
109 struct {
110 float cx, cy, angle;
111 } conic;
112 } fData;
114 BList fColorStops;
115 Type fType;
118 #endif // _GRADIENT_H