stereo mode preferences
authorVladimir Nadvornik <nadvornik@suse.cz>
Sat, 19 Mar 2011 18:53:30 +0000 (19:53 +0100)
committerVladimir Nadvornik <nadvornik@suse.cz>
Tue, 27 Sep 2011 12:30:07 +0000 (14:30 +0200)
src/fullscreen.c
src/image.c
src/options.h
src/preferences.c
src/typedefs.h

index b7cf168..faecc72 100644 (file)
@@ -294,7 +294,7 @@ FullScreenData *fullscreen_start(GtkWidget *window, ImageWindow *imd,
        image_background_set_color_from_options(fs->imd, TRUE);
        image_set_delay_flip(fs->imd, options->fullscreen.clean_flip);
        image_auto_refresh_enable(fs->imd, fs->normal_imd->auto_refresh);
-
+       
        if (options->fullscreen.clean_flip)
                {
                image_set_update_func(fs->imd, fullscreen_image_update_cb, fs);
@@ -305,6 +305,10 @@ FullScreenData *fullscreen_start(GtkWidget *window, ImageWindow *imd,
 
        image_change_from_image(fs->imd, fs->normal_imd);
 
+       if (options->stereo.enable_fsmode) {
+               image_stereo_set(fs->imd, options->stereo.fsmode);
+       }
+
        gtk_widget_show(fs->window);
 
        /* for hiding the mouse */
@@ -337,6 +341,11 @@ void fullscreen_stop(FullScreenData *fs)
        gdk_keyboard_ungrab(GDK_CURRENT_TIME);
 
        image_change_from_image(fs->normal_imd, fs->imd);
+
+       if (options->stereo.enable_fsmode) {
+               image_stereo_set(fs->normal_imd, options->stereo.mode);
+       }
+
 #ifdef HIDE_WINDOW_IN_FULLSCREEN
        gtk_widget_show(fs->normal_window);
 #endif
index 8b2e2c4..07d231a 100644 (file)
@@ -1432,6 +1432,7 @@ gint image_stereo_get(ImageWindow *imd)
 
 void image_stereo_set(ImageWindow *imd, gint stereo_mode)
 {
+       DEBUG_1("Setting stereo mode %04x for imd %p", stereo_mode, imd);  
        pixbuf_renderer_stereo_set((PixbufRenderer *)imd->pr, stereo_mode);
 }
 
@@ -1689,6 +1690,8 @@ static void image_options_set(ImageWindow *imd)
                                        NULL);
 
        pixbuf_renderer_set_parent((PixbufRenderer *)imd->pr, (GtkWindow *)imd->top_window);
+       
+       image_stereo_set(imd, options->stereo.mode);
 }
 
 void image_options_sync(void)
index da59a44..193577e 100644 (file)
@@ -181,7 +181,17 @@ struct _ConfOptions
                gboolean keywords_case_sensitive;
                gboolean write_orientation;
        } metadata;
-
+       
+       /* Stereo */
+       struct {
+               gint mode;
+               gboolean fallback;
+               gint fsmode;
+               gboolean enable_fsmode;
+               gint fixed_w, fixed_h;
+               gint fixed_x1, fixed_y1;
+               gint fixed_x2, fixed_y2;
+       } stereo;
 };
 
 ConfOptions *options;
index b637d0d..2f6efc6 100644 (file)
@@ -306,6 +306,17 @@ static void config_window_apply(void)
        options->metadata.keywords_case_sensitive = c_options->metadata.keywords_case_sensitive;
        options->metadata.write_orientation = c_options->metadata.write_orientation;
 
+       options->stereo.mode = c_options->stereo.mode;
+       options->stereo.fallback = c_options->stereo.fallback;
+       options->stereo.fsmode = c_options->stereo.fsmode;
+       options->stereo.enable_fsmode = c_options->stereo.enable_fsmode;
+       options->stereo.fixed_w = c_options->stereo.fixed_w;
+       options->stereo.fixed_h = c_options->stereo.fixed_h;
+       options->stereo.fixed_x1 = c_options->stereo.fixed_x1;
+       options->stereo.fixed_y1 = c_options->stereo.fixed_y1;
+       options->stereo.fixed_x2 = c_options->stereo.fixed_x2;
+       options->stereo.fixed_y2 = c_options->stereo.fixed_y2;
+
 #ifdef DEBUG
        set_debug_level(debug_c);
 #endif
@@ -528,6 +539,68 @@ static void add_thumb_size_menu(GtkWidget *table, gint column, gint row, gchar *
        gtk_widget_show(combo);
 }
 
