4 * Copyright (C) 2008 - 2009 The Geeqie Team
8 * This software is released under the GNU General Public License (GNU GPL).
9 * Please read the included file COPYING for more information.
10 * This software comes with no warranty of any kind, use at your own risk!
14 #include "image-overlay.h"
19 #include "histogram.h"
24 #include "pixbuf-renderer.h"
25 #include "pixbuf_util.h"
26 #include "ui_fileops.h"
27 #include "image-load.h"
30 *----------------------------------------------------------------------------
32 *----------------------------------------------------------------------------
36 typedef struct _OverlayStateData OverlayStateData;
37 struct _OverlayStateData {
39 ImageState changed_states;
50 gint icon_time[IMAGE_OSD_COUNT];
51 gint icon_id[IMAGE_OSD_COUNT];
59 typedef struct _OSDIcon OSDIcon;
61 gint reset; /* reset on new image */
62 gint x; /* x, y offset */
64 gchar *key; /* inline pixbuf */
67 static OSDIcon osd_icons[] = {
68 { TRUE, 0, 0, NULL }, /* none */
69 { TRUE, -10, -10, NULL }, /* auto rotated */
70 { TRUE, -10, -10, NULL }, /* user rotated */
71 { TRUE, -40, -10, NULL }, /* color embedded */
72 { TRUE, -70, -10, NULL }, /* first image */
73 { TRUE, -70, -10, NULL }, /* last image */
74 { FALSE, -70, -10, NULL }, /* osd enabled */
78 #define OSD_DATA "overlay-data"
80 #define IMAGE_OSD_DEFAULT_DURATION 30
82 #define HISTOGRAM_HEIGHT 140
83 #define HISTOGRAM_WIDTH 256
85 static void image_osd_timer_schedule(OverlayStateData *osd);
87 void set_image_overlay_template_string(gchar **template_string, const gchar *value)
89 g_assert(template_string);
91 g_free(*template_string);
92 *template_string = g_strdup(value);
96 void set_default_image_overlay_template_string(gchar **template_string)
98 set_image_overlay_template_string(template_string, DEFAULT_OVERLAY_INFO);
101 static OverlayStateData *image_get_osd_data(ImageWindow *imd)
103 OverlayStateData *osd;
105 if (!imd) return NULL;
109 osd = g_object_get_data(G_OBJECT(imd->pr), "IMAGE_OVERLAY_DATA");
113 static void image_set_osd_data(ImageWindow *imd, OverlayStateData *osd)
117 g_object_set_data(G_OBJECT(imd->pr), "IMAGE_OVERLAY_DATA", osd);
121 *----------------------------------------------------------------------------
123 *----------------------------------------------------------------------------
127 void image_osd_histogram_chan_toggle(ImageWindow *imd)
129 OverlayStateData *osd = image_get_osd_data(imd);
131 if (!osd || !osd->histogram) return;
133 histogram_toggle_channel(osd->histogram);
134 options->image_overlay.common.histogram_channel = histogram_get_channel(osd->histogram);
135 image_osd_update(imd);
138 void image_osd_histogram_log_toggle(ImageWindow *imd)
140 OverlayStateData *osd = image_get_osd_data(imd);
142 if (!osd || !osd->histogram) return;
144 histogram_toggle_mode(osd->histogram);
145 options->image_overlay.common.histogram_mode = histogram_get_mode(osd->histogram);
146 image_osd_update(imd);
149 void image_osd_toggle(ImageWindow *imd)
151 OverlayStateData *osd;
155 osd = image_get_osd_data(imd);
158 image_osd_set(imd, OSD_SHOW_INFO | OSD_SHOW_STATUS);
162 if (osd->show != OSD_SHOW_NOTHING)
164 if (osd->show & OSD_SHOW_HISTOGRAM)
166 image_osd_set(imd, OSD_SHOW_NOTHING);
170 image_osd_set(imd, osd->show | OSD_SHOW_HISTOGRAM);
175 static gchar *keywords_to_string(FileData *fd)
178 GString *kwstr = NULL;
183 keywords = metadata_read_list(fd, KEYWORD_KEY, METADATA_PLAIN);
187 GList *work = keywords;
191 gchar *kw = work->data;
196 kwstr = g_string_new("");
198 g_string_append(kwstr, ", ");
200 g_string_append(kwstr, kw);
202 string_list_free(keywords);
208 g_string_free(kwstr, FALSE);
214 static gchar *image_osd_mkinfo(const gchar *str, ImageWindow *imd, GHashTable *vars)
216 gchar delim = '%', imp = '|', sep[] = " - ";
219 gboolean want_separator = FALSE;
224 if (!str || !*str) return g_strdup("");
226 new = g_string_new(str);
234 gchar *limpos = NULL;
236 gchar *extrapos = NULL;
239 start = strchr(new->str, delim);
242 end = strchr(start+1, delim);
246 /* Search for optionnal modifiers
247 * %name:99:extra% -> name = "name", limit=99, extra = "extra"
249 for (p = start + 1; p < end; p++)
253 if (g_ascii_isdigit(p[1]) && !limpos)
256 if (!trunc) trunc = p;
261 if (!trunc) trunc = p;
268 limit = (guint) atoi(limpos);
271 extra = g_strndup(extrapos, end - extrapos);
273 name = g_strndup(start+1, (trunc ? trunc : end)-start-1);
274 pos = start - new->str;
277 if (strcmp(name, "keywords") == 0)
279 data = keywords_to_string(imd->image_fd);
281 else if (strcmp(name, "comment") == 0)
283 data = metadata_read_string(imd->image_fd, COMMENT_KEY, METADATA_PLAIN);
287 data = g_strdup(g_hash_table_lookup(vars, name));
288 if (data && strcmp(name, "zoom") == 0) imd->overlay_show_zoom = TRUE;
290 data = metadata_read_string(imd->image_fd, name, METADATA_FORMATTED);
293 if (data && *data && limit > 0 && strlen(data) > limit + 3)
295 gchar *new_data = g_strdup_printf("%-*.*s...", limit, limit, data);
302 /* Since we use pango markup to display, we need to escape here */
303 gchar *escaped = g_markup_escape_text(data, -1);
312 /* Display data between left and right parts of extra string
313 * the data is expressed by a '*' character. A '*' may be escaped
314 * by a \. You should escape all '*' characters, do not rely on the
315 * current implementation which only replaces the first unescaped '*'.
316 * If no "*" is present, the extra string is just appended to data string.
317 * Pango mark up is accepted in left and right parts.
318 * Any \n is replaced by a newline
320 * "<i>*</i>\n" -> data is displayed in italics ended with a newline
321 * "\n" -> ended with newline
322 * "ISO *" -> prefix data with "ISO " (ie. "ISO 100")
323 * "\**\*" -> prefix data with a star, and append a star (ie. "*100*")
324 * "\\*" -> prefix data with an anti slash (ie "\100")
325 * "Collection <b>*</b>\n" -> display data in bold prefixed by "Collection " and a newline is appended
327 * FIXME: using background / foreground colors lead to weird results.
331 gchar *right = extra;
333 guint len = strlen(extra);
335 /* Search for left and right parts and unescape characters */
336 for (p = extra; *p; p++, len--)
341 memmove(p+1, p+2, --len);
344 else if (p[1] != '\0')
345 memmove(p, p+1, len--); // includes \0
347 else if (p[0] == '*' && !left)
353 if (left) right[-1] = '\0';
355 new_data = g_strdup_printf("%s%s%s", left ? left : "", data, right);
362 g_string_erase(new, pos, end-start+1);
367 /* insert separator */
368 g_string_insert(new, pos, sep);
370 want_separator = FALSE;
373 g_string_insert(new, pos, data);
377 if (pos-prev >= 1 && new->str[pos] == imp)
379 /* pipe character is replaced by a separator, delete it
380 * and raise a flag if needed */
381 g_string_erase(new, pos--, 1);
382 want_separator |= (data && *data);
385 if (new->str[pos] == '\n') want_separator = FALSE;
393 /* search and destroy empty lines */
395 while ((start = strchr(end, '\n')))
398 while (*++(end) == '\n')
400 g_string_erase(new, start-new->str, end-start-1);
403 g_strchomp(new->str);
406 g_string_free(new, FALSE);
417 static void osd_template_insert(GHashTable *vars, gchar *keyword, gchar *value, OsdTemplateFlags flags)
421 g_hash_table_insert(vars, keyword, g_strdup(""));
425 if (flags & OSDT_NO_DUP)
427 g_hash_table_insert(vars, keyword, value);
432 g_hash_table_insert(vars, keyword, g_strdup(value));
435 if (flags & OSDT_FREE) g_free((gpointer) value);
438 static GdkPixbuf *image_osd_info_render(OverlayStateData *osd)
440 GdkPixbuf *pixbuf = NULL;
445 GdkPixbuf *imgpixbuf = NULL;
447 const HistMap *histmap;
448 ImageWindow *imd = osd->imd;
449 FileData *fd = image_get_fd(imd);
451 if (!fd) return NULL;
453 name = image_get_name(imd);
461 vars = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
463 cd = image_get_collection(imd, &info);
466 t = g_list_length(cd->list);
467 n = g_list_index(cd->list, info) + 1;
470 if (file_extension_match(cd->name, GQ_COLLECTION_EXT))
471 osd_template_insert(vars, "collection", remove_extension_from_path(cd->name), OSDT_FREE);
473 osd_template_insert(vars, "collection", cd->name, OSDT_NONE);
477 osd_template_insert(vars, "collection", _("Untitled"), OSDT_NONE);
482 LayoutWindow *lw = layout_find_by_image(imd);
487 n = g_list_length(lw->slideshow->list_done);
488 t = n + g_list_length(lw->slideshow->list);
493 t = layout_list_count(lw, NULL);
494 n = layout_list_get_index(lw, image_get_fd(lw->image)) + 1;
497 else if (view_window_find_image(imd, &n, &t))
510 osd_template_insert(vars, "collection", NULL, OSDT_NONE);
513 osd_template_insert(vars, "number", g_strdup_printf("%d", n), OSDT_NO_DUP);
514 osd_template_insert(vars, "total", g_strdup_printf("%d", t), OSDT_NO_DUP);
515 osd_template_insert(vars, "name", (gchar *) name, OSDT_NONE);
516 osd_template_insert(vars, "date", imd->image_fd ? ((gchar *) text_from_time(imd->image_fd->date)) : "", OSDT_NONE);
517 osd_template_insert(vars, "size", imd->image_fd ? (text_from_size_abrev(imd->image_fd->size)) : g_strdup(""), OSDT_FREE);
518 osd_template_insert(vars, "zoom", image_zoom_get_as_text(imd), OSDT_FREE);
523 GdkPixbuf *load_pixbuf = image_loader_get_pixbuf(imd->il);
525 if (imd->delay_flip &&
526 imd->il && load_pixbuf &&
527 image_get_pixbuf(imd) != load_pixbuf)
529 w = gdk_pixbuf_get_width(load_pixbuf);
530 h = gdk_pixbuf_get_height(load_pixbuf);
531 imgpixbuf = load_pixbuf;
535 image_get_image_size(imd, &w, &h);
536 imgpixbuf = (PIXBUF_RENDERER(imd->pr))->pixbuf;
540 osd_template_insert(vars, "width", g_strdup_printf("%d", w), OSDT_NO_DUP);
541 osd_template_insert(vars, "height", g_strdup_printf("%d", h), OSDT_NO_DUP);
542 osd_template_insert(vars, "res", g_strdup_printf("%d × %d", w, h), OSDT_FREE);
546 osd_template_insert(vars, "width", NULL, OSDT_NONE);
547 osd_template_insert(vars, "height", NULL, OSDT_NONE);
548 osd_template_insert(vars, "res", NULL, OSDT_NONE);
551 text = image_osd_mkinfo(options->image_overlay.common.template_string, imd, vars);
552 g_hash_table_destroy(vars);
555 /* When does this occur ?? */
556 text = g_markup_escape_text(_("Untitled"), -1);
559 with_hist = ((osd->show & OSD_SHOW_HISTOGRAM) && osd->histogram);
562 histmap = histmap_get(imd->image_fd);
563 if (!histmap) with_hist = FALSE;
568 gint active_marks = 0;
572 for (mark = 0; mark < FILEDATA_MARKS_SIZE; mark++)
574 active_marks += file_data_get_mark(fd, mark);
577 if (active_marks > 0)
579 GString *buf = g_string_sized_new(FILEDATA_MARKS_SIZE * 2);
581 for (mark = 0; mark < FILEDATA_MARKS_SIZE; mark++)
583 g_string_append_printf(buf, file_data_get_mark(fd, mark) ? " <span background='#FF00FF'>%c</span>" : " %c", '1' + mark);
587 text2 = g_strdup_printf("%s\n%s", text, buf->str);
589 text2 = g_strdup(buf->str);
590 g_string_free(buf, TRUE);
597 gchar *escaped_histogram_label = g_markup_escape_text(histogram_label(osd->histogram), -1);
599 text2 = g_strdup_printf("%s\n%s", text, escaped_histogram_label);
601 text2 = g_strdup(escaped_histogram_label);
602 g_free(escaped_histogram_label);
608 layout = gtk_widget_create_pango_layout(imd->pr, NULL);
609 pango_layout_set_markup(layout, text, -1);
612 pango_layout_get_pixel_size(layout, &width, &height);
613 /* with empty text width is set to 0, but not height) */
616 else if (height == 0)
618 if (width > 0) width += 10;
619 if (height > 0) height += 10;
623 if (width < HISTOGRAM_WIDTH + 10) width = HISTOGRAM_WIDTH + 10;
624 height += HISTOGRAM_HEIGHT + 5;
627 if (width > 0 && height > 0)
629 /* TODO: make osd color configurable --Zas */
630 pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height);
631 pixbuf_set_rect_fill(pixbuf, 3, 3, width-6, height-6, 240, 240, 240, 210);
632 pixbuf_set_rect(pixbuf, 0, 0, width, height, 240, 240, 240, 80, 1, 1, 1, 1);
633 pixbuf_set_rect(pixbuf, 1, 1, width-2, height-2, 240, 240, 240, 130, 1, 1, 1, 1);
634 pixbuf_set_rect(pixbuf, 2, 2, width-4, height-4, 240, 240, 240, 180, 1, 1, 1, 1);
635 pixbuf_pixel_set(pixbuf, 0, 0, 0, 0, 0, 0);
636 pixbuf_pixel_set(pixbuf, width - 1, 0, 0, 0, 0, 0);
637 pixbuf_pixel_set(pixbuf, 0, height - 1, 0, 0, 0, 0);
638 pixbuf_pixel_set(pixbuf, width - 1, height - 1, 0, 0, 0, 0);
643 gint y = height - HISTOGRAM_HEIGHT - 5;
646 pixbuf_set_rect_fill(pixbuf, x, y, w, HISTOGRAM_HEIGHT, 220, 220, 220, 210);
647 histogram_draw(osd->histogram, histmap, pixbuf, x, y, w, HISTOGRAM_HEIGHT);
649 pixbuf_draw_layout(pixbuf, layout, imd->pr, 5, 5, 0, 0, 0, 255);
652 g_object_unref(G_OBJECT(layout));
657 static GdkPixbuf *image_osd_icon_pixbuf(ImageOSDFlag flag)
659 static GdkPixbuf **icons = NULL;
660 GdkPixbuf *icon = NULL;
662 if (!icons) icons = g_new0(GdkPixbuf *, IMAGE_OSD_COUNT);
663 if (icons[flag]) return icons[flag];
665 if (osd_icons[flag].key)
667 icon = pixbuf_inline(osd_icons[flag].key);
672 icon = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 24, 24);
673 pixbuf_set_rect_fill(icon, 1, 1, 22, 22, 255, 255, 255, 200);
674 pixbuf_set_rect(icon, 0, 0, 24, 24, 0, 0, 0, 128, 1, 1, 1, 1);
677 case IMAGE_OSD_ROTATE_AUTO:
678 pixbuf_set_rect(icon, 3, 8, 11, 12,
681 pixbuf_draw_triangle(icon, 14, 3, 6, 12,
682 20, 9, 14, 15, 14, 3,
685 case IMAGE_OSD_ROTATE_USER:
687 case IMAGE_OSD_COLOR:
688 pixbuf_set_rect_fill(icon, 3, 3, 18, 6, 200, 0, 0, 255);
689 pixbuf_set_rect_fill(icon, 3, 9, 18, 6, 0, 200, 0, 255);
690 pixbuf_set_rect_fill(icon, 3, 15, 18, 6, 0, 0, 200, 255);
692 case IMAGE_OSD_FIRST:
693 pixbuf_set_rect(icon, 3, 3, 18, 18, 0, 0, 0, 200, 3, 3, 3, 0);
694 pixbuf_draw_triangle(icon, 6, 5, 12, 6,
695 12, 5, 18, 11, 6, 11,
699 pixbuf_set_rect(icon, 3, 3, 18, 18, 0, 0, 0, 200, 3, 3, 0, 3);
700 pixbuf_draw_triangle(icon, 6, 12, 12, 6,
701 12, 18, 6, 12, 18, 12,
705 pixbuf_set_rect_fill(icon, 11, 3, 3, 12, 0, 0, 0, 255);
706 pixbuf_set_rect_fill(icon, 11, 17, 3, 3, 0, 0, 0, 255);
718 static gint image_overlay_add(ImageWindow *imd, GdkPixbuf *pixbuf, gint x, gint y,
719 OverlayRendererFlags flags)
721 return pixbuf_renderer_overlay_add((PixbufRenderer *)imd->pr, pixbuf, x, y, flags);
724 static void image_overlay_set(ImageWindow *imd, gint id, GdkPixbuf *pixbuf, gint x, gint y)
726 pixbuf_renderer_overlay_set((PixbufRenderer *)imd->pr, id, pixbuf, x, y);
729 #if 0 /* unused for now */
730 static gint image_overlay_get(ImageWindow *imd, gint id, GdkPixbuf **pixbuf, gint *x, gint *y)
732 return pixbuf_renderer_overlay_get((PixbufRenderer *)imd->pr, id, pixbuf, x, y);
736 static void image_overlay_remove(ImageWindow *imd, gint id)
738 pixbuf_renderer_overlay_remove((PixbufRenderer *)imd->pr, id);
741 static void image_osd_icon_show(OverlayStateData *osd, ImageOSDFlag flag)
745 if (osd->icon_id[flag]) return;
747 pixbuf = image_osd_icon_pixbuf(flag);
750 osd->icon_id[flag] = image_overlay_add(osd->imd, pixbuf,
751 osd_icons[flag].x, osd_icons[flag].y,
755 static void image_osd_icon_hide(OverlayStateData *osd, ImageOSDFlag flag)
757 if (osd->icon_id[flag])
759 image_overlay_remove(osd->imd, osd->icon_id[flag]);
760 osd->icon_id[flag] = 0;
764 static void image_osd_icons_reset_time(OverlayStateData *osd)
768 for (i = 0; i < IMAGE_OSD_COUNT; i++)
770 if (osd_icons[i].reset)
772 osd->icon_time[i] = 0;
777 static void image_osd_icons_update(OverlayStateData *osd)
781 for (i = 0; i < IMAGE_OSD_COUNT; i++)
783 if (osd->icon_time[i] > 0)
785 image_osd_icon_show(osd, i);
789 image_osd_icon_hide(osd, i);
794 static void image_osd_icons_hide(OverlayStateData *osd)
798 for (i = 0; i < IMAGE_OSD_COUNT; i++)
800 image_osd_icon_hide(osd, i);
804 static void image_osd_info_show(OverlayStateData *osd, GdkPixbuf *pixbuf)
806 if (osd->ovl_info == 0)
808 osd->ovl_info = image_overlay_add(osd->imd, pixbuf, osd->x, osd->y, OVL_RELATIVE);
812 image_overlay_set(osd->imd, osd->ovl_info, pixbuf, osd->x, osd->y);
816 static void image_osd_info_hide(OverlayStateData *osd)
818 if (osd->ovl_info == 0) return;
820 image_overlay_remove(osd->imd, osd->ovl_info);
824 static gint image_osd_update_cb(gpointer data)
826 OverlayStateData *osd = data;
828 osd->imd->overlay_show_zoom = FALSE;
830 if (osd->show & OSD_SHOW_INFO)
832 /* redraw when the image was changed,
833 with histogram we have to redraw also when loading is finished */
834 if (osd->changed_states & IMAGE_STATE_IMAGE ||
835 (osd->changed_states & IMAGE_STATE_LOADING && osd->show & OSD_SHOW_HISTOGRAM))
839 pixbuf = image_osd_info_render(osd);
842 image_osd_info_show(osd, pixbuf);
843 g_object_unref(pixbuf);
847 image_osd_info_hide(osd);
853 image_osd_info_hide(osd);
856 if (osd->show & OSD_SHOW_STATUS)
858 if (osd->changed_states & IMAGE_STATE_IMAGE)
859 image_osd_icons_reset_time(osd);
861 if (osd->changed_states & IMAGE_STATE_COLOR_ADJ)
863 osd->icon_time[IMAGE_OSD_COLOR] = IMAGE_OSD_DEFAULT_DURATION + 1;
864 image_osd_timer_schedule(osd);
867 if (osd->changed_states & IMAGE_STATE_ROTATE_AUTO)
871 if (osd->imd->state & IMAGE_STATE_ROTATE_AUTO)
874 if (!osd->imd->cm) n += IMAGE_OSD_DEFAULT_DURATION;
877 osd->icon_time[IMAGE_OSD_ROTATE_AUTO] = n;
878 image_osd_timer_schedule(osd);
881 image_osd_icons_update(osd);
885 image_osd_icons_hide(osd);
888 if (osd->imd->il && image_loader_get_is_done(osd->imd->il))
889 osd->changed_states = IMAGE_STATE_NONE;
894 static void image_osd_update_schedule(OverlayStateData *osd, gint force)
896 if (force) osd->changed_states |= IMAGE_STATE_IMAGE;
898 if (osd->idle_id == -1)
900 osd->idle_id = g_idle_add_full(G_PRIORITY_HIGH, image_osd_update_cb, osd, NULL);
904 void image_osd_update(ImageWindow *imd)
906 OverlayStateData *osd = image_get_osd_data(imd);
910 image_osd_update_schedule(osd, TRUE);
913 static gint image_osd_timer_cb(gpointer data)
915 OverlayStateData *osd = data;
917 gint changed = FALSE;
920 for (i = 0; i < IMAGE_OSD_COUNT; i++)
922 if (osd->icon_time[i] > 1)
925 if (osd->icon_time[i] < 2)
927 osd->icon_time[i] = 0;
937 if (changed) image_osd_update_schedule(osd, FALSE);
948 static void image_osd_timer_schedule(OverlayStateData *osd)
950 if (osd->timer_id == -1)
952 osd->timer_id = g_timeout_add(100, image_osd_timer_cb, osd);
956 static void image_osd_state_cb(ImageWindow *imd, ImageState state, gpointer data)
958 OverlayStateData *osd = data;
960 osd->changed_states |= state;
961 image_osd_update_schedule(osd, FALSE);
964 static void image_osd_free(OverlayStateData *osd)
968 if (osd->idle_id != -1) g_source_remove(osd->idle_id);
969 if (osd->timer_id != -1) g_source_remove(osd->timer_id);
973 image_set_osd_data(osd->imd, NULL);
974 g_signal_handler_disconnect(osd->imd->pr, osd->destroy_id);
976 image_set_state_func(osd->imd, NULL, NULL);
978 image_osd_info_hide(osd);
979 image_osd_icons_hide(osd);
982 if (osd->histogram) histogram_free(osd->histogram);
987 static void image_osd_remove(ImageWindow *imd)
989 OverlayStateData *osd = image_get_osd_data(imd);
991 if (osd) image_osd_free(osd);
994 static void image_osd_destroy_cb(GtkWidget *widget, gpointer data)
996 OverlayStateData *osd = data;
1002 static void image_osd_enable(ImageWindow *imd, OsdShowFlags show)
1004 OverlayStateData *osd = image_get_osd_data(imd);
1008 osd = g_new0(OverlayStateData, 1);
1012 osd->show = OSD_SHOW_NOTHING;
1013 osd->histogram = NULL;
1014 osd->x = options->image_overlay.common.x;
1015 osd->y = options->image_overlay.common.y;
1017 osd->destroy_id = g_signal_connect(G_OBJECT(imd->pr), "destroy",
1018 G_CALLBACK(image_osd_destroy_cb), osd);
1019 image_set_osd_data(imd, osd);
1021 image_set_state_func(osd->imd, image_osd_state_cb, osd);
1024 if (show & OSD_SHOW_HISTOGRAM)
1026 osd->histogram = histogram_new();
1027 histogram_set_channel(osd->histogram, options->image_overlay.common.histogram_channel);
1028 histogram_set_mode(osd->histogram, options->image_overlay.common.histogram_mode);
1030 else if (osd->histogram)
1032 histogram_free(osd->histogram);
1033 osd->histogram = NULL;
1036 if (show & OSD_SHOW_STATUS)
1037 image_osd_icon(imd, IMAGE_OSD_ICON, -1);
1039 if (show != osd->show)
1040 image_osd_update_schedule(osd, TRUE);
1045 void image_osd_set(ImageWindow *imd, OsdShowFlags show)
1049 if (show == OSD_SHOW_NOTHING)
1051 image_osd_remove(imd);
1055 image_osd_enable(imd, show);
1058 OsdShowFlags image_osd_get(ImageWindow *imd)
1060 OverlayStateData *osd = image_get_osd_data(imd);
1062 return osd ? osd->show : OSD_SHOW_NOTHING;
1068 2+ = show for duration tenths of a second
1069 -1 = use default duration
1071 void image_osd_icon(ImageWindow *imd, ImageOSDFlag flag, gint duration)
1073 OverlayStateData *osd = image_get_osd_data(imd);
1077 if (flag >= IMAGE_OSD_COUNT) return;
1078 if (duration < 0) duration = IMAGE_OSD_DEFAULT_DURATION;
1079 if (duration > 1) duration += 1;
1081 osd->icon_time[flag] = duration;
1083 image_osd_update_schedule(osd, FALSE);
1084 image_osd_timer_schedule(osd);
1086 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */