add function to give the minimum size of an appearance to fully render it's data
[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     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     char *data;
104 } pixmap_mask;
105
106 typedef struct TextureMask {
107     color_rgb *color;
108     pixmap_mask *mask;
109 } TextureMask;
110
111 typedef struct TextureRGBA {
112     int width;
113     int height;
114     unsigned long *data;
115 /* cached scaled so we don't have to scale often */
116     int cwidth;
117     int cheight;
118     unsigned long *cache;
119 } TextureRGBA;
120
121 typedef union {
122     TextureRGBA rgba;
123     TextureText text;
124     TextureMask mask;
125 } TextureData;
126
127 typedef struct Texture {
128     Rect position;
129     TextureType type;
130     TextureData data;
131 } Texture;
132
133 typedef struct Appearance {
134     Surface surface;
135     Rect area;
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);
147
148 void render_startup(void);
149 void init_appearance(Appearance *l);
150 void x_paint(Window win, Appearance *l);
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 void truecolor_startup(void);
156 void pseudocolor_startup(void);
157 void pixel32_to_pixmap(pixel32 *in, Pixmap out, int x, int y, int w, int h);
158
159 void appearance_minsize(Appearance *l, Size *s);
160
161 #endif /*__render_h*/