[vlc-devel] [PATCH] Feature #2568: Hotkey for font size change
Rémi Denis-Courmont
remi at remlab.net
Fri Mar 14 09:51:22 CET 2014
On Thu, 13 Mar 2014 23:42:25 -0600, Subodh Shrestha <forsubodh at gmail.com>
wrote:
> + 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);
As a general rule, the hotkeys interface does not clobber the
configuration. In other words, do not change settings permanently; use
var_*() functions instead.
> + }
> + 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;
That's not a valid cast. Libvlc is not a filter.
>
> (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 )
--
Rémi Denis-Courmont
Sent from my collocated server
More information about the vlc-devel
mailing list