Commit 849824af authored by Rafaël Carré's avatar Rafaël Carré

ncurses: remove f_slider* from intf context

ManageSlider() -> ChangePosition(), now takes the position increment as (signed) argument
Don't show percentage of media in Position (elapsed/total already show this information)
parent e311921b
...@@ -176,9 +176,6 @@ struct intf_sys_t ...@@ -176,9 +176,6 @@ struct intf_sys_t
bool b_color; bool b_color;
bool b_color_started; bool b_color_started;
float f_slider;
float f_slider_old;
WINDOW *w; WINDOW *w;
int i_box_type; int i_box_type;
...@@ -781,7 +778,7 @@ static void Redraw(intf_thread_t *p_intf, time_t *t_last_refresh) ...@@ -781,7 +778,7 @@ static void Redraw(intf_thread_t *p_intf, time_t *t_last_refresh)
var_Get(p_input, "length", &val); var_Get(p_input, "length", &val);
secstotimestr(buf2, val.i_time / CLOCK_FREQ); secstotimestr(buf2, val.i_time / CLOCK_FREQ);
mvnprintw(y++, 0, COLS, _(" Position : %s/%s (%.2f%%)"), buf1, buf2, p_sys->f_slider); mvnprintw(y++, 0, COLS, _(" Position : %s/%s"), buf1, buf2);
/* Volume */ /* Volume */
aout_VolumeGet(p_playlist, &i_volume); aout_VolumeGet(p_playlist, &i_volume);
...@@ -819,7 +816,13 @@ static void Redraw(intf_thread_t *p_intf, time_t *t_last_refresh) ...@@ -819,7 +816,13 @@ static void Redraw(intf_thread_t *p_intf, time_t *t_last_refresh)
DrawBox(p_sys->w, y, 0, 3, COLS, "", p_sys->b_color); DrawBox(p_sys->w, y, 0, 3, COLS, "", p_sys->b_color);
DrawEmptyLine(p_sys->w, y+1, 1, COLS-2); DrawEmptyLine(p_sys->w, y+1, 1, COLS-2);
DrawLine(p_sys->w, y+1, 1, (int)(p_intf->p_sys->f_slider/100.0 * (COLS -2)));
if (p_input && var_GetInteger(p_input, "state") == PLAYING_S)
{
float pos = var_GetFloat(p_input, "position");
DrawLine(p_sys->w, y+1, 1, (int)(pos * (COLS-2)));
}
y += 3; y += 3;
p_sys->i_box_y = y + 1; p_sys->i_box_y = y + 1;
...@@ -1339,7 +1342,7 @@ static void Redraw(intf_thread_t *p_intf, time_t *t_last_refresh) ...@@ -1339,7 +1342,7 @@ static void Redraw(intf_thread_t *p_intf, time_t *t_last_refresh)
*t_last_refresh = time(0); *t_last_refresh = time(0);
} }
static void ManageSlider(intf_thread_t *p_intf) static void ChangePosition(intf_thread_t *p_intf, float increment)
{ {
intf_sys_t *p_sys = p_intf->p_sys; intf_sys_t *p_sys = p_intf->p_sys;
input_thread_t *p_input = p_sys->p_input; input_thread_t *p_input = p_sys->p_input;
...@@ -1348,16 +1351,12 @@ static void ManageSlider(intf_thread_t *p_intf) ...@@ -1348,16 +1351,12 @@ static void ManageSlider(intf_thread_t *p_intf)
if (!p_input || var_GetInteger(p_input, "state") != PLAYING_S) if (!p_input || var_GetInteger(p_input, "state") != PLAYING_S)
return; return;
pos = var_GetFloat(p_input, "position"); pos = var_GetFloat(p_input, "position") + increment;
if (p_sys->f_slider == p_sys->f_slider_old)
p_sys->f_slider = p_sys->f_slider_old = 100. * pos; if (pos > 0.99) pos = 0.99;
else if (pos < 0.0) pos = 0.0;
{
p_sys->f_slider_old = p_sys->f_slider;
pos = p_sys->f_slider / 100.;
var_SetFloat(p_input, "position", pos); var_SetFloat(p_input, "position", pos);
}
} }
static inline int RemoveLastUTF8Entity(char *psz, int len) static inline int RemoveLastUTF8Entity(char *psz, int len)
...@@ -1726,25 +1725,19 @@ static int HandleKey(intf_thread_t *p_intf) ...@@ -1726,25 +1725,19 @@ static int HandleKey(intf_thread_t *p_intf)
switch(i_key) switch(i_key)
{ {
case KEY_HOME: case KEY_HOME:
p_sys->f_slider = 0; ChangePosition(p_intf, -1.0);
ManageSlider(p_intf);
return 1; return 1;
#ifdef __FreeBSD__ #ifdef __FreeBSD__
case KEY_SELECT: case KEY_SELECT:
#endif #endif
case KEY_END: case KEY_END:
p_sys->f_slider = 99.9; ChangePosition(p_intf, .99);
ManageSlider(p_intf);
return 1; return 1;
case KEY_UP: case KEY_UP:
p_sys->f_slider += 5.0; ChangePosition(p_intf, 0.05);
if (p_sys->f_slider >= 99.0) p_sys->f_slider = 99.0;
ManageSlider(p_intf);
return 1; return 1;
case KEY_DOWN: case KEY_DOWN:
p_sys->f_slider -= 5.0; ChangePosition(p_intf, -0.05);
if (p_sys->f_slider < 0.0) p_sys->f_slider = 0.0;
ManageSlider(p_intf);
return 1; return 1;
default: default:
...@@ -1929,15 +1922,11 @@ static int HandleKey(intf_thread_t *p_intf) ...@@ -1929,15 +1922,11 @@ static int HandleKey(intf_thread_t *p_intf)
/* Navigation */ /* Navigation */
case KEY_RIGHT: case KEY_RIGHT:
p_sys->f_slider += 1.0; ChangePosition(p_intf, 0.01);
if (p_sys->f_slider > 99.9) p_sys->f_slider = 99.9;
ManageSlider(p_intf);
break; break;
case KEY_LEFT: case KEY_LEFT:
p_sys->f_slider -= 1.0; ChangePosition(p_intf, -0.01);
if (p_sys->f_slider < 0.0) p_sys->f_slider = 0.0;
ManageSlider(p_intf);
break; break;
/* Common control */ /* Common control */
...@@ -2053,7 +2042,6 @@ static void Run(intf_thread_t *p_intf) ...@@ -2053,7 +2042,6 @@ static void Run(intf_thread_t *p_intf)
{ {
vlc_object_release(p_sys->p_input); vlc_object_release(p_sys->p_input);
p_sys->p_input = NULL; p_sys->p_input = NULL;
p_sys->f_slider = p_sys->f_slider_old = 0.0;
} }
PL_LOCK; PL_LOCK;
...@@ -2073,11 +2061,8 @@ static void Run(intf_thread_t *p_intf) ...@@ -2073,11 +2061,8 @@ static void Run(intf_thread_t *p_intf)
} }
if ((time(0) - t_last_refresh) >= 1) if ((time(0) - t_last_refresh) >= 1)
{
ManageSlider(p_intf);
Redraw(p_intf, &t_last_refresh); Redraw(p_intf, &t_last_refresh);
} }
}
var_DelCallback(p_playlist, "intf-change", PlaylistChanged, p_intf); var_DelCallback(p_playlist, "intf-change", PlaylistChanged, p_intf);
var_DelCallback(p_playlist, "playlist-item-append", PlaylistChanged, p_intf); var_DelCallback(p_playlist, "playlist-item-append", PlaylistChanged, p_intf);
vlc_restorecancel(canc); vlc_restorecancel(canc);
......
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