More unification of layers and anim version: toolbars work. You can switch toolbars by right-clicking the icon from status bar: it proposes 'Anim' only while the current image has 1 layer (see Button_toggle_toolbar()). The animation-specific stuff (rendering...) isn't activated yet, see all the NOLAYERS places remaining. Also will need a trick for keyboard shortcuts to work on multiple buttons, and extra code on swap-to-spare, undo, redo, load etc. to sync toolbars with Image_type.

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1909 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2012-02-27 23:19:23 +00:00
parent 2343dcb54c
commit db50b4ebdc
14 changed files with 223 additions and 202 deletions

View File

@ -510,13 +510,14 @@ void Button_Toggle_toolbar(void)
{
T_Dropdown_button dropdown;
T_Dropdown_choice *item;
static char menu_name[2][9]= {
" Tools",
" Layers"
};
static char menu_name_tools[9] = " Tools";
static char menu_name_layers[9]= " Layers";
static char menu_name_anim[9] = " Anim";
menu_name[0][0] = Menu_bars[MENUBAR_TOOLS ].Visible ? 22 : ' ';
menu_name[1][0] = Menu_bars[MENUBAR_LAYERS].Visible ? 22 : ' ';
menu_name_tools[0] = Menu_bars[MENUBAR_TOOLS ].Visible ? 22 : ' ';
menu_name_layers[0] = Menu_bars[MENUBAR_LAYERS].Visible ? 22 : ' ';
menu_name_anim[0] = Menu_bars[MENUBAR_ANIMATION].Visible ? 22 : ' ';
Hide_cursor();
@ -527,8 +528,16 @@ void Button_Toggle_toolbar(void)
dropdown.First_item =NULL;
dropdown.Bottom_up =1;
Window_dropdown_add_item(&dropdown, 0, menu_name[0]);
Window_dropdown_add_item(&dropdown, 1, menu_name[1]);
Window_dropdown_add_item(&dropdown, 0, menu_name_tools);
if (Main_backups->Pages->Image_mode == IMAGE_MODE_LAYERED ||
Main_backups->Pages->Image_mode == IMAGE_MODE_MODE5 ||
(Main_backups->Pages->Image_mode == IMAGE_MODE_ANIMATION && Main_backups->Pages->Nb_layers==1))
Window_dropdown_add_item(&dropdown, 1, menu_name_layers);
if (Main_backups->Pages->Image_mode == IMAGE_MODE_ANIMATION ||
(Main_backups->Pages->Image_mode == IMAGE_MODE_LAYERED && Main_backups->Pages->Nb_layers==1))
Window_dropdown_add_item(&dropdown, 2, menu_name_anim);
item=Dropdown_activate(&dropdown,0,Menu_Y+Menu_bars[MENUBAR_STATUS].Top*Menu_factor_Y);
@ -536,11 +545,33 @@ void Button_Toggle_toolbar(void)
{
switch (item->Number)
{
case 0:
case 0: // tools
Set_bar_visibility(MENUBAR_TOOLS, !Menu_bars[MENUBAR_TOOLS].Visible);
break;
case 1:
case 1: // anim
if (Menu_bars[MENUBAR_ANIMATION].Visible && !Menu_bars[MENUBAR_LAYERS].Visible)
Set_bar_visibility(MENUBAR_ANIMATION, 0);
Set_bar_visibility(MENUBAR_LAYERS, !Menu_bars[MENUBAR_LAYERS].Visible);
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;
}
break;
case 2: // layers
if (Menu_bars[MENUBAR_LAYERS].Visible && !Menu_bars[MENUBAR_ANIMATION].Visible)
Set_bar_visibility(MENUBAR_LAYERS, 0);
Set_bar_visibility(MENUBAR_ANIMATION, !Menu_bars[MENUBAR_ANIMATION].Visible);
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;
}
break;
}
}
@ -1544,11 +1575,9 @@ void Button_Page(void)
Swap_tilemap();
// On fait le reste du travail "à la main":
#ifndef NOLAYERS
SWAP_PBYTES(Main_visible_image.Image,Spare_visible_image.Image)
SWAP_WORDS (Main_visible_image.Width,Spare_visible_image.Width)
SWAP_WORDS (Main_visible_image.Height,Spare_visible_image.Height)
#endif
SWAP_SHORTS(Main_offset_X,Spare_offset_X)
SWAP_SHORTS(Main_offset_Y,Spare_offset_Y)
SWAP_SHORTS(Main_separator_position,Spare_separator_position)

