Issue 473: Fix mouse droppings in Brush rotate tool when you hold Shift
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@2012 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
		
							parent
							
								
									d8fd3d33a4
								
							
						
					
					
						commit
						effde4aee2
					
				@ -952,24 +952,27 @@ void Rotate_brush_1_5(void)
 | 
				
			|||||||
  short prev_state;
 | 
					  short prev_state;
 | 
				
			||||||
  float angle;
 | 
					  float angle;
 | 
				
			||||||
  int dx,dy;
 | 
					  int dx,dy;
 | 
				
			||||||
 | 
					  short cursor_x,cursor_y;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Operation_pop(&prev_state);
 | 
					  Operation_pop(&prev_state);
 | 
				
			||||||
  Operation_pop(&old_y);
 | 
					  Operation_pop(&old_y);
 | 
				
			||||||
  Operation_pop(&old_x);
 | 
					  Operation_pop(&old_x);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // On corrige les coordonnées de la ligne si la touche shift est appuyée...
 | 
					  // On corrige les coordonnées de la ligne si la touche shift est appuyée...
 | 
				
			||||||
 | 
					  cursor_x = Paintbrush_X;
 | 
				
			||||||
 | 
					  cursor_y = Paintbrush_Y;
 | 
				
			||||||
  if(SDL_GetModState() & KMOD_SHIFT)
 | 
					  if(SDL_GetModState() & KMOD_SHIFT)
 | 
				
			||||||
    Clamp_coordinates_regular_angle(Brush_rotation_center_X,Brush_rotation_center_Y,&Paintbrush_X,&Paintbrush_Y);
 | 
					    Clamp_coordinates_regular_angle(Brush_rotation_center_X,Brush_rotation_center_Y,&cursor_x,&cursor_y);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if ( (Paintbrush_X!=old_x) || (Paintbrush_Y!=old_y) || (prev_state!=2) )
 | 
					  if ( (cursor_x!=old_x) || (cursor_y!=old_y) || (prev_state!=2) )
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    if ( (Brush_rotation_center_X==Paintbrush_X)
 | 
					    if ( (Brush_rotation_center_X==cursor_x)
 | 
				
			||||||
      && (Brush_rotation_center_Y==Paintbrush_Y) )
 | 
					      && (Brush_rotation_center_Y==cursor_y) )
 | 
				
			||||||
      angle=0.0;
 | 
					      angle=0.0;
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      dx=Paintbrush_X-Brush_rotation_center_X;
 | 
					      dx=cursor_x-Brush_rotation_center_X;
 | 
				
			||||||
      dy=Paintbrush_Y-Brush_rotation_center_Y;
 | 
					      dy=cursor_y-Brush_rotation_center_Y;
 | 
				
			||||||
      angle=M_2PI-atan2(dy,dx);
 | 
					      angle=M_2PI-atan2(dy,dx);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -989,12 +992,13 @@ void Rotate_brush_1_5(void)
 | 
				
			|||||||
    Display_cursor();
 | 
					    Display_cursor();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Operation_stack_size-=2;
 | 
					    Operation_stack_size-=2;
 | 
				
			||||||
    Operation_push(Paintbrush_X);
 | 
					    Operation_push(cursor_x);
 | 
				
			||||||
    Operation_push(Paintbrush_Y);
 | 
					    Operation_push(cursor_y);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Operation_push(Paintbrush_X);
 | 
					  Operation_push(cursor_x);
 | 
				
			||||||
  Operation_push(Paintbrush_Y);
 | 
					  Operation_push(cursor_y);
 | 
				
			||||||
  Operation_push(2);
 | 
					  Operation_push(2);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1018,24 +1022,29 @@ void Rotate_brush_0_5(void)
 | 
				
			|||||||
  short prev_state;
 | 
					  short prev_state;
 | 
				
			||||||
  float angle=0.0;
 | 
					  float angle=0.0;
 | 
				
			||||||
  int dx,dy;
 | 
					  int dx,dy;
 | 
				
			||||||
 | 
					  short cursor_x, cursor_y;
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Operation_pop(&prev_state);
 | 
					  Operation_pop(&prev_state);
 | 
				
			||||||
  Operation_pop(&old_y);
 | 
					  Operation_pop(&old_y);
 | 
				
			||||||
  Operation_pop(&old_x);
 | 
					  Operation_pop(&old_x);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // On corrige les coordonnées de la ligne si la touche shift est appuyée...
 | 
					  // On corrige les coordonnées de la ligne si la touche shift est appuyée...
 | 
				
			||||||
 | 
					  cursor_x = Paintbrush_X;
 | 
				
			||||||
 | 
					  cursor_y = Paintbrush_Y;
 | 
				
			||||||
  if(SDL_GetModState() & KMOD_SHIFT)
 | 
					  if(SDL_GetModState() & KMOD_SHIFT)
 | 
				
			||||||
    Clamp_coordinates_regular_angle(Brush_rotation_center_X,Brush_rotation_center_Y,&Paintbrush_X,&Paintbrush_Y);
 | 
					    Clamp_coordinates_regular_angle(Brush_rotation_center_X,Brush_rotation_center_Y,&cursor_x,&cursor_y);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if ((Paintbrush_X!=old_x) || (Paintbrush_Y!=old_y) || (prev_state!=3))
 | 
					  if ((cursor_x!=old_x) || (cursor_y!=old_y) || (prev_state!=3))
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    if ( (Brush_rotation_center_X==Paintbrush_X)
 | 
					    Hide_cursor();
 | 
				
			||||||
      && (Brush_rotation_center_Y==Paintbrush_Y) )
 | 
					    if ( (Brush_rotation_center_X==cursor_x)
 | 
				
			||||||
 | 
					      && (Brush_rotation_center_Y==cursor_y) )
 | 
				
			||||||
      angle=0.0;
 | 
					      angle=0.0;
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      dx=Paintbrush_X-Brush_rotation_center_X;
 | 
					      dx=cursor_x-Brush_rotation_center_X;
 | 
				
			||||||
      dy=Paintbrush_Y-Brush_rotation_center_Y;
 | 
					      dy=cursor_y-Brush_rotation_center_Y;
 | 
				
			||||||
      angle=acos(((float)dx)/sqrt((dx*dx)+(dy*dy)));
 | 
					      angle=acos(((float)dx)/sqrt((dx*dx)+(dy*dy)));
 | 
				
			||||||
      if (dy>0) angle=M_2PI-angle;
 | 
					      if (dy>0) angle=M_2PI-angle;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -1050,6 +1059,7 @@ void Rotate_brush_0_5(void)
 | 
				
			|||||||
      else
 | 
					      else
 | 
				
			||||||
        Print_coordinates();
 | 
					        Print_coordinates();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    Display_cursor();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Utilise Key_ANSI au lieu de Key, car Get_input() met ce dernier
 | 
					  // Utilise Key_ANSI au lieu de Key, car Get_input() met ce dernier
 | 
				
			||||||
