Commit 7f00f3bf authored by Simon Latapie's avatar Simon Latapie

* added a i_min, i_max, f_min and f_max in module_config_t structure

 * added a add_integer_with_range() and add_float_with_range()
 * gtk interface: now uses a slider when a min or a max is specified
parent ba3ec85c
......@@ -4,7 +4,7 @@
* It includes functions allowing to declare, get or set configuration options.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: configuration.h,v 1.22 2002/12/10 14:19:44 gbazin Exp $
* $Id: configuration.h,v 1.23 2003/01/06 00:37:29 garf Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -57,6 +57,10 @@ struct module_config_t
char *psz_value; /* Option value */
int i_value; /* Option value */
float f_value; /* Option value */
int i_min; /* Option minimum value */
int i_max; /* Option maximum value */
float f_min; /* Option minimum value */
float f_max; /* Option maximum value */
/* Function to call when commiting a change */
void ( * pf_callback ) ( vlc_object_t * );
......@@ -65,6 +69,7 @@ struct module_config_t
vlc_mutex_t *p_lock; /* Lock to use when modifying the config */
vlc_bool_t b_dirty; /* Dirty flag to indicate a config change */
};
/*****************************************************************************
......@@ -127,15 +132,19 @@ VLC_EXPORT( void, config_UnsetCallbacks, ( module_config_t * ) );
{ static module_config_t tmp = { CONFIG_ITEM_STRING, NULL, name, '\0', text, longtext, psz_value }; p_config[ i_config ] = tmp; p_config[ i_config ].pf_callback = p_callback; } i_config++
#define add_string_from_list( name, psz_value, ppsz_list, p_callback, text, \
longtext ) \
{ static module_config_t tmp = { CONFIG_ITEM_STRING, NULL, name, '\0', text, longtext, psz_value, 0, 0, NULL, ppsz_list }; p_config[ i_config ] = tmp; p_config[ i_config ].pf_callback = p_callback; } i_config++
{ static module_config_t tmp = { CONFIG_ITEM_STRING, NULL, name, '\0', text, longtext, psz_value, 0, 0, 0, 0, 0, 0, NULL, ppsz_list }; p_config[ i_config ] = tmp; p_config[ i_config ].pf_callback = p_callback; } i_config++
#define add_file( name, psz_value, p_callback, text, longtext ) \
{ static module_config_t tmp = { CONFIG_ITEM_FILE, NULL, name, '\0', text, longtext, psz_value, 0, 0 }; p_config[ i_config ] = tmp; p_config[ i_config ].pf_callback = p_callback; } i_config++
#define add_module( name, psz_caps, psz_value, p_callback, text, longtext ) \
{ static module_config_t tmp = { CONFIG_ITEM_MODULE, psz_caps, name, '\0', text, longtext, psz_value }; p_config[ i_config ] = tmp; p_config[ i_config ].pf_callback = p_callback; } i_config++
#define add_integer( name, i_value, p_callback, text, longtext ) \
{ static module_config_t tmp = { CONFIG_ITEM_INTEGER, NULL, name, '\0', text, longtext, NULL, i_value }; p_config[ i_config ] = tmp; p_config[ i_config ].pf_callback = p_callback; } i_config++
#define add_integer_with_range( name, i_value, i_min, i_max, p_callback, text, longtext ) \
{ static module_config_t tmp = { CONFIG_ITEM_INTEGER, NULL, name, '\0', text, longtext, NULL, i_value, 0, i_min, i_max }; p_config[ i_config ] = tmp; p_config[ i_config ].pf_callback = p_callback; } i_config++
#define add_float( name, f_value, p_callback, text, longtext ) \
{ static module_config_t tmp = { CONFIG_ITEM_FLOAT, NULL, name, '\0', text, longtext, NULL, 0, f_value }; p_config[ i_config ] = tmp; p_config[ i_config ].pf_callback = p_callback; } i_config++
#define add_float_with_range( name, f_value, f_min, f_max, p_callback, text, longtext ) \
{ static module_config_t tmp = { CONFIG_ITEM_FLOAT, NULL, name, '\0', text, longtext, NULL, 0, f_value, 0, 0, f_min, f_max }; p_config[ i_config ] = tmp; p_config[ i_config ].pf_callback = p_callback; } i_config++
#define add_bool( name, b_value, p_callback, text, longtext ) \
{ static module_config_t tmp = { CONFIG_ITEM_BOOL, NULL, name, '\0', text, longtext, NULL, b_value }; p_config[ i_config ] = tmp; p_config[ i_config ].pf_callback = p_callback; } i_config++
......
......@@ -2,7 +2,7 @@
* modules_inner.h : Macros used from within a module.
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: modules_inner.h,v 1.35 2002/12/10 12:46:35 gbazin Exp $
* $Id: modules_inner.h,v 1.36 2003/01/06 00:37:29 garf Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -114,8 +114,7 @@
} \
{ \
static module_config_t tmp = { CONFIG_HINT_END, NULL, NULL, '\0', \
NULL, NULL, NULL, 0, 0.0, NULL, \
NULL, NULL, VLC_FALSE }; \
NULL, NULL, NULL, 0, 0.0, 0, 0, 0.0, 0.0, NULL,NULL, NULL, VLC_FALSE }; \
p_config[ i_config ] = tmp; \
} \
config_Duplicate( p_module, p_config ); \
......
This diff is collapsed.
......@@ -2,7 +2,7 @@
* adjust.c : Contrast/Hue/Saturation/Brightness video plugin for vlc
*****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN
* $Id: adjust.c,v 1.4 2002/12/12 10:56:24 garf Exp $
* $Id: adjust.c,v 1.5 2003/01/06 00:37:30 garf Exp $
*
* Authors: Simon Latapie <garf@via.ecp.fr>, Samuel Hocevar <sam@zoy.org>
*
......@@ -63,10 +63,10 @@ static void Render ( vout_thread_t *, picture_t * );
vlc_module_begin();
add_category_hint( N_("Miscellaneous"), NULL );
add_float( "Contrast", 1.0, NULL, CONT_TEXT, CONT_LONGTEXT );
add_float( "Brightness", 1.0, NULL, LUM_TEXT, LUM_LONGTEXT );
add_integer( "Hue", 0, NULL, HUE_TEXT, HUE_LONGTEXT );
add_float( "Saturation", 1.0, NULL, SAT_TEXT, SAT_LONGTEXT );
add_float_with_range( "Contrast", 1.0, 0.0, 2.0, NULL, CONT_TEXT, CONT_LONGTEXT );
add_float_with_range( "Brightness", 1.0, 0.0, 2.0, NULL, LUM_TEXT, LUM_LONGTEXT );
add_integer_with_range( "Hue", 0, 0, 360, NULL, HUE_TEXT, HUE_LONGTEXT );
add_float_with_range( "Saturation", 1.0, 0.0, 3.0, NULL, SAT_TEXT, SAT_LONGTEXT );
set_description( _("Contrast/Hue/Saturation/Brightness filter") );
set_capability( "video filter", 0 );
add_shortcut( "adjust" );
......
......@@ -2,7 +2,7 @@
* libvlc.h: main libvlc header
*****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
* $Id: libvlc.h,v 1.31 2002/12/18 17:52:23 gbazin Exp $
* $Id: libvlc.h,v 1.32 2003/01/06 00:37:30 garf Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -432,7 +432,7 @@ vlc_module_begin();
add_module_with_short( "aout", 'A', "audio output", NULL, NULL,
AOUT_TEXT, AOUT_LONGTEXT );
add_bool( "audio", 1, NULL, AUDIO_TEXT, AUDIO_LONGTEXT );
add_integer( "volume", -1, NULL, VOLUME_TEXT, VOLUME_LONGTEXT );
add_integer_with_range( "volume", 256, 0, 1024, NULL, VOLUME_TEXT, VOLUME_LONGTEXT );
add_integer( "aout-rate", -1, NULL, AOUT_RATE_TEXT, AOUT_RATE_LONGTEXT );
add_integer( "aout-channels", -1, NULL,
AOUT_CHANNELS_TEXT, AOUT_CHANNELS_LONGTEXT );
......@@ -555,19 +555,19 @@ vlc_module_end();
static module_config_t p_help_config[] =
{
{ CONFIG_ITEM_BOOL, NULL, "help", 'h', N_("print help"),
NULL, NULL, 0, 0.0, NULL, NULL, NULL, VLC_FALSE },
NULL, NULL, 0, 0.0, 0, 0, 0.0, 0.0, NULL, NULL, NULL, VLC_FALSE },
{ CONFIG_ITEM_BOOL, NULL, "longhelp", 'H', N_("print detailed help"),
NULL, NULL, 0, 0.0, NULL, NULL, NULL, VLC_FALSE },
NULL, NULL, 0, 0.0, 0, 0, 0.0, 0.0, NULL, NULL, NULL, VLC_FALSE },
{ CONFIG_ITEM_BOOL, NULL, "list", 'l',
N_("print a list of available modules"),
NULL, NULL, 0, 0.0, NULL, NULL, NULL, VLC_FALSE },
NULL, NULL, 0, 0.0, 0, 0, 0.0, 0.0, NULL, NULL, NULL, VLC_FALSE },
{ CONFIG_ITEM_STRING, NULL, "module", 'p', N_("print help on module"),
NULL, NULL, 0, 0.0, NULL, NULL, NULL, VLC_FALSE },
NULL, NULL, 0, 0.0, 0, 0, 0.0, 0.0, NULL, NULL, NULL, VLC_FALSE },
{ CONFIG_ITEM_BOOL, NULL, "version", '\0',
N_("print version information"),
NULL, NULL, 0, 0.0, NULL, NULL, NULL, VLC_FALSE },
NULL, NULL, 0, 0.0, 0, 0, 0.0, 0.0, NULL, NULL, NULL, VLC_FALSE },
{ CONFIG_HINT_END, NULL, NULL, '\0', NULL,
NULL, NULL, 0, 0.0, NULL, NULL, NULL, VLC_FALSE }
NULL, NULL, 0, 0.0, 0, 0, 0.0, 0.0, NULL, NULL, NULL, VLC_FALSE }
};
/*****************************************************************************
......
......@@ -2,7 +2,7 @@
* configuration.c management of the modules configuration
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: configuration.c,v 1.47 2002/12/13 01:56:30 gbazin Exp $
* $Id: configuration.c,v 1.48 2003/01/06 00:37:30 garf Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -222,7 +222,23 @@ void __config_PutInt( vlc_object_t *p_this, const char *psz_name, int i_value )
return;
}
p_config->i_value = i_value;
/* if i_min == i_max == 0, then do not use them */
if ((p_config->i_min == 0) && (p_config->i_max == 0))
{
p_config->i_value = i_value;
}
else if (i_value < p_config->i_min)
{
p_config->i_value = p_config->i_min;
}
else if (i_value > p_config->i_max)
{
p_config->i_value = p_config->i_max;
}
else
{
p_config->i_value = i_value;
}
if( p_config->pf_callback )
{
......@@ -255,7 +271,23 @@ void __config_PutFloat( vlc_object_t *p_this,
return;
}
p_config->f_value = f_value;
/* if f_min == f_max == 0, then do not use them */
if ((p_config->f_min == 0) && (p_config->f_max == 0))
{
p_config->f_value = f_value;
}
else if (f_value < p_config->f_min)
{
p_config->f_value = p_config->f_min;
}
else if (f_value > p_config->f_max)
{
p_config->f_value = p_config->f_max;
}
else
{
p_config->f_value = f_value;
}
if( p_config->pf_callback )
{
......@@ -353,7 +385,11 @@ void config_Duplicate( module_t *p_module, module_config_t *p_orig )
p_module->p_config[i].i_type = p_orig[i].i_type;
p_module->p_config[i].i_short = p_orig[i].i_short;
p_module->p_config[i].i_value = p_orig[i].i_value;
p_module->p_config[i].i_min = p_orig[i].i_min;
p_module->p_config[i].i_max = p_orig[i].i_max;
p_module->p_config[i].f_value = p_orig[i].f_value;
p_module->p_config[i].f_min = p_orig[i].f_min;
p_module->p_config[i].f_max = p_orig[i].f_max;
p_module->p_config[i].b_dirty = p_orig[i].b_dirty;
p_module->p_config[i].psz_type = p_orig[i].psz_type ?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment