mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	theme: add osd colors
This commit is contained in:
		
							parent
							
								
									2d4ca16db8
								
							
						
					
					
						commit
						960a1bb2ed
					
				
					 4 changed files with 32 additions and 5 deletions
				
			
		| 
						 | 
					@ -70,6 +70,12 @@ elements are not listed here, but are supported.
 | 
				
			||||||
*menu.items.active.text.color*
 | 
					*menu.items.active.text.color*
 | 
				
			||||||
	Text color of active menu item
 | 
						Text color of active menu item
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					*osd.bg.color*
 | 
				
			||||||
 | 
						Background color of on-screen-display
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					*osd.label.text.color*
 | 
				
			||||||
 | 
						Text color of on-screen-display
 | 
				
			||||||
 | 
					
 | 
				
			||||||
*border.color*
 | 
					*border.color*
 | 
				
			||||||
	Set all border colors. This is obsolete, but supported for backward
 | 
						Set all border colors. This is obsolete, but supported for backward
 | 
				
			||||||
	compatibility as some themes still contain it.
 | 
						compatibility as some themes still contain it.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -34,6 +34,9 @@ struct theme {
 | 
				
			||||||
	float menu_items_active_bg_color[4];
 | 
						float menu_items_active_bg_color[4];
 | 
				
			||||||
	float menu_items_active_text_color[4];
 | 
						float menu_items_active_text_color[4];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						float osd_bg_color[4];
 | 
				
			||||||
 | 
						float osd_label_text_color[4];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct wlr_texture *xbm_close_active_unpressed;
 | 
						struct wlr_texture *xbm_close_active_unpressed;
 | 
				
			||||||
	struct wlr_texture *xbm_maximize_active_unpressed;
 | 
						struct wlr_texture *xbm_maximize_active_unpressed;
 | 
				
			||||||
	struct wlr_texture *xbm_iconify_active_unpressed;
 | 
						struct wlr_texture *xbm_iconify_active_unpressed;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										18
									
								
								src/osd.c
									
										
									
									
									
								
							
							
						
						
									
										18
									
								
								src/osd.c
									
										
									
									
									
								
							| 
						 | 
					@ -8,6 +8,7 @@
 | 
				
			||||||
#include "common/font.h"
 | 
					#include "common/font.h"
 | 
				
			||||||
#include "config/rcxml.h"
 | 
					#include "config/rcxml.h"
 | 
				
			||||||
#include "labwc.h"
 | 
					#include "labwc.h"
 | 
				
			||||||
 | 
					#include "theme.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define OSD_ITEM_HEIGHT (20)
 | 
					#define OSD_ITEM_HEIGHT (20)
 | 
				
			||||||
#define OSD_ITEM_WIDTH (600)
 | 
					#define OSD_ITEM_WIDTH (600)
 | 
				
			||||||
| 
						 | 
					@ -73,6 +74,8 @@ void
 | 
				
			||||||
osd_update(struct server *server)
 | 
					osd_update(struct server *server)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct wlr_renderer *renderer = server->renderer;
 | 
						struct wlr_renderer *renderer = server->renderer;
 | 
				
			||||||
 | 
						struct theme *theme = server->theme;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int w = OSD_ITEM_WIDTH + 2 * OSD_BORDER_WIDTH;
 | 
						int w = OSD_ITEM_WIDTH + 2 * OSD_BORDER_WIDTH;
 | 
				
			||||||
	int h = get_osd_height(&server->views);
 | 
						int h = get_osd_height(&server->views);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -81,11 +84,16 @@ osd_update(struct server *server)
 | 
				
			||||||
	cairo_t *cairo = cairo_create(surf);
 | 
						cairo_t *cairo = cairo_create(surf);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* background */
 | 
						/* background */
 | 
				
			||||||
	set_source(cairo, (float[4]){1.0f, 1.0f, 1.0f, 1.0f});
 | 
						set_source(cairo, theme->osd_bg_color);
 | 
				
			||||||
	cairo_rectangle(cairo, 0, 0, w, h);
 | 
						cairo_rectangle(cairo, 0, 0, w, h);
 | 
				
			||||||
	cairo_fill(cairo);
 | 
						cairo_fill(cairo);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* highlight current application */
 | 
						/* border */
 | 
				
			||||||
 | 
						set_source(cairo, theme->osd_label_text_color);
 | 
				
			||||||
 | 
						cairo_rectangle(cairo, 0, 0, w, h);
 | 
				
			||||||
 | 
						cairo_stroke(cairo);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* highlight current window */
 | 
				
			||||||
	int y = OSD_BORDER_WIDTH;
 | 
						int y = OSD_BORDER_WIDTH;
 | 
				
			||||||
	struct view *view;
 | 
						struct view *view;
 | 
				
			||||||
	wl_list_for_each(view, &server->views, link) {
 | 
						wl_list_for_each(view, &server->views, link) {
 | 
				
			||||||
| 
						 | 
					@ -93,17 +101,17 @@ osd_update(struct server *server)
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (view == server->cycle_view) {
 | 
							if (view == server->cycle_view) {
 | 
				
			||||||
			set_source(cairo, (float[4]){0.3f, 0.3f, 0.3f, 0.5f});
 | 
								set_source(cairo, theme->osd_label_text_color);
 | 
				
			||||||
			cairo_rectangle(cairo, OSD_BORDER_WIDTH, y,
 | 
								cairo_rectangle(cairo, OSD_BORDER_WIDTH, y,
 | 
				
			||||||
				OSD_ITEM_WIDTH, OSD_ITEM_HEIGHT);
 | 
									OSD_ITEM_WIDTH, OSD_ITEM_HEIGHT);
 | 
				
			||||||
			cairo_fill(cairo);
 | 
								cairo_stroke(cairo);
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		y += OSD_ITEM_HEIGHT;
 | 
							y += OSD_ITEM_HEIGHT;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* text */
 | 
						/* text */
 | 
				
			||||||
	set_source(cairo, (float[4]){0.0f, 0.0f, 0.0f, 1.0f});
 | 
						set_source(cairo, theme->osd_label_text_color);
 | 
				
			||||||
	PangoLayout *layout = pango_cairo_create_layout(cairo);
 | 
						PangoLayout *layout = pango_cairo_create_layout(cairo);
 | 
				
			||||||
	pango_layout_set_width(layout, w * PANGO_SCALE);
 | 
						pango_layout_set_width(layout, w * PANGO_SCALE);
 | 
				
			||||||
	pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
 | 
						pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										10
									
								
								src/theme.c
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								src/theme.c
									
										
									
									
									
								
							| 
						 | 
					@ -102,6 +102,9 @@ theme_builtin(struct theme *theme)
 | 
				
			||||||
	parse_hexstr("#000000", theme->menu_items_text_color);
 | 
						parse_hexstr("#000000", theme->menu_items_text_color);
 | 
				
			||||||
	parse_hexstr("#dddad6", theme->menu_items_active_bg_color);
 | 
						parse_hexstr("#dddad6", theme->menu_items_active_bg_color);
 | 
				
			||||||
	parse_hexstr("#000000", theme->menu_items_active_text_color);
 | 
						parse_hexstr("#000000", theme->menu_items_active_text_color);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						parse_hexstr("#dddad6", theme->osd_bg_color);
 | 
				
			||||||
 | 
						parse_hexstr("#000000", theme->osd_label_text_color);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static bool
 | 
					static bool
 | 
				
			||||||
| 
						 | 
					@ -207,6 +210,13 @@ entry(struct theme *theme, const char *key, const char *value)
 | 
				
			||||||
	if (match(key, "menu.items.active.text.color")) {
 | 
						if (match(key, "menu.items.active.text.color")) {
 | 
				
			||||||
		parse_hexstr(value, theme->menu_items_active_text_color);
 | 
							parse_hexstr(value, theme->menu_items_active_text_color);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (match(key, "osd.bg.color")) {
 | 
				
			||||||
 | 
							parse_hexstr(value, theme->osd_bg_color);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if (match(key, "osd.label.text.color")) {
 | 
				
			||||||
 | 
							parse_hexstr(value, theme->osd_label_text_color);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue