mirror of
https://github.com/lbonn/rofi
synced 2024-11-10 06:14:14 +00:00
[Textbox] Add text-outline to style
This commit is contained in:
parent
a1943bab1f
commit
0ff6ff21c3
4 changed files with 27 additions and 5 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,4 +1,6 @@
|
|||
/build/
|
||||
/build*/
|
||||
/.cache/
|
||||
/.vscode/
|
||||
|
||||
# autotools generated files
|
||||
/missing
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue