Toolbars now automatically switch to anim/layers when required
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1911 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
e73eb2786a
commit
de6b3ac8d1
@ -214,6 +214,7 @@ void Button_Undo(void)
|
|||||||
Set_palette(Main_palette);
|
Set_palette(Main_palette);
|
||||||
Compute_optimal_menu_colors(Main_palette);
|
Compute_optimal_menu_colors(Main_palette);
|
||||||
|
|
||||||
|
Check_menu_mode();
|
||||||
Display_all_screen();
|
Display_all_screen();
|
||||||
Unselect_button(BUTTON_UNDO);
|
Unselect_button(BUTTON_UNDO);
|
||||||
Draw_menu_button(BUTTON_MAGNIFIER,Main_magnifier_mode);
|
Draw_menu_button(BUTTON_MAGNIFIER,Main_magnifier_mode);
|
||||||
@ -228,6 +229,7 @@ void Button_Redo(void)
|
|||||||
Set_palette(Main_palette);
|
Set_palette(Main_palette);
|
||||||
Compute_optimal_menu_colors(Main_palette);
|
Compute_optimal_menu_colors(Main_palette);
|
||||||
|
|
||||||
|
Check_menu_mode();
|
||||||
Display_all_screen();
|
Display_all_screen();
|
||||||
Unselect_button(BUTTON_UNDO);
|
Unselect_button(BUTTON_UNDO);
|
||||||
Draw_menu_button(BUTTON_MAGNIFIER,Main_magnifier_mode);
|
Draw_menu_button(BUTTON_MAGNIFIER,Main_magnifier_mode);
|
||||||
@ -448,64 +450,6 @@ void Button_Hide_menu(void)
|
|||||||
Display_cursor();
|
Display_cursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Set_bar_visibility(word bar, byte visible)
|
|
||||||
{
|
|
||||||
if (!visible && Menu_bars[bar].Visible)
|
|
||||||
{
|
|
||||||
// Hide it
|
|
||||||
Menu_bars[bar].Visible=0;
|
|
||||||
|
|
||||||
Compute_menu_offsets();
|
|
||||||
|
|
||||||
if (Main_magnifier_mode)
|
|
||||||
{
|
|
||||||
Compute_magnifier_data();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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 if (visible && !Menu_bars[bar].Visible)
|
|
||||||
{
|
|
||||||
// Show it
|
|
||||||
Menu_bars[bar].Visible = 1;
|
|
||||||
|
|
||||||
Compute_menu_offsets();
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Button_Toggle_toolbar(void)
|
void Button_Toggle_toolbar(void)
|
||||||
{
|
{
|
||||||
T_Dropdown_button dropdown;
|
T_Dropdown_button dropdown;
|
||||||
@ -546,12 +490,12 @@ void Button_Toggle_toolbar(void)
|
|||||||
switch (item->Number)
|
switch (item->Number)
|
||||||
{
|
{
|
||||||
case 0: // tools
|
case 0: // tools
|
||||||
Set_bar_visibility(MENUBAR_TOOLS, !Menu_bars[MENUBAR_TOOLS].Visible);
|
Set_bar_visibility(MENUBAR_TOOLS, !Menu_bars[MENUBAR_TOOLS].Visible, 0);
|
||||||
break;
|
break;
|
||||||
case 1: // layers
|
case 1: // layers
|
||||||
if (Menu_bars[MENUBAR_ANIMATION].Visible && !Menu_bars[MENUBAR_LAYERS].Visible)
|
if (Menu_bars[MENUBAR_ANIMATION].Visible && !Menu_bars[MENUBAR_LAYERS].Visible)
|
||||||
Set_bar_visibility(MENUBAR_ANIMATION, 0);
|
Set_bar_visibility(MENUBAR_ANIMATION, 0, 0);
|
||||||
Set_bar_visibility(MENUBAR_LAYERS, !Menu_bars[MENUBAR_LAYERS].Visible);
|
Set_bar_visibility(MENUBAR_LAYERS, !Menu_bars[MENUBAR_LAYERS].Visible, 0);
|
||||||
|
|
||||||
if (Main_backups->Pages->Image_mode == IMAGE_MODE_ANIMATION)
|
if (Main_backups->Pages->Image_mode == IMAGE_MODE_ANIMATION)
|
||||||
{
|
{
|
||||||
@ -562,8 +506,8 @@ void Button_Toggle_toolbar(void)
|
|||||||
break;
|
break;
|
||||||
case 2: // anim
|
case 2: // anim
|
||||||
if (Menu_bars[MENUBAR_LAYERS].Visible && !Menu_bars[MENUBAR_ANIMATION].Visible)
|
if (Menu_bars[MENUBAR_LAYERS].Visible && !Menu_bars[MENUBAR_ANIMATION].Visible)
|
||||||
Set_bar_visibility(MENUBAR_LAYERS, 0);
|
Set_bar_visibility(MENUBAR_LAYERS, 0, 0);
|
||||||
Set_bar_visibility(MENUBAR_ANIMATION, !Menu_bars[MENUBAR_ANIMATION].Visible);
|
Set_bar_visibility(MENUBAR_ANIMATION, !Menu_bars[MENUBAR_ANIMATION].Visible, 0);
|
||||||
|
|
||||||
if (Main_backups->Pages->Image_mode == IMAGE_MODE_LAYERED)
|
if (Main_backups->Pages->Image_mode == IMAGE_MODE_LAYERED)
|
||||||
{
|
{
|
||||||
@ -574,6 +518,9 @@ void Button_Toggle_toolbar(void)
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// redraw image and menu
|
||||||
|
Display_menu();
|
||||||
|
Display_all_screen();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Closing
|
// Closing
|
||||||
@ -603,14 +550,17 @@ void Button_Toggle_all_toolbars(void)
|
|||||||
// At least one is visible: Hide all
|
// At least one is visible: Hide all
|
||||||
Last_visibility=current_visibility;
|
Last_visibility=current_visibility;
|
||||||
for (i=MENUBAR_STATUS+1;i<MENUBAR_COUNT;i++)
|
for (i=MENUBAR_STATUS+1;i<MENUBAR_COUNT;i++)
|
||||||
Set_bar_visibility(i,0);
|
Set_bar_visibility(i,0, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Restore all
|
// Restore all
|
||||||
for (i=MENUBAR_STATUS+1;i<MENUBAR_COUNT;i++)
|
for (i=MENUBAR_STATUS+1;i<MENUBAR_COUNT;i++)
|
||||||
Set_bar_visibility(i,(Last_visibility & (1<<i)) ? 1 : 0);
|
Set_bar_visibility(i,(Last_visibility & (1<<i)) ? 1 : 0, 0);
|
||||||
}
|
}
|
||||||
|
Check_menu_mode();
|
||||||
|
Display_menu();
|
||||||
|
Display_all_screen();
|
||||||
|
|
||||||
Unselect_button(BUTTON_HIDE);
|
Unselect_button(BUTTON_HIDE);
|
||||||
Display_cursor();
|
Display_cursor();
|
||||||
@ -1638,6 +1588,7 @@ void Button_Page(void)
|
|||||||
|
|
||||||
Set_palette(Main_palette);
|
Set_palette(Main_palette);
|
||||||
Compute_optimal_menu_colors(Main_palette);
|
Compute_optimal_menu_colors(Main_palette);
|
||||||
|
Check_menu_mode();
|
||||||
Display_all_screen();
|
Display_all_screen();
|
||||||
Unselect_button(BUTTON_PAGE);
|
Unselect_button(BUTTON_PAGE);
|
||||||
Draw_menu_button(BUTTON_MAGNIFIER,Main_magnifier_mode);
|
Draw_menu_button(BUTTON_MAGNIFIER,Main_magnifier_mode);
|
||||||
@ -3295,6 +3246,7 @@ void Load_picture(byte image)
|
|||||||
Compute_optimal_menu_colors(Main_palette);
|
Compute_optimal_menu_colors(Main_palette);
|
||||||
Redraw_layered_image();
|
Redraw_layered_image();
|
||||||
End_of_modification();
|
End_of_modification();
|
||||||
|
Check_menu_mode();
|
||||||
Display_all_screen();
|
Display_all_screen();
|
||||||
|
|
||||||
if (image)
|
if (image)
|
||||||
@ -3398,6 +3350,7 @@ void Button_Reload(void)
|
|||||||
Tilemap_update();
|
Tilemap_update();
|
||||||
Redraw_layered_image();
|
Redraw_layered_image();
|
||||||
End_of_modification();
|
End_of_modification();
|
||||||
|
Check_menu_mode();
|
||||||
Display_all_screen();
|
Display_all_screen();
|
||||||
|
|
||||||
Main_image_is_modified=0;
|
Main_image_is_modified=0;
|
||||||
|
|||||||
124
src/engine.c
124
src/engine.c
@ -636,12 +636,12 @@ void Main_handler(void)
|
|||||||
Compute_paintbrush_coordinates();
|
Compute_paintbrush_coordinates();
|
||||||
Redraw_layered_image();
|
Redraw_layered_image();
|
||||||
End_of_modification();
|
End_of_modification();
|
||||||
Display_all_screen();
|
|
||||||
Main_image_is_modified=0;
|
Main_image_is_modified=0;
|
||||||
}
|
}
|
||||||
Destroy_context(&context);
|
Destroy_context(&context);
|
||||||
|
|
||||||
Compute_optimal_menu_colors(Main_palette);
|
Compute_optimal_menu_colors(Main_palette);
|
||||||
|
Check_menu_mode();
|
||||||
Display_menu();
|
Display_menu();
|
||||||
if (Config.Display_image_limits)
|
if (Config.Display_image_limits)
|
||||||
Display_image_limits();
|
Display_image_limits();
|
||||||
@ -1703,6 +1703,7 @@ void Close_window(void)
|
|||||||
Menu_is_visible=Menu_is_visible_before_window;
|
Menu_is_visible=Menu_is_visible_before_window;
|
||||||
Cursor_shape=Cursor_shape_before_window;
|
Cursor_shape=Cursor_shape_before_window;
|
||||||
|
|
||||||
|
Check_menu_mode();
|
||||||
Display_all_screen();
|
Display_all_screen();
|
||||||
Display_menu();
|
Display_menu();
|
||||||
Allow_colorcycling=1;
|
Allow_colorcycling=1;
|
||||||
@ -3512,3 +3513,124 @@ void Delay_with_active_mouse(int speed)
|
|||||||
Get_input(20);
|
Get_input(20);
|
||||||
} while (Mouse_K == original_mouse_k && SDL_GetTicks()<end);
|
} while (Mouse_K == original_mouse_k && SDL_GetTicks()<end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Based on which toolbars are visible, updates their offsets and
|
||||||
|
/// computes ::Menu_height and ::Menu_Y
|
||||||
|
void Compute_menu_offsets(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int offset;
|
||||||
|
|
||||||
|
// Recompute all offsets
|
||||||
|
offset=0;
|
||||||
|
Menu_height=0;
|
||||||
|
for (i = MENUBAR_COUNT-1; i >=0; i--)
|
||||||
|
{
|
||||||
|
Menu_bars[i].Top = offset;
|
||||||
|
if(Menu_bars[i].Visible)
|
||||||
|
{
|
||||||
|
offset += Menu_bars[i].Height;
|
||||||
|
Menu_height += Menu_bars[i].Height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Update global menu coordinates
|
||||||
|
Menu_Y = Screen_height - Menu_height * Menu_factor_Y;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Shows or hides a tolbar from the menu.
|
||||||
|
/// If with_redraw is set to zero, the caller should
|
||||||
|
/// redraw itself using Display_menu() and Display_all_screen().
|
||||||
|
void Set_bar_visibility(word bar, int visible, int with_redraw)
|
||||||
|
{
|
||||||
|
if (!visible && Menu_bars[bar].Visible)
|
||||||
|
{
|
||||||
|
// Hide it
|
||||||
|
Menu_bars[bar].Visible=0;
|
||||||
|
|
||||||
|
Compute_menu_offsets();
|
||||||
|
|
||||||
|
if (Main_magnifier_mode)
|
||||||
|
{
|
||||||
|
Compute_magnifier_data();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
if (with_redraw)
|
||||||
|
{
|
||||||
|
Display_menu();
|
||||||
|
Display_all_screen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (visible && !Menu_bars[bar].Visible)
|
||||||
|
{
|
||||||
|
// Show it
|
||||||
|
Menu_bars[bar].Visible = 1;
|
||||||
|
|
||||||
|
Compute_menu_offsets();
|
||||||
|
Compute_magnifier_data();
|
||||||
|
if (Main_magnifier_mode)
|
||||||
|
Position_screen_according_to_zoom();
|
||||||
|
Compute_limits();
|
||||||
|
Compute_paintbrush_coordinates();
|
||||||
|
if (with_redraw)
|
||||||
|
{
|
||||||
|
Display_menu();
|
||||||
|
if (Main_magnifier_mode)
|
||||||
|
Display_all_screen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Checks if the current menu toolbars suit the current image type :
|
||||||
|
/// layered vs anim. If they don't fit, swap the toolbars and return 1:
|
||||||
|
/// The caller is then responsible for refreshing the screen by calling
|
||||||
|
/// Display_menu() and Display_all_screen()
|
||||||
|
int Check_menu_mode(void)
|
||||||
|
{
|
||||||
|
if (Main_backups->Pages->Image_mode == IMAGE_MODE_ANIMATION
|
||||||
|
&& Main_backups->Pages->Nb_layers>1 )
|
||||||
|
{
|
||||||
|
if (Menu_bars[MENUBAR_LAYERS].Visible)
|
||||||
|
{
|
||||||
|
Set_bar_visibility(MENUBAR_LAYERS, 0, 0);
|
||||||
|
Set_bar_visibility(MENUBAR_ANIMATION, 1, 0);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (Main_backups->Pages->Image_mode != IMAGE_MODE_ANIMATION
|
||||||
|
&& Main_backups->Pages->Nb_layers>1 )
|
||||||
|
{
|
||||||
|
if (Menu_bars[MENUBAR_ANIMATION].Visible)
|
||||||
|
{
|
||||||
|
Set_bar_visibility(MENUBAR_ANIMATION, 0, 0);
|
||||||
|
Set_bar_visibility(MENUBAR_LAYERS, 1, 0);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|||||||
18
src/engine.h
18
src/engine.h
@ -120,4 +120,22 @@ void Status_print_palette_color(byte color);
|
|||||||
/// though the mouse still works.
|
/// though the mouse still works.
|
||||||
void Delay_with_active_mouse(int delay);
|
void Delay_with_active_mouse(int delay);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Based on which toolbars are visible, updates their offsets and
|
||||||
|
/// computes ::Menu_height and ::Menu_Y
|
||||||
|
void Compute_menu_offsets(void);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Shows or hides a tolbar from the menu.
|
||||||
|
/// If with_redraw is set to zero, the caller should
|
||||||
|
/// redraw itself using Display_menu() and Display_all_screen().
|
||||||
|
void Set_bar_visibility(word bar, int visible, int with_redraw);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Checks if the current menu toolbars suit the current image type :
|
||||||
|
/// layered vs anim. If they don't fit, swap the toolbars and return 1:
|
||||||
|
/// The caller is then responsible for refreshing the screen by calling
|
||||||
|
/// Display_menu() and Display_all_screen()
|
||||||
|
int Check_menu_mode(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
25
src/init.c
25
src/init.c
@ -84,7 +84,6 @@
|
|||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
#include "layers.h"
|
#include "layers.h"
|
||||||
#include "special.h"
|
#include "special.h"
|
||||||
#include "buttons.h"
|
|
||||||
|
|
||||||
char Gui_loading_error_message[512];
|
char Gui_loading_error_message[512];
|
||||||
|
|
||||||
@ -2875,30 +2874,6 @@ void Set_current_skin(const char *skinfile, T_Gui_skin *gfx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
|
||||||
/// Based on which toolbars are visible, updates their offsets and
|
|
||||||
/// computes ::Menu_height and ::Menu_Y
|
|
||||||
void Compute_menu_offsets(void)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int offset;
|
|
||||||
|
|
||||||
// Recompute all offsets
|
|
||||||
offset=0;
|
|
||||||
Menu_height=0;
|
|
||||||
for (i = MENUBAR_COUNT-1; i >=0; i--)
|
|
||||||
{
|
|
||||||
Menu_bars[i].Top = offset;
|
|
||||||
if(Menu_bars[i].Visible)
|
|
||||||
{
|
|
||||||
offset += Menu_bars[i].Height;
|
|
||||||
Menu_height += Menu_bars[i].Height;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Update global menu coordinates
|
|
||||||
Menu_Y = Screen_height - Menu_height * Menu_factor_Y;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Init_paintbrush(int index, int width, int height, byte shape, const char * bitmap)
|
void Init_paintbrush(int index, int width, int height, byte shape, const char * bitmap)
|
||||||
{
|
{
|
||||||
if (bitmap!=NULL)
|
if (bitmap!=NULL)
|
||||||
|
|||||||
@ -48,9 +48,3 @@ extern char Gui_loading_error_message[512];
|
|||||||
/// If an error is encountered, it frees what needs it, prints an error message
|
/// If an error is encountered, it frees what needs it, prints an error message
|
||||||
/// in ::Gui_loading_error_message, and returns NULL.
|
/// in ::Gui_loading_error_message, and returns NULL.
|
||||||
byte * Load_font(const char * font_name);
|
byte * Load_font(const char * font_name);
|
||||||
|
|
||||||
///
|
|
||||||
/// Based on which toolbars are visible, updates their offsets and
|
|
||||||
/// computes ::Menu_height and ::Menu_Y
|
|
||||||
void Compute_menu_offsets(void);
|
|
||||||
|
|
||||||
|
|||||||
@ -817,6 +817,7 @@ int Init_program(int argc,char * argv[])
|
|||||||
// Some files were loaded from last crash-exit.
|
// Some files were loaded from last crash-exit.
|
||||||
// Do not load files from command-line, nor show splash screen.
|
// Do not load files from command-line, nor show splash screen.
|
||||||
Compute_optimal_menu_colors(Main_palette);
|
Compute_optimal_menu_colors(Main_palette);
|
||||||
|
Check_menu_mode();
|
||||||
Display_all_screen();
|
Display_all_screen();
|
||||||
Display_menu();
|
Display_menu();
|
||||||
Display_cursor();
|
Display_cursor();
|
||||||
@ -868,6 +869,7 @@ int Init_program(int argc,char * argv[])
|
|||||||
|
|
||||||
Hide_cursor();
|
Hide_cursor();
|
||||||
Compute_optimal_menu_colors(Main_palette);
|
Compute_optimal_menu_colors(Main_palette);
|
||||||
|
Check_menu_mode();
|
||||||
Display_all_screen();
|
Display_all_screen();
|
||||||
Display_menu();
|
Display_menu();
|
||||||
Display_cursor();
|
Display_cursor();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user