changeset 1830:c5a0d540907a

type of source stereo image made adjustable from menu
author Vladimir Nadvornik <nadvornik@suse.cz>
date Sat, 19 Mar 2011 21:42:13 +0100
parents c8b1f56466ef
children 024f1752fe7b
files src/image-load.c src/image.c src/image.h src/layout_image.c src/layout_image.h src/layout_util.c src/pixbuf-renderer.c src/pixbuf-renderer.h src/renderer-tiles.c src/typedefs.h
diffstat 10 files changed, 83 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/src/image-load.c	Sat Mar 19 19:53:30 2011 +0100
+++ b/src/image-load.c	Sat Mar 19 21:42:13 2011 +0100
@@ -352,7 +352,7 @@
 
 	if (g_ascii_strcasecmp(".jps", il->fd->extension) == 0)
 		{
-		g_object_set_data(G_OBJECT(pb), "stereo_sbs", GINT_TO_POINTER(1));
+		g_object_set_data(G_OBJECT(pb), "stereo_data", GINT_TO_POINTER(STEREO_PIXBUF_CROSS));
 		}
 
 	if (il->pixbuf) g_object_unref(il->pixbuf);
--- a/src/image.c	Sat Mar 19 19:53:30 2011 +0100
+++ b/src/image.c	Sat Mar 19 21:42:13 2011 +0100
@@ -1115,6 +1115,11 @@
 			}
 		}
 
+	if (pixbuf && imd->user_stereo)
+		{
+		g_object_set_data(G_OBJECT(pixbuf), "stereo_data", GINT_TO_POINTER(imd->user_stereo));
+		}
+
 	pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, NULL, NULL, FALSE);
 	if (imd->cm)
 		{
@@ -1434,6 +1439,17 @@
 	pixbuf_renderer_stereo_set((PixbufRenderer *)imd->pr, stereo_mode);
 }
 
+StereoPixbufData image_stereo_pixbuf_get(ImageWindow *imd)
+{
+	return imd->user_stereo;
+}
+
+void image_stereo_pixbuf_set(ImageWindow *imd, StereoPixbufData stereo_mode)
+{
+	imd->user_stereo = stereo_mode;
+	image_reload(imd);
+}
+
 /* read ahead */
 
 void image_prebuffer_set(ImageWindow *imd, FileData *fd)
--- a/src/image.h	Sat Mar 19 19:53:30 2011 +0100
+++ b/src/image.h	Sat Mar 19 21:42:13 2011 +0100
@@ -96,6 +96,9 @@
 void image_stereo_set(ImageWindow *imd, gint stereo_mode);
 void image_stereo_swap(ImageWindow *imd);
 
+StereoPixbufData image_stereo_pixbuf_get(ImageWindow *imd);
+void image_stereo_pixbuf_set(ImageWindow *imd, StereoPixbufData stereo_mode);
+
 /* read ahead, pass NULL to cancel */
 void image_prebuffer_set(ImageWindow *imd, FileData *fd);
 
--- a/src/layout_image.c	Sat Mar 19 19:53:30 2011 +0100
+++ b/src/layout_image.c	Sat Mar 19 21:42:13 2011 +0100
@@ -903,6 +903,7 @@
 }
 
 /* stereo */
+/*
 gint layout_image_stereo_get(LayoutWindow *lw)
 {
 	if (!layout_valid(&lw)) return 0;
@@ -916,7 +917,7 @@
 
 	image_stereo_set(lw->image, stereo_mode);
 }
-
+*/
 void layout_image_stereo_swap(LayoutWindow *lw)
 {
 	if (!layout_valid(&lw)) return;
@@ -924,6 +925,20 @@
 	image_stereo_swap(lw->image);
 }
 
