[vlc-devel] commit: subtitles/hotkeys: hotkey accessible subtitle position adjustment ( Jakob Leben )

git version control git at videolan.org
Sat Nov 28 13:24:36 CET 2009


vlc | branch: master | Jakob Leben <jleben at videolan.org> | Sat Nov 28 13:16:44 2009 +0100| [e87593bb6a622515e011370e52ccf426c92b02a8] | committer: Jakob Leben 

subtitles/hotkeys: hotkey accessible subtitle position adjustment

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e87593bb6a622515e011370e52ccf426c92b02a8
---

 include/vlc_keys.h                  |    2 ++
 modules/control/hotkeys.c           |   20 ++++++++++++++++++++
 src/input/var.c                     |    2 ++
 src/libvlc-module.c                 |   14 ++++++++++++++
 src/video_output/vout_subpictures.c |   26 +++++++++++++++++++++++++-
 5 files changed, 63 insertions(+), 1 deletions(-)

diff --git a/include/vlc_keys.h b/include/vlc_keys.h
index 795c42f..a9c64e5 100644
--- a/include/vlc_keys.h
+++ b/include/vlc_keys.h
@@ -142,6 +142,8 @@ typedef enum vlc_key {
     /* end of contiguous zone */
     ACTIONID_SUBDELAY_UP,
     ACTIONID_SUBDELAY_DOWN,
+    ACTIONID_SUBPOS_UP,
+    ACTIONID_SUBPOS_DOWN,
     ACTIONID_HISTORY_BACK,
     ACTIONID_HISTORY_FORWARD,
     ACTIONID_AUDIO_TRACK,
diff --git a/modules/control/hotkeys.c b/modules/control/hotkeys.c
index c91a948..bd5d82b 100644
--- a/modules/control/hotkeys.c
+++ b/modules/control/hotkeys.c
@@ -790,6 +790,26 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
                                 _( "Subtitle delay %i ms" ),
                                  (int)(i_delay/1000) );
             }
