/* vim:expandtab:ts=2 sw=2: */ /* Grafx2 - The Ultimate 256-color bitmap paint program Copyright 2007 Adrien Destugues Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Grafx2 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. Grafx2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Grafx2; if not, see */ #include #include #include "const.h" #include "struct.h" #include "global.h" #include "graph.h" #include "engine.h" #include "windows.h" #include "special.h" #include "pages.h" #include "misc.h" #include "osdep.h" #include "buttons.h" //---------------------- Modifier le pinceau spécial ------------------------- void Set_paintbrush_size(int width, int height) { int x_pos,y_pos; int x,y; int radius2; if (width<1) width=1; if (height<1) height=1; if (width>MAX_PAINTBRUSH_SIZE) width=MAX_PAINTBRUSH_SIZE; if (height>MAX_PAINTBRUSH_SIZE) height=MAX_PAINTBRUSH_SIZE; Paintbrush_width=width; Paintbrush_height=height; Paintbrush_offset_X=Paintbrush_width>>1; Paintbrush_offset_Y=Paintbrush_height>>1; switch (Paintbrush_shape) { case PAINTBRUSH_SHAPE_ROUND : radius2=Circle_squared_diameter(Paintbrush_width); for (y_pos=0, y=1-Paintbrush_height; y_pos>1; for (y_pos=0; y_pos>1; for (y_pos=0; y_pos>1; for (y_pos=0; y_pos>1; for (y_pos=0; y_pos>1; for (y_pos=0; y_pos0) Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos-1]=0; if (y_pos>0) Paintbrush_sprite[((y_pos-1)*MAX_PAINTBRUSH_SIZE)+x_pos]=0; } } } } void Smaller_paintbrush(void) { if ( (Paintbrush_shape1) || (Paintbrush_height>1) ) ) { Hide_cursor(); switch (Paintbrush_shape) { case PAINTBRUSH_SHAPE_CROSS: case PAINTBRUSH_SHAPE_PLUS: case PAINTBRUSH_SHAPE_DIAMOND: if (Paintbrush_width&1) Set_paintbrush_size(Paintbrush_width-2,Paintbrush_height-2); else Set_paintbrush_size(Paintbrush_width-1,Paintbrush_height-1); break; case PAINTBRUSH_SHAPE_SQUARE: case PAINTBRUSH_SHAPE_SLASH: case PAINTBRUSH_SHAPE_ANTISLASH: case PAINTBRUSH_SHAPE_SIEVE_SQUARE: case PAINTBRUSH_SHAPE_ROUND: case PAINTBRUSH_SHAPE_SIEVE_ROUND: case PAINTBRUSH_SHAPE_RANDOM: Set_paintbrush_size(Paintbrush_width-1,Paintbrush_height-1); break; case PAINTBRUSH_SHAPE_HORIZONTAL_BAR: Set_paintbrush_size(Paintbrush_width-1,1); break; case PAINTBRUSH_SHAPE_VERTICAL_BAR: Set_paintbrush_size(1,Paintbrush_height-1); } Display_paintbrush_in_menu(); Display_cursor(); } } void Bigger_paintbrush(void) { if ( (Paintbrush_shapeMain.image_width) temp_x_offset=Main.image_width-Screen_width; if (temp_y_offset+Menu_Y>Main.image_height) temp_y_offset=Main.image_height-Menu_Y; if (temp_x_offset<0) temp_x_offset=0; if (temp_y_offset<0) temp_y_offset=0; if ( (Main.offset_X!=temp_x_offset) || (Main.offset_Y!=temp_y_offset) ) { Hide_cursor(); Main.offset_X=temp_x_offset; Main.offset_Y=temp_y_offset; Compute_limits(); Compute_paintbrush_coordinates(); Display_all_screen(); // <=> Display_screen + Display_image_limits Display_cursor(); } } // ---------------------- Scroller la fenêtre de la loupe -------------------- void Scroll_magnifier(short delta_x,short delta_y) { short temp_x_offset; short temp_y_offset; temp_x_offset=Main.magnifier_offset_X+delta_x; temp_y_offset=Main.magnifier_offset_Y+delta_y; Clip_magnifier_offsets(&temp_x_offset, &temp_y_offset); if ( (Main.magnifier_offset_X!=temp_x_offset) || (Main.magnifier_offset_Y!=temp_y_offset) ) { Hide_cursor(); Main.magnifier_offset_X=temp_x_offset; Main.magnifier_offset_Y=temp_y_offset; Position_screen_according_to_zoom(); Compute_limits(); Compute_paintbrush_coordinates(); Display_all_screen(); Display_cursor(); } } // -------------- Changer le Zoom (grâce aux touches [+] et [-]) ------------- void Zoom(short delta) { short index; for (index=0; ZOOM_FACTOR[index]!=Main.magnifier_factor; index++); index+=delta; if ( (index>=0) && (index