+static void stereo_mode_menu_cb(GtkWidget *combo, gpointer data)
+{
+       gint *option = data;
+
+       switch (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)))
+               {
+               case 0:
+               default:
+                       *option = PR_STEREO_NONE;
+                       break;
+               case 1:
+                       *option = PR_STEREO_ANAGLYPH;
+                       break;
+               case 2:
+                       *option = PR_STEREO_HORIZ;
+                       break;
+               case 3:
+                       *option = PR_STEREO_VERT;
+                       break;
+               case 4:
+                       *option = PR_STEREO_FIXED;
+                       break;
+               }
+}
+
+static void add_stereo_mode_menu(GtkWidget *table, gint column, gint row, const gchar *text,
+                            guint option, guint *option_c, gboolean add_fixed)
+{
+       GtkWidget *combo;
+       gint current = 0;
+
+       *option_c = option;
+
+       pref_table_label(table, column, row, text, 0.0);
+
+       combo = gtk_combo_box_new_text();
+
+       gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Single image"));
+       if (option == PR_STEREO_NONE) current = 0;
+       gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Anaglyph"));
+       if (option == PR_STEREO_ANAGLYPH) current = 1;
+       gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Side by Side"));
+       if (option == PR_STEREO_HORIZ) current = 2;
+       gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Above - below"));
+       if (option == PR_STEREO_VERT) current = 3;
+       
+       if (add_fixed)
+               {
+               gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Fixed position"));
+               if (option == PR_STEREO_FIXED) current = 4;
+               }
+
+       gtk_combo_box_set_active(GTK_COMBO_BOX(combo), current);
+
+       g_signal_connect(G_OBJECT(combo), "changed",
+                        G_CALLBACK(stereo_mode_menu_cb), option_c);
+
+       gtk_table_attach(GTK_TABLE(table), combo, column + 1, column + 2, row, row + 1,
+                        GTK_EXPAND | GTK_FILL, 0, 0, 0);
+       gtk_widget_show(combo);
+}
+
 static void filter_store_populate(void)
 {
        GList *work;
@@ -1964,6 +2037,30 @@ static void config_tab_accelerators(GtkWidget *notebook)
 #endif
 }
 
+/* stereo tab */
+static void config_tab_stereo(GtkWidget *notebook)
+{
+       GtkWidget *vbox;
+       GtkWidget *group;
+       GtkWidget *table;
+       vbox = scrolled_notebook_page(notebook, _("Stereo"));
+
+       group = pref_group_new(vbox, FALSE, _("Windowed stereo mode"), GTK_ORIENTATION_VERTICAL);
+
+       table = pref_table_new(group, 2, 1, FALSE, FALSE);
+       add_stereo_mode_menu(table, 0, 0, _("Windowed stereo mode"), options->stereo.mode, &c_options->stereo.mode, FALSE);
+
+       pref_checkbox_new_int(group, _("Fall back to single image mode on 2d"),
+                             options->stereo.fallback, &c_options->stereo.fallback);
+
+       group = pref_group_new(vbox, FALSE, _("Fullscreen stereo mode"), GTK_ORIENTATION_VERTICAL);
+       pref_checkbox_new_int(group, _("Use different settings for fullscreen"),
+                             options->stereo.enable_fsmode, &c_options->stereo.enable_fsmode);
+       table = pref_table_new(group, 2, 1, FALSE, FALSE);
+       add_stereo_mode_menu(table, 0, 0, _("Fullscreen stereo mode"), options->stereo.fsmode, &c_options->stereo.fsmode, TRUE);
+
+}
+
 /* Main preferences window */
 static void config_window_create(void)
 {
@@ -2036,6 +2133,7 @@ static void config_window_create(void)
        config_tab_files(notebook);
        config_tab_metadata(notebook);
        config_tab_color(notebook);
+       config_tab_stereo(notebook);
        config_tab_behavior(notebook);
 
        gtk_widget_show(notebook);
index 8fc743a..f7c59c6 100644 (file)
@@ -191,6 +191,7 @@ typedef enum {
        PR_STEREO_DUAL     = 1 << 0, /* independent stereo buffers, for example nvidia opengl */
        PR_STEREO_HORIZ    = 1 << 2, /* side by side */
        PR_STEREO_VERT     = 1 << 3, /* above below */
+       PR_STEREO_FIXED    = 1 << 1, /* custom position */
        /* flags for renderer: */
        PR_STEREO_RIGHT    = 1 << 4, /* render right buffer */
        PR_STEREO_ANAGLYPH = 1 << 5, /* anaglyph */