moved paint's arguments into the appearance struct
[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 struct Appearance;
48
49 typedef struct PlanarSurface {
50     SurfaceColorType grad;
51     ReliefType relief;
52     BevelType bevel;
53     color_rgb *primary;
54     color_rgb *secondary;
55     color_rgb *border_color;
56     gboolean interlaced;
57     gboolean border;
58     struct Appearance *parent;
59     int parentx;
60     int parenty;
61     pixel32 *pixel_data;
62 } PlanarSurface;
63
64 typedef struct NonplanarSurface {
65     int poo;
66 } NonplanarSurface;
67
68 typedef union {
69     PlanarSurface planar;
70     NonplanarSurface nonplanar;
71 } SurfaceData;
72
73 typedef struct Surface {
74     SurfaceType type;
75     SurfaceColorType colortype;
76     SurfaceData data;
77 } Surface;
78
79 typedef struct {
80     XftFont *xftfont;
81     int height;
82 } ObFont;
83
84 typedef enum {
85     Justify_Center,
86     Justify_Left,
87     Justify_Right
88 } Justify;
89
90 typedef struct TextureText {
91     ObFont *font;
92     Justify justify;
93     int shadow;
94     unsigned char tint;
95     unsigned char offset;
96     color_rgb *color;
97     char *string;
98 } TextureText;   
99
100 typedef struct {
101     Pixmap mask;
102     guint w, h;
103 } pixmap_mask;
104
105 typedef struct TextureMask {
106     color_rgb *color;
107     pixmap_mask *mask;
108 } TextureMask;
109
110 typedef struct TextureRGBA {
111     int width;
112     int height;
113     unsigned long *data;
114 /* cached scaled so we don't have to scale often */
115     int cwidth;
116     int cheight;
117     unsigned long *cache;
118 } TextureRGBA;
119
120 typedef union {
121     TextureRGBA rgba;
122     TextureText text;
123     TextureMask mask;
124 } TextureData;
125
126 typedef struct Texture {
127     Rect position;
128     TextureType type;
129     TextureData data;
130 } Texture;
131
132 typedef struct Appearance {
133     Surface surface;
134     Rect area;
135     int textures;
136     Texture *texture;
137     Pixmap pixmap;
138     XftDraw *xftdraw;
139 } Appearance;
140
141 extern Visual *render_visual;
142 extern int render_depth;
143 extern Colormap render_colormap;
144
145 void (*paint)(Window win, Appearance *l);
146
147 void render_startup(void);
148 void init_appearance(Appearance *l);
149 void x_paint(Window win, Appearance *l);
150 void render_shutdown(void);
151 Appearance *appearance_new(SurfaceType type, int numtex);
152 Appearance *appearance_copy(Appearance *a);
153 void appearance_free(Appearance *a);
154 void truecolor_startup(void);
155 void pixel32_to_pixmap(pixel32 *in, Pixmap out, int x, int y, int w, int h);
156
157 #endif /*__render_h*/