+gint layout_image_stereo_pixbuf_get(LayoutWindow *lw)
+{
+	if (!layout_valid(&lw)) return 0;
+
+	return image_stereo_pixbuf_get(lw->image);
+}
+
+void layout_image_stereo_pixbuf_set(LayoutWindow *lw, gint stereo_mode)
+{
+	if (!layout_valid(&lw)) return;
+
+	image_stereo_pixbuf_set(lw->image, stereo_mode);
+}
+
 const gchar *layout_image_get_path(LayoutWindow *lw)
 {
 	if (!layout_valid(&lw)) return NULL;
--- a/src/layout_image.h	Sat Mar 19 19:53:30 2011 +0100
+++ b/src/layout_image.h	Sat Mar 19 21:42:13 2011 +0100
@@ -55,10 +55,15 @@
 void layout_image_set_desaturate(LayoutWindow *lw, gboolean desaturate);
 gboolean layout_image_get_desaturate(LayoutWindow *lw);
 
+/*
 gint layout_image_stereo_get(LayoutWindow *lw);
 void layout_image_stereo_set(LayoutWindow *lw, gint stereo_mode);
+*/
 void layout_image_stereo_swap(LayoutWindow *lw);
 
+gint layout_image_stereo_pixbuf_get(LayoutWindow *lw);
+void layout_image_stereo_pixbuf_set(LayoutWindow *lw, gint stereo_mode);
+
 void layout_image_next(LayoutWindow *lw);
 void layout_image_prev(LayoutWindow *lw);
 void layout_image_first(LayoutWindow *lw);
--- a/src/layout_util.c	Sat Mar 19 19:53:30 2011 +0100
+++ b/src/layout_util.c	Sat Mar 19 21:42:13 2011 +0100
@@ -847,12 +847,9 @@
 {
 	LayoutWindow *lw = data;
 	gint mode = gtk_radio_action_get_current_value(action);
-	layout_image_stereo_set(lw, (layout_image_stereo_get(lw) & ~(PR_STEREO_ANAGLYPH | PR_STEREO_HORIZ | PR_STEREO_VERT)) | mode);
+	layout_image_stereo_pixbuf_set(lw, mode);
 }
 
-
-
-
 static void layout_menu_help_cb(GtkAction *action, gpointer data)
 {
 	LayoutWindow *lw = data;
@@ -1433,10 +1430,10 @@
 };
 
 static GtkRadioActionEntry menu_stereo_mode_entries[] = {
-  { "StereoNone",	NULL,			N_("_None"),				NULL,			N_("Stereo Off"),		PR_STEREO_NONE },
-  { "StereoAnaglyph",	NULL,			N_("_Anaglyph"),			NULL,			N_("Stereo Anaglyph"),		PR_STEREO_ANAGLYPH },
-  { "StereoHoriz",	NULL,			N_("_Side by Side"),			NULL,			N_("Stereo Side by Side"),	PR_STEREO_HORIZ },
-  { "StereoVert",	NULL,			N_("Above-_Below"),			NULL,			N_("Stereo Above-Below"),	PR_STEREO_VERT }
+  { "StereoAuto",	NULL,			N_("_Auto"),				NULL,			N_("Stereo Auto"),		STEREO_PIXBUF_DEFAULT },
+  { "StereoSBS",	NULL,			N_("_Side by Side"),			NULL,			N_("Stereo Side by Side"),	STEREO_PIXBUF_SBS },
+  { "StereoCross",	NULL,			N_("_Cross"),				NULL,			N_("Stereo Cross"),		STEREO_PIXBUF_CROSS },
+  { "StereoOff",	NULL,			N_("_Off"),				NULL,			N_("Stereo Off"),		STEREO_PIXBUF_NONE }
 };
 
 
@@ -1580,10 +1577,10 @@
 "      <menu action='StereoMenu'>"
 "        <menuitem action='StereoSwap'/>"
 "        <separator/>"
-"        <menuitem action='StereoNone'/>"
-"        <menuitem action='StereoAnaglyph'/>"
-"        <menuitem action='StereoHoriz'/>"
-"        <menuitem action='StereoVert'/>"
+"        <menuitem action='StereoAuto'/>"
+"        <menuitem action='StereoSBS'/>"
+"        <menuitem action='StereoCross'/>"
+"        <menuitem action='StereoOff'/>"
 "      </menu>"
 "      <menu action='ColorMenu'>"
 "        <menuitem action='UseColorProfiles'/>"
@@ -2411,6 +2408,9 @@
 	action = gtk_action_group_get_action(lw->action_group, "ConnectZoomMenu");
 	gtk_action_set_sensitive(action, lw->split_mode != SPLIT_NONE);
 
+	action = gtk_action_group_get_action(lw->action_group, "StereoAuto");
+	radio_action_set_current_value(GTK_RADIO_ACTION(action), layout_image_stereo_pixbuf_get(lw));
+
 	layout_util_sync_color(lw);
 }
 
--- a/src/pixbuf-renderer.c	Sat Mar 19 19:53:30 2011 +0100
+++ b/src/pixbuf-renderer.c	Sat Mar 19 21:42:13 2011 +0100
@@ -2292,8 +2292,10 @@
  */
 static void pr_pixbuf_size_sync(PixbufRenderer *pr)
 {
-	pr->stereo_pixbuf_offset = 0;
+	pr->stereo_pixbuf_offset_left = 0;
+	pr->stereo_pixbuf_offset_right = 0;
 	if (!pr->pixbuf) return;
+	gint stereo_data = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(pr->pixbuf), "stereo_data"));
 	switch (pr->orientation)
 		{
 		case EXIF_ORIENTATION_LEFT_TOP:
@@ -2302,20 +2304,30 @@
 		case EXIF_ORIENTATION_LEFT_BOTTOM:
 			pr->image_width = gdk_pixbuf_get_height(pr->pixbuf);
 			pr->image_height = gdk_pixbuf_get_width(pr->pixbuf);
-			if (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(pr->pixbuf), "stereo_sbs"))) 
+			if (stereo_data == STEREO_PIXBUF_SBS) 
 				{
 				pr->image_height /= 2;
-				pr->stereo_pixbuf_offset = pr->image_height;
+				pr->stereo_pixbuf_offset_right = pr->image_height;
+				}
+			else if (stereo_data == STEREO_PIXBUF_CROSS) 
+				{
+				pr->image_height /= 2;
+				pr->stereo_pixbuf_offset_left = pr->image_height;
 				}
 			
 			break;
 		default:
 			pr->image_width = gdk_pixbuf_get_width(pr->pixbuf);
 			pr->image_height = gdk_pixbuf_get_height(pr->pixbuf);
