Drag and drop files: more stable. Unfinished
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1570 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
cd39485232
commit
c83cd8c339
45
src/engine.c
45
src/engine.c
@ -41,6 +41,7 @@
|
|||||||
#include "pages.h"
|
#include "pages.h"
|
||||||
#include "layers.h"
|
#include "layers.h"
|
||||||
#include "factory.h"
|
#include "factory.h"
|
||||||
|
#include "loadsave.h"
|
||||||
|
|
||||||
|
|
||||||
// we need this as global
|
// we need this as global
|
||||||
@ -658,6 +659,39 @@ void Main_handler(void)
|
|||||||
Display_all_screen();
|
Display_all_screen();
|
||||||
Display_cursor();
|
Display_cursor();
|
||||||
}
|
}
|
||||||
|
else if (Drop_file_name)
|
||||||
|
{
|
||||||
|
// A file was dragged into Grafx2's window
|
||||||
|
Upload_infos_page_main(Main_backups->Pages);
|
||||||
|
|
||||||
|
if ( (!Main_image_is_modified) || Confirmation_box("Discard unsaved changes ?") )
|
||||||
|
{
|
||||||
|
T_IO_Context context;
|
||||||
|
char* flimit;
|
||||||
|
byte old_cursor_shape;
|
||||||
|
|
||||||
|
flimit = Find_last_slash(Drop_file_name);
|
||||||
|
*(flimit++) = '\0';
|
||||||
|
|
||||||
|
Hide_cursor();
|
||||||
|
old_cursor_shape=Cursor_shape;
|
||||||
|
Cursor_shape=CURSOR_SHAPE_HOURGLASS;
|
||||||
|
Display_cursor();
|
||||||
|
|
||||||
|
Init_context_layered_image(&context, flimit, Drop_file_name);
|
||||||
|
Load_image(&context);
|
||||||
|
Destroy_context(&context);
|
||||||
|
Redraw_layered_image();
|
||||||
|
Hide_cursor();
|
||||||
|
Cursor_shape=old_cursor_shape;
|
||||||
|
Display_cursor();
|
||||||
|
End_of_modification();
|
||||||
|
Display_all_screen();
|
||||||
|
|
||||||
|
free(Drop_file_name);
|
||||||
|
Drop_file_name=NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(Get_input())
|
if(Get_input())
|
||||||
{
|
{
|
||||||
@ -2750,6 +2784,7 @@ short Window_get_clicked_button(void)
|
|||||||
Display_cursor();
|
Display_cursor();
|
||||||
Delay_with_active_mouse((Mouse_K==1)? Config.Delay_left_click_on_slider : Config.Delay_right_click_on_slider);
|
Delay_with_active_mouse((Mouse_K==1)? Config.Delay_left_click_on_slider : Config.Delay_right_click_on_slider);
|
||||||
Hide_cursor();
|
Hide_cursor();
|
||||||
|
Need_timer_for_tool=1;
|
||||||
Window_unselect_normal_button(temp1->Pos_X,temp1->Pos_Y,temp1->Width,temp1->Height);
|
Window_unselect_normal_button(temp1->Pos_X,temp1->Pos_Y,temp1->Width,temp1->Height);
|
||||||
Display_cursor();
|
Display_cursor();
|
||||||
return temp1->Number;
|
return temp1->Number;
|
||||||
@ -3296,15 +3331,13 @@ void Delay_with_active_mouse(int speed)
|
|||||||
Uint32 end;
|
Uint32 end;
|
||||||
end = SDL_GetTicks()+speed*10;
|
end = SDL_GetTicks()+speed*10;
|
||||||
|
|
||||||
//Need_Timer_events=1;
|
Need_timer_for_tool=1;
|
||||||
//Activate_timer(10);
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Get_input();
|
Get_input();
|
||||||
now = SDL_GetTicks();
|
now = SDL_GetTicks();
|
||||||
} while (now<end);
|
} while (now<end);
|
||||||
//Need_Timer_events=0;
|
Need_timer_for_tool=0;
|
||||||
//Disable_timer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ======== Timer stuff =========
|
// ======== Timer stuff =========
|
||||||
@ -3320,9 +3353,9 @@ static SDL_TimerID Current_timer=NULL;
|
|||||||
/// It is designed especially to "wake" grafx2 in some situations where
|
/// It is designed especially to "wake" grafx2 in some situations where
|
||||||
/// an animation or something is running, even if the mouse and keyboard
|
/// an animation or something is running, even if the mouse and keyboard
|
||||||
/// are untouched.
|
/// are untouched.
|
||||||
Uint32 Push_timer_event(Uint32 i, void* p)
|
Uint32 Push_timer_event(Uint32 i, __attribute__((unused)) void* p)
|
||||||
{
|
{
|
||||||
//if (Need_Timer_events)
|
if (Need_timer_for_tool || Need_timer_for_cursor)
|
||||||
{
|
{
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
SDL_UserEvent user_event;
|
SDL_UserEvent user_event;
|
||||||
|
|||||||
65
src/input.c
65
src/input.c
@ -51,7 +51,10 @@ int Snap_axis = 0;
|
|||||||
int Snap_axis_origin_X;
|
int Snap_axis_origin_X;
|
||||||
int Snap_axis_origin_Y;
|
int Snap_axis_origin_Y;
|
||||||
|
|
||||||
volatile int Need_Timer_events;
|
volatile int Need_timer_for_tool;
|
||||||
|
volatile int Need_timer_for_cursor;
|
||||||
|
|
||||||
|
char * Drop_file_name = NULL;
|
||||||
|
|
||||||
// --
|
// --
|
||||||
|
|
||||||
@ -229,7 +232,11 @@ int Move_cursor_with_constraints()
|
|||||||
feedback=1;
|
feedback=1;
|
||||||
|
|
||||||
if (Input_new_mouse_K == 0)
|
if (Input_new_mouse_K == 0)
|
||||||
|
{
|
||||||
Input_sticky_control = 0;
|
Input_sticky_control = 0;
|
||||||
|
Need_timer_for_tool=0;
|
||||||
|
Need_timer_for_cursor=0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Hide cursor, because even just a click change needs it
|
// Hide cursor, because even just a click change needs it
|
||||||
if (!Mouse_moved)
|
if (!Mouse_moved)
|
||||||
@ -753,26 +760,43 @@ int Get_input(void)
|
|||||||
|
|
||||||
case SDL_SYSWMEVENT:
|
case SDL_SYSWMEVENT:
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
if(event.syswm.msg->msg == WM_DROPFILES) {
|
if(event.syswm.msg->msg == WM_DROPFILES)
|
||||||
int fileCount;
|
{
|
||||||
|
int file_count;
|
||||||
HDROP hdrop = (HDROP)(event.syswm.msg->wParam);
|
HDROP hdrop = (HDROP)(event.syswm.msg->wParam);
|
||||||
if((fileCount = DragQueryFile(hdrop,(UINT)-1,(LPTSTR) NULL ,(UINT) 0)) > 0) {
|
if((file_count = DragQueryFile(hdrop,(UINT)-1,(LPTSTR) NULL ,(UINT) 0)) > 0)
|
||||||
char buf[MAX_PATH];
|
{
|
||||||
T_IO_Context context;
|
long len;
|
||||||
char* flimit;
|
// Query filename length
|
||||||
|
len = DragQueryFile(hdrop,0 ,NULL ,0);
|
||||||
DragQueryFile(hdrop,0 ,(LPTSTR) buf ,(UINT) MAX_PATH);
|
if (len)
|
||||||
flimit = Find_last_slash(buf);
|
{
|
||||||
*(flimit++) = '\0';
|
Drop_file_name=calloc(len+1,1);
|
||||||
|
if (Drop_file_name)
|
||||||
// TODO : check if there are unsaved changes first !
|
{
|
||||||
|
if (DragQueryFile(hdrop,0 ,(LPTSTR) Drop_file_name ,(UINT) MAX_PATH))
|
||||||
Init_context_layered_image(&context, flimit, buf);
|
{
|
||||||
Load_image(&context);
|
// Success
|
||||||
Destroy_context(&context);
|
}
|
||||||
Redraw_layered_image();
|
else
|
||||||
End_of_modification();
|
{
|
||||||
Display_all_screen();
|
free(Drop_file_name);
|
||||||
|
// Don't report name copy error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Don't report alloc error (for a file name? :/ )
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Don't report weird Windows error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Drop of zero files. Thanks for the information, Bill.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -798,6 +822,7 @@ int Get_input(void)
|
|||||||
Directional_left||Directional_up_left))
|
Directional_left||Directional_up_left))
|
||||||
{
|
{
|
||||||
Directional_delay=-1;
|
Directional_delay=-1;
|
||||||
|
Need_timer_for_cursor=1;
|
||||||
Directional_last_move=SDL_GetTicks();
|
Directional_last_move=SDL_GetTicks();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
16
src/input.h
16
src/input.h
@ -60,5 +60,17 @@ extern int Snap_axis_origin_X;
|
|||||||
/// For the :Snap_axis mode, sets the origin's point (in image coordinates)
|
/// For the :Snap_axis mode, sets the origin's point (in image coordinates)
|
||||||
extern int Snap_axis_origin_Y;
|
extern int Snap_axis_origin_Y;
|
||||||
|
|
||||||
/// Boolean, true if Push_timer_event() should put "ticks" in the SDL queue
|
///
|
||||||
extern volatile int Need_Timer_events;
|
/// Boolean, true if the timer should put "ticks" in the SDL queue.
|
||||||
|
/// This one flag is for tools (airbrush) or windows (repeatable button) that require it.
|
||||||
|
extern volatile int Need_timer_for_tool;
|
||||||
|
///
|
||||||
|
/// Boolean, true if the timer should put "ticks" in the SDL queue.
|
||||||
|
/// This one flag is for the mouse emulation, by keyboard/joystick.
|
||||||
|
extern volatile int Need_timer_for_cursor;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// This malloced string is set when a drag-and-drop event
|
||||||
|
/// brings a file to Grafx2's window.
|
||||||
|
extern char * Drop_file_name;
|
||||||
|
|
||||||
@ -1908,8 +1908,7 @@ void Airbrush_1_0(void)
|
|||||||
Backup();
|
Backup();
|
||||||
Shade_table=Shade_table_left;
|
Shade_table=Shade_table_left;
|
||||||
|
|
||||||
//Need_Timer_events=1;
|
Need_timer_for_tool=1;
|
||||||
//Activate_timer(10);
|
|
||||||
if (SDL_GetTicks()>Airbrush_next_time)
|
if (SDL_GetTicks()>Airbrush_next_time)
|
||||||
{
|
{
|
||||||
Airbrush(LEFT_SIDE);
|
Airbrush(LEFT_SIDE);
|
||||||
@ -1935,8 +1934,7 @@ void Airbrush_2_0(void)
|
|||||||
Init_start_operation();
|
Init_start_operation();
|
||||||
Backup();
|
Backup();
|
||||||
Shade_table=Shade_table_right;
|
Shade_table=Shade_table_right;
|
||||||
//Need_Timer_events=1;
|
Need_timer_for_tool=1;
|
||||||
//Activate_timer(10);
|
|
||||||
if (SDL_GetTicks()>Airbrush_next_time)
|
if (SDL_GetTicks()>Airbrush_next_time)
|
||||||
{
|
{
|
||||||
Airbrush(RIGHT_SIDE);
|
Airbrush(RIGHT_SIDE);
|
||||||
@ -1993,8 +1991,7 @@ void Airbrush_0_2(void)
|
|||||||
//
|
//
|
||||||
{
|
{
|
||||||
Operation_stack_size-=2;
|
Operation_stack_size-=2;
|
||||||
//Need_Timer_events=0;
|
//Need_timer_for_tool=0; // Not needed, mouse release did it in Get_input()
|
||||||
//Disable_timer();
|
|
||||||
End_of_modification();
|
End_of_modification();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user