4 * Copyright (C) 2008 - 2012 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;
51 gint icon_time[IMAGE_OSD_COUNT];
52 gint icon_id[IMAGE_OSD_COUNT];
54 guint idle_id; /* event source id */
55 guint timer_id; /* event source id */
60 typedef struct _OSDIcon OSDIcon;
62 gboolean reset; /* reset on new image */
63 gint x; /* x, y offset */
65 gchar *key; /* inline pixbuf */
68 static OSDIcon osd_icons[] = {
69 { TRUE, 0, 0, NULL }, /* none */
70 { TRUE, -10, -10, NULL }, /* auto rotated */
71 { TRUE, -10, -10, NULL }, /* user rotated */
72 { TRUE, -40, -10, NULL }, /* color embedded */
73 { TRUE, -70, -10, NULL }, /* first image */
74 { TRUE, -70, -10, NULL }, /* last image */
75 { FALSE, -70, -10, NULL }, /* osd enabled */
79 #define OSD_DATA "overlay-data"
81 #define IMAGE_OSD_DEFAULT_DURATION 30
83 #define HISTOGRAM_HEIGHT 140
84 #define HISTOGRAM_WIDTH 256
86 static void image_osd_timer_schedule(OverlayStateData *osd);
88 void set_image_overlay_template_string(gchar **template_string, const gchar *value)
90 g_assert(template_string);
92 g_free(*template_string);
93 *template_string = g_strdup(value);
97 void set_default_image_overlay_template_string(gchar **template_string)
99 set_image_overlay_template_string(template_string, DEFAULT_OVERLAY_INFO);
102 static OverlayStateData *image_get_osd_data(ImageWindow *imd)
104 OverlayStateData *osd;
106 if (!imd) return NULL;
110 osd = g_object_get_data(G_OBJECT(imd->pr), "IMAGE_OVERLAY_DATA");
114 static void image_set_osd_data(ImageWindow *imd, OverlayStateData *osd)
118 g_object_set_data(G_OBJECT(imd->pr), "IMAGE_OVERLAY_DATA", osd);
122 *----------------------------------------------------------------------------
124 *----------------------------------------------------------------------------
128 void image_osd_histogram_toggle_channel(ImageWindow *imd)
130 OverlayStateData *osd = image_get_osd_data(imd);
132 if (!osd || !osd->histogram) return;
134 histogram_toggle_channel(osd->histogram);
135 image_osd_update(imd);
138 void image_osd_histogram_toggle_mode(ImageWindow *imd)
140 OverlayStateData *osd = image_get_osd_data(imd);
142 if (!osd || !osd->histogram) return;
144 histogram_toggle_mode(osd->histogram);
145 image_osd_update(imd);
148 void image_osd_histogram_set_channel(ImageWindow *imd, gint chan)
150 OverlayStateData *osd = image_get_osd_data(imd);
152 if (!osd || !osd->histogram) return;
154 histogram_set_channel(osd->histogram, chan);
155 image_osd_update(imd);
158 void image_osd_histogram_set_mode(ImageWindow *imd, gint mode)
160 OverlayStateData *osd = image_get_osd_data(imd);
162 if (!osd || !osd->histogram) return;
164 histogram_set_mode(osd->histogram, mode);
165 image_osd_update(imd);
168 gint image_osd_histogram_get_channel(ImageWindow *imd)
170 OverlayStateData *osd = image_get_osd_data(imd);
172 if (!osd || !osd->histogram) return HCHAN_DEFAULT;
174 return histogram_get_channel(osd->histogram);
177 gint image_osd_histogram_get_mode(ImageWindow *imd)
179 OverlayStateData *osd = image_get_osd_data(imd);
181 if (!osd || !osd->histogram) return 0;
183 return histogram_get_mode(osd->histogram);
186 void image_osd_toggle(ImageWindow *imd)
192 show = image_osd_get(imd);
193 if (show == OSD_SHOW_NOTHING)
195 image_osd_set(imd, OSD_SHOW_INFO | OSD_SHOW_STATUS);
200 if (show & OSD_SHOW_HISTOGRAM)
202 image_osd_set(imd, OSD_SHOW_NOTHING);
206 image_osd_set(imd, show | OSD_SHOW_HISTOGRAM);
211 static gchar *keywords_to_string(FileData *fd)
214 GString *kwstr = NULL;
219 keywords = metadata_read_list(fd, KEYWORD_KEY, METADATA_PLAIN);
223 GList *work = keywords;
227 gchar *kw = work->data;
232 kwstr = g_string_new("");
234 g_string_append(kwstr, ", ");
236 g_string_append(kwstr, kw);
238 string_list_free(keywords);
244 g_string_free(kwstr, FALSE);
250 static gchar *image_osd_mkinfo(const gchar *str, ImageWindow *imd, GHashTable *vars)
252 gchar delim = '%', imp = '|', sep[] = " - ";
255 gboolean want_separator = FALSE;
260 if (!str || !*str) return g_strdup("");
262 new = g_string_new(str);
270 gchar *limpos = NULL;
272 gchar *extrapos = NULL;
275 start = strchr(new->str, delim);
278 end = strchr(start+1, delim);
282 /* Search for optionnal modifiers
283 * %name:99:extra% -> name = "name", limit=99, extra = "extra"
285 for (p = start + 1; p < end; p++)
289 if (g_ascii_isdigit(p[1]) && !limpos)
292 if (!trunc) trunc = p;
297 if (!trunc) trunc = p;
304 limit = (guint) atoi(limpos);
307 extra = g_strndup(extrapos, end - extrapos);
309 name = g_strndup(start+1, (trunc ? trunc : end)-start-1);
310 pos = start - new->str;
313 if (strcmp(name, "keywords") == 0)
315 data = keywords_to_string(imd->image_fd);
317 else if (strcmp(name, "comment") == 0)
319 data = metadata_read_string(imd->image_fd, COMMENT_KEY, METADATA_PLAIN);
323 data = g_strdup(g_hash_table_lookup(vars, name));
325 data = metadata_read_string(imd->image_fd, name, METADATA_FORMATTED);
328 if (data && *data && limit > 0 && strlen(data) > limit + 3)
330 gchar *new_data = g_strdup_printf("%-*.*s...", limit, limit, data);
337 /* Since we use pango markup to display, we need to escape here */
338 gchar *escaped = g_markup_escape_text(data, -1);
347 /* Display data between left and right parts of extra string
348 * the data is expressed by a '*' character. A '*' may be escaped
349 * by a \. You should escape all '*' characters, do not rely on the
350 * current implementation which only replaces the first unescaped '*'.
351 * If no "*" is present, the extra string is just appended to data string.
352 * Pango mark up is accepted in left and right parts.
353 * Any \n is replaced by a newline
355 * "<i>*</i>\n" -> data is displayed in italics ended with a newline
356 * "\n" -> ended with newline
357 * "ISO *" -> prefix data with "ISO " (ie. "ISO 100")
358 * "\**\*" -> prefix data with a star, and append a star (ie. "*100*")
359 * "\\*" -> prefix data with an anti slash (ie "\100")
360 * "Collection <b>*</b>\n" -> display data in bold prefixed by "Collection " and a newline is appended
362 * FIXME: using background / foreground colors lead to weird results.
366 gchar *right = extra;
368 guint len = strlen(extra);
370 /* Search for left and right parts and unescape characters */
371 for (p = extra; *p; p++, len--)
376 memmove(p+1, p+2, --len);
379 else if (p[1] != '\0')
380 memmove(p, p+1, len--); // includes \0
382 else if (p[0] == '*' && !left)
388 if (left) right[-1] = '\0';
390 new_data = g_strdup_printf("%s%s%s", left ? left : "", data, right);
397 g_string_erase(new, pos, end-start+1);
402 /* insert separator */
403 g_string_insert(new, pos, sep);
405 want_separator = FALSE;
408 g_string_insert(new, pos, data);
412 if (pos-prev >= 1 && new->str[pos] == imp)
414 /* pipe character is replaced by a separator, delete it
415 * and raise a flag if needed */
416 g_string_erase(new, pos--, 1);
417 want_separator |= (data && *data);
420 if (new->str[pos] == '\n') want_separator = FALSE;
428 /* search and destroy empty lines */
430 while ((start = strchr(end, '\n')))
433 while (*++(end) == '\n')
435 g_string_erase(new, start-new->str, end-start-1);
438 g_strchomp(new->str);
441 g_string_free(new, FALSE);
452 static void osd_template_insert(GHashTable *vars, gchar *keyword, gchar *value, OsdTemplateFlags flags)
456 g_hash_table_insert(vars, keyword, g_strdup(""));
460 if (flags & OSDT_NO_DUP)
462 g_hash_table_insert(vars, keyword, value);
467 g_hash_table_insert(vars, keyword, g_strdup(value));
470 if (flags & OSDT_FREE) g_free((gpointer) value);
473 static GdkPixbuf *image_osd_info_render(OverlayStateData *osd)
475 GdkPixbuf *pixbuf = NULL;
481 const HistMap *histmap = NULL;
482 ImageWindow *imd = osd->imd;
483 FileData *fd = image_get_fd(imd);
485 if (!fd) return NULL;
487 name = image_get_name(imd);
495 vars = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
497 cd = image_get_collection(imd, &info);
500 t = g_list_length(cd->list);
501 n = g_list_index(cd->list, info) + 1;
504 if (file_extension_match(cd->name, GQ_COLLECTION_EXT))
505 osd_template_insert(vars, "collection", remove_extension_from_path(cd->name), OSDT_FREE);
507 osd_template_insert(vars, "collection", cd->name, OSDT_NONE);
511 osd_template_insert(vars, "collection", _("Untitled"), OSDT_NONE);
516 LayoutWindow *lw = layout_find_by_image(imd);
521 n = g_list_length(lw->slideshow->list_done);
522 t = n + g_list_length(lw->slideshow->list);
527 t = layout_list_count(lw, NULL);
528 n = layout_list_get_index(lw, image_get_fd(lw->image)) + 1;
531 else if (view_window_find_image(imd, &n, &t))
544 osd_template_insert(vars, "collection", NULL, OSDT_NONE);
547 osd_template_insert(vars, "number", g_strdup_printf("%d", n), OSDT_NO_DUP);
548 osd_template_insert(vars, "total", g_strdup_printf("%d", t), OSDT_NO_DUP);
549 osd_template_insert(vars, "name", (gchar *) name, OSDT_NONE);
550 osd_template_insert(vars, "date", imd->image_fd ? ((gchar *) text_from_time(imd->image_fd->date)) : "", OSDT_NONE);
551 osd_template_insert(vars, "size", imd->image_fd ? (text_from_size_abrev(imd->image_fd->size)) : g_strdup(""), OSDT_FREE);
552 osd_template_insert(vars, "zoom", image_zoom_get_as_text(imd), OSDT_FREE);
557 GdkPixbuf *load_pixbuf = image_loader_get_pixbuf(imd->il);
559 if (imd->delay_flip &&
560 imd->il && load_pixbuf &&
561 image_get_pixbuf(imd) != load_pixbuf)
563 w = gdk_pixbuf_get_width(load_pixbuf);
564 h = gdk_pixbuf_get_height(load_pixbuf);
568 image_get_image_size(imd, &w, &h);
572 osd_template_insert(vars, "width", g_strdup_printf("%d", w), OSDT_NO_DUP);
573 osd_template_insert(vars, "height", g_strdup_printf("%d", h), OSDT_NO_DUP);
574 osd_template_insert(vars, "res", g_strdup_printf("%d × %d", w, h), OSDT_FREE);
578 osd_template_insert(vars, "width", NULL, OSDT_NONE);
579 osd_template_insert(vars, "height", NULL, OSDT_NONE);
580 osd_template_insert(vars, "res", NULL, OSDT_NONE);
583 text = image_osd_mkinfo(options->image_overlay.template_string, imd, vars);
584 g_hash_table_destroy(vars);
587 /* When does this occur ?? */
588 text = g_markup_escape_text(_("Untitled"), -1);
591 with_hist = ((osd->show & OSD_SHOW_HISTOGRAM) && osd->histogram);
594 histmap = histmap_get(imd->image_fd);
597 histmap_start_idle(imd->image_fd);
604 gint active_marks = 0;
608 for (mark = 0; mark < FILEDATA_MARKS_SIZE; mark++)
610 active_marks += file_data_get_mark(fd, mark);
613 if (active_marks > 0)
615 GString *buf = g_string_sized_new(FILEDATA_MARKS_SIZE * 2);
617 for (mark = 0; mark < FILEDATA_MARKS_SIZE; mark++)
619 g_string_append_printf(buf, file_data_get_mark(fd, mark) ? " <span background='#FF00FF'>%c</span>" : " %c", '1' + mark);
623 text2 = g_strdup_printf("%s\n%s", text, buf->str);
625 text2 = g_strdup(buf->str);
626 g_string_free(buf, TRUE);
633 gchar *escaped_histogram_label = g_markup_escape_text(histogram_label(osd->histogram), -1);
635 text2 = g_strdup_printf("%s\n%s", text, escaped_histogram_label);
637 text2 = g_strdup(escaped_histogram_label);
638 g_free(escaped_histogram_label);
644 layout = gtk_widget_create_pango_layout(imd->pr, NULL);
645 pango_layout_set_markup(layout, text, -1);
648 pango_layout_get_pixel_size(layout, &width, &height);
649 /* with empty text width is set to 0, but not height) */
652 else if (height == 0)
654 if (width > 0) width += 10;
655 if (height > 0) height += 10;
659 if (width < HISTOGRAM_WIDTH + 10) width = HISTOGRAM_WIDTH + 10;
660 height += HISTOGRAM_HEIGHT + 5;
663 if (width > 0 && height > 0)
665 /* TODO: make osd color configurable --Zas */
666 pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height);
667 pixbuf_set_rect_fill(pixbuf, 3, 3, width-6, height-6, 240, 240, 240, 210);
668 pixbuf_set_rect(pixbuf, 0, 0, width, height, 240, 240, 240, 80, 1, 1, 1, 1);
669 pixbuf_set_rect(pixbuf, 1, 1, width-2, height-2, 240, 240, 240, 130, 1, 1, 1, 1);
670 pixbuf_set_rect(pixbuf, 2, 2, width-4, height-4, 240, 240, 240, 180, 1, 1, 1, 1);
671 pixbuf_pixel_set(pixbuf, 0, 0, 0, 0, 0, 0);
672 pixbuf_pixel_set(pixbuf, width - 1, 0, 0, 0, 0, 0);
673 pixbuf_pixel_set(pixbuf, 0, height - 1, 0, 0, 0, 0);
674 pixbuf_pixel_set(pixbuf, width - 1, height - 1, 0, 0, 0, 0);
679 gint y = height - HISTOGRAM_HEIGHT - 5;
682 pixbuf_set_rect_fill(pixbuf, x, y, w, HISTOGRAM_HEIGHT, 220, 220, 220, 210);
683 histogram_draw(osd->histogram, histmap, pixbuf, x, y, w, HISTOGRAM_HEIGHT);
685 pixbuf_draw_layout(pixbuf, layout, imd->pr, 5, 5, 0, 0, 0, 255);
688 g_object_unref(G_OBJECT(layout));
693 static GdkPixbuf *image_osd_icon_pixbuf(ImageOSDFlag flag)
695 static GdkPixbuf **icons = NULL;
696 GdkPixbuf *icon = NULL;
698 if (!icons) icons = g_new0(GdkPixbuf *, IMAGE_OSD_COUNT);
699 if (icons[flag]) return icons[flag];
701 if (osd_icons[flag].key)
703 icon = pixbuf_inline(osd_icons[flag].key);
708 icon = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 24, 24);
709 pixbuf_set_rect_fill(icon, 1, 1, 22, 22, 255, 255, 255, 200);
710 pixbuf_set_rect(icon, 0, 0, 24, 24, 0, 0, 0, 128, 1, 1, 1, 1);
713 case IMAGE_OSD_ROTATE_AUTO:
714 pixbuf_set_rect(icon, 3, 8, 11, 12,
717 pixbuf_draw_triangle(icon, 14, 3, 6, 12,
718 20, 9, 14, 15, 14, 3,
721 case IMAGE_OSD_ROTATE_USER:
723 case IMAGE_OSD_COLOR:
724 pixbuf_set_rect_fill(icon, 3, 3, 18, 6, 200, 0, 0, 255);
725 pixbuf_set_rect_fill(icon, 3, 9, 18, 6, 0, 200, 0, 255);
726 pixbuf_set_rect_fill(icon, 3, 15, 18, 6, 0, 0, 200, 255);
728 case IMAGE_OSD_FIRST:
729 pixbuf_set_rect(icon, 3, 3, 18, 18, 0, 0, 0, 200, 3, 3, 3, 0);
730 pixbuf_draw_triangle(icon, 6, 5, 12, 6,
731 12, 5, 18, 11, 6, 11,
735 pixbuf_set_rect(icon, 3, 3, 18, 18, 0, 0, 0, 200, 3, 3, 0, 3);
736 pixbuf_draw_triangle(icon, 6, 12, 12, 6,
737 12, 18, 6, 12, 18, 12,
741 pixbuf_set_rect_fill(icon, 11, 3, 3, 12, 0, 0, 0, 255);
742 pixbuf_set_rect_fill(icon, 11, 17, 3, 3, 0, 0, 0, 255);
754 static gint image_overlay_add(ImageWindow *imd, GdkPixbuf *pixbuf, gint x, gint y,
755 OverlayRendererFlags flags)
757 return pixbuf_renderer_overlay_add((PixbufRenderer *)imd->pr, pixbuf, x, y, flags);
760 static void image_overlay_set(ImageWindow *imd, gint id, GdkPixbuf *pixbuf, gint x, gint y)
762 pixbuf_renderer_overlay_set((PixbufRenderer *)imd->pr, id, pixbuf, x, y);
765 static void image_overlay_remove(ImageWindow *imd, gint id)
767 pixbuf_renderer_overlay_remove((PixbufRenderer *)imd->pr, id);
770 static void image_osd_icon_show(OverlayStateData *osd, ImageOSDFlag flag)
774 if (osd->icon_id[flag]) return;
776 pixbuf = image_osd_icon_pixbuf(flag);
779 osd->icon_id[flag] = image_overlay_add(osd->imd, pixbuf,
780 osd_icons[flag].x, osd_icons[flag].y,
784 static void image_osd_icon_hide(OverlayStateData *osd, ImageOSDFlag flag)
786 if (osd->icon_id[flag])
788 image_overlay_remove(osd->imd, osd->icon_id[flag]);
789 osd->icon_id[flag] = 0;
793 static void image_osd_icons_reset_time(OverlayStateData *osd)
797 for (i = 0; i < IMAGE_OSD_COUNT; i++)
799 if (osd_icons[i].reset)
801 osd->icon_time[i] = 0;
806 static void image_osd_icons_update(OverlayStateData *osd)
810 for (i = 0; i < IMAGE_OSD_COUNT; i++)
812 if (osd->icon_time[i] > 0)
814 image_osd_icon_show(osd, i);
818 image_osd_icon_hide(osd, i);
823 static void image_osd_icons_hide(OverlayStateData *osd)
827 for (i = 0; i < IMAGE_OSD_COUNT; i++)
829 image_osd_icon_hide(osd, i);
833 static void image_osd_info_show(OverlayStateData *osd, GdkPixbuf *pixbuf)
835 if (osd->ovl_info == 0)
837 osd->ovl_info = image_overlay_add(osd->imd, pixbuf, osd->x, osd->y, OVL_RELATIVE);
841 image_overlay_set(osd->imd, osd->ovl_info, pixbuf, osd->x, osd->y);
845 static void image_osd_info_hide(OverlayStateData *osd)
847 if (osd->ovl_info == 0) return;
849 image_overlay_remove(osd->imd, osd->ovl_info);
853 static gboolean image_osd_update_cb(gpointer data)
855 OverlayStateData *osd = data;
857 if (osd->show & OSD_SHOW_INFO)
859 /* redraw when the image was changed,
860 with histogram we have to redraw also when loading is finished */
861 if (osd->changed_states & IMAGE_STATE_IMAGE ||
862 (osd->changed_states & IMAGE_STATE_LOADING && osd->show & OSD_SHOW_HISTOGRAM) ||
863 osd->notify & NOTIFY_HISTMAP)
867 pixbuf = image_osd_info_render(osd);
870 image_osd_info_show(osd, pixbuf);
871 g_object_unref(pixbuf);
875 image_osd_info_hide(osd);
881 image_osd_info_hide(osd);
884 if (osd->show & OSD_SHOW_STATUS)
886 if (osd->changed_states & IMAGE_STATE_IMAGE)
887 image_osd_icons_reset_time(osd);
889 if (osd->changed_states & IMAGE_STATE_COLOR_ADJ)
891 osd->icon_time[IMAGE_OSD_COLOR] = IMAGE_OSD_DEFAULT_DURATION + 1;
892 image_osd_timer_schedule(osd);
895 if (osd->changed_states & IMAGE_STATE_ROTATE_AUTO)
899 if (osd->imd->state & IMAGE_STATE_ROTATE_AUTO)
902 if (!osd->imd->cm) n += IMAGE_OSD_DEFAULT_DURATION;
905 osd->icon_time[IMAGE_OSD_ROTATE_AUTO] = n;
906 image_osd_timer_schedule(osd);
909 image_osd_icons_update(osd);
913 image_osd_icons_hide(osd);
916 osd->changed_states = IMAGE_STATE_NONE;
922 static void image_osd_update_schedule(OverlayStateData *osd, gboolean force)
924 if (force) osd->changed_states |= IMAGE_STATE_IMAGE;
928 osd->idle_id = g_idle_add_full(G_PRIORITY_HIGH, image_osd_update_cb, osd, NULL);
932 void image_osd_update(ImageWindow *imd)
934 OverlayStateData *osd = image_get_osd_data(imd);
938 image_osd_update_schedule(osd, TRUE);
941 static gboolean image_osd_timer_cb(gpointer data)
943 OverlayStateData *osd = data;
944 gboolean done = TRUE;
945 gboolean changed = FALSE;
948 for (i = 0; i < IMAGE_OSD_COUNT; i++)
950 if (osd->icon_time[i] > 1)
953 if (osd->icon_time[i] < 2)
955 osd->icon_time[i] = 0;
965 if (changed) image_osd_update_schedule(osd, FALSE);
976 static void image_osd_timer_schedule(OverlayStateData *osd)
980 osd->timer_id = g_timeout_add(100, image_osd_timer_cb, osd);
984 static void image_osd_state_cb(ImageWindow *imd, ImageState state, gpointer data)
986 OverlayStateData *osd = data;
988 osd->changed_states |= state;
989 image_osd_update_schedule(osd, FALSE);
992 static void image_osd_notify_cb(FileData *fd, NotifyType type, gpointer data)
994 OverlayStateData *osd = data;
996 if ((type & (NOTIFY_HISTMAP)) && osd->imd && fd == osd->imd->image_fd)
998 DEBUG_1("Notify osd: %s %04x", fd->path, type);
1000 image_osd_update_schedule(osd, FALSE);
1005 static void image_osd_free(OverlayStateData *osd)
1009 if (osd->idle_id) g_source_remove(osd->idle_id);
1010 if (osd->timer_id) g_source_remove(osd->timer_id);
1012 file_data_unregister_notify_func(image_osd_notify_cb, osd);
1016 image_set_osd_data(osd->imd, NULL);
1017 g_signal_handler_disconnect(osd->imd->pr, osd->destroy_id);
1019 image_set_state_func(osd->imd, NULL, NULL);
1021 image_osd_info_hide(osd);
1022 image_osd_icons_hide(osd);
1025 if (osd->histogram) histogram_free(osd->histogram);
1030 static void image_osd_destroy_cb(GtkWidget *widget, gpointer data)
1032 OverlayStateData *osd = data;
1035 image_osd_free(osd);
1038 static void image_osd_enable(ImageWindow *imd, OsdShowFlags show)
1040 OverlayStateData *osd = image_get_osd_data(imd);
1044 osd = g_new0(OverlayStateData, 1);
1046 osd->show = OSD_SHOW_NOTHING;
1047 osd->x = options->image_overlay.x;
1048 osd->y = options->image_overlay.y;
1050 osd->histogram = histogram_new();
1052 osd->destroy_id = g_signal_connect(G_OBJECT(imd->pr), "destroy",
1053 G_CALLBACK(image_osd_destroy_cb), osd);
1054 image_set_osd_data(imd, osd);
1056 image_set_state_func(osd->imd, image_osd_state_cb, osd);
1057 file_data_register_notify_func(image_osd_notify_cb, osd, NOTIFY_PRIORITY_LOW);
1060 if (show & OSD_SHOW_STATUS)
1061 image_osd_icon(imd, IMAGE_OSD_ICON, -1);
1063 if (show != osd->show)
1064 image_osd_update_schedule(osd, TRUE);
1069 void image_osd_set(ImageWindow *imd, OsdShowFlags show)
1073 image_osd_enable(imd, show);
1076 OsdShowFlags image_osd_get(ImageWindow *imd)
1078 OverlayStateData *osd = image_get_osd_data(imd);
1080 return osd ? osd->show : OSD_SHOW_NOTHING;
1083 Histogram *image_osd_get_histogram(ImageWindow *imd)
1085 OverlayStateData *osd = image_get_osd_data(imd);
1087 return osd ? osd->histogram : NULL;
1090 void image_osd_copy_status(ImageWindow *src, ImageWindow *dest)
1092 Histogram *h_src, *h_dest;
1093 image_osd_set(dest, image_osd_get(src));
1095 h_src = image_osd_get_histogram(src);
1096 h_dest = image_osd_get_histogram(dest);
1098 h_dest->histogram_mode = h_src->histogram_mode;
1099 h_dest->histogram_channel = h_src->histogram_channel;
1106 2+ = show for duration tenths of a second
1107 -1 = use default duration
1109 void image_osd_icon(ImageWindow *imd, ImageOSDFlag flag, gint duration)
1111 OverlayStateData *osd = image_get_osd_data(imd);
1115 if (flag >= IMAGE_OSD_COUNT) return;
1116 if (duration < 0) duration = IMAGE_OSD_DEFAULT_DURATION;
1117 if (duration > 1) duration += 1;
1119 osd->icon_time[flag] = duration;
1121 image_osd_update_schedule(osd, FALSE);
1122 image_osd_timer_schedule(osd);
1124 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */