The 'Clear' function now clears with Transparent color instead of hard-coded 0. Outside edges of images are also drawn with this color. Reduced max layers to 16, for consistency with UI. Added help screens for Layer menu and Brush factory.

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1349 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2010-02-14 04:50:23 +00:00
parent d5353b378d
commit 4219ca839d
12 changed files with 75 additions and 31 deletions

View File

@ -14,7 +14,7 @@ $(OBJDIR)/engine.o: engine.c const.h struct.h global.h graph.h misc.h special.h
input.h engine.h pages.h layers.h
$(OBJDIR)/factory.o: factory.c brush.h struct.h const.h buttons.h engine.h errors.h \
filesel.h loadsave.h global.h graph.h io.h misc.h pages.h readline.h \
sdlscreen.h windows.h palette.h
sdlscreen.h windows.h palette.h input.h help.h
$(OBJDIR)/fileformats.o: fileformats.c errors.h global.h struct.h const.h \
loadsave.h misc.h io.h windows.h pages.h
$(OBJDIR)/filesel.o: filesel.c const.h struct.h global.h misc.h errors.h io.h \

View File

@ -646,9 +646,9 @@ void Button_Clear(void)
Hide_cursor();
Backup();
if (Stencil_mode && Config.Clear_with_stencil)
Hide_current_image_with_stencil(0,Stencil);
Clear_current_image_with_stencil(Main_backups->Pages->Transparent_color,Stencil);
else
Hide_current_image(0);
Clear_current_image(Main_backups->Pages->Transparent_color);
Redraw_layered_image();
Display_all_screen();
End_of_modification();
@ -661,9 +661,9 @@ void Button_Clear_with_backcolor(void)
Hide_cursor();
Backup();
if (Stencil_mode && Config.Clear_with_stencil)
Hide_current_image_with_stencil(Back_color,Stencil);
Clear_current_image_with_stencil(Back_color,Stencil);
else
Hide_current_image(Back_color);
Clear_current_image(Back_color);
Redraw_layered_image();
Display_all_screen();
End_of_modification();

View File

@ -71,6 +71,7 @@
/// Character to display in menus for an ellipsis.
#define ELLIPSIS_CHARACTER '…'
#define NB_LAYERS 1 ///< Initial number of layers for a new image
#define MAX_NB_LAYERS 16 ///< Maximum number of layers that can be used in grafx2. Note that 32 is upper limit because of a few bit fields.
#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_COLUMNS 4 ///< Number of columns in the Brush container

View File

@ -38,6 +38,8 @@
#include "sdlscreen.h"
#include "windows.h"
#include "palette.h"
#include "input.h" // Is_shortcut()
#include "help.h" // Window_help()
#ifdef __ENABLE_LUA__
@ -768,8 +770,11 @@ void Button_Brush_Factory(void)
Update_window_area(0, 0, Window_width, Window_height);
Display_cursor();
do {
do
{
clicked_button = Window_clicked_button();
if (Is_shortcut(Key,0x100+BUTTON_HELP))
Window_help(BUTTON_BRUSH_EFFECTS, "BRUSH FACTORY");
switch (clicked_button)
{

View File

@ -592,7 +592,6 @@ try_again:
Position_screen_according_to_zoom();
Compute_limits();
Compute_paintbrush_coordinates();
Display_all_screen();
Resize_width=0;
Resize_height=0;

View File

@ -1284,6 +1284,30 @@ static const T_Help_table helptable_brush_fx[] =
HELP_TEXT ("")
HELP_LINK ("- Save : (Key:%s)",SPECIAL_SAVE_BRUSH)
HELP_TEXT ("Save a brush to disk.")
HELP_TEXT ("")
HELP_TEXT ("")
HELP_TEXT ("")
HELP_TITLE("BRUSH FACTORY")
HELP_TEXT ("")
HELP_TEXT ("This menu allows you to run scripts. Scripts")
HELP_TEXT ("are written in the Lua language, and allow")
HELP_TEXT ("you to modify the brush (hence the name")
HELP_TEXT ("'Brush factory'), or even modify the image")
HELP_TEXT ("or palette, like a Photoshop filter. See")
HELP_TEXT ("the online documentation for more help")
HELP_TEXT ("on scripting.")
HELP_TEXT ("")
HELP_TEXT ("You can select a script with the selector,")
HELP_TEXT ("the bottom panel shows a short description")
HELP_TEXT ("of what it does, and you can click Run to")
HELP_TEXT ("launch it.")
HELP_TEXT ("")
HELP_TEXT ("The scripts are located in the application's")
HELP_TEXT ("data folder, under the '/scripts'")
HELP_TEXT ("subdirectory. The list is refreshed each")
HELP_TEXT ("time you open the window. Scripts are loaded")
HELP_TEXT ("from disk when you run them.")
HELP_TEXT ("")
};
static const T_Help_table helptable_effects[] =
{
@ -2187,7 +2211,8 @@ static const T_Help_table helptable_clear[] =
HELP_BOLD ("LEFT CLICK")
HELP_LINK ("(Key:%s)",0x100+BUTTON_CLEAR)
HELP_TEXT ("")
HELP_TEXT ("Clears the picture with the color number 0.")
HELP_TEXT ("Clears the picture with the color number 0,")
HELP_TEXT ("or the transparent color of the picture.")
HELP_TEXT ("")
HELP_BOLD ("RIGHT CLICK")
HELP_LINK ("(Key:%s)",0x200+BUTTON_CLEAR)
@ -2500,7 +2525,22 @@ static const T_Help_table helptable_layermenu[] =
HELP_TEXT ("")
HELP_LINK ("(Key:%s)",0x100+BUTTON_LAYER_MENU)
HELP_TEXT ("")
HELP_TEXT ("* Not implemented yet! *")
HELP_TEXT ("In this menu you can set the following")
HELP_TEXT ("options:")
HELP_TEXT ("")
HELP_TEXT ("* Transparent color : This determines which")
HELP_TEXT ("color index is considered transparent when")
HELP_TEXT ("using layers. Click the button and then")
HELP_TEXT ("click on the image to pick the right color,")
HELP_TEXT ("or use ESC to cancel.")
HELP_TEXT ("")
HELP_TEXT ("* Transparent background : When this option")
HELP_TEXT ("is checked, all pixels of the transparent")
HELP_TEXT ("color on layer 1 (background layer) will")
HELP_TEXT ("be tagged as transparent in the final image.")
HELP_TEXT ("Check this option if you want to make a")
HELP_TEXT ("transparent GIF or PNG. These are the only")
HELP_TEXT ("file formats that support this option.")
};
static const T_Help_table helptable_layertrans[] =

View File

@ -903,9 +903,9 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = {
0},
{104,
"Clear page",
"Clears the picture with the first",
"color of the palette (usually black)",
"",
"Clears the picture with color 0,",
"or the transparent color if it's",
"a layered image.",
true,
SDLK_BACKSPACE, // BackSpace
0},
@ -1471,8 +1471,8 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = {
0},
{180,
"Layers menu",
"Opens the window with layer options.",
"",
"Opens a window with options related",
"to layers and image transparency.",
"",
true,
SDLK_HOME|MOD_ALT, // Alt + Home

View File

@ -97,7 +97,7 @@ void Button_Layer_add(void)
{
Hide_cursor();
if (Main_backups->Pages->Nb_layers < 32)
if (Main_backups->Pages->Nb_layers < MAX_NB_LAYERS)
{
// Backup with unchanged layers
Backup_layers(0);
@ -212,8 +212,8 @@ void Button_Layer_menu(void)
{
clicked_button=Window_clicked_button();
//if (Is_shortcut(Key,0x100+BUTTON_HELP))
// Window_help(BUTTON_LAYERS, NULL);
if (Is_shortcut(Key,0x100+BUTTON_HELP))
Window_help(BUTTON_LAYER_MENU, NULL);
switch(clicked_button)
{
case 1: // color

4
misc.c
View File

@ -173,7 +173,7 @@ void Wait_end_of_click(void)
while(Mouse_K) if(!Get_input()) SDL_Delay(20);
}
void Hide_current_image_with_stencil(byte color, byte * stencil)
void Clear_current_image_with_stencil(byte color, byte * stencil)
//Effacer l'image courante avec une certaine couleur en mode Stencil
{
int nb_pixels=0; //ECX
@ -192,7 +192,7 @@ void Hide_current_image_with_stencil(byte color, byte * stencil)
}
}
void Hide_current_image(byte color)
void Clear_current_image(byte color)
// Effacer l'image courante avec une certaine couleur
{
memset(

4
misc.h
View File

@ -40,8 +40,8 @@ void Set_color(byte color, byte red, byte green, byte blue);
void Set_palette(T_Palette palette);
void Palette_256_to_64(T_Palette palette);
void Palette_64_to_256(T_Palette palette);
void Hide_current_image(byte color);
void Hide_current_image_with_stencil(byte color, byte * stencil);
void Clear_current_image(byte color);
void Clear_current_image_with_stencil(byte color, byte * stencil);
void Slider_timer(byte speed);
dword Round_div(dword numerator,dword divisor);
word Count_used_colors(dword * usage);

View File

@ -807,7 +807,7 @@ int Backup_with_new_dimensions(int upload,byte layers,int width,int height)
{
for (i=0; i<layers;i++)
{
memset(Main_backups->Pages->Image[i], 0, width*height);
memset(Main_backups->Pages->Image[i], Main_backups->Pages->Transparent_color, width*height);
}
Update_buffers(width, height);
@ -859,7 +859,7 @@ int Backup_and_resize_the_spare(int width,int height)
for (i=0; i<nb_layers;i++)
{
memset(Spare_backups->Pages->Image[i], 0, width*height);
memset(Spare_backups->Pages->Image[i], Spare_backups->Pages->Transparent_color, width*height);
}
// Update_buffers(width, height); // Not for spare
@ -1106,8 +1106,7 @@ byte Add_layer(T_List_of_pages *list, byte layer)
source_page = list->Pages;
// Hard limit of 32 at the moment, because layer bitmasks are 32bit.
if (list->Pages->Nb_layers == 32)
if (list->Pages->Nb_layers == MAX_NB_LAYERS)
return 1;
// Keep the position reasonable

View File

@ -478,7 +478,7 @@ void Display_layerbar(void)
if (horiz_space/button_width < button_number)
button_number = horiz_space/button_width;
// Only 16 icons at the moment
if (button_number > 16)
if (button_number > 16) // can be different from MAX_NB_LAYERS
button_number = 16;
// Enlarge the buttons themselves if there's enough room
@ -2582,15 +2582,15 @@ void Display_all_screen(void)
if (Main_magnifier_mode)
{
if (Main_image_width<Main_separator_position && Main_image_width < Screen_width)
Block(Main_image_width,0,(Main_separator_position-Main_image_width),Menu_Y,0);
Block(Main_image_width,0,(Main_separator_position-Main_image_width),Menu_Y,Main_backups->Pages->Transparent_color);
}
else
{
if (Main_image_width<Screen_width)
Block(Main_image_width,0,(Screen_width-Main_image_width),Menu_Y,0);
Block(Main_image_width,0,(Screen_width-Main_image_width),Menu_Y,Main_backups->Pages->Transparent_color);
}
if (Main_image_height<Menu_Y)
Block(0,Main_image_height,width,(Menu_Y-height),0);
Block(0,Main_image_height,width,(Menu_Y-height),Main_backups->Pages->Transparent_color);
// ---/\/\/\ Partie zoomée: /\/\/\---
if (Main_magnifier_mode)
@ -2616,9 +2616,9 @@ void Display_all_screen(void)
if (Main_image_width<Main_magnifier_width)
Block(Main_X_zoom+(Main_image_width*Main_magnifier_factor),0,
(Main_magnifier_width-Main_image_width)*Main_magnifier_factor,
Menu_Y,0);
Menu_Y,Main_backups->Pages->Transparent_color);
if (Main_image_height<Main_magnifier_height)
Block(Main_X_zoom,height,width*Main_magnifier_factor,(Menu_Y-height),0);
Block(Main_X_zoom,height,width*Main_magnifier_factor,(Menu_Y-height),Main_backups->Pages->Transparent_color);
}
// ---/\/\/\ Affichage des limites /\/\/\---