changeset 20424:945fa0eb37c0

Add ASS subtitle rendering options to gui. Patch by Piotr Kaczuba <pepe at attika dot ath dot cx>.
author eugeni
date Wed, 25 Oct 2006 00:05:14 +0000
parents a5ae4d97de7f
children f59726d0761e
files Gui/cfg.c Gui/cfg.h Gui/interface.c Gui/mplayer/gtk/common.c Gui/mplayer/gtk/common.h Gui/mplayer/gtk/opts.c help/help_mp-en.h
diffstat 7 files changed, 138 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Gui/cfg.c	Tue Oct 24 21:09:14 2006 +0000
+++ b/Gui/cfg.c	Wed Oct 25 00:05:14 2006 +0000
@@ -73,6 +73,10 @@
 int    gui_main_pos_y = -2;
 int    gui_sub_pos_x = -1;
 int    gui_sub_pos_y = -1;
+
+#ifdef USE_ASS
+gtkASS_t gtkASS;
+#endif
 // ---
 
 extern char * get_path( const char * filename );
@@ -139,6 +143,12 @@
  { "osd_level",&osd_level,CONF_TYPE_INT,CONF_RANGE,0,3,NULL },
  { "sub_auto_load",&sub_auto,CONF_TYPE_FLAG,0,0,1,NULL },
  { "sub_unicode",&sub_unicode,CONF_TYPE_FLAG,0,0,1,NULL },
+#ifdef USE_ASS
+ { "ass_enabled",&ass_enabled,CONF_TYPE_FLAG,0,0,1,NULL },
+ { "ass_use_margins",&ass_use_margins,CONF_TYPE_FLAG,0,0,1,NULL },
+ { "ass_top_margin",&ass_top_margin,CONF_TYPE_INT,CONF_RANGE,0,512,NULL },
+ { "ass_bottom_margin",&ass_bottom_margin,CONF_TYPE_INT,CONF_RANGE,0,512,NULL },
+#endif
  { "sub_pos",&sub_pos,CONF_TYPE_INT,CONF_RANGE,0,200,NULL },
  { "sub_overlap",&suboverlap_enabled,CONF_TYPE_FLAG,0,0,0,NULL },
 #ifdef USE_ICONV
--- a/Gui/cfg.h	Tue Oct 24 21:09:14 2006 +0000
+++ b/Gui/cfg.h	Wed Oct 25 00:05:14 2006 +0000
@@ -57,6 +57,20 @@
 extern int    gui_sub_pos_x;
 extern int    gui_sub_pos_y;
 
+#ifdef USE_ASS
+typedef struct {
+    int enabled;
+    int use_margins;
+    int top_margin;
+    int bottom_margin;
+} gtkASS_t;
+extern gtkASS_t gtkASS;
+extern int ass_enabled;
+extern int ass_use_margins;
+extern int ass_top_margin;
+extern int ass_bottom_margin;
+#endif
+
 extern int cfg_read( void );
 extern int cfg_write( void );
 
--- a/Gui/interface.c	Tue Oct 24 21:09:14 2006 +0000
+++ b/Gui/interface.c	Wed Oct 25 00:05:14 2006 +0000
@@ -216,6 +216,13 @@
  else if ( stream_cache_size == 0 ) gtkCacheOn = 0;
  if ( autosync && autosync != gtkAutoSync ) { gtkAutoSyncOn=1; gtkAutoSync=autosync; }
    
+#ifdef USE_ASS
+ gtkASS.enabled = ass_enabled;
+ gtkASS.use_margins = ass_use_margins;
+ gtkASS.top_margin = ass_top_margin;
+ gtkASS.bottom_margin = ass_bottom_margin;
+#endif
+
  gtkInit();
 // --- initialize X 
  wsXInit( (void *)mDisplay );
@@ -388,6 +395,13 @@
    gui_main_pos_x=appMPlayer.mainWindow.X; gui_main_pos_y=appMPlayer.mainWindow.Y;
    gui_sub_pos_x=appMPlayer.subWindow.X; gui_sub_pos_y=appMPlayer.subWindow.Y;
   }
