diff --git a/graph.c b/graph.c index b473a193..9029f439 100644 --- a/graph.c +++ b/graph.c @@ -1011,11 +1011,32 @@ void Fill_general(byte fill_color) ////////////////////////// avec gestion de previews ////////////////////////// ////////////////////////////////////////////////////////////////////////////// + // Data used by ::Init_permanent_draw() and ::Pixel_figure_permanent() + static Uint32 Permanent_draw_next_refresh=0; + static int Permanent_draw_count=0; + + void Init_permanent_draw(void) + { + Permanent_draw_count = 0; + Permanent_draw_next_refresh = SDL_GetTicks() + 100; + } // Affichage d'un point de façon définitive (utilisation du pinceau) void Pixel_figure_permanent(word x_pos,word y_pos,byte color) { Display_paintbrush(x_pos,y_pos,color,0); + Permanent_draw_count ++; + + // Check every 8 pixels + if (! (Permanent_draw_count&7)) + { + Uint32 now = SDL_GetTicks(); + if (now>= Permanent_draw_next_refresh) + { + Permanent_draw_next_refresh = now+100; + Flush_update(); + } + } } // Affichage d'un point de façon définitive @@ -1157,6 +1178,7 @@ void Draw_empty_circle_general(short center_x,short center_y,short radius,byte c void Draw_empty_circle_permanent(short center_x,short center_y,short radius,byte color) { Pixel_figure=Pixel_figure_permanent; + Init_permanent_draw(); Draw_empty_circle_general(center_x,center_y,radius,color); Update_part_of_screen(center_x - radius, center_y - radius, 2* radius+1, 2*radius+1); } @@ -1299,6 +1321,7 @@ void Draw_empty_ellipse_general(short center_x,short center_y,short horizontal_r void Draw_empty_ellipse_permanent(short center_x,short center_y,short horizontal_radius,short vertical_radius,byte color) { Pixel_figure=Pixel_figure_permanent; + Init_permanent_draw(); Draw_empty_ellipse_general(center_x,center_y,horizontal_radius,vertical_radius,color); Update_part_of_screen(center_x - horizontal_radius, center_y - vertical_radius, 2* horizontal_radius+1, 2*vertical_radius+1); } @@ -1498,8 +1521,7 @@ void Draw_line_general(short start_x,short start_y,short end_x,short end_y, byte short incr_x,incr_y; short i,cumul; short delta_x,delta_y; - - + x_pos=start_x; y_pos=start_y; @@ -1563,11 +1585,12 @@ void Draw_line_general(short start_x,short start_y,short end_x,short end_y, byte // -- Tracer définitif d'une ligne -- -void Draw_line_permanet(short start_x,short start_y,short end_x,short end_y, byte color) +void Draw_line_permanent(short start_x,short start_y,short end_x,short end_y, byte color) { int w = end_x-start_x, h = end_y - start_y; Pixel_figure=Pixel_figure_permanent; + Init_permanent_draw(); Draw_line_general(start_x,start_y,end_x,end_y,color); Update_part_of_screen((start_x=Screen_height) { Input_new_mouse_Y=Screen_height-1; - bl=1; + Mouse_blocked=1; } if (Input_new_mouse_X>=Screen_width) { Input_new_mouse_X=Screen_width-1; - bl=1; + Mouse_blocked=1; } //Gestion "avancée" du curseur: interdire la descente du curseur dans le //menu lorsqu'on est en train de travailler dans l'image @@ -136,7 +136,7 @@ int Move_cursor_with_constraints() if(Menu_Y<=Input_new_mouse_Y) { //On bloque le curseur en fin d'image - bl++; + Mouse_blocked=1; Input_new_mouse_Y=Menu_Y-1; //La ligne !!au-dessus!! du menu } @@ -146,7 +146,7 @@ int Move_cursor_with_constraints() { if(Input_new_mouse_X>=Main_separator_position) { - bl++; + Mouse_blocked=1; Input_new_mouse_X=Main_separator_position-1; } } @@ -154,7 +154,7 @@ int Move_cursor_with_constraints() { if(Input_new_mouse_XConfig.Mouse_merge_movement) + if (Operation_stack_size != 0) feedback=1; } @@ -653,7 +657,10 @@ int Get_input(void) Key_ANSI = 0; Key = 0; - Mouse_count=0; + Mouse_moved=0; + Mouse_blocked=0; + Input_new_mouse_X = Mouse_X; + Input_new_mouse_Y = Mouse_Y; // Process as much events as possible without redrawing the screen. // This mostly allows us to merge mouse events for people with an high @@ -770,11 +777,20 @@ int Get_input(void) } } } - // Vidage de toute mise à jour de l'affichage à l'écran qui serait encore en attente. - // (c'est fait ici car on est sur que cette function est apellée partout ou on a besoin d'interragir avec l'utilisateur) + // If the cursor was moved since last update, + // it was erased, so we need to redraw it (with the preview brush) + if (Mouse_moved) + { + Compute_paintbrush_coordinates(); + Display_cursor(); + } + // Commit any pending screen update. + // This is done in this function because it's called after reading + // some user input. Flush_update(); - return user_feedback_required; + + return Mouse_moved || user_feedback_required; } void Adjust_mouse_sensitivity(word fullscreen) diff --git a/operatio.c b/operatio.c index d8ad8908..d9b359ce 100644 --- a/operatio.c +++ b/operatio.c @@ -224,7 +224,7 @@ void Freehand_mode1_1_2(void) { Hide_cursor(); Print_coordinates(); - Draw_line_permanet(start_x,start_y,Paintbrush_X,Paintbrush_Y,Fore_color); + Draw_line_permanent(start_x,start_y,Paintbrush_X,Paintbrush_Y,Fore_color); Display_cursor(); } @@ -279,7 +279,7 @@ void Freehand_mode1_2_2(void) { Print_coordinates(); Hide_cursor(); - Draw_line_permanet(start_x,start_y,Paintbrush_X,Paintbrush_Y,Back_color); + Draw_line_permanent(start_x,start_y,Paintbrush_X,Paintbrush_Y,Back_color); Display_cursor(); } @@ -572,7 +572,7 @@ void Line_0_5(void) Pixel_figure_preview_auto (start_x,start_y); Hide_line_preview (start_x,start_y,end_x,end_y); Display_paintbrush (start_x,start_y,color,0); - Draw_line_permanet(start_x,start_y,end_x,end_y,color); + Draw_line_permanent(start_x,start_y,end_x,end_y,color); End_of_modification(); if ( (Config.Coords_rel) && (Menu_is_visible) ) @@ -695,7 +695,7 @@ void K_line_0_6(void) Display_paintbrush(start_x,start_y,color,0); direction=(direction & 0x7F); } - Draw_line_permanet(start_x,start_y,Paintbrush_X,Paintbrush_Y,color); + Draw_line_permanent(start_x,start_y,Paintbrush_X,Paintbrush_Y,color); Paintbrush_shape=PAINTBRUSH_SHAPE_POINT; Operation_push(direction); @@ -2242,7 +2242,7 @@ void Polygon_12_9(void) Paintbrush_shape=Paintbrush_shape_before_operation; // Le pied aurait été de ne pas repasser sur le 1er point de la 1ère ligne // mais c'est pas possible :( - Draw_line_permanet(start_x,start_y,end_x,end_y,color); + Draw_line_permanent(start_x,start_y,end_x,end_y,color); Paintbrush_shape=PAINTBRUSH_SHAPE_POINT; Display_cursor(); @@ -2534,7 +2534,7 @@ void Polyform_12_8(void) Hide_line_preview(start_x,start_y,end_x,end_y); // On l'affiche de façon définitive: - Draw_line_permanet(start_x,start_y,Paintbrush_X,Paintbrush_Y,color); + Draw_line_permanent(start_x,start_y,Paintbrush_X,Paintbrush_Y,color); // Et on affiche un pixel de preview en (Paintbrush_X,Paintbrush_Y): Pixel_figure_preview(Paintbrush_X,Paintbrush_Y,color); @@ -2565,7 +2565,7 @@ void Polyform_12_8(void) Hide_line_preview(start_x,start_y,end_x,end_y); // On affiche de façon définitive le bouclage du polygone: - Draw_line_permanet(start_x,start_y,initial_x,initial_y,color); + Draw_line_permanent(start_x,start_y,initial_x,initial_y,color); Display_cursor(); End_of_modification(); @@ -5056,7 +5056,7 @@ void Centered_lines_12_7(void) Smear_start=1; Display_paintbrush (start_x,start_y,color,0); - Draw_line_permanet(start_x,start_y,Paintbrush_X,Paintbrush_Y,color); + Draw_line_permanent(start_x,start_y,Paintbrush_X,Paintbrush_Y,color); Paintbrush_shape=PAINTBRUSH_SHAPE_POINT; Pixel_figure_preview(Paintbrush_X,Paintbrush_Y,color);