Working layer bar. Champagne!

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1193 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud
2009-11-15 19:24:04 +00:00
parent 353f5dbbd2
commit 883653480b
10 changed files with 234 additions and 332 deletions

256
layers.c
View File

@@ -26,107 +26,132 @@
#include "engine.h"
#include "pages.h"
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;
#ifndef NOLAYERS
if (side == RIGHT_SIDE)
{
// Right-click on current layer
if (Main_current_layer == layer)
{
if (Main_layers_visible == (dword)(1<<layer))
{
// Set all layers visible
Main_layers_visible = 0xFFFFFFFF;
}
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;
}
#else
// Handler for limited layers support: only allow one visible at a time
if (side == LEFT_SIDE)
{
Main_current_layer = layer;
Main_layers_visible = 1<<layer;
Update_screen_targets();
}
#endif
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_layerbar();
Display_cursor();
}
void Button_Layer_add(void)
{
// Backup with unchanged layers
Backup_layers(0);
if (!Add_layer(Main_backups,Main_current_layer+1))
Hide_cursor();
if (Main_backups->Pages->Nb_layers < 32)
{
Update_depth_buffer();
Hide_cursor();
Display_all_screen();
Display_cursor();
End_of_modification();
// Backup with unchanged layers
Backup_layers(0);
if (!Add_layer(Main_backups,Main_current_layer+1))
{
Update_depth_buffer();
Display_all_screen();
Display_layerbar();
End_of_modification();
}
}
Hide_cursor();
Unselect_button(BUTTON_LAYER_ADD);
Display_cursor();
}
void Button_Layer_remove(void)
{
// Backup with unchanged layers
Backup_layers(0);
if (!Delete_layer(Main_backups,Main_current_layer))
{
Update_screen_targets();
Redraw_layered_image();
Hide_cursor();
Display_all_screen();
Display_cursor();
End_of_modification();
}
Hide_cursor();
if (Main_backups->Pages->Nb_layers > 1)
{
// Backup with unchanged layers
Backup_layers(0);
if (!Delete_layer(Main_backups,Main_current_layer))
{
Update_screen_targets();
Redraw_layered_image();
Display_all_screen();
Display_layerbar();
End_of_modification();
}
}
Unselect_button(BUTTON_LAYER_REMOVE);
Display_cursor();
}
void Button_Layer_select(void)
{
Hide_cursor();
Unselect_button(BUTTON_LAYER_SELECT);
Display_cursor();
word layer;
// Determine which button is clicked according to mouse position
layer = (Mouse_X/Menu_factor_X - Menu_bars[MENUBAR_LAYERS].Skin_width)
/ Layer_button_width;
Layer_activate(layer, LEFT_SIDE);
}
/*
void Button_Layer_1(void)
void Button_Layer_toggle(void)
{
Hide_cursor();
Unselect_button(BUTTON_LAYER_1);
Display_cursor();
word layer;
// Determine which button is clicked according to mouse position
layer = (Mouse_X/Menu_factor_X - Menu_bars[MENUBAR_LAYERS].Skin_width)
/ Layer_button_width;
Layer_activate(layer, RIGHT_SIDE);
}
void Button_Layer_2(void)
{
Hide_cursor();
Unselect_button(BUTTON_LAYER_2);
Display_cursor();
}
void Button_Layer_3(void)
{
Hide_cursor();
Unselect_button(BUTTON_LAYER_3);
Display_cursor();
}
void Button_Layer_4(void)
{
Hide_cursor();
Unselect_button(BUTTON_LAYER_4);
Display_cursor();
}
void Button_Layer_5(void)
{
Hide_cursor();
Unselect_button(BUTTON_LAYER_5);
Display_cursor();
}
void Button_Layer_6(void)
{
Hide_cursor();
Unselect_button(BUTTON_LAYER_6);
Display_cursor();
}
void Button_Layer_7(void)
{
Hide_cursor();
Unselect_button(BUTTON_LAYER_7);
Display_cursor();
}
void Button_Layer_8(void)
{
Hide_cursor();
Unselect_button(BUTTON_LAYER_8);
Display_cursor();
}
*/
void Button_Layer_menu(void)
{
Hide_cursor();
@@ -136,25 +161,27 @@ void Button_Layer_menu(void)
void Button_Layer_color(void)
{
Hide_cursor();
if (Main_backups->Pages->Transparent_color != Back_color)
{
Backup_layers(-1);
Main_backups->Pages->Transparent_color = Back_color;
Redraw_layered_image();
Hide_cursor();
Display_all_screen();
Display_cursor();
End_of_modification();
}
Hide_cursor();
Unselect_button(BUTTON_LAYER_COLOR);
Display_cursor();
}
void Button_Layer_merge(void)
{
Hide_cursor();
if (Main_current_layer>0)
{
// Backup layer below the current
@@ -164,58 +191,58 @@ void Button_Layer_merge(void)
Update_screen_targets();
Redraw_layered_image();
Hide_cursor();
Display_all_screen();
Display_cursor();
Display_layerbar();
End_of_modification();
}
Hide_cursor();
Unselect_button(BUTTON_LAYER_MERGE);
Display_cursor();
}
void Button_Layer_up(void)
{
Hide_cursor();
if (Main_current_layer < (Main_backups->Pages->Nb_layers-1))
{
byte * tmp;
dword layer_flags;
// Backup with unchanged layers
Backup_layers(0);
// swap
tmp = Main_backups->Pages->Image[Main_current_layer];
Main_backups->Pages->Image[Main_current_layer] = Main_backups->Pages->Image[Main_current_layer+1];
Main_backups->Pages->Image[Main_current_layer+1] = tmp;
// Swap visibility indicators
layer_flags = (Main_layers_visible >> Main_current_layer) & 3;
// Only needed if they are different.
if (layer_flags == 1 || layer_flags == 2)
{
// One is on, the other is off. Negating them will
// perform the swap.
Main_layers_visible ^= (3 << Main_current_layer);
}
Main_current_layer++;
Update_screen_targets();
Redraw_layered_image();
Hide_cursor();
Display_all_screen();
Display_cursor();
End_of_modification();
byte * tmp;
dword layer_flags;
// Backup with unchanged layers
Backup_layers(0);
// swap
tmp = Main_backups->Pages->Image[Main_current_layer];
Main_backups->Pages->Image[Main_current_layer] = Main_backups->Pages->Image[Main_current_layer+1];
Main_backups->Pages->Image[Main_current_layer+1] = tmp;
// Swap visibility indicators
layer_flags = (Main_layers_visible >> Main_current_layer) & 3;
// Only needed if they are different.
if (layer_flags == 1 || layer_flags == 2)
{
// One is on, the other is off. Negating them will
// perform the swap.
Main_layers_visible ^= (3 << Main_current_layer);
}
Main_current_layer++;
Update_screen_targets();
Redraw_layered_image();
Display_all_screen();
Display_layerbar();
End_of_modification();
}
Hide_cursor();
Unselect_button(BUTTON_LAYER_UP);
Display_cursor();
}
void Button_Layer_down(void)
{
Hide_cursor();
if (Main_current_layer > 0)
{
byte * tmp;
@@ -242,12 +269,11 @@ void Button_Layer_down(void)
Main_current_layer--;
Update_screen_targets();
Redraw_layered_image();
Hide_cursor();
Display_layerbar();
Display_all_screen();
Display_cursor();
End_of_modification();
}
Hide_cursor();
Unselect_button(BUTTON_LAYER_DOWN);
Display_cursor();
}