View File

@ -303,6 +303,20 @@ enum BUTTON_NUMBERS
// Status bar
BUTTON_HIDE = 0,
// Anim bar
BUTTON_LAYER_MENU2,
BUTTON_ANIM_TIME,
BUTTON_ANIM_FIRST_FRAME,
BUTTON_ANIM_PREV_FRAME,
BUTTON_ANIM_NEXT_FRAME,
BUTTON_ANIM_LAST_FRAME,
BUTTON_ANIM_ADD_FRAME,
BUTTON_ANIM_REMOVE_FRAME,
BUTTON_ANIM_UP_FRAME,
BUTTON_ANIM_DOWN_FRAME,
BUTTON_ANIM_PLAY, // unused at this time
// Layer bar
BUTTON_LAYER_MENU,
BUTTON_LAYER_COLOR,
@ -311,12 +325,6 @@ enum BUTTON_NUMBERS
BUTTON_LAYER_REMOVE,
BUTTON_LAYER_UP,
BUTTON_LAYER_DOWN,
BUTTON_ANIM_TIME,
BUTTON_ANIM_FIRST_FRAME,
BUTTON_ANIM_PREV_FRAME,
BUTTON_ANIM_NEXT_FRAME,
BUTTON_ANIM_LAST_FRAME,
BUTTON_ANIM_PLAY,
BUTTON_LAYER_SELECT,
// Main menu

View File

@ -491,20 +491,6 @@ GFX2_GLOBAL byte Menu_factor_Y;
/// Size of a color cell in the menu's palette.
GFX2_GLOBAL word Menu_palette_cell_width;
GFX2_GLOBAL T_Menu_Bar Menu_bars[MENUBAR_COUNT]
#ifdef GLOBAL_VARIABLES
=
{{MENU_WIDTH, 9, 1, 45, {NULL,NULL,NULL}, 20, BUTTON_HIDE }, // Status
#ifdef NOLAYERS
{MENU_WIDTH, 14, 1, 35, {NULL,NULL,NULL}, 236, BUTTON_LAYER_SELECT }, // Animation
#else
{MENU_WIDTH, 10, 1, 35, {NULL,NULL,NULL}, 144, BUTTON_LAYER_SELECT }, // Layers
#endif
{MENU_WIDTH, 35, 1, 0, {NULL,NULL,NULL}, 254, BUTTON_CHOOSE_COL }} // Main
#endif
;
// -- Window data
/// Number of stacked windows currently displayed. 0 when no window is present.

View File

