[layers] Merged-in the trunk changes (support for variable-height menu bar). Color replacer now works. Saving non-layer formats issues a warning and saves flattened version of the visible layers.
git-svn-id: svn://pulkomandy.tk/GrafX2/branches/layers@1068 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
		
						commit
						dc70d2f59f
					
				@ -394,7 +394,7 @@ void Button_Hide_menu(void)
 | 
			
		||||
  {
 | 
			
		||||
    Menu_is_visible=1;
 | 
			
		||||
    Pixel_in_menu=Pixel_in_toolbar;
 | 
			
		||||
    Menu_Y=Screen_height-(MENU_HEIGHT*Menu_factor_Y);
 | 
			
		||||
    Menu_Y=Screen_height-(Menu_height*Menu_factor_Y);
 | 
			
		||||
 | 
			
		||||
    Compute_magnifier_data();
 | 
			
		||||
    if (Main_magnifier_mode)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										4
									
								
								global.h
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								global.h
									
									
									
									
									
								
							@ -474,9 +474,11 @@ GFX2_GLOBAL short Brush_rotation_center_Y;
 | 
			
		||||
 | 
			
		||||
/// Boolean, true if the menu has to be displayed.
 | 
			
		||||
GFX2_GLOBAL byte  Menu_is_visible;
 | 
			
		||||
/// Height of the menu, when it's displayed
 | 
			
		||||
GFX2_GLOBAL word  Menu_height;
 | 
			
		||||
///
 | 
			
		||||
/// Y position (in screen coordinates) where the menu begins.
 | 
			
		||||
/// This is always either ::Screen_height (when menu is hidden) or (::Screen_height - ::MENU_HEIGHT)
 | 
			
		||||
/// This is always either ::Screen_height (when menu is hidden) or (::Screen_height - ::Menu_height)
 | 
			
		||||
/// As a result, the drawing algoritm always draws the image from 0 to ::Menu_Y-1
 | 
			
		||||
GFX2_GLOBAL word  Menu_Y;
 | 
			
		||||
/// Y position of the status bar (in screen coordinates)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								graph.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								graph.c
									
									
									
									
									
								
							@ -531,7 +531,7 @@ int Init_mode_video(int width, int height, int fullscreen, int pix_ratio)
 | 
			
		||||
  
 | 
			
		||||
  Menu_Y = Screen_height;
 | 
			
		||||
  if (Menu_is_visible)
 | 
			
		||||
    Menu_Y -= MENU_HEIGHT * Menu_factor_Y;
 | 
			
		||||
    Menu_Y -= Menu_height * Menu_factor_Y;
 | 
			
		||||
  Menu_status_Y = Screen_height-(Menu_factor_Y<<3);
 | 
			
		||||
 | 
			
		||||
  Adjust_mouse_sensitivity(fullscreen);
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										59
									
								
								loadsave.c
									
									
									
									
									
								
							
							
						
						
									
										59
									
								
								loadsave.c
									
									
									
									
									
								
							@ -126,22 +126,22 @@ void Save_PNG(void);
 | 
			
		||||
void Init_preview(short width,short height,long size,int format,enum PIXEL_RATIO ratio);
 | 
			
		||||
 | 
			
		||||
T_Format File_formats[NB_KNOWN_FORMATS] = {
 | 
			
		||||
  {"pkm", Test_PKM, Load_PKM, Save_PKM, 1, 1},
 | 
			
		||||
  {"lbm", Test_LBM, Load_LBM, Save_LBM, 1, 0},
 | 
			
		||||
  {"gif", Test_GIF, Load_GIF, Save_GIF, 1, 1},
 | 
			
		||||
  {"bmp", Test_BMP, Load_BMP, Save_BMP, 1, 0},
 | 
			
		||||
  {"pcx", Test_PCX, Load_PCX, Save_PCX, 1, 0},
 | 
			
		||||
  {"img", Test_IMG, Load_IMG, Save_IMG, 1, 0},
 | 
			
		||||
  {"sc?", Test_SCx, Load_SCx, Save_SCx, 1, 0},
 | 
			
		||||
  {"pi1", Test_PI1, Load_PI1, Save_PI1, 1, 0},
 | 
			
		||||
  {"pc1", Test_PC1, Load_PC1, Save_PC1, 1, 0},
 | 
			
		||||
  {"cel", Test_CEL, Load_CEL, Save_CEL, 1, 0},
 | 
			
		||||
  {"neo", Test_NEO, Load_NEO, Save_NEO, 1, 0},
 | 
			
		||||
  {"kcf", Test_KCF, Load_KCF, Save_KCF, 0, 0},
 | 
			
		||||
  {"pal", Test_PAL, Load_PAL, Save_PAL, 0, 0},
 | 
			
		||||
  {"c64", Test_C64, Load_C64, Save_C64, 1, 1},
 | 
			
		||||
  {"pkm", Test_PKM, Load_PKM, Save_PKM, 1, 1, 0},
 | 
			
		||||
  {"lbm", Test_LBM, Load_LBM, Save_LBM, 1, 0, 0},
 | 
			
		||||
  {"gif", Test_GIF, Load_GIF, Save_GIF, 1, 1, 1},
 | 
			
		||||
  {"bmp", Test_BMP, Load_BMP, Save_BMP, 1, 0, 0},
 | 
			
		||||
  {"pcx", Test_PCX, Load_PCX, Save_PCX, 1, 0, 0},
 | 
			
		||||
  {"img", Test_IMG, Load_IMG, Save_IMG, 1, 0, 0},
 | 
			
		||||
  {"sc?", Test_SCx, Load_SCx, Save_SCx, 1, 0, 0},
 | 
			
		||||
  {"pi1", Test_PI1, Load_PI1, Save_PI1, 1, 0, 0},
 | 
			
		||||
  {"pc1", Test_PC1, Load_PC1, Save_PC1, 1, 0, 0},
 | 
			
		||||
  {"cel", Test_CEL, Load_CEL, Save_CEL, 1, 0, 0},
 | 
			
		||||
  {"neo", Test_NEO, Load_NEO, Save_NEO, 1, 0, 0},
 | 
			
		||||
  {"kcf", Test_KCF, Load_KCF, Save_KCF, 0, 0, 0},
 | 
			
		||||
  {"pal", Test_PAL, Load_PAL, Save_PAL, 0, 0, 0},
 | 
			
		||||
  {"c64", Test_C64, Load_C64, Save_C64, 1, 1, 0},
 | 
			
		||||
#ifndef __no_pnglib__
 | 
			
		||||
  {"png", Test_PNG, Load_PNG, Save_PNG, 1, 1}
 | 
			
		||||
  {"png", Test_PNG, Load_PNG, Save_PNG, 1, 1, 0}
 | 
			
		||||
#endif
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -742,7 +742,28 @@ void Save_image(byte image)
 | 
			
		||||
  // sauver le format du fichier: (Est-ce vraiment utile??? Je ne crois pas!)
 | 
			
		||||
  File_error=1;
 | 
			
		||||
 | 
			
		||||
  Read_pixel_function=(image)?Read_pixel_from_current_screen:Read_pixel_from_brush;
 | 
			
		||||
  if (image)
 | 
			
		||||
  {
 | 
			
		||||
    if (!File_formats[Main_fileformat-1].Supports_layers
 | 
			
		||||
      && Main_backups->Pages->Nb_layers > 1)
 | 
			
		||||
    {
 | 
			
		||||
      if (! Confirmation_box("This format will save a flattened copy."))
 | 
			
		||||
      {
 | 
			
		||||
        // File_error is already set to 1.
 | 
			
		||||
        return;
 | 
			
		||||
      }
 | 
			
		||||
      Read_pixel_function=Read_pixel_from_current_screen;
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      Read_pixel_function=Read_pixel_from_current_layer;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    Read_pixel_function=Read_pixel_from_brush;
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  File_formats[Main_fileformat-1].Save();
 | 
			
		||||
 | 
			
		||||
@ -3416,9 +3437,6 @@ void Save_GIF(void)
 | 
			
		||||
  byte old_current_layer=Main_current_layer;
 | 
			
		||||
 | 
			
		||||
  /////////////////////////////////////////////////// FIN DES DECLARATIONS //
 | 
			
		||||
 | 
			
		||||
  if (Read_pixel_function==Read_pixel_from_current_screen)
 | 
			
		||||
    Read_pixel_function=Read_pixel_from_current_layer;
 | 
			
		||||
  
 | 
			
		||||
  File_error=0;
 | 
			
		||||
  
 | 
			
		||||
@ -3714,8 +3732,9 @@ void Save_GIF(void)
 | 
			
		||||
  else
 | 
			
		||||
    File_error=1;
 | 
			
		||||
  
 | 
			
		||||
  // Restore original layer
 | 
			
		||||
  // Restore original index of current layer
 | 
			
		||||
  Main_current_layer = old_current_layer;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										13
									
								
								loadsave.h
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								loadsave.h
									
									
									
									
									
								
							@ -40,12 +40,13 @@ void Save_image(byte image);
 | 
			
		||||
 | 
			
		||||
/// Data for an image file format.
 | 
			
		||||
typedef struct {
 | 
			
		||||
  char *Extension;  ///< Three-letter file extension
 | 
			
		||||
  Func_action Test; ///< Function which tests if the file is of this format
 | 
			
		||||
  Func_action Load; ///< Function which loads an image of this format
 | 
			
		||||
  Func_action Save; ///< Function which saves an image of this format
 | 
			
		||||
  byte Backup_done; ///< Boolean, true if this format saves all the image, and considers it backed up. Set false for formats which only save the palette.
 | 
			
		||||
  byte Comment;     ///< This file format allows a text comment
 | 
			
		||||
  char *Extension;      ///< Three-letter file extension
 | 
			
		||||
  Func_action Test;     ///< Function which tests if the file is of this format
 | 
			
		||||
  Func_action Load;     ///< Function which loads an image of this format
 | 
			
		||||
  Func_action Save;     ///< Function which saves an image of this format
 | 
			
		||||
  byte Backup_done;     ///< Boolean, true if this format saves all the image, and considers it backed up. Set false for formats which only save the palette.
 | 
			
		||||
  byte Comment;         ///< This file format allows a text comment
 | 
			
		||||
  byte Supports_layers; ///< Boolean, true if this format preserves layers on saving
 | 
			
		||||
} T_Format;
 | 
			
		||||
 | 
			
		||||
/// Array of the known file formats
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										1
									
								
								main.c
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								main.c
									
									
									
									
									
								
							@ -462,6 +462,7 @@ int Init_program(int argc,char * argv[])
 | 
			
		||||
  // Données sur l'état du menu:
 | 
			
		||||
  Pixel_in_menu=Pixel_in_toolbar;
 | 
			
		||||
  Menu_is_visible=1;
 | 
			
		||||
  Menu_height=MENU_HEIGHT;
 | 
			
		||||
  // Données sur les couleurs et la palette:
 | 
			
		||||
  First_color_in_palette=0;
 | 
			
		||||
  // Données sur le curseur:
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										23
									
								
								misc.c
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								misc.c
									
									
									
									
									
								
							@ -257,21 +257,16 @@ byte Read_pixel_from_current_layer(word x,word y)
 | 
			
		||||
  return *((y)*Main_image_width+(x)+Main_backups->Pages->Image[Main_current_layer]);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Replace_a_color(byte old_color, byte New_color)
 | 
			
		||||
void Replace_a_color(byte old_color, byte new_color)
 | 
			
		||||
{
 | 
			
		||||
	byte* pixel_on_layer;
 | 
			
		||||
	byte* pixel_visible;
 | 
			
		||||
 | 
			
		||||
	// pour chaque pixel :
 | 
			
		||||
	pixel_visible=Main_screen;
 | 
			
		||||
	for(pixel_on_layer = Main_backups->Pages->Image[Main_current_layer];pixel_on_layer < Main_screen + Main_image_height * Main_image_width;pixel_on_layer++,pixel_visible++)
 | 
			
		||||
	{
 | 
			
		||||
		if (*pixel_on_layer == old_color)
 | 
			
		||||
		{
 | 
			
		||||
			*pixel_on_layer = New_color;
 | 
			
		||||
			*pixel_visible = New_color;
 | 
			
		||||
	  }
 | 
			
		||||
	}
 | 
			
		||||
  word x;
 | 
			
		||||
  word y;
 | 
			
		||||
  
 | 
			
		||||
  // Update all pixels
 | 
			
		||||
	for (y=0; y<Main_image_height; y++)
 | 
			
		||||
  	for (x=0; x<Main_image_width; x++)
 | 
			
		||||
  	  if (Read_pixel_from_current_layer(x,y) == old_color)
 | 
			
		||||
  	    Pixel_in_current_screen(x,y,new_color,0);
 | 
			
		||||
	Update_rect(0,0,0,0); // On peut TOUT a jour
 | 
			
		||||
	// C'est pas un problème car il n'y a pas de preview
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB  | 
							
								
								
									
										24
									
								
								windows.c
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								windows.c
									
									
									
									
									
								
							@ -178,11 +178,11 @@ word Palette_cell_Y(byte index)
 | 
			
		||||
{
 | 
			
		||||
  if (Config.Palette_vertical)
 | 
			
		||||
  {
 | 
			
		||||
    return Menu_Y+((2+(((index-First_color_in_palette)/Menu_cells_X)*(32/Menu_cells_Y)))*Menu_factor_Y);
 | 
			
		||||
    return Menu_Y+((2+(((index-First_color_in_palette)/Menu_cells_X)*((Menu_height-11)/Menu_cells_Y)))*Menu_factor_Y);
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    return Menu_Y+((2+(((index-First_color_in_palette)%Menu_cells_Y)*(32/Menu_cells_Y)))*Menu_factor_Y);
 | 
			
		||||
    return Menu_Y+((2+(((index-First_color_in_palette)%Menu_cells_Y)*((Menu_height-11)/Menu_cells_Y)))*Menu_factor_Y);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -215,7 +215,7 @@ void Frame_menu_color(byte id)
 | 
			
		||||
{
 | 
			
		||||
  word start_x,start_y,end_x,end_y;
 | 
			
		||||
  word index;
 | 
			
		||||
  word cell_height=32/Menu_cells_Y;
 | 
			
		||||
  word cell_height=(Menu_height-11)/Menu_cells_Y;
 | 
			
		||||
  byte color;
 | 
			
		||||
 | 
			
		||||
  if (id==Fore_color)
 | 
			
		||||
@ -289,12 +289,12 @@ void Frame_menu_color(byte id)
 | 
			
		||||
void Display_menu_palette(void)
 | 
			
		||||
{
 | 
			
		||||
  int color;
 | 
			
		||||
  byte cell_height=32/Menu_cells_Y;
 | 
			
		||||
  byte cell_height=(Menu_height-11)/Menu_cells_Y;
 | 
			
		||||
  // width: Menu_palette_cell_width
 | 
			
		||||
  
 | 
			
		||||
  if (Menu_is_visible)
 | 
			
		||||
  {
 | 
			
		||||
    Block(MENU_WIDTH*Menu_factor_X,Menu_Y,Screen_width-(MENU_WIDTH*Menu_factor_X),(MENU_HEIGHT-9)*Menu_factor_Y,MC_Black);
 | 
			
		||||
    Block(MENU_WIDTH*Menu_factor_X,Menu_Y,Screen_width-(MENU_WIDTH*Menu_factor_X),(Menu_height-11+2)*Menu_factor_Y,MC_Black);
 | 
			
		||||
 | 
			
		||||
    if (Config.Separate_colors)
 | 
			
		||||
      for (color=First_color_in_palette;color<256&&(color-First_color_in_palette)<Menu_cells_X*Menu_cells_Y;color++)
 | 
			
		||||
@ -313,7 +313,7 @@ void Display_menu_palette(void)
 | 
			
		||||
 | 
			
		||||
    Frame_menu_color(Back_color);
 | 
			
		||||
    Frame_menu_color(Fore_color);
 | 
			
		||||
    Update_rect(MENU_WIDTH*Menu_factor_X,Menu_Y,Screen_width-(MENU_WIDTH*Menu_factor_X),(MENU_HEIGHT-9)*Menu_factor_Y);
 | 
			
		||||
    Update_rect(MENU_WIDTH*Menu_factor_X,Menu_Y,Screen_width-(MENU_WIDTH*Menu_factor_X),(Menu_height-11)*Menu_factor_Y);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -380,7 +380,7 @@ void Change_palette_cells()
 | 
			
		||||
  // Mise à jour de la taille du bouton dans le menu. C'est pour pas que
 | 
			
		||||
  // la bordure noire soit active.
 | 
			
		||||
  Buttons_Pool[BUTTON_CHOOSE_COL].Width=(Menu_palette_cell_width*Menu_cells_X)-1;
 | 
			
		||||
  Buttons_Pool[BUTTON_CHOOSE_COL].Height=32/Menu_cells_Y*Menu_cells_Y-1;
 | 
			
		||||
  Buttons_Pool[BUTTON_CHOOSE_COL].Height=(Menu_height-11)/Menu_cells_Y*Menu_cells_Y-1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Retrouve la couleur sur laquelle pointe le curseur souris.
 | 
			
		||||
@ -395,7 +395,7 @@ int Pick_color_in_palette()
 | 
			
		||||
  int line;
 | 
			
		||||
  int column;
 | 
			
		||||
 | 
			
		||||
  line=(((Mouse_Y-Menu_Y)/Menu_factor_Y)-2)/(32/Menu_cells_Y);
 | 
			
		||||
  line=(((Mouse_Y-Menu_Y)/Menu_factor_Y)-2)/((Menu_height-11)/Menu_cells_Y);
 | 
			
		||||
  column=(((Mouse_X/Menu_factor_X)-(MENU_WIDTH+1))/Menu_palette_cell_width);
 | 
			
		||||
  if (Config.Palette_vertical)
 | 
			
		||||
  {
 | 
			
		||||
@ -457,7 +457,7 @@ void Display_menu(void)
 | 
			
		||||
      Print_filename();
 | 
			
		||||
    }
 | 
			
		||||
	// Now update the area: menu height and whole screen width (including palette)
 | 
			
		||||
    Update_rect(0,Menu_Y,Screen_width,MENU_HEIGHT*Menu_factor_Y);
 | 
			
		||||
    Update_rect(0,Menu_Y,Screen_width,Menu_height*Menu_factor_Y);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1107,12 +1107,12 @@ void Display_menu_palette_avoiding_window(byte * table)
 | 
			
		||||
  if (Config.Separate_colors)
 | 
			
		||||
  {
 | 
			
		||||
    width=(Menu_palette_cell_width-1)*Menu_factor_X;
 | 
			
		||||
    height=Menu_factor_Y*(32/Menu_cells_Y-1);
 | 
			
		||||
    height=Menu_factor_Y*((Menu_height-11)/Menu_cells_Y-1);
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    width=Menu_palette_cell_width*Menu_factor_X;
 | 
			
		||||
    height=Menu_factor_Y*(32/Menu_cells_Y);
 | 
			
		||||
    height=Menu_factor_Y*((Menu_height-11)/Menu_cells_Y);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  for (color=0,real_color=First_color_in_palette;color<Menu_cells_X*Menu_cells_Y;color++,real_color++)
 | 
			
		||||
@ -1195,7 +1195,7 @@ void Display_menu_palette_avoiding_window(byte * table)
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  Update_rect(MENU_WIDTH*Menu_factor_X,Menu_Y_before_window,Screen_width-(MENU_WIDTH*Menu_factor_X),(MENU_HEIGHT-9)*Menu_factor_Y);
 | 
			
		||||
  Update_rect(MENU_WIDTH*Menu_factor_X,Menu_Y_before_window,Screen_width-(MENU_WIDTH*Menu_factor_X),(Menu_height-11)*Menu_factor_Y);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// -------- Calcul des bornes de la partie d'image visible à l'écran ---------
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user