-			if (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(pr->pixbuf), "stereo_sbs"))) 
+			if (stereo_data == STEREO_PIXBUF_SBS) 
 				{
 				pr->image_width /= 2;
-				pr->stereo_pixbuf_offset = pr->image_width;
+				pr->stereo_pixbuf_offset_right = pr->image_width;
+				}
+			else if (stereo_data == STEREO_PIXBUF_CROSS) 
+				{
+				pr->image_width /= 2;
+				pr->stereo_pixbuf_offset_left = pr->image_width;
 				}
 		}
 }
--- a/src/pixbuf-renderer.h	Sat Mar 19 19:53:30 2011 +0100
+++ b/src/pixbuf-renderer.h	Sat Mar 19 21:42:13 2011 +0100
@@ -101,7 +101,8 @@
 
 	gint image_width;	/* image actual dimensions (pixels) */
 	gint image_height;
-	gint stereo_pixbuf_offset; /* offset of the right part of the stereo image in pixbuf */
+	gint stereo_pixbuf_offset_right; /* offset of the right part of the stereo image in pixbuf */
+	gint stereo_pixbuf_offset_left; /* offset of the left part of the stereo image in pixbuf */
 
 	GdkPixbuf *pixbuf;
 
--- a/src/renderer-tiles.c	Sat Mar 19 19:53:30 2011 +0100
+++ b/src/renderer-tiles.c	Sat Mar 19 21:42:13 2011 +0100
@@ -166,12 +166,12 @@
 #define GET_RIGHT_PIXBUF_OFFSET(rt) \
         (( (rt->stereo_mode & PR_STEREO_RIGHT) && !(rt->stereo_mode & PR_STEREO_SWAP)) || \
          (!(rt->stereo_mode & PR_STEREO_RIGHT) &&  (rt->stereo_mode & PR_STEREO_SWAP)) ?  \
-          rt->pr->stereo_pixbuf_offset : 0 )
+          rt->pr->stereo_pixbuf_offset_right : rt->pr->stereo_pixbuf_offset_left )
 
 #define GET_LEFT_PIXBUF_OFFSET(rt) \
         ((!(rt->stereo_mode & PR_STEREO_RIGHT) && !(rt->stereo_mode & PR_STEREO_SWAP)) || \
          ( (rt->stereo_mode & PR_STEREO_RIGHT) &&  (rt->stereo_mode & PR_STEREO_SWAP)) ?  \
-          rt->pr->stereo_pixbuf_offset : 0 )
+          rt->pr->stereo_pixbuf_offset_right : rt->pr->stereo_pixbuf_offset_left )
 
 
 static void rt_sync_scroll(RendererTiles *rt)
@@ -1405,7 +1405,8 @@
 				   scale_x, scale_y,
 				   (fast) ? GDK_INTERP_NEAREST : pr->zoom_quality,
 				   it->x + pb_x, it->y + pb_y);
-		if (rt->stereo_mode & PR_STEREO_ANAGLYPH && pr->stereo_pixbuf_offset > 0)
+		if (rt->stereo_mode & PR_STEREO_ANAGLYPH && 
+		    (pr->stereo_pixbuf_offset_right > 0 || pr->stereo_pixbuf_offset_left > 0))
 			{
 			GdkPixbuf *right_pb = rt_get_spare_tile(rt);
 			rt_tile_get_region(has_alpha,
--- a/src/typedefs.h	Sat Mar 19 19:53:30 2011 +0100
+++ b/src/typedefs.h	Sat Mar 19 21:42:13 2011 +0100
@@ -201,6 +201,12 @@
 	
 } PixbufRendererStereoMode;
 
+typedef enum {
+	STEREO_PIXBUF_DEFAULT  = 0,
+	STEREO_PIXBUF_SBS      = 1,
+	STEREO_PIXBUF_CROSS    = 2,
+	STEREO_PIXBUF_NONE     = 3
+} StereoPixbufData;
 
 #define MAX_SPLIT_IMAGES 4
 
@@ -456,6 +462,7 @@
 	gboolean delay_flip;
 	gint orientation;
 	gboolean desaturate;
+	gint user_stereo;
 };
 
 #define FILEDATA_MARKS_SIZE 6