aboutsummaryrefslogtreecommitdiffstats
path: root/swaynag/render.c
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-07-28 09:34:25 -0400
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-08-01 22:47:54 -0400
commit8463a2896a932cd99f3dc93608b03cb4aba93293 (patch)
treeb8c4ba994cf4d9ca7510d0f80a1864cce144092a /swaynag/render.c
parentAddress first round review for swaynag (diff)
downloadsway-8463a2896a932cd99f3dc93608b03cb4aba93293.tar.gz
sway-8463a2896a932cd99f3dc93608b03cb4aba93293.tar.zst
sway-8463a2896a932cd99f3dc93608b03cb4aba93293.zip
swaynag: implement config file support
Diffstat (limited to 'swaynag/render.c')
-rw-r--r--swaynag/render.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/swaynag/render.c b/swaynag/render.c
index 150ae3f2..134c247e 100644
--- a/swaynag/render.c
+++ b/swaynag/render.c
@@ -4,6 +4,7 @@
4#include "pango.h" 4#include "pango.h"
5#include "pool-buffer.h" 5#include "pool-buffer.h"
6#include "swaynag/nagbar.h" 6#include "swaynag/nagbar.h"
7#include "swaynag/types.h"
7#include "wlr-layer-shell-unstable-v1-client-protocol.h" 8#include "wlr-layer-shell-unstable-v1-client-protocol.h"
8 9
9static uint32_t render_message(cairo_t *cairo, struct sway_nagbar *nagbar) { 10static uint32_t render_message(cairo_t *cairo, struct sway_nagbar *nagbar) {
@@ -22,7 +23,7 @@ static uint32_t render_message(cairo_t *cairo, struct sway_nagbar *nagbar) {
22 return ideal_surface_height; 23 return ideal_surface_height;
23 } 24 }
24 25
25 cairo_set_source_u32(cairo, nagbar->colors.text); 26 cairo_set_source_u32(cairo, nagbar->type->text);
26 cairo_move_to(cairo, padding, (int)(ideal_height - text_height) / 2); 27 cairo_move_to(cairo, padding, (int)(ideal_height - text_height) / 2);
27 pango_printf(cairo, nagbar->font, nagbar->scale, true, "%s", 28 pango_printf(cairo, nagbar->font, nagbar->scale, true, "%s",
28 nagbar->message); 29 nagbar->message);
@@ -39,17 +40,17 @@ static void render_details_scroll_button(cairo_t *cairo,
39 int border = NAGBAR_BUTTON_BORDER_THICKNESS * nagbar->scale; 40 int border = NAGBAR_BUTTON_BORDER_THICKNESS * nagbar->scale;
40 int padding = NAGBAR_BUTTON_PADDING * nagbar->scale; 41 int padding = NAGBAR_BUTTON_PADDING * nagbar->scale;
41 42
42 cairo_set_source_u32(cairo, nagbar->colors.border); 43 cairo_set_source_u32(cairo, nagbar->type->border);
43 cairo_rectangle(cairo, button->x, button->y, 44 cairo_rectangle(cairo, button->x, button->y,
44 button->width, button->height); 45 button->width, button->height);
45 cairo_fill(cairo); 46 cairo_fill(cairo);
46 47
47 cairo_set_source_u32(cairo, nagbar->colors.button_background); 48 cairo_set_source_u32(cairo, nagbar->type->button_background);
48 cairo_rectangle(cairo, button->x + border, button->y + border, 49 cairo_rectangle(cairo, button->x + border, button->y + border,
49 button->width - (border * 2), button->height - (border * 2)); 50 button->width - (border * 2), button->height - (border * 2));
50 cairo_fill(cairo); 51 cairo_fill(cairo);
51 52
52 cairo_set_source_u32(cairo, nagbar->colors.text); 53 cairo_set_source_u32(cairo, nagbar->type->text);
53 cairo_move_to(cairo, button->x + border + padding, 54 cairo_move_to(cairo, button->x + border + padding,
54 button->y + border + (button->height - text_height) / 2); 55 button->y + border + (button->height - text_height) / 2);
55 pango_printf(cairo, nagbar->font, nagbar->scale, true, "%s", button->text); 56 pango_printf(cairo, nagbar->font, nagbar->scale, true, "%s", button->text);
@@ -154,14 +155,14 @@ static uint32_t render_detailed(cairo_t *cairo, struct sway_nagbar *nagbar,
154 &nagbar->details.button_down); 155 &nagbar->details.button_down);
155 } 156 }
156 157
157 cairo_set_source_u32(cairo, nagbar->colors.border); 158 cairo_set_source_u32(cairo, nagbar->type->border);
158 cairo_rectangle(cairo, nagbar->details.x, nagbar->details.y, 159 cairo_rectangle(cairo, nagbar->details.x, nagbar->details.y,
159 nagbar->details.width, nagbar->details.height); 160 nagbar->details.width, nagbar->details.height);
160 cairo_fill(cairo); 161 cairo_fill(cairo);
161 162
162 cairo_move_to(cairo, nagbar->details.x + padding, 163 cairo_move_to(cairo, nagbar->details.x + padding,
163 nagbar->details.y + padding); 164 nagbar->details.y + padding);
164 cairo_set_source_u32(cairo, nagbar->colors.text); 165 cairo_set_source_u32(cairo, nagbar->type->text);
165 pango_cairo_show_layout(cairo, layout); 166 pango_cairo_show_layout(cairo, layout);
166 g_object_unref(layout); 167 g_object_unref(layout);
167 168
@@ -192,17 +193,17 @@ static uint32_t render_button(cairo_t *cairo, struct sway_nagbar *nagbar,
192 button->width = text_width + padding * 2; 193 button->width = text_width + padding * 2;
193 button->height = text_height + padding * 2; 194 button->height = text_height + padding * 2;
194 195
195 cairo_set_source_u32(cairo, nagbar->colors.border); 196 cairo_set_source_u32(cairo, nagbar->type->border);
196 cairo_rectangle(cairo, button->x - border, button->y - border, 197 cairo_rectangle(cairo, button->x - border, button->y - border,
197 button->width + border * 2, button->height + border * 2); 198 button->width + border * 2, button->height + border * 2);
198 cairo_fill(cairo); 199 cairo_fill(cairo);
199 200
200 cairo_set_source_u32(cairo, nagbar->colors.button_background); 201 cairo_set_source_u32(cairo, nagbar->type->button_background);
201 cairo_rectangle(cairo, button->x, button->y, 202 cairo_rectangle(cairo, button->x, button->y,
202 button->width, button->height); 203 button->width, button->height);
203 cairo_fill(cairo); 204 cairo_fill(cairo);
204 205
205 cairo_set_source_u32(cairo, nagbar->colors.text); 206 cairo_set_source_u32(cairo, nagbar->type->text);
206 cairo_move_to(cairo, button->x + padding, button->y + padding); 207 cairo_move_to(cairo, button->x + padding, button->y + padding);
207 pango_printf(cairo, nagbar->font, nagbar->scale, true, "%s", button->text); 208 pango_printf(cairo, nagbar->font, nagbar->scale, true, "%s", button->text);
208 209
@@ -215,7 +216,7 @@ static uint32_t render_to_cairo(cairo_t *cairo, struct sway_nagbar *nagbar) {
215 uint32_t max_height = 0; 216 uint32_t max_height = 0;
216 217
217 cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE); 218 cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE);
218 cairo_set_source_u32(cairo, nagbar->colors.background); 219 cairo_set_source_u32(cairo, nagbar->type->background);
219 cairo_paint(cairo); 220 cairo_paint(cairo);
220 221
221 uint32_t h = render_message(cairo, nagbar); 222 uint32_t h = render_message(cairo, nagbar);
@@ -240,7 +241,7 @@ static uint32_t render_to_cairo(cairo_t *cairo, struct sway_nagbar *nagbar) {
240 if (max_height > nagbar->height) { 241 if (max_height > nagbar->height) {
241 max_height += border; 242 max_height += border;
242 } 243 }
243 cairo_set_source_u32(cairo, nagbar->colors.border_bottom); 244 cairo_set_source_u32(cairo, nagbar->type->border_bottom);
244 cairo_rectangle(cairo, 0, nagbar->height * nagbar->scale - border, 245 cairo_rectangle(cairo, 0, nagbar->height * nagbar->scale - border,
245 nagbar->width * nagbar->scale, border); 246 nagbar->width * nagbar->scale, border);
246 cairo_fill(cairo); 247 cairo_fill(cairo);