diff --git a/src/buttons.c b/src/buttons.c index 9e95697b..52adb1c8 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -76,6 +76,7 @@ #include "special.h" #include "tiles.h" #include "setup.h" +#include "layers.h" #if defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__) #include @@ -150,6 +151,7 @@ void Button_Message_initial(void) { char str[30]; int x_pos,offs_y,x,y; + int clicked_button=0; strcpy(str,"GrafX2 version "); strcat(str,Program_version); @@ -170,6 +172,9 @@ void Button_Message_initial(void) //Print_in_window( 120-4*13,128,"(placeholder)",MC_Dark,MC_Light); Print_in_window(130-4*28,136,"http://grafx2.googlecode.com",MC_Dark,MC_Light); + Window_set_normal_button(56, 151, 71, 14, "Anim", 0, (Main_backups->Pages->Image_mode != IMAGE_MODE_ANIMATION), KEY_NONE); + Window_set_normal_button(133, 151, 71, 14, "Layers", 0, (Main_backups->Pages->Image_mode != IMAGE_MODE_LAYERED), KEY_NONE); + Update_window_area(0,0,Window_width, Window_height); Display_cursor(); @@ -177,9 +182,35 @@ void Button_Message_initial(void) while(!Mouse_K && !Key) Get_input(20); if (Mouse_K) + { + clicked_button = Window_get_clicked_button(); Wait_end_of_click(); - + } Close_window(); + + if (clicked_button == 1) + { + if (Main_backups->Pages->Image_mode == IMAGE_MODE_LAYERED) + { + // Set to anim mode + if (Menu_bars[MENUBAR_LAYERS].Visible && !Menu_bars[MENUBAR_ANIMATION].Visible) + Set_bar_visibility(MENUBAR_LAYERS, 0, 0); + Set_bar_visibility(MENUBAR_ANIMATION, !Menu_bars[MENUBAR_ANIMATION].Visible, 0); + + Switch_layer_mode(IMAGE_MODE_ANIMATION); + } + else + { + // Set to layer mode + if (Menu_bars[MENUBAR_ANIMATION].Visible && !Menu_bars[MENUBAR_LAYERS].Visible) + Set_bar_visibility(MENUBAR_ANIMATION, 0, 0); + Set_bar_visibility(MENUBAR_LAYERS, !Menu_bars[MENUBAR_LAYERS].Visible, 0); + + Switch_layer_mode(IMAGE_MODE_LAYERED); + } + Display_menu(); + Display_all_screen(); + } Display_cursor(); } @@ -498,20 +529,8 @@ void Button_Toggle_toolbar(void) Set_bar_visibility(MENUBAR_LAYERS, !Menu_bars[MENUBAR_LAYERS].Visible, 0); if (Main_backups->Pages->Image_mode == IMAGE_MODE_ANIMATION) - { - // Exceptionally, this doesn't require a backup because a single-layer - // image is the same as a single-frame animation. - Main_backups->Pages->Image_mode = IMAGE_MODE_LAYERED; - Update_buffers(Main_image_width, Main_image_height); - // Refresh the buffer, special shortcut because only one layer exists. - memset(Main_visible_image_depth_buffer.Image, 0, Main_image_width*Main_image_height); - memcpy(Main_visible_image.Image, - Main_backups->Pages->Image[0].Pixels, - Main_image_width*Main_image_height); + Switch_layer_mode(IMAGE_MODE_LAYERED); - Update_pixel_renderer(); - - } break; case 2: // anim if (Menu_bars[MENUBAR_LAYERS].Visible && !Menu_bars[MENUBAR_ANIMATION].Visible) @@ -519,12 +538,7 @@ void Button_Toggle_toolbar(void) Set_bar_visibility(MENUBAR_ANIMATION, !Menu_bars[MENUBAR_ANIMATION].Visible, 0); if (Main_backups->Pages->Image_mode == IMAGE_MODE_LAYERED) - { - // Exceptionally, this doesn't require a backup because a single-frame - // animation is the same as a single-layer image. - Main_backups->Pages->Image_mode = IMAGE_MODE_ANIMATION; - Update_pixel_renderer(); - } + Switch_layer_mode(IMAGE_MODE_ANIMATION); break; } diff --git a/src/layers.c b/src/layers.c index 09ea4288..7ea4bcc0 100644 --- a/src/layers.c +++ b/src/layers.c @@ -671,3 +671,29 @@ void Button_Anim_continuous_prev(void) Unselect_button(BUTTON_ANIM_PREV_FRAME); Display_cursor(); } + +void Switch_layer_mode(enum IMAGE_MODES new_mode) +{ + if (new_mode == Main_backups->Pages->Image_mode) + return; + + switch (new_mode) + { + case IMAGE_MODE_LAYERED: + Update_buffers(Main_image_width, Main_image_height); + // Refresh the buffer, special shortcut because only one layer exists. + memset(Main_visible_image_depth_buffer.Image, 0, Main_image_width*Main_image_height); + memcpy(Main_visible_image.Image, + Main_backups->Pages->Image[0].Pixels, + Main_image_width*Main_image_height); + break; + case IMAGE_MODE_ANIMATION: + // nothing to do + break; + case IMAGE_MODE_MODE5: + break; + } + + Main_backups->Pages->Image_mode = new_mode; + Update_pixel_renderer(); +} diff --git a/src/layers.h b/src/layers.h index c9439912..6e8e5f3f 100644 --- a/src/layers.h +++ b/src/layers.h @@ -41,3 +41,5 @@ void Button_Anim_continuous_prev(void); void Button_Anim_continuous_next(void); short Layer_under_mouse(void); + +void Switch_layer_mode(enum IMAGE_MODES new_mode);