4 #include "framerender.h"
5 #include "render/theme.h"
7 static void framerender_label(Frame
*self
, Appearance
*a
);
8 static void framerender_icon(Frame
*self
, Appearance
*a
);
9 static void framerender_max(Frame
*self
, Appearance
*a
);
10 static void framerender_iconify(Frame
*self
, Appearance
*a
);
11 static void framerender_desk(Frame
*self
, Appearance
*a
);
12 static void framerender_shade(Frame
*self
, Appearance
*a
);
13 static void framerender_close(Frame
*self
, Appearance
*a
);
15 void framerender_frame(Frame
*self
)
17 if (client_focused(self
->client
)) {
18 XSetWindowBorder(ob_display
, self
->plate
,
19 theme_cb_focused_color
->pixel
);
21 XSetWindowBorder(ob_display
, self
->plate
,
22 theme_cb_unfocused_color
->pixel
);
25 if (self
->client
->decorations
& Decor_Titlebar
) {
26 Appearance
*t
, *l
, *m
, *n
, *i
, *d
, *s
, *c
;
28 t
= (client_focused(self
->client
) ?
29 self
->a_focused_title
: self
->a_unfocused_title
);
30 l
= (client_focused(self
->client
) ?
31 self
->a_focused_label
: self
->a_unfocused_label
);
32 m
= (client_focused(self
->client
) ?
33 (self
->client
->max_vert
|| self
->client
->max_horz
?
34 theme_a_focused_pressed_set_max
:
36 theme_a_focused_pressed_max
: theme_a_focused_unpressed_max
)) :
37 (self
->client
->max_vert
|| self
->client
->max_horz
?
38 theme_a_unfocused_pressed_set_max
:
40 theme_a_unfocused_pressed_max
:
41 theme_a_unfocused_unpressed_max
)));
43 i
= (client_focused(self
->client
) ?
44 (self
->iconify_press
?
45 theme_a_focused_pressed_iconify
:
46 theme_a_focused_unpressed_iconify
) :
47 (self
->iconify_press
?
48 theme_a_unfocused_pressed_iconify
:
49 theme_a_unfocused_unpressed_iconify
));
50 d
= (client_focused(self
->client
) ?
51 (self
->client
->desktop
== DESKTOP_ALL
?
52 theme_a_focused_pressed_set_desk
:
54 theme_a_focused_pressed_desk
:
55 theme_a_focused_unpressed_desk
)) :
56 (self
->client
->desktop
== DESKTOP_ALL
?
57 theme_a_unfocused_pressed_set_desk
:
59 theme_a_unfocused_pressed_desk
:
60 theme_a_unfocused_unpressed_desk
)));
61 s
= (client_focused(self
->client
) ?
62 (self
->client
->shaded
?
63 theme_a_focused_pressed_set_shade
:
65 theme_a_focused_pressed_shade
:
66 theme_a_focused_unpressed_shade
)) :
67 (self
->client
->shaded
?
68 theme_a_unfocused_pressed_set_shade
:
70 theme_a_unfocused_pressed_shade
:
71 theme_a_unfocused_unpressed_shade
)));
72 c
= (client_focused(self
->client
) ?
74 theme_a_focused_pressed_close
:
75 theme_a_focused_unpressed_close
) :
77 theme_a_unfocused_pressed_close
:
78 theme_a_unfocused_unpressed_close
));
80 paint(self
->title
, t
);
82 /* set parents for any parent relative guys */
83 l
->surface
.data
.planar
.parent
= t
;
84 l
->surface
.data
.planar
.parentx
= self
->label_x
;
85 l
->surface
.data
.planar
.parenty
= theme_bevel
;
87 m
->surface
.data
.planar
.parent
= t
;
88 m
->surface
.data
.planar
.parentx
= self
->max_x
;
89 m
->surface
.data
.planar
.parenty
= theme_bevel
+ 1;
91 n
->surface
.data
.planar
.parent
= t
;
92 n
->surface
.data
.planar
.parentx
= self
->icon_x
;
93 n
->surface
.data
.planar
.parenty
= theme_bevel
+ 1;
95 i
->surface
.data
.planar
.parent
= t
;
96 i
->surface
.data
.planar
.parentx
= self
->iconify_x
;
97 i
->surface
.data
.planar
.parenty
= theme_bevel
+ 1;
99 d
->surface
.data
.planar
.parent
= t
;
100 d
->surface
.data
.planar
.parentx
= self
->desk_x
;
101 d
->surface
.data
.planar
.parenty
= theme_bevel
+ 1;
103 s
->surface
.data
.planar
.parent
= t
;
104 s
->surface
.data
.planar
.parentx
= self
->shade_x
;
105 s
->surface
.data
.planar
.parenty
= theme_bevel
+ 1;
107 c
->surface
.data
.planar
.parent
= t
;
108 c
->surface
.data
.planar
.parentx
= self
->close_x
;
109 c
->surface
.data
.planar
.parenty
= theme_bevel
+ 1;
111 framerender_label(self
, l
);
112 framerender_max(self
, m
);
113 framerender_icon(self
, n
);
114 framerender_iconify(self
, i
);
115 framerender_desk(self
, d
);
116 framerender_shade(self
, s
);
117 framerender_close(self
, c
);
120 if (self
->client
->decorations
& Decor_Handle
) {
123 h
= (client_focused(self
->client
) ?
124 self
->a_focused_handle
: self
->a_unfocused_handle
);
125 g
= (client_focused(self
->client
) ?
126 theme_a_focused_grip
: theme_a_unfocused_grip
);
128 if (g
->surface
.data
.planar
.grad
== Background_ParentRelative
) {
129 g
->surface
.data
.planar
.parent
= h
;
130 paint(self
->handle
, h
);
132 paint(self
->handle
, h
);
134 g
->surface
.data
.planar
.parentx
= 0;
135 g
->surface
.data
.planar
.parenty
= 0;
137 paint(self
->lgrip
, g
);
139 g
->surface
.data
.planar
.parentx
= self
->width
- theme_grip_width
;
140 g
->surface
.data
.planar
.parenty
= 0;
142 paint(self
->rgrip
, g
);
146 static void framerender_label(Frame
*self
, Appearance
*a
)
148 if (self
->label_x
< 0) return;
151 /* set the texture's text! */
152 a
->texture
[0].data
.text
.string
= self
->client
->title
;
153 RECT_SET(a
->texture
[0].position
, 0, 0,
154 self
->label_width
, theme_label_height
);
156 paint(self
->label
, a
);
159 static void framerender_icon(Frame
*self
, Appearance
*a
)
161 if (self
->icon_x
< 0) return;
163 if (self
->client
->nicons
) {
164 Icon
*icon
= client_icon(self
->client
,
165 theme_button_size
, theme_button_size
);
166 a
->texture
[0].type
= RGBA
;
167 a
->texture
[0].data
.rgba
.width
= icon
->width
;
168 a
->texture
[0].data
.rgba
.height
= icon
->height
;
169 a
->texture
[0].data
.rgba
.data
= icon
->data
;
170 RECT_SET(self
->a_icon
->texture
[0].position
, 0, 0,
171 theme_button_size
,theme_button_size
);
173 a
->texture
[0].type
= NoTexture
;
175 paint(self
->icon
, a
);
178 static void framerender_max(Frame
*self
, Appearance
*a
)
180 if (self
->max_x
< 0) return;
182 RECT_SET(a
->texture
[0].position
, 0, 0,
183 theme_button_size
, theme_button_size
);
187 static void framerender_iconify(Frame
*self
, Appearance
*a
)
189 if (self
->iconify_x
< 0) return;
191 RECT_SET(a
->texture
[0].position
, 0, 0,
192 theme_button_size
, theme_button_size
);
193 paint(self
->iconify
, a
);
196 static void framerender_desk(Frame
*self
, Appearance
*a
)
198 if (self
->desk_x
< 0) return;
200 RECT_SET(a
->texture
[0].position
, 0, 0,
201 theme_button_size
, theme_button_size
);
202 paint(self
->desk
, a
);
205 static void framerender_shade(Frame
*self
, Appearance
*a
)
207 if (self
->shade_x
< 0) return;
209 RECT_SET(a
->texture
[0].position
, 0, 0,
210 theme_button_size
, theme_button_size
);
211 paint(self
->shade
, a
);
214 static void framerender_close(Frame
*self
, Appearance
*a
)
216 if (self
->close_x
< 0) return;
218 RECT_SET(a
->texture
[0].position
, 0, 0,
219 theme_button_size
, theme_button_size
);
220 paint(self
->close
, a
);
223 void framerender_popup_label(Window win
, Size
*sz
, char *text
)
227 a
= theme_app_hilite_label
;
228 a
->texture
[0].data
.text
.string
= text
;
229 RECT_SET(a
->area
, 0, 0, sz
->width
, sz
->height
);
230 a
->texture
[0].position
= a
->area
;
232 XSetWindowBorderWidth(ob_display
, win
, theme_bwidth
);
233 XSetWindowBorder(ob_display
, win
, theme_b_color
->pixel
);
238 void framerender_size_popup_label(char *text
, Size
*sz
)
242 a
= theme_app_hilite_label
;
243 a
->texture
[0].data
.text
.string
= text
;
245 appearance_minsize(a
, &sz
->width
, &sz
->height
);
246 sz
->width
+= theme_bevel
* 2;
247 sz
->height
+= theme_bevel
* 2;