add a struct for pixmap masks
[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 "mask.h"
10
11 #ifdef HAVE_STDINT_H
12 #  include <stdint.h>
13 #else
14 #  ifdef HAVE_SYS_TYPES_H
15 #    include <sys/types.h>
16 #  endif
17 #endif
18
19 #ifdef HAVE_STDINT_H
20 typedef uint32_t pixel32;
21 typedef uint16_t pixel16;
22 #else
23 typedef u_int32_t pixel32;
24 typedef u_int16_t pixel16;
25 #endif /* HAVE_STDINT_H */
26
27 #if (G_ENDIAN == G_BIG_ENDIAN)
28 #define default_red_shift 0
29 #define default_green_shift 8
30 #define default_blue_shift 16
31 #define endian MSBFirst
32 #else
33 #define default_red_shift 16
34 #define default_green_shift 8
35 #define default_blue_shift 0
36 #define endian LSBFirst
37 #endif /* G_ENDIAN == G_BIG_ENDIAN */
38
39 typedef enum {
40     Surface_Planar,
41     Surface_Nonplanar
42 } SurfaceType;
43
44 typedef enum {
45     Flat,
46     Raised,
47     Sunken
48 } ReliefType;
49
50 typedef enum {
51     Bevel1,
52     Bevel2
53 } BevelType;
54
55 typedef enum {
56     Background_ParentRelative,
57     Background_Solid,
58     Background_Horizontal,
59     Background_Vertical,
60     Background_Diagonal,
61     Background_CrossDiagonal,
62     Background_PipeCross,
63     Background_Rectangle,
64     Background_Pyramid,
65     Background_Elliptic
66 } SurfaceColorType;
67
68 typedef enum {
69     Bitmask,
70     Text,
71     RGBA
72 } TextureType;
73
74 typedef struct PlanarSurface {
75     SurfaceColorType grad;
76     ReliefType relief;
77     BevelType bevel;
78     color_rgb *primary;
79     color_rgb *secondary;
80     color_rgb *border_color;
81     gboolean interlaced;
82     gboolean border;
83     pixel32 *pixel_data;
84 } PlanarSurface;
85
86 typedef struct NonplanarSurface {
87     int poo;
88 } NonplanarSurface;
89
90 typedef union {
91     PlanarSurface planar;
92     NonplanarSurface nonplanar;
93 } SurfaceData;
94
95 typedef struct Surface {
96     SurfaceType type;
97     SurfaceColorType colortype;
98     SurfaceData data;
99 } Surface;
100
101 typedef struct {
102     XftFont *xftfont;
103 } ObFont;
104
105 typedef struct TextureText {
106     ObFont *font;
107     int shadow;  
108     unsigned char tint;
109     unsigned char offset;
110     color_rgb *color;
111     char *string;
112 } TextureText;   
113
114 typedef struct TextureMask {
115     color_rgb *color;
116     pixmap_mask *mask;
117 } TextureMask;
118
119 typedef struct TextureRGBA {
120     int poo;
121 } TextureRGBA;
122
123 typedef union {
124     TextureRGBA rgba;
125     TextureText text;
126     TextureMask mask;
127 } TextureData;
128
129 typedef struct Texture {
130     TextureType type;
131     TextureData data;
132 } Texture;
133
134 typedef struct Appearance {
135     Surface surface;
136     int textures;
137     Texture *texture;
138     Pixmap pixmap;
139     XftDraw *xftdraw;
140 } Appearance;
141
142 extern Visual *render_visual;
143 extern int render_depth;
144 extern Colormap render_colormap;
145
146 void (*paint)(Window win, Appearance *l, int w, int h);
147
148 void render_startup(void);
149 void init_appearance(Appearance *l);
150 void x_paint(Window win, Appearance *l, int w, int h);
151 void render_shutdown(void);
152 Appearance *appearance_new(SurfaceType type, int numtex);
153 Appearance *appearance_copy(Appearance *a);
154 void appearance_free(Appearance *a);
155 #endif /*__render_h*/