Added crop tool.

This commit is contained in:
David Capello 2007-10-04 02:44:09 +00:00
parent c1879f7c07
commit a1b9a6844b
10 changed files with 134 additions and 157 deletions

View File

@ -1,3 +1,8 @@
2007-10-03 David A. Capello <dacap@users.sourceforge.net>
* src/commands/cmd_crop.c: Added with crop_sprite/layer/frame &
autocrop sprite.
2007-09-30 David A. Capello <dacap@users.sourceforge.net>
* src/commands/cmd_sprite_properties.c (command_execute_sprite_properties): Done.

View File

@ -134,7 +134,7 @@
<item command="change_image_type" name="Image &Type" />
<separator />
<item command="crop_sprite" name="Cr&op" />
<item command="auto_crop_sprite" name="&Auto Crop" />
<item command="autocrop_sprite" name="&Auto Crop" />
</menu>
<menu name="&Layer" id="layer_popup">
<item command="layer_properties" name="&Properties" />

View File

@ -59,6 +59,7 @@
<key command="spray_tool" shortcut="S" />
<key command="floodfill_tool" shortcut="F" />
<key command="line_tool" shortcut="L" />
<key command="bezier_tool" shortcut="V" />
<key command="rectangle_tool" shortcut="R" />
<key command="ellipse_tool" shortcut="E" />
<key command="film_editor" shortcut="Tab" />
@ -85,10 +86,6 @@
<item command="screen_shot" name="Screen Shot" />
<item command="record_screen" name="Record Screen" />
</menu>
<menu name="Sessions">
<item command="load_session" name="Load Session" />
<item command="save_session" name="Save Session" />
</menu>
<separator />
<item command="about" name="About" />
<item command="exit" name="E&xit" />
@ -137,7 +134,7 @@
<item command="change_image_type" name="Image &Type" />
<separator />
<item command="crop_sprite" name="Cr&op" />
<item command="auto_crop_sprite" name="&Auto Crop" />
<item command="autocrop_sprite" name="&Autocrop" />
</menu>
<menu name="&Layer" id="layer_popup">
<item command="layer_properties" name="&Properties" />
@ -170,9 +167,8 @@
<separator />
<item command="mask_by_color" name="&Color Range" />
<separator />
<item command="mask_repository" name="Repositor&y" />
<item command="load_mask" name="&Load" />
<item command="save_mask" name="&Save" />
<item command="load_mask" name="&Load from MSK file" />
<item command="save_mask" name="&Save to MSK file" />
</menu>
<menu name="&Tools">
<menu name="&Drawing Tool">
@ -186,10 +182,10 @@
<item command="floodfill_tool" name="&Floodfill" />
<separator />
<item command="line_tool" name="&Line" />
<!-- <item command="bezier_tool" name="&Bezier" /> -->
<item command="rectangle_tool" name="&Rectangle" />
<item command="ellipse_tool" name="&Ellipse" />
<!-- <item name=# "&Oval" command=# "oval_tool" /> -->
<!-- <item name=# "&Bezier" command=# "bezier_tool" /> -->
<!-- <item command="oval_tool" name="&Oval" /> -->
</menu>
<item command="film_editor" name="&Film Editor" />
<item command="palette_editor" name="&Palette Editor" />
@ -200,13 +196,14 @@
<separator />
<item command="despeckle" name="&Despeckle (median filter)" />
</menu>
<item command="draw_text" name="Draw &Text" />
<item command="play_flic" name="Pla&y FLI/FLC File" />
<item command="mapgen" name="&MapGen" />
<item command="run_script" name="Run &Script" />
<!-- <item command="draw_text" name="Draw &Text" /> -->
<!-- <item command="play_flic" name="Pla&y FLI/FLC File" /> -->
<!-- <item command="mapgen" name="&MapGen" /> -->
<menu name="Scripting">
<item command="run_script" name="Run &Script" />
</menu>
<separator />
<item command="tips" name="T&ips" />
<item command="customize" name="&Customize" />
<item command="options" name="&Options" />
</menu>
<item id="sprite_list" name="L&ist" />

View File

@ -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 \

View File

@ -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)
{
}

106
src/commands/cmd_crop.c Normal file
View File

@ -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;
}

View File

@ -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)
{
}

View File

@ -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)
{
}

View File

@ -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)
{
}

View File

@ -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),