[vlc-devel] [PATCH] Feature #2568: Hotkey for font size change
Subodh Shrestha
forsubodh at gmail.com
Fri Mar 14 06:42:25 CET 2014
- added hotkeys (Alt+u increases fontsize, Alt+Shift+u decreases font size)
- Check whether absolute or relative sizing is being used
-- depends on whether freetype-fontsize is set or not
---
include/vlc_keys.h | 2 ++
modules/control/hotkeys.c | 66 +++++++++++++++++++++++++++++++++++++++++++--
src/config/keys.c | 2 ++
src/libvlc-module.c | 12 +++++++++
4 files changed, 80 insertions(+), 2 deletions(-)
diff --git a/include/vlc_keys.h b/include/vlc_keys.h
index aafa589..883bc41 100644
--- a/include/vlc_keys.h
+++ b/include/vlc_keys.h
@@ -223,6 +223,8 @@ typedef enum vlc_action {
ACTIONID_PROGRAM_SID_NEXT,
ACTIONID_PROGRAM_SID_PREV,
ACTIONID_INTF_POPUP_MENU,
+ ACTIONID_FONTSIZE_UP,
+ ACTIONID_FONTSIZE_DOWN
} vlc_action_t;
diff --git a/modules/control/hotkeys.c b/modules/control/hotkeys.c
index 1e7fcdf..40fb43b 100644
--- a/modules/control/hotkeys.c
+++ b/modules/control/hotkeys.c
@@ -129,7 +129,7 @@ static void Close( vlc_object_t *p_this )
free( p_sys );
}
-static int PutAction( intf_thread_t *p_intf, int i_action )
+static int PutAction( intf_thread_t *p_intf, int i_action, filter_t *p_filter)
{
intf_sys_t *p_sys = p_intf->p_sys;
playlist_t *p_playlist = pl_Get( p_intf );
@@ -1046,6 +1046,67 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
if( p_vout && vout_OSDEpg( p_vout, input_GetItem( p_input ) ) )
DisplayPosition( p_intf, p_vout, p_input );
break;
+
+ case ACTIONID_FONTSIZE_UP:
+ if( p_filter )
+ {
+ int abs_fontsize = var_InheritInteger( p_filter, "freetype-fontsize");
+ int rel_fontsize = var_InheritInteger( p_filter, "freetype-rel-fontsize");
+
+ // If freetype-fontsize is set in config file (non-zero value), it overrides the freetype-rel-fontsize value
+ // in determining the subtitle fontsize.
+ // So checking for this config value first
+ if( abs_fontsize )
+ {
+ config_PutInt(p_filter, "freetype-fontsize", ++abs_fontsize);
+ }
+ else
+ {
+ int MAX_REL_FONTSIZE = 1;
+ // If freetype-rel-fontsize is allowed to go 0 or below, subtitle fontsize gets reset to 12 (absolute value)
+ // So not allowing value to go below 1
+ if( rel_fontsize == MAX_REL_FONTSIZE )
+ {
+ msg_Err( p_filter, "Cannot increase fontsize further using relative sizing" );
+ }
+ else
+ {
+ config_PutInt(p_filter, "freetype-rel-fontsize", --rel_fontsize);
+ }
+ }
+ }
+ break;
+
+ case ACTIONID_FONTSIZE_DOWN:
+ if( p_filter )
+ {
+ int abs_fontsize = var_InheritInteger( p_filter, "freetype-fontsize");
+ int rel_fontsize = var_InheritInteger( p_filter, "freetype-rel-fontsize");
+
+ // If freetype-fontsize is set in config file (non-zero value), it overrides the freetype-rel-fontsize value
+ // in determining the subtitle fontsize.
+ // So checking for this config value first
+ if( abs_fontsize )
+ {
+ int MIN_ABS_FONTSIZE = 1;
+ // If freetype-fontsize gets to 0, then this config value is not used for setting subtitle size,
+ // (and freetype-rel-fontsize is used instead)
+ // So not allowing the value to go below 1
+ if ( abs_fontsize == MIN_ABS_FONTSIZE)
+ {
+ msg_Err( p_filter, "Cannot decrease fontsize further using absolute sizing" );
+ }
+ else
+ {
+ config_PutInt(p_filter, "freetype-fontsize", --abs_fontsize);
+ }
+ }
+ else
+ {
+ config_PutInt(p_filter, "freetype-rel-fontsize", ++rel_fontsize);
+ }
+ }
+ break;
}
if( p_vout )
@@ -1062,12 +1123,13 @@ static int ActionEvent( vlc_object_t *libvlc, char const *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
intf_thread_t *p_intf = (intf_thread_t *)p_data;
+ filter_t *p_filter = (filter_t *)libvlc;
(void)libvlc;
(void)psz_var;
(void)oldval;
- return PutAction( p_intf, newval.i_int );
+ return PutAction( p_intf, newval.i_int , p_filter);
}
static void PlayBookmark( intf_thread_t *p_intf, int i_num )
diff --git a/src/config/keys.c b/src/config/keys.c
index 07c0d75..8684101 100644
--- a/src/config/keys.c
+++ b/src/config/keys.c
@@ -288,6 +288,8 @@ static const struct action actions[] =
{ "deinterlace-mode", ACTIONID_DEINTERLACE_MODE, },
{ "disc-menu", ACTIONID_DISC_MENU, },
{ "faster", ACTIONID_FASTER, },
+ { "fontsize-up", ACTIONID_FONTSIZE_UP, },
+ { "fontsize-down", ACTIONID_FONTSIZE_DOWN, },
{ "frame-next", ACTIONID_FRAME_NEXT, },
{ "incr-scalefactor", ACTIONID_SCALE_UP, },
{ "intf-boss", ACTIONID_INTF_BOSS, },
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index 85637bd..4493bd0 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -1431,6 +1431,11 @@ static const char *const mouse_wheel_texts[] =
#define AUDI_DEVICE_CYCLE_KEY_TEXT N_("Cycle through audio devices")
#define AUDI_DEVICE_CYCLE_KEY_LONGTEXT N_("Cycle through available audio devices")
+#define FONTSIZE_UP_KEY_TEXT N_("Increase font size")
+#define FONTSIZE_UP_KEY_LONGTEXT N_("Increase font size using hotkey")
+
+#define FONTSIZE_DOWN_KEY_TEXT N_("Decrease font size")
+#define FONTSIZE_DOWN_KEY_LONGTEXT N_("Decrease font size using hotkey")
/*
* Quick usage guide for the configuration options:
*
@@ -2388,6 +2393,9 @@ vlc_module_begin ()
/* Playlist clear */
# define KEY_PLAY_CLEAR "Ctrl+w"
+
+# define KEY_FONTSIZE_UP "Alt+u"
+# define KEY_FONTSIZE_DOWN "Alt+Shift+u"
#endif
add_key( "key-toggle-fullscreen", KEY_TOGGLE_FULLSCREEN, TOGGLE_FULLSCREEN_KEY_TEXT,
@@ -2615,6 +2623,10 @@ vlc_module_begin ()
add_key( "key-clear-playlist", KEY_PLAY_CLEAR,
PLAY_CLEAR_KEY_TEXT, PLAY_CLEAR_KEY_LONGTEXT, true )
+ add_key( "key-fontsize-up", KEY_FONTSIZE_UP,
+ FONTSIZE_UP_KEY_TEXT, FONTSIZE_UP_KEY_LONGTEXT, true)
+ add_key( "key-fontsize-down", KEY_FONTSIZE_DOWN,
+ FONTSIZE_DOWN_KEY_TEXT, FONTSIZE_DOWN_KEY_LONGTEXT, true)
add_string( "bookmark1", NULL,
BOOKMARK1_TEXT, BOOKMARK_LONGTEXT, false )
--
1.7.9.5
More information about the vlc-devel
mailing list