add rgba icon support
[mikachu/openbox.git] / render / render.h
1 #ifndef __render_h
2 #define __render_h
3
4 #include <X11/Xlib.h>
5 #define _XFT_NO_COMPAT_ /* no Xft 1 API */
6 #include <X11/Xft/Xft.h>
7 #include <glib.h>
8 #include "color.h"
9 #include "../kernel/geom.h"
10
11 typedef enum {
12     Surface_Planar,
13     Surface_Nonplanar
14 } SurfaceType;
15
16 typedef enum {
17     Flat,
18     Raised,
19     Sunken
20 } ReliefType;
21
22 typedef enum {
23     Bevel1,
24     Bevel2
25 } BevelType;
26
27 typedef enum {
28     Background_ParentRelative,
29     Background_Solid,
30     Background_Horizontal,
31     Background_Vertical,
32     Background_Diagonal,
33     Background_CrossDiagonal,
34     Background_PipeCross,
35     Background_Rectangle,
36     Background_Pyramid,
37     Background_Elliptic
38 } SurfaceColorType;
39
40 typedef enum {
41     Bitmask,
42     Text,
43     RGBA,
44     NoTexture
45 } TextureType;
46
47 typedef struct PlanarSurface {
48     SurfaceColorType grad;
49     ReliefType relief;
50     BevelType bevel;
51     color_rgb *primary;
52     color_rgb *secondary;
53     color_rgb *border_color;
54     gboolean interlaced;
55     gboolean border;
56     pixel32 *pixel_data;
57 } PlanarSurface;
58
59 typedef struct NonplanarSurface {
60     int poo;
61 } NonplanarSurface;
62
63 typedef union {
64     PlanarSurface planar;
65     NonplanarSurface nonplanar;
66 } SurfaceData;
67
68 typedef struct Surface {
69     SurfaceType type;
70     SurfaceColorType colortype;
71     SurfaceData data;
72 } Surface;
73
74 typedef struct {
75     XftFont *xftfont;
76     int height;
77 } ObFont;
78
79 typedef enum {
80     Justify_Center,
81     Justify_Left,
82     Justify_Right
83 } Justify;
84
85 typedef struct TextureText {
86     ObFont *font;
87     Justify justify;
88     int shadow;
89     unsigned char tint;
90     unsigned char offset;
91     color_rgb *color;
92     char *string;
93 } TextureText;   
94
95 typedef struct {
96     Pixmap mask;
97     guint w, h;
98 } pixmap_mask;
99
100 typedef struct TextureMask {
101     color_rgb *color;
102     pixmap_mask *mask;
103 } TextureMask;
104
105 typedef struct TextureRGBA {
106     int width;
107     int height;
108     unsigned long *data;
109 /* cached scaled so we don't have to scale often */
110     int cwidth;
111     int cheight;
112     unsigned long *cache;
113 } TextureRGBA;
114
115 typedef union {
116     TextureRGBA rgba;
117     TextureText text;
118     TextureMask mask;
119 } TextureData;
120
121 typedef struct Texture {
122     Rect position;
123     TextureType type;
124     TextureData data;
125 } Texture;
126
127 typedef struct Appearance {
128     Surface surface;
129     int textures;
130     Texture *texture;
131     Pixmap pixmap;
132     XftDraw *xftdraw;
133 } Appearance;
134
135 extern Visual *render_visual;
136 extern int render_depth;
137 extern Colormap render_colormap;
138
139 void (*paint)(Window win, Appearance *l, int x, int y, int w, int h);
140
141 void render_startup(void);
142 void init_appearance(Appearance *l);
143 void x_paint(Window win, Appearance *l, int x, int y, int w, int h);
144 void render_shutdown(void);
145 Appearance *appearance_new(SurfaceType type, int numtex);
146 Appearance *appearance_copy(Appearance *a);
147 void appearance_free(Appearance *a);
148 void truecolor_startup(void);
149 #endif /*__render_h*/