Right click on the "add layer" button creates a new layer with a copy of the current layer contents

Suggested by ilkke.


git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@2092 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Adrien Destugues 2015-02-23 21:42:16 +00:00
parent 9d00b93a5f
commit c6b9eba7eb
3 changed files with 39 additions and 14 deletions

View File

@ -1245,11 +1245,11 @@ void Init_buttons(void)
Do_nothing, Do_nothing,
FAMILY_INSTANT); FAMILY_INSTANT);
Init_button(BUTTON_LAYER_ADD, Init_button(BUTTON_LAYER_ADD,
"Add layer ", "Add/Duplicate layer ",
86,0, 86,0,
13,9, 13,9,
BUTTON_SHAPE_RECTANGLE, BUTTON_SHAPE_RECTANGLE,
Button_Layer_add, Button_Layer_add, Button_Layer_add, Button_Layer_duplicate,
0,0, 0,0,
Do_nothing, Do_nothing,
FAMILY_INSTANT); FAMILY_INSTANT);
@ -1351,7 +1351,7 @@ void Init_buttons(void)
177,0, 177,0,
13,13, 13,13,
BUTTON_SHAPE_RECTANGLE, BUTTON_SHAPE_RECTANGLE,
Button_Layer_add, Button_Layer_add, Button_Layer_duplicate, Button_Layer_duplicate,
0,0, 0,0,
Do_nothing, Do_nothing,
FAMILY_INSTANT); FAMILY_INSTANT);

View File

@ -110,16 +110,40 @@ void Button_Layer_add(void)
Backup_layers(LAYER_NONE); Backup_layers(LAYER_NONE);
if (!Add_layer(Main_backups,Main_current_layer+1)) if (!Add_layer(Main_backups,Main_current_layer+1))
{ {
if (Main_backups->Pages->Image_mode == IMAGE_MODE_ANIMATION) Update_depth_buffer();
// I just noticed this might be unneeded, since the new layer
// is transparent, it shouldn't have any visible effect.
Display_all_screen();
Display_layerbar();
End_of_modification();
}
}
Unselect_button(BUTTON_LAYER_ADD);
Unselect_button(BUTTON_ANIM_ADD_FRAME);
Display_cursor();
}
void Button_Layer_duplicate(void)
{ {
// Make a copy of current image, so the display is unchanged int max[] = {MAX_NB_LAYERS, MAX_NB_FRAMES, 5};
Hide_cursor();
if (Main_backups->Pages->Nb_layers < max[Main_backups->Pages->Image_mode])
{
// Backup with unchanged layers
Backup_layers(LAYER_NONE);
if (!Add_layer(Main_backups,Main_current_layer+1))
{
// Make a copy of current image
memcpy( memcpy(
Main_backups->Pages->Image[Main_current_layer].Pixels, Main_backups->Pages->Image[Main_current_layer].Pixels,
Main_backups->Pages->Image[Main_current_layer-1].Pixels, Main_backups->Pages->Image[Main_current_layer-1].Pixels,
Main_backups->Pages->Width*Main_backups->Pages->Height); Main_backups->Pages->Width*Main_backups->Pages->Height);
}
else if (Main_backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) {
{
Update_depth_buffer(); Update_depth_buffer();
// I just noticed this might be unneeded, since the new layer // I just noticed this might be unneeded, since the new layer
// is transparent, it shouldn't have any visible effect. // is transparent, it shouldn't have any visible effect.

View File

@ -21,6 +21,7 @@
*/ */
void Button_Layer_add(void); void Button_Layer_add(void);
void Button_Layer_duplicate(void);
void Button_Layer_remove(void); void Button_Layer_remove(void);
void Button_Layer_menu(void); void Button_Layer_menu(void);
void Button_Layer_set_transparent(void); void Button_Layer_set_transparent(void);