4 * Copyright (C) 2008 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_set_channel(osd->histogram, (histogram_get_channel(osd->histogram) +1)%HCHAN_COUNT);
134 image_osd_update(imd);
137 void image_osd_histogram_log_toggle(ImageWindow *imd)
139 OverlayStateData *osd = image_get_osd_data(imd);
141 if (!osd || !osd->histogram) return;
143 histogram_set_mode(osd->histogram, !histogram_get_mode(osd->histogram));
144 image_osd_update(imd);
147 void image_osd_toggle(ImageWindow *imd)
149 OverlayStateData *osd;
153 osd = image_get_osd_data(imd);
156 image_osd_set(imd, OSD_SHOW_INFO | OSD_SHOW_STATUS);
160 if (osd->show != OSD_SHOW_NOTHING)
162 if (osd->show & OSD_SHOW_HISTOGRAM)
164 image_osd_set(imd, OSD_SHOW_NOTHING);
168 image_osd_set(imd, osd->show | OSD_SHOW_HISTOGRAM);
173 static gchar *keywords_to_string(FileData *fd)
176 GString *kwstr = NULL;
181 if (comment_read(fd, &keywords, NULL))
183 GList *work = keywords;
187 gchar *kw = work->data;
192 kwstr = g_string_new("");
194 g_string_append(kwstr, ", ");
196 g_string_append(kwstr, kw);
203 g_string_free(kwstr, FALSE);
209 static gchar *image_osd_mkinfo(const gchar *str, ImageWindow *imd, GHashTable *vars)
211 gchar delim = '%', imp = '|', sep[] = " - ";
214 gboolean want_separator = FALSE;
219 if (!str || !*str) return g_strdup("");
221 new = g_string_new(str);
229 gchar *limpos = NULL;
231 gchar *extrapos = NULL;
234 start = strchr(new->str, delim);
237 end = strchr(start+1, delim);
241 /* Search for optionnal modifiers
242 * %name:99:extra% -> name = "name", limit=99, extra = "extra"
244 for (p = start + 1; p < end; p++)
248 if (g_ascii_isdigit(p[1]) && !limpos)
251 if (!trunc) trunc = p;
256 if (!trunc) trunc = p;
263 limit = (guint) atoi(limpos);
266 extra = g_strndup(extrapos, end - extrapos);
268 name = g_strndup(start+1, (trunc ? trunc : end)-start-1);
269 pos = start - new->str;
272 if (strcmp(name, "keywords") == 0)
274 data = keywords_to_string(imd->image_fd);
276 else if (strcmp(name, "comment") == 0)
278 comment_read(imd->image_fd, NULL, &data);
283 keywords and comment can't be read between exif_read_fd and exif_free_fd calls
284 because fd->exif does not count references
285 on the other hand, it is OK to call it in the loop because it is cached
289 exif = exif_read_fd(imd->image_fd);
291 data = g_strdup(g_hash_table_lookup(vars, name));
292 if (data && strcmp(name, "zoom") == 0) imd->overlay_show_zoom = TRUE;
294 data = exif_get_data_as_text(exif, name);
295 exif_free_fd(imd->image_fd, exif);
298 if (data && *data && limit > 0 && strlen(data) > limit + 3)
300 gchar *new_data = g_strdup_printf("%-*.*s...", limit, limit, data);
307 /* Since we use pango markup to display, we need to escape here */
308 gchar *escaped = g_markup_escape_text(data, -1);
317 /* Display data between left and right parts of extra string
318 * the data is expressed by a '*' character. A '*' may be escaped
319 * by a \. You should escape all '*' characters, do not rely on the
320 * current implementation which only replaces the first unescaped '*'.
321 * If no "*" is present, the extra string is just appended to data string.
322 * Pango mark up is accepted in left and right parts.
323 * Any \n is replaced by a newline
325 * "<i>*</i>\n" -> data is displayed in italics ended with a newline
326 * "\n" -> ended with newline
327 * "ISO *" -> prefix data with "ISO " (ie. "ISO 100")
328 * "\**\*" -> prefix data with a star, and append a star (ie. "*100*")
329 * "\\*" -> prefix data with an anti slash (ie "\100")
330 * "Collection <b>*</b>\n" -> display data in bold prefixed by "Collection " and a newline is appended
332 * FIXME: using background / foreground colors lead to weird results.
336 gchar *right = extra;
338 guint len = strlen(extra);
340 /* Search for left and right parts and unescape characters */
341 for (p = extra; *p; p++, len--)
346 memmove(p+1, p+2, --len);
349 else if (p[1] != '\0')
350 memmove(p, p+1, len--); // includes \0
352 else if (p[0] == '*' && !left)
358 if (left) right[-1] = '\0';
360 new_data = g_strdup_printf("%s%s%s", left ? left : "", data, right);
367 g_string_erase(new, pos, end-start+1);
372 /* insert separator */
373 g_string_insert(new, pos, sep);
375 want_separator = FALSE;
378 g_string_insert(new, pos, data);
382 if (pos-prev >= 1 && new->str[pos] == imp)
384 /* pipe character is replaced by a separator, delete it
385 * and raise a flag if needed */
386 g_string_erase(new, pos--, 1);
387 want_separator |= (data && *data);
390 if (new->str[pos] == '\n') want_separator = FALSE;
398 /* search and destroy empty lines */
400 while ((start = strchr(end, '\n')))
403 while (*++(end) == '\n')
405 g_string_erase(new, start-new->str, end-start-1);
408 g_strchomp(new->str);
411 g_string_free(new, FALSE);
422 static void osd_template_insert(GHashTable *vars, gchar *keyword, gchar *value, OsdTemplateFlags flags)
426 g_hash_table_insert(vars, keyword, g_strdup(""));
430 if (flags & OSDT_NO_DUP)
432 g_hash_table_insert(vars, keyword, value);
437 g_hash_table_insert(vars, keyword, g_strdup(value));
440 if (flags & OSDT_FREE) g_free((gpointer) value);
443 static GdkPixbuf *image_osd_info_render(OverlayStateData *osd)
445 GdkPixbuf *pixbuf = NULL;
450 GdkPixbuf *imgpixbuf = NULL;
452 ImageWindow *imd = osd->imd;
453 FileData *fd = image_get_fd(imd);
455 if (!fd) return NULL;
457 name = image_get_name(imd);
465 vars = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
467 cd = image_get_collection(imd, &info);
470 t = g_list_length(cd->list);
471 n = g_list_index(cd->list, info) + 1;
474 if (file_extension_match(cd->name, GQ_COLLECTION_EXT))
475 osd_template_insert(vars, "collection", remove_extension_from_path(cd->name), OSDT_FREE);
477 osd_template_insert(vars, "collection", cd->name, OSDT_NONE);
481 osd_template_insert(vars, "collection", _("Untitled"), OSDT_NONE);
486 LayoutWindow *lw = layout_find_by_image(imd);
491 n = g_list_length(lw->slideshow->list_done);
492 t = n + g_list_length(lw->slideshow->list);
497 t = layout_list_count(lw, NULL);
498 n = layout_list_get_index(lw, image_get_fd(lw->image)) + 1;
501 else if (view_window_find_image(imd, &n, &t))
514 osd_template_insert(vars, "collection", NULL, OSDT_NONE);
517 osd_template_insert(vars, "number", g_strdup_printf("%d", n), OSDT_NO_DUP);
518 osd_template_insert(vars, "total", g_strdup_printf("%d", t), OSDT_NO_DUP);
519 osd_template_insert(vars, "name", (gchar *) name, OSDT_NONE);
520 osd_template_insert(vars, "date", imd->image_fd ? ((gchar *) text_from_time(imd->image_fd->date)) : "", OSDT_NONE);
521 osd_template_insert(vars, "size", imd->image_fd ? (text_from_size_abrev(imd->image_fd->size)) : g_strdup(""), OSDT_FREE);
522 osd_template_insert(vars, "zoom", image_zoom_get_as_text(imd), OSDT_FREE);
527 GdkPixbuf *load_pixbuf = image_loader_get_pixbuf(imd->il);
529 if (imd->delay_flip &&
530 imd->il && load_pixbuf &&
531 image_get_pixbuf(imd) != load_pixbuf)
533 w = gdk_pixbuf_get_width(load_pixbuf);
534 h = gdk_pixbuf_get_height(load_pixbuf);
535 imgpixbuf = load_pixbuf;
539 image_get_image_size(imd, &w, &h);
540 imgpixbuf = (PIXBUF_RENDERER(imd->pr))->pixbuf;
544 osd_template_insert(vars, "width", g_strdup_printf("%d", w), OSDT_NO_DUP);
545 osd_template_insert(vars, "height", g_strdup_printf("%d", h), OSDT_NO_DUP);
546 osd_template_insert(vars, "res", g_strdup_printf("%d × %d", w, h), OSDT_FREE);
550 osd_template_insert(vars, "width", NULL, OSDT_NONE);
551 osd_template_insert(vars, "height", NULL, OSDT_NONE);
552 osd_template_insert(vars, "res", NULL, OSDT_NONE);
555 text = image_osd_mkinfo(options->image_overlay.common.template_string, imd, vars);
556 g_hash_table_destroy(vars);
559 /* When does this occur ?? */
560 text = g_markup_escape_text(_("Untitled"), -1);
563 with_hist = (imgpixbuf && (osd->show & OSD_SHOW_HISTOGRAM) && osd->histogram && (!imd->il || image_loader_get_is_done(imd->il)));
566 gint active_marks = 0;
570 for (mark = 0; mark < FILEDATA_MARKS_SIZE; mark++)
572 active_marks += file_data_get_mark(fd, mark);
575 if (active_marks > 0)
577 GString *buf = g_string_sized_new(FILEDATA_MARKS_SIZE * 2);
579 for (mark = 0; mark < FILEDATA_MARKS_SIZE; mark++)
581 g_string_append_printf(buf, file_data_get_mark(fd, mark) ? " <span background='#FF00FF'>%c</span>" : " %c", '1' + mark);
585 text2 = g_strdup_printf("%s\n%s", text, buf->str);
587 text2 = g_strdup(buf->str);
588 g_string_free(buf, TRUE);
595 gchar *escaped_histogram_label = g_markup_escape_text(histogram_label(osd->histogram), -1);
597 text2 = g_strdup_printf("%s\n%s", text, escaped_histogram_label);
599 text2 = g_strdup(escaped_histogram_label);
600 g_free(escaped_histogram_label);
606 layout = gtk_widget_create_pango_layout(imd->pr, NULL);
607 pango_layout_set_markup(layout, text, -1);
610 pango_layout_get_pixel_size(layout, &width, &height);
611 /* with empty text width is set to 0, but not height) */
614 else if (height == 0)
616 if (width > 0) width += 10;
617 if (height > 0) height += 10;
621 histogram_read(osd->histogram, imgpixbuf);
622 if (width < HISTOGRAM_WIDTH + 10) width = HISTOGRAM_WIDTH + 10;
623 height += HISTOGRAM_HEIGHT + 5;
626 if (width > 0 && height > 0)
628 /* TODO: make osd color configurable --Zas */
629 pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height);
630 pixbuf_set_rect_fill(pixbuf, 3, 3, width-6, height-6, 240, 240, 240, 210);
631 pixbuf_set_rect(pixbuf, 0, 0, width, height, 240, 240, 240, 80, 1, 1, 1, 1);
632 pixbuf_set_rect(pixbuf, 1, 1, width-2, height-2, 240, 240, 240, 130, 1, 1, 1, 1);
633 pixbuf_set_rect(pixbuf, 2, 2, width-4, height-4, 240, 240, 240, 180, 1, 1, 1, 1);
634 pixbuf_pixel_set(pixbuf, 0, 0, 0, 0, 0, 0);
635 pixbuf_pixel_set(pixbuf, width - 1, 0, 0, 0, 0, 0);
636 pixbuf_pixel_set(pixbuf, 0, height - 1, 0, 0, 0, 0);
637 pixbuf_pixel_set(pixbuf, width - 1, height - 1, 0, 0, 0, 0);
642 gint y = height - HISTOGRAM_HEIGHT - 5;
649 float add = w / (float)subdiv;
651 for (i = 0; i < subdiv; i++)
653 gint d = (i > 0 ? 0 : 1);
655 pixbuf_set_rect(pixbuf, x + xoffset + 0.5, y, add + d + 0.5, HISTOGRAM_HEIGHT, c, c, c, alpha, d, 1, 1, 1);
659 histogram_draw(osd->histogram, pixbuf, x, y, w, HISTOGRAM_HEIGHT);
661 pixbuf_draw_layout(pixbuf, layout, imd->pr, 5, 5, 0, 0, 0, 255);
664 g_object_unref(G_OBJECT(layout));
669 static GdkPixbuf *image_osd_icon_pixbuf(ImageOSDFlag flag)
671 static GdkPixbuf **icons = NULL;
672 GdkPixbuf *icon = NULL;
674 if (!icons) icons = g_new0(GdkPixbuf *, IMAGE_OSD_COUNT);
675 if (icons[flag]) return icons[flag];
677 if (osd_icons[flag].key)
679 icon = pixbuf_inline(osd_icons[flag].key);
684 icon = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 24, 24);
685 pixbuf_set_rect_fill(icon, 1, 1, 22, 22, 255, 255, 255, 200);
686 pixbuf_set_rect(icon, 0, 0, 24, 24, 0, 0, 0, 128, 1, 1, 1, 1);
689 case IMAGE_OSD_ROTATE_AUTO:
690 pixbuf_set_rect(icon, 3, 8, 11, 12,
693 pixbuf_draw_triangle(icon, 14, 3, 6, 12,
694 20, 9, 14, 15, 14, 3,
697 case IMAGE_OSD_ROTATE_USER:
699 case IMAGE_OSD_COLOR:
700 pixbuf_set_rect_fill(icon, 3, 3, 18, 6, 200, 0, 0, 255);
701 pixbuf_set_rect_fill(icon, 3, 9, 18, 6, 0, 200, 0, 255);
702 pixbuf_set_rect_fill(icon, 3, 15, 18, 6, 0, 0, 200, 255);
704 case IMAGE_OSD_FIRST:
705 pixbuf_set_rect(icon, 3, 3, 18, 18, 0, 0, 0, 200, 3, 3, 3, 0);
706 pixbuf_draw_triangle(icon, 6, 5, 12, 6,
707 12, 5, 18, 11, 6, 11,
711 pixbuf_set_rect(icon, 3, 3, 18, 18, 0, 0, 0, 200, 3, 3, 0, 3);
712 pixbuf_draw_triangle(icon, 6, 12, 12, 6,
713 12, 18, 6, 12, 18, 12,
717 pixbuf_set_rect_fill(icon, 11, 3, 3, 12, 0, 0, 0, 255);
718 pixbuf_set_rect_fill(icon, 11, 17, 3, 3, 0, 0, 0, 255);
730 static gint image_overlay_add(ImageWindow *imd, GdkPixbuf *pixbuf, gint x, gint y,
731 OverlayRendererFlags flags)
733 return pixbuf_renderer_overlay_add((PixbufRenderer *)imd->pr, pixbuf, x, y, flags);
736 static void image_overlay_set(ImageWindow *imd, gint id, GdkPixbuf *pixbuf, gint x, gint y)
738 pixbuf_renderer_overlay_set((PixbufRenderer *)imd->pr, id, pixbuf, x, y);
741 #if 0 /* unused for now */
742 static gint image_overlay_get(ImageWindow *imd, gint id, GdkPixbuf **pixbuf, gint *x, gint *y)
744 return pixbuf_renderer_overlay_get((PixbufRenderer *)imd->pr, id, pixbuf, x, y);
748 static void image_overlay_remove(ImageWindow *imd, gint id)
750 pixbuf_renderer_overlay_remove((PixbufRenderer *)imd->pr, id);
753 static void image_osd_icon_show(OverlayStateData *osd, ImageOSDFlag flag)
757 if (osd->icon_id[flag]) return;
759 pixbuf = image_osd_icon_pixbuf(flag);
762 osd->icon_id[flag] = image_overlay_add(osd->imd, pixbuf,
763 osd_icons[flag].x, osd_icons[flag].y,
767 static void image_osd_icon_hide(OverlayStateData *osd, ImageOSDFlag flag)
769 if (osd->icon_id[flag])
771 image_overlay_remove(osd->imd, osd->icon_id[flag]);
772 osd->icon_id[flag] = 0;
776 static void image_osd_icons_reset_time(OverlayStateData *osd)
780 for (i = 0; i < IMAGE_OSD_COUNT; i++)
782 if (osd_icons[i].reset)
784 osd->icon_time[i] = 0;
789 static void image_osd_icons_update(OverlayStateData *osd)
793 for (i = 0; i < IMAGE_OSD_COUNT; i++)
795 if (osd->icon_time[i] > 0)
797 image_osd_icon_show(osd, i);
801 image_osd_icon_hide(osd, i);
806 static void image_osd_icons_hide(OverlayStateData *osd)
810 for (i = 0; i < IMAGE_OSD_COUNT; i++)
812 image_osd_icon_hide(osd, i);
816 static void image_osd_info_show(OverlayStateData *osd, GdkPixbuf *pixbuf)
818 if (osd->ovl_info == 0)
820 osd->ovl_info = image_overlay_add(osd->imd, pixbuf, osd->x, osd->y, OVL_RELATIVE);
824 image_overlay_set(osd->imd, osd->ovl_info, pixbuf, osd->x, osd->y);
828 static void image_osd_info_hide(OverlayStateData *osd)
830 if (osd->ovl_info == 0) return;
832 image_overlay_remove(osd->imd, osd->ovl_info);
836 static gint image_osd_update_cb(gpointer data)
838 OverlayStateData *osd = data;
840 osd->imd->overlay_show_zoom = FALSE;
842 if (osd->show & OSD_SHOW_INFO)
844 if (osd->changed_states & IMAGE_STATE_IMAGE)
848 pixbuf = image_osd_info_render(osd);
851 image_osd_info_show(osd, pixbuf);
852 g_object_unref(pixbuf);
856 image_osd_info_hide(osd);
862 image_osd_info_hide(osd);
865 if (osd->show & OSD_SHOW_STATUS)
867 if (osd->changed_states & IMAGE_STATE_IMAGE)
868 image_osd_icons_reset_time(osd);
870 if (osd->changed_states & IMAGE_STATE_COLOR_ADJ)
872 osd->icon_time[IMAGE_OSD_COLOR] = IMAGE_OSD_DEFAULT_DURATION + 1;
873 image_osd_timer_schedule(osd);
876 if (osd->changed_states & IMAGE_STATE_ROTATE_AUTO)
880 if (osd->imd->state & IMAGE_STATE_ROTATE_AUTO)
883 if (!osd->imd->cm) n += IMAGE_OSD_DEFAULT_DURATION;
886 osd->icon_time[IMAGE_OSD_ROTATE_AUTO] = n;
887 image_osd_timer_schedule(osd);
890 image_osd_icons_update(osd);
894 image_osd_icons_hide(osd);
897 if (osd->imd->il && image_loader_get_is_done(osd->imd->il))
898 osd->changed_states = IMAGE_STATE_NONE;
903 static void image_osd_update_schedule(OverlayStateData *osd, gint force)
905 if (force) osd->changed_states |= IMAGE_STATE_IMAGE;
907 if (osd->idle_id == -1)
909 osd->idle_id = g_idle_add_full(G_PRIORITY_HIGH, image_osd_update_cb, osd, NULL);
913 void image_osd_update(ImageWindow *imd)
915 OverlayStateData *osd = image_get_osd_data(imd);
919 image_osd_update_schedule(osd, TRUE);
922 static gint image_osd_timer_cb(gpointer data)
924 OverlayStateData *osd = data;
926 gint changed = FALSE;
929 for (i = 0; i < IMAGE_OSD_COUNT; i++)
931 if (osd->icon_time[i] > 1)
934 if (osd->icon_time[i] < 2)
936 osd->icon_time[i] = 0;
946 if (changed) image_osd_update_schedule(osd, FALSE);
957 static void image_osd_timer_schedule(OverlayStateData *osd)
959 if (osd->timer_id == -1)
961 osd->timer_id = g_timeout_add(100, image_osd_timer_cb, osd);
965 static void image_osd_state_cb(ImageWindow *imd, ImageState state, gpointer data)
967 OverlayStateData *osd = data;
969 osd->changed_states |= state;
970 image_osd_update_schedule(osd, FALSE);
973 static void image_osd_free(OverlayStateData *osd)
977 if (osd->idle_id != -1) g_source_remove(osd->idle_id);
978 if (osd->timer_id != -1) g_source_remove(osd->timer_id);
982 image_set_osd_data(osd->imd, NULL);
983 g_signal_handler_disconnect(osd->imd->pr, osd->destroy_id);
985 image_set_state_func(osd->imd, NULL, NULL);
987 image_osd_info_hide(osd);
988 image_osd_icons_hide(osd);
991 if (osd->histogram) histogram_free(osd->histogram);
996 static void image_osd_remove(ImageWindow *imd)
998 OverlayStateData *osd = image_get_osd_data(imd);
1000 if (osd) image_osd_free(osd);
1003 static void image_osd_destroy_cb(GtkWidget *widget, gpointer data)
1005 OverlayStateData *osd = data;
1008 image_osd_free(osd);
1011 static void image_osd_enable(ImageWindow *imd, OsdShowFlags show)
1013 OverlayStateData *osd = image_get_osd_data(imd);
1017 osd = g_new0(OverlayStateData, 1);
1021 osd->show = OSD_SHOW_NOTHING;
1022 osd->histogram = NULL;
1023 osd->x = options->image_overlay.common.x;
1024 osd->y = options->image_overlay.common.y;
1026 osd->destroy_id = g_signal_connect(G_OBJECT(imd->pr), "destroy",
1027 G_CALLBACK(image_osd_destroy_cb), osd);
1028 image_set_osd_data(imd, osd);
1030 image_set_state_func(osd->imd, image_osd_state_cb, osd);
1033 if (show & OSD_SHOW_HISTOGRAM)
1034 osd->histogram = histogram_new();
1035 else if (osd->histogram)
1037 histogram_free(osd->histogram);
1038 osd->histogram = NULL;
1041 if (show & OSD_SHOW_STATUS)
1042 image_osd_icon(imd, IMAGE_OSD_ICON, -1);
1044 if (show != osd->show)
1045 image_osd_update_schedule(osd, TRUE);
1050 void image_osd_set(ImageWindow *imd, OsdShowFlags show)
1054 if (show == OSD_SHOW_NOTHING)
1056 image_osd_remove(imd);
1060 image_osd_enable(imd, show);
1063 OsdShowFlags image_osd_get(ImageWindow *imd)
1065 OverlayStateData *osd = image_get_osd_data(imd);
1067 return osd ? osd->show : OSD_SHOW_NOTHING;
1073 2+ = show for duration tenths of a second
1074 -1 = use default duration
1076 void image_osd_icon(ImageWindow *imd, ImageOSDFlag flag, gint duration)
1078 OverlayStateData *osd = image_get_osd_data(imd);
1082 if (flag >= IMAGE_OSD_COUNT) return;
1083 if (duration < 0) duration = IMAGE_OSD_DEFAULT_DURATION;
1084 if (duration > 1) duration += 1;
1086 osd->icon_time[flag] = duration;
1088 image_osd_update_schedule(osd, FALSE);
1089 image_osd_timer_schedule(osd);
1091 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */