-Style fixes (check for (i != 0) instead of just i for int
-Error on some extreme cases (can't even allocate 1 byte) (the exit here are to make splint happy) -Header protection with #ifdef git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@925 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
07bfc119b8
commit
b5e806eda3
125
brush.c
125
brush.c
@ -123,7 +123,8 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
|
|||||||
int position;
|
int position;
|
||||||
byte * temp;
|
byte * temp;
|
||||||
|
|
||||||
if (!(is_preview && Mouse_K)) // Si bouton enfoncé & preview > pas de dessin
|
if (is_preview==0 || Mouse_K==0) // pas de curseur si on est en preview et
|
||||||
|
// en train de cliquer
|
||||||
switch (Paintbrush_shape)
|
switch (Paintbrush_shape)
|
||||||
{
|
{
|
||||||
case PAINTBRUSH_SHAPE_POINT : // !!! TOUJOURS EN PREVIEW !!!
|
case PAINTBRUSH_SHAPE_POINT : // !!! TOUJOURS EN PREVIEW !!!
|
||||||
@ -151,7 +152,7 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
|
|||||||
end_counter_x=start_x_counter+width;
|
end_counter_x=start_x_counter+width;
|
||||||
end_counter_y=start_y_counter+height;
|
end_counter_y=start_y_counter+height;
|
||||||
|
|
||||||
if (is_preview)
|
if (is_preview != 0)
|
||||||
{
|
{
|
||||||
if ( (width>0) && (height>0) )
|
if ( (width>0) && (height>0) )
|
||||||
Display_brush_color(
|
Display_brush_color(
|
||||||
@ -165,7 +166,7 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
|
|||||||
Brush_width
|
Brush_width
|
||||||
);
|
);
|
||||||
|
|
||||||
if (Main_magnifier_mode)
|
if (Main_magnifier_mode != 0)
|
||||||
{
|
{
|
||||||
Compute_clipped_dimensions_zoom(&start_x,&start_y,&width,
|
Compute_clipped_dimensions_zoom(&start_x,&start_y,&width,
|
||||||
&height
|
&height
|
||||||
@ -196,9 +197,9 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((Smear_mode) && (Shade_table==Shade_table_left))
|
if ((Smear_mode != 0) && (Shade_table==Shade_table_left))
|
||||||
{
|
{
|
||||||
if (Smear_start)
|
if (Smear_start != 0)
|
||||||
{
|
{
|
||||||
if ((width>0) && (height>0))
|
if ((width>0) && (height>0))
|
||||||
{
|
{
|
||||||
@ -275,7 +276,7 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
|
|||||||
start_y_counter=start_y-(y-Brush_offset_Y);
|
start_y_counter=start_y-(y-Brush_offset_Y);
|
||||||
end_counter_x=start_x_counter+width;
|
end_counter_x=start_x_counter+width;
|
||||||
end_counter_y=start_y_counter+height;
|
end_counter_y=start_y_counter+height;
|
||||||
if (is_preview)
|
if (is_preview != 0)
|
||||||
{
|
{
|
||||||
if ( (width>0) && (height>0) )
|
if ( (width>0) && (height>0) )
|
||||||
Display_brush_mono(start_x-Main_offset_X,
|
Display_brush_mono(start_x-Main_offset_X,
|
||||||
@ -285,7 +286,7 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
|
|||||||
Back_color,Fore_color,
|
Back_color,Fore_color,
|
||||||
Brush_width);
|
Brush_width);
|
||||||
|
|
||||||
if (Main_magnifier_mode)
|
if (Main_magnifier_mode != 0)
|
||||||
{
|
{
|
||||||
Compute_clipped_dimensions_zoom(&start_x,&start_y,&width,&height);
|
Compute_clipped_dimensions_zoom(&start_x,&start_y,&width,&height);
|
||||||
start_x_counter=start_x-(x-Brush_offset_X);
|
start_x_counter=start_x-(x-Brush_offset_X);
|
||||||
@ -314,9 +315,9 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((Smear_mode) && (Shade_table==Shade_table_left))
|
if ((Smear_mode != 0) && (Shade_table==Shade_table_left))
|
||||||
{
|
{
|
||||||
if (Smear_start)
|
if (Smear_start != 0)
|
||||||
{
|
{
|
||||||
if ((width>0) && (height>0))
|
if ((width>0) && (height>0))
|
||||||
{
|
{
|
||||||
@ -377,7 +378,7 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
|
|||||||
start_y_counter=start_y-(y-Paintbrush_offset_Y);
|
start_y_counter=start_y-(y-Paintbrush_offset_Y);
|
||||||
end_counter_x=start_x_counter+width;
|
end_counter_x=start_x_counter+width;
|
||||||
end_counter_y=start_y_counter+height;
|
end_counter_y=start_y_counter+height;
|
||||||
if (is_preview)
|
if (is_preview != 0)
|
||||||
{
|
{
|
||||||
temp=Brush;
|
temp=Brush;
|
||||||
Brush=Paintbrush_sprite;
|
Brush=Paintbrush_sprite;
|
||||||
@ -390,7 +391,7 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
|
|||||||
0,Fore_color,
|
0,Fore_color,
|
||||||
MAX_PAINTBRUSH_SIZE);
|
MAX_PAINTBRUSH_SIZE);
|
||||||
|
|
||||||
if (Main_magnifier_mode)
|
if (Main_magnifier_mode != 0)
|
||||||
{
|
{
|
||||||
Compute_clipped_dimensions_zoom(&start_x,&start_y,&width,&height);
|
Compute_clipped_dimensions_zoom(&start_x,&start_y,&width,&height);
|
||||||
start_x_counter=start_x-(x-Paintbrush_offset_X);
|
start_x_counter=start_x-(x-Paintbrush_offset_X);
|
||||||
@ -419,9 +420,9 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((Smear_mode) && (Shade_table==Shade_table_left))
|
if ((Smear_mode != 0) && (Shade_table==Shade_table_left))
|
||||||
{
|
{
|
||||||
if (Smear_start)
|
if (Smear_start != 0)
|
||||||
{
|
{
|
||||||
if ((width>0) && (height>0))
|
if ((width>0) && (height>0))
|
||||||
{
|
{
|
||||||
@ -444,10 +445,13 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
|
|||||||
{
|
{
|
||||||
temp_color=Read_pixel_from_current_screen(x_pos,y_pos);
|
temp_color=Read_pixel_from_current_screen(x_pos,y_pos);
|
||||||
position=(counter_y*Smear_brush_width)+counter_x;
|
position=(counter_y*Smear_brush_width)+counter_x;
|
||||||
if ( (Paintbrush_sprite[(MAX_PAINTBRUSH_SIZE*counter_y)+counter_x]) // Le pinceau sert de masque pour dire quels pixels on doit traiter dans le rectangle
|
if ( (Paintbrush_sprite[(MAX_PAINTBRUSH_SIZE*counter_y)+counter_x] != 0)
|
||||||
&& (counter_y<Smear_max_Y) && (counter_x<Smear_max_X) // On clippe l'effet smear entre Smear_Min et Smear_Max
|
// Le pinceau sert de masque pour dire quels pixels on doit traiter dans le rectangle
|
||||||
&& (counter_y>=Smear_min_Y) && (counter_x>=Smear_min_X) )
|
&& (counter_y<Smear_max_Y) && (counter_x<Smear_max_X)
|
||||||
Display_pixel(x_pos,y_pos,Smear_brush[position]);
|
&& (counter_y>=Smear_min_Y) && (counter_x>=Smear_min_X)
|
||||||
|
// On clippe l'effet smear entre Smear_Min et Smear_Max
|
||||||
|
)
|
||||||
|
Display_pixel(x_pos,y_pos,Smear_brush[position]);
|
||||||
Smear_brush[position]=temp_color;
|
Smear_brush[position]=temp_color;
|
||||||
}
|
}
|
||||||
Update_part_of_screen(start_x, start_y, width, height);
|
Update_part_of_screen(start_x, start_y, width, height);
|
||||||
@ -464,7 +468,7 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
|
|||||||
for (y_pos=start_y,counter_y=start_y_counter;counter_y<end_counter_y;y_pos++,counter_y++)
|
for (y_pos=start_y,counter_y=start_y_counter;counter_y<end_counter_y;y_pos++,counter_y++)
|
||||||
for (x_pos=start_x,counter_x=start_x_counter;counter_x<end_counter_x;x_pos++,counter_x++)
|
for (x_pos=start_x,counter_x=start_x_counter;counter_x<end_counter_x;x_pos++,counter_x++)
|
||||||
{
|
{
|
||||||
if (Paintbrush_sprite[(MAX_PAINTBRUSH_SIZE*counter_y)+counter_x])
|
if (Paintbrush_sprite[(MAX_PAINTBRUSH_SIZE*counter_y)+counter_x] != 0)
|
||||||
Display_pixel(x_pos,y_pos,color);
|
Display_pixel(x_pos,y_pos,color);
|
||||||
}
|
}
|
||||||
Update_part_of_screen(start_x,start_y,width,height);
|
Update_part_of_screen(start_x,start_y,width,height);
|
||||||
@ -495,11 +499,11 @@ void Hide_paintbrush(short x,short y)
|
|||||||
//short counter_x; // Position X (dans la brosse/pinceau) en cours
|
//short counter_x; // Position X (dans la brosse/pinceau) en cours
|
||||||
//d'affichage
|
//d'affichage
|
||||||
//short counter_y; // Position Y (dans la brosse/pinceau) en cours d'affichage
|
//short counter_y; // Position Y (dans la brosse/pinceau) en cours d'affichage
|
||||||
short end_counter_x; // Position X ou s'arrête l'affichade de la brosse/pinceau
|
short end_counter_x; // Position X ou s'arrête l'affichage de la brosse/pinceau
|
||||||
short end_counter_y; // Position Y ou s'arrête l'affichade de la brosse/pinceau
|
short end_counter_y; // Position Y ou s'arrête l'affichage de la brosse/pinceau
|
||||||
byte * temp;
|
byte * temp;
|
||||||
|
|
||||||
if (!Mouse_K)
|
if (Mouse_K == 0)
|
||||||
switch (Paintbrush_shape)
|
switch (Paintbrush_shape)
|
||||||
{
|
{
|
||||||
case PAINTBRUSH_SHAPE_POINT :
|
case PAINTBRUSH_SHAPE_POINT :
|
||||||
@ -531,7 +535,7 @@ void Hide_paintbrush(short x,short y)
|
|||||||
width,height,Back_color,
|
width,height,Back_color,
|
||||||
Main_image_width);
|
Main_image_width);
|
||||||
|
|
||||||
if (Main_magnifier_mode)
|
if (Main_magnifier_mode != 0)
|
||||||
{
|
{
|
||||||
Compute_clipped_dimensions_zoom(&start_x,&start_y,&width,&height);
|
Compute_clipped_dimensions_zoom(&start_x,&start_y,&width,&height);
|
||||||
start_x_counter=start_x;
|
start_x_counter=start_x;
|
||||||
@ -577,7 +581,7 @@ void Hide_paintbrush(short x,short y)
|
|||||||
Main_image_width);
|
Main_image_width);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Main_magnifier_mode)
|
if (Main_magnifier_mode != 0)
|
||||||
{
|
{
|
||||||
Compute_clipped_dimensions_zoom(&start_x,&start_y,&width,&height);
|
Compute_clipped_dimensions_zoom(&start_x,&start_y,&width,&height);
|
||||||
start_x_counter=start_x;
|
start_x_counter=start_x;
|
||||||
@ -656,11 +660,16 @@ void Capture_brush(short start_x,short start_y,short end_x,short end_y,short cle
|
|||||||
{
|
{
|
||||||
free(Brush);
|
free(Brush);
|
||||||
Brush=(byte *)malloc(((long)new_brush_height)*new_brush_width);
|
Brush=(byte *)malloc(((long)new_brush_height)*new_brush_width);
|
||||||
if (!Brush)
|
if (Brush == NULL)
|
||||||
{
|
{
|
||||||
Error(0);
|
Error(0);
|
||||||
|
|
||||||
Brush=(byte *)malloc(1*1);
|
Brush=(byte *)malloc(1*1);
|
||||||
|
if(Brush == NULL)
|
||||||
|
{
|
||||||
|
Error(ERROR_MEMORY);
|
||||||
|
exit(ERROR_MEMORY);
|
||||||
|
}
|
||||||
new_brush_height=new_brush_width=1;
|
new_brush_height=new_brush_width=1;
|
||||||
*Brush=Fore_color;
|
*Brush=Fore_color;
|
||||||
}
|
}
|
||||||
@ -673,16 +682,26 @@ void Capture_brush(short start_x,short start_y,short end_x,short end_y,short cle
|
|||||||
Smear_brush_height=(Brush_height>MAX_PAINTBRUSH_SIZE)?Brush_height:MAX_PAINTBRUSH_SIZE;
|
Smear_brush_height=(Brush_height>MAX_PAINTBRUSH_SIZE)?Brush_height:MAX_PAINTBRUSH_SIZE;
|
||||||
Smear_brush=(byte *)malloc(((long)Smear_brush_height)*Smear_brush_width);
|
Smear_brush=(byte *)malloc(((long)Smear_brush_height)*Smear_brush_width);
|
||||||
|
|
||||||
if (!Smear_brush) // On ne peut même pas allouer la brosse du smear!
|
if (Smear_brush == NULL) // On ne peut même pas allouer la brosse du smear!
|
||||||
{
|
{
|
||||||
Error(0);
|
Error(0);
|
||||||
|
|
||||||
free(Brush);
|
free(Brush);
|
||||||
Brush=(byte *)malloc(1*1);
|
Brush=(byte *)malloc(1*1);
|
||||||
|
if(Brush == NULL)
|
||||||
|
{
|
||||||
|
Error(ERROR_MEMORY);
|
||||||
|
exit(ERROR_MEMORY);
|
||||||
|
}
|
||||||
Brush_height=1;
|
Brush_height=1;
|
||||||
Brush_width=1;
|
Brush_width=1;
|
||||||
|
|
||||||
Smear_brush=(byte *)malloc(MAX_PAINTBRUSH_SIZE*MAX_PAINTBRUSH_SIZE);
|
Smear_brush=(byte *)malloc(MAX_PAINTBRUSH_SIZE*MAX_PAINTBRUSH_SIZE);
|
||||||
|
if(Smear_brush == NULL)
|
||||||
|
{
|
||||||
|
Error(ERROR_MEMORY);
|
||||||
|
exit(ERROR_MEMORY);
|
||||||
|
}
|
||||||
Smear_brush_height=MAX_PAINTBRUSH_SIZE;
|
Smear_brush_height=MAX_PAINTBRUSH_SIZE;
|
||||||
Smear_brush_width=MAX_PAINTBRUSH_SIZE;
|
Smear_brush_width=MAX_PAINTBRUSH_SIZE;
|
||||||
}
|
}
|
||||||
@ -690,7 +709,7 @@ void Capture_brush(short start_x,short start_y,short end_x,short end_y,short cle
|
|||||||
Copy_image_to_brush(start_x,start_y,Brush_width,Brush_height,Main_image_width);
|
Copy_image_to_brush(start_x,start_y,Brush_width,Brush_height,Main_image_width);
|
||||||
|
|
||||||
// On regarde s'il faut effacer quelque chose:
|
// On regarde s'il faut effacer quelque chose:
|
||||||
if (clear)
|
if (clear != 0)
|
||||||
{
|
{
|
||||||
for (y_pos=start_y;y_pos<start_y+Brush_height;y_pos++)
|
for (y_pos=start_y;y_pos<start_y+Brush_height;y_pos++)
|
||||||
for (x_pos=start_x;x_pos<start_x+Brush_width;x_pos++)
|
for (x_pos=start_x;x_pos<start_x+Brush_width;x_pos++)
|
||||||
@ -716,7 +735,7 @@ void Rotate_90_deg()
|
|||||||
new_brush=(byte *)malloc(((long)Brush_height)*Brush_width);
|
new_brush=(byte *)malloc(((long)Brush_height)*Brush_width);
|
||||||
if (new_brush)
|
if (new_brush)
|
||||||
{
|
{
|
||||||
Rotate_90_deg_lowlevel(Brush,new_brush,Brush_width,Brush_height);
|
Rotate_90_deg_lowlevel(Brush,/*@out@*/ new_brush,Brush_width,Brush_height);
|
||||||
free(Brush);
|
free(Brush);
|
||||||
Brush=new_brush;
|
Brush=new_brush;
|
||||||
|
|
||||||
@ -767,7 +786,7 @@ void Remap_brush(void)
|
|||||||
// conversion puisque elles n'existent pas dans la brosse, donc elles
|
// conversion puisque elles n'existent pas dans la brosse, donc elles
|
||||||
// ne seront pas utilisées par Remap_brush_LOWLEVEL.
|
// ne seront pas utilisées par Remap_brush_LOWLEVEL.
|
||||||
for (color=0;color<=255;color++)
|
for (color=0;color<=255;color++)
|
||||||
if (used[color])
|
if (used[color] != 0)
|
||||||
used[color]=Best_color(Spare_palette[color].R,Spare_palette[color].G,Spare_palette[color].B);
|
used[color]=Best_color(Spare_palette[color].R,Spare_palette[color].G,Spare_palette[color].B);
|
||||||
|
|
||||||
// Il reste une couleur non calculée dans la table qu'il faut mettre à
|
// Il reste une couleur non calculée dans la table qu'il faut mettre à
|
||||||
@ -808,13 +827,9 @@ void Outline_brush(void)
|
|||||||
|
|
||||||
// On copie la brosse courante dans la nouvelle
|
// On copie la brosse courante dans la nouvelle
|
||||||
Copy_part_of_image_to_another(Brush, // source
|
Copy_part_of_image_to_another(Brush, // source
|
||||||
0, 0,
|
0, 0, Brush_width, Brush_height, Brush_width,
|
||||||
Brush_width,
|
new_brush, // Destination
|
||||||
Brush_height,
|
1, 1, width);
|
||||||
Brush_width,
|
|
||||||
new_brush, // Destination
|
|
||||||
1, 1,
|
|
||||||
width);
|
|
||||||
|
|
||||||
// On intervertit la nouvelle et l'ancienne brosse:
|
// On intervertit la nouvelle et l'ancienne brosse:
|
||||||
temp=Brush;
|
temp=Brush;
|
||||||
@ -835,23 +850,20 @@ void Outline_brush(void)
|
|||||||
{
|
{
|
||||||
if (temp[((y_pos-1)*width)+x_pos-1]==Back_color)
|
if (temp[((y_pos-1)*width)+x_pos-1]==Back_color)
|
||||||
{
|
{
|
||||||
if (state)
|
if (state != 0)
|
||||||
{
|
{
|
||||||
Pixel_in_brush(x_pos,y_pos,Fore_color);
|
Pixel_in_brush(x_pos,y_pos,Fore_color);
|
||||||
state=0;
|
state=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (state == 0)
|
||||||
{
|
{
|
||||||
if (!state)
|
Pixel_in_brush(x_pos-1,y_pos,Fore_color);
|
||||||
{
|
state=1;
|
||||||
Pixel_in_brush(x_pos-1,y_pos,Fore_color);
|
|
||||||
state=1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Cas du dernier pixel à droite de la ligne
|
// Cas du dernier pixel à droite de la ligne
|
||||||
if (state)
|
if (state != 0)
|
||||||
Pixel_in_brush(x_pos,y_pos,Fore_color);
|
Pixel_in_brush(x_pos,y_pos,Fore_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -863,23 +875,20 @@ void Outline_brush(void)
|
|||||||
{
|
{
|
||||||
if (temp[((y_pos-1)*width)+x_pos-1]==Back_color)
|
if (temp[((y_pos-1)*width)+x_pos-1]==Back_color)
|
||||||
{
|
{
|
||||||
if (state)
|
if (state != 0)
|
||||||
{
|
{
|
||||||
Pixel_in_brush(x_pos,y_pos,Fore_color);
|
Pixel_in_brush(x_pos,y_pos,Fore_color);
|
||||||
state=0;
|
state=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (state == 0)
|
||||||
{
|
{
|
||||||
if (!state)
|
|
||||||
{
|
|
||||||
Pixel_in_brush(x_pos,y_pos-1,Fore_color);
|
Pixel_in_brush(x_pos,y_pos-1,Fore_color);
|
||||||
state=1;
|
state=1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Cas du dernier pixel en bas de la colonne
|
// Cas du dernier pixel en bas de la colonne
|
||||||
if (state)
|
if (state != 0)
|
||||||
Pixel_in_brush(x_pos,y_pos,Fore_color);
|
Pixel_in_brush(x_pos,y_pos,Fore_color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -903,7 +912,7 @@ void Outline_brush(void)
|
|||||||
|
|
||||||
void Nibble_brush(void)
|
void Nibble_brush(void)
|
||||||
{
|
{
|
||||||
long /*Pos,*/x_pos,y_pos;
|
long x_pos,y_pos;
|
||||||
byte state;
|
byte state;
|
||||||
byte * new_brush;
|
byte * new_brush;
|
||||||
byte * temp;
|
byte * temp;
|
||||||
@ -946,7 +955,7 @@ void Nibble_brush(void)
|
|||||||
{
|
{
|
||||||
if (temp[((y_pos+1)*width)+x_pos+1]==Back_color)
|
if (temp[((y_pos+1)*width)+x_pos+1]==Back_color)
|
||||||
{
|
{
|
||||||
if (state)
|
if (state != 0)
|
||||||
{
|
{
|
||||||
if (x_pos>0)
|
if (x_pos>0)
|
||||||
Pixel_in_brush(x_pos-1,y_pos,Back_color);
|
Pixel_in_brush(x_pos-1,y_pos,Back_color);
|
||||||
@ -955,7 +964,7 @@ void Nibble_brush(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!state)
|
if (state == 0)
|
||||||
{
|
{
|
||||||
Pixel_in_brush(x_pos,y_pos,Back_color);
|
Pixel_in_brush(x_pos,y_pos,Back_color);
|
||||||
state=1;
|
state=1;
|
||||||
@ -984,7 +993,7 @@ void Nibble_brush(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!state)
|
if (state == 0)
|
||||||
{
|
{
|
||||||
Pixel_in_brush(x_pos,y_pos,Back_color);
|
Pixel_in_brush(x_pos,y_pos,Back_color);
|
||||||
state=1;
|
state=1;
|
||||||
@ -1021,7 +1030,7 @@ void Capture_brush_with_lasso(int vertices, short * points,short clear)
|
|||||||
short start_y=Limit_bottom+1;
|
short start_y=Limit_bottom+1;
|
||||||
short end_x=Limit_left-1;
|
short end_x=Limit_left-1;
|
||||||
short end_y=Limit_top-1;
|
short end_y=Limit_top-1;
|
||||||
short temp;
|
unsigned short temp;
|
||||||
short x_pos;
|
short x_pos;
|
||||||
short y_pos;
|
short y_pos;
|
||||||
word new_brush_width;
|
word new_brush_width;
|
||||||
@ -1029,10 +1038,10 @@ void Capture_brush_with_lasso(int vertices, short * points,short clear)
|
|||||||
|
|
||||||
|
|
||||||
// On recherche les bornes de la brosse:
|
// On recherche les bornes de la brosse:
|
||||||
for (temp=0; temp<vertices; temp++)
|
for (temp=0; temp<2*vertices; temp+=2)
|
||||||
{
|
{
|
||||||
x_pos=points[temp<<1];
|
x_pos=points[temp];
|
||||||
y_pos=points[(temp<<1)+1];
|
y_pos=points[temp+1];
|
||||||
if (x_pos<start_x)
|
if (x_pos<start_x)
|
||||||
start_x=x_pos;
|
start_x=x_pos;
|
||||||
if (x_pos>end_x)
|
if (x_pos>end_x)
|
||||||
@ -1079,6 +1088,7 @@ void Capture_brush_with_lasso(int vertices, short * points,short clear)
|
|||||||
Error(0);
|
Error(0);
|
||||||
|
|
||||||
Brush=(byte *)malloc(1*1);
|
Brush=(byte *)malloc(1*1);
|
||||||
|
if(Brush==NULL) Error(ERROR_MEMORY);
|
||||||
new_brush_height=new_brush_width=1;
|
new_brush_height=new_brush_width=1;
|
||||||
*Brush=Fore_color;
|
*Brush=Fore_color;
|
||||||
}
|
}
|
||||||
@ -1097,6 +1107,7 @@ void Capture_brush_with_lasso(int vertices, short * points,short clear)
|
|||||||
|
|
||||||
free(Brush);
|
free(Brush);
|
||||||
Brush=(byte *)malloc(1*1);
|
Brush=(byte *)malloc(1*1);
|
||||||
|
if(Brush==NULL) Error(ERROR_MEMORY);
|
||||||
Brush_height=1;
|
Brush_height=1;
|
||||||
Brush_width=1;
|
Brush_width=1;
|
||||||
|
|
||||||
|
|||||||
178
engine.h
178
engine.h
@ -1,84 +1,94 @@
|
|||||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||||
|
|
||||||
Copyright 2007 Adrien Destugues
|
Copyright 2007 Adrien Destugues
|
||||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||||
|
|
||||||
Grafx2 is free software; you can redistribute it and/or
|
Grafx2 is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License
|
modify it under the terms of the GNU General Public License
|
||||||
as published by the Free Software Foundation; version 2
|
as published by the Free Software Foundation; version 2
|
||||||
of the License.
|
of the License.
|
||||||
|
|
||||||
Grafx2 is distributed in the hope that it will be useful,
|
Grafx2 is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Grafx2; if not, see <http://www.gnu.org/licenses/>
|
along with Grafx2; if not, see <http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
///@file engine.h
|
///@file engine.h
|
||||||
/// Utility functions for the menu and all windows.
|
/// Utility functions for the menu and all windows.
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void Main_handler (void);
|
#ifndef __ENGINE_H__
|
||||||
void Draw_menu_button_frame(byte btn_number,byte pressed);
|
#define __ENGINE_H__
|
||||||
void Unselect_button (int btn_number);
|
|
||||||
void Select_button (int btn_number,byte click);
|
#include "struct.h"
|
||||||
void Open_window (word width,word height, char * title);
|
|
||||||
void Close_window (void);
|
void Main_handler (void);
|
||||||
|
void Draw_menu_button_frame(byte btn_number,byte pressed);
|
||||||
void Open_popup (word x_pos, word y_pos, word width, word height);
|
void Unselect_button (int btn_number);
|
||||||
void Close_popup (void);
|
void Select_button (int btn_number,byte click);
|
||||||
|
void Open_window (word width,word height, char * title);
|
||||||
void Window_draw_normal_bouton(word x_pos,word y_pos,word width,word height,
|
void Close_window (void);
|
||||||
char * title,byte undersc_letter,byte clickable);
|
|
||||||
void Window_select_normal_button(word x_pos,word y_pos,word width,word height);
|
void Open_popup (word x_pos, word y_pos, word width, word height);
|
||||||
void Window_unselect_normal_button(word x_pos,word y_pos,word width,word height);
|
void Close_popup (void);
|
||||||
void Window_draw_palette_bouton(word x_pos,word y_pos);
|
|
||||||
|
void Window_draw_normal_bouton(word x_pos,word y_pos,word width,word height,
|
||||||
void Compute_slider_cursor_height(T_Scroller_button * button);
|
char * title,byte undersc_letter,byte clickable);
|
||||||
void Window_draw_slider(T_Scroller_button * button);
|
void Window_select_normal_button(word x_pos,word y_pos,word width,word height);
|
||||||
void Window_draw_scroller_bouton(T_Scroller_button * button);
|
void Window_unselect_normal_button(word x_pos,word y_pos,word width,word height);
|
||||||
|
void Window_draw_palette_bouton(word x_pos,word y_pos);
|
||||||
void Window_input_content(T_Special_button * button, char * content);
|
|
||||||
void Window_clear_input_button(T_Special_button * button);
|
void Compute_slider_cursor_height(T_Scroller_button * button);
|
||||||
void Window_draw_input_bouton(word x_pos,word y_pos,word width_in_characters);
|
void Window_draw_slider(T_Scroller_button * button);
|
||||||
|
void Window_draw_scroller_bouton(T_Scroller_button * button);
|
||||||
T_Normal_button * Window_set_normal_button(word x_pos, word y_pos,
|
|
||||||
word width, word height,
|
void Window_input_content(T_Special_button * button, char * content);
|
||||||
char * title,byte undersc_letter,
|
void Window_clear_input_button(T_Special_button * button);
|
||||||
byte clickable, word shortcut);
|
void Window_draw_input_bouton(word x_pos,word y_pos,word width_in_characters);
|
||||||
#define GGUI_set_normal_button(x_pos,y_pos,width,height,title,undersc_letter,clickable,shortcut,NAME) \
|
|
||||||
const short NAME = Window_set_normal_button((x_pos),(y_pos),(width),(height),(title),(undersc_letter),(clickable),(shortcut))->Number;
|
T_Normal_button * Window_set_normal_button(word x_pos, word y_pos,
|
||||||
T_Normal_button * Window_set_repeatable_button(word x_pos, word y_pos,
|
word width, word height,
|
||||||
word width, word height,
|
char * title,byte undersc_letter,
|
||||||
char * title,byte undersc_letter,
|
byte clickable, word shortcut);
|
||||||
byte clickable, word shortcut);
|
T_Normal_button * Window_set_repeatable_button(word x_pos, word y_pos,
|
||||||
|
word width, word height,
|
||||||
T_Palette_button * Window_set_palette_button(word x_pos, word y_pos);
|
char * title,byte undersc_letter,
|
||||||
void Window_clear_tags(void);
|
byte clickable, word shortcut);
|
||||||
void Tag_color_range(byte start,byte end);
|
|
||||||
|
T_Palette_button * Window_set_palette_button(word x_pos, word y_pos);
|
||||||
T_Scroller_button * Window_set_scroller_button(word x_pos, word y_pos,
|
void Window_clear_tags(void);
|
||||||
word height,
|
void Tag_color_range(byte start,byte end);
|
||||||
word nb_elements,
|
|
||||||
word nb_elements_visible,
|
T_Scroller_button * Window_set_scroller_button(word x_pos, word y_pos,
|
||||||
word initial_position);
|
word height, word nb_elements, word nb_elements_visible,
|
||||||
T_Special_button * Window_set_special_button(word x_pos,word y_pos,word width,word height);
|
word initial_position);
|
||||||
T_Special_button * Window_set_input_button(word x_pos,word y_pos,word width_in_characters);
|
T_Special_button * Window_set_special_button(word x_pos,word y_pos,word width,
|
||||||
T_Dropdown_button * Window_set_dropdown_button(word x_pos,word y_pos,word width,word height,word dropdown_width,const char *label,byte display_choice,byte display_centered,byte display_arrow,byte active_button);
|
word height);
|
||||||
void Window_dropdown_add_item(T_Dropdown_button * dropdown, word btn_number, const char *label);
|
T_Special_button * Window_set_input_button(word x_pos,word y_pos,
|
||||||
void Window_dropdown_clear_items(T_Dropdown_button * dropdown);
|
word width_in_characters);
|
||||||
T_List_button * Window_set_list_button(T_Special_button * entry_button, T_Scroller_button * scroller, Func_draw_list_item draw_list_item);
|
T_Dropdown_button * Window_set_dropdown_button(word x_pos,word y_pos,word width,
|
||||||
void Window_redraw_list(T_List_button * list);
|
word height,word dropdown_width,const char *label,byte display_choice,
|
||||||
byte Window_click_in_rectangle(short start_x,short start_y,short end_x,short end_y);
|
byte display_centered,byte display_arrow,byte active_button);
|
||||||
short Wait_click_in_palette(T_Palette_button * button);
|
void Window_dropdown_add_item(T_Dropdown_button * dropdown, word btn_number,
|
||||||
void Get_color_behind_window(byte * color, byte * click);
|
const char *label);
|
||||||
|
void Window_dropdown_clear_items(T_Dropdown_button * dropdown);
|
||||||
short Window_clicked_button(void);
|
T_List_button * Window_set_list_button(T_Special_button * entry_button,
|
||||||
int Button_under_mouse(void);
|
T_Scroller_button * scroller, Func_draw_list_item draw_list_item);
|
||||||
short Window_get_clicked_button(void);
|
void Window_redraw_list(T_List_button * list);
|
||||||
void Remap_window_backgrounds(byte * conversion_table, int Min_Y, int Max_Y);
|
byte Window_click_in_rectangle(short start_x,short start_y,short end_x,
|
||||||
void Pixel_background(int x_pos, int y_pos, byte color);
|
short end_y);
|
||||||
|
short Wait_click_in_palette(T_Palette_button * button);
|
||||||
|
void Get_color_behind_window(byte * color, byte * click);
|
||||||
|
|
||||||
|
short Window_clicked_button(void);
|
||||||
|
int Button_under_mouse(void);
|
||||||
|
short Window_get_clicked_button(void);
|
||||||
|
void Remap_window_backgrounds(byte * conversion_table, int Min_Y, int Max_Y);
|
||||||
|
void Pixel_background(int x_pos, int y_pos, byte color);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@ -21,6 +21,10 @@
|
|||||||
///@file filesel.h
|
///@file filesel.h
|
||||||
/// Fileselector window, used for loading and saving images and brushes.
|
/// Fileselector window, used for loading and saving images and brushes.
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
#ifndef __FILESEL_H__
|
||||||
|
#define __FILESEL_H__
|
||||||
|
|
||||||
|
#include "struct.h"
|
||||||
|
|
||||||
byte Button_Load_or_Save(byte load, byte image);
|
byte Button_Load_or_Save(byte load, byte image);
|
||||||
|
|
||||||
@ -40,3 +44,5 @@ void Recount_files(T_Fileselector *list);
|
|||||||
T_Fileselector_item * Get_item_by_index(T_Fileselector *list, short index);
|
T_Fileselector_item * Get_item_by_index(T_Fileselector *list, short index);
|
||||||
|
|
||||||
short Find_file_in_fileselector(T_Fileselector *list, char * fname);
|
short Find_file_in_fileselector(T_Fileselector *list, char * fname);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user