From a1b9a6844ba19993959ed813fb34413c5af7f982 Mon Sep 17 00:00:00 2001 From: David Capello Date: Thu, 4 Oct 2007 02:44:09 +0000 Subject: [PATCH] Added crop tool. --- ChangeLog | 5 ++ data/defgui-en.xml | 2 +- data/defgui-es.xml | 27 ++++--- makefile.lst | 5 +- src/commands/cmd_auto_crop_sprite.c | 33 --------- src/commands/cmd_crop.c | 106 ++++++++++++++++++++++++++++ src/commands/cmd_crop_frame.c | 33 --------- src/commands/cmd_crop_layer.c | 33 --------- src/commands/cmd_crop_sprite.c | 33 --------- src/commands/commands.c | 14 ++-- 10 files changed, 134 insertions(+), 157 deletions(-) delete mode 100644 src/commands/cmd_auto_crop_sprite.c create mode 100644 src/commands/cmd_crop.c delete mode 100644 src/commands/cmd_crop_frame.c delete mode 100644 src/commands/cmd_crop_layer.c delete mode 100644 src/commands/cmd_crop_sprite.c diff --git a/ChangeLog b/ChangeLog index 5df365367..152f21316 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-10-03 David A. Capello + + * src/commands/cmd_crop.c: Added with crop_sprite/layer/frame & + autocrop sprite. + 2007-09-30 David A. Capello * src/commands/cmd_sprite_properties.c (command_execute_sprite_properties): Done. diff --git a/data/defgui-en.xml b/data/defgui-en.xml index db9ed433e..2718f589d 100644 --- a/data/defgui-en.xml +++ b/data/defgui-en.xml @@ -134,7 +134,7 @@ - + diff --git a/data/defgui-es.xml b/data/defgui-es.xml index 43c36135e..02dfe5cb5 100644 --- a/data/defgui-es.xml +++ b/data/defgui-es.xml @@ -59,6 +59,7 @@ + @@ -85,10 +86,6 @@ - - - - @@ -137,7 +134,7 @@ - + @@ -170,9 +167,8 @@ - - - + + @@ -186,10 +182,10 @@ + - - + @@ -200,13 +196,14 @@ - - - - + + + + + + - diff --git a/makefile.lst b/makefile.lst index 524cb7589..7ff823751 100644 --- a/makefile.lst +++ b/makefile.lst @@ -8,7 +8,6 @@ ASE = ase$(EXE) ASE_SOURCES = \ src/commands/cmd_about.c \ src/commands/cmd_advanced_mode.c \ - src/commands/cmd_auto_crop_sprite.c \ src/commands/cmd_change_image_type.c \ src/commands/cmd_clear.c \ src/commands/cmd_close_file.c \ @@ -18,9 +17,7 @@ ASE_SOURCES = \ src/commands/cmd_convolution_matrix.c \ src/commands/cmd_copy.c \ src/commands/cmd_copy_frame.c \ - src/commands/cmd_crop_frame.c \ - src/commands/cmd_crop_layer.c \ - src/commands/cmd_crop_sprite.c \ + src/commands/cmd_crop.c \ src/commands/cmd_cut.c \ src/commands/cmd_deselect_mask.c \ src/commands/cmd_despeckle.c \ diff --git a/src/commands/cmd_auto_crop_sprite.c b/src/commands/cmd_auto_crop_sprite.c deleted file mode 100644 index 07b3d8e1d..000000000 --- a/src/commands/cmd_auto_crop_sprite.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ase -- allegro-sprite-editor: the ultimate sprites factory - * Copyright (C) 2007 David A. Capello - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config.h" - -#ifndef USE_PRECOMPILED_HEADER - -#include "jinete.h" - -#include "core/app.h" -#include "modules/sprites.h" -#include "raster/sprite.h" - -#endif - -void command_execute_auto_crop_sprite(const char *argument) -{ -} diff --git a/src/commands/cmd_crop.c b/src/commands/cmd_crop.c new file mode 100644 index 000000000..37aa2c27d --- /dev/null +++ b/src/commands/cmd_crop.c @@ -0,0 +1,106 @@ +/* ase -- allegro-sprite-editor: the ultimate sprites factory + * Copyright (C) 2007 David A. Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "config.h" + +#ifndef USE_PRECOMPILED_HEADER + +#include "modules/sprites.h" +#include "raster/image.h" +#include "raster/mask.h" +#include "raster/layer.h" +#include "raster/sprite.h" +#include "util/autocrop.h" +#include "util/crop.h" +#include "util/misc.h" + +#endif + +static bool command_enabled_crop(const char *argument); + +/* ======================== */ +/* crop_sprite */ +/* ======================== */ + +bool command_enabled_crop_sprite(const char *argument) +{ + return command_enabled_crop(argument); +} + +void command_execute_crop_sprite(const char *argument) +{ + crop_sprite(); +} + +/* ======================== */ +/* auto_crop_sprite */ +/* ======================== */ + +bool command_enabled_autocrop_sprite(const char *argument) +{ + return current_sprite != NULL; +} + +void command_execute_autocrop_sprite(const char *argument) +{ + autocrop_sprite(); +} + +/* ======================== */ +/* crop_layer */ +/* ======================== */ + +bool command_enabled_crop_layer(const char *argument) +{ + return command_enabled_crop(argument); +} + +void command_execute_crop_layer(const char *argument) +{ + crop_layer(); +} + +/* ======================== */ +/* crop_frame */ +/* ======================== */ + +bool command_enabled_crop_frame(const char *argument) +{ + return command_enabled_crop(argument); +} + +void command_execute_crop_frame(const char *argument) +{ + crop_frame(); +} + +/**********************************************************************/ +/* local */ + +static bool command_enabled_crop(const char *argument) +{ + if ((!current_sprite) || + (!current_sprite->layer) || + (!current_sprite->layer->readable) || + (!current_sprite->layer->writeable) || + (!current_sprite->mask) || + (!current_sprite->mask->bitmap)) + return FALSE; + else + return GetImage() ? TRUE: FALSE; +} diff --git a/src/commands/cmd_crop_frame.c b/src/commands/cmd_crop_frame.c deleted file mode 100644 index 44ea15b8e..000000000 --- a/src/commands/cmd_crop_frame.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ase -- allegro-sprite-editor: the ultimate sprites factory - * Copyright (C) 2007 David A. Capello - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config.h" - -#ifndef USE_PRECOMPILED_HEADER - -#include "jinete.h" - -#include "core/app.h" -#include "modules/sprites.h" -#include "raster/sprite.h" - -#endif - -void command_execute_crop_frame(const char *argument) -{ -} diff --git a/src/commands/cmd_crop_layer.c b/src/commands/cmd_crop_layer.c deleted file mode 100644 index 55db47422..000000000 --- a/src/commands/cmd_crop_layer.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ase -- allegro-sprite-editor: the ultimate sprites factory - * Copyright (C) 2007 David A. Capello - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config.h" - -#ifndef USE_PRECOMPILED_HEADER - -#include "jinete.h" - -#include "core/app.h" -#include "modules/sprites.h" -#include "raster/sprite.h" - -#endif - -void command_execute_crop_layer(const char *argument) -{ -} diff --git a/src/commands/cmd_crop_sprite.c b/src/commands/cmd_crop_sprite.c deleted file mode 100644 index 4d55929bb..000000000 --- a/src/commands/cmd_crop_sprite.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ase -- allegro-sprite-editor: the ultimate sprites factory - * Copyright (C) 2007 David A. Capello - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config.h" - -#ifndef USE_PRECOMPILED_HEADER - -#include "jinete.h" - -#include "core/app.h" -#include "modules/sprites.h" -#include "raster/sprite.h" - -#endif - -void command_execute_crop_sprite(const char *argument) -{ -} diff --git a/src/commands/commands.c b/src/commands/commands.c index 588922c87..cfe602f3a 100644 --- a/src/commands/commands.c +++ b/src/commands/commands.c @@ -85,8 +85,10 @@ bool command_enabled_sprite_properties(const char *argument); void command_execute_sprite_properties(const char *argument); void command_execute_duplicate_sprite(const char *argument); void command_execute_change_image_type(const char *argument); +bool command_enabled_crop_sprite(const char *argument); void command_execute_crop_sprite(const char *argument); -void command_execute_auto_crop_sprite(const char *argument); +bool command_enabled_autocrop_sprite(const char *argument); +void command_execute_autocrop_sprite(const char *argument); /* layer */ void command_execute_layer_properties(const char *argument); void command_execute_new_layer(const char *argument); @@ -95,6 +97,7 @@ void command_execute_remove_layer(const char *argument); void command_execute_duplicate_layer(const char *argument); void command_execute_merge_down_layer(const char *argument); void command_execute_flatten_layers(const char *argument); +bool command_enabled_crop_layer(const char *argument); void command_execute_crop_layer(const char *argument); /* frame */ void command_execute_frame_properties(const char *argument); @@ -103,6 +106,7 @@ void command_execute_new_frame(const char *argument); void command_execute_move_frame(const char *argument); void command_execute_copy_frame(const char *argument); void command_execute_link_frame(const char *argument); +bool command_enabled_crop_frame(const char *argument); void command_execute_crop_frame(const char *argument); /* select */ bool command_enabled_mask_all(const char *argument); @@ -198,8 +202,8 @@ static Command commands[] = { CMD_EXE_ENA(sprite_properties), { CMD_DUPLICATE_SPRITE, NULL, NULL, NULL, NULL }, { CMD_CHANGE_IMAGE_TYPE, NULL, NULL, NULL, NULL }, - { CMD_CROP_SPRITE, NULL, NULL, NULL, NULL }, - { CMD_AUTO_CROP_SPRITE, NULL, NULL, NULL, NULL }, + CMD_EXE_ENA(crop_sprite), + CMD_EXE_ENA(autocrop_sprite), { CMD_LAYER_PROPERTIES, NULL, NULL, NULL, NULL }, { CMD_NEW_LAYER, NULL, NULL, NULL, NULL }, { CMD_NEW_LAYER_SET, NULL, NULL, NULL, NULL }, @@ -207,14 +211,14 @@ static Command commands[] = { { CMD_DUPLICATE_LAYER, NULL, NULL, NULL, NULL }, { CMD_MERGE_DOWN_LAYER, NULL, NULL, NULL, NULL }, { CMD_FLATTEN_LAYERS, NULL, NULL, NULL, NULL }, - { CMD_CROP_LAYER, NULL, NULL, NULL, NULL }, + CMD_EXE_ENA(crop_layer), { CMD_FRAME_PROPERTIES, NULL, NULL, NULL, NULL }, { CMD_REMOVE_FRAME, NULL, NULL, NULL, NULL }, { CMD_NEW_FRAME, NULL, NULL, NULL, NULL }, { CMD_MOVE_FRAME, NULL, NULL, NULL, NULL }, { CMD_COPY_FRAME, NULL, NULL, NULL, NULL }, { CMD_LINK_FRAME, NULL, NULL, NULL, NULL }, - { CMD_CROP_FRAME, NULL, NULL, NULL, NULL }, + CMD_EXE_ENA(crop_frame), CMD_EXE_ENA(mask_all), CMD_EXE_ENA(deselect_mask), CMD_EXE_ENA(reselect_mask),