@ -314,13 +314,10 @@ static const T_Help_table helptable_help[] =
HELP_LINK (" Menu : %s", 0x100+BUTTON_LAYER_MENU)
HELP_LINK (" Add new : %s", 0x100+BUTTON_LAYER_ADD)
HELP_LINK (" Delete : %s", 0x100+BUTTON_LAYER_REMOVE)
#ifndef NOLAYERS
HELP_LINK (" Merge : %s", 0x100+BUTTON_LAYER_MERGE)
#endif
HELP_LINK (" Move up : %s", 0x100+BUTTON_LAYER_UP)
HELP_LINK (" Move down : %s", 0x100+BUTTON_LAYER_DOWN)
//HELP_LINK (" Set transp: %s", 0x100+BUTTON_LAYER_COLOR)
#ifndef NOLAYERS
HELP_TEXT (" Select :")
HELP_LINK (" 1 : %s", SPECIAL_LAYER1_SELECT)
HELP_LINK (" 2 : %s", SPECIAL_LAYER2_SELECT)
@ -339,13 +336,11 @@ static const T_Help_table helptable_help[] =
HELP_LINK (" 6 : %s", SPECIAL_LAYER6_TOGGLE)
HELP_LINK (" 7 : %s", SPECIAL_LAYER7_TOGGLE)
HELP_LINK (" 8 : %s", SPECIAL_LAYER8_TOGGLE)
#else
HELP_LINK (" Go to first: %s", 0x100+BUTTON_ANIM_FIRST_FRAME)
HELP_LINK (" Go to previous: %s", 0x100+BUTTON_ANIM_PREV_FRAME)
HELP_LINK (" Go to next: %s", 0x100+BUTTON_ANIM_NEXT_FRAME)
HELP_LINK (" Go to last: %s", 0x100+BUTTON_ANIM_LAST_FRAME)
HELP_LINK (" Set duration: %s", 0x100+BUTTON_ANIM_TIME)
#endif
HELP_TEXT ("")
HELP_LINK (" Format check : %s", SPECIAL_FORMAT_CHECKER)
HELP_LINK (" Format check menu: %s", SPECIAL_FORMAT_CHECKER_MENU)
@ -3056,6 +3051,19 @@ T_Help_section Help_section[] =
// Attention, keep the same order as BUTTON_NUMBERS:
HELP_TABLE_DECLARATION(helptable_hide)
HELP_TABLE_DECLARATION(helptable_layermenu)
HELP_TABLE_DECLARATION(helptable_animtime)
HELP_TABLE_DECLARATION(helptable_firstframe)
HELP_TABLE_DECLARATION(helptable_prevframe)
HELP_TABLE_DECLARATION(helptable_nextframe)
HELP_TABLE_DECLARATION(helptable_lastframe)
HELP_TABLE_DECLARATION(helptable_layeradd)
HELP_TABLE_DECLARATION(helptable_layerdel)
HELP_TABLE_DECLARATION(helptable_layerup)
HELP_TABLE_DECLARATION(helptable_layerdown)
HELP_TABLE_DECLARATION(helptable_animtime) // reserved for future button
HELP_TABLE_DECLARATION(helptable_layermenu)
HELP_TABLE_DECLARATION(helptable_layertrans)
HELP_TABLE_DECLARATION(helptable_layermerge)
@ -3063,15 +3071,8 @@ T_Help_section Help_section[] =
HELP_TABLE_DECLARATION(helptable_layerdel)
HELP_TABLE_DECLARATION(helptable_layerup)
HELP_TABLE_DECLARATION(helptable_layerdown)
// Anim-specific
HELP_TABLE_DECLARATION(helptable_animtime)
HELP_TABLE_DECLARATION(helptable_firstframe)
HELP_TABLE_DECLARATION(helptable_prevframe)
HELP_TABLE_DECLARATION(helptable_nextframe)
HELP_TABLE_DECLARATION(helptable_lastframe)
HELP_TABLE_DECLARATION(helptable_animtime) // reserved for future button
// end of anim-specific
HELP_TABLE_DECLARATION(helptable_layerselect)
HELP_TABLE_DECLARATION(helptable_paintbrush)
HELP_TABLE_DECLARATION(helptable_adjust)
HELP_TABLE_DECLARATION(helptable_draw)

View File

@ -1940,6 +1940,6 @@ word Ordering[NB_SHORTCUTS]=
0x100+BUTTON_ANIM_LAST_FRAME,
0x100+BUTTON_ANIM_PREV_FRAME,
0x100+BUTTON_ANIM_NEXT_FRAME,
0x100+BUTTON_ANIM_PLAY,
0x100+BUTTON_ANIM_PLAY, // Unused at this time
SPECIAL_HOLD_PAN,
};

View File

@ -376,14 +376,14 @@ byte Parse_skin(SDL_Surface * gui, T_Gui_skin *gfx)
return 1;
if (Read_GUI_block(gfx, gui, cursor_x, cursor_y, gfx->Layerbar_block[0], 144, 10,"layer bar",0))
return 1;
cursor_y+= 10;
cursor_y+= Menu_bars[MENUBAR_LAYERS].Height;
// Animbar
if (GUI_seek_down(gui, &cursor_x, &cursor_y, neutral_color, "anim bar"))
return 1;
if (Read_GUI_block(gfx, gui, cursor_x, cursor_y, gfx->Animbar_block[0], 236, 14,"anim bar",0))
return 1;
cursor_y+= 14;
cursor_y+= Menu_bars[MENUBAR_ANIMATION].Height;
// Status bar
if (GUI_seek_down(gui, &cursor_x, &cursor_y, neutral_color, "status bar"))
@ -404,14 +404,14 @@ byte Parse_skin(SDL_Surface * gui, T_Gui_skin *gfx)
return 1;
if (Read_GUI_block(gfx, gui, cursor_x, cursor_y, gfx->Layerbar_block[1], 144, 10,"selected layer bar",0))
return 1;
cursor_y+= 10;
cursor_y+= Menu_bars[MENUBAR_LAYERS].Height;
// Animbar (selected)
if (GUI_seek_down(gui, &cursor_x, &cursor_y, neutral_color, "selected anim bar"))
return 1;
if (Read_GUI_block(gfx, gui, cursor_x, cursor_y, gfx->Animbar_block[1], 236, 14,"selected anim bar",0))
return 1;
cursor_y+= 14;
cursor_y+= Menu_bars[MENUBAR_ANIMATION].Height;
// Status bar (selected)
if (GUI_seek_down(gui, &cursor_x, &cursor_y, neutral_color, "selected status bar"))
@ -1205,7 +1205,7 @@ void Init_buttons(void)
FAMILY_INSTANT);
// Layer bar
#ifndef NOLAYERS
Init_button(BUTTON_LAYER_MENU,
"Layers manager ",
0,0,
@ -1278,9 +1278,10 @@ void Init_buttons(void)
0,0,
Do_nothing,
FAMILY_INSTANT);
#else
// Anim bar
Init_button(BUTTON_LAYER_MENU,
Init_button(BUTTON_LAYER_MENU2,
"Layers manager ",
0,0,
44,13,
@ -1334,8 +1335,8 @@ void Init_buttons(void)
0,0,
Do_nothing,
FAMILY_INSTANT);
Init_button(BUTTON_LAYER_ADD,
"Add layer ",
Init_button(BUTTON_ANIM_ADD_FRAME,
"Add frame ",
177,0,
13,13,
BUTTON_SHAPE_RECTANGLE,
@ -1343,8 +1344,8 @@ void Init_buttons(void)
0,0,
Do_nothing,
FAMILY_INSTANT);
Init_button(BUTTON_LAYER_REMOVE,
"Drop layer ",
Init_button(BUTTON_ANIM_REMOVE_FRAME,
"Drop frame ",
191,0,
13,13,
BUTTON_SHAPE_RECTANGLE,
@ -1352,8 +1353,8 @@ void Init_buttons(void)
0,0,
Do_nothing,
FAMILY_INSTANT);
Init_button(BUTTON_LAYER_DOWN,
"Lower layer ",
Init_button(BUTTON_ANIM_DOWN_FRAME,
"Move frame back ",
205,0,
13,13,
BUTTON_SHAPE_RECTANGLE,
@ -1361,8 +1362,8 @@ void Init_buttons(void)
0,0,
Do_nothing,
FAMILY_INSTANT);
Init_button(BUTTON_LAYER_UP,
"Raise layer ",
Init_button(BUTTON_ANIM_UP_FRAME,
"Move frame forwards ",
219,0,
13,13,
BUTTON_SHAPE_RECTANGLE,
@ -1370,7 +1371,7 @@ void Init_buttons(void)
0,0,
Do_nothing,
FAMILY_INSTANT);
#endif
// Status bar
Init_button(BUTTON_HIDE,
"Hide toolbars / Select ",
@ -2868,11 +2869,8 @@ void Set_current_skin(const char *skinfile, T_Gui_skin *gfx)
for (i=0; i<3; i++)
{
Menu_bars[MENUBAR_TOOLS ].Skin[i] = (byte*)&(gfx->Menu_block[i]);
#ifndef NOLAYERS
Menu_bars[MENUBAR_LAYERS].Skin[i] = (byte*)&(gfx->Layerbar_block[i]);
#else
Menu_bars[MENUBAR_LAYERS].Skin[i] = (byte*)&(gfx->Animbar_block[i]);
#endif
Menu_bars[MENUBAR_ANIMATION].Skin[i] = (byte*)&(gfx->Animbar_block[i]);
Menu_bars[MENUBAR_STATUS].Skin[i] = (byte*)&(gfx->Statusbar_block[i]);
}
}

View File

@ -575,16 +575,6 @@ void Button_Anim_last_frame(void)
Display_cursor();
}
void Button_Anim_play(void)
{
Hide_cursor();
//
Unselect_button(BUTTON_ANIM_PLAY);
Display_cursor();
}
void Button_Anim_continuous_next(void)
{
Uint32 time_start;

View File

@ -1154,12 +1154,10 @@ void Emergency_backup(const char *fname, byte *source, int width, int height, T_
void Image_emergency_backup()
{
#ifndef NOLAYERS
if (Main_backups && Main_backups->Pages && Main_backups->Pages->Nb_layers == 1)
Emergency_backup(SAFETYBACKUP_PREFIX_A "999999" BACKUP_FILE_EXTENSION,Main_screen, Main_image_width, Main_image_height, &Main_palette);
if (Spare_backups && Spare_backups->Pages && Spare_backups->Pages->Nb_layers == 1)
Emergency_backup(SAFETYBACKUP_PREFIX_B "999999" BACKUP_FILE_EXTENSION,Spare_visible_image.Image, Spare_image_width, Spare_image_height, &Spare_palette);
#endif
}
T_Format * Get_fileformat(byte format)

View File

@ -40,14 +40,12 @@ extern byte * FX_feedback_screen;
/////////////////////////// BACKUP ///////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
#ifndef NOLAYERS
/// The pixels of visible layers, flattened copy.
extern T_Bitmap Main_visible_image;
/// The pixels of visible layers, flattened copy, used for no-feedback effects.
extern T_Bitmap Main_visible_image_backup;
/// The index of visible pixels from ::Visible image. Points to the right layer.
extern T_Bitmap Main_visible_image_depth_buffer;
#endif
/// The pixels of visible layers for the spare page, flattened copy.
extern T_Bitmap Spare_visible_image;

View File

@ -36,6 +36,8 @@
#include "setup.h"
#include "realpath.h"
#include "io.h"
#include "windows.h"
void Load_INI_clear_string(char * str, byte keep_comments)
{
@ -898,12 +900,13 @@ int Load_INI(T_Config * conf)
// Optional, Menu bars visibility (> 2.1)
if (!Load_INI_get_values (file, buffer,"Menubars_visible",1,values))
{
int index;
for (index=MENUBAR_STATUS+1; index<MENUBAR_COUNT;index++)
{
// Note that I skip the status bar, always enabled.
Menu_bars[index].Visible = (values[0] & (1<<index)) ? 1 : 0;
}
byte anim_visible = (values[0] & 2)!=0;
byte tools_visible = (values[0] & 4)!=0;
// Skip status bar, always enabled.
Menu_bars[MENUBAR_LAYERS].Visible = anim_visible;
Menu_bars[MENUBAR_ANIMATION].Visible = 0;
Menu_bars[MENUBAR_TOOLS].Visible = tools_visible;
}
conf->Right_click_colorpick=0;

View File

@ -32,6 +32,7 @@
#include "misc.h"
#include "saveini.h"
#include "setup.h"
#include "windows.h"
int Save_INI_reach_group(FILE * old_file,FILE * new_file,char * buffer,char * group)
{
@ -665,15 +666,13 @@ int Save_INI(T_Config * conf)
}
values[0]=0;
for (index=0; index<MENUBAR_COUNT;index++)
{
values[0] |= Menu_bars[index].Visible ? (1<<index) : 0;
}
// Fill out the remaining bits. When new toolbars get implemented, they will
if (!Menu_bars[MENUBAR_LAYERS].Visible && !Menu_bars[MENUBAR_ANIMATION].Visible)
values[0]|=2;
if (!Menu_bars[MENUBAR_TOOLS].Visible)
values[0]|=4;
values[0]=255 ^ values[0];
// Remaining bits are filled so that when new toolbars get implemented, they will
// be visible by default.
for (; index<8;index++)
values[0] |= (1<<index);
if ((return_code=Save_INI_set_values (old_file,new_file,buffer,"Menubars_visible",1,values,0)))
goto Erreur_Retour;

View File

@ -533,24 +533,6 @@ typedef struct {
} T_Paintbrush;
// A menubar.
typedef struct {
word Width;
word Height;
byte Visible;
word Top; ///< Relative to the top line of the menu, hidden bars don't count.
byte* Skin[3]; ///< [0] has normal buttons, [1] has selected buttons, [2] is current.
word Skin_width;
byte Last_button_index;
} T_Menu_Bar;
typedef enum {
MENUBAR_STATUS = 0, // MUST be 0
MENUBAR_LAYERS,
MENUBAR_TOOLS,
MENUBAR_COUNT
} T_Menubars;
typedef struct
{
int Previous;

View File

@ -42,6 +42,13 @@
#include "palette.h"
T_Toolbar_button Buttons_Pool[NB_BUTTONS];
T_Menu_Bar Menu_bars[MENUBAR_COUNT] =
{{MENU_WIDTH, 9, 1, 45, {NULL,NULL,NULL}, 20, BUTTON_HIDE }, // Status
{MENU_WIDTH, 14, 1, 35, {NULL,NULL,NULL}, 236, BUTTON_ANIM_PLAY }, // Animation
{MENU_WIDTH, 10, 1, 35, {NULL,NULL,NULL}, 144, BUTTON_LAYER_SELECT }, // Layers
{MENU_WIDTH, 35, 1, 0, {NULL,NULL,NULL}, 254, BUTTON_CHOOSE_COL }} // Main
;
/// Width of one layer button, in pixels before scaling
word Layer_button_width = 1;
@ -465,105 +472,106 @@ void Draw_bar_remainder(word current_menu, word x_off)
/// Display / update the layer menubar
void Display_layerbar(void)
{
#ifndef NOLAYERS
word x_off=0;
word button_width = LAYER_SPRITE_WIDTH;
word button_number = Main_backups->Pages->Nb_layers;
word horiz_space;
word current_button;
word repeats=1;
if (! Menu_bars[MENUBAR_LAYERS].Visible)
return;
// Available space in pixels
horiz_space = Screen_width / Menu_factor_X - Menu_bars[MENUBAR_LAYERS].Skin_width;
// Don't display all buttons if not enough room
if (horiz_space/button_width < button_number)
button_number = horiz_space/button_width;
// Only 16 icons at the moment
if (button_number > 16) // can be different from MAX_NB_LAYERS
button_number = 16;
// Enlarge the buttons themselves if there's enough room
while (button_number*(button_width+2) < horiz_space && repeats < 20)
if (Menu_bars[MENUBAR_LAYERS].Visible)
{
repeats+=1;
button_width+=2;
}
word x_off=0;
word button_width = LAYER_SPRITE_WIDTH;
word button_number = Main_backups->Pages->Nb_layers;
word horiz_space;
word current_button;
word repeats=1;
x_off=Menu_bars[MENUBAR_LAYERS].Skin_width;
for (current_button=0; current_button<button_number; current_button++)
{
word x_pos=0;
word y_pos;
word sprite_index;
// Available space in pixels
horiz_space = Screen_width / Menu_factor_X - Menu_bars[MENUBAR_LAYERS].Skin_width;
if (Main_current_layer == current_button)
sprite_index=1;
else if (Main_layers_visible & (1 << current_button))
sprite_index=0;
else
sprite_index=2;
// Don't display all buttons if not enough room
if (horiz_space/button_width < button_number)
button_number = horiz_space/button_width;
// Only 16 icons at the moment
if (button_number > 16) // can be different from MAX_NB_LAYERS
button_number = 16;
for (y_pos=0;y_pos<LAYER_SPRITE_HEIGHT;y_pos++)
// Enlarge the buttons themselves if there's enough room
while (button_number*(button_width+2) < horiz_space && repeats < 20)
{
word source_x=0;
for (source_x=0;source_x<LAYER_SPRITE_WIDTH;source_x++)
{
short i = 1;
// This stretches a button, by duplicating the 2nd from right column
// and 3rd column from left.
if (source_x == 1 || (source_x == LAYER_SPRITE_WIDTH-3))
i=repeats;
for (;i>0; i--)
{
Pixel_in_menu(MENUBAR_LAYERS, x_pos + x_off, y_pos, Gfx->Layer_sprite[sprite_index][current_button][y_pos][source_x]);
x_pos++;
}
}
// Next line
x_pos=0;
repeats+=1;
button_width+=2;
}
// Next button
x_off+=button_width;
x_off=Menu_bars[MENUBAR_LAYERS].Skin_width;
for (current_button=0; current_button<button_number; current_button++)
{
word x_pos=0;
word y_pos;
word sprite_index;
if (Main_current_layer == current_button)
sprite_index=1;
else if (Main_layers_visible & (1 << current_button))
sprite_index=0;
else
sprite_index=2;
for (y_pos=0;y_pos<LAYER_SPRITE_HEIGHT;y_pos++)
{
word source_x=0;
for (source_x=0;source_x<LAYER_SPRITE_WIDTH;source_x++)
{
short i = 1;
// This stretches a button, by duplicating the 2nd from right column
// and 3rd column from left.
if (source_x == 1 || (source_x == LAYER_SPRITE_WIDTH-3))
i=repeats;
for (;i>0; i--)
{
Pixel_in_menu(MENUBAR_LAYERS, x_pos + x_off, y_pos, Gfx->Layer_sprite[sprite_index][current_button][y_pos][source_x]);
x_pos++;
}
}
// Next line
x_pos=0;
}
// Next button
x_off+=button_width;
}
// Texture any remaining space to the right.
// This overwrites any junk like deleted buttons.
Draw_bar_remainder(MENUBAR_LAYERS, x_off);
// Update the active area of the layers pseudo-button
Buttons_Pool[BUTTON_LAYER_SELECT].Width = button_number * button_width;
// Required to determine which layer button is clicked
Layer_button_width = button_width;
// A screen refresh required by some callers
Update_rect(
Menu_bars[MENUBAR_LAYERS].Skin_width,
Menu_Y+Menu_bars[MENUBAR_LAYERS].Top*Menu_factor_Y,
horiz_space*Menu_factor_X,
Menu_bars[MENUBAR_LAYERS].Height*Menu_factor_Y);
}
if (Menu_bars[MENUBAR_ANIMATION].Visible)
{
char str[8];
// Rest of horizontal line
Draw_bar_remainder(MENUBAR_ANIMATION, Menu_bars[MENUBAR_ANIMATION].Skin_width);
// Frame# background rectangle
// Block((Menu_bars[MENUBAR_ANIMATION].Skin_width)*Menu_factor_X,(0+Menu_bars[MENUBAR_ANIMATION].Top)*Menu_factor_Y+Menu_Y,8*8*Menu_factor_X,8*Menu_factor_Y,MC_Light);
// Frame #/#
snprintf(str, 5, "#%3d", Main_current_layer+1);
Print_general((82)*Menu_factor_X,(Menu_bars[MENUBAR_ANIMATION].Top+3)*Menu_factor_Y+Menu_Y,str,MC_Black,MC_Light);
Update_rect(
(82)*Menu_factor_X,
(Menu_bars[MENUBAR_ANIMATION].Top+3)*Menu_factor_Y+Menu_Y,
4*8*Menu_factor_X,
8*Menu_factor_Y);
}
// Texture any remaining space to the right.
// This overwrites any junk like deleted buttons.
Draw_bar_remainder(MENUBAR_LAYERS, x_off);
// Update the active area of the layers pseudo-button
Buttons_Pool[BUTTON_LAYER_SELECT].Width = button_number * button_width;
// Required to determine which layer button is clicked
Layer_button_width = button_width;
// A screen refresh required by some callers
Update_rect(
Menu_bars[MENUBAR_LAYERS].Skin_width,
Menu_Y+Menu_bars[MENUBAR_LAYERS].Top*Menu_factor_Y,
horiz_space*Menu_factor_X,
Menu_bars[MENUBAR_LAYERS].Height*Menu_factor_Y);
#else
char str[8];
// Rest of horizontal line
Draw_bar_remainder(MENUBAR_LAYERS, Menu_bars[MENUBAR_LAYERS].Skin_width);
// Frame# background rectangle
// Block((Menu_bars[MENUBAR_LAYERS].Skin_width)*Menu_factor_X,(0+Menu_bars[MENUBAR_LAYERS].Top)*Menu_factor_Y+Menu_Y,8*8*Menu_factor_X,8*Menu_factor_Y,MC_Light);
// Frame #/#
snprintf(str, 5, "#%3d", Main_current_layer+1);
Print_general((82)*Menu_factor_X,(Menu_bars[MENUBAR_LAYERS].Top+3)*Menu_factor_Y+Menu_Y,str,MC_Black,MC_Light);
Update_rect(
(82)*Menu_factor_X,
(Menu_bars[MENUBAR_LAYERS].Top+3)*Menu_factor_Y+Menu_Y,
4*8*Menu_factor_X,
8*Menu_factor_Y);
#endif
}
@ -588,7 +596,7 @@ void Display_menu(void)
for (x_pos=0;x_pos<Menu_bars[current_menu].Skin_width;x_pos++)
Pixel_in_menu(current_menu, x_pos, y_pos, Menu_bars[current_menu].Skin[2][y_pos * Menu_bars[current_menu].Skin_width + x_pos]);
if (current_menu == MENUBAR_LAYERS)
if (current_menu == MENUBAR_LAYERS || current_menu == MENUBAR_ANIMATION)
{
// The layerbar has its own display, for the whole length.
Display_layerbar();

View File

@ -143,4 +143,25 @@ typedef struct
extern T_Toolbar_button Buttons_Pool[NB_BUTTONS];
// A menubar.
typedef struct {
word Width;
word Height;
byte Visible;
word Top; ///< Relative to the top line of the menu, hidden bars don't count.
byte* Skin[3]; ///< [0] has normal buttons, [1] has selected buttons, [2] is current.
word Skin_width;
byte Last_button_index;
} T_Menu_Bar;
enum {
MENUBAR_STATUS = 0, // MUST be 0
MENUBAR_ANIMATION,
MENUBAR_LAYERS,
MENUBAR_TOOLS,
MENUBAR_COUNT
};
extern T_Menu_Bar Menu_bars[MENUBAR_COUNT];
#endif