From 7690cd9e507fb970d8969ce1b40100196b5c585f Mon Sep 17 00:00:00 2001 From: Yves Rizoud Date: Tue, 13 Oct 2009 01:03:32 +0000 Subject: [PATCH] [layers] Added functions to add and delete layers (Keyboard shortcuts alt-ins and alt-del) Now defaults back to 1 layer per image on startup. git-svn-id: svn://pulkomandy.tk/GrafX2/branches/layers@1073 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- buttons.c | 99 ---------------------------------------------- buttons.h | 7 ---- const.h | 2 +- engine.c | 25 ++++++++++++ pages.c | 4 +- special.c | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ special.h | 12 ++++++ 7 files changed, 155 insertions(+), 109 deletions(-) diff --git a/buttons.c b/buttons.c index 142a53eb..81926943 100644 --- a/buttons.c +++ b/buttons.c @@ -4233,105 +4233,6 @@ void Effects_off(void) Snap_mode=0; } -void Transparency_set(byte amount) -{ - const int doubleclick_delay = Config.Double_key_speed; - static long time_click = 0; - long time_previous; - - if (!Colorize_mode) - { - // Activate mode - switch(Colorize_current_mode) - { - case 0 : - Effect_function=Effect_interpolated_colorize; - break; - case 1 : - Effect_function=Effect_additive_colorize; - break; - case 2 : - Effect_function=Effect_substractive_colorize; - } - Shade_mode=0; - Quick_shade_mode=0; - Smooth_mode=0; - Tiling_mode=0; - - Colorize_mode=1; - } - - time_previous = time_click; - time_click = SDL_GetTicks(); - - // Check if it's a quick re-press - if (time_click - time_previous < doubleclick_delay) - { - // Use the typed amount as units, keep the tens. - Colorize_opacity = ((Colorize_opacity%100) /10 *10) + amount; - if (Colorize_opacity == 0) - Colorize_opacity = 100; - } - else - { - // Use 10% units: "1"=10%, ... "0"=100% - if (amount == 0) - Colorize_opacity = 100; - else - Colorize_opacity = amount*10; - } - Compute_colorize_table(); -} - -void Layer_activate(short layer, short side) -{ - word old_layers; - - if (layer >= Main_backups->Pages->Nb_layers) - return; - - // Keep a copy of which layers were visible - old_layers = Main_layers_visible; - if (side == RIGHT_SIDE) - { - // Right-click on current layer - if (Main_current_layer == layer) - { - if (Main_layers_visible == (1<Pages); - //Download_infos_backup(Main_backups); - Display_all_screen(); - Display_cursor(); -} - //---------------------------- Courbes de Bézier ---------------------------- void Button_Curves(void) diff --git a/buttons.h b/buttons.h index 1b25ac64..7c38d05e 100644 --- a/buttons.h +++ b/buttons.h @@ -436,13 +436,6 @@ void Button_Tiling_menu(void); */ void Effects_off(void); -/*! - Command that sets the transparency level. -*/ -void Transparency_set(byte amount); - -void Layer_activate(short layer, short side); - // Menu des effets /*! diff --git a/const.h b/const.h index 60608858..d58c8d0b 100644 --- a/const.h +++ b/const.h @@ -64,7 +64,7 @@ #define LEFT_TRIANGLE_CHARACTER 17 /// Character to display in menus for an ellipsis. #define ELLIPSIS_CHARACTER '…' -#define NB_LAYERS 8 +#define NB_LAYERS 1 ///< Initial number of layers for a new image #define BRUSH_CONTAINER_PREVIEW_WIDTH 16 ///< Size for preview of a brush in Brush container #define BRUSH_CONTAINER_PREVIEW_HEIGHT 16 ///< Size for preview of a brush in Brush container #define BRUSH_CONTAINER_COLUMNS 4 ///< Number of columns in the Brush container diff --git a/engine.c b/engine.c index 44be2eba..2c2f9df1 100644 --- a/engine.c +++ b/engine.c @@ -36,6 +36,7 @@ #include "brush.h" #include "input.h" #include "engine.h" +#include "pages.h" // we need this as global @@ -1032,6 +1033,30 @@ void Main_handler(void) Layer_activate((key_index-SPECIAL_LAYER1_TOGGLE)/2, RIGHT_SIDE); action++; break; + case SPECIAL_LAYER_ADD: + // Backup with unchanged layers + Backup_layers(0); + if (!Add_layer(Main_backups,Main_current_layer+1)) + { + Update_depth_buffer(); + Hide_cursor(); + Display_all_screen(); + Display_cursor(); + } + action++; + break; + case SPECIAL_LAYER_DELETE: + // Backup with unchanged layers + Backup_layers(0); + if (!Delete_layer(Main_backups,Main_current_layer)) + { + Redraw_layered_image(); + Hide_cursor(); + Display_all_screen(); + Display_cursor(); + } + action++; + break; } } } // End of special keys diff --git a/pages.c b/pages.c index 7e6d96c3..03199945 100644 --- a/pages.c +++ b/pages.c @@ -991,7 +991,7 @@ byte Add_layer(T_List_of_pages *list, byte layer) // Fun with binary! layers_before = ((1<>1; + layers_after = (*visible_layers_flag & (~layers_before))>>1; *visible_layers_flag = layers_before | layers_after; // Ensure the current layer is part what is shown. *visible_layers_flag |= 1<= Main_backups->Pages->Nb_layers) + return; + + // Keep a copy of which layers were visible + old_layers = Main_layers_visible; + if (side == RIGHT_SIDE) + { + // Right-click on current layer + if (Main_current_layer == layer) + { + if (Main_layers_visible == (1<Pages); + //Download_infos_backup(Main_backups); + Display_all_screen(); + Display_cursor(); +} + +void Special_add_layer() +{ + + +} +void Special_delete_layer() +{ + + +} diff --git a/special.h b/special.h index d6d64b37..8dfa57c0 100644 --- a/special.h +++ b/special.h @@ -48,3 +48,15 @@ void Zoom_set(int index); void Display_stored_brush_in_window(word x,word y,int number); void Store_brush(int index); byte Restore_brush(int index); + +/*! + Command that sets the transparency level. +*/ +void Transparency_set(byte amount); + +void Layer_activate(short layer, short side); + +void Special_add_layer(void); + +void Special_delete_layer(void); +