From e8865533148c9002f4b84b7b212556dcf444fcdd Mon Sep 17 00:00:00 2001 From: Yves Rizoud Date: Sun, 12 Dec 2010 18:55:55 +0000 Subject: [PATCH] Fix issue 401: Touchscreen adaptation for Caanoo and Wiz git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1659 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- src/operatio.c | 89 ++++++++++++++++++++++++++++++++------------------ src/readini.c | 7 ++++ src/struct.h | 1 + 3 files changed, 66 insertions(+), 31 deletions(-) diff --git a/src/operatio.c b/src/operatio.c index a522be2f..a7b88e9d 100644 --- a/src/operatio.c +++ b/src/operatio.c @@ -1744,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] } @@ -1778,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) ) { @@ -1798,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; @@ -1850,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; @@ -1890,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 diff --git a/src/readini.c b/src/readini.c index 57f3225d..6d1997df 100644 --- a/src/readini.c +++ b/src/readini.c @@ -432,6 +432,13 @@ int Load_INI(T_Config * conf) char value_label[1024]; Line_number_in_INI_file=0; + +#if defined(__WIZ__) || defined(__CAANOO__) + conf->Stylus_mode = 1; +#else + conf->Stylus_mode = 0; +#endif + // On alloue les zones de mémoire: buffer=(char *)malloc(1024); diff --git a/src/struct.h b/src/struct.h index fc655589..27b0dfe6 100644 --- a/src/struct.h +++ b/src/struct.h @@ -350,6 +350,7 @@ typedef struct byte Grid_XOR_color; ///< XOR value to apply for grid color. byte Right_click_colorpick; ///< Boolean, true to enable a "tablet" mode, where RMB acts as instant colorpicker byte Sync_views; ///< Boolean, true when the Main and Spare should share their viewport settings. + byte Stylus_mode; ///< Boolean, true to tweak some tools (eg:Curve) for single-button stylus. } T_Config; // Structures utilisées pour les descriptions de pages et de liste de pages.