"Hide" button now toggles the layerbar. Right-click works as before. Enjoy the layerbar !

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1179 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Adrien Destugues 2009-11-14 14:11:24 +00:00
parent 6a4ba08343
commit 90595e3af6
8 changed files with 164 additions and 30 deletions

View File

@ -391,9 +391,81 @@ void Button_Hide_menu(void)
}
else
{
byte current_menu;
Menu_is_visible=1;
Pixel_in_menu=Pixel_in_toolbar;
Menu_Y=Screen_height-(Menu_height*Menu_factor_Y);
Menu_Y=Screen_height;
for (current_menu = 0; current_menu < MENUBARS_COUNT; current_menu++)
if (Menu_bars[current_menu].visible)
Menu_Y -= Menu_bars[current_menu].height * Menu_factor_Y;
Compute_magnifier_data();
if (Main_magnifier_mode)
Position_screen_according_to_zoom();
Compute_limits();
Compute_paintbrush_coordinates();
Display_menu();
if (Main_magnifier_mode)
Display_all_screen();
}
Unselect_button(BUTTON_HIDE);
Display_cursor();
}
void Button_Show_layerbar(void)
{
Hide_cursor();
if (Menu_bars[layers_bar].visible)
{
// Hide it
Menu_bars[layers_bar].visible=0;
Menu_Y += Menu_bars[layers_bar].height * Menu_factor_Y;
Menu_height -= Menu_bars[layers_bar].height;
if (Main_magnifier_mode)
{
Compute_magnifier_data();
if (Main_magnifier_offset_Y+Main_magnifier_height>Main_image_height)
{
if (Main_magnifier_height>Main_image_height)
Main_magnifier_offset_Y=0;
else
Main_magnifier_offset_Y=Main_image_height-Main_magnifier_height;
}
}
// On repositionne le décalage de l'image pour qu'il n'y ait pas d'in-
// -cohérences lorsqu'on sortira du mode Loupe.
if (Main_offset_Y+Screen_height>Main_image_height)
{
if (Screen_height>Main_image_height)
Main_offset_Y=0;
else
Main_offset_Y=Main_image_height-Screen_height;
}
// On fait pareil pour le brouillon
if (Spare_offset_Y+Screen_height>Spare_image_height)
{
if (Screen_height>Spare_image_height)
Spare_offset_Y=0;
else
Spare_offset_Y=Spare_image_height-Screen_height;
}
Compute_magnifier_data();
if (Main_magnifier_mode)
Position_screen_according_to_zoom();
Compute_limits();
Compute_paintbrush_coordinates();
Display_menu();
Display_all_screen();
}
else
{
// Show it
Menu_bars[layers_bar].visible = 1;
Menu_Y -= Menu_bars[layers_bar].height * Menu_factor_Y;
Menu_height += Menu_bars[layers_bar].height;
Compute_magnifier_data();
if (Main_magnifier_mode)

View File

@ -629,6 +629,9 @@ void Button_Quit(void);
*/
void Button_Hide_menu(void);
/// Shows or hide the layerbar
void Button_Show_layerbar(void);
/*!
Load picture from file.

10
const.h
View File

@ -257,7 +257,14 @@ enum ICON_TYPES
/// Identifiers for the buttons in the menu.
enum BUTTON_NUMBERS
{
BUTTON_PAINTBRUSHES=0,
// Status bar
BUTTON_HIDE = 0,
// Layer bar
BUTTON_LAYER_MENU,
// Main menu
BUTTON_PAINTBRUSHES,
BUTTON_ADJUST,
BUTTON_DRAW,
BUTTON_CURVES,
@ -293,7 +300,6 @@ enum BUTTON_NUMBERS
BUTTON_PAL_LEFT,
BUTTON_PAL_RIGHT,
BUTTON_CHOOSE_COL,
BUTTON_HIDE,
NB_BUTTONS ///< Number of buttons in the menu bar.
};

View File

@ -65,6 +65,10 @@ byte* Window_background[8];
///Table of tooltip texts for menu buttons
char * Menu_tooltip[NB_BUTTONS]=
{
"Layerbar / Hide menu ",
"Layers manager ",
"Paintbrush choice ",
"Adjust / Transform menu ",
"Freehand draw. / Toggle ",
@ -105,7 +109,6 @@ char * Menu_tooltip[NB_BUTTONS]=
"Scroll pal. bkwd / Fast ",
"Scroll pal. fwd / Fast ",
"Color #" ,
"Hide tool bar "
};
///Save a screen block (usually before erasing it with a new window or a dropdown menu)
@ -144,11 +147,28 @@ int Button_under_mouse(void)
int btn_number;
short x_pos;
short y_pos;
byte current_menu;
word current_offset = Screen_height;
byte first_button;
x_pos=(Mouse_X )/Menu_factor_X;
y_pos=(Mouse_Y-Menu_Y)/Menu_factor_Y;
x_pos = Mouse_X / Menu_factor_X;
for (btn_number=0;btn_number<NB_BUTTONS;btn_number++)
// Find in which menubar we are
for (current_menu = 0; current_menu < MENUBARS_COUNT; current_menu ++)
{
if (Menu_bars[current_menu].visible)
{
current_offset -= Menu_bars[current_menu].height * Menu_factor_Y;
if (Mouse_Y >= current_offset)
break;
}
}
y_pos=(Mouse_Y - current_offset)/Menu_factor_Y;
if (current_menu == 0) first_button = 0;
else first_button = Menu_bars[current_menu - 1].last_button_index + 1;
for (btn_number=first_button;btn_number<=Menu_bars[current_menu].last_button_index;btn_number++)
{
switch(Buttons_Pool[btn_number].Shape)
{
@ -193,9 +213,24 @@ void Draw_menu_button_frame(byte btn_number,byte pressed)
word end_y;
word x_pos;
word y_pos;
byte current_menu;
word y_off = 0;
// Find in which menu the button is
for (current_menu = 0; current_menu < MENUBARS_COUNT; current_menu++)
{
if(Menu_bars[current_menu].visible)
{
y_off += Menu_bars[current_menu].height;
if (Menu_bars[current_menu].last_button_index >= btn_number)
break;
}
}
y_off = Menu_height - y_off;
start_x=Buttons_Pool[btn_number].X_offset;
start_y=Buttons_Pool[btn_number].Y_offset;
start_y=Buttons_Pool[btn_number].Y_offset + y_off;
end_x =start_x+Buttons_Pool[btn_number].Width;
end_y =start_y+Buttons_Pool[btn_number].Height;

View File

@ -479,9 +479,9 @@ GFX2_GLOBAL word Menu_palette_cell_width;
GFX2_GLOBAL T_Menu_Bar Menu_bars[MENUBARS_COUNT]
#ifdef GLOBAL_VARIABLES
=
{{MENU_WIDTH, 9, 1, NULL }, // Status
{MENU_WIDTH, 10, 0, NULL }, // Layers
{MENU_WIDTH, 35, 1, NULL }} // Main
{{MENU_WIDTH, 9, 1, NULL, BUTTON_HIDE }, // Status
{MENU_WIDTH, 10, 0, NULL, BUTTON_LAYER_MENU }, // Layers
{MENU_WIDTH, 35, 1, NULL, BUTTON_CHOOSE_COL }} // Main
#endif
;

20
init.c
View File

@ -1234,11 +1234,21 @@ void Init_buttons(void)
Do_nothing,
FAMILY_INSTANT);
// Layer bar
Init_button(BUTTON_LAYER_MENU,
0,0,
57,9,
BUTTON_SHAPE_RECTANGLE,
Do_nothing, Do_nothing,
Do_nothing,
FAMILY_TOOLBAR);
// Status bar
Init_button(BUTTON_HIDE,
0,35,
0,0,
16,9,
BUTTON_SHAPE_RECTANGLE,
Button_Hide_menu,Button_Hide_menu,
Button_Show_layerbar, Button_Hide_menu,
Do_nothing,
FAMILY_TOOLBAR);
}
@ -2515,7 +2525,7 @@ void Set_current_skin(const char *skinfile, T_Gui_skin *gfx)
MC_Trans = gfx->Color_trans;
// Set menubars to point to the new data
Menu_bars[2].skin = (byte*)&(gfx->Menu_block);
Menu_bars[1].skin = (byte*)&(gfx->Layerbar_block);
Menu_bars[0].skin = (byte*)&(gfx->Statusbar_block);
Menu_bars[main_bar].skin = (byte*)&(gfx->Menu_block);
Menu_bars[layers_bar].skin = (byte*)&(gfx->Layerbar_block);
Menu_bars[status_bar].skin = (byte*)&(gfx->Statusbar_block);
}

View File

@ -468,6 +468,7 @@ typedef struct {
word height;
byte visible;
byte* skin;
byte last_button_index;
} T_Menu_Bar;
typedef enum {

View File

@ -183,11 +183,11 @@ word Palette_cell_Y(byte index)
{
if (Config.Palette_vertical)
{
return Menu_Y+((2+(((index-First_color_in_palette)/Menu_cells_X)*((Menu_height-11)/Menu_cells_Y)))*Menu_factor_Y);
return Menu_Y+((2+(((index-First_color_in_palette)/Menu_cells_X)*(Menu_bars[main_bar].height/Menu_cells_Y)))*Menu_factor_Y);
}
else
{
return Menu_Y+((2+(((index-First_color_in_palette)%Menu_cells_Y)*((Menu_height-11)/Menu_cells_Y)))*Menu_factor_Y);
return Menu_Y+((2+(((index-First_color_in_palette)%Menu_cells_Y)*(Menu_bars[main_bar].height/Menu_cells_Y)))*Menu_factor_Y);
}
}
@ -220,7 +220,7 @@ void Frame_menu_color(byte id)
{
word start_x,start_y,end_x,end_y;
word index;
word cell_height=(Menu_height-11)/Menu_cells_Y;
word cell_height=Menu_bars[main_bar].height*Menu_factor_Y/Menu_cells_Y;
byte color;
if (id==Fore_color)
@ -238,12 +238,12 @@ void Frame_menu_color(byte id)
start_y=Palette_cell_Y(id)-1*Menu_factor_Y;
Block(start_x,start_y,(Menu_palette_cell_width+1)*Menu_factor_X,Menu_factor_Y,color);
Block(start_x,start_y+(Menu_factor_Y*cell_height),(Menu_palette_cell_width+1)*Menu_factor_X,Menu_factor_Y,color);
Block(start_x,start_y+cell_height,(Menu_palette_cell_width+1)*Menu_factor_X,Menu_factor_Y,color);
Block(start_x,start_y+Menu_factor_Y,Menu_factor_X,Menu_factor_Y*(cell_height-1),color);
Block(start_x+(Menu_palette_cell_width*Menu_factor_X),start_y+Menu_factor_Y,Menu_factor_X,Menu_factor_Y*(cell_height-1),color);
Block(start_x,start_y+Menu_factor_Y,Menu_factor_X,cell_height - Menu_factor_Y,color);
Block(start_x+(Menu_palette_cell_width*Menu_factor_X),start_y+Menu_factor_Y,Menu_factor_X,cell_height - Menu_factor_Y,color);
Update_rect(start_x,start_y,(Menu_palette_cell_width+1)*Menu_factor_X,Menu_factor_Y*(cell_height+1));
Update_rect(start_x,start_y,(Menu_palette_cell_width+1)*Menu_factor_X,cell_height + Menu_factor_Y);
}
else
{
@ -253,14 +253,14 @@ void Frame_menu_color(byte id)
if (color==MC_Black)
{
Block(start_x,start_y,Menu_palette_cell_width*Menu_factor_X,
cell_height*Menu_factor_Y,id);
cell_height,id);
Update_rect(start_x,start_y,Menu_palette_cell_width*Menu_factor_X,cell_height*Menu_factor_Y);
Update_rect(start_x,start_y,Menu_palette_cell_width*Menu_factor_X,cell_height);
}
else
{
end_x=Menu_palette_cell_width-1;
end_y=cell_height-1;
end_y=cell_height/Menu_factor_Y-1;
// Top line
for (index=0; index<=end_x; index++)
@ -283,7 +283,7 @@ void Frame_menu_color(byte id)
Menu_factor_X,Menu_factor_Y,
((index+end_y)&1)?color:MC_Black);
Update_rect(start_x*Menu_factor_X,start_y*Menu_factor_Y,Menu_palette_cell_width*Menu_factor_X,Menu_Y+Menu_factor_Y*cell_height);
Update_rect(start_x*Menu_factor_X,start_y*Menu_factor_Y,Menu_palette_cell_width*Menu_factor_X,Menu_Y+cell_height);
}
}
}
@ -294,7 +294,7 @@ void Frame_menu_color(byte id)
void Display_menu_palette(void)
{
int color;
byte cell_height=(Menu_height-11)/Menu_cells_Y;
byte cell_height=(Menu_bars[main_bar].height)*Menu_factor_Y/Menu_cells_Y;
// width: Menu_palette_cell_width
if (Menu_is_visible)
@ -306,14 +306,14 @@ void Display_menu_palette(void)
Block(Palette_cell_X(color),
Palette_cell_Y(color),
(Menu_palette_cell_width-1)*Menu_factor_X,
(cell_height-1)*Menu_factor_Y,
cell_height-Menu_factor_Y,
color);
else
for (color=First_color_in_palette;color<256&&color-First_color_in_palette<Menu_cells_X*Menu_cells_Y;color++)
Block(Palette_cell_X(color),
Palette_cell_Y(color),
Menu_palette_cell_width*Menu_factor_X,
cell_height*Menu_factor_Y,
cell_height,
color);
Frame_menu_color(Back_color);
@ -440,6 +440,13 @@ void Display_menu(void)
// Grey area for filename below palette
Block(MENU_WIDTH*Menu_factor_X,Menu_status_Y-Menu_factor_Y,Screen_width-(MENU_WIDTH*Menu_factor_X),9*Menu_factor_Y,MC_Light);
// Black area below palette
if(Menu_bars[layers_bar].visible)
Block(MENU_WIDTH*Menu_factor_X,
Menu_Y + Menu_bars[main_bar].height*Menu_factor_Y,
Screen_width-(MENU_WIDTH*Menu_factor_X),
Menu_bars[layers_bar].height*Menu_factor_Y,MC_Black);
// Display palette
Display_menu_palette();