mirror of
https://github.com/labwc/labwc.git
synced 2026-04-13 08:21:15 -04:00
theme: simplify loading of xbm buttons
No functional change.
This commit is contained in:
parent
7a19184e5e
commit
eca98a9b6e
5 changed files with 99 additions and 60 deletions
|
|
@ -2,7 +2,7 @@
|
|||
/*
|
||||
* Create wlr textures based on xbm data
|
||||
*
|
||||
* Copyright Johan Malm 2020
|
||||
* Copyright Johan Malm 2020-2023
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
@ -17,13 +17,6 @@
|
|||
#include "xbm/xbm.h"
|
||||
#include "buffer.h"
|
||||
|
||||
/* built-in 6x6 buttons */
|
||||
char menu_button_normal[] = { 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00 };
|
||||
char iconify_button_normal[] = { 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3f };
|
||||
char max_button_normal[] = { 0x3f, 0x3f, 0x21, 0x21, 0x21, 0x3f };
|
||||
char max_button_toggled[] = { 0x3e, 0x22, 0x2f, 0x29, 0x39, 0x0f };
|
||||
char close_button_normal[] = { 0x33, 0x3f, 0x1e, 0x1e, 0x3f, 0x33 };
|
||||
|
||||
static char *
|
||||
xbm_path(const char *button)
|
||||
{
|
||||
|
|
@ -33,8 +26,9 @@ xbm_path(const char *button)
|
|||
return buffer;
|
||||
}
|
||||
|
||||
static void
|
||||
load_button(const char *filename, struct lab_data_buffer **buffer, char *button)
|
||||
void
|
||||
xbm_load_button(const char *filename, struct lab_data_buffer **buffer,
|
||||
char *fallback_button, float *rgba)
|
||||
{
|
||||
struct pixmap pixmap = {0};
|
||||
if (*buffer) {
|
||||
|
|
@ -42,6 +36,8 @@ load_button(const char *filename, struct lab_data_buffer **buffer, char *button)
|
|||
*buffer = NULL;
|
||||
}
|
||||
|
||||
parse_set_color(rgba);
|
||||
|
||||
/* Read file into memory as it's easier to tokenzie that way */
|
||||
char *token_buffer = grab_file(xbm_path(filename));
|
||||
if (token_buffer) {
|
||||
|
|
@ -53,40 +49,10 @@ load_button(const char *filename, struct lab_data_buffer **buffer, char *button)
|
|||
}
|
||||
}
|
||||
if (!pixmap.data) {
|
||||
pixmap = parse_xbm_builtin(button, 6);
|
||||
pixmap = parse_xbm_builtin(fallback_button, 6);
|
||||
}
|
||||
|
||||
/* Create buffer with free_on_destroy being true */
|
||||
*buffer = buffer_create_wrap(pixmap.data, pixmap.width, pixmap.height,
|
||||
pixmap.width * 4, true);
|
||||
}
|
||||
|
||||
void
|
||||
xbm_load(struct theme *theme)
|
||||
{
|
||||
parse_set_color(theme->window_active_button_menu_unpressed_image_color);
|
||||
load_button("menu.xbm",
|
||||
&theme->xbm_menu_active_unpressed, menu_button_normal);
|
||||
parse_set_color(theme->window_active_button_iconify_unpressed_image_color);
|
||||
load_button("iconify.xbm",
|
||||
&theme->xbm_iconify_active_unpressed, iconify_button_normal);
|
||||
parse_set_color(theme->window_active_button_max_unpressed_image_color);
|
||||
load_button("max.xbm",
|
||||
&theme->xbm_maximize_active_unpressed, max_button_normal);
|
||||
parse_set_color(theme->window_active_button_close_unpressed_image_color);
|
||||
load_button("close.xbm",
|
||||
&theme->xbm_close_active_unpressed, close_button_normal);
|
||||
|
||||
parse_set_color(theme->window_inactive_button_menu_unpressed_image_color);
|
||||
load_button("menu.xbm",
|
||||
&theme->xbm_menu_inactive_unpressed, menu_button_normal);
|
||||
parse_set_color(theme->window_inactive_button_iconify_unpressed_image_color);
|
||||
load_button("iconify.xbm",
|
||||
&theme->xbm_iconify_inactive_unpressed, iconify_button_normal);
|
||||
parse_set_color(theme->window_inactive_button_max_unpressed_image_color);
|
||||
load_button("max.xbm",
|
||||
&theme->xbm_maximize_inactive_unpressed, max_button_normal);
|
||||
parse_set_color(theme->window_inactive_button_close_unpressed_image_color);
|
||||
load_button("close.xbm",
|
||||
&theme->xbm_close_inactive_unpressed, close_button_normal);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue