[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
This commit is contained in:
parent
64f1449a3b
commit
7690cd9e50
99
buttons.c
99
buttons.c
@ -4233,105 +4233,6 @@ void Effects_off(void)
|
|||||||
Snap_mode=0;
|
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<<layer))
|
|
||||||
{
|
|
||||||
// Set all layers visible
|
|
||||||
Main_layers_visible = 0xFFFF;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Set only this one visible
|
|
||||||
Main_layers_visible = 1<<layer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Right-click on an other layer : toggle its visibility
|
|
||||||
Main_layers_visible ^= 1<<layer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Left-click on any layer
|
|
||||||
Main_current_layer = layer;
|
|
||||||
Main_layers_visible |= 1<<layer;
|
|
||||||
}
|
|
||||||
|
|
||||||
Hide_cursor();
|
|
||||||
if (Main_layers_visible != old_layers)
|
|
||||||
Redraw_layered_image();
|
|
||||||
else
|
|
||||||
Update_depth_buffer(); // Only need the depth buffer
|
|
||||||
//Download_infos_page_main(Main_backups->Pages);
|
|
||||||
//Download_infos_backup(Main_backups);
|
|
||||||
Display_all_screen();
|
|
||||||
Display_cursor();
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------- Courbes de Bézier ----------------------------
|
//---------------------------- Courbes de Bézier ----------------------------
|
||||||
|
|
||||||
void Button_Curves(void)
|
void Button_Curves(void)
|
||||||
|
|||||||
@ -436,13 +436,6 @@ void Button_Tiling_menu(void);
|
|||||||
*/
|
*/
|
||||||
void Effects_off(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
|
// Menu des effets
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
2
const.h
2
const.h
@ -64,7 +64,7 @@
|
|||||||
#define LEFT_TRIANGLE_CHARACTER 17
|
#define LEFT_TRIANGLE_CHARACTER 17
|
||||||
/// Character to display in menus for an ellipsis.
|
/// Character to display in menus for an ellipsis.
|
||||||
#define ELLIPSIS_CHARACTER '…'
|
#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_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_PREVIEW_HEIGHT 16 ///< Size for preview of a brush in Brush container
|
||||||
#define BRUSH_CONTAINER_COLUMNS 4 ///< Number of columns in the Brush container
|
#define BRUSH_CONTAINER_COLUMNS 4 ///< Number of columns in the Brush container
|
||||||
|
|||||||
25
engine.c
25
engine.c
@ -36,6 +36,7 @@
|
|||||||
#include "brush.h"
|
#include "brush.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
|
#include "pages.h"
|
||||||
|
|
||||||
|
|
||||||
// we need this as global
|
// we need this as global
|
||||||
@ -1032,6 +1033,30 @@ void Main_handler(void)
|
|||||||
Layer_activate((key_index-SPECIAL_LAYER1_TOGGLE)/2, RIGHT_SIDE);
|
Layer_activate((key_index-SPECIAL_LAYER1_TOGGLE)/2, RIGHT_SIDE);
|
||||||
action++;
|
action++;
|
||||||
break;
|
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
|
} // End of special keys
|
||||||
|
|||||||
4
pages.c
4
pages.c
@ -991,7 +991,7 @@ byte Add_layer(T_List_of_pages *list, byte layer)
|
|||||||
|
|
||||||
// Fun with binary!
|
// Fun with binary!
|
||||||
layers_before = ((1<<layer)-1) & *visible_layers_flag;
|
layers_before = ((1<<layer)-1) & *visible_layers_flag;
|
||||||
layers_after = (*visible_layers_flag & (!layers_before))<<1;
|
layers_after = (*visible_layers_flag & (~layers_before))<<1;
|
||||||
*visible_layers_flag = (1<<layer) | layers_before | layers_after;
|
*visible_layers_flag = (1<<layer) | layers_before | layers_after;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1057,7 +1057,7 @@ byte Delete_layer(T_List_of_pages *list, byte layer)
|
|||||||
|
|
||||||
// Fun with binary!
|
// Fun with binary!
|
||||||
layers_before = ((1<<layer)-1) & *visible_layers_flag;
|
layers_before = ((1<<layer)-1) & *visible_layers_flag;
|
||||||
layers_after = (*visible_layers_flag & (!layers_before))>>1;
|
layers_after = (*visible_layers_flag & (~layers_before))>>1;
|
||||||
*visible_layers_flag = layers_before | layers_after;
|
*visible_layers_flag = layers_before | layers_after;
|
||||||
// Ensure the current layer is part what is shown.
|
// Ensure the current layer is part what is shown.
|
||||||
*visible_layers_flag |= 1<<new_current_layer;
|
*visible_layers_flag |= 1<<new_current_layer;
|
||||||
|
|||||||
115
special.c
115
special.c
@ -25,6 +25,11 @@
|
|||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
#include "special.h"
|
#include "special.h"
|
||||||
|
#include "pages.h"
|
||||||
|
#include "misc.h"
|
||||||
|
#include "buttons.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -411,3 +416,113 @@ void Zoom_set(int index)
|
|||||||
}
|
}
|
||||||
Display_cursor();
|
Display_cursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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<<layer))
|
||||||
|
{
|
||||||
|
// Set all layers visible
|
||||||
|
Main_layers_visible = 0xFFFF;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Set only this one visible
|
||||||
|
Main_layers_visible = 1<<layer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Right-click on an other layer : toggle its visibility
|
||||||
|
Main_layers_visible ^= 1<<layer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Left-click on any layer
|
||||||
|
Main_current_layer = layer;
|
||||||
|
Main_layers_visible |= 1<<layer;
|
||||||
|
}
|
||||||
|
|
||||||
|
Hide_cursor();
|
||||||
|
if (Main_layers_visible != old_layers)
|
||||||
|
Redraw_layered_image();
|
||||||
|
else
|
||||||
|
Update_depth_buffer(); // Only need the depth buffer
|
||||||
|
//Download_infos_page_main(Main_backups->Pages);
|
||||||
|
//Download_infos_backup(Main_backups);
|
||||||
|
Display_all_screen();
|
||||||
|
Display_cursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Special_add_layer()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
void Special_delete_layer()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
12
special.h
12
special.h
@ -48,3 +48,15 @@ void Zoom_set(int index);
|
|||||||
void Display_stored_brush_in_window(word x,word y,int number);
|
void Display_stored_brush_in_window(word x,word y,int number);
|
||||||
void Store_brush(int index);
|
void Store_brush(int index);
|
||||||
byte Restore_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);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user