prevent sliders to be displayed out of their range

This commit is contained in:
Thomas Bernard 2018-12-15 16:47:00 +01:00
parent 7a8b25ea4f
commit 9f26e372ba
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C
2 changed files with 20 additions and 10 deletions

View File

@ -1958,9 +1958,15 @@ void Window_draw_slider(T_Scroller_button * button)
button->Pos_Y,
button->Length-24,11,MC_Black/*MC_Dark*/);
if (button->Nb_elements>button->Nb_visibles)
slider_position+=
((button->Length-24-button->Cursor_length)*(button->Position)+(button->Nb_elements-button->Nb_visibles)/2)/(button->Nb_elements-button->Nb_visibles);
if (button->Nb_elements > button->Nb_visibles)
{
int pos = ( (button->Length - 24 - button->Cursor_length) * button->Position
+ (button->Nb_elements - button->Nb_visibles) / 2)
/ (button->Nb_elements - button->Nb_visibles);
if ((pos + button->Cursor_length) > (button->Length - 24))
pos = button->Length - 24 - button->Cursor_length;
slider_position += pos;
}
Window_rectangle(slider_position,
button->Pos_Y,
@ -1978,11 +1984,15 @@ void Window_draw_slider(T_Scroller_button * button)
slider_position,
11,button->Length-24,MC_Black/*MC_Dark*/);
if (button->Nb_elements>button->Nb_visibles)
slider_position+=
((button->Length-24-button->Cursor_length)*(button->Position)+(button->Nb_elements-button->Nb_visibles)/2)/(button->Nb_elements-button->Nb_visibles);
//
//(button->Position*) / (button->Nb_elements-button->Nb_visibles));
if (button->Nb_elements > button->Nb_visibles)
{
int pos = ( (button->Length - 24 - button->Cursor_length) * button->Position
+ (button->Nb_elements - button->Nb_visibles) / 2)
/ (button->Nb_elements - button->Nb_visibles);
if ((pos + button->Cursor_length) > (button->Length - 24))
pos = button->Length - 24 - button->Cursor_length;
slider_position += pos;
}
Window_rectangle(button->Pos_X,
slider_position,

View File

@ -70,7 +70,7 @@ T_Scroller_button * Window_set_scroller_button(word x_pos, word y_pos,
word initial_position);
T_Scroller_button * Window_set_horizontal_scroller_button(word x_pos, word y_pos,
word height, word nb_elements, word nb_elements_visible,
word width, word nb_elements, word nb_elements_visible,
word initial_position);
T_Special_button * Window_set_special_button(word x_pos, word y_pos,