+ 
+#ifdef USE_ASS
+ ass_enabled = gtkASS.enabled;
+ ass_use_margins = gtkASS.use_margins;
+ ass_top_margin = gtkASS.top_margin;
+ ass_bottom_margin = gtkASS.bottom_margin;
+#endif
 
  cfg_write();
  wsXDone();
@@ -923,6 +937,13 @@
         guiIntfStruct.FilenameChanged=0;
         guiIntfStruct.NewPlay=0;
 
+#ifdef USE_ASS
+        ass_enabled = gtkASS.enabled;
+        ass_use_margins = gtkASS.use_margins;
+        ass_top_margin = gtkASS.top_margin;
+        ass_bottom_margin = gtkASS.bottom_margin;
+#endif
+
 	break;
   }
  return False;
--- a/Gui/mplayer/gtk/common.c	Tue Oct 24 21:09:14 2006 +0000
+++ b/Gui/mplayer/gtk/common.c	Wed Oct 25 00:05:14 2006 +0000
@@ -97,6 +97,21 @@
  return RB;
 }
 
+GtkWidget * AddSpinButton( const char * title,GtkAdjustment * adj,GtkWidget * parent )
+{
+ GtkWidget * SB;
+ GtkWidget * label;
+ label=gtk_label_new( title );
+ gtk_misc_set_alignment( GTK_MISC( label ),0,0.5 );
+ gtk_box_pack_start( GTK_BOX( parent ),label,FALSE,FALSE,0 );
+ gtk_widget_show( label );
+ SB=gtk_spin_button_new( adj,0,0 );
+ gtk_widget_set_name( SB,"SB" );
+ gtk_box_pack_start( GTK_BOX( parent ),SB,FALSE,FALSE,0 );
+ gtk_widget_show( SB );
+ return SB;
+}
+
 GtkWidget * AddButton( const char * title,GtkWidget * parent )
 {
  GtkWidget * B;
--- a/Gui/mplayer/gtk/common.h	Tue Oct 24 21:09:14 2006 +0000
+++ b/Gui/mplayer/gtk/common.h	Wed Oct 25 00:05:14 2006 +0000
@@ -12,6 +12,7 @@
 extern GtkWidget * AddHBox( GtkWidget * parent,int type );
 extern GtkWidget * AddCheckButton( const char * title, GtkWidget * parent );
 extern GtkWidget * AddRadioButton( const char * title,GSList ** group,GtkWidget * parent );
+extern GtkWidget * AddSpinButton( const char * title,GtkAdjustment * adj,GtkWidget * parent );
 extern GtkWidget * AddButton( const char * title,GtkWidget * parent );
 extern GtkWidget * AddHSeparator( GtkWidget * parent );
 extern GtkWidget * AddHButtonBox( GtkWidget * parent );
--- a/Gui/mplayer/gtk/opts.c	Tue Oct 24 21:09:14 2006 +0000
+++ b/Gui/mplayer/gtk/opts.c	Wed Oct 25 00:05:14 2006 +0000
@@ -67,6 +67,10 @@
 static GtkWidget * CBSubOverlap;
 static GtkWidget * CBDumpMPSub;
 static GtkWidget * CBDumpSrt;
+static GtkWidget * CBUseASS;
+static GtkWidget * CBASSUseMargins;
+static GtkWidget * SBASSTopMargin;
+static GtkWidget * SBASSBottomMargin;
 static GtkWidget * CBPostprocess;
 static GtkWidget * CBCache;
 static GtkWidget * CBLoadFullscreen;
@@ -259,6 +263,20 @@
  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBDumpMPSub ),gtkSubDumpMPSub );
  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBDumpSrt ),gtkSubDumpSrt );
  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBSubUnicode ),sub_unicode );
