summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--man/feh.pre6
-rw-r--r--src/feh.h4
-rw-r--r--src/imlib.c60
-rw-r--r--src/options.c4
-rw-r--r--src/options.h4
6 files changed, 41 insertions, 40 deletions
diff --git a/ChangeLog b/ChangeLog
index c9753e7..bb3e154 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,9 @@ git HEAD
* Reload image after executing an action with the hold-action flag set
<https://github.com/derf/feh/issues/59>
+ * Add --draw-tinted options to make overlay text (filename, caption etc.)
+ better readable
+ <https://github.com/derf/feh/issues/60>
Tue, 16 Aug 2011 22:48:06 +0200 Daniel Friesel <derf@finalrewind.org>
diff --git a/man/feh.pre b/man/feh.pre
index d2c0c35..5e5235d 100644
--- a/man/feh.pre
+++ b/man/feh.pre
@@ -199,6 +199,12 @@ Draw the defined actions and what they do at the top-left of the image.
.
Draw the filename at the top-left of the image.
.
+.It Cm --draw-tinted
+.
+Show overlay texts
+.Pq as created by Cm --draw-filename No et al
+on a semi-transparent background to improve their readability
+.
.It Cm -f , --filelist Ar file
.
This option is similar to the playlists used by music software. If
diff --git a/src/feh.h b/src/feh.h
index 6af425c..b25b3cc 100644
--- a/src/feh.h
+++ b/src/feh.h
@@ -93,6 +93,10 @@ enum bgmode_type { BG_MODE_NONE = 0, BG_MODE_TILE, BG_MODE_CENTER,
BG_MODE_SCALE, BG_MODE_FILL, BG_MODE_MAX
};
+enum zoom_mode { ZOOM_MODE_FILL, ZOOM_MODE_MAX };
+
+enum text_bg { TEXT_BG_CLEAR = 0, TEXT_BG_TINTED };
+
enum slide_change { SLIDE_NEXT, SLIDE_PREV, SLIDE_RAND, SLIDE_FIRST, SLIDE_LAST,
SLIDE_JUMP_FWD,
SLIDE_JUMP_BACK
diff --git a/src/imlib.c b/src/imlib.c
index d12852c..3259e4d 100644
--- a/src/imlib.c
+++ b/src/imlib.c
@@ -319,13 +319,29 @@ char *feh_http_load_image(char *url)
#endif /* HAVE_LIBCURL */
+void feh_imlib_image_fill_text_bg(Imlib_Image im, int w, int h)
+{
+ static DATA8 atab[256];
+ memset(atab, 0, sizeof(atab));
+
+ gib_imlib_image_set_has_alpha(im, 1);
+
+ gib_imlib_apply_color_modifier_to_rectangle(im, 0, 0, w, h, NULL, NULL,
+ NULL, atab);
+
+ if (opt.text_bg == TEXT_BG_CLEAR)
+ gib_imlib_image_fill_rectangle(im, 0, 0, w, h, 0, 0, 0, 0);
+ else
+ gib_imlib_image_fill_rectangle(im, 0, 0, w, h, 0, 0, 0, 127);
+}
+
+
void feh_draw_zoom(winwidget w)
{
static Imlib_Font fn = NULL;
int tw = 0, th = 0;
Imlib_Image im = NULL;
char buf[100];
- static DATA8 atab[256];
if (!w->im)
return;
@@ -342,8 +358,6 @@ void feh_draw_zoom(winwidget w)
return;
}
- memset(atab, 0, sizeof(atab));
-
snprintf(buf, sizeof(buf), "%.0f%%, %dx%d", w->zoom * 100,
(int) (w->im_w * w->zoom), (int) (w->im_h * w->zoom));
@@ -356,9 +370,7 @@ void feh_draw_zoom(winwidget w)
if (!im)
eprintf("Couldn't create image. Out of memory?");
- gib_imlib_image_set_has_alpha(im, 1);
- gib_imlib_apply_color_modifier_to_rectangle(im, 0, 0, tw, th, NULL, NULL, NULL, atab);
- gib_imlib_image_fill_rectangle(im, 0, 0, tw, th, 0, 0, 0, 0);
+ feh_imlib_image_fill_text_bg(im, tw, th);
gib_imlib_text_draw(im, fn, NULL, 2, 2, buf, IMLIB_TEXT_TO_RIGHT, 0, 0, 0, 255);
gib_imlib_text_draw(im, fn, NULL, 1, 1, buf, IMLIB_TEXT_TO_RIGHT, 255, 255, 255, 255);
@@ -394,7 +406,6 @@ void feh_draw_errstr(winwidget w)
static Imlib_Font fn = NULL;
int tw = 0, th = 0;
Imlib_Image im = NULL;
- static DATA8 atab[256];
if (!w->im)
return;
@@ -408,8 +419,6 @@ void feh_draw_errstr(winwidget w)
if (!fn)
eprintf("Unable to draw error message. Dying to be safe.");
- memset(atab, 0, sizeof(atab));
-
/* Work out how high the font is */
gib_imlib_get_text_size(fn, w->errstr, NULL, &tw, &th, IMLIB_TEXT_TO_RIGHT);
@@ -419,9 +428,7 @@ void feh_draw_errstr(winwidget w)
if (!im)
eprintf("Couldn't create errstr image. Out of memory?");
- gib_imlib_image_set_has_alpha(im, 1);
- gib_imlib_apply_color_modifier_to_rectangle(im, 0, 0, tw, th, NULL, NULL, NULL, atab);
- gib_imlib_image_fill_rectangle(im, 0, 0, tw, th, 0, 0, 0, 0);
+ feh_imlib_image_fill_text_bg(im, tw, th);
gib_imlib_text_draw(im, fn, NULL, 2, 2, w->errstr, IMLIB_TEXT_TO_RIGHT, 0, 0, 0, 255);
gib_imlib_text_draw(im, fn, NULL, 1, 1, w->errstr, IMLIB_TEXT_TO_RIGHT, 255, 0, 0, 255);
@@ -436,7 +443,6 @@ void feh_draw_filename(winwidget w)
static Imlib_Font fn = NULL;
int tw = 0, th = 0, nw = 0;
Imlib_Image im = NULL;
- static DATA8 atab[256];
char *s = NULL;
int len = 0;
@@ -459,8 +465,6 @@ void feh_draw_filename(winwidget w)
return;
}
- memset(atab, 0, sizeof(atab));
-
/* Work out how high the font is */
gib_imlib_get_text_size(fn, FEH_FILE(w->file->data)->filename, NULL, &tw,
&th, IMLIB_TEXT_TO_RIGHT);
@@ -484,10 +488,7 @@ void feh_draw_filename(winwidget w)
if (!im)
eprintf("Couldn't create image. Out of memory?");
- gib_imlib_image_set_has_alpha(im, 1);
- gib_imlib_apply_color_modifier_to_rectangle(im, 0, 0, tw, 2 * th, NULL,
- NULL, NULL, atab);
- gib_imlib_image_fill_rectangle(im, 0, 0, tw, 2 * th, 0, 0, 0, 0);
+ feh_imlib_image_fill_text_bg(im, tw, 2 * th);
gib_imlib_text_draw(im, fn, NULL, 2, 2, FEH_FILE(w->file->data)->filename,
IMLIB_TEXT_TO_RIGHT, 0, 0, 0, 255);
@@ -511,7 +512,6 @@ void feh_draw_info(winwidget w)
static Imlib_Font fn = NULL;
int tw = 0, th = 0;
Imlib_Image im = NULL;
- static DATA8 atab[256];
int no_lines = 0;
char *info_cmd;
char info_buf[256];
@@ -538,8 +538,6 @@ void feh_draw_info(winwidget w)
info_cmd = feh_printf(opt.info_cmd, FEH_FILE(w->file->data));
- memset(atab, 0, sizeof(atab));
-
gib_imlib_get_text_size(fn, "w", NULL, &tw, &th, IMLIB_TEXT_TO_RIGHT);
info_pipe = popen(info_cmd, "r");
@@ -548,9 +546,7 @@ void feh_draw_info(winwidget w)
if (!im)
eprintf("Couldn't create image. Out of memory?");
- gib_imlib_image_set_has_alpha(im, 1);
- gib_imlib_apply_color_modifier_to_rectangle(im, 0, 0, 290 * tw, 20 * th, NULL, NULL, NULL, atab);
- gib_imlib_image_fill_rectangle(im, 0, 0, 290 * tw, 20 * th, 0, 0, 0, 0);
+ feh_imlib_image_fill_text_bg(im, 290 * tw, 20 * th);
if (!info_pipe) {
gib_imlib_text_draw(im, fn, NULL, 2, 2,
@@ -622,7 +618,6 @@ void feh_draw_caption(winwidget w)
int tw = 0, th = 0, ww, hh;
int x, y;
Imlib_Image im = NULL;
- static DATA8 atab[256];
char *p;
gib_list *lines, *l;
static gib_style *caption_style = NULL;
@@ -683,8 +678,6 @@ void feh_draw_caption(winwidget w)
return;
}
- memset(atab, 0, sizeof(atab));
-
if (*(file->caption) == '\0') {
p = estrdup("Caption entry mode - Hit ESC to cancel");
lines = feh_wrap_string(p, w->w, fn, NULL);
@@ -718,9 +711,7 @@ void feh_draw_caption(winwidget w)
if (!im)
eprintf("Couldn't create image. Out of memory?");
- gib_imlib_image_set_has_alpha(im, 1);
- gib_imlib_apply_color_modifier_to_rectangle(im, 0, 0, tw, th, NULL, NULL, NULL, atab);
- gib_imlib_image_fill_rectangle(im, 0, 0, tw, th, 0, 0, 0, 0);
+ feh_imlib_image_fill_text_bg(im, tw, th);
l = lines;
x = 0;
@@ -973,7 +964,6 @@ void feh_draw_actions(winwidget w)
int max_tw = 0;
int line_th = 0;
Imlib_Image im = NULL;
- static DATA8 atab[256];
int i = 0;
int num_actions = 0;
int cur_action = 0;
@@ -1011,8 +1001,6 @@ void feh_draw_actions(winwidget w)
return;
}
- memset(atab, 0, sizeof(atab));
-
gib_imlib_get_text_size(fn, "defined actions:", NULL, &tw, &th, IMLIB_TEXT_TO_RIGHT);
/* Check for the widest line */
max_tw = tw;
@@ -1045,9 +1033,7 @@ void feh_draw_actions(winwidget w)
if (!im)
eprintf("Couldn't create image. Out of memory?");
- gib_imlib_image_set_has_alpha(im, 1);
- gib_imlib_apply_color_modifier_to_rectangle(im, 0, 0, tw, th, NULL, NULL, NULL, atab);
- gib_imlib_image_fill_rectangle(im, 0, 0, tw, th, 0, 0, 0, 0);
+ feh_imlib_image_fill_text_bg(im, tw, th);
gib_imlib_text_draw(im, fn, NULL, 2, 2, "defined actions:", IMLIB_TEXT_TO_RIGHT, 0, 0, 0, 255);
gib_imlib_text_draw(im, fn, NULL, 1, 1, "defined actions:", IMLIB_TEXT_TO_RIGHT, 255, 255, 255, 255);
diff --git a/src/options.c b/src/options.c
index 4c832a0..13aaa95 100644
--- a/src/options.c
+++ b/src/options.c
@@ -362,6 +362,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)
{"no-rotate-ctrl-mask", 0, 0, 226},
{"no-blur-ctrl-mask", 0, 0, 227},
{"menu-ctrl-mask", 0, 0, 228},
+ {"draw-tinted" , 0, 0, 229},
{"output" , 1, 0, 'o'},
{"output-only" , 1, 0, 'O'},
@@ -757,6 +758,9 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)
case 228:
opt.menu_ctrl_mask = 1;
break;
+ case 229:
+ opt.text_bg = TEXT_BG_TINTED;
+ break;
case 230:
opt.index_show_name = atoi(optarg);
break;
diff --git a/src/options.h b/src/options.h
index bfcb94c..2ca655e 100644
--- a/src/options.h
+++ b/src/options.h
@@ -27,9 +27,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef OPTIONS_H
#define OPTIONS_H
-#define ZOOM_MODE_FILL 1
-#define ZOOM_MODE_MAX 2
-
struct __fehoptions {
unsigned char multiwindow;
unsigned char montage;
@@ -72,6 +69,7 @@ struct __fehoptions {
unsigned char cache_thumbnails;
unsigned char cycle_once;
unsigned char hold_actions[10];
+ unsigned char text_bg;
char *output_file;
char *output_dir;