@ -1089,8 +1099,8 @@ void Rotate_brush_0_5(void)
 | 
				
			|||||||
    Operation_push(computed_y);
 | 
					    Operation_push(computed_y);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Operation_push(Paintbrush_X);
 | 
					  Operation_push(cursor_x);
 | 
				
			||||||
  Operation_push(Paintbrush_Y);
 | 
					  Operation_push(cursor_y);
 | 
				
			||||||
  Operation_push(3);
 | 
					  Operation_push(3);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1781,7 +1781,11 @@ void Draw_line_preview(short start_x,short start_y,short end_x,short end_y,byte
 | 
				
			|||||||
void Draw_line_preview_xor(short start_x,short start_y,short end_x,short end_y,byte color)
 | 
					void Draw_line_preview_xor(short start_x,short start_y,short end_x,short end_y,byte color)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  int w, h;
 | 
					  int w, h;
 | 
				
			||||||
  Pixel_figure=Pixel_figure_preview_xor;
 | 
					  
 | 
				
			||||||
 | 
					  Pixel_figure=(Func_pixel)Pixel_figure_preview_xor;
 | 
				
			||||||
 | 
					  // Needed a cast because this function supports signed shorts,
 | 
				
			||||||
 | 
					  // (it's usually in image space), while this time it's in screen space
 | 
				
			||||||
 | 
					  // and some line endpoints can be out of screen.
 | 
				
			||||||
  Draw_line_general(start_x,start_y,end_x,end_y,color);
 | 
					  Draw_line_general(start_x,start_y,end_x,end_y,color);
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  if (start_x<Limit_left)
 | 
					  if (start_x<Limit_left)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user