From 8b340684bd3640d32bb253de01ba25ac80b67aaf Mon Sep 17 00:00:00 2001 From: Yves Rizoud Date: Sat, 8 Aug 2009 18:53:30 +0000 Subject: [PATCH] Various internal changes, preparing for layers (mostly backup system) git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@983 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- buttons.c | 100 +++++++++++++++-------------------------------------- graph.c | 2 ++ misc.c | 21 ++++++----- operatio.c | 36 ++++++++++++++++++- pages.c | 4 +++ pages.h | 2 +- palette.c | 11 ++++++ 7 files changed, 93 insertions(+), 83 deletions(-) diff --git a/buttons.c b/buttons.c index 36ea052d..c9f75428 100644 --- a/buttons.c +++ b/buttons.c @@ -505,6 +505,7 @@ void Button_Clear(void) else Hide_current_image(0); Display_all_screen(); + End_of_modification(); Unselect_button(BUTTON_CLEAR); Display_cursor(); } @@ -518,6 +519,7 @@ void Button_Clear_with_backcolor(void) else Hide_current_image(Back_color); Display_all_screen(); + End_of_modification(); Unselect_button(BUTTON_CLEAR); Display_cursor(); } @@ -1306,97 +1308,51 @@ void Button_Skins(void) //---------------------------- Changement de page ---------------------------- void Button_Page(void) { - byte temp_byte; - word temp_word; - short temp_short; - float temp_float; + byte factor_index; char Temp_buffer[256]; + #define SWAP_BYTES(a,b) { byte c=a; a=b; b=c;} + #define SWAP_WORDS(a,b) { word c=a; a=b; b=c;} + #define SWAP_SHORTS(a,b) { short c=a; a=b; b=c;} + #define SWAP_FLOATS(a,b) { float c=a; a=b; b=c;} + Hide_cursor(); // On dégrossit le travail avec les infos des listes de pages Exchange_main_and_spare(); // On fait le reste du travail "à la main": - temp_short=Spare_offset_X; - Spare_offset_X=Main_offset_X; - Main_offset_X=temp_short; - - temp_short=Spare_offset_Y; - Spare_offset_Y=Main_offset_Y; - Main_offset_Y=temp_short; - - temp_short=Old_spare_offset_X; - Old_spare_offset_X=Old_main_offset_X; - Old_main_offset_X=temp_short; - - temp_short=Old_spare_offset_Y; - Old_spare_offset_Y=Old_main_offset_Y; - Old_main_offset_Y=temp_short; - - temp_short=Spare_separator_position; - Spare_separator_position=Main_separator_position; - Main_separator_position=temp_short; - - temp_short=Spare_X_zoom; - Spare_X_zoom=Main_X_zoom; - Main_X_zoom=temp_short; - - temp_float=Spare_separator_proportion; - Spare_separator_proportion=Main_separator_proportion; - Main_separator_proportion=temp_float; - - temp_byte=Spare_magnifier_mode; - Spare_magnifier_mode=Main_magnifier_mode; - Main_magnifier_mode=temp_byte; + SWAP_SHORTS(Main_offset_X,Spare_offset_X) + SWAP_SHORTS(Main_offset_Y,Spare_offset_Y) + SWAP_SHORTS(Old_main_offset_X,Old_spare_offset_X) + SWAP_SHORTS(Old_main_offset_Y,Old_spare_offset_Y) + SWAP_SHORTS(Main_separator_position,Spare_separator_position) + SWAP_SHORTS(Main_X_zoom,Spare_X_zoom) + SWAP_FLOATS(Main_separator_proportion,Spare_separator_proportion) + SWAP_BYTES (Main_magnifier_mode,Spare_magnifier_mode) Pixel_preview=(Main_magnifier_mode)?Pixel_preview_magnifier:Pixel_preview_normal; - temp_word=Spare_magnifier_factor; - Spare_magnifier_factor=Main_magnifier_factor; - Main_magnifier_factor=temp_word; - - temp_word=Spare_magnifier_height; - Spare_magnifier_height=Main_magnifier_height; - Main_magnifier_height=temp_word; - - temp_word=Spare_magnifier_width; - Spare_magnifier_width=Main_magnifier_width; - Main_magnifier_width=temp_word; - - temp_short=Spare_magnifier_offset_X; - Spare_magnifier_offset_X=Main_magnifier_offset_X; - Main_magnifier_offset_X=temp_short; - - temp_short=Spare_magnifier_offset_Y; - Spare_magnifier_offset_Y=Main_magnifier_offset_Y; - Main_magnifier_offset_Y=temp_short; - + SWAP_WORDS (Main_magnifier_factor,Spare_magnifier_factor) + SWAP_WORDS (Main_magnifier_height,Spare_magnifier_height) + SWAP_WORDS (Main_magnifier_width,Spare_magnifier_width) + SWAP_SHORTS(Main_magnifier_offset_X,Spare_magnifier_offset_X) + SWAP_SHORTS(Main_magnifier_offset_Y,Spare_magnifier_offset_Y) // Swap du booléen "Image modifiée" - temp_byte =Spare_image_is_modified; - Spare_image_is_modified=Main_image_is_modified; - Main_image_is_modified=temp_byte; + SWAP_BYTES (Main_image_is_modified,Spare_image_is_modified) // Swap des infos sur les fileselects strcpy(Temp_buffer ,Spare_current_directory); strcpy(Spare_current_directory,Main_current_directory); strcpy(Main_current_directory,Temp_buffer ); - temp_byte=Spare_format; - Spare_format=Main_format; - Main_format=temp_byte; - - temp_word =Spare_fileselector_position; - Spare_fileselector_position=Main_fileselector_position; - Main_fileselector_position=temp_word; - - temp_word =Spare_fileselector_offset; - Spare_fileselector_offset=Main_fileselector_offset; - Main_fileselector_offset=temp_word; - + SWAP_BYTES (Main_format,Spare_format) + SWAP_WORDS (Main_fileselector_position,Spare_fileselector_position) + SWAP_WORDS (Main_fileselector_offset,Spare_fileselector_offset) + // A la fin, on affiche l'écran - for (temp_byte=0; ZOOM_FACTOR[temp_byte]!=Main_magnifier_factor; temp_byte++); - Change_magnifier_factor(temp_byte); + for (factor_index=0; ZOOM_FACTOR[factor_index]!=Main_magnifier_factor; factor_index++); + Change_magnifier_factor(factor_index); Set_palette(Main_palette); Compute_optimal_menu_colors(Main_palette); diff --git a/graph.c b/graph.c index 14b41147..b473a193 100644 --- a/graph.c +++ b/graph.c @@ -681,6 +681,7 @@ void Get_colors_from_brush(void) Display_all_screen(); Display_menu(); Display_cursor(); + End_of_modification(); Main_image_is_modified=1; } @@ -999,6 +1000,7 @@ void Fill_general(byte fill_color) // on n'y a jamais touché à l'écran les autres: ils sont donc corrects. Update_rect(0,0,0,0); + End_of_modification(); } } diff --git a/misc.c b/misc.c index 17d77754..ed70e042 100644 --- a/misc.c +++ b/misc.c @@ -396,11 +396,12 @@ byte Effect_interpolated_colorize (word x,word y,byte color) // On place dans ESI 3*Couleur_dessous ( = position de cette couleur dans la // palette des teintes) et dans EDI, 3*color. - byte blue_under=Main_palette[*(FX_feedback_screen + y * Main_image_width + x)].B; + byte color_under = Read_pixel_from_feedback_screen(x,y); + byte blue_under=Main_palette[color_under].B; byte blue=Main_palette[color].B; - byte green_under=Main_palette[*(FX_feedback_screen + y * Main_image_width + x)].G; + byte green_under=Main_palette[color_under].G; byte green=Main_palette[color].G; - byte red_under=Main_palette[*(FX_feedback_screen + y * Main_image_width + x)].R; + byte red_under=Main_palette[color_under].R; byte red=Main_palette[color].R; // On récupère les 3 composantes RVB @@ -418,9 +419,10 @@ byte Effect_interpolated_colorize (word x,word y,byte color) byte Effect_additive_colorize (word x,word y,byte color) { - byte blue_under=Main_palette[*(FX_feedback_screen + y * Main_image_width + x)].B; - byte green_under=Main_palette[*(FX_feedback_screen + y * Main_image_width + x)].G; - byte red_under=Main_palette[*(FX_feedback_screen + y * Main_image_width + x)].R; + byte color_under = Read_pixel_from_feedback_screen(x,y); + byte blue_under=Main_palette[color_under].B; + byte green_under=Main_palette[color_under].G; + byte red_under=Main_palette[color_under].R; byte blue=Main_palette[color].B; byte green=Main_palette[color].G; byte red=Main_palette[color].R; @@ -433,9 +435,10 @@ byte Effect_additive_colorize (word x,word y,byte color) byte Effect_substractive_colorize(word x,word y,byte color) { - byte blue_under=Main_palette[*(FX_feedback_screen + y * Main_image_width + x)].B; - byte green_under=Main_palette[*(FX_feedback_screen + y * Main_image_width + x)].G; - byte red_under=Main_palette[*(FX_feedback_screen + y * Main_image_width + x)].R; + byte color_under = Read_pixel_from_feedback_screen(x,y); + byte blue_under=Main_palette[color_under].B; + byte green_under=Main_palette[color_under].G; + byte red_under=Main_palette[color_under].R; byte blue=Main_palette[color].B; byte green=Main_palette[color].G; byte red=Main_palette[color].R; diff --git a/operatio.c b/operatio.c index 30c447ea..d8ad8908 100644 --- a/operatio.c +++ b/operatio.c @@ -241,6 +241,7 @@ void Freehand_mode12_0_2(void) // Souris effacée: Non { Operation_stack_size=0; + End_of_modification(); } @@ -431,6 +432,7 @@ void Freehand_mode3_0_1(void) // // Souris effacée: Non { + End_of_modification(); Operation_stack_size--; } @@ -572,6 +574,7 @@ void Line_0_5(void) Display_paintbrush (start_x,start_y,color,0); Draw_line_permanet(start_x,start_y,end_x,end_y,color); + End_of_modification(); if ( (Config.Coords_rel) && (Menu_is_visible) ) { Print_in_menu("X: Y: ",0); @@ -750,6 +753,7 @@ void K_line_12_7(void) Hide_cursor(); Paintbrush_shape=Paintbrush_shape_before_operation; + End_of_modification(); if ( (Config.Coords_rel) && (Menu_is_visible) ) { Print_in_menu("X: Y: ",0); @@ -925,6 +929,8 @@ void Empty_rectangle_0_5(void) Paintbrush_X=old_paintbrush_x; Paintbrush_Y=old_paintbrush_y; + End_of_modification(); + if ((Config.Coords_rel) && (Menu_is_visible)) Print_in_menu("X: Y:",0); Print_coordinates(); @@ -970,6 +976,7 @@ void Filled_rectangle_0_5(void) Paintbrush_X=old_paintbrush_x; Paintbrush_Y=old_paintbrush_y; + End_of_modification(); if ( (Config.Coords_rel) && (Menu_is_visible) ) { Print_in_menu("X: Y:",0); @@ -1102,6 +1109,8 @@ void Empty_circle_0_5(void) Draw_empty_circle_permanent(center_x,center_y,radius,color); + End_of_modification(); + if ( (Config.Coords_rel) && (Menu_is_visible) ) { Print_in_menu("X: Y:",0); @@ -1141,6 +1150,7 @@ void Filled_circle_0_5(void) Draw_filled_circle(center_x,center_y,radius,color); + End_of_modification(); if ( (Config.Coords_rel) && (Menu_is_visible) ) { Print_in_menu("X: Y:",0); @@ -1271,6 +1281,8 @@ void Empty_ellipse_0_5(void) Draw_empty_ellipse_permanent(center_x,center_y,horizontal_radius,vertical_radius,color); + End_of_modification(); + if ( (Config.Coords_rel) && (Menu_is_visible) ) { Print_in_menu("X: Y: ",0); @@ -1312,6 +1324,7 @@ void Filled_ellipse_0_5(void) Draw_filled_ellipse(center_x,center_y,horizontal_radius,vertical_radius,color); + End_of_modification(); if ( (Config.Coords_rel) && (Menu_is_visible) ) { Print_in_menu("X: Y: ",0); @@ -1340,6 +1353,7 @@ void Fill_1_0(void) Shade_table=Shade_table_left; Fill_general(Fore_color); Display_cursor(); + End_of_modification(); Wait_end_of_click(); } @@ -1361,6 +1375,7 @@ void Fill_2_0(void) Shade_table=Shade_table_right; Fill_general(Back_color); Display_cursor(); + End_of_modification(); Wait_end_of_click(); } @@ -1385,6 +1400,7 @@ void Replace_1_0(void) // Shade_table=Shade_table_left; Replace(Fore_color); Display_cursor(); + End_of_modification(); Wait_end_of_click(); } @@ -1406,6 +1422,7 @@ void Replace_2_0(void) // Shade_table=Shade_table_right; Replace(Back_color); Display_cursor(); + End_of_modification(); Wait_end_of_click(); } @@ -1895,6 +1912,7 @@ void Curve_4_points_2_9(void) Draw_curve_permanent(x1,y1,x2,y2,x3,y3,x4,y4,color); Display_cursor(); + End_of_modification(); Wait_end_of_click(); } @@ -2049,6 +2067,7 @@ void Curve_3_points_12_11(void) Compute_3_point_curve(x1,y1,x4,y4,&x2,&y2,&x3,&y3); Draw_curve_permanent(x1,y1,x2,y2,x3,y3,x4,y4,color); + End_of_modification(); Display_cursor(); Wait_end_of_click(); } @@ -2136,6 +2155,7 @@ void Airbrush_0_2(void) // { Operation_stack_size-=2; + End_of_modification(); } @@ -2226,6 +2246,7 @@ void Polygon_12_9(void) Paintbrush_shape=PAINTBRUSH_SHAPE_POINT; Display_cursor(); + End_of_modification(); Wait_end_of_click(); Hide_cursor(); @@ -2424,6 +2445,7 @@ void Polyfill_12_9(void) Polyfill(Polyfill_number_of_points,Polyfill_table_of_points,color); free(Polyfill_table_of_points); + End_of_modification(); if ( (Config.Coords_rel) && (Menu_is_visible) ) { Print_in_menu("X: Y: ",0); @@ -2546,6 +2568,7 @@ void Polyform_12_8(void) Draw_line_permanet(start_x,start_y,initial_x,initial_y,color); Display_cursor(); + End_of_modification(); Wait_end_of_click(); } } @@ -2755,6 +2778,7 @@ void Filled_polyform_12_8(void) Paintbrush_hidden=0; Display_cursor(); + End_of_modification(); Wait_end_of_click(); } } @@ -2838,6 +2862,7 @@ void Filled_contour_0_8(void) Paintbrush_hidden=0; Display_cursor(); + End_of_modification(); } ////////////////////////////////////////////////////// OPERATION_GRAB_BRUSH @@ -2980,6 +3005,7 @@ void Brush_0_5(void) Brush_offset_Y=(Brush_offset_Y/Snap_height)*Snap_height; } + End_of_modification(); Return_to_draw_mode(); } @@ -3103,6 +3129,8 @@ void Polybrush_12_8(void) Brush_offset_Y=(Brush_offset_Y/Snap_height)*Snap_height; } + if (click==RIGHT_SIDE) + End_of_modification(); Return_to_draw_mode(); Display_cursor(); } @@ -3952,6 +3980,7 @@ void Scroll_0_4(void) { Operation_stack_size-=4; Cursor_hidden=Cursor_hidden_before_scroll; + End_of_modification(); if ((Config.Coords_rel) && (Menu_is_visible)) { Print_in_menu("X: Y: ",0); @@ -4117,6 +4146,7 @@ void Grad_circle_0_6(void) Draw_filled_circle(center_x,center_y,radius,Back_color); + End_of_modification(); if ((Config.Coords_rel) && (Menu_is_visible)) { Print_in_menu("X: Y: ",0); @@ -4168,6 +4198,7 @@ void Grad_circle_12_8(void) Draw_grad_circle(center_x,center_y,radius,Paintbrush_X,Paintbrush_Y); Display_cursor(); + End_of_modification(); Wait_end_of_click(); if ((Config.Coords_rel) && (Menu_is_visible)) @@ -4371,6 +4402,7 @@ void Grad_ellipse_0_6(void) Draw_filled_ellipse(center_x,center_y,horizontal_radius,vertical_radius,Back_color); + End_of_modification(); if ((Config.Coords_rel) && (Menu_is_visible)) { Print_in_menu("X: Y: ",0); @@ -4423,7 +4455,7 @@ void Grad_ellipse_12_8(void) Draw_grad_ellipse(center_x,center_y,horizontal_radius,vertical_radius,Paintbrush_X,Paintbrush_Y); Display_cursor(); - + End_of_modification(); Wait_end_of_click(); if ((Config.Coords_rel) && (Menu_is_visible)) @@ -4903,6 +4935,7 @@ void Grad_rectangle_0_9(void) Draw_grad_rectangle(rect_start_x,rect_start_y,rect_end_x,rect_end_y,vector_start_x,vector_start_y,vector_end_x,vector_end_y); Display_cursor(); + End_of_modification(); Wait_end_of_click(); if ((Config.Coords_rel) && (Menu_is_visible)) @@ -5056,6 +5089,7 @@ void Centered_lines_12_7(void) } Display_cursor(); + End_of_modification(); Wait_end_of_click(); } } diff --git a/pages.c b/pages.c index ccd1b37c..a52c9c22 100644 --- a/pages.c +++ b/pages.c @@ -930,3 +930,7 @@ void * Borrow_memory_from_page(int size) // Pour que le compilateur ne dise pas qu'il manque une valeur de sortie: return 0; } + +void End_of_modification(void) +{ +} diff --git a/pages.h b/pages.h index 5472a7d4..8a6c8ca4 100644 --- a/pages.h +++ b/pages.h @@ -81,7 +81,7 @@ void Undo(void); void Redo(void); void Free_current_page(void); // 'Kill' button void Exchange_main_and_spare(void); - +void End_of_modification(void); /// diff --git a/palette.c b/palette.c index 79b9165e..f8bcaa00 100644 --- a/palette.c +++ b/palette.c @@ -1318,7 +1318,10 @@ void Button_Palette(void) // En cas de X-Swap, tout l'ecran a pu changer de couleur. if (clicked_button==8) + { Update_rect(0, 0, Screen_width, Menu_Y_before_window); + End_of_modification(); + } Wait_end_of_click(); } break; @@ -1418,6 +1421,7 @@ void Button_Palette(void) Draw_all_palette_sliders(red_slider,green_slider,blue_slider,working_palette,block_start,block_end); memcpy(temp_palette,working_palette,sizeof(T_Palette)); + End_of_modification(); need_to_remap=1; break; @@ -1782,6 +1786,7 @@ void Button_Palette(void) Hide_cursor(); Remap_image_highlevel(conversion_table); Display_cursor(); + End_of_modification(); } // On prépare la "modifiabilité" des nouvelles couleurs Set_palette(working_palette); @@ -1943,6 +1948,8 @@ void Button_Palette(void) // Maintenant, tous ces calculs doivent êtres pris en compte dans la // palette, l'image et à l'écran. Set_palette(working_palette); + + End_of_modification(); need_to_remap=1; } break; @@ -2033,6 +2040,8 @@ void Button_Palette(void) memcpy(temp_palette,working_palette,sizeof(T_Palette)); Draw_all_palette_sliders(red_slider,green_slider,blue_slider,working_palette,block_start,block_end); Update_color_count(&used_colors,color_usage); + // End_of_modification(); + // Not really needed, the change was in palette entries need_to_remap=1; Key=0; break; @@ -2117,6 +2126,8 @@ void Button_Palette(void) && memcmp(Main_palette,working_palette,sizeof(T_Palette)) ) Backup(); memcpy(Main_palette,working_palette,sizeof(T_Palette)); + // End_of_modification(); + // Not really needed, the change was in palette entries } Compute_optimal_menu_colors(Main_palette);