+            else if( i_action == ACTIONID_SUBPOS_DOWN )
+            {
+                int i_pos = var_GetInteger( p_input, "sub-margin" );
+                --i_pos;
+                var_SetInteger( p_input, "sub-margin", i_pos );
+                ClearChannels( p_intf, p_vout );
+                vout_OSDMessage( p_intf, DEFAULT_CHAN,
+                                _( "Subtitle position %i px" ),
+                                 (int)(i_pos) );
+            }
+            else if( i_action == ACTIONID_SUBPOS_UP )
+            {
+                int i_pos = var_GetInteger( p_input, "sub-margin" );
+                ++i_pos;
+                var_SetInteger( p_input, "sub-margin", i_pos );
+                ClearChannels( p_intf, p_vout );
+                vout_OSDMessage( p_intf, DEFAULT_CHAN,
+                                _( "Subtitle position %i px" ),
+                                 (int)(i_pos) );
+            }
             else if( i_action == ACTIONID_AUDIODELAY_DOWN )
             {
                 int64_t i_delay = var_GetTime( p_input, "audio-delay" );
diff --git a/src/input/var.c b/src/input/var.c
index f2f75ab..a70f55b 100644
--- a/src/input/var.c
+++ b/src/input/var.c
@@ -216,6 +216,8 @@ void input_ControlVarInit ( input_thread_t *p_input )
     text.psz_string = _("Subtitles Track");
     var_Change( p_input, "spu-es", VLC_VAR_SETTEXT, &text, NULL );
 
+    var_Create( p_input, "sub-margin", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
+
     /* Special read only objects variables for intf */
     var_Create( p_input, "bookmarks", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
 
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index 00cc63f..db43e48 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -1359,6 +1359,10 @@ static const char *const ppsz_albumart_descriptions[] =
 #define SUBDELAY_UP_KEY_LONGTEXT N_("Select the key to increase the subtitle delay.")
 #define SUBDELAY_DOWN_KEY_TEXT N_("Subtitle delay down")
 #define SUBDELAY_DOWN_KEY_LONGTEXT N_("Select the key to decrease the subtitle delay.")
+#define SUBPOS_UP_KEY_TEXT N_("Subtitle position up")
+#define SUBPOS_UP_KEY_LONGTEXT N_("Select the key to move subtitles higher.")
+#define SUBPOS_DOWN_KEY_TEXT N_("Subtitle position down")
+#define SUBPOS_DOWN_KEY_LONGTEXT N_("Select the key to move subtitles lower.")
 #define AUDIODELAY_UP_KEY_TEXT N_("Audio delay up")
 #define AUDIODELAY_UP_KEY_LONGTEXT N_("Select the key to increase the audio delay.")
 #define AUDIODELAY_DOWN_KEY_TEXT N_("Audio delay down")
@@ -2241,6 +2245,8 @@ vlc_module_begin ()
 #   define KEY_VOL_MUTE           KEY_MODIFIER_COMMAND|KEY_MODIFIER_ALT|KEY_DOWN
 #   define KEY_SUBDELAY_UP        'j'
 #   define KEY_SUBDELAY_DOWN      'h'
+#   define KEY_SUBPOS_DOWN        KEY_UNSET
+#   define KEY_SUBPOS_UP          KEY_UNSET
 #   define KEY_AUDIODELAY_UP      'g'
 #   define KEY_AUDIODELAY_DOWN    'f'
 #   define KEY_AUDIO_TRACK        'l'
@@ -2356,6 +2362,8 @@ vlc_module_begin ()
 #   define KEY_VOL_MUTE           'm'
 #   define KEY_SUBDELAY_UP        'h'
 #   define KEY_SUBDELAY_DOWN      'g'
+#   define KEY_SUBPOS_DOWN        KEY_UNSET
+#   define KEY_SUBPOS_UP          KEY_UNSET
 #   define KEY_AUDIODELAY_UP      'k'
 #   define KEY_AUDIODELAY_DOWN    'j'
 #   define KEY_RANDOM             'r'
@@ -2517,6 +2525,10 @@ vlc_module_begin ()
              SUBDELAY_UP_KEY_TEXT, SUBDELAY_UP_KEY_LONGTEXT, true )
     add_key( "key-subdelay-down", KEY_SUBDELAY_DOWN, NULL,
              SUBDELAY_DOWN_KEY_TEXT, SUBDELAY_DOWN_KEY_LONGTEXT, true )
+    add_key( "key-subpos-up", KEY_SUBPOS_UP, NULL,
+             SUBPOS_UP_KEY_TEXT, SUBPOS_UP_KEY_LONGTEXT, true )
+    add_key( "key-subpos-down", KEY_SUBPOS_DOWN, NULL,
+             SUBPOS_DOWN_KEY_TEXT, SUBPOS_DOWN_KEY_LONGTEXT, true )
     add_key( "key-audiodelay-up", KEY_AUDIODELAY_UP, NULL,
              AUDIODELAY_UP_KEY_TEXT, AUDIODELAY_UP_KEY_LONGTEXT, true )
     add_key( "key-audiodelay-down", KEY_AUDIODELAY_DOWN, NULL,
@@ -2810,6 +2822,8 @@ const struct action libvlc_actions[] =
     { "key-vol-mute", ACTIONID_VOL_MUTE, },
     { "key-subdelay-down", ACTIONID_SUBDELAY_DOWN, },
     { "key-subdelay-up", ACTIONID_SUBDELAY_UP, },
+    { "key-subpos-down", ACTIONID_SUBPOS_DOWN, },
+    { "key-subpos-up", ACTIONID_SUBPOS_UP, },
     { "key-audiodelay-down", ACTIONID_AUDIODELAY_DOWN, },
     { "key-audiodelay-up", ACTIONID_AUDIODELAY_UP, },
     { "key-audio-track", ACTIONID_AUDIO_TRACK, },
diff --git a/src/video_output/vout_subpictures.c b/src/video_output/vout_subpictures.c
index 2c37c55..e440967 100644
--- a/src/video_output/vout_subpictures.c
+++ b/src/video_output/vout_subpictures.c
@@ -156,6 +156,8 @@ static void SpuRenderRegion( spu_t *,
 static void UpdateSPU   ( spu_t *, vlc_object_t * );
 static int  CropCallback( vlc_object_t *, char const *,
                           vlc_value_t, vlc_value_t, void * );
+static int MarginCallback( vlc_object_t *, char const *,
+                           vlc_value_t, vlc_value_t, void * );
 
 static int SpuControl( spu_t *, int, va_list );
 
@@ -243,7 +245,10 @@ int spu_Init( spu_t *p_spu )
     spu_private_t *p_sys = p_spu->p;
 
     /* If the user requested a sub margin, we force the position. */
-    p_sys->i_margin = var_CreateGetInteger( p_spu, "sub-margin" );
+    /* NOTE position is initialized from "sub-margin" belonging to
+       input_thread_t in UpdateSPU() */
+    p_sys->i_margin = 0;
+    //obsolete: p_sys->i_margin = var_CreateGetInteger( p_spu, "sub-margin" );
 
     var_Create( p_spu, "sub-filter", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
     var_AddCallback( p_spu, "sub-filter", SubFilterCallback, p_spu );
@@ -304,12 +309,14 @@ void spu_Attach( spu_t *p_spu, vlc_object_t *p_this, bool b_attach )
     {
         UpdateSPU( p_spu, VLC_OBJECT(p_input) );
         var_AddCallback( p_input, "highlight", CropCallback, p_spu );
+        var_AddCallback( p_input, "sub-margin", MarginCallback, p_spu->p );
         vlc_object_release( p_input );
     }
     else
     {
         /* Delete callback */
         var_DelCallback( p_input, "highlight", CropCallback, p_spu );
+        var_DelCallback( p_input, "sub-margin", MarginCallback, p_spu->p );
         vlc_object_release( p_input );
     }
 }
@@ -1758,6 +1765,7 @@ static void UpdateSPU( spu_t *p_spu, vlc_object_t *p_object )
     p_sys->i_crop_y = var_GetInteger( p_object, "y-start" );
     p_sys->i_crop_width  = var_GetInteger( p_object, "x-end" ) - p_sys->i_crop_x;
     p_sys->i_crop_height = var_GetInteger( p_object, "y-end" ) - p_sys->i_crop_y;
+    p_sys->i_margin = var_GetInteger( p_object, "sub-margin" );
 
     if( var_Get( p_object, "menu-palette", &val ) == VLC_SUCCESS )
     {
@@ -1787,6 +1795,22 @@ static int CropCallback( vlc_object_t *p_object, char const *psz_var,
 }
 
 /*****************************************************************************
+ * MarginCallback: called when requested subtitle position has changed         *
+ *****************************************************************************/
+
+static int MarginCallback( vlc_object_t *p_object, char const *psz_var,
+                         vlc_value_t oldval, vlc_value_t newval, void *p_data )
+{
+    VLC_UNUSED( psz_var ); VLC_UNUSED( oldval ); VLC_UNUSED( p_object );
+    spu_private_t *p_sys = ( spu_private_t* ) p_data;
+
+    vlc_mutex_lock( &p_sys->lock );
+    p_sys->i_margin = newval.i_int;
+    vlc_mutex_unlock( &p_sys->lock );
+    return VLC_SUCCESS;
+}
+
+/*****************************************************************************
  * Buffers allocation callbacks for the filters
  *****************************************************************************/
 struct filter_owner_sys_t




More information about the vlc-devel mailing list