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 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_toggle_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);
154 if (osd->show == OSD_SHOW_NOTHING)
156 image_osd_set(imd, OSD_SHOW_INFO | OSD_SHOW_STATUS);
161 if (osd->show & OSD_SHOW_HISTOGRAM)
163 image_osd_set(imd, OSD_SHOW_NOTHING);
167 image_osd_set(imd, osd->show | OSD_SHOW_HISTOGRAM);
172 static gchar *keywords_to_string(FileData *fd)
175 GString *kwstr = NULL;
180 keywords = metadata_read_list(fd, KEYWORD_KEY, METADATA_PLAIN);
184 GList *work = keywords;
188 gchar *kw = work->data;
193 kwstr = g_string_new("");
195 g_string_append(kwstr, ", ");
197 g_string_append(kwstr, kw);
199 string_list_free(keywords);
205 g_string_free(kwstr, FALSE);
211 static gchar *image_osd_mkinfo(const gchar *str, ImageWindow *imd, GHashTable *vars)
213 gchar delim = '%', imp = '|', sep[] = " - ";
216 gboolean want_separator = FALSE;
221 if (!str || !*str) return g_strdup("");
223 new = g_string_new(str);
231 gchar *limpos = NULL;
233 gchar *extrapos = NULL;
236 start = strchr(new->str, delim);
239 end = strchr(start+1, delim);
243 /* Search for optionnal modifiers
244 * %name:99:extra% -> name = "name", limit=99, extra = "extra"
246 for (p = start + 1; p < end; p++)
250 if (g_ascii_isdigit(p[1]) && !limpos)
253 if (!trunc) trunc = p;
258 if (!trunc) trunc = p;
265 limit = (guint) atoi(limpos);
268 extra = g_strndup(extrapos, end - extrapos);
270 name = g_strndup(start+1, (trunc ? trunc : end)-start-1);
271 pos = start - new->str;
274 if (strcmp(name, "keywords") == 0)
276 data = keywords_to_string(imd->image_fd);
278 else if (strcmp(name, "comment") == 0)
280 data = metadata_read_string(imd->image_fd, COMMENT_KEY, METADATA_PLAIN);
284 data = g_strdup(g_hash_table_lookup(vars, name));
285 if (data && strcmp(name, "zoom") == 0) imd->overlay_show_zoom = TRUE;
287 data = metadata_read_string(imd->image_fd, name, METADATA_FORMATTED);
290 if (data && *data && limit > 0 && strlen(data) > limit + 3)
292 gchar *new_data = g_strdup_printf("%-*.*s...", limit, limit, data);
299 /* Since we use pango markup to display, we need to escape here */
300 gchar *escaped = g_markup_escape_text(data, -1);
309 /* Display data between left and right parts of extra string
310 * the data is expressed by a '*' character. A '*' may be escaped
311 * by a \. You should escape all '*' characters, do not rely on the
312 * current implementation which only replaces the first unescaped '*'.
313 * If no "*" is present, the extra string is just appended to data string.
314 * Pango mark up is accepted in left and right parts.
315 * Any \n is replaced by a newline
317 * "<i>*</i>\n" -> data is displayed in italics ended with a newline
318 * "\n" -> ended with newline
319 * "ISO *" -> prefix data with "ISO " (ie. "ISO 100")
320 * "\**\*" -> prefix data with a star, and append a star (ie. "*100*")
321 * "\\*" -> prefix data with an anti slash (ie "\100")
322 * "Collection <b>*</b>\n" -> display data in bold prefixed by "Collection " and a newline is appended
324 * FIXME: using background / foreground colors lead to weird results.
328 gchar *right = extra;
330 guint len = strlen(extra);
332 /* Search for left and right parts and unescape characters */
333 for (p = extra; *p; p++, len--)
338 memmove(p+1, p+2, --len);
341 else if (p[1] != '\0')
342 memmove(p, p+1, len--); // includes \0
344 else if (p[0] == '*' && !left)
350 if (left) right[-1] = '\0';
352 new_data = g_strdup_printf("%s%s%s", left ? left : "", data, right);
359 g_string_erase(new, pos, end-start+1);
364 /* insert separator */
365 g_string_insert(new, pos, sep);
367 want_separator = FALSE;
370 g_string_insert(new, pos, data);
374 if (pos-prev >= 1 && new->str[pos] == imp)
376 /* pipe character is replaced by a separator, delete it
377 * and raise a flag if needed */
378 g_string_erase(new, pos--, 1);
379 want_separator |= (data && *data);
382 if (new->str[pos] == '\n') want_separator = FALSE;
390 /* search and destroy empty lines */
392 while ((start = strchr(end, '\n')))
395 while (*++(end) == '\n')
397 g_string_erase(new, start-new->str, end-start-1);
400 g_strchomp(new->str);
403 g_string_free(new, FALSE);
414 static void osd_template_insert(GHashTable *vars, gchar *keyword, gchar *value, OsdTemplateFlags flags)
418 g_hash_table_insert(vars, keyword, g_strdup(""));
422 if (flags & OSDT_NO_DUP)
424 g_hash_table_insert(vars, keyword, value);
429 g_hash_table_insert(vars, keyword, g_strdup(value));
432 if (flags & OSDT_FREE) g_free((gpointer) value);
435 static GdkPixbuf *image_osd_info_render(OverlayStateData *osd)
437 GdkPixbuf *pixbuf = NULL;
442 GdkPixbuf *imgpixbuf = NULL;
444 const HistMap *histmap;
445 ImageWindow *imd = osd->imd;
446 FileData *fd = image_get_fd(imd);
448 if (!fd) return NULL;
450 name = image_get_name(imd);
458 vars = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
460 cd = image_get_collection(imd, &info);
463 t = g_list_length(cd->list);
464 n = g_list_index(cd->list, info) + 1;
467 if (file_extension_match(cd->name, GQ_COLLECTION_EXT))
468 osd_template_insert(vars, "collection", remove_extension_from_path(cd->name), OSDT_FREE);
470 osd_template_insert(vars, "collection", cd->name, OSDT_NONE);
474 osd_template_insert(vars, "collection", _("Untitled"), OSDT_NONE);
479 LayoutWindow *lw = layout_find_by_image(imd);
484 n = g_list_length(lw->slideshow->list_done);
485 t = n + g_list_length(lw->slideshow->list);
490 t = layout_list_count(lw, NULL);
491 n = layout_list_get_index(lw, image_get_fd(lw->image)) + 1;
494 else if (view_window_find_image(imd, &n, &t))
507 osd_template_insert(vars, "collection", NULL, OSDT_NONE);
510 osd_template_insert(vars, "number", g_strdup_printf("%d", n), OSDT_NO_DUP);
511 osd_template_insert(vars, "total", g_strdup_printf("%d", t), OSDT_NO_DUP);
512 osd_template_insert(vars, "name", (gchar *) name, OSDT_NONE);
513 osd_template_insert(vars, "date", imd->image_fd ? ((gchar *) text_from_time(imd->image_fd->date)) : "", OSDT_NONE);
514 osd_template_insert(vars, "size", imd->image_fd ? (text_from_size_abrev(imd->image_fd->size)) : g_strdup(""), OSDT_FREE);
515 osd_template_insert(vars, "zoom", image_zoom_get_as_text(imd), OSDT_FREE);
520 GdkPixbuf *load_pixbuf = image_loader_get_pixbuf(imd->il);
522 if (imd->delay_flip &&
523 imd->il && load_pixbuf &&
524 image_get_pixbuf(imd) != load_pixbuf)
526 w = gdk_pixbuf_get_width(load_pixbuf);
527 h = gdk_pixbuf_get_height(load_pixbuf);
528 imgpixbuf = load_pixbuf;
532 image_get_image_size(imd, &w, &h);
533 imgpixbuf = (PIXBUF_RENDERER(imd->pr))->pixbuf;
537 osd_template_insert(vars, "width", g_strdup_printf("%d", w), OSDT_NO_DUP);
538 osd_template_insert(vars, "height", g_strdup_printf("%d", h), OSDT_NO_DUP);
539 osd_template_insert(vars, "res", g_strdup_printf("%d × %d", w, h), OSDT_FREE);
543 osd_template_insert(vars, "width", NULL, OSDT_NONE);
544 osd_template_insert(vars, "height", NULL, OSDT_NONE);
545 osd_template_insert(vars, "res", NULL, OSDT_NONE);
548 text = image_osd_mkinfo(options->image_overlay.template_string, imd, vars);
549 g_hash_table_destroy(vars);
552 /* When does this occur ?? */
553 text = g_markup_escape_text(_("Untitled"), -1);
556 with_hist = ((osd->show & OSD_SHOW_HISTOGRAM) && osd->histogram);
559 histmap = histmap_get(imd->image_fd);
560 if (!histmap) with_hist = FALSE;
565 gint active_marks = 0;
569 for (mark = 0; mark < FILEDATA_MARKS_SIZE; mark++)
571 active_marks += file_data_get_mark(fd, mark);
574 if (active_marks > 0)
576 GString *buf = g_string_sized_new(FILEDATA_MARKS_SIZE * 2);
578 for (mark = 0; mark < FILEDATA_MARKS_SIZE; mark++)
580 g_string_append_printf(buf, file_data_get_mark(fd, mark) ? " <span background='#FF00FF'>%c</span>" : " %c", '1' + mark);
584 text2 = g_strdup_printf("%s\n%s", text, buf->str);
586 text2 = g_strdup(buf->str);
587 g_string_free(buf, TRUE);
594 gchar *escaped_histogram_label = g_markup_escape_text(histogram_label(osd->histogram), -1);
596 text2 = g_strdup_printf("%s\n%s", text, escaped_histogram_label);
598 text2 = g_strdup(escaped_histogram_label);
599 g_free(escaped_histogram_label);
605 layout = gtk_widget_create_pango_layout(imd->pr, NULL);
606 pango_layout_set_markup(layout, text, -1);
609 pango_layout_get_pixel_size(layout, &width, &height);
610 /* with empty text width is set to 0, but not height) */
613 else if (height == 0)
615 if (width > 0) width += 10;
616 if (height > 0) height += 10;
620 if (width < HISTOGRAM_WIDTH + 10) width = HISTOGRAM_WIDTH + 10;
621 height += HISTOGRAM_HEIGHT + 5;
624 if (width > 0 && height > 0)
626 /* TODO: make osd color configurable --Zas */
627 pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height);
628 pixbuf_set_rect_fill(pixbuf, 3, 3, width-6, height-6, 240, 240, 240, 210);
629 pixbuf_set_rect(pixbuf, 0, 0, width, height, 240, 240, 240, 80, 1, 1, 1, 1);
630 pixbuf_set_rect(pixbuf, 1, 1, width-2, height-2, 240, 240, 240, 130, 1, 1, 1, 1);
631 pixbuf_set_rect(pixbuf, 2, 2, width-4, height-4, 240, 240, 240, 180, 1, 1, 1, 1);
632 pixbuf_pixel_set(pixbuf, 0, 0, 0, 0, 0, 0);
633 pixbuf_pixel_set(pixbuf, width - 1, 0, 0, 0, 0, 0);
634 pixbuf_pixel_set(pixbuf, 0, height - 1, 0, 0, 0, 0);
635 pixbuf_pixel_set(pixbuf, width - 1, height - 1, 0, 0, 0, 0);
640 gint y = height - HISTOGRAM_HEIGHT - 5;
643 pixbuf_set_rect_fill(pixbuf, x, y, w, HISTOGRAM_HEIGHT, 220, 220, 220, 210);
644 histogram_draw(osd->histogram, histmap, pixbuf, x, y, w, HISTOGRAM_HEIGHT);
646 pixbuf_draw_layout(pixbuf, layout, imd->pr, 5, 5, 0, 0, 0, 255);
649 g_object_unref(G_OBJECT(layout));
654 static GdkPixbuf *image_osd_icon_pixbuf(ImageOSDFlag flag)
656 static GdkPixbuf **icons = NULL;
657 GdkPixbuf *icon = NULL;
659 if (!icons) icons = g_new0(GdkPixbuf *, IMAGE_OSD_COUNT);
660 if (icons[flag]) return icons[flag];
662 if (osd_icons[flag].key)
664 icon = pixbuf_inline(osd_icons[flag].key);
669 icon = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 24, 24);
670 pixbuf_set_rect_fill(icon, 1, 1, 22, 22, 255, 255, 255, 200);
671 pixbuf_set_rect(icon, 0, 0, 24, 24, 0, 0, 0, 128, 1, 1, 1, 1);
674 case IMAGE_OSD_ROTATE_AUTO:
675 pixbuf_set_rect(icon, 3, 8, 11, 12,
678 pixbuf_draw_triangle(icon, 14, 3, 6, 12,
679 20, 9, 14, 15, 14, 3,
682 case IMAGE_OSD_ROTATE_USER:
684 case IMAGE_OSD_COLOR:
685 pixbuf_set_rect_fill(icon, 3, 3, 18, 6, 200, 0, 0, 255);
686 pixbuf_set_rect_fill(icon, 3, 9, 18, 6, 0, 200, 0, 255);
687 pixbuf_set_rect_fill(icon, 3, 15, 18, 6, 0, 0, 200, 255);
689 case IMAGE_OSD_FIRST:
690 pixbuf_set_rect(icon, 3, 3, 18, 18, 0, 0, 0, 200, 3, 3, 3, 0);
691 pixbuf_draw_triangle(icon, 6, 5, 12, 6,
692 12, 5, 18, 11, 6, 11,
696 pixbuf_set_rect(icon, 3, 3, 18, 18, 0, 0, 0, 200, 3, 3, 0, 3);
697 pixbuf_draw_triangle(icon, 6, 12, 12, 6,
698 12, 18, 6, 12, 18, 12,
702 pixbuf_set_rect_fill(icon, 11, 3, 3, 12, 0, 0, 0, 255);
703 pixbuf_set_rect_fill(icon, 11, 17, 3, 3, 0, 0, 0, 255);
715 static gint image_overlay_add(ImageWindow *imd, GdkPixbuf *pixbuf, gint x, gint y,
716 OverlayRendererFlags flags)
718 return pixbuf_renderer_overlay_add((PixbufRenderer *)imd->pr, pixbuf, x, y, flags);
721 static void image_overlay_set(ImageWindow *imd, gint id, GdkPixbuf *pixbuf, gint x, gint y)
723 pixbuf_renderer_overlay_set((PixbufRenderer *)imd->pr, id, pixbuf, x, y);
726 #if 0 /* unused for now */
727 static gint image_overlay_get(ImageWindow *imd, gint id, GdkPixbuf **pixbuf, gint *x, gint *y)
729 return pixbuf_renderer_overlay_get((PixbufRenderer *)imd->pr, id, pixbuf, x, y);
733 static void image_overlay_remove(ImageWindow *imd, gint id)
735 pixbuf_renderer_overlay_remove((PixbufRenderer *)imd->pr, id);
738 static void image_osd_icon_show(OverlayStateData *osd, ImageOSDFlag flag)
742 if (osd->icon_id[flag]) return;
744 pixbuf = image_osd_icon_pixbuf(flag);
747 osd->icon_id[flag] = image_overlay_add(osd->imd, pixbuf,
748 osd_icons[flag].x, osd_icons[flag].y,
752 static void image_osd_icon_hide(OverlayStateData *osd, ImageOSDFlag flag)
754 if (osd->icon_id[flag])
756 image_overlay_remove(osd->imd, osd->icon_id[flag]);
757 osd->icon_id[flag] = 0;
761 static void image_osd_icons_reset_time(OverlayStateData *osd)
765 for (i = 0; i < IMAGE_OSD_COUNT; i++)
767 if (osd_icons[i].reset)
769 osd->icon_time[i] = 0;
774 static void image_osd_icons_update(OverlayStateData *osd)
778 for (i = 0; i < IMAGE_OSD_COUNT; i++)
780 if (osd->icon_time[i] > 0)
782 image_osd_icon_show(osd, i);
786 image_osd_icon_hide(osd, i);
791 static void image_osd_icons_hide(OverlayStateData *osd)
795 for (i = 0; i < IMAGE_OSD_COUNT; i++)
797 image_osd_icon_hide(osd, i);
801 static void image_osd_info_show(OverlayStateData *osd, GdkPixbuf *pixbuf)
803 if (osd->ovl_info == 0)
805 osd->ovl_info = image_overlay_add(osd->imd, pixbuf, osd->x, osd->y, OVL_RELATIVE);
809 image_overlay_set(osd->imd, osd->ovl_info, pixbuf, osd->x, osd->y);
813 static void image_osd_info_hide(OverlayStateData *osd)
815 if (osd->ovl_info == 0) return;
817 image_overlay_remove(osd->imd, osd->ovl_info);
821 static gint image_osd_update_cb(gpointer data)
823 OverlayStateData *osd = data;
825 osd->imd->overlay_show_zoom = FALSE;
827 if (osd->show & OSD_SHOW_INFO)
829 /* redraw when the image was changed,
830 with histogram we have to redraw also when loading is finished */
831 if (osd->changed_states & IMAGE_STATE_IMAGE ||
832 (osd->changed_states & IMAGE_STATE_LOADING && osd->show & OSD_SHOW_HISTOGRAM))
836 pixbuf = image_osd_info_render(osd);
839 image_osd_info_show(osd, pixbuf);
840 g_object_unref(pixbuf);
844 image_osd_info_hide(osd);
850 image_osd_info_hide(osd);
853 if (osd->show & OSD_SHOW_STATUS)
855 if (osd->changed_states & IMAGE_STATE_IMAGE)
856 image_osd_icons_reset_time(osd);
858 if (osd->changed_states & IMAGE_STATE_COLOR_ADJ)
860 osd->icon_time[IMAGE_OSD_COLOR] = IMAGE_OSD_DEFAULT_DURATION + 1;
861 image_osd_timer_schedule(osd);
864 if (osd->changed_states & IMAGE_STATE_ROTATE_AUTO)
868 if (osd->imd->state & IMAGE_STATE_ROTATE_AUTO)
871 if (!osd->imd->cm) n += IMAGE_OSD_DEFAULT_DURATION;
874 osd->icon_time[IMAGE_OSD_ROTATE_AUTO] = n;
875 image_osd_timer_schedule(osd);
878 image_osd_icons_update(osd);
882 image_osd_icons_hide(osd);
885 if (osd->imd->il && image_loader_get_is_done(osd->imd->il))
886 osd->changed_states = IMAGE_STATE_NONE;
891 static void image_osd_update_schedule(OverlayStateData *osd, gint force)
893 if (force) osd->changed_states |= IMAGE_STATE_IMAGE;
895 if (osd->idle_id == -1)
897 osd->idle_id = g_idle_add_full(G_PRIORITY_HIGH, image_osd_update_cb, osd, NULL);
901 void image_osd_update(ImageWindow *imd)
903 OverlayStateData *osd = image_get_osd_data(imd);
907 image_osd_update_schedule(osd, TRUE);
910 static gint image_osd_timer_cb(gpointer data)
912 OverlayStateData *osd = data;
914 gint changed = FALSE;
917 for (i = 0; i < IMAGE_OSD_COUNT; i++)
919 if (osd->icon_time[i] > 1)
922 if (osd->icon_time[i] < 2)
924 osd->icon_time[i] = 0;
934 if (changed) image_osd_update_schedule(osd, FALSE);
945 static void image_osd_timer_schedule(OverlayStateData *osd)
947 if (osd->timer_id == -1)
949 osd->timer_id = g_timeout_add(100, image_osd_timer_cb, osd);
953 static void image_osd_state_cb(ImageWindow *imd, ImageState state, gpointer data)
955 OverlayStateData *osd = data;
957 osd->changed_states |= state;
958 image_osd_update_schedule(osd, FALSE);
961 static void image_osd_free(OverlayStateData *osd)
965 if (osd->idle_id != -1) g_source_remove(osd->idle_id);
966 if (osd->timer_id != -1) g_source_remove(osd->timer_id);
970 image_set_osd_data(osd->imd, NULL);
971 g_signal_handler_disconnect(osd->imd->pr, osd->destroy_id);
973 image_set_state_func(osd->imd, NULL, NULL);
975 image_osd_info_hide(osd);
976 image_osd_icons_hide(osd);
979 if (osd->histogram) histogram_free(osd->histogram);
984 static void image_osd_remove(ImageWindow *imd)
986 OverlayStateData *osd = image_get_osd_data(imd);
988 if (osd) image_osd_free(osd);
991 static void image_osd_destroy_cb(GtkWidget *widget, gpointer data)
993 OverlayStateData *osd = data;
999 static void image_osd_enable(ImageWindow *imd, OsdShowFlags show)
1001 OverlayStateData *osd = image_get_osd_data(imd);
1005 osd = g_new0(OverlayStateData, 1);
1009 osd->show = OSD_SHOW_NOTHING;
1010 osd->histogram = NULL;
1011 osd->x = options->image_overlay.x;
1012 osd->y = options->image_overlay.y;
1014 osd->histogram = histogram_new();
1016 osd->destroy_id = g_signal_connect(G_OBJECT(imd->pr), "destroy",
1017 G_CALLBACK(image_osd_destroy_cb), osd);
1018 image_set_osd_data(imd, osd);
1020 image_set_state_func(osd->imd, image_osd_state_cb, osd);
1023 if (show & OSD_SHOW_STATUS)
1024 image_osd_icon(imd, IMAGE_OSD_ICON, -1);
1026 if (show != osd->show)
1027 image_osd_update_schedule(osd, TRUE);
1032 void image_osd_set(ImageWindow *imd, OsdShowFlags show)
1036 image_osd_enable(imd, show);
1039 OsdShowFlags image_osd_get(ImageWindow *imd)
1041 OverlayStateData *osd = image_get_osd_data(imd);
1043 return osd ? osd->show : OSD_SHOW_NOTHING;
1046 Histogram *image_osd_get_histogram(ImageWindow *imd)
1048 OverlayStateData *osd = image_get_osd_data(imd);
1050 return osd ? osd->histogram : NULL;
1053 void image_osd_copy_status(ImageWindow *src, ImageWindow *dest)
1055 Histogram *h_src, *h_dest;
1056 image_osd_set(dest, image_osd_get(src));
1058 h_src = image_osd_get_histogram(src);
1059 h_dest = image_osd_get_histogram(dest);
1061 h_dest->histogram_mode = h_src->histogram_mode;
1062 h_dest->histogram_channel = h_src->histogram_channel;
1069 2+ = show for duration tenths of a second
1070 -1 = use default duration
1072 void image_osd_icon(ImageWindow *imd, ImageOSDFlag flag, gint duration)
1074 OverlayStateData *osd = image_get_osd_data(imd);
1078 if (flag >= IMAGE_OSD_COUNT) return;
1079 if (duration < 0) duration = IMAGE_OSD_DEFAULT_DURATION;
1080 if (duration > 1) duration += 1;
1082 osd->icon_time[flag] = duration;
1084 image_osd_update_schedule(osd, FALSE);
1085 image_osd_timer_schedule(osd);
1087 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */