Implemented double-click in Brush factory window. Still need to check/fix all other occurences of the listbox control (need to eliminate unnecessary refresh on double-click, or trigger a specific action instead)
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1733 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
5b332bfa25
commit
107779edf5
26
src/engine.c
26
src/engine.c
@ -3145,9 +3145,10 @@ short Window_get_button_shortcut(void)
|
||||
short Window_clicked_button(void)
|
||||
{
|
||||
short Button;
|
||||
byte old_mouse_k;
|
||||
|
||||
old_mouse_k=Mouse_K;
|
||||
Get_input(20);
|
||||
|
||||
// Handle clicks
|
||||
if (Mouse_K)
|
||||
{
|
||||
@ -3174,6 +3175,9 @@ short Window_clicked_button(void)
|
||||
{
|
||||
short clicked_button;
|
||||
T_List_button * list;
|
||||
static Uint32 time_last_click = 0;
|
||||
static int last_list_number = -1;
|
||||
Uint32 time_now;
|
||||
|
||||
// Check which controls was clicked (by rectangular area)
|
||||
clicked_button = Window_get_clicked_button();
|
||||
@ -3186,9 +3190,25 @@ short Window_clicked_button(void)
|
||||
// Click in the textual part of a list.
|
||||
short clicked_line;
|
||||
clicked_line = (((Mouse_Y-Window_pos_Y)/Menu_factor_Y)-list->Entry_button->Pos_Y)>>3;
|
||||
if (clicked_line == list->Cursor_position || // Same as before
|
||||
clicked_line >= list->Scroller->Nb_elements) // Below last line
|
||||
if (clicked_line >= list->Scroller->Nb_elements) // Below last line
|
||||
return 0;
|
||||
time_now = SDL_GetTicks();
|
||||
if (clicked_line == list->Cursor_position)
|
||||
{
|
||||
// Double click check
|
||||
if (old_mouse_k==0 && last_list_number==list->Number && time_now - time_last_click < Config.Double_click_speed)
|
||||
{
|
||||
time_last_click = time_now;
|
||||
// Store the selected value as attribute2
|
||||
Window_attribute2=list->List_start + list->Cursor_position;
|
||||
// Return the control ID of the list.
|
||||
return list->Number;
|
||||
}
|
||||
time_last_click = time_now;
|
||||
last_list_number=list->Number;
|
||||
// Already selected : don't activate anything
|
||||
return 0;
|
||||
}
|
||||
|
||||
Hide_cursor();
|
||||
// Redraw one item as disabled
|
||||
|
||||
@ -1632,7 +1632,7 @@ void Button_Brush_Factory(void)
|
||||
T_Special_button* scriptarea;
|
||||
char scriptdir[MAX_PATH_CHARACTERS];
|
||||
T_Fileselector_item *item;
|
||||
|
||||
int last_selected_item=-1;
|
||||
// Reinitialize the list
|
||||
Free_fileselector_list(&Scripts_selector);
|
||||
strcpy(scriptdir, Data_directory);
|
||||
@ -1675,6 +1675,12 @@ void Button_Brush_Factory(void)
|
||||
|
||||
Update_window_area(0, 0, Window_width, Window_height);
|
||||
Display_cursor();
|
||||
// Wait for mouse release (needed for example after a double-click
|
||||
// that navigates to a subdirectory)
|
||||
while (last_selected_item==-1 && Mouse_K)
|
||||
{
|
||||
Get_input(20);
|
||||
}
|
||||
|
||||
Reset_quicksearch();
|
||||
|
||||
@ -1701,28 +1707,17 @@ void Button_Brush_Factory(void)
|
||||
switch (clicked_button)
|
||||
{
|
||||
case 4:
|
||||
if (last_selected_item == scriptlist->List_start + scriptlist->Cursor_position)
|
||||
{
|
||||
// Double click
|
||||
clicked_button=5;
|
||||
break;
|
||||
}
|
||||
last_selected_item = scriptlist->List_start + scriptlist->Cursor_position;
|
||||
Hide_cursor();
|
||||
Draw_script_information(Get_item_by_index(&Scripts_selector,
|
||||
scriptlist->List_start + scriptlist->Cursor_position));
|
||||
Display_cursor();
|
||||
{
|
||||
// Test double-click
|
||||
static long time_click = 0;
|
||||
static int last_selected_item=-1;
|
||||
static long time_previous;
|
||||
|
||||
time_previous = time_click;
|
||||
time_click = SDL_GetTicks();
|
||||
if (scriptlist->List_start + scriptlist->Cursor_position == last_selected_item)
|
||||
{
|
||||
if (time_click - time_previous < Config.Double_click_speed)
|
||||
clicked_button=5;
|
||||
}
|
||||
else
|
||||
{
|
||||
last_selected_item=scriptlist->List_start + scriptlist->Cursor_position;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 6:
|
||||
@ -1807,7 +1802,7 @@ void Button_Brush_Factory(void)
|
||||
|
||||
scriptlist->Scroller->Nb_elements=Scripts_selector.Nb_elements;
|
||||
Compute_slider_cursor_length(scriptlist->Scroller);
|
||||
|
||||
last_selected_item = -1;
|
||||
Hide_cursor();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user