Merge trunk to the cpcmode5 branch. This gets us a more recent grafx2 with the cpcmode5 drawing. Now to make this mode optional so users can still work in regular mode :)
git-svn-id: svn://pulkomandy.tk/GrafX2/branches/cpcmode5@1719 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
197
src/operatio.c
197
src/operatio.c
@@ -36,6 +36,7 @@
|
||||
#include "sdlscreen.h"
|
||||
#include "brush.h"
|
||||
#include "windows.h"
|
||||
#include "input.h"
|
||||
|
||||
// PI is NOT part of math.h according to C standards...
|
||||
#if defined(__GP2X__) || defined(__VBCC__)
|
||||
@@ -53,11 +54,12 @@ void Start_operation_stack(word new_operation)
|
||||
// On mémorise l'opération précédente si on démarre une interruption
|
||||
switch(new_operation)
|
||||
{
|
||||
case OPERATION_MAGNIFY :
|
||||
case OPERATION_COLORPICK :
|
||||
case OPERATION_GRAB_BRUSH :
|
||||
case OPERATION_POLYBRUSH :
|
||||
case OPERATION_STRETCH_BRUSH :
|
||||
case OPERATION_MAGNIFY:
|
||||
case OPERATION_COLORPICK:
|
||||
case OPERATION_RMB_COLORPICK:
|
||||
case OPERATION_GRAB_BRUSH:
|
||||
case OPERATION_POLYBRUSH:
|
||||
case OPERATION_STRETCH_BRUSH:
|
||||
case OPERATION_ROTATE_BRUSH:
|
||||
Operation_before_interrupt=Current_operation;
|
||||
// On passe à l'operation demandée
|
||||
@@ -226,6 +228,9 @@ void Freehand_mode1_2_0(void)
|
||||
//
|
||||
// Souris effacée: Oui
|
||||
{
|
||||
if (Rightclick_colorpick(0))
|
||||
return;
|
||||
|
||||
Init_start_operation();
|
||||
Backup();
|
||||
Shade_table=Shade_table_right;
|
||||
@@ -322,6 +327,9 @@ void Freehand_mode2_2_0(void)
|
||||
//
|
||||
// Souris effacée: Oui
|
||||
{
|
||||
if (Rightclick_colorpick(0))
|
||||
return;
|
||||
|
||||
Init_start_operation();
|
||||
Backup();
|
||||
Shade_table=Shade_table_right;
|
||||
@@ -390,6 +398,9 @@ void Freehand_Mode3_2_0(void)
|
||||
//
|
||||
// Souris effacée: Oui
|
||||
{
|
||||
if (Rightclick_colorpick(0))
|
||||
return;
|
||||
|
||||
Init_start_operation();
|
||||
Backup();
|
||||
Shade_table=Shade_table_right;
|
||||
@@ -422,6 +433,9 @@ void Line_12_0(void)
|
||||
|
||||
// Début du tracé d'une ligne (premier clic)
|
||||
{
|
||||
if (Rightclick_colorpick(0))
|
||||
return;
|
||||
|
||||
Init_start_operation();
|
||||
Backup();
|
||||
Paintbrush_shape_before_operation=Paintbrush_shape;
|
||||
@@ -480,9 +494,7 @@ void Line_12_5(void)
|
||||
|
||||
// On corrige les coordonnées de la ligne si la touche shift est appuyée...
|
||||
if(SDL_GetModState() & KMOD_SHIFT)
|
||||
{
|
||||
Clamp_coordinates_regular_angle(start_x,start_y,&cursor_x,&cursor_y);
|
||||
}
|
||||
|
||||
// On vient de bouger
|
||||
if ((cursor_x!=end_x) || (cursor_y!=end_y))
|
||||
@@ -557,11 +569,11 @@ void Line_0_5(void)
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////// OPERATION_K_LIGNE
|
||||
/////////////////////////////////////////////////////////// OPERATION_K_LINE
|
||||
|
||||
|
||||
void K_line_12_0(void)
|
||||
// Opération : OPERATION_K_LIGNE
|
||||
// Opération : OPERATION_K_LINE
|
||||
// Click Souris: 1 ou 2
|
||||
// Taille_Pile : 0
|
||||
//
|
||||
@@ -569,6 +581,9 @@ void K_line_12_0(void)
|
||||
{
|
||||
byte color;
|
||||
|
||||
if (Rightclick_colorpick(0))
|
||||
return;
|
||||
|
||||
Init_start_operation();
|
||||
Backup();
|
||||
Shade_table=(Mouse_K==LEFT_SIDE)?Shade_table_left:Shade_table_right;
|
||||
@@ -594,7 +609,7 @@ void K_line_12_0(void)
|
||||
|
||||
|
||||
void K_line_12_6(void)
|
||||
// Opération : OPERATION_K_LIGNE
|
||||
// Opération : OPERATION_K_LINE
|
||||
// Click Souris: 1 ou 2 | 0
|
||||
// Taille_Pile : 6 | 7
|
||||
//
|
||||
@@ -634,7 +649,7 @@ void K_line_12_6(void)
|
||||
|
||||
|
||||
void K_line_0_6(void)
|
||||
// Opération : OPERATION_K_LIGNE
|
||||
// Opération : OPERATION_K_LINE
|
||||
// Click Souris: 0
|
||||
// Taille_Pile : 6
|
||||
//
|
||||
@@ -684,7 +699,7 @@ void K_line_0_6(void)
|
||||
|
||||
|
||||
void K_line_12_7(void)
|
||||
// Opération : OPERATION_K_LIGNE
|
||||
// Opération : OPERATION_K_LINE
|
||||
// Click Souris: 1 ou 2
|
||||
// Taille_Pile : 7
|
||||
//
|
||||
@@ -745,6 +760,9 @@ void Rectangle_12_0(void)
|
||||
//
|
||||
// Souris effacée: Oui
|
||||
{
|
||||
if (Rightclick_colorpick(0))
|
||||
return;
|
||||
|
||||
Init_start_operation();
|
||||
|
||||
if ((Config.Coords_rel) && (Menu_is_visible))
|
||||
@@ -916,6 +934,9 @@ void Circle_12_0(void)
|
||||
//
|
||||
// Souris effacée: Oui
|
||||
{
|
||||
if (Rightclick_colorpick(0))
|
||||
return;
|
||||
|
||||
Init_start_operation();
|
||||
Backup();
|
||||
|
||||
@@ -1090,6 +1111,9 @@ void Ellipse_12_0(void)
|
||||
//
|
||||
// Souris effacée: Oui
|
||||
{
|
||||
if (Rightclick_colorpick(0))
|
||||
return;
|
||||
|
||||
Init_start_operation();
|
||||
Backup();
|
||||
|
||||
@@ -1284,9 +1308,12 @@ void Fill_2_0(void)
|
||||
// Click Souris: 2
|
||||
// Taille_Pile : 0
|
||||
//
|
||||
// Souris effacée: Oui
|
||||
// Souris effacée: Non
|
||||
//
|
||||
{
|
||||
if (Rightclick_colorpick(1))
|
||||
return;
|
||||
|
||||
Hide_cursor();
|
||||
// Pas besoin d'initialiser le début d'opération car le Smear n'affecte pas
|
||||
// le Fill, et on se fout de savoir si on est dans la partie gauche ou
|
||||
@@ -1309,7 +1336,7 @@ void Replace_1_0(void)
|
||||
// Click Souris: 1
|
||||
// Taille_Pile : 0
|
||||
//
|
||||
// Souris effacée: Oui
|
||||
// Souris effacée: Non
|
||||
//
|
||||
{
|
||||
Hide_cursor();
|
||||
@@ -1331,9 +1358,12 @@ void Replace_2_0(void)
|
||||
// Click Souris: 2
|
||||
// Taille_Pile : 0
|
||||
//
|
||||
// Souris effacée: Oui
|
||||
// Souris effacée: Non
|
||||
//
|
||||
{
|
||||
if (Rightclick_colorpick(1))
|
||||
return;
|
||||
|
||||
Hide_cursor();
|
||||
// Pas besoin d'initialiser le début d'opération car le Smear n'affecte pas
|
||||
// le Replace, et on se fout de savoir si on est dans la partie gauche ou
|
||||
@@ -1433,6 +1463,9 @@ void Curve_34_points_2_0(void)
|
||||
// Souris effacée: Oui
|
||||
//
|
||||
{
|
||||
if (Rightclick_colorpick(0))
|
||||
return;
|
||||
|
||||
Init_start_operation();
|
||||
Backup();
|
||||
Shade_table=Shade_table_right;
|
||||
@@ -1711,17 +1744,17 @@ void Compute_3_point_curve(short x1, short y1, short x4, short y4,
|
||||
float cx,cy; // Centre de (x1,y1) et (x4,y4)
|
||||
float bx,by; // Intersect. des dtes ((x1,y1),(x2,y2)) et ((x3,y3),(x4,y4))
|
||||
|
||||
cx=(float)(x1+x4)/2.0; // P1*--_ Légende:
|
||||
cy=(float)(y1+y4)/2.0; // · \·· P2 -_\|/ : courbe
|
||||
// · \ ·*· * : point important
|
||||
bx=cx+((8.0/3.0)*(Paintbrush_X-cx));// · | ·· · : pointillÚ
|
||||
cx=(float)(x1+x4)/2.0; // P1*--_ Legend:
|
||||
cy=(float)(y1+y4)/2.0; // · \·· P2 -_\|/ : curve
|
||||
// · \ ·*· * : important point
|
||||
bx=cx+((8.0/3.0)*(Paintbrush_X-cx));// · | ·· · : dotted line
|
||||
by=cy+((8.0/3.0)*(Paintbrush_Y-cy));// · |P ·· B
|
||||
// C *·····*·········* P=Pos. du pinceau
|
||||
*x2=Round((bx+x1)/2.0); // · | ·· C=milieu de [P1,P4]
|
||||
*y2=Round((by+y1)/2.0); // · | ·· B=point tel que
|
||||
// · / ·*· C->B=(8/3) * C->P
|
||||
*x3=Round((bx+x4)/2.0); // · _/·· P3 P2=milieu de [P1,B]
|
||||
*y3=Round((by+y4)/2.0); // P4*-- P3=milieu de [P4,B]
|
||||
// C *·····*·········* P=Pencil position
|
||||
*x2=Round((bx+x1)/2.0); // · | ·· C=middle of [P1,P4]
|
||||
*y2=Round((by+y1)/2.0); // · | ·· B=point computed as
|
||||
// · / ·*· C->B=(8/3) * C->P
|
||||
*x3=Round((bx+x4)/2.0); // · _/·· P3 P2=middle of [P1,B]
|
||||
*y3=Round((by+y4)/2.0); // P4*-- P3=middle of [P4,B]
|
||||
}
|
||||
|
||||
|
||||
@@ -1745,8 +1778,11 @@ void Curve_3_points_0_5(void)
|
||||
|
||||
Compute_3_point_curve(x1,y1,x4,y4,&x2,&y2,&x3,&y3);
|
||||
|
||||
Hide_line_preview(x1,y1,x4,y4);
|
||||
Draw_curve_preview(x1,y1,x2,y2,x3,y3,x4,y4,color);
|
||||
if (!Config.Stylus_mode)
|
||||
{
|
||||
Hide_line_preview(x1,y1,x4,y4);
|
||||
Draw_curve_preview(x1,y1,x2,y2,x3,y3,x4,y4,color);
|
||||
}
|
||||
|
||||
if ( (Config.Coords_rel) && (Menu_is_visible) )
|
||||
{
|
||||
@@ -1765,17 +1801,19 @@ void Curve_3_points_0_5(void)
|
||||
Operation_push(y4);
|
||||
Operation_push(Paintbrush_X);
|
||||
Operation_push(Paintbrush_Y);
|
||||
|
||||
if (Config.Stylus_mode)
|
||||
{
|
||||
Display_cursor();
|
||||
while(!Mouse_K)
|
||||
Get_input(20);
|
||||
Hide_cursor();
|
||||
|
||||
Hide_line_preview(x1,y1,x4,y4);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Curve_3_points_0_11(void)
|
||||
//
|
||||
// Opération : OPERATION_3_POINTS_CURVE
|
||||
// Click Souris: 0
|
||||
// Taille_Pile : 11
|
||||
//
|
||||
// Souris effacée: Non
|
||||
//
|
||||
void Curve_drag(void)
|
||||
{
|
||||
short x1,y1,x2,y2,x3,y3,x4,y4;
|
||||
short old_x,old_y;
|
||||
@@ -1817,16 +1855,7 @@ void Curve_3_points_0_11(void)
|
||||
Operation_push(Paintbrush_X);
|
||||
Operation_push(Paintbrush_Y);
|
||||
}
|
||||
|
||||
|
||||
void Curve_3_points_12_11(void)
|
||||
//
|
||||
// Opération : OPERATION_3_POINTS_CURVE
|
||||
// Click Souris: 1 ou 2
|
||||
// Taille_Pile : 11
|
||||
//
|
||||
// Souris effacée: Oui
|
||||
//
|
||||
void Curve_finalize(void)
|
||||
{
|
||||
short x1,y1,x2,y2,x3,y3,x4,y4;
|
||||
short old_x,old_y;
|
||||
@@ -1857,6 +1886,37 @@ void Curve_3_points_12_11(void)
|
||||
Wait_end_of_click();
|
||||
}
|
||||
|
||||
void Curve_3_points_0_11(void)
|
||||
//
|
||||
// Opération : OPERATION_3_POINTS_CURVE
|
||||
// Click Souris: 0
|
||||
// Taille_Pile : 11
|
||||
//
|
||||
// Souris effacée: Non
|
||||
//
|
||||
{
|
||||
if (!Config.Stylus_mode)
|
||||
Curve_drag();
|
||||
else
|
||||
Curve_finalize();
|
||||
}
|
||||
|
||||
|
||||
void Curve_3_points_12_11(void)
|
||||
//
|
||||
// Opération : OPERATION_3_POINTS_CURVE
|
||||
// Click Souris: 1 ou 2
|
||||
// Taille_Pile : 11
|
||||
//
|
||||
// Souris effacée: Oui
|
||||
//
|
||||
{
|
||||
if (!Config.Stylus_mode)
|
||||
Curve_finalize();
|
||||
else
|
||||
Curve_drag();
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////// OPERATION_AIRBRUSH
|
||||
|
||||
@@ -1873,8 +1933,11 @@ void Airbrush_1_0(void)
|
||||
Backup();
|
||||
Shade_table=Shade_table_left;
|
||||
|
||||
Airbrush_next_time = SDL_GetTicks()+Airbrush_delay*10;
|
||||
Airbrush(LEFT_SIDE);
|
||||
if (SDL_GetTicks()>Airbrush_next_time)
|
||||
{
|
||||
Airbrush(LEFT_SIDE);
|
||||
Airbrush_next_time = SDL_GetTicks()+Airbrush_delay*10;
|
||||
}
|
||||
|
||||
Operation_push(Paintbrush_X);
|
||||
Operation_push(Paintbrush_Y);
|
||||
@@ -1889,11 +1952,17 @@ void Airbrush_2_0(void)
|
||||
// Souris effacée: Non
|
||||
//
|
||||
{
|
||||
if (Rightclick_colorpick(1))
|
||||
return;
|
||||
|
||||
Init_start_operation();
|
||||
Backup();
|
||||
Shade_table=Shade_table_right;
|
||||
Airbrush_next_time = SDL_GetTicks()+Airbrush_delay*10;
|
||||
Airbrush(RIGHT_SIDE);
|
||||
if (SDL_GetTicks()>Airbrush_next_time)
|
||||
{
|
||||
Airbrush(RIGHT_SIDE);
|
||||
Airbrush_next_time = SDL_GetTicks()+Airbrush_delay*10;
|
||||
}
|
||||
|
||||
Operation_push(Paintbrush_X);
|
||||
Operation_push(Paintbrush_Y);
|
||||
@@ -1909,6 +1978,7 @@ void Airbrush_12_2(void)
|
||||
//
|
||||
{
|
||||
short old_x,old_y;
|
||||
Uint32 now;
|
||||
|
||||
Operation_pop(&old_y);
|
||||
Operation_pop(&old_x);
|
||||
@@ -1920,9 +1990,13 @@ void Airbrush_12_2(void)
|
||||
Display_cursor();
|
||||
}
|
||||
|
||||
if (SDL_GetTicks()>Airbrush_next_time)
|
||||
now=SDL_GetTicks();
|
||||
if (now>Airbrush_next_time)
|
||||
{
|
||||
Airbrush_next_time+=Airbrush_delay*10;
|
||||
//Airbrush_next_time+=Airbrush_delay*10;
|
||||
// Time is now reset, because the += was death spiral
|
||||
// if drawing took more time than the frequency.
|
||||
Airbrush_next_time=now+Airbrush_delay*10;
|
||||
Airbrush(Mouse_K_unique);
|
||||
}
|
||||
|
||||
@@ -1956,6 +2030,9 @@ void Polygon_12_0(void)
|
||||
{
|
||||
byte color;
|
||||
|
||||
if (Rightclick_colorpick(0))
|
||||
return;
|
||||
|
||||
Init_start_operation();
|
||||
Backup();
|
||||
Shade_table=(Mouse_K==LEFT_SIDE)?Shade_table_left:Shade_table_right;
|
||||
@@ -2057,6 +2134,9 @@ void Polyfill_12_0(void)
|
||||
{
|
||||
byte color;
|
||||
|
||||
if (Rightclick_colorpick(0))
|
||||
return;
|
||||
|
||||
Init_start_operation();
|
||||
Backup();
|
||||
Shade_table=(Mouse_K==LEFT_SIDE)?Shade_table_left:Shade_table_right;
|
||||
@@ -2255,6 +2335,9 @@ void Polyform_12_0(void)
|
||||
{
|
||||
short color;
|
||||
|
||||
if (Rightclick_colorpick(0))
|
||||
return;
|
||||
|
||||
Init_start_operation();
|
||||
Backup();
|
||||
Shade_table=(Mouse_K==LEFT_SIDE)?Shade_table_left:Shade_table_right;
|
||||
@@ -2413,6 +2496,9 @@ void Filled_polyform_12_0(void)
|
||||
{
|
||||
short color;
|
||||
|
||||
if (Rightclick_colorpick(0))
|
||||
return;
|
||||
|
||||
Init_start_operation();
|
||||
|
||||
// Cette opération étant également utilisée pour le lasso, on ne fait pas de
|
||||
@@ -2825,6 +2911,7 @@ void Grad_circle_12_0(void)
|
||||
|
||||
Init_start_operation();
|
||||
Backup();
|
||||
Load_gradient_data(Current_gradient);
|
||||
|
||||
Shade_table=(Mouse_K==LEFT_SIDE)?Shade_table_left:Shade_table_right;
|
||||
color=(Mouse_K==LEFT_SIDE)?Fore_color:Back_color;
|
||||
@@ -3082,6 +3169,8 @@ void Grad_ellipse_12_0(void)
|
||||
|
||||
Init_start_operation();
|
||||
Backup();
|
||||
Load_gradient_data(Current_gradient);
|
||||
|
||||
|
||||
Shade_table=(Mouse_K==LEFT_SIDE)?Shade_table_left:Shade_table_right;
|
||||
color=(Mouse_K==LEFT_SIDE)?Fore_color:Back_color;
|
||||
@@ -3306,6 +3395,7 @@ void Grad_rectangle_12_0(void)
|
||||
{
|
||||
Init_start_operation();
|
||||
Backup();
|
||||
Load_gradient_data(Current_gradient);
|
||||
|
||||
if ((Config.Coords_rel) && (Menu_is_visible))
|
||||
Print_in_menu("\035: 1 \022: 1",0);
|
||||
@@ -3712,6 +3802,9 @@ void Centered_lines_12_0(void)
|
||||
//
|
||||
// Souris effacée: Oui
|
||||
{
|
||||
if (Rightclick_colorpick(0))
|
||||
return;
|
||||
|
||||
Init_start_operation();
|
||||
Backup();
|
||||
Shade_table=(Mouse_K==LEFT_SIDE)?Shade_table_left:Shade_table_right;
|
||||
|
||||
Reference in New Issue
Block a user