summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@blame.services>2022-12-23 13:38:09 +0100
committerDave Davenport <qball@blame.services>2022-12-23 13:38:09 +0100
commit0ff6ff21c343ceaff4ee74e02e4cd225462537dc (patch)
tree9f9b18bbe2830f22751193d4857113c029e8339e
parenta1943bab1f9a4f69d9aed72a11c67ddaa3b65891 (diff)
[Textbox] Add text-outline to style
-rw-r--r--.gitignore4
-rw-r--r--doc/rofi-theme.56
-rw-r--r--doc/rofi-theme.5.markdown3
-rw-r--r--source/widgets/textbox.c19
4 files changed, 27 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
index ac7472d9..aded913b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,6 @@
-/build/
+/build*/
+/.cache/
+/.vscode/
# autotools generated files
/missing
diff --git a/doc/rofi-theme.5 b/doc/rofi-theme.5
index b7b36f3c..293304c5 100644
--- a/doc/rofi-theme.5
+++ b/doc/rofi-theme.5
@@ -1536,6 +1536,12 @@ The text appears to the right of the tab stop position (other alignments are not
\fBcursor-width\fP: The width of the cursor.
.IP \(bu 2
\fBcursor-color\fP: The color used to draw the cursor.
+.IP \(bu 2
+\fBtext-outline\fP: Enable a border (outline) around the text. (Boolean)
+.IP \(bu 2
+\fBtext-outline-width\fP: The width of the border around the text. (Double)
+.IP \(bu 2
+\fBtext-outline-color\fP: The color to use for the text outline. (Color)
.RE
diff --git a/doc/rofi-theme.5.markdown b/doc/rofi-theme.5.markdown
index 9a06c1a5..354d77cf 100644
--- a/doc/rofi-theme.5.markdown
+++ b/doc/rofi-theme.5.markdown
@@ -951,6 +951,9 @@ The following properties are currently supported:
The text appears to the right of the tab stop position (other alignments are not supported yet).
* **cursor-width**: The width of the cursor.
* **cursor-color**: The color used to draw the cursor.
+* **text-outline**: Enable a border (outline) around the text. (Boolean)
+* **text-outline-width**: The width of the border around the text. (Double)
+* **text-outline-color**: The color to use for the text outline. (Color)
### listview:
* **columns**: integer
diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c
index 0501b432..90e8cc53 100644
--- a/source/widgets/textbox.c
+++ b/source/widgets/textbox.c
@@ -27,12 +27,12 @@
*/
#include "config.h"
-#include "widgets/textbox.h"
#include "helper-theme.h"
#include "helper.h"
#include "keyb.h"
#include "mode.h"
#include "view.h"
+#include "widgets/textbox.h"
#include <ctype.h>
#include <glib.h>
#include <math.h>
@@ -484,7 +484,7 @@ static void textbox_draw(widget *wid, cairo_t *draw) {
// TODO check if this is still needed after flatning.
cairo_set_operator(draw, CAIRO_OPERATOR_OVER);
- cairo_set_source_rgb ( draw, 0.0, 0.0, 0.0 );
+ cairo_set_source_rgb(draw, 0.0, 0.0, 0.0);
// use text color as fallback for themes that don't specify the cursor color
rofi_theme_get_color(WIDGET(tb), "text-color", draw);
@@ -531,8 +531,10 @@ static void textbox_draw(widget *wid, cairo_t *draw) {
int cursor_x = pos.x / PANGO_SCALE;
int cursor_y = pos.y / PANGO_SCALE;
int cursor_height = pos.height / PANGO_SCALE;
- RofiDistance cursor_width = rofi_theme_get_distance(WIDGET(tb), "cursor-width", 2);
- int cursor_pixel_width = distance_get_pixel(cursor_width, ROFI_ORIENTATION_HORIZONTAL);
+ RofiDistance cursor_width =
+ rofi_theme_get_distance(WIDGET(tb), "cursor-width", 2);
+ int cursor_pixel_width =
+ distance_get_pixel(cursor_width, ROFI_ORIENTATION_HORIZONTAL);
if ((x + cursor_x) != tb->cursor_x_pos) {
tb->cursor_x_pos = x + cursor_x;
}
@@ -554,6 +556,15 @@ static void textbox_draw(widget *wid, cairo_t *draw) {
rofi_theme_get_color(WIDGET(tb), "placeholder-color", draw);
}
pango_cairo_show_layout(draw, tb->layout);
+
+ if (rofi_theme_get_boolean(WIDGET(tb), "text-outline", FALSE)) {
+ rofi_theme_get_color(WIDGET(tb), "text-outline-color", draw);
+ double width = rofi_theme_get_double(WIDGET(tb), "text-outline-width", 0.5);
+ pango_cairo_layout_path(draw, tb->layout);
+ cairo_set_line_width(draw, width);
+ cairo_stroke(draw);
+ }
+
cairo_restore(draw);
}