mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
theme: Implement window.label.text.justify
Crosses off 6.12.1 Signed-off-by: Joshua Ashton <joshua@froggi.es>
This commit is contained in:
parent
140c245880
commit
8b8e37c268
3 changed files with 51 additions and 2 deletions
29
src/ssd.c
29
src/ssd.c
|
|
@ -148,8 +148,24 @@ center_vertically(struct wlr_box *box, struct wlr_texture *texture)
|
|||
return;
|
||||
}
|
||||
box->y += (box->height - texture->height) / 2;
|
||||
box->width = texture->width;
|
||||
box->height = texture->height;
|
||||
}
|
||||
|
||||
static void
|
||||
center_horizontally(struct view *view, struct wlr_box *box, struct wlr_texture *texture)
|
||||
{
|
||||
if (!texture) {
|
||||
return;
|
||||
}
|
||||
box->x = view->x + (view->w - texture->width) / 2;
|
||||
}
|
||||
|
||||
static void
|
||||
justify_right(struct view *view, struct wlr_box *box, struct wlr_texture *texture)
|
||||
{
|
||||
if (!texture) {
|
||||
return;
|
||||
}
|
||||
box->x = view->x + (box->width - texture->width);
|
||||
}
|
||||
|
||||
struct wlr_box
|
||||
|
|
@ -175,6 +191,15 @@ ssd_visible_box(struct view *view, enum ssd_part_type type)
|
|||
case LAB_SSD_PART_TITLE:
|
||||
box = ssd_box(view, type);
|
||||
center_vertically(&box, view->title.active);
|
||||
if (theme->window_label_text_justify == LAB_JUSTIFY_CENTER) {
|
||||
center_horizontally(view, &box, view->title.active);
|
||||
} else if (theme->window_label_text_justify == LAB_JUSTIFY_RIGHT) {
|
||||
justify_right(view, &box, view->title.active);
|
||||
}
|
||||
if (view->title.active) {
|
||||
box.width = view->title.active->width;
|
||||
box.height = view->title.active->height;
|
||||
}
|
||||
break;
|
||||
case LAB_SSD_PART_CORNER_TOP_LEFT:
|
||||
box = ssd_box(view, type);
|
||||
|
|
|
|||
17
src/theme.c
17
src/theme.c
|
|
@ -17,6 +17,7 @@
|
|||
#include <string.h>
|
||||
#include <wlr/util/box.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include <strings.h>
|
||||
#include "common/dir.h"
|
||||
#include "common/font.h"
|
||||
#include "common/string-helpers.h"
|
||||
|
|
@ -61,6 +62,18 @@ parse_hexstr(const char *hex, float *rgba)
|
|||
}
|
||||
}
|
||||
|
||||
static enum lab_justification
|
||||
parse_justification(const char *str)
|
||||
{
|
||||
if (!strcasecmp(str, "Center")) {
|
||||
return LAB_JUSTIFY_CENTER;
|
||||
} else if (!strcasecmp(str, "Right")) {
|
||||
return LAB_JUSTIFY_RIGHT;
|
||||
} else {
|
||||
return LAB_JUSTIFY_LEFT;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* We generally use Openbox defaults, but if no theme file can be found it's
|
||||
* better to populate the theme variables with some sane values as no-one
|
||||
|
|
@ -87,6 +100,7 @@ theme_builtin(struct theme *theme)
|
|||
|
||||
parse_hexstr("#000000", theme->window_active_label_text_color);
|
||||
parse_hexstr("#000000", theme->window_inactive_label_text_color);
|
||||
theme->window_label_text_justify = parse_justification("Left");
|
||||
|
||||
parse_hexstr("#000000",
|
||||
theme->window_active_button_iconify_unpressed_image_color);
|
||||
|
|
@ -164,6 +178,9 @@ entry(struct theme *theme, const char *key, const char *value)
|
|||
if (match(key, "window.inactive.label.text.color")) {
|
||||
parse_hexstr(value, theme->window_inactive_label_text_color);
|
||||
}
|
||||
if (match(key, "window.label.text.justify")) {
|
||||
theme->window_label_text_justify = parse_justification(value);
|
||||
}
|
||||
|
||||
/* universal button */
|
||||
if (match(key, "window.active.button.unpressed.image.color")) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue