Commit 7b5e02f6 authored by Yoann Peronneau's avatar Yoann Peronneau

Added a Mute OSD icon.

parent dd57adf9
......@@ -31,8 +31,13 @@
#define OSD_ALIGN_TOP 0x4
#define OSD_ALIGN_BOTTOM 0x8
#define OSD_HOR_SLIDER 1
#define OSD_VERT_SLIDER 2
#define OSD_PLAY_ICON 1
#define OSD_PAUSE_ICON 2
#define OSD_SPEAKER_ICON 3
#define OSD_MUTE_ICON 4
/**
* Text style information.
......
......@@ -244,7 +244,7 @@ static void Run( intf_thread_t *p_intf )
if( !p_vout->p_parent_intf || p_vout->b_fullscreen )
{
vout_OSDSlider( VLC_OBJECT( p_intf ),
i_newvol*100/AOUT_VOLUME_MAX, 1 );
i_newvol*100/AOUT_VOLUME_MAX, OSD_VERT_SLIDER );
}
else
{
......@@ -262,7 +262,7 @@ static void Run( intf_thread_t *p_intf )
if( !p_vout->p_parent_intf || p_vout->b_fullscreen )
{
vout_OSDSlider( VLC_OBJECT( p_intf ),
i_newvol*100/AOUT_VOLUME_MAX, 1 );
i_newvol*100/AOUT_VOLUME_MAX, OSD_VERT_SLIDER );
}
else
{
......@@ -272,6 +272,33 @@ static void Run( intf_thread_t *p_intf )
}
}
else if( i_action == ACTIONID_VOL_MUTE )
{
audio_volume_t i_newvol = -1;
aout_VolumeMute( p_intf, &i_newvol );
if( p_vout )
{
if( i_newvol == 0 )
{
vout_OSDMessage( p_intf, _( "Mute" ) );
vout_OSDIcon( VLC_OBJECT( p_intf ), OSD_MUTE_ICON );
}
else
{
if( !p_vout->p_parent_intf || p_vout->b_fullscreen )
{
vout_OSDSlider( VLC_OBJECT( p_intf ),
i_newvol*100/AOUT_VOLUME_MAX, OSD_VERT_SLIDER );
}
else
{
vout_OSDMessage( p_intf, "Vol %d%%",
i_newvol * 100 / AOUT_VOLUME_MAX );
}
}
}
}
else if( i_action == ACTIONID_SUBDELAY_DOWN )
{
int i_delay;
......@@ -294,20 +321,6 @@ static void Run( intf_thread_t *p_intf )
vout_OSDMessage( p_intf, "Subtitle delay %i ms", i_delay*100);
}
}
else if( i_action == ACTIONID_VOL_MUTE )
{
audio_volume_t i_newvol = -1;
aout_VolumeMute( p_intf, &i_newvol );
if( i_newvol == 0 )
{
vout_OSDMessage( p_intf, _( "Mute" ) );
}
else
{
vout_OSDMessage( p_intf, "Vol %d%%",
i_newvol * 100 / AOUT_VOLUME_MAX );
}
}
else if( i_action == ACTIONID_FULLSCREEN && p_vout )
{
var_Get( p_vout, "fullscreen", &val );
......@@ -365,7 +378,7 @@ static void Run( intf_thread_t *p_intf )
if( !p_vout->p_parent_intf || p_vout->b_fullscreen )
{
vout_OSDSlider( VLC_OBJECT( p_intf ),
GetPosition( p_intf ), 0 );
GetPosition( p_intf ), OSD_HOR_SLIDER );
}
else
{
......@@ -381,7 +394,7 @@ static void Run( intf_thread_t *p_intf )
if( !p_vout->p_parent_intf || p_vout->b_fullscreen )
{
vout_OSDSlider( VLC_OBJECT( p_intf ),
GetPosition( p_intf ), 0 );
GetPosition( p_intf ), OSD_HOR_SLIDER );
}
else
{
......@@ -398,7 +411,7 @@ static void Run( intf_thread_t *p_intf )
if( !p_vout->p_parent_intf || p_vout->b_fullscreen )
{
vout_OSDSlider( VLC_OBJECT( p_intf ),
GetPosition( p_intf ), 0 );
GetPosition( p_intf ), OSD_HOR_SLIDER );
}
else
{
......@@ -415,7 +428,7 @@ static void Run( intf_thread_t *p_intf )
if( !p_vout->p_parent_intf || p_vout->b_fullscreen )
{
vout_OSDSlider( VLC_OBJECT( p_intf ),
GetPosition( p_intf ), 0 );
GetPosition( p_intf ), OSD_HOR_SLIDER );
}
else
{
......@@ -425,7 +438,6 @@ static void Run( intf_thread_t *p_intf )
}
else if( i_action == ACTIONID_JUMP_BACKWARD_5MIN && b_seekable )
{
vout_OSDMessage( p_intf, _( "Jump -5 minutes" ) );
val.i_time = -300000000;
var_Set( p_input, "time-offset", val );
if( p_vout )
......@@ -433,7 +445,7 @@ static void Run( intf_thread_t *p_intf )
if( !p_vout->p_parent_intf || p_vout->b_fullscreen )
{
vout_OSDSlider( VLC_OBJECT( p_intf ),
GetPosition( p_intf ), 0 );
GetPosition( p_intf ), OSD_HOR_SLIDER );
}
else
{
......@@ -450,7 +462,7 @@ static void Run( intf_thread_t *p_intf )
if( !p_vout->p_parent_intf || p_vout->b_fullscreen )
{
vout_OSDSlider( VLC_OBJECT( p_intf ),
GetPosition( p_intf ), 0 );
GetPosition( p_intf ), OSD_HOR_SLIDER );
}
else
{
......
......@@ -28,8 +28,8 @@
#include <vlc/vout.h>
#include <osd.h>
#define RECT_EMPTY 0
#define RECT_FILLED 1
#define STYLE_EMPTY 0
#define STYLE_FILLED 1
/*****************************************************************************
* Local prototypes
......@@ -62,7 +62,7 @@ struct subpicture_sys_t
/*****************************************************************************
* Draws a rectangle at the given position in the subpic.
* It may be filled (fill == RECT_FILLED) or empty (fill == RECT_EMPTY).
* It may be filled (fill == STYLE_FILLED) or empty (fill == STYLE_EMPTY).
*****************************************************************************/
static void DrawRect( vout_thread_t *p_vout, subpicture_t *p_subpic,
int i_x1, int i_y1, int i_x2, int i_y2, short fill )
......@@ -70,7 +70,7 @@ static void DrawRect( vout_thread_t *p_vout, subpicture_t *p_subpic,
int x, y;
subpicture_sys_t *p_widget = p_subpic->p_sys;
if( fill == RECT_FILLED )
if( fill == STYLE_FILLED )
{
for( y = i_y1; y <= i_y2; y++ )
{
......@@ -97,7 +97,7 @@ static void DrawRect( vout_thread_t *p_vout, subpicture_t *p_subpic,
/*****************************************************************************
* Draws a triangle at the given position in the subpic.
* It may be filled (fill == RECT_FILLED) or empty (fill == RECT_EMPTY).
* It may be filled (fill == STYLE_FILLED) or empty (fill == STYLE_EMPTY).
*****************************************************************************/
static void DrawTriangle( vout_thread_t *p_vout, subpicture_t *p_subpic,
int i_x1, int i_y1, int i_x2, int i_y2, short fill )
......@@ -107,27 +107,56 @@ static void DrawTriangle( vout_thread_t *p_vout, subpicture_t *p_subpic,
i_mid = i_y1 + ( ( i_y2 - i_y1 ) >> 1 );
if( fill == RECT_FILLED )
if( i_x2 >= i_x1 )
{
for( y = i_y1; y <= i_mid; y++ )
if( fill == STYLE_FILLED )
{
h = y - i_y1;
for( x = i_x1; x <= i_x1 + h && x <= i_x2; x++ )
for( y = i_y1; y <= i_mid; y++ )
{
p_widget->p_pic[ x + p_widget->i_width * y ] = 1;
p_widget->p_pic[ x + p_widget->i_width * ( i_y2 - h ) ] = 1;
h = y - i_y1;
for( x = i_x1; x <= i_x1 + h && x <= i_x2; x++ )
{
p_widget->p_pic[ x + p_widget->i_width * y ] = 1;
p_widget->p_pic[ x + p_widget->i_width * ( i_y2 - h ) ] = 1;
}
}
}
else
{
for( y = i_y1; y <= i_mid; y++ )
{
h = y - i_y1;
p_widget->p_pic[ i_x1 + p_widget->i_width * y ] = 1;
p_widget->p_pic[ i_x1 + h + p_widget->i_width * y ] = 1;
p_widget->p_pic[ i_x1 + p_widget->i_width * ( i_y2 - h ) ] = 1;
p_widget->p_pic[ i_x1 + h + p_widget->i_width * ( i_y2 - h ) ] = 1;
}
}
}
else
{
for( y = i_y1; y <= i_mid; y++ )
if( fill == STYLE_FILLED )
{
h = y - i_y1;
p_widget->p_pic[ i_x1 + p_widget->i_width * y ] = 1;
p_widget->p_pic[ i_x1 + h + p_widget->i_width * y ] = 1;
p_widget->p_pic[ i_x1 + p_widget->i_width * ( i_y2 - h ) ] = 1;
p_widget->p_pic[ i_x1 + h + p_widget->i_width * ( i_y2 - h ) ] = 1;
for( y = i_y1; y <= i_mid; y++ )
{
h = y - i_y1;
for( x = i_x1; x >= i_x1 - h && x >= i_x2; x-- )
{
p_widget->p_pic[ x + p_widget->i_width * y ] = 1;
p_widget->p_pic[ x + p_widget->i_width * ( i_y2 - h ) ] = 1;
}
}
}
else
{
for( y = i_y1; y <= i_mid; y++ )
{
h = y - i_y1;
p_widget->p_pic[ i_x1 + p_widget->i_width * y ] = 1;
p_widget->p_pic[ i_x1 - h + p_widget->i_width * y ] = 1;
p_widget->p_pic[ i_x1 + p_widget->i_width * ( i_y2 - h ) ] = 1;
p_widget->p_pic[ i_x1 - h + p_widget->i_width * ( i_y2 - h ) ] = 1;
}
}
}
}
......@@ -378,7 +407,7 @@ subpicture_t *vout_CreateWidget( vout_thread_t *p_vout )
/*****************************************************************************
* Displays an OSD slider.
* Type 0 is position slider-like, and type 1 is volume slider-like.
* Types are: OSD_HOR_SLIDER and OSD_VERT_SLIDER.
*****************************************************************************/
void vout_OSDSlider( vlc_object_t *p_caller, int i_position, short i_type )
{
......@@ -402,7 +431,7 @@ void vout_OSDSlider( vlc_object_t *p_caller, int i_position, short i_type )
i_y_margin = p_vout->render.i_height / 10;
i_x_margin = i_y_margin;
if( i_type == 0 )
if( i_type == OSD_HOR_SLIDER )
{
p_widget->i_width = p_vout->render.i_width - 2 * i_x_margin;
p_widget->i_height = p_vout->render.i_height / 20;
......@@ -429,27 +458,27 @@ void vout_OSDSlider( vlc_object_t *p_caller, int i_position, short i_type )
}
memset( p_widget->p_pic, 0, p_widget->i_width * p_widget->i_height );
if( i_type == 0 )
if( i_type == OSD_HOR_SLIDER )
{
int i_x_pos = ( p_widget->i_width - 2 ) * i_position / 100;
int i_y_pos = p_widget->i_height / 2;
DrawRect( p_vout, p_subpic, i_x_pos - 1, 2, i_x_pos + 1,
p_widget->i_height - 3, RECT_FILLED );
p_widget->i_height - 3, STYLE_FILLED );
DrawRect( p_vout, p_subpic, 0, 0, p_widget->i_width - 1,
p_widget->i_height - 1, RECT_EMPTY );
p_widget->i_height - 1, STYLE_EMPTY );
}
else if( i_type == 1 )
else if( i_type == OSD_VERT_SLIDER )
{
int i_y_pos = p_widget->i_height / 2;
DrawRect( p_vout, p_subpic, 2, p_widget->i_height -
( p_widget->i_height - 2 ) * i_position / 100,
p_widget->i_width - 3, p_widget->i_height - 3,
RECT_FILLED );
DrawRect( p_vout, p_subpic, 1, i_y_pos, 1, i_y_pos, RECT_FILLED );
STYLE_FILLED );
DrawRect( p_vout, p_subpic, 1, i_y_pos, 1, i_y_pos, STYLE_FILLED );
DrawRect( p_vout, p_subpic, p_widget->i_width - 2, i_y_pos,
p_widget->i_width - 2, i_y_pos, RECT_FILLED );
p_widget->i_width - 2, i_y_pos, STYLE_FILLED );
DrawRect( p_vout, p_subpic, 0, 0, p_widget->i_width - 1,
p_widget->i_height - 1, RECT_EMPTY );
p_widget->i_height - 1, STYLE_EMPTY );
}
vlc_mutex_lock( &p_vout->change_lock );
......@@ -469,7 +498,7 @@ void vout_OSDSlider( vlc_object_t *p_caller, int i_position, short i_type )
/*****************************************************************************
* Displays an OSD icon.
* Types are: OSD_PLAY_ICON, OSD_PAUSE_ICON
* Types are: OSD_PLAY_ICON, OSD_PAUSE_ICON, OSD_SPEAKER_ICON, OSD_MUTE_ICON
*****************************************************************************/
void vout_OSDIcon( vlc_object_t *p_caller, short i_type )
{
......@@ -493,7 +522,7 @@ void vout_OSDIcon( vlc_object_t *p_caller, short i_type )
i_y_margin = p_vout->render.i_height / 15;
i_x_margin = i_y_margin;
p_widget->i_width = p_vout->render.i_width / 22;
p_widget->i_width = p_vout->render.i_width / 20;
p_widget->i_height = p_widget->i_width;
p_widget->i_x = p_vout->render.i_width - i_x_margin -
p_widget->i_width;
......@@ -513,9 +542,9 @@ void vout_OSDIcon( vlc_object_t *p_caller, short i_type )
{
int i_bar_width = p_widget->i_width / 3;
DrawRect( p_vout, p_subpic, 0, 0, i_bar_width - 1,
p_widget->i_height - 1, RECT_FILLED );
p_widget->i_height - 1, STYLE_FILLED );
DrawRect( p_vout, p_subpic, p_widget->i_width - i_bar_width, 0,
p_widget->i_width - 1, p_widget->i_height - 1, RECT_FILLED );
p_widget->i_width - 1, p_widget->i_height - 1, STYLE_FILLED );
}
else if( i_type == OSD_PLAY_ICON )
{
......@@ -523,7 +552,27 @@ void vout_OSDIcon( vlc_object_t *p_caller, short i_type )
int i_delta = ( p_widget->i_width - i_mid ) >> 1;
int i_y2 = ( ( p_widget->i_height - 1 ) >> 1 ) * 2;
DrawTriangle( p_vout, p_subpic, i_delta, 0,
p_widget->i_width - i_delta, i_y2, RECT_FILLED );
p_widget->i_width - i_delta, i_y2, STYLE_FILLED );
}
else if( i_type == OSD_SPEAKER_ICON || i_type == OSD_MUTE_ICON )
{
int i_mid = p_widget->i_height >> 1;
int i_delta = ( p_widget->i_width - i_mid ) >> 1;
int i_y2 = ( ( p_widget->i_height - 1 ) >> 1 ) * 2;
DrawRect( p_vout, p_subpic, i_delta, i_mid / 2,
p_widget->i_width - i_delta,
p_widget->i_height - 1 - i_mid / 2, STYLE_FILLED );
DrawTriangle( p_vout, p_subpic, p_widget->i_width - i_delta, 0,
i_delta, i_y2, STYLE_FILLED );
if( i_type == OSD_MUTE_ICON )
{
int i;
for( i = 1; i < p_widget->i_width; i++ )
{
int k = i + ( p_widget->i_height - i - 1 ) * p_widget->i_width;
p_widget->p_pic[ k ] = 1 - p_widget->p_pic[ k ];
}
}
}
vlc_mutex_lock( &p_vout->change_lock );
......
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