+#ifdef USE_ASS
+ gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBUseASS ),gtkASS.enabled );
+ gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBASSUseMargins ),gtkASS.use_margins );
+ gtk_spin_button_set_value( (GtkSpinButton *)SBASSTopMargin,(gdouble)gtkASS.top_margin );
+ gtk_spin_button_set_value( (GtkSpinButton *)SBASSBottomMargin,(gdouble)gtkASS.bottom_margin );
+
+ if ( !gtkASS.enabled )
+  {
+   gtk_widget_set_sensitive( CBASSUseMargins,FALSE );
+   gtk_widget_set_sensitive( SBASSTopMargin,FALSE );
+   gtk_widget_set_sensitive( SBASSBottomMargin,FALSE );
+  }
+#endif
+
  gtk_adjustment_set_value( HSSubDelayadj,sub_delay );
  gtk_adjustment_set_value( HSSubFPSadj,sub_fps );
  gtk_adjustment_set_value( HSSubPositionadj,sub_pos );
@@ -394,6 +412,13 @@
  gtk_widget_set_sensitive( HSSubFPS,FALSE );
 #endif
 
+#ifndef USE_ASS
+ gtk_widget_set_sensitive( CBUseASS,FALSE );
+ gtk_widget_set_sensitive( CBASSUseMargins,FALSE );
+ gtk_widget_set_sensitive( SBASSTopMargin,FALSE );
+ gtk_widget_set_sensitive( SBASSBottomMargin,FALSE );
+#endif
+
 #ifndef USE_OSD
  gtk_widget_set_sensitive( RBOSDNone,FALSE );
  gtk_widget_set_sensitive( RBOSDTandP,FALSE );
@@ -421,6 +446,9 @@
 #endif
  gtk_signal_connect( GTK_OBJECT( CBCache ),"toggled",GTK_SIGNAL_FUNC( prToggled ),(void*)8);
  gtk_signal_connect( GTK_OBJECT( CBAutoSync ),"toggled",GTK_SIGNAL_FUNC( prToggled ),(void*)9);
+#ifdef USE_ASS
+ gtk_signal_connect( GTK_OBJECT( CBUseASS ),"toggled",GTK_SIGNAL_FUNC( prToggled ),(void*)10);
+#endif
 
  gtk_signal_connect( GTK_OBJECT( HSExtraStereoMul ),"motion_notify_event",GTK_SIGNAL_FUNC( prHScaler ),(void*)0 );
  gtk_signal_connect( GTK_OBJECT( HSAudioDelay ),"motion_notify_event",GTK_SIGNAL_FUNC( prHScaler ),(void*)1 );
@@ -539,6 +567,12 @@
 	gtkSubDumpMPSub=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBDumpMPSub ) );
 	gtkSubDumpSrt=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBDumpSrt ) );
 	sub_unicode=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBSubUnicode ) );
+#ifdef USE_ASS
+	gtkASS.enabled=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBUseASS ) );
+	gtkASS.use_margins=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBASSUseMargins ) );
+	gtkASS.top_margin=gtk_spin_button_get_value( GTK_SPIN_BUTTON( SBASSTopMargin ) );
+	gtkASS.bottom_margin=gtk_spin_button_get_value( GTK_SPIN_BUTTON( SBASSBottomMargin ) );
+#endif
 	sub_delay=HSSubDelayadj->value;
 	sub_fps=HSSubFPSadj->value;
 	sub_pos=(int)HSSubPositionadj->value;
@@ -721,6 +755,22 @@
 	if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBAutoSync ) ) ) gtk_widget_set_sensitive( SBAutoSync,TRUE );
 	 else gtk_widget_set_sensitive( SBAutoSync,FALSE );
 	break;
+#ifdef USE_ASS
+   case 10:
+	if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBUseASS ) ) )
+	 {
+	  gtk_widget_set_sensitive( CBASSUseMargins,TRUE );
+	  gtk_widget_set_sensitive( SBASSTopMargin,TRUE );
+	  gtk_widget_set_sensitive( SBASSBottomMargin,TRUE );
+	 }
+	else
+	 {
+	  gtk_widget_set_sensitive( CBASSUseMargins,FALSE );
+	  gtk_widget_set_sensitive( SBASSTopMargin,FALSE );
+	  gtk_widget_set_sensitive( SBASSBottomMargin,FALSE );
+	 }
+	break;
+#endif
   }
 }
 
@@ -790,6 +840,10 @@
   GtkWidget * hbuttonbox1;
   GtkAccelGroup * accel_group;
 
+  GtkWidget * hbox9;
+  GtkWidget * hbox91;
+  GtkWidget * hbox92;
+
   accel_group=gtk_accel_group_new();
 
   Preferences=gtk_window_new( GTK_WINDOW_TOPLEVEL );
@@ -1028,6 +1082,25 @@
   CBDumpMPSub=AddCheckButton( MSGTR_PREFERENCES_SUB_MPSUB,vbox9 );
   CBDumpSrt=AddCheckButton( MSGTR_PREFERENCES_SUB_SRT,vbox9 );
 
+  AddHSeparator( vbox9 );
+  CBUseASS=AddCheckButton( MSGTR_PREFERENCES_SUB_USE_ASS,vbox9 );
+  hbox9=AddHBox( vbox9,0 );
+  CBASSUseMargins=AddCheckButton( MSGTR_PREFERENCES_SUB_ASS_USE_MARGINS,hbox9 );
+
+  hbox91=gtk_hbox_new( FALSE,0 );
+  gtk_widget_set_name( hbox91,"hbox91" );
+  gtk_box_pack_start( GTK_BOX( hbox9 ),hbox91,TRUE,FALSE,0 );
+  gtk_widget_show( hbox91 );
+  SBASSTopMargin=AddSpinButton( MSGTR_PREFERENCES_SUB_ASS_TOP_MARGIN,
+	(GtkAdjustment *)gtk_adjustment_new(0,0,512,1,8,0),hbox91 );
+
+  hbox92=gtk_hbox_new( FALSE,0 );
+  gtk_widget_set_name( hbox92,"hbox92" );
+  gtk_box_pack_start( GTK_BOX( hbox9 ),hbox92,TRUE,FALSE,0 );
+  gtk_widget_show( hbox92 );
+  SBASSBottomMargin=AddSpinButton( MSGTR_PREFERENCES_SUB_ASS_BOTTOM_MARGIN,
+	(GtkAdjustment *)gtk_adjustment_new(0,0,512,1,8,0),hbox92 );
+
   label=AddLabel( MSGTR_PREFERENCES_SubtitleOSD,NULL );
     gtk_notebook_set_tab_label( GTK_NOTEBOOK( notebook1 ),gtk_notebook_get_nth_page( GTK_NOTEBOOK( notebook1 ),2 ),label );
   vbox601=AddVBox( notebook1,0 );
--- a/help/help_mp-en.h	Tue Oct 24 21:09:14 2006 +0000
+++ b/help/help_mp-en.h	Wed Oct 25 00:05:14 2006 +0000
@@ -858,6 +858,10 @@
 #define MSGTR_PREFERENCES_SUB_MPSUB "Convert the given subtitle to MPlayer's subtitle format"
 #define MSGTR_PREFERENCES_SUB_SRT "Convert the given subtitle to the time based SubViewer (SRT) format"
 #define MSGTR_PREFERENCES_SUB_Overlap "Toggle subtitle overlapping"
+#define MSGTR_PREFERENCES_SUB_USE_ASS "SSA/ASS subtitle rendering"
+#define MSGTR_PREFERENCES_SUB_ASS_USE_MARGINS "Use margins"
+#define MSGTR_PREFERENCES_SUB_ASS_TOP_MARGIN "Top: "
+#define MSGTR_PREFERENCES_SUB_ASS_BOTTOM_MARGIN "Bottom: "
 #define MSGTR_PREFERENCES_Font "Font:"
 #define MSGTR_PREFERENCES_FontFactor "Font factor:"
 #define MSGTR_PREFERENCES_PostProcess "Enable postprocessing"