GUI Generic list control: now takes cursors and mousewheel shortcuts. Still some mouse cursor problems, but almost done.
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@882 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
f683d9ff2e
commit
5a01415960
140
buttons.c
140
buttons.c
@ -5501,147 +5501,7 @@ void Button_Text()
|
||||
|
||||
clicked_button=Window_clicked_button();
|
||||
if (clicked_button==0)
|
||||
{/*
|
||||
if (Key==SDLK_UP && (cursor_position+list_start)>0)
|
||||
{
|
||||
Key=0;
|
||||
Hide_cursor();
|
||||
cursor_position--;
|
||||
if (cursor_position<0)
|
||||
{
|
||||
list_start=list_start+cursor_position;
|
||||
cursor_position=0;
|
||||
// Mise à jour du scroller
|
||||
font_scroller->Position=list_start;
|
||||
Window_draw_slider(font_scroller);
|
||||
}
|
||||
redraw_is_needed=1;
|
||||
preview_is_needed=1;
|
||||
}
|
||||
if (Key==SDLK_DOWN && (cursor_position+list_start)<(Nb_fonts-1))
|
||||
{
|
||||
Key=0;
|
||||
Hide_cursor();
|
||||
cursor_position++;
|
||||
if (cursor_position>(NB_FONTS-1))
|
||||
{
|
||||
list_start=list_start+cursor_position-(NB_FONTS-1);
|
||||
cursor_position=(NB_FONTS-1);
|
||||
// Mise à jour du scroller
|
||||
font_scroller->Position=list_start;
|
||||
Window_draw_slider(font_scroller);
|
||||
}
|
||||
redraw_is_needed=1;
|
||||
preview_is_needed=1;
|
||||
}
|
||||
if (Key==SDLK_HOME && (cursor_position!=0 || list_start!=0))
|
||||
{
|
||||
Key=0;
|
||||
Hide_cursor();
|
||||
cursor_position=0;
|
||||
list_start=0;
|
||||
// Mise à jour du scroller
|
||||
font_scroller->Position=list_start;
|
||||
Window_draw_slider(font_scroller);
|
||||
redraw_is_needed=1;
|
||||
preview_is_needed=1;
|
||||
}
|
||||
if (Key==SDLK_END && (cursor_position+list_start)<(Nb_fonts-1))
|
||||
{
|
||||
Key=0;
|
||||
Hide_cursor();
|
||||
cursor_position=(Nb_fonts-1)-list_start;
|
||||
if (cursor_position>(NB_FONTS-1))
|
||||
{
|
||||
list_start=list_start+cursor_position-(NB_FONTS-1);
|
||||
cursor_position=(NB_FONTS-1);
|
||||
// Mise à jour du scroller
|
||||
font_scroller->Position=list_start;
|
||||
Window_draw_slider(font_scroller);
|
||||
}
|
||||
redraw_is_needed=1;
|
||||
preview_is_needed=1;
|
||||
}
|
||||
if (Key==SDLK_PAGEDOWN && (cursor_position+list_start)<(Nb_fonts-1))
|
||||
{
|
||||
Key=0;
|
||||
Hide_cursor();
|
||||
if (Nb_fonts<NB_FONTS)
|
||||
{
|
||||
cursor_position=Nb_fonts-1;
|
||||
}
|
||||
else if(cursor_position!=NB_FONTS-1)
|
||||
{
|
||||
cursor_position=NB_FONTS-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
list_start+=NB_FONTS;
|
||||
if (list_start+NB_FONTS>Nb_fonts)
|
||||
{
|
||||
list_start=Nb_fonts-NB_FONTS;
|
||||
}
|
||||
// Mise à jour du scroller
|
||||
font_scroller->Position=list_start;
|
||||
Window_draw_slider(font_scroller);
|
||||
}
|
||||
redraw_is_needed=1;
|
||||
preview_is_needed=1;
|
||||
}
|
||||
if (Key==SDLK_PAGEUP && (cursor_position+list_start)>0)
|
||||
{
|
||||
Key=0;
|
||||
Hide_cursor();
|
||||
if(cursor_position!=0)
|
||||
{
|
||||
cursor_position=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
list_start-=NB_FONTS;
|
||||
if (list_start<0)
|
||||
{
|
||||
list_start=0;
|
||||
}
|
||||
// Mise à jour du scroller
|
||||
font_scroller->Position=list_start;
|
||||
Window_draw_slider(font_scroller);
|
||||
}
|
||||
redraw_is_needed=1;
|
||||
preview_is_needed=1;
|
||||
}
|
||||
if (Key == KEY_MOUSEWHEELUP && list_start>0)
|
||||
{
|
||||
cursor_position+=list_start;
|
||||
if (list_start>=3)
|
||||
list_start-=3;
|
||||
else
|
||||
list_start=0;
|
||||
cursor_position-=list_start;
|
||||
// On affiche à nouveau la liste
|
||||
Hide_cursor();
|
||||
redraw_is_needed=1;
|
||||
// Mise à jour du scroller
|
||||
font_scroller->Position=list_start;
|
||||
Window_draw_slider(font_scroller);
|
||||
}
|
||||
if (Key==KEY_MOUSEWHEELDOWN && list_start<Nb_fonts-NB_FONTS)
|
||||
{
|
||||
cursor_position+=list_start;
|
||||
list_start+=3;
|
||||
if (list_start+NB_FONTS>Nb_fonts)
|
||||
{
|
||||
list_start=Nb_fonts-NB_FONTS;
|
||||
}
|
||||
cursor_position-=list_start;
|
||||
// On affiche à nouveau la liste
|
||||
Hide_cursor();
|
||||
redraw_is_needed=1;
|
||||
// Mise à jour du scroller
|
||||
font_scroller->Position=list_start;
|
||||
Window_draw_slider(font_scroller);
|
||||
}
|
||||
*/
|
||||
if (Is_shortcut(Key,0x100+BUTTON_HELP))
|
||||
Window_help(BUTTON_TEXT, NULL);
|
||||
}
|
||||
|
||||
168
engine.c
168
engine.c
@ -2654,12 +2654,180 @@ short Window_clicked_button(void)
|
||||
// Intercept keys
|
||||
if (Key)
|
||||
{
|
||||
T_List_button * list;
|
||||
|
||||
Button=Window_get_button_shortcut();
|
||||
if (Button)
|
||||
{
|
||||
Key=0;
|
||||
return Button;
|
||||
}
|
||||
// Check if there's a list control and the keys can control it
|
||||
for (list=Window_list_button_list; list!=NULL; list=list->Next)
|
||||
{
|
||||
// FIXME: Make only one list have the keyboard focus.
|
||||
if (1)
|
||||
{
|
||||
if (Key==SDLK_UP && (list->Cursor_position+list->List_start)>0)
|
||||
{
|
||||
Key=0;
|
||||
Hide_cursor();
|
||||
list->Cursor_position--;
|
||||
if (list->Cursor_position<0)
|
||||
{
|
||||
list->List_start=list->List_start+list->Cursor_position;
|
||||
list->Cursor_position=0;
|
||||
// Mise à jour du scroller
|
||||
list->Scroller->Position=list->List_start;
|
||||
Window_draw_slider(list->Scroller);
|
||||
}
|
||||
Window_redraw_list(list);// reduce redraw?
|
||||
// Store the selected value as attribute2
|
||||
Window_attribute2=list->List_start + list->Cursor_position;
|
||||
// Return the control ID of the list.
|
||||
return list->Number;
|
||||
}
|
||||
if (Key==SDLK_DOWN && (list->Cursor_position+list->List_start)<(list->Scroller->Nb_elements-1))
|
||||
{
|
||||
Key=0;
|
||||
Hide_cursor();
|
||||
list->Cursor_position++;
|
||||
if (list->Cursor_position>(list->Scroller->Nb_visibles-1))
|
||||
{
|
||||
list->List_start=list->List_start+list->Cursor_position-(list->Scroller->Nb_visibles-1);
|
||||
list->Cursor_position=(list->Scroller->Nb_visibles-1);
|
||||
// Mise à jour du scroller
|
||||
list->Scroller->Position=list->List_start;
|
||||
Window_draw_slider(list->Scroller);
|
||||
}
|
||||
Window_redraw_list(list);// reduce redraw?
|
||||
// Store the selected value as attribute2
|
||||
Window_attribute2=list->List_start + list->Cursor_position;
|
||||
// Return the control ID of the list.
|
||||
return list->Number;
|
||||
}
|
||||
if (Key==SDLK_HOME && (list->Cursor_position!=0 || list->List_start!=0))
|
||||
{
|
||||
Key=0;
|
||||
Hide_cursor();
|
||||
list->Cursor_position=0;
|
||||
list->List_start=0;
|
||||
// Mise à jour du scroller
|
||||
list->Scroller->Position=list->List_start;
|
||||
Window_draw_slider(list->Scroller);
|
||||
Window_redraw_list(list);// reduce redraw?
|
||||
// Store the selected value as attribute2
|
||||
Window_attribute2=list->List_start + list->Cursor_position;
|
||||
// Return the control ID of the list.
|
||||
return list->Number;
|
||||
}
|
||||
if (Key==SDLK_END && (list->Cursor_position+list->List_start)<(list->Scroller->Nb_elements-1))
|
||||
{
|
||||
Key=0;
|
||||
Hide_cursor();
|
||||
list->Cursor_position=(list->Scroller->Nb_elements-1)-list->List_start;
|
||||
if (list->Cursor_position>(list->Scroller->Nb_visibles-1))
|
||||
{
|
||||
list->List_start=list->List_start+list->Cursor_position-(list->Scroller->Nb_visibles-1);
|
||||
list->Cursor_position=(list->Scroller->Nb_visibles-1);
|
||||
// Mise à jour du scroller
|
||||
list->Scroller->Position=list->List_start;
|
||||
Window_draw_slider(list->Scroller);
|
||||
}
|
||||
Window_redraw_list(list);// reduce redraw?
|
||||
// Store the selected value as attribute2
|
||||
Window_attribute2=list->List_start + list->Cursor_position;
|
||||
// Return the control ID of the list.
|
||||
return list->Number;
|
||||
}
|
||||
if (Key==SDLK_PAGEDOWN && (list->Cursor_position+list->List_start)<(list->Scroller->Nb_elements-1))
|
||||
{
|
||||
Key=0;
|
||||
Hide_cursor();
|
||||
if (list->Scroller->Nb_elements<list->Scroller->Nb_visibles)
|
||||
{
|
||||
list->Cursor_position=list->Scroller->Nb_elements-1;
|
||||
}
|
||||
else if(list->Cursor_position!=list->Scroller->Nb_visibles-1)
|
||||
{
|
||||
list->Cursor_position=list->Scroller->Nb_visibles-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
list->List_start+=list->Scroller->Nb_visibles;
|
||||
if (list->List_start+list->Scroller->Nb_visibles>list->Scroller->Nb_elements)
|
||||
{
|
||||
list->List_start=list->Scroller->Nb_elements-list->Scroller->Nb_visibles;
|
||||
}
|
||||
// Mise à jour du scroller
|
||||
list->Scroller->Position=list->List_start;
|
||||
Window_draw_slider(list->Scroller);
|
||||
}
|
||||
Window_redraw_list(list);// reduce redraw?
|
||||
// Store the selected value as attribute2
|
||||
Window_attribute2=list->List_start + list->Cursor_position;
|
||||
// Return the control ID of the list.
|
||||
return list->Number;
|
||||
}
|
||||
if (Key==SDLK_PAGEUP && (list->Cursor_position+list->List_start)>0)
|
||||
{
|
||||
Key=0;
|
||||
Hide_cursor();
|
||||
if(list->Cursor_position!=0)
|
||||
{
|
||||
list->Cursor_position=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
list->List_start-=list->Scroller->Nb_visibles;
|
||||
if (list->List_start<0)
|
||||
{
|
||||
list->List_start=0;
|
||||
}
|
||||
// Mise à jour du scroller
|
||||
list->Scroller->Position=list->List_start;
|
||||
Window_draw_slider(list->Scroller);
|
||||
}
|
||||
Window_redraw_list(list);// reduce redraw?
|
||||
// Store the selected value as attribute2
|
||||
Window_attribute2=list->List_start + list->Cursor_position;
|
||||
// Return the control ID of the list.
|
||||
return list->Number;
|
||||
}
|
||||
if (Key == KEY_MOUSEWHEELUP && list->List_start>0)
|
||||
{
|
||||
list->Cursor_position+=list->List_start;
|
||||
if (list->List_start>=3)
|
||||
list->List_start-=3;
|
||||
else
|
||||
list->List_start=0;
|
||||
list->Cursor_position-=list->List_start;
|
||||
// On affiche à nouveau la liste
|
||||
Hide_cursor();
|
||||
Window_redraw_list(list);// reduce redraw?
|
||||
// Mise à jour du scroller
|
||||
list->Scroller->Position=list->List_start;
|
||||
Window_draw_slider(list->Scroller);
|
||||
}
|
||||
if (Key==KEY_MOUSEWHEELDOWN && list->List_start<list->Scroller->Nb_elements-list->Scroller->Nb_visibles)
|
||||
{
|
||||
list->Cursor_position+=list->List_start;
|
||||
list->List_start+=3;
|
||||
if (list->List_start+list->Scroller->Nb_visibles>list->Scroller->Nb_elements)
|
||||
{
|
||||
list->List_start=list->Scroller->Nb_elements-list->Scroller->Nb_visibles;
|
||||
}
|
||||
list->Cursor_position-=list->List_start;
|
||||
// On affiche à nouveau la liste
|
||||
Hide_cursor();
|
||||
Window_redraw_list(list);// reduce redraw?
|
||||
// Mise à jour du scroller
|
||||
list->Scroller->Position=list->List_start;
|
||||
Window_draw_slider(list->Scroller);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user