Render close, iconify and maximize buttons

This commit is contained in:
Johan Malm 2020-07-06 21:58:51 +01:00
parent e1b86555f4
commit f7fa28ab42
10 changed files with 140 additions and 53 deletions

View file

@ -36,10 +36,12 @@ static void process_bytes(struct pixmap *pixmap, struct token *tokens)
}
if (!t->type)
return;
int value = (int)strtol(t->name, NULL, 0);
if (t->type != TOKEN_INT)
return;
int bit = 1 << (col % 8);
if (value & bit)
pixmap->data[row * pixmap->width + col] = u32(defaultcolor);
if (t->value & bit)
pixmap->data[row * pixmap->width + col] =
u32(defaultcolor);
}
++t;
}
@ -65,6 +67,25 @@ out:
return pixmap;
}
/* Assuming a 6x6 button for the time being */
/* TODO: pass width, height, vargs bytes */
struct pixmap xbm_create_pixmap_builtin(const char *button)
{
struct pixmap pixmap = { 0 };
pixmap.width = 6;
pixmap.height = 6;
struct token t[7];
for (int i = 0; i < 6; i++) {
t[i].value = button[i];
t[i].type = TOKEN_INT;
}
t[6].type = 0;
process_bytes(&pixmap, t);
return pixmap;
}
char *xbm_read_file(const char *filename)
{
char *line = NULL;