#include <stdio.h>
#include <wlr/render/wlr_renderer.h>
+enum lab_justification {
+ LAB_JUSTIFY_LEFT,
+ LAB_JUSTIFY_CENTER,
+ LAB_JUSTIFY_RIGHT,
+};
+
struct theme {
int border_width;
int padding_height;
float window_active_label_text_color[4];
float window_inactive_label_text_color[4];
+ enum lab_justification window_label_text_justify;
/* buttons */
float window_active_button_iconify_unpressed_image_color[4];
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
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);
#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"
}
}
+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
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);
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")) {