Renamed "frame" to "cel"

This commit is contained in:
David Capello 2007-11-16 20:49:40 +00:00
parent 40e3a27ce7
commit 429d6a83ef
69 changed files with 1285 additions and 1495 deletions

View File

@ -1,3 +1,10 @@
2007-11-16 David A. Capello <dacap@users.sourceforge.net>
* src/raster/cel.c: Renamed "frame" to "cel" to avoid
confusion (Manuel Quiñones advice)
* src/modules/render.[ch]: Moved to util/.
2007-11-14 David A. Capello <dacap@users.sourceforge.net>
* INSTALL.txt: Clarified "COMPILATION" section (thanks to Manuel

View File

@ -1,7 +1,7 @@
ASE - Allegro Sprite Editor
Copyright (C) 2001-2005, 2007 por David A. Capello
------------------------------------------------------------------------
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 por David A. Capello
---------------------------------------------------------------------
Mire el fichero "AUTHORS.txt" para la lista completa de colaboradores
@ -125,33 +125,20 @@ ACTUALIZACIONES
http://sourceforge.net/project/showfiles.php?group_id=20848
También, si desea obtener la última versión en desarrollo de ASE desde el
repositorio CVS, la cual por sierto es la más propensa a tener errores pero
repositorio SVN, la cual por sierto es la más propensa a tener errores pero
es la que más actualizada está con respecto a las herramientas, la puede
explorar archivo por archivo en esta dirección:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/ase
http://ase.svn.sourceforge.net/viewvc/ase/
O la puede bajar completamente a su disco con un programa que controle CVS,
O la puede bajar completamente a su disco con un programa que controle SVN,
de la siguiente forma:
1) Debemos ingresar al repositorio de forma anónima (cuando le pregunte
por la contraseña, solamente presione <enter>):
svn checkout svn co https://ase.svn.sourceforge.net/svnroot/ase/trunk ase
cvs -d :pserver:anonymous@cvs.ase.sourceforge.net:/cvsroot/ase login
2) Realizamos el primer checkout, lo que significa que sacaremos una
copia "fresca" de ASE:
cvs -z3 -d :pserver:anonymous@cvs.ase.sourceforge.net:/cvsroot/ase checkout gnuase
3) Una vez esto, cada vez que quiera actualizar la copia local con la
del repositorio, deberá ejecutar en el directorio gnuase/:
cvs update -Pd
AVISO: Cuando obtenga la versión CVS, no borre los directorios CVS
AVISO: Cuando obtenga la versión SVN, no borre los directorios .svn
ni el contenido dentro de ellos, ya que es para uso interno del
programa cvs.
programa svn.
===================================
@ -177,4 +164,4 @@ INFORMACI
----------------------------------------------------------------------------
Copyright (C) 2001-2005 por David A. Capello
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 por David A. Capello

View File

@ -1,7 +1,7 @@
ASE - Allegro Sprite Editor
Copyright (C) 2001-2005, 2007 by David A. Capello
--------------------------------------------------------------
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 by David A. Capello
--------------------------------------------------------------------
See the "AUTHORS.txt" file for a complete list of contributors
@ -126,25 +126,12 @@ UPDATES
http://ase.svn.sourceforge.net/viewvc/ase/
Or you can download it completelly to your disk with a program which
control CVS, as follow-up:
control SVN, as follow-up:
1) We must input to the repository in anonymous form (when you be
asked for the password, just press <enter>):
svn checkout svn co https://ase.svn.sourceforge.net/svnroot/ase/trunk ase
cvs -d :pserver:anonymous@cvs.ase.sourceforge.net:/cvsroot/ase login
2) We make the first checkout, which means that we fetch a "fresh"
copy of ASE:
cvs -z3 -d :pserver:anonymous@cvs.ase.sourceforge.net:/cvsroot/ase checkout gnuase
3) Then, whenever you want update your copy with the repository
one, you will must execute in the gnuase/ directory:
cvs update -Pd
WARNING: When you obtain the CVS version, don't remove the CVS
directories, they are for exclusive use of the cvs program.
WARNING: When you obtain the SVN version, don't remove the .svn
directories, they are for exclusive use of the svn program.
===================================
@ -170,4 +157,4 @@ CONTACT INFO
----------------------------------------------------------------------------
Copyright (C) 2001-2005 by David A. Capello
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 by David A. Capello

View File

@ -45,13 +45,17 @@ High priority work
Wish-list
---------
- my wish-list:
- dacap wish-list:
+ keyboard shortcuts for snap-to-grid and view-grid
+ different snap-to-grid for paste operation
+ better dialogs: widder buttons, more borders.
+ better film editor
+ "middle mouse button" for the film editor.
+ don't use LINKs when load a sequence of bitmaps.
- manuq wish-list:
+ sprite/layer/frame/cel (distintion between "frame" and "cel")
+ layer-with-constant-cel
+ onion skin for all layers in a frame
- add menu customization through UI (Tools/Customize).
- Mateusz Czaplinski ideas:
+ when move selections, will be good the possibility to see relative

2
all.h
View File

@ -80,7 +80,6 @@
#include "modules/gui.h"
#include "modules/palette.h"
#include "modules/recent.h"
#include "modules/render.h"
#include "modules/rootmenu.h"
#include "modules/sprites.h"
#include "modules/tools.h"
@ -120,6 +119,7 @@
#include "util/pic_file.h"
#include "util/quantize.h"
#include "util/recscr.h"
#include "util/render.h"
#include "util/scrshot.h"
#include "util/setgfx.h"
#include "util/thmbnail.h"

View File

@ -25,7 +25,7 @@
/* general information */
#define PACKAGE "ase"
#define VERSION "0.6"
#define WEBSITE "http://ase.sourceforge.net/"
#define WEBSITE "http://www.allegrospriteeditor.com.ar/"
#define BUGREPORT "ase-help@lists.sourceforge.net"
#define COPYRIGHT "Copyright (C) 2001-2005, 2007 David A. Capello"

View File

@ -40,9 +40,9 @@
<!-- layer -->
<key command="layer_properties" shortcut="Shift+P" />
<key command="new_layer" shortcut="Shift+N" />
<!-- frame -->
<key command="frame_properties" shortcut="Shift+Ctrl+P" />
<key command="new_frame" shortcut="Ctrl+Shift+N" />
<!-- cel -->
<key command="cel_properties" shortcut="Shift+Ctrl+P" />
<key command="new_cel" shortcut="Ctrl+Shift+N" />
<!-- mask -->
<key command="mask_all" shortcut="Ctrl+A" />
<key command="deselect_mask" shortcut="Ctrl+D" />
@ -122,7 +122,7 @@
<item command="preview_tiled" name="&Tiled" />
</menu>
</menu>
<menu name="Spr&ite">
<menu name="&Sprite">
<item command="sprite_properties" name="&Properties" />
<separator />
<item command="duplicate_sprite" name="&Duplicate" />
@ -143,18 +143,18 @@
<item command="flatten_layers" name="&Flatten" />
<item command="crop_layer" name="Cr&op" />
</menu>
<menu name="F&rame" id="frame_popup">
<item command="frame_properties" name="&Properties" />
<item command="remove_frame" name="&Remove" />
<menu name="&Cel" id="cel_popup">
<item command="cel_properties" name="&Properties" />
<item command="remove_cel" name="&Remove" />
<separator />
<item command="new_frame" name="&New" />
<item command="move_frame" name="&Move" />
<item command="copy_frame" name="&Copy" />
<item command="link_frame" name="&Link" />
<item command="new_cel" name="&New" />
<item command="move_cel" name="&Move" />
<item command="copy_cel" name="&Copy" />
<item command="link_cel" name="&Link" />
<separator />
<item command="crop_frame" name="Cr&op" />
<item command="crop_cel" name="Cr&op" />
</menu>
<menu name="&Select">
<menu name="&Mask">
<item command="mask_all" name="&All" />
<item command="deselect_mask" name="&Deselect" />
<item command="reselect_mask" name="&Reselect" />

View File

@ -1,211 +0,0 @@
<!-- Copyright (C) 2007 by David A. Capello -->
<gui>
<keyboard>
<!-- file -->
<key command="new_file" shortcut="Ctrl+N" />
<key command="open_file" shortcut="Ctrl+O" />
<key command="open_file" shortcut="F3" />
<key command="save_file" shortcut="Ctrl+S" />
<key command="save_file" shortcut="F2" />
<key command="save_file_as" shortcut="Shift+Ctrl+S" />
<key command="save_file_as" shortcut="Shift+F2" />
<key command="close_file" shortcut="Ctrl+W" />
<key command="close_all_files" shortcut="Shift+Ctrl+W" />
<key command="screen_shot" shortcut="F12" />
<key command="exit" shortcut="Ctrl+Q" />
<key command="exit" shortcut="Esc" />
<!-- edit -->
<key command="undo" shortcut="Ctrl+Z" /> <key command="undo" shortcut="Ctrl+U" />
<key command="redo" shortcut="Ctrl+R" />
<key command="cut" shortcut="Ctrl+X" /> <key command="cut" shortcut="Shift+Del" />
<key command="copy" shortcut="Ctrl+C" /> <key command="copy" shortcut="Ctrl+Ins" />
<key command="paste" shortcut="Ctrl+V" /> <key command="paste" shortcut="Shift+Ins" />
<key command="clear" shortcut="Ctrl+B" /> <key command="clear" shortcut="Ctrl+Del" />
<key command="quick_move" shortcut="Shift+M" />
<key command="quick_copy" shortcut="Shift+C" />
<key command="flip_horizontal" shortcut="Shift+H" />
<key command="flip_vertical" shortcut="Shift+V" />
<key command="replace_color" shortcut="Shift+R" />
<key command="invert_color" shortcut="Ctrl+I" />
<!-- view -->
<key command="refresh" shortcut="F5" />
<key command="advanced_mode" shortcut="A" />
<key command="make_unique_editor" shortcut="Ctrl+1" />
<key command="split_editor_vertically" shortcut="Ctrl+2" />
<key command="split_editor_horizontally" shortcut="Ctrl+3" />
<key command="close_editor" shortcut="Ctrl+4" />
<key command="preview_fit_to_screen" shortcut="F6" />
<key command="preview_normal" shortcut="F7" />
<key command="preview_tiled" shortcut="F8" />
<!-- sprite -->
<key command="sprite_properties" shortcut="Ctrl+P" />
<!-- layer -->
<key command="layer_properties" shortcut="Shift+P" />
<key command="new_layer" shortcut="Shift+N" />
<!-- frame -->
<key command="frame_properties" shortcut="Shift+Ctrl+P" />
<key command="new_frame" shortcut="Ctrl+Shift+N" />
<!-- mask -->
<key command="mask_all" shortcut="Ctrl+A" />
<key command="deselect_mask" shortcut="Ctrl+D" />
<key command="reselect_mask" shortcut="Shift+Ctrl+D" />
<key command="invert_mask" shortcut="Shift+Ctrl+I" />
<!-- tools -->
<key command="configure_tools" shortcut="C" />
<key command="marker_tool" shortcut="M" />
<key command="dots_tool" shortcut="D" />
<key command="pencil_tool" shortcut="P" />
<key command="brush_tool" shortcut="B" />
<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" />
<key command="palette_editor" shortcut="F4" />
<key command="convolution_matrix" shortcut="F9" />
<key command="color_curve" shortcut="Ctrl+M" />
<key command="color_curve" shortcut="F10" />
<key command="run_script" shortcut="Ctrl+0" />
<key command="tips" shortcut="F1" />
<key command="options" shortcut="Shift+Ctrl+O" />
</keyboard>
<menu id="main_menu">
<menu name="&File">
<item command="new_file" name="&New" />
<item command="open_file" name="&Open" />
<item id="recent_list" name="Open &Recent" />
<separator />
<item command="save_file" name="&Save" />
<item command="save_file_as" name="Save &As..." />
<item command="close_file" name="&Close" />
<item command="close_all_files" name="Close All" />
<separator />
<menu name="Ca&pture">
<item command="screen_shot" name="Screen Shot" />
<item command="record_screen" name="Record Screen" />
</menu>
<separator />
<item command="about" name="About" />
<item command="exit" name="E&xit" />
</menu>
<menu name="&Edit">
<item command="undo" name="&Undo" />
<item command="redo" name="&Redo" />
<separator />
<item command="cut" name="Cu&t" />
<item command="copy" name="&Copy" />
<item command="paste" name="&Paste" />
<item command="clear" name="C&lear" />
<separator />
<item command="quick_move" name="Quick &Move" />
<item command="quick_copy" name="Quick C&opy" />
<separator />
<item command="flip_horizontal" name="Flip &Horizontal" />
<item command="flip_vertical" name="Flip &Vertical" />
<separator />
<item command="replace_color" name="R&eplace Color" />
<item command="invert_color" name="&Invert" />
</menu>
<menu name="&View">
<item command="refresh" name="&Refresh" />
<item command="configure_screen" name="Configure &Screen" />
<item command="advanced_mode" name="&Advanced Mode" />
<menu name="&Editor">
<item command="make_unique_editor" name="Make &Unique" />
<separator />
<item command="split_editor_vertically" name="Split &Vertically" />
<item command="split_editor_horizontally" name="Split &Horizontally" />
<separator />
<item command="close_editor" name="&Close" />
</menu>
<separator />
<menu name="&Preview">
<item command="preview_fit_to_screen" name="&Fit to screen" />
<item command="preview_normal" name="&Normal" />
<item command="preview_tiled" name="&Tiled" />
</menu>
</menu>
<menu name="Spr&ite">
<item command="sprite_properties" name="&Properties" />
<separator />
<item command="duplicate_sprite" name="&Duplicate" />
<item command="change_image_type" name="Image &Type" />
<separator />
<item command="crop_sprite" name="Cr&op" />
<item command="autocrop_sprite" name="&Autocrop" />
</menu>
<menu name="&Layer" id="layer_popup">
<item command="layer_properties" name="&Properties" />
<separator />
<item command="new_layer" name="&New" />
<item command="new_layer_set" name="New &Set" />
<item command="remove_layer" name="&Remove" />
<separator />
<item command="duplicate_layer" name="&Duplicate" />
<item command="merge_down_layer" name="&Merge Down" />
<item command="flatten_layers" name="&Flatten" />
<item command="crop_layer" name="Cr&op" />
</menu>
<menu name="F&rame" id="frame_popup">
<item command="frame_properties" name="&Properties" />
<item command="remove_frame" name="&Remove" />
<separator />
<item command="new_frame" name="&New" />
<item command="move_frame" name="&Move" />
<item command="copy_frame" name="&Copy" />
<item command="link_frame" name="&Link" />
<separator />
<item command="crop_frame" name="Cr&op" />
</menu>
<menu name="&Select">
<item command="mask_all" name="&All" />
<item command="deselect_mask" name="&Deselect" />
<item command="reselect_mask" name="&Reselect" />
<item command="invert_mask" name="&Inverse" />
<separator />
<item command="mask_by_color" name="&Color Range" />
<separator />
<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">
<item command="configure_tools" name="&Configure" />
<separator />
<item command="marker_tool" name="&Marker" />
<item command="dots_tool" name="&Dots" />
<item command="pencil_tool" name="&Pencil" />
<item command="brush_tool" name="&Brush" />
<item command="spray_tool" name="&Spray" />
<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 command="oval_tool" name="&Oval" /> -->
</menu>
<item command="film_editor" name="&Film Editor" />
<item command="palette_editor" name="&Palette Editor" />
<separator />
<menu name="F&X" id="fx_popup">
<item command="convolution_matrix" name="Convolution &Matrix" />
<item command="color_curve" name="&Color Curve" />
<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" /> -->
<menu name="Scripting">
<item command="run_script" name="Run &Script" />
</menu>
<separator />
<item command="tips" name="T&ips" />
<item command="options" name="&Options" />
</menu>
<item id="sprite_list" name="L&ist" />
</menu>
</gui>

View File

@ -31,14 +31,24 @@ STRING length=WORD (how many characters to read next)
2. Introduction
========================================
The format is the same as FLI/FLC files, with a different magic number
and a different set of chunks (but the new chunks doesn't collided
with the FLI/FLC ones). Also, the color depth can be 8, 16 or 32 for
Indexed, Grayscale and RGB respectively. The palette isn't included
for color depths more than 8, but when the sprite is 8 bpp, the
palette is in an old FLI color chunk (type=11). See fli.txt for
The format is much like FLI/FLC files, but with different magic number
and differents chunks. Also, the color depth can be 8, 16 or 32 for
Indexed, Grayscale and RGB respectively, and the images are more easy
to read (there aren't differences with old frames). The palette isn't
included for color depths more than 8, but when the sprite is 8 bpp,
the palette is in an old FLI color chunk (type=11). See fli.txt for
details.
To read the sprite, just do this:
* Read the ASE header (section 3)
* For each frame do (how many frames? the ASE header has that
information):
+ Read the frame header (section 4)
+ For each chunk in this frame (how many chunks? the frame header
has that information)
- Read the chunk (it should be layer information, a cel or a
palette)
========================================
3. Header
@ -55,8 +65,8 @@ WORD Height in pixels
WORD Color depth (bits per pixel)
DWORD Flags (must be 0)
WORD Speed (milliseconds between frame, like in FLC files)
!!! This field is deprecated, you should use the
frame duration field from each frame header.
DEPRECATED!!!: you should use the frame duration
field from each frame header
DWORD Set be 0
DWORD Set be 0
BYTE[100] For future (set to zero)
@ -71,8 +81,8 @@ header of 16 bytes:
DWORD Bytes in this frame
WORD Magic number (always 0xF1FA)
WORD Number of "chunks" in frame
WORD Frame duration (in milliseconds) [NEW FIELD!!!]
WORD Number of "chunks" in this frame
WORD Frame duration (in milliseconds) [NEW FIELD!!!]
BYTE[6] For future (set to zero)
Then each chunk format is:
@ -120,37 +130,37 @@ Layer Chunk (0x2004)
STRING Layer name
Frame Chunk (0x2005)
Cel Chunk (0x2005)
----------------------------------------
This chunk determine where to put a real ASE frame in the specified
layer.
This chunk determine where to put a cel in the specified
layer/frame.
WORD Layer index (see NOTE.2)
WORD X position
WORD Y position
BYTE Opacity level
WORD Frame type
WORD Cel type
BYTE[7] For future (set to zero)
+ For frame type = 0 (raw image):
+ For cel type = 0 (Raw Cel):
WORD Width in pixels
WORD Height in pixels
BYTE[] Pixel data (see NOTE.3)
+ For frame type = 1 (linked image):
+ For cel type = 1 (Linked Cel):
WORD Frame position to link with
+ For frame type = 2 (RLE compressed image, only for Indexed images):
+ For cel type = 2 (RLE compressed image, only for Indexed images):
WORD Width in pixels
WORD Height in pixels
XXXXX -todo-
Mask Chunk (0x2016)
Mask Chunk (0x2016) DEPRECATED!!!
----------------------------------------
WORD X position
@ -213,5 +223,5 @@ File Format Changes
How to read both formats (old and new one)? You should set all
frames durations to the "speed" field read from the main ASE
header. Then, if you found a frame with the frame-duration
field > 0, you should update the frame's duration with that
value.
field > 0, you should update the duration of the frame with
that value.

View File

@ -119,7 +119,6 @@ ASE_SOURCES = \
src/modules/gui.c \
src/modules/palette.c \
src/modules/recent.c \
src/modules/render.c \
src/modules/rootmenu.c \
src/modules/sprites.c \
src/modules/tools.c \
@ -128,8 +127,8 @@ ASE_SOURCES = \
src/raster/algofill.c \
src/raster/blend.c \
src/raster/brush.c \
src/raster/cel.c \
src/raster/dirty.c \
src/raster/frame.c \
src/raster/gfxobj.c \
src/raster/image.c \
src/raster/layer.c \
@ -145,11 +144,11 @@ ASE_SOURCES = \
src/script/script.c \
src/util/autocrop.c \
src/util/boundary.c \
src/util/celmove.c \
src/util/clipbrd.c \
src/util/col_file.c \
src/util/crop.c \
src/util/filetoks.c \
src/util/frmove.c \
src/util/hash.c \
src/util/mapgen.c \
src/util/misc.c \
@ -157,6 +156,7 @@ ASE_SOURCES = \
src/util/pic_file.c \
src/util/quantize.c \
src/util/recscr.c \
src/util/render.c \
src/util/setgfx.c \
src/util/thmbnail.c \
src/widgets/colbar.c \

View File

@ -28,11 +28,11 @@
#endif
bool command_enabled_copy_frame(const char *argument)
bool command_enabled_copy_cel(const char *argument)
{
return FALSE;
}
void command_execute_copy_frame(const char *argument)
void command_execute_copy_cel(const char *argument)
{
}

View File

@ -76,17 +76,17 @@ void command_execute_crop_layer(const char *argument)
}
/* ======================== */
/* crop_frame */
/* crop_cel */
/* ======================== */
bool command_enabled_crop_frame(const char *argument)
bool command_enabled_crop_cel(const char *argument)
{
return command_enabled_crop(argument);
}
void command_execute_crop_frame(const char *argument)
void command_execute_crop_cel(const char *argument)
{
crop_frame();
crop_cel();
}
/**********************************************************************/

View File

@ -25,24 +25,24 @@
#include "core/app.h"
#include "modules/gui.h"
#include "modules/sprites.h"
#include "raster/frame.h"
#include "raster/cel.h"
#include "raster/layer.h"
#include "raster/sprite.h"
#include "raster/undo.h"
#endif
bool command_enabled_frame_properties(const char *argument)
bool command_enabled_cel_properties(const char *argument)
{
return current_sprite != NULL;
}
void command_execute_frame_properties(const char *argument)
void command_execute_cel_properties(const char *argument)
{
JWidget window, entry_frpos, entry_xpos, entry_ypos, slider_opacity, button_ok;
Sprite *sprite;
Layer *layer;
Frame *frame;
Cel *cel;
char buf[1024];
/* get current sprite */
@ -55,9 +55,9 @@ void command_execute_frame_properties(const char *argument)
if (!layer)
return;
/* get current frame */
frame = layer_get_frame(layer, sprite->frpos);
if (!frame)
/* get current cel */
cel = layer_get_cel(layer, sprite->frpos);
if (!cel)
return;
window = load_widget("frmprop.jid", "frame_properties");
@ -70,53 +70,54 @@ void command_execute_frame_properties(const char *argument)
slider_opacity = jwidget_find_name(window, "opacity");
button_ok = jwidget_find_name(window, "ok");
sprintf(buf, "%d", frame->frpos); jwidget_set_text(entry_frpos, buf);
sprintf(buf, "%d", frame->x); jwidget_set_text(entry_xpos, buf);
sprintf(buf, "%d", frame->y); jwidget_set_text(entry_ypos, buf);
jslider_set_value(slider_opacity, frame->opacity);
sprintf(buf, "%d", cel->frpos); jwidget_set_text(entry_frpos, buf);
sprintf(buf, "%d", cel->x); jwidget_set_text(entry_xpos, buf);
sprintf(buf, "%d", cel->y); jwidget_set_text(entry_ypos, buf);
jslider_set_value(slider_opacity, cel->opacity);
while (TRUE) {
jwindow_open_fg(window);
if (jwindow_get_killer(window) == button_ok) {
int new_frpos, new_xpos, new_ypos;
Frame *existent_frame;
Cel *existent_cel;
new_frpos = strtol(jwidget_get_text(entry_frpos), NULL, 10);
new_frpos = MID(0, new_frpos, sprite->frames-1);
existent_frame = layer_get_frame(layer, new_frpos);
existent_cel = layer_get_cel(layer, new_frpos);
if (new_frpos != frame->frpos && existent_frame) {
jalert("Error<<You can't change frpos to %d"
"<<Already there is a frame in that pos.||&OK",
new_frpos);
if (new_frpos != cel->frpos && existent_cel) {
jalert(_("Error"
"<<You can't change frame position to %d."
"<<Already there is a cel in that position."
"||&OK"), new_frpos);
}
else {
/* WE MUST REMOVE THE FRAME BEFORE CALL frame_set_frpos() */
if (undo_is_enabled(sprite->undo)) {
undo_open(sprite->undo);
undo_remove_frame(sprite->undo, layer, frame);
undo_remove_cel(sprite->undo, layer, cel);
}
layer_remove_frame(layer, frame);
layer_remove_cel(layer, cel);
/* change frame properties */
new_xpos = strtol(jwidget_get_text(entry_xpos), NULL, 10);
new_ypos = strtol(jwidget_get_text(entry_ypos), NULL, 10);
frame_set_frpos(frame, new_frpos);
frame_set_position(frame,
MID(-9999, new_xpos, 9999),
MID(-9999, new_ypos, 9999));
frame_set_opacity(frame, jslider_get_value(slider_opacity));
cel_set_frpos(cel, new_frpos);
cel_set_position(cel,
MID(-9999, new_xpos, 9999),
MID(-9999, new_ypos, 9999));
cel_set_opacity(cel, jslider_get_value(slider_opacity));
/* add again the same frame */
if (undo_is_enabled(sprite->undo)) {
undo_add_frame(sprite->undo, layer, frame);
undo_add_cel(sprite->undo, layer, cel);
undo_close(sprite->undo);
}
layer_add_frame(layer, frame);
layer_add_cel(layer, cel);
/* set the sprite position, refresh and break the loop */
sprite_set_frpos(sprite, new_frpos);

View File

@ -28,11 +28,11 @@
#endif
bool command_enabled_link_frame(const char *argument)
bool command_enabled_link_cel(const char *argument)
{
return FALSE;
}
void command_execute_link_frame(const char *argument)
void command_execute_link_cel(const char *argument)
{
}

View File

@ -25,7 +25,7 @@
#include "core/app.h"
#include "modules/gui.h"
#include "modules/sprites.h"
#include "raster/frame.h"
#include "raster/cel.h"
#include "raster/image.h"
#include "raster/layer.h"
#include "raster/sprite.h"
@ -58,7 +58,7 @@ void command_execute_merge_down_layer(const char *argument)
{
Sprite *sprite = current_sprite;
Layer *src_layer, *dst_layer;
Frame *src_frame, *dst_frame;
Cel *src_cel, *dst_cel;
Image *src_image, *dst_image;
int frpos, index;
@ -70,17 +70,17 @@ void command_execute_merge_down_layer(const char *argument)
for (frpos=0; frpos<sprite->frames; ++frpos) {
/* get frames */
src_frame = layer_get_frame(src_layer, frpos);
dst_frame = layer_get_frame(dst_layer, frpos);
src_cel = layer_get_cel(src_layer, frpos);
dst_cel = layer_get_cel(dst_layer, frpos);
/* get images */
if (src_frame)
src_image = stock_get_image(src_layer->stock, src_frame->image);
if (src_cel)
src_image = stock_get_image(src_layer->stock, src_cel->image);
else
src_image = NULL;
if (dst_frame)
dst_image = stock_get_image(dst_layer->stock, dst_frame->image);
if (dst_cel)
dst_image = stock_get_image(dst_layer->stock, dst_cel->image);
else
dst_image = NULL;
@ -88,43 +88,43 @@ void command_execute_merge_down_layer(const char *argument)
if (src_image) {
/* no destination image */
if (!dst_image) {
/* copy this frame to the destination layer */
/* copy this cel to the destination layer */
dst_image = image_new_copy(src_image);
index = stock_add_image(dst_layer->stock, dst_image);
if (undo_is_enabled(sprite->undo)) {
undo_add_image(sprite->undo, dst_layer->stock, dst_image);
}
dst_frame = frame_new(frpos, index);
frame_set_position(dst_frame, src_frame->x, src_frame->y);
frame_set_opacity(dst_frame, src_frame->opacity);
dst_cel = cel_new(frpos, index);
cel_set_position(dst_cel, src_cel->x, src_cel->y);
cel_set_opacity(dst_cel, src_cel->opacity);
if (undo_is_enabled(sprite->undo)) {
undo_add_frame(sprite->undo, dst_layer, dst_frame);
undo_add_cel(sprite->undo, dst_layer, dst_cel);
}
layer_add_frame(dst_layer, dst_frame);
layer_add_cel(dst_layer, dst_cel);
}
/* with destination */
else {
int x1 = MIN(src_frame->x, dst_frame->x);
int y1 = MIN(src_frame->y, dst_frame->y);
int x2 = MAX(src_frame->x+src_image->w-1, dst_frame->x+dst_image->w-1);
int y2 = MAX(src_frame->y+src_image->h-1, dst_frame->y+dst_image->h-1);
int x1 = MIN(src_cel->x, dst_cel->x);
int y1 = MIN(src_cel->y, dst_cel->y);
int x2 = MAX(src_cel->x+src_image->w-1, dst_cel->x+dst_image->w-1);
int y2 = MAX(src_cel->y+src_image->h-1, dst_cel->y+dst_image->h-1);
Image *new_image = image_crop(dst_image,
x1-dst_frame->x,
y1-dst_frame->y,
x1-dst_cel->x,
y1-dst_cel->y,
x2-x1+1, y2-y1+1);
/* merge src_image in new_image */
image_merge(new_image, src_image,
src_frame->x-x1,
src_frame->y-y1,
src_frame->opacity,
src_cel->x-x1,
src_cel->y-y1,
src_cel->opacity,
src_layer->blend_mode);
frame_set_position(dst_frame, x1, y1);
cel_set_position(dst_cel, x1, y1);
if (undo_is_enabled(sprite->undo)) {
undo_replace_image(sprite->undo, dst_layer->stock, dst_frame->image);
undo_replace_image(sprite->undo, dst_layer->stock, dst_cel->image);
}
stock_replace_image(dst_layer->stock, dst_frame->image, new_image);
stock_replace_image(dst_layer->stock, dst_cel->image, new_image);
image_free(dst_image);
}

View File

@ -28,11 +28,11 @@
#endif
bool command_enabled_move_frame(const char *argument)
bool command_enabled_move_cel(const char *argument)
{
return FALSE;
}
void command_execute_move_frame(const char *argument)
void command_execute_move_cel(const char *argument)
{
}

View File

@ -27,8 +27,8 @@
#include "modules/gui.h"
#include "modules/color.h"
#include "modules/sprites.h"
#include "raster/cel.h"
#include "raster/image.h"
#include "raster/frame.h"
#include "raster/layer.h"
#include "raster/sprite.h"
#include "raster/stock.h"
@ -37,7 +37,7 @@
#endif
bool command_enabled_new_frame(const char *argument)
bool command_enabled_new_cel(const char *argument)
{
return
current_sprite &&
@ -47,18 +47,18 @@ bool command_enabled_new_frame(const char *argument)
layer_is_image(current_sprite->layer);
}
void command_execute_new_frame(const char *argument)
void command_execute_new_cel(const char *argument)
{
int bg, image_index;
Frame *frame;
Cel *cel;
Image *image;
int frpos;
frpos = current_sprite->frpos;
while (layer_get_frame(current_sprite->layer, frpos))
while (layer_get_cel(current_sprite->layer, frpos))
frpos++;
/* create a new empty frame with a new clean image */
/* create a new empty cel with a new clean image */
image = image_new(current_sprite->imgtype,
current_sprite->w,
current_sprite->h);
@ -87,10 +87,10 @@ void command_execute_new_frame(const char *argument)
undo_add_image(current_sprite->undo,
current_sprite->layer->stock, image);
/* add the frame in the layer */
frame = frame_new(current_sprite->frpos, image_index);
undo_add_frame(current_sprite->undo, current_sprite->layer, frame);
layer_add_frame(current_sprite->layer, frame);
/* add the cel in the layer */
cel = cel_new(current_sprite->frpos, image_index);
undo_add_cel(current_sprite->undo, current_sprite->layer, cel);
layer_add_cel(current_sprite->layer, cel);
undo_close(current_sprite->undo);

View File

@ -27,6 +27,7 @@
#include "modules/sprites.h"
#include "raster/layer.h"
#include "raster/sprite.h"
#include "script/functions.h"
#endif

View File

@ -27,6 +27,7 @@
#include "modules/sprites.h"
#include "raster/layer.h"
#include "raster/sprite.h"
#include "script/functions.h"
#endif

View File

@ -30,9 +30,9 @@
#include "modules/editors.h"
#include "modules/gfx.h"
#include "modules/gui.h"
#include "modules/render.h"
#include "raster/image.h"
#include "raster/sprite.h"
#include "util/render.h"
#include "widgets/editor.h"
#include "widgets/statebar.h"

View File

@ -20,7 +20,10 @@
#ifndef USE_PRECOMPILED_HEADER
#include <allegro/gfx.h>
#include "jinete/base.h"
#include "jinete/alert.h"
#include "util/recscr.h"
@ -35,6 +38,13 @@ void command_execute_record_screen(const char *argument)
{
if (is_rec_screen())
rec_screen_off();
else
else if (bitmap_color_depth(screen) == 8
|| jalert(_("Warning"
"<<The display isn't in a 8 bpp resolution, the recording."
"<<process can be really slow. It's recommended to use a"
"<<8 bpp to make it faster."
"<<Do you want to continue anyway?"
"||Yes||No")) == 1) {
rec_screen_on();
}
}

View File

@ -22,24 +22,24 @@
#include "modules/gui.h"
#include "modules/sprites.h"
#include "raster/frame.h"
#include "raster/cel.h"
#include "raster/layer.h"
#include "raster/sprite.h"
#include "script/functions.h"
#endif
bool command_enabled_remove_frame(const char *argument)
bool command_enabled_remove_cel(const char *argument)
{
return current_sprite != NULL;
}
void command_execute_remove_frame(const char *argument)
void command_execute_remove_cel(const char *argument)
{
Sprite *sprite = current_sprite;
Frame *frame = layer_get_frame(sprite->layer, sprite->frpos);
if (frame) {
RemoveFrame(sprite->layer, frame);
Cel *cel = layer_get_cel(sprite->layer, sprite->frpos);
if (cel) {
RemoveCel(sprite->layer, cel);
GUI_Refresh(sprite);
}
}

View File

@ -23,6 +23,7 @@
#include "modules/gui.h"
#include "modules/sprites.h"
#include "raster/sprite.h"
#include "script/functions.h"
#endif

View File

@ -110,21 +110,21 @@ bool command_enabled_flatten_layers(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 */
bool command_enabled_frame_properties(const char *argument);
void command_execute_frame_properties(const char *argument);
bool command_enabled_remove_frame(const char *argument);
void command_execute_remove_frame(const char *argument);
bool command_enabled_new_frame(const char *argument);
void command_execute_new_frame(const char *argument);
bool command_enabled_move_frame(const char *argument);
void command_execute_move_frame(const char *argument);
bool command_enabled_copy_frame(const char *argument);
void command_execute_copy_frame(const char *argument);
bool command_enabled_link_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);
/* cel */
bool command_enabled_cel_properties(const char *argument);
void command_execute_cel_properties(const char *argument);
bool command_enabled_remove_cel(const char *argument);
void command_execute_remove_cel(const char *argument);
bool command_enabled_new_cel(const char *argument);
void command_execute_new_cel(const char *argument);
bool command_enabled_move_cel(const char *argument);
void command_execute_move_cel(const char *argument);
bool command_enabled_copy_cel(const char *argument);
void command_execute_copy_cel(const char *argument);
bool command_enabled_link_cel(const char *argument);
void command_execute_link_cel(const char *argument);
bool command_enabled_crop_cel(const char *argument);
void command_execute_crop_cel(const char *argument);
/* select */
bool command_enabled_mask_all(const char *argument);
void command_execute_mask_all(const char *argument);
@ -230,13 +230,13 @@ static Command commands[] = {
CMD_EXE_ENA(merge_down_layer),
CMD_EXE_ENA(flatten_layers),
CMD_EXE_ENA(crop_layer),
CMD_EXE_ENA(frame_properties),
CMD_EXE_ENA(remove_frame),
CMD_EXE_ENA(new_frame),
CMD_EXE_ENA(move_frame),
CMD_EXE_ENA(copy_frame),
CMD_EXE_ENA(link_frame),
CMD_EXE_ENA(crop_frame),
CMD_EXE_ENA(cel_properties),
CMD_EXE_ENA(remove_cel),
CMD_EXE_ENA(new_cel),
CMD_EXE_ENA(move_cel),
CMD_EXE_ENA(copy_cel),
CMD_EXE_ENA(link_cel),
CMD_EXE_ENA(crop_cel),
CMD_EXE_ENA(mask_all),
CMD_EXE_ENA(deselect_mask),
CMD_EXE_ENA(reselect_mask),

View File

@ -69,14 +69,14 @@
#define CMD_MERGE_DOWN_LAYER "merge_down_layer"
#define CMD_FLATTEN_LAYERS "flatten_layers"
#define CMD_CROP_LAYER "crop_layer"
/* frame */
#define CMD_FRAME_PROPERTIES "frame_properties"
#define CMD_REMOVE_FRAME "remove_frame"
#define CMD_NEW_FRAME "new_frame"
#define CMD_MOVE_FRAME "move_frame"
#define CMD_COPY_FRAME "copy_frame"
#define CMD_LINK_FRAME "link_frame"
#define CMD_CROP_FRAME "crop_frame"
/* cel */
#define CMD_CEL_PROPERTIES "cel_properties"
#define CMD_REMOVE_CEL "remove_cel"
#define CMD_NEW_CEL "new_cel"
#define CMD_MOVE_CEL "move_cel"
#define CMD_COPY_CEL "copy_cel"
#define CMD_LINK_CEL "link_cel"
#define CMD_CROP_CEL "crop_cel"
/* select */
#define CMD_MASK_ALL "mask_all"
#define CMD_DESELECT_MASK "deselect_mask"

View File

@ -29,7 +29,6 @@
#include "modules/gui.h"
#include "modules/palette.h"
#include "modules/recent.h"
#include "modules/render.h"
#include "modules/rootmenu.h"
#include "modules/sprites.h"
#include "modules/tools.h"
@ -61,7 +60,6 @@ static Module module[] =
DEF_MODULE(effect, REQUIRE_INTERFACE | REQUIRE_SCRIPTING),
DEF_MODULE(tools, REQUIRE_INTERFACE | REQUIRE_SCRIPTING),
DEF_MODULE(graphics, REQUIRE_INTERFACE),
DEF_MODULE(render, REQUIRE_INTERFACE),
DEF_MODULE(gui, REQUIRE_INTERFACE),
DEF_MODULE(recent, REQUIRE_INTERFACE),
DEF_MODULE(rootmenu, REQUIRE_INTERFACE),

View File

@ -34,13 +34,13 @@
#include "modules/palette.h"
#include "modules/rootmenu.h"
#include "modules/sprites.h"
#include "raster/frame.h"
#include "raster/cel.h"
#include "raster/image.h"
#include "raster/layer.h"
#include "raster/sprite.h"
#include "raster/stock.h"
#include "raster/undo.h"
#include "util/frmove.h"
#include "util/celmove.h"
#include "util/thmbnail.h"
#endif
@ -56,26 +56,26 @@ enum {
STATE_SELECTING,
};
struct FrameBox;
struct CelBox;
typedef struct LayerBox {
JWidget widget;
struct FrameBox *frame_box;
struct CelBox *cel_box;
/* for layer movement */
Layer *layer;
struct jrect rect;
void *rect_data;
} LayerBox;
typedef struct FrameBox {
typedef struct CelBox {
JWidget widget;
LayerBox *layer_box;
/* for frame movement */
Layer *layer;
Frame *frame;
Cel *cel;
struct jrect rect;
void *rect_data;
} FrameBox;
} CelBox;
static int state = STATE_NONE;
@ -85,11 +85,11 @@ static LayerBox *layer_box_data (JWidget widget);
static void layer_box_request_size (JWidget widget, int *w, int *h);
static bool layer_box_msg_proc (JWidget widget, JMessage msg);
static JWidget frame_box_new (void);
static int frame_box_type (void);
static FrameBox *frame_box_data (JWidget widget);
static void frame_box_request_size (JWidget widget, int *w, int *h);
static bool frame_box_msg_proc (JWidget widget, JMessage msg);
static JWidget cel_box_new (void);
static int cel_box_type (void);
static CelBox *cel_box_data (JWidget widget);
static void cel_box_request_size (JWidget widget, int *w, int *h);
static bool cel_box_msg_proc (JWidget widget, JMessage msg);
static Layer *select_prev_layer(Layer *layer, int enter_in_sets);
static Layer *select_next_layer(Layer *layer, int enter_in_sets);
@ -97,10 +97,10 @@ static int count_layers(Layer *layer);
static int get_layer_pos(Layer *layer, Layer *current, int *pos);
static Layer *get_layer_in_pos(Layer *layer, int pos);
static void select_frpos_motion (JWidget widget);
static void select_layer_motion (JWidget widget, LayerBox *layer_box, FrameBox *frame_box);
static void control_scroll_motion (JWidget widget, LayerBox *layer_box, FrameBox *frame_box);
static void get_frame_rect (JWidget widget, JRect rect);
static void select_frpos_motion(JWidget widget);
static void select_layer_motion(JWidget widget, LayerBox *layer_box, CelBox *cel_box);
static void control_scroll_motion(JWidget widget, LayerBox *layer_box, CelBox *cel_box);
static void get_cel_rect(JWidget widget, JRect rect);
bool is_movingframe (void)
{
@ -112,7 +112,7 @@ void switch_between_film_and_sprite_editor (void)
Sprite *sprite = current_sprite;
JWidget window, box1, panel1;
JWidget layer_view, frame_view;
JWidget layer_box, frame_box;
JWidget layer_box, cel_box;
if (!is_interactive ())
return;
@ -123,15 +123,15 @@ void switch_between_film_and_sprite_editor (void)
layer_view = jview_new();
frame_view = jview_new();
layer_box = layer_box_new();
frame_box = frame_box_new();
cel_box = cel_box_new();
layer_box_data(layer_box)->frame_box = frame_box_data(frame_box);
frame_box_data(frame_box)->layer_box = layer_box_data(layer_box);
layer_box_data(layer_box)->cel_box = cel_box_data(cel_box);
cel_box_data(cel_box)->layer_box = layer_box_data(layer_box);
jwidget_expansive(panel1, TRUE);
jview_attach(layer_view, layer_box);
jview_attach(frame_view, frame_box);
jview_attach(frame_view, cel_box);
jview_without_bars(layer_view);
jview_without_bars(frame_view);
@ -369,7 +369,7 @@ static bool layer_box_msg_proc (JWidget widget, JMessage msg)
state = STATE_MOVING;
jmouse_set_cursor(JI_CURSOR_MOVE);
select_layer_motion(widget, layer_box, layer_box->frame_box);
select_layer_motion(widget, layer_box, layer_box->cel_box);
layer_box->layer = current_sprite->layer;
/* layer_box->rect = rect; */
/* layer_box->rect_data = NULL; */
@ -379,10 +379,10 @@ static bool layer_box_msg_proc (JWidget widget, JMessage msg)
if (jwidget_has_capture (widget)) {
/* scroll */
if (state == STATE_SCROLLING)
control_scroll_motion (widget, layer_box, layer_box->frame_box);
control_scroll_motion (widget, layer_box, layer_box->cel_box);
/* move */
else if (state == STATE_MOVING) {
select_layer_motion (widget, layer_box, layer_box->frame_box);
select_layer_motion (widget, layer_box, layer_box->cel_box);
}
return TRUE;
}
@ -405,7 +405,7 @@ static bool layer_box_msg_proc (JWidget widget, JMessage msg)
msg->mouse.x, msg->mouse.y);
jview_update (jwidget_get_view (layer_box->widget));
jview_update (jwidget_get_view (layer_box->frame_box->widget));
jview_update (jwidget_get_view (layer_box->cel_box->widget));
}
}
/* move */
@ -416,7 +416,7 @@ static bool layer_box_msg_proc (JWidget widget, JMessage msg)
current_sprite->layer = layer_box->layer;
jview_update (jwidget_get_view (layer_box->widget));
jview_update (jwidget_get_view (layer_box->frame_box->widget));
jview_update (jwidget_get_view (layer_box->cel_box->widget));
}
else
jwidget_dirty (widget);
@ -431,24 +431,24 @@ static bool layer_box_msg_proc (JWidget widget, JMessage msg)
}
/***********************************************************************
FrameBox
CelBox
***********************************************************************/
static JWidget frame_box_new (void)
static JWidget cel_box_new (void)
{
JWidget widget = jwidget_new (frame_box_type ());
FrameBox *frame_box = jnew (FrameBox, 1);
JWidget widget = jwidget_new (cel_box_type ());
CelBox *cel_box = jnew (CelBox, 1);
frame_box->widget = widget;
cel_box->widget = widget;
jwidget_add_hook (widget, frame_box_type (),
frame_box_msg_proc, frame_box);
jwidget_add_hook (widget, cel_box_type (),
cel_box_msg_proc, cel_box);
jwidget_focusrest (widget, TRUE);
return widget;
}
static int frame_box_type (void)
static int cel_box_type (void)
{
static int type = 0;
if (!type)
@ -456,12 +456,12 @@ static int frame_box_type (void)
return type;
}
static FrameBox *frame_box_data (JWidget widget)
static CelBox *cel_box_data (JWidget widget)
{
return jwidget_get_data (widget, frame_box_type ());
return jwidget_get_data (widget, cel_box_type ());
}
static void frame_box_request_size (JWidget widget, int *w, int *h)
static void cel_box_request_size (JWidget widget, int *w, int *h)
{
Sprite *sprite = current_sprite;
@ -469,19 +469,19 @@ static void frame_box_request_size (JWidget widget, int *w, int *h)
*h = LAYSIZE*(count_layers (sprite->set)+1);
}
static bool frame_box_msg_proc (JWidget widget, JMessage msg)
static bool cel_box_msg_proc (JWidget widget, JMessage msg)
{
FrameBox *frame_box = frame_box_data (widget);
CelBox *cel_box = cel_box_data (widget);
Sprite *sprite = current_sprite;
switch (msg->type) {
case JM_DESTROY:
jfree (frame_box);
jfree (cel_box);
break;
case JM_REQSIZE:
frame_box_request_size (widget, &msg->reqsize.w, &msg->reqsize.h);
cel_box_request_size (widget, &msg->reqsize.w, &msg->reqsize.h);
return TRUE;
case JM_DRAW: {
@ -568,22 +568,22 @@ static bool frame_box_msg_proc (JWidget widget, JMessage msg)
case GFXOBJ_LAYER_SET:
break;
case GFXOBJ_LAYER_IMAGE: {
Frame *frame, *frame_link;
Cel *cel, *cel_link;
int k_frpos, k_image;
JLink link;
JI_LIST_FOR_EACH(layer->frames, link) {
frame = link->data;
k_frpos = frame->frpos;
JI_LIST_FOR_EACH(layer->cels, link) {
cel = link->data;
k_frpos = cel->frpos;
if (k_frpos < first_viewable_frame ||
k_frpos > last_viewable_frame)
continue;
k_image = frame->image;
k_image = cel->image;
frame_link = frame_is_link(frame, layer);
thumbnail = generate_thumbnail(frame_link ? frame_link: frame,
cel_link = cel_is_link(cel, layer);
thumbnail = generate_thumbnail(cel_link ? cel_link: cel,
layer);
x1 = k_frpos*FRMSIZE-scroll_x+FRMSIZE/2-THUMBSIZE/2;
@ -598,7 +598,7 @@ static bool frame_box_msg_proc (JWidget widget, JMessage msg)
if (thumbnail)
draw_sprite(bmp, thumbnail, x1, y1);
if (frame_link) {
if (cel_link) {
BITMAP *sprite = get_gfx(GFX_LINKFRAME);
draw_sprite(bmp, sprite, x1, y2-sprite->h+1);
}
@ -626,13 +626,13 @@ static bool frame_box_msg_proc (JWidget widget, JMessage msg)
jmouse_set_cursor(JI_CURSOR_MOVE);
}
else {
Frame *frame;
Cel *cel;
state = STATE_SELECTING; /* by default we will be selecting
frames */
select_frpos_motion (widget);
select_layer_motion (widget, frame_box->layer_box, frame_box);
select_frpos_motion(widget);
select_layer_motion(widget, cel_box->layer_box, cel_box);
/* show the dialog to change the frlen (frame duration time)? */
if (msg->mouse.y < FRMSIZE) {
@ -643,26 +643,25 @@ static bool frame_box_msg_proc (JWidget widget, JMessage msg)
return TRUE;
}
frame = layer_get_frame (current_sprite->layer,
current_sprite->frpos);
if (frame) {
state = STATE_MOVING; /* now we will moving a frame */
cel = layer_get_cel(current_sprite->layer,
current_sprite->frpos);
if (cel) {
state = STATE_MOVING; /* now we will moving a cel */
jmouse_set_cursor(JI_CURSOR_MOVE);
frame_box->layer = current_sprite->layer;
frame_box->frame = frame;
frame_box->rect_data = NULL;
cel_box->layer = current_sprite->layer;
cel_box->cel = cel;
cel_box->rect_data = NULL;
get_frame_rect (widget, &frame_box->rect);
get_cel_rect(widget, &cel_box->rect);
jmouse_hide();
frame_box->rect_data = rectsave
(ji_screen,
frame_box->rect.x1, frame_box->rect.y1,
frame_box->rect.x2-1, frame_box->rect.y2-1);
cel_box->rect_data = rectsave(ji_screen,
cel_box->rect.x1, cel_box->rect.y1,
cel_box->rect.x2-1, cel_box->rect.y2-1);
rectdotted(ji_screen,
frame_box->rect.x1, frame_box->rect.y1,
frame_box->rect.x2-1, frame_box->rect.y2-1,
cel_box->rect.x1, cel_box->rect.y1,
cel_box->rect.x2-1, cel_box->rect.y2-1,
makecol (0, 0, 0), makecol (255, 255, 255));
jmouse_show();
}
@ -672,29 +671,28 @@ static bool frame_box_msg_proc (JWidget widget, JMessage msg)
if (jwidget_has_capture (widget)) {
/* scroll */
if (state == STATE_SCROLLING)
control_scroll_motion (widget, frame_box->layer_box, frame_box);
control_scroll_motion (widget, cel_box->layer_box, cel_box);
/* move */
else if (state == STATE_MOVING) {
jmouse_hide();
rectrestore(frame_box->rect_data);
rectdiscard(frame_box->rect_data);
rectrestore(cel_box->rect_data);
rectdiscard(cel_box->rect_data);
select_frpos_motion(widget);
select_layer_motion(widget, frame_box->layer_box, frame_box);
select_layer_motion(widget, cel_box->layer_box, cel_box);
get_frame_rect(widget, &frame_box->rect);
get_cel_rect(widget, &cel_box->rect);
jwidget_flush_redraw(widget);
frame_box->rect_data = rectsave
(ji_screen,
frame_box->rect.x1, frame_box->rect.y1,
frame_box->rect.x2-1, frame_box->rect.y2-1);
cel_box->rect_data = rectsave(ji_screen,
cel_box->rect.x1, cel_box->rect.y1,
cel_box->rect.x2-1, cel_box->rect.y2-1);
rectdotted(ji_screen,
frame_box->rect.x1, frame_box->rect.y1,
frame_box->rect.x2-1, frame_box->rect.y2-1,
cel_box->rect.x1, cel_box->rect.y1,
cel_box->rect.x2-1, cel_box->rect.y2-1,
makecol(0, 0, 0), makecol(255, 255, 255));
jmouse_show();
@ -702,7 +700,7 @@ static bool frame_box_msg_proc (JWidget widget, JMessage msg)
/* select */
else if (state == STATE_SELECTING) {
select_frpos_motion(widget);
select_layer_motion(widget, frame_box->layer_box, frame_box);
select_layer_motion(widget, cel_box->layer_box, cel_box);
}
return TRUE;
}
@ -718,12 +716,12 @@ static bool frame_box_msg_proc (JWidget widget, JMessage msg)
if ((state == STATE_SELECTING) || (state == STATE_MOVING)) {
if (state == STATE_MOVING) {
jmouse_hide();
rectrestore(frame_box->rect_data);
rectdiscard(frame_box->rect_data);
rectrestore(cel_box->rect_data);
rectdiscard(cel_box->rect_data);
jmouse_show();
}
set_frame_to_handle(frame_box->layer, frame_box->frame);
set_cel_to_handle(cel_box->layer, cel_box->cel);
if (msg->mouse.right) {
JWidget popup_menuitem = get_frame_popup_menuitem();
@ -733,12 +731,12 @@ static bool frame_box_msg_proc (JWidget widget, JMessage msg)
jmenu_popup(jmenuitem_get_submenu(popup_menuitem),
msg->mouse.x, msg->mouse.y);
jview_update(jwidget_get_view (frame_box->widget));
jview_update(jwidget_get_view (frame_box->layer_box->widget));
jview_update(jwidget_get_view (cel_box->widget));
jview_update(jwidget_get_view (cel_box->layer_box->widget));
}
}
else if (state == STATE_MOVING) {
move_frame();
move_cel();
jwidget_dirty(widget);
}
}
@ -904,7 +902,7 @@ static void select_frpos_motion(JWidget widget)
/* select the layer depending of mouse motion (also adjust the scroll) */
static void select_layer_motion(JWidget widget,
LayerBox *layer_box, FrameBox *frame_box)
LayerBox *layer_box, CelBox *cel_box)
{
Sprite *sprite = current_sprite;
int layer, current_layer;
@ -919,7 +917,7 @@ static void select_layer_motion(JWidget widget,
/* the layer change? */
if (layer != current_layer) {
JWidget view1 = jwidget_get_view(layer_box->widget);
JWidget view2 = jwidget_get_view(frame_box->widget);
JWidget view2 = jwidget_get_view(cel_box->widget);
JRect vp = jview_get_viewport_position(jwidget_get_view(widget));
int scroll1_x, scroll1_y, scroll_change;
int scroll2_x, scroll2_y;
@ -947,19 +945,19 @@ static void select_layer_motion(JWidget widget,
widget->rc->y1+LAYSIZE+layer*LAYSIZE+LAYSIZE/2);
jwidget_dirty(layer_box->widget);
jwidget_dirty(frame_box->widget);
jwidget_dirty(cel_box->widget);
jrect_free(vp);
}
}
/* controls scroll for "layer_box" and "frame_box" handling horizontal
/* controls scroll for "layer_box" and "cel_box" handling horizontal
scroll individually and vertical scroll jointly */
static void control_scroll_motion (JWidget widget,
LayerBox *layer_box, FrameBox *frame_box)
static void control_scroll_motion(JWidget widget,
LayerBox *layer_box, CelBox *cel_box)
{
JWidget view1 = jwidget_get_view(layer_box->widget);
JWidget view2 = jwidget_get_view(frame_box->widget);
JWidget view2 = jwidget_get_view(cel_box->widget);
JRect vp = jview_get_viewport_position(jwidget_get_view (widget));
int scroll1_x, scroll1_y;
int scroll2_x, scroll2_y;
@ -970,7 +968,7 @@ static void control_scroll_motion (JWidget widget,
/* horizontal scroll for layer_box */
if (widget == layer_box->widget)
scroll1_x += jmouse_x(1)-jmouse_x(0);
/* horizontal scroll for frame_box */
/* horizontal scroll for cel_box */
else
scroll2_x += jmouse_x(1)-jmouse_x(0);
@ -988,7 +986,7 @@ static void control_scroll_motion (JWidget widget,
jrect_free(vp);
}
static void get_frame_rect (JWidget widget, JRect rect)
static void get_cel_rect(JWidget widget, JRect rect)
{
JWidget view = jwidget_get_view(widget);
JRect vp = jview_get_viewport_position(view);

View File

@ -28,8 +28,8 @@
#include "modules/sprites.h"
#include "modules/tools2.h"
#include "raster/blend.h"
#include "raster/cel.h"
#include "raster/dirty.h"
#include "raster/frame.h"
#include "raster/image.h"
#include "raster/layer.h"
#include "raster/mask.h"

View File

@ -36,13 +36,13 @@
#define ASE_FILE_CHUNK_FLI_COLOR 11
#define ASE_FILE_CHUNK_LAYER 0x2004
#define ASE_FILE_CHUNK_FRAME 0x2005
#define ASE_FILE_CHUNK_CEL 0x2005
#define ASE_FILE_CHUNK_MASK 0x2016
#define ASE_FILE_CHUNK_PATH 0x2017
#define ASE_FILE_RAW_FRAME 0
#define ASE_FILE_LINK_FRAME 1
#define ASE_FILE_RLE_COMPRESSED_FRAME 2
#define ASE_FILE_RAW_CEL 0
#define ASE_FILE_LINK_CEL 1
#define ASE_FILE_RLE_COMPRESSED_CEL 2
typedef struct ASE_Header
{
@ -87,7 +87,7 @@ static void ase_file_prepare_frame_header(FILE *f, ASE_FrameHeader *frame_header
static void ase_file_write_frame_header(FILE *f, ASE_FrameHeader *frame_header);
static void ase_file_write_layers(FILE *f, Layer *layer);
static void ase_file_write_frames(FILE *f, Sprite *sprite, Layer *layer, int frpos);
static void ase_file_write_cels(FILE *f, Sprite *sprite, Layer *layer, int frpos);
static void ase_file_read_padding(FILE *f, int bytes);
static void ase_file_write_padding(FILE *f, int bytes);
@ -101,8 +101,8 @@ static void ase_file_read_color_chunk(FILE *f, RGB *pal);
static void ase_file_write_color_chunk(FILE *f, RGB *pal);
static Layer *ase_file_read_layer_chunk(FILE *f, int imgtype, Layer **previous_layer, int *current_level);
static void ase_file_write_layer_chunk(FILE *f, Layer *layer);
static Frame *ase_file_read_frame_chunk(FILE *f, Sprite *sprite, int frpos, int imgtype);
static void ase_file_write_frame_chunk(FILE *f, Frame *frame, Layer *layer, int layer_index);
static Cel *ase_file_read_cel_chunk(FILE *f, Sprite *sprite, int frpos, int imgtype);
static void ase_file_write_cel_chunk(FILE *f, Cel *cel, Layer *layer, int layer_index);
static Mask *ase_file_read_mask_chunk(FILE *f);
static void ase_file_write_mask_chunk(FILE *f, Mask *mask);
@ -162,7 +162,7 @@ static int ase_file_write(Sprite *sprite)
return ret;
}
Sprite *ase_file_read_f (FILE *f)
Sprite *ase_file_read_f(FILE *f)
{
Sprite *sprite = NULL;
ASE_Header header;
@ -175,17 +175,17 @@ Sprite *ase_file_read_f (FILE *f)
int chunk_type;
int c, frpos;
if (ase_file_read_header (f, &header) != 0) {
console_printf (_("Error reading header\n"));
if (ase_file_read_header(f, &header) != 0) {
console_printf(_("Error reading header\n"));
return NULL;
}
/* create the new sprite */
sprite = sprite_new (header.depth == 32 ? IMAGE_RGB:
header.depth == 16 ? IMAGE_GRAYSCALE: IMAGE_INDEXED,
header.width, header.height);
sprite = sprite_new(header.depth == 32 ? IMAGE_RGB:
header.depth == 16 ? IMAGE_GRAYSCALE: IMAGE_INDEXED,
header.width, header.height);
if (!sprite) {
console_printf (_("Error creating sprite with file spec\n"));
console_printf(_("Error creating sprite with file spec\n"));
return NULL;
}
@ -203,11 +203,11 @@ Sprite *ase_file_read_f (FILE *f)
/* read frame by frame to end-of-file */
for (frpos=0; frpos<sprite->frames; frpos++) {
/* start frame position */
frame_pos = ftell (f);
do_progress (frame_pos);
frame_pos = ftell(f);
do_progress(frame_pos);
/* read frame header */
ase_file_read_frame_header (f, &frame_header);
ase_file_read_frame_header(f, &frame_header);
/* correct frame type */
if (frame_header.magic == ASE_FILE_FRAME_MAGIC) {
@ -218,12 +218,12 @@ Sprite *ase_file_read_f (FILE *f)
/* read chunks */
for (c=0; c<frame_header.chunks; c++) {
/* start chunk position */
chunk_pos = ftell (f);
do_progress (chunk_pos);
chunk_pos = ftell(f);
do_progress(chunk_pos);
/* read chunk information */
chunk_size = fgetl (f);
chunk_type = fgetw (f);
chunk_size = fgetl(f);
chunk_type = fgetw(f);
switch (chunk_type) {
@ -250,10 +250,10 @@ Sprite *ase_file_read_f (FILE *f)
break;
}
case ASE_FILE_CHUNK_FRAME: {
/* console_printf ("Frame chunk\n"); */
case ASE_FILE_CHUNK_CEL: {
/* console_printf ("Cel chunk\n"); */
ase_file_read_frame_chunk (f, sprite, frpos, sprite->imgtype);
ase_file_read_cel_chunk(f, sprite, frpos, sprite->imgtype);
break;
}
@ -286,15 +286,15 @@ Sprite *ase_file_read_f (FILE *f)
}
/* skip frame size */
fseek (f, frame_pos+frame_header.size, SEEK_SET);
fseek(f, frame_pos+frame_header.size, SEEK_SET);
}
del_progress ();
del_progress();
return sprite;
}
int ase_file_write_f (FILE *f, Sprite *sprite)
int ase_file_write_f(FILE *f, Sprite *sprite)
{
ASE_Header header;
ASE_FrameHeader frame_header;
@ -334,8 +334,8 @@ int ase_file_write_f (FILE *f, Sprite *sprite)
ase_file_write_mask_chunk(f, link->data);
}
/* write frames chunks */
ase_file_write_frames(f, sprite, sprite->set, frpos);
/* write cel chunks */
ase_file_write_cels(f, sprite, sprite->set, frpos);
/* write the frame header */
ase_file_write_frame_header(f, &frame_header);
@ -411,7 +411,7 @@ static void ase_file_write_header (FILE *f, ASE_Header *header)
fseek (f, header->pos+header->size, SEEK_SET);
}
static void ase_file_read_frame_header (FILE *f, ASE_FrameHeader *frame_header)
static void ase_file_read_frame_header(FILE *f, ASE_FrameHeader *frame_header)
{
frame_header->size = fgetl (f);
frame_header->magic = fgetw (f);
@ -420,7 +420,7 @@ static void ase_file_read_frame_header (FILE *f, ASE_FrameHeader *frame_header)
ase_file_read_padding (f, 6);
}
static void ase_file_prepare_frame_header (FILE *f, ASE_FrameHeader *frame_header)
static void ase_file_prepare_frame_header(FILE *f, ASE_FrameHeader *frame_header)
{
int pos = ftell (f);
@ -434,7 +434,7 @@ static void ase_file_prepare_frame_header (FILE *f, ASE_FrameHeader *frame_heade
fseek (f, pos+16, SEEK_SET);
}
static void ase_file_write_frame_header (FILE *f, ASE_FrameHeader *frame_header)
static void ase_file_write_frame_header(FILE *f, ASE_FrameHeader *frame_header)
{
int pos = frame_header->size;
int end = ftell (f);
@ -465,28 +465,28 @@ static void ase_file_write_layers(FILE *f, Layer *layer)
}
}
static void ase_file_write_frames(FILE *f, Sprite *sprite, Layer *layer, int frpos)
static void ase_file_write_cels(FILE *f, Sprite *sprite, Layer *layer, int frpos)
{
if (layer_is_image(layer)) {
Frame *frame = layer_get_frame(layer, frpos);
Cel *cel = layer_get_cel(layer, frpos);
if (frame) {
/* console_printf ("New frame in frpos %d, in layer %d\n", */
if (cel) {
/* console_printf ("New cel in frpos %d, in layer %d\n", */
/* frpos, sprite_layer2index (sprite, layer)); */
ase_file_write_frame_chunk(f, frame, layer, /* index_count */
sprite_layer2index(sprite, layer));
ase_file_write_cel_chunk(f, cel, layer, /* index_count */
sprite_layer2index(sprite, layer));
}
}
if (layer_is_set(layer)) {
JLink link;
JI_LIST_FOR_EACH(layer->layers, link)
ase_file_write_frames(f, sprite, link->data, frpos);
ase_file_write_cels(f, sprite, link->data, frpos);
}
}
static void ase_file_read_padding (FILE *f, int bytes)
static void ase_file_read_padding(FILE *f, int bytes)
{
int c;
@ -494,7 +494,7 @@ static void ase_file_read_padding (FILE *f, int bytes)
fgetc (f);
}
static void ase_file_write_padding (FILE *f, int bytes)
static void ase_file_write_padding(FILE *f, int bytes)
{
int c;
@ -502,7 +502,7 @@ static void ase_file_write_padding (FILE *f, int bytes)
fputc (0, f);
}
static char *ase_file_read_string (FILE *f)
static char *ase_file_read_string(FILE *f)
{
char *string;
int c, length;
@ -522,7 +522,7 @@ static char *ase_file_read_string (FILE *f)
return string;
}
static void ase_file_write_string (FILE *f, const char *string)
static void ase_file_write_string(FILE *f, const char *string)
{
const char *p;
@ -691,35 +691,35 @@ static void ase_file_write_layer_chunk (FILE *f, Layer *layer)
/* console_printf ("Layer name \"%s\" child level: %d\n", layer->name, child_level); */
}
static Frame *ase_file_read_frame_chunk (FILE *f, Sprite *sprite, int frpos, int imgtype)
static Cel *ase_file_read_cel_chunk(FILE *f, Sprite *sprite, int frpos, int imgtype)
{
Frame *frame;
Cel *cel;
/* read chunk data */
int layer_index = fgetw (f);
int x = ((short)fgetw (f));
int y = ((short)fgetw (f));
int opacity = fgetc (f);
int frame_type = fgetw (f);
int layer_index = fgetw(f);
int x = ((short)fgetw(f));
int y = ((short)fgetw(f));
int opacity = fgetc(f);
int cel_type = fgetw(f);
Layer *layer;
ase_file_read_padding (f, 7);
ase_file_read_padding(f, 7);
layer = sprite_index2layer (sprite, layer_index);
layer = sprite_index2layer(sprite, layer_index);
if (!layer) {
console_printf (_("Frame %d didn't found layer with index %d\n"),
frpos, layer_index);
console_printf(_("Frame %d didn't found layer with index %d\n"),
frpos, layer_index);
return NULL;
}
/* console_printf ("Layer found: %d -> %s\n", layer_index, layer->name); */
/* create the new frame */
frame = frame_new(frpos, 0);
frame_set_position(frame, x, y);
frame_set_opacity(frame, opacity);
cel = cel_new(frpos, 0);
cel_set_position(cel, x, y);
cel_set_opacity(cel, opacity);
switch (frame_type) {
switch (cel_type) {
case ASE_FILE_RAW_FRAME: {
case ASE_FILE_RAW_CEL: {
int x, y, r, g, b, a, k;
Image *image;
/* read width and height */
@ -729,7 +729,7 @@ static Frame *ase_file_read_frame_chunk (FILE *f, Sprite *sprite, int frpos, int
if (w > 0 && h > 0) {
image = image_new (imgtype, w, h);
if (!image) {
frame_free (frame);
cel_free(cel);
/* not enough memory for frame's image */
return NULL;
}
@ -771,64 +771,62 @@ static Frame *ase_file_read_frame_chunk (FILE *f, Sprite *sprite, int frpos, int
break;
}
frame->image = stock_add_image (layer->stock, image);
cel->image = stock_add_image(layer->stock, image);
}
break;
}
case ASE_FILE_LINK_FRAME: {
case ASE_FILE_LINK_CEL: {
/* read link position */
int link_frpos = fgetw (f);
Frame *link = layer_get_frame (layer, link_frpos);
Cel *link = layer_get_cel(layer, link_frpos);
if (link)
frame->image = link->image;
cel->image = link->image;
else {
frame_free (frame);
/* linked frame doesn't found */
cel_free(cel);
/* linked cel doesn't found */
return NULL;
}
break;
}
case ASE_FILE_RLE_COMPRESSED_FRAME:
case ASE_FILE_RLE_COMPRESSED_CEL:
/* XXXX */
break;
}
layer_add_frame (layer, frame);
return frame;
layer_add_cel(layer, cel);
return cel;
}
static void ase_file_write_frame_chunk (FILE *f, Frame *frame, Layer *layer, int layer_index)
static void ase_file_write_cel_chunk(FILE *f, Cel *cel, Layer *layer, int layer_index)
{
Frame *link = frame_is_link (frame, layer);
int frame_type = link ? ASE_FILE_LINK_FRAME: ASE_FILE_RAW_FRAME;
Cel *link = cel_is_link(cel, layer);
int cel_type = link ? ASE_FILE_LINK_CEL: ASE_FILE_RAW_CEL;
/* ASE_FILE_RLE_COMPRESSED_FRAME */
ase_file_write_start_chunk(f, ASE_FILE_CHUNK_CEL);
ase_file_write_start_chunk (f, ASE_FILE_CHUNK_FRAME);
fputw(layer_index, f);
fputw(cel->x, f);
fputw(cel->y, f);
fputc(cel->opacity, f);
fputw(cel_type, f);
ase_file_write_padding(f, 7);
fputw (layer_index, f);
fputw (frame->x, f);
fputw (frame->y, f);
fputc (frame->opacity, f);
fputw (frame_type, f);
ase_file_write_padding (f, 7);
switch (cel_type) {
switch (frame_type) {
case ASE_FILE_RAW_FRAME: {
Image *image = stock_get_image (layer->stock, frame->image);
case ASE_FILE_RAW_CEL: {
Image *image = stock_get_image(layer->stock, cel->image);
int x, y, c;
if (image) {
/* width and height */
fputw (image->w, f);
fputw (image->h, f);
fputw(image->w, f);
fputw(image->h, f);
/* XXXX */
/* add_progress (image->h); */
/* add_progress(image->h); */
/* pixel data */
switch (image->imgtype) {
@ -837,122 +835,122 @@ static void ase_file_write_frame_chunk (FILE *f, Frame *frame, Layer *layer, int
for (y=0; y<image->h; y++) {
for (x=0; x<image->w; x++) {
c = image->method->getpixel (image, x, y);
fputc (_rgba_getr (c), f);
fputc (_rgba_getg (c), f);
fputc (_rgba_getb (c), f);
fputc (_rgba_geta (c), f);
fputc(_rgba_getr(c), f);
fputc(_rgba_getg(c), f);
fputc(_rgba_getb(c), f);
fputc(_rgba_geta(c), f);
}
/* do_progress (y); */
/* do_progress(y); */
}
break;
case IMAGE_GRAYSCALE:
for (y=0; y<image->h; y++) {
for (x=0; x<image->w; x++) {
c = image->method->getpixel (image, x, y);
fputc (_graya_getk (c), f);
fputc (_graya_geta (c), f);
c = image->method->getpixel(image, x, y);
fputc(_graya_getk(c), f);
fputc(_graya_geta(c), f);
}
/* do_progress (y); */
/* do_progress(y); */
}
break;
case IMAGE_INDEXED:
for (y=0; y<image->h; y++) {
for (x=0; x<image->w; x++)
fputc (image->method->getpixel (image, x, y), f);
fputc(image->method->getpixel(image, x, y), f);
/* do_progress (y); */
/* do_progress(y); */
}
break;
}
/* del_progress (); */
/* del_progress(); */
}
else {
/* width and height */
fputw (0, f);
fputw (0, f);
fputw(0, f);
fputw(0, f);
}
break;
}
case ASE_FILE_LINK_FRAME:
case ASE_FILE_LINK_CEL:
/* linked frame position */
fputw (link->frpos, f);
fputw(link->frpos, f);
break;
case ASE_FILE_RLE_COMPRESSED_FRAME:
/* XXXX */
case ASE_FILE_RLE_COMPRESSED_CEL:
/* TODO */
break;
}
ase_file_write_close_chunk (f);
ase_file_write_close_chunk(f);
}
static Mask *ase_file_read_mask_chunk (FILE *f)
static Mask *ase_file_read_mask_chunk(FILE *f)
{
int c, u, v, byte;
Mask *mask;
/* read chunk data */
int x = fgetw (f);
int y = fgetw (f);
int w = fgetw (f);
int h = fgetw (f);
int x = fgetw(f);
int y = fgetw(f);
int w = fgetw(f);
int h = fgetw(f);
char *name;
ase_file_read_padding (f, 8);
name = ase_file_read_string (f);
ase_file_read_padding(f, 8);
name = ase_file_read_string(f);
mask = mask_new ();
mask = mask_new();
if (!mask)
return NULL;
if (name)
mask_set_name (mask, name);
mask_set_name(mask, name);
mask_replace (mask, x, y, w, h);
mask_replace(mask, x, y, w, h);
/* read image data */
for (v=0; v<h; v++)
for (u=0; u<(w+7)/8; u++) {
byte = fgetc (f);
for (c=0; c<8; c++)
image_putpixel (mask->bitmap, u*8+c, v, byte & (1<<(7-c)));
image_putpixel(mask->bitmap, u*8+c, v, byte & (1<<(7-c)));
}
return mask;
}
static void ase_file_write_mask_chunk (FILE *f, Mask *mask)
static void ase_file_write_mask_chunk(FILE *f, Mask *mask)
{
int c, u, v, byte;
ase_file_write_start_chunk (f, ASE_FILE_CHUNK_MASK);
ase_file_write_start_chunk(f, ASE_FILE_CHUNK_MASK);
fputw (mask->x, f);
fputw (mask->y, f);
fputw (mask->w, f);
fputw (mask->h, f);
ase_file_write_padding (f, 8);
fputw(mask->x, f);
fputw(mask->y, f);
fputw(mask->w, f);
fputw(mask->h, f);
ase_file_write_padding(f, 8);
/* name */
ase_file_write_string (f, mask->name);
ase_file_write_string(f, mask->name);
/* bit map */
for (v=0; v<mask->h; v++)
for (u=0; u<(mask->w+7)/8; u++) {
byte = 0;
for (c=0; c<8; c++)
if (image_getpixel (mask->bitmap, u*8+c, v))
if (image_getpixel(mask->bitmap, u*8+c, v))
byte |= (1<<(7-c));
fputc (byte, f);
fputc(byte, f);
}
ase_file_write_close_chunk (f);
ase_file_write_close_chunk(f);
}
/* returns a word (16 bits) */
int fgetw (FILE *file)
int fgetw(FILE *file)
{
int b1, b2;
@ -969,7 +967,7 @@ int fgetw (FILE *file)
}
/* returns a dword (32 bits) */
long fgetl (FILE *file)
long fgetl(FILE *file)
{
int b1, b2, b3, b4;
@ -994,7 +992,7 @@ long fgetl (FILE *file)
}
/* returns 0 in success or -1 in error */
int fputw (int w, FILE *file)
int fputw(int w, FILE *file)
{
int b1, b2;
@ -1010,7 +1008,7 @@ int fputw (int w, FILE *file)
}
/* returns 0 in success or -1 in error */
int fputl (long l, FILE *file)
int fputl(long l, FILE *file)
{
int b1, b2, b3, b4;
@ -1031,7 +1029,7 @@ int fputl (long l, FILE *file)
#if 0
/* returns a floating point (32 bits) */
static float fgetf (FILE *file)
static float fgetf(FILE *file)
{
union {
float f;
@ -1044,7 +1042,7 @@ static float fgetf (FILE *file)
}
/* returns a floating point with double precision (64 bits) */
static double fgetd (FILE *file)
static double fgetd(FILE *file)
{
union {
double d;
@ -1058,7 +1056,7 @@ static double fgetd (FILE *file)
}
/* returns 0 in success or -1 in error */
static int fputf (float c, FILE *file)
static int fputf(float c, FILE *file)
{
union {
float f;
@ -1070,7 +1068,7 @@ static int fputf (float c, FILE *file)
}
/* returns 0 in success or -1 in error */
static int fputd (double c, FILE *file)
static int fputd(double c, FILE *file)
{
union {
double d;

View File

@ -45,7 +45,7 @@ static struct {
Layer *layer;
int frpos;
Image *last_image;
Frame *last_frame;
Cel *last_cel;
/* to save */
Image *image;
} file_sequence;
@ -106,7 +106,7 @@ Image *file_sequence_image(int imgtype, int w, int h)
/* create a bitmap */
if (file_sequence.last_frame) {
if (file_sequence.last_cel) {
console_printf(_("Error: called two times \"file_sequence_image ()\".\n"));
return NULL;
}
@ -118,7 +118,7 @@ Image *file_sequence_image(int imgtype, int w, int h)
}
file_sequence.last_image = image;
file_sequence.last_frame = frame_new(file_sequence.frpos++, 0);
file_sequence.last_cel = cel_new(file_sequence.frpos++, 0);
return image;
}
@ -198,17 +198,17 @@ Sprite *sprite_load(const char *filename)
index = stock_add_image(file_sequence.layer->stock, \
file_sequence.last_image); \
\
file_sequence.last_frame->image = index; \
file_sequence.last_cel->image = index; \
\
layer_add_frame(file_sequence.layer, \
file_sequence.last_frame); \
layer_add_cel(file_sequence.layer, \
file_sequence.last_cel); \
\
sprite_set_palette(file_sequence.sprite, file_palette, c); \
\
old_image = file_sequence.last_image; \
\
file_sequence.last_image = NULL; \
file_sequence.last_frame = NULL; \
file_sequence.last_cel = NULL; \
} while (0)
char buf[512], left[512], right[512];
@ -264,7 +264,7 @@ Sprite *sprite_load(const char *filename)
file_sequence.layer = NULL;
file_sequence.frpos = 0;
file_sequence.last_image = NULL;
file_sequence.last_frame = NULL;
file_sequence.last_cel = NULL;
/* load the sequence */
c = 0;
@ -281,12 +281,12 @@ Sprite *sprite_load(const char *filename)
/* for the first frame */
if (!old_image) {
/* error reading the first frame */
if ((!sprite) || (!file_sequence.last_frame)) {
if ((!sprite) || (!file_sequence.last_cel)) {
if (file_sequence.last_image)
image_free(file_sequence.last_image);
if (file_sequence.last_frame)
frame_free(file_sequence.last_frame);
if (file_sequence.last_cel)
cel_free(file_sequence.last_cel);
if (file_sequence.sprite) {
sprite_free(file_sequence.sprite);
@ -307,12 +307,12 @@ Sprite *sprite_load(const char *filename)
/* for other frames */
else {
/* all done (or maybe not enough memory) */
if ((!sprite) || (!file_sequence.last_frame)) {
if ((!sprite) || (!file_sequence.last_cel)) {
if (file_sequence.last_image)
image_free (file_sequence.last_image);
image_free(file_sequence.last_image);
if (file_sequence.last_frame)
frame_free (file_sequence.last_frame);
if (file_sequence.last_cel)
cel_free(file_sequence.last_cel);
break;
}
@ -327,12 +327,12 @@ Sprite *sprite_load(const char *filename)
image_free(file_sequence.last_image);
/* but add a link frame */
file_sequence.last_frame->image = index;
file_sequence.last_cel->image = index;
layer_add_frame(file_sequence.layer,
file_sequence.last_frame);
file_sequence.last_cel);
file_sequence.last_image = NULL;
file_sequence.last_frame = NULL;
file_sequence.last_cel = NULL;
}
#else
SEQUENCE_IMAGE();

View File

@ -130,7 +130,7 @@ static Sprite *load_FLI(const char *filename)
/* add the new frame */
index = stock_add_image(layer->stock, image_new_copy(bmp));
layer_add_frame(layer, frame_new(frpos_out, index));
layer_add_cel(layer, cel_new(frpos_out, index));
/* first frame or the palette changes */
if ((frpos_in == 0) || (memcmp(omap, cmap, 768) != 0))
@ -142,7 +142,7 @@ static Sprite *load_FLI(const char *filename)
SETPAL();
/* add link */
layer_add_frame(layer, frame_new(frpos_out, index));
layer_add_cel(layer, cel_new(frpos_out, index));
}
/* the palette and the image don't change: add duration to the last added frame */
else {

View File

@ -82,8 +82,8 @@ static Sprite *load_GIF(const char *filename)
{
GIF_ANIMATION *gif = NULL;
Sprite *sprite = NULL;
Frame *frame = NULL;
Layer *layer = NULL;
Cel *cel = NULL;
Image *image = NULL;
Image *current_image_old = NULL;
Image *current_image = NULL;
@ -168,7 +168,7 @@ static Sprite *load_GIF(const char *filename)
/* copy new palette to old palette */
palette_copy(opal, npal);
frame = frame_new(i, 0);
cel = cel_new(i, 0);
image = image_new(IMAGE_INDEXED,
#ifdef LOAD_GIF_STRUCTURE
gif->frames[i].w,
@ -177,21 +177,21 @@ static Sprite *load_GIF(const char *filename)
sprite->w, sprite->h
#endif
);
if (!frame || !image) {
if (frame) frame_free(frame);
if (!cel || !image) {
if (cel) cel_free(cel);
if (image) image_free(image);
console_printf(_("Error creating frame %d.\n"), i);
console_printf(_("Error creating cel %d.\n"), i);
break;
}
frame_set_position(frame,
cel_set_position(cel,
#ifdef LOAD_GIF_STRUCTURE
gif->frames[i].xoff,
gif->frames[i].yoff
gif->frames[i].xoff,
gif->frames[i].yoff
#else
0, 0
0, 0
#endif
);
);
image_copy(current_image_old, current_image, 0, 0);
render_gif_frame(gif->frames+i, current_image,
@ -207,8 +207,8 @@ static Sprite *load_GIF(const char *filename)
0, 0
#endif
);
frame->image = stock_add_image(layer->stock, image);
layer_add_frame(layer, frame);
cel->image = stock_add_image(layer->stock, image);
layer_add_cel(layer, cel);
#ifdef LOAD_GIF_STRUCTURE
/* when load the GIF structure, the disposal method is ever

View File

@ -369,7 +369,7 @@ static Sprite *load_TGA (const char *filename)
}
else {
if (compressed) {
rle_tga_read16 (image->line[yc], image_width, f);
rle_tga_read16(image->line[yc], image_width, f);
}
else {
for (x=0; x<image_width; x++) {

View File

@ -52,7 +52,7 @@ int init_module_editors(void)
return 0;
}
void exit_module_editors (void)
void exit_module_editors(void)
{
jlist_free(editors);
}
@ -391,7 +391,7 @@ void make_unique_editor(JWidget editor)
editor_update(editor);
}
static int is_sprite_in_some_editor (Sprite *sprite)
static int is_sprite_in_some_editor(Sprite *sprite)
{
JWidget widget;
JLink link;

View File

@ -691,7 +691,7 @@ static bool manager_msg_proc(JWidget widget, JMessage msg)
case JM_IDLE:
gui_feedback();
/* don't eat CPU... rest some time */
rest(0);
rest(1);
break;
case JM_CHAR: {

View File

@ -120,13 +120,13 @@ void SetDrawMode (const char *string)
rectangle, ellipse
uses the current FG color
*/
void ToolTrace (const char *string)
void ToolTrace(const char *string)
{
Sprite *sprite = current_sprite;
if (sprite) {
Tool *old_current_tool = current_tool;
char *copy = jstrdup (string);
char *copy = jstrdup(string);
char *tok;
int count;
int npoints = 0;
@ -137,19 +137,19 @@ void ToolTrace (const char *string)
tok=strtok (NULL, " "), count++) {
switch (count) {
case 0:
select_tool (tok);
select_tool(tok);
break;
default: {
int u, v;
char *s;
u = (int)strtod (tok, &s);
u = (int)strtod(tok, &s);
if (s && *s == ',') {
v = (int)strtod (s+1, &s);
v = (int)strtod(s+1, &s);
npoints++;
x = jrealloc (x, sizeof (int)*npoints);
y = jrealloc (y, sizeof (int)*npoints);
x = jrealloc(x, sizeof (int)*npoints);
y = jrealloc(y, sizeof (int)*npoints);
x[npoints-1] = u;
y[npoints-1] = v;
}
@ -159,14 +159,14 @@ void ToolTrace (const char *string)
}
if (npoints > 0) {
do_tool_points (sprite, current_tool, get_fg_color (), npoints, x, y);
jfree (x);
jfree (y);
do_tool_points(sprite, current_tool, get_fg_color(), npoints, x, y);
jfree(x);
jfree(y);
}
select_tool (old_current_tool->name);
select_tool(old_current_tool->name);
jfree (copy);
jfree(copy);
}
}
@ -198,7 +198,7 @@ static int cfg_jpeg_smooth;
static int cfg_jpeg_quality;
static int cfg_jpeg_method;
void ResetConfig (void)
void ResetConfig(void)
{
JRect rect;

97
src/raster/cel.c Normal file
View File

@ -0,0 +1,97 @@
/* ASE - Allegro Sprite Editor
* Copyright (C) 2001-2005, 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 "raster/cel.h"
#include "raster/layer.h"
#endif
Cel *cel_new(int frpos, int image)
{
Cel *cel = (Cel *)gfxobj_new(GFXOBJ_CEL, sizeof(Cel));
if (!cel)
return NULL;
cel->frpos = frpos;
cel->image = image;
cel->x = 0;
cel->y = 0;
cel->opacity = 255;
return cel;
}
Cel *cel_new_copy(const Cel *cel)
{
Cel *cel_copy;
cel_copy = cel_new(cel->frpos, cel->image);
if (!cel_copy)
return NULL;
cel_set_position(cel_copy, cel->x, cel->y);
cel_set_opacity(cel_copy, cel->opacity);
return cel_copy;
}
void cel_free(Cel *cel)
{
gfxobj_free((GfxObj *)cel);
}
Cel *cel_is_link(Cel *cel, Layer *layer)
{
Cel *link;
int frpos;
for (frpos=0; frpos<cel->frpos; frpos++) {
link = layer_get_cel(layer, frpos);
if (link && link->image == cel->image)
return link;
}
return NULL;
}
/* warning, you must remove the cel from parent layer before to change
the frpos */
void cel_set_frpos(Cel *cel, int frpos)
{
cel->frpos = frpos;
}
void cel_set_image(Cel *cel, int image)
{
cel->image = image;
}
void cel_set_position(Cel *cel, int x, int y)
{
cel->x = x;
cel->y = y;
}
void cel_set_opacity(Cel *cel, int opacity)
{
cel->opacity = opacity;
}

View File

@ -16,16 +16,16 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef RASTER_FRAME_H
#define RASTER_FRAME_H
#ifndef RASTER_CEL_H
#define RASTER_CEL_H
#include "raster/gfxobj.h"
struct Layer;
typedef struct Frame Frame;
typedef struct Cel Cel;
struct Frame
struct Cel
{
GfxObj gfxobj;
int frpos; /* frame position */
@ -34,15 +34,15 @@ struct Frame
int opacity; /* opacity level */
};
Frame *frame_new (int frpos, int image);
Frame *frame_new_copy (const Frame *frame);
void frame_free (Frame *frame);
Cel *cel_new(int frpos, int image);
Cel *cel_new_copy(const Cel *cel);
void cel_free(Cel *cel);
Frame *frame_is_link (Frame *frame, struct Layer *layer);
Cel *cel_is_link(Cel *cel, struct Layer *layer);
void frame_set_frpos (Frame *frame, int frpos);
void frame_set_image (Frame *frame, int image);
void frame_set_position (Frame *frame, int x, int y);
void frame_set_opacity (Frame *frame, int opacity);
void cel_set_frpos(Cel *cel, int frpos);
void cel_set_image(Cel *cel, int image);
void cel_set_position(Cel *cel, int x, int y);
void cel_set_opacity(Cel *cel, int opacity);
#endif /* RASTER_FRAME_H */

View File

@ -1,97 +0,0 @@
/* ASE - Allegro Sprite Editor
* Copyright (C) 2001-2005, 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 "raster/frame.h"
#include "raster/layer.h"
#endif
Frame *frame_new (int frpos, int image)
{
Frame *frame = (Frame *)gfxobj_new (GFXOBJ_FRAME, sizeof(Frame));
if (!frame)
return NULL;
frame->frpos = frpos;
frame->image = image;
frame->x = 0;
frame->y = 0;
frame->opacity = 255;
return frame;
}
Frame *frame_new_copy (const Frame *frame)
{
Frame *frame_copy;
frame_copy = frame_new (frame->frpos, frame->image);
if (!frame_copy)
return NULL;
frame_set_position (frame_copy, frame->x, frame->y);
frame_set_opacity (frame_copy, frame->opacity);
return frame_copy;
}
void frame_free (Frame *frame)
{
gfxobj_free ((GfxObj *)frame);
}
Frame *frame_is_link (Frame *frame, Layer *layer)
{
Frame *link;
int frpos;
for (frpos=0; frpos<frame->frpos; frpos++) {
link = layer_get_frame (layer, frpos);
if (link && link->image == frame->image)
return link;
}
return NULL;
}
/* warning, you must remove the frame from parent layer before to
change the frpos */
void frame_set_frpos (Frame *frame, int frpos)
{
frame->frpos = frpos;
}
void frame_set_image (Frame *frame, int image)
{
frame->image = image;
}
void frame_set_position (Frame *frame, int x, int y)
{
frame->x = x;
frame->y = y;
}
void frame_set_opacity (Frame *frame, int opacity)
{
frame->opacity = opacity;
}

View File

@ -22,7 +22,7 @@
#include "jinete/base.h"
enum {
GFXOBJ_FRAME,
GFXOBJ_CEL,
GFXOBJ_IMAGE,
GFXOBJ_LAYER_IMAGE,
GFXOBJ_LAYER_SET,

View File

@ -75,17 +75,18 @@ struct Image
/* struct BITMAP *bmp; */
};
typedef struct ImageMethods {
int (*init) (Image *image);
int (*getpixel) (const Image *image, int x, int y);
void (*putpixel) (Image *image, int x, int y, int color);
void (*clear) (Image *image, int color);
void (*copy) (Image *dst, const Image *src, int x, int y);
void (*merge) (Image *dst, const Image *src, int x, int y, int opacity,
int blend_mode);
void (*hline) (Image *image, int x1, int y, int x2, int color);
void (*rectfill) (Image *image, int x1, int y1, int x2, int y2, int color);
void (*to_allegro) (const Image *image, struct BITMAP *bmp, int x, int y);
typedef struct ImageMethods
{
int (*init)(Image *image);
int (*getpixel)(const Image *image, int x, int y);
void (*putpixel)(Image *image, int x, int y, int color);
void (*clear)(Image *image, int color);
void (*copy)(Image *dst, const Image *src, int x, int y);
void (*merge)(Image *dst, const Image *src, int x, int y, int opacity,
int blend_mode);
void (*hline)(Image *image, int x1, int y, int x2, int color);
void (*rectfill)(Image *image, int x1, int y1, int x2, int y2, int color);
void (*to_allegro)(const Image *image, struct BITMAP *bmp, int x, int y);
} ImageMethods;
Image *image_new(int imgtype, int w, int h);

View File

@ -25,14 +25,14 @@
#include "jinete/list.h"
#include "raster/blend.h"
#include "raster/frame.h"
#include "raster/cel.h"
#include "raster/image.h"
#include "raster/layer.h"
#include "raster/stock.h"
#endif
static int has_frames (Layer *layer, int frpos);
static int has_cels(Layer *layer, int frpos);
#define LAYER_INIT(name_string) \
do { \
@ -45,7 +45,7 @@ static int has_frames (Layer *layer, int frpos);
layer->imgtype = 0; \
layer->blend_mode = 0; \
layer->stock = NULL; \
layer->frames = NULL; \
layer->cels = NULL; \
\
layer->layers = NULL; \
} while (0);
@ -62,7 +62,7 @@ Layer *layer_new(int imgtype)
layer->imgtype = imgtype;
layer->blend_mode = BLEND_MODE_NORMAL;
layer->stock = stock_new(imgtype);
layer->frames = jlist_new();
layer->cels = jlist_new();
return layer;
}
@ -110,7 +110,7 @@ Layer *layer_new_copy(const Layer *layer)
switch (layer->gfxobj.type) {
case GFXOBJ_LAYER_IMAGE: {
Frame *frame_copy;
Cel *cel_copy;
JLink link;
layer_copy = layer_new(layer->imgtype);
@ -127,14 +127,14 @@ Layer *layer_new_copy(const Layer *layer)
return NULL;
}
/* copy frames */
JI_LIST_FOR_EACH(layer->frames, link) {
frame_copy = frame_new_copy(link->data);
if (!frame_copy) {
/* copy cels */
JI_LIST_FOR_EACH(layer->cels, link) {
cel_copy = cel_new_copy(link->data);
if (!cel_copy) {
layer_free(layer_copy);
return NULL;
}
layer_add_frame(layer_copy, frame_copy);
layer_add_cel(layer_copy, cel_copy);
}
break;
}
@ -180,7 +180,7 @@ Layer *layer_new_copy(const Layer *layer)
Layer *layer_new_with_image(int imgtype, int x, int y, int w, int h, int frpos)
{
Layer *layer;
Frame *frame;
Cel *cel;
Image *image;
int index;
@ -206,12 +206,12 @@ Layer *layer_new_with_image(int imgtype, int x, int y, int w, int h, int frpos)
/* add image in the layer stock */
index = stock_add_image(layer->stock, image);
/* create the frame */
frame = frame_new(frpos, index);
frame_set_position (frame, x, y);
/* create the cel */
cel = cel_new(frpos, index);
cel_set_position(cel, x, y);
/* add the frame in the layer */
layer_add_frame(layer, frame);
/* add the cel in the layer */
layer_add_cel(layer, cel);
return layer;
}
@ -227,11 +227,11 @@ void layer_free (Layer *layer)
if (layer->stock)
stock_free(layer->stock);
/* remove frames */
JI_LIST_FOR_EACH(layer->frames, link)
frame_free(link->data);
/* remove cels */
JI_LIST_FOR_EACH(layer->cels, link)
cel_free(link->data);
jlist_free(layer->frames);
jlist_free(layer->cels);
break;
}
@ -243,6 +243,7 @@ void layer_free (Layer *layer)
}
case GFXOBJ_LAYER_TEXT:
/* TODO */
/* if (layer->text) */
/* r_free (layer->text); */
@ -256,13 +257,13 @@ void layer_free (Layer *layer)
}
/* returns TRUE if "layer" is a normal layer type (an image layer) */
int layer_is_image (const Layer *layer)
int layer_is_image(const Layer *layer)
{
return (layer->gfxobj.type == GFXOBJ_LAYER_IMAGE) ? TRUE: FALSE;
}
/* returns TRUE if "layer" is a set of layers */
int layer_is_set (const Layer *layer)
int layer_is_set(const Layer *layer)
{
return (layer->gfxobj.type == GFXOBJ_LAYER_SET) ? TRUE: FALSE;
}
@ -290,51 +291,51 @@ Layer *layer_get_next(Layer *layer)
return NULL;
}
void layer_set_name (Layer *layer, const char *name)
void layer_set_name(Layer *layer, const char *name)
{
strcpy (layer->name, name);
strcpy(layer->name, name);
}
void layer_set_blend_mode (Layer *layer, int blend_mode)
void layer_set_blend_mode(Layer *layer, int blend_mode)
{
if (layer->gfxobj.type == GFXOBJ_LAYER_IMAGE)
layer->blend_mode = blend_mode;
}
void layer_set_parent (Layer *layer, GfxObj *gfxobj)
void layer_set_parent(Layer *layer, GfxObj *gfxobj)
{
layer->parent = gfxobj;
}
void layer_add_frame(Layer *layer, Frame *frame)
void layer_add_cel(Layer *layer, Cel *cel)
{
if (layer_is_image(layer)) {
JLink link;
JI_LIST_FOR_EACH(layer->frames, link)
if (((Frame *)link->data)->frpos >= frame->frpos)
JI_LIST_FOR_EACH(layer->cels, link)
if (((Cel *)link->data)->frpos >= cel->frpos)
break;
jlist_insert_before(layer->frames, link, frame);
jlist_insert_before(layer->cels, link, cel);
}
}
void layer_remove_frame(Layer *layer, Frame *frame)
void layer_remove_cel(Layer *layer, Cel *cel)
{
if (layer_is_image(layer))
jlist_remove(layer->frames, frame);
jlist_remove(layer->cels, cel);
}
Frame *layer_get_frame(Layer *layer, int frpos)
Cel *layer_get_cel(Layer *layer, int frpos)
{
if (layer_is_image(layer)) {
Frame *frame;
Cel *cel;
JLink link;
JI_LIST_FOR_EACH(layer->frames, link) {
frame = link->data;
if (frame->frpos == frpos)
return frame;
JI_LIST_FOR_EACH(layer->cels, link) {
cel = link->data;
if (cel->frpos == frpos)
return cel;
}
}
@ -379,21 +380,21 @@ void layer_render(Layer *layer, Image *image, int x, int y, int frpos)
switch (layer->gfxobj.type) {
case GFXOBJ_LAYER_IMAGE: {
Frame *frame = layer_get_frame (layer, frpos);
Cel *cel = layer_get_cel(layer, frpos);
Image *src_image;
if (frame) {
if ((frame->image >= 0) &&
(frame->image < layer->stock->nimage))
src_image = layer->stock->image[frame->image];
if (cel) {
if ((cel->image >= 0) &&
(cel->image < layer->stock->nimage))
src_image = layer->stock->image[cel->image];
else
src_image = NULL;
if (src_image) {
image_merge(image, src_image,
frame->x + x,
frame->y + y,
MID (0, frame->opacity, 255),
cel->x + x,
cel->y + y,
MID (0, cel->opacity, 255),
layer->blend_mode);
}
}
@ -413,16 +414,18 @@ void layer_render(Layer *layer, Image *image, int x, int y, int frpos)
}
}
/* returns a new layer (flat_layer) with all "layer" rendered frames
by frame from "frmin" to "frmax" (inclusive). "layer" can be a set
of layers, so the routines flatten all childs to the unique output
layer */
/**
* Returns a new layer (flat_layer) with all "layer" rendered frame
* by frame from "frmin" to "frmax" (inclusive). "layer" can be a set
* of layers, so the routines flatten all childs to the unique output
* layer.
*/
Layer *layer_flatten(Layer *layer, int imgtype,
int x, int y, int w, int h, int frmin, int frmax)
{
Layer *flat_layer;
Image *image;
Frame *frame;
Cel *cel;
int frpos;
flat_layer = layer_new(imgtype);
@ -432,8 +435,8 @@ Layer *layer_flatten(Layer *layer, int imgtype,
layer_set_name(flat_layer, "Flat Layer");
for (frpos=frmin; frpos<=frmax; frpos++) {
/* this "frpos" has frames to render */
if (has_frames(layer, frpos)) {
/* does this "frpos" have cels to render? */
if (has_cels(layer, frpos)) {
/* create a new image */
image = image_new(imgtype, w, h);
if (!image) {
@ -441,11 +444,11 @@ Layer *layer_flatten(Layer *layer, int imgtype,
return NULL;
}
/* create the new frame for the output layer (add the image to
/* create the new cel for the output layer (add the image to
stock too) */
frame = frame_new(frpos, stock_add_image(flat_layer->stock, image));
frame_set_position(frame, x, y);
if (!frame) {
cel = cel_new(frpos, stock_add_image(flat_layer->stock, image));
cel_set_position(cel, x, y);
if (!cel) {
layer_free(flat_layer);
image_free(image);
return NULL;
@ -454,15 +457,15 @@ Layer *layer_flatten(Layer *layer, int imgtype,
/* clear the image and render this frame */
image_clear(image, 0);
layer_render(layer, image, -x, -y, frpos);
layer_add_frame(flat_layer, frame);
layer_add_cel(flat_layer, cel);
}
}
return flat_layer;
}
/* returns TRUE if the "layer" (or him childs) has frames to render in frpos */
static int has_frames(Layer *layer, int frpos)
/* returns TRUE if the "layer" (or him childs) has cels to render in frpos */
static int has_cels(Layer *layer, int frpos)
{
if (!layer->readable)
return FALSE;
@ -470,18 +473,19 @@ static int has_frames(Layer *layer, int frpos)
switch (layer->gfxobj.type) {
case GFXOBJ_LAYER_IMAGE:
return layer_get_frame(layer, frpos) ? TRUE: FALSE;
return layer_get_cel(layer, frpos) ? TRUE: FALSE;
case GFXOBJ_LAYER_SET: {
JLink link;
JI_LIST_FOR_EACH(layer->layers, link)
if (has_frames(link->data, frpos))
JI_LIST_FOR_EACH(layer->layers, link) {
if (has_cels(link->data, frpos))
return TRUE;
}
break;
}
case GFXOBJ_LAYER_TEXT:
/* XXX */
/* TODO */
break;
}

View File

@ -22,7 +22,7 @@
#include "jinete/base.h"
#include "raster/gfxobj.h"
struct Frame;
struct Cel;
struct Image;
struct Stock;
@ -40,7 +40,7 @@ struct Layer
int imgtype; /* image type */
int blend_mode; /* constant blend mode */
struct Stock *stock; /* stock to get images */
JList frames; /* list of frames */
JList cels; /* list of cels */
/* for GFXOBJ_LAYER_SET */
JList layers;
@ -72,9 +72,9 @@ void layer_set_blend_mode(Layer *layer, int blend_mode);
void layer_set_parent(Layer *layer, GfxObj *gfxobj);
/* for LAYER_IMAGE */
void layer_add_frame(Layer *layer, struct Frame *frame);
void layer_remove_frame(Layer *layer, struct Frame *frame);
struct Frame *layer_get_frame(Layer *layer, int frpos);
void layer_add_cel(Layer *layer, struct Cel *cel);
void layer_remove_cel(Layer *layer, struct Cel *cel);
struct Cel *layer_get_cel(Layer *layer, int frpos);
/* for LAYER_SET */
void layer_add_layer(Layer *set, Layer *layer);

View File

@ -22,8 +22,8 @@
#include "raster/algo.h"
#include "raster/blend.h"
#include "raster/brush.h"
#include "raster/cel.h"
#include "raster/dirty.h"
#include "raster/frame.h"
#include "raster/gfxobj.h"
#include "raster/image.h"
#include "raster/layer.h"

View File

@ -459,14 +459,14 @@ void sprite_add_mask (Sprite *sprite, Mask *mask)
}
/* removes a mask from the sprites's repository */
void sprite_remove_mask (Sprite *sprite, Mask *mask)
void sprite_remove_mask(Sprite *sprite, Mask *mask)
{
/* remove the mask from the repository */
jlist_remove(sprite->repository.masks, mask);
}
/* returns a mask from the sprite's repository searching it by its name */
Mask *sprite_request_mask (Sprite *sprite, const char *name)
Mask *sprite_request_mask(Sprite *sprite, const char *name)
{
Mask *mask;
JLink link;

View File

@ -26,8 +26,8 @@
#include "jinete/list.h"
#include "raster/cel.h"
#include "raster/dirty.h"
#include "raster/frame.h"
#include "raster/image.h"
#include "raster/layer.h"
#include "raster/mask.h"
@ -62,9 +62,9 @@ enum {
UNDO_TYPE_REMOVE_IMAGE,
UNDO_TYPE_REPLACE_IMAGE,
/* frame management */
UNDO_TYPE_ADD_FRAME,
UNDO_TYPE_REMOVE_FRAME,
/* cel management */
UNDO_TYPE_ADD_CEL,
UNDO_TYPE_REMOVE_CEL,
/* layer management */
UNDO_TYPE_ADD_LAYER,
@ -131,11 +131,11 @@ static void redo_remove_image(UndoStream *stream, UndoChunk *chunk, int state);
static void chunk_replace_image(UndoStream *stream, Stock *stock, int index);
static void redo_replace_image(UndoStream *stream, UndoChunk *chunk, int state);
static void chunk_add_frame(UndoStream *stream, Layer *layer, Frame *frame);
static void redo_add_frame(UndoStream *stream, UndoChunk *chunk, int state);
static void chunk_add_cel(UndoStream *stream, Layer *layer, Cel *cel);
static void redo_add_cel(UndoStream *stream, UndoChunk *chunk, int state);
static void chunk_remove_frame(UndoStream *stream, Layer *layer, Frame *frame);
static void redo_remove_frame(UndoStream *stream, UndoChunk *chunk, int state);
static void chunk_remove_cel(UndoStream *stream, Layer *layer, Cel *cel);
static void redo_remove_cel(UndoStream *stream, UndoChunk *chunk, int state);
static void chunk_add_layer(UndoStream *stream, Layer *set, Layer *layer);
static void redo_add_layer(UndoStream *stream, UndoChunk *chunk, int state);
@ -165,8 +165,8 @@ static UndoAction undo_actions[] = { /* in UNDO_TYPEs order */
{ "Add image", redo_add_image },
{ "Remove image", redo_remove_image },
{ "Replace image", redo_replace_image },
{ "Add frame", redo_add_frame },
{ "Remove frame", redo_remove_frame },
{ "Add cel", redo_add_cel },
{ "Remove cel", redo_remove_cel },
{ "Add layer", redo_add_layer },
{ "Remove layer", redo_remove_layer },
{ "Move layer", redo_move_layer },
@ -198,8 +198,8 @@ static void undo_chunk_write(UndoChunk *chunk, const unsigned char *buf, int siz
static char *undo_chunk_read_string(UndoChunk *chunk);
static void undo_chunk_write_string(UndoChunk *chunk, const char *string);
static Frame *undo_chunk_read_frame(UndoChunk *chunk);
static void undo_chunk_write_frame(UndoChunk *chunk, Frame *frame);
static Cel *undo_chunk_read_cel(UndoChunk *chunk);
static void undo_chunk_write_cel(UndoChunk *chunk, Cel *cel);
static Layer *undo_chunk_read_layer(UndoChunk *chunk);
static void undo_chunk_write_layer(UndoChunk *chunk, Layer *layer);
@ -746,7 +746,7 @@ static void redo_dirty(UndoStream *stream, UndoChunk *chunk, int state)
/***********************************************************************
"add_frame"
"add_image"
DWORD stock ID
DWORD index
@ -887,80 +887,80 @@ static void redo_replace_image(UndoStream *stream, UndoChunk *chunk, int state)
/***********************************************************************
"add_frame"
"add_cel"
DWORD layer ID
DWORD frame ID
DWORD cel ID
***********************************************************************/
void undo_add_frame(Undo *undo, Layer *layer, Frame *frame)
void undo_add_cel(Undo *undo, Layer *layer, Cel *cel)
{
chunk_add_frame(undo->undo_stream, layer, frame);
chunk_add_cel(undo->undo_stream, layer, cel);
update_undo(undo);
}
static void chunk_add_frame(UndoStream *stream, Layer *layer, Frame *frame)
static void chunk_add_cel(UndoStream *stream, Layer *layer, Cel *cel)
{
UndoChunk *chunk = undo_chunk_new(UNDO_TYPE_ADD_FRAME);
UndoChunk *chunk = undo_chunk_new(UNDO_TYPE_ADD_CEL);
undo_chunk_put32(chunk, layer->gfxobj.id);
undo_chunk_put32(chunk, frame->gfxobj.id);
undo_chunk_put32(chunk, cel->gfxobj.id);
undo_stream_push_chunk(stream, chunk);
}
static void redo_add_frame(UndoStream *stream, UndoChunk *chunk, int state)
static void redo_add_cel(UndoStream *stream, UndoChunk *chunk, int state)
{
unsigned long layer_id = undo_chunk_get32(chunk);
unsigned long frame_id = undo_chunk_get32(chunk);
unsigned long cel_id = undo_chunk_get32(chunk);
Layer *layer = (Layer *)gfxobj_find(layer_id);
Frame *frame = (Frame *)gfxobj_find(frame_id);
Cel *cel = (Cel *)gfxobj_find(cel_id);
if (layer && frame) {
chunk_remove_frame(stream, layer, frame);
layer_remove_frame(layer, frame);
frame_free(frame);
if (layer && cel) {
chunk_remove_cel(stream, layer, cel);
layer_remove_cel(layer, cel);
cel_free(cel);
}
}
/***********************************************************************
"remove_frame"
"remove_cel"
DWORD layer ID
FRAME_DATA see undo_chunk_read/write_frame
CEL_DATA see undo_chunk_read/write_cel
***********************************************************************/
void undo_remove_frame(Undo *undo, Layer *layer, Frame *frame)
void undo_remove_cel(Undo *undo, Layer *layer, Cel *cel)
{
chunk_remove_frame(undo->undo_stream, layer, frame);
chunk_remove_cel(undo->undo_stream, layer, cel);
update_undo(undo);
}
static void chunk_remove_frame(UndoStream *stream, Layer *layer, Frame *frame)
static void chunk_remove_cel(UndoStream *stream, Layer *layer, Cel *cel)
{
UndoChunk *chunk = undo_chunk_new(UNDO_TYPE_REMOVE_FRAME);
UndoChunk *chunk = undo_chunk_new(UNDO_TYPE_REMOVE_CEL);
undo_chunk_put32(chunk, layer->gfxobj.id);
undo_chunk_write_frame(chunk, frame);
undo_chunk_write_cel(chunk, cel);
undo_stream_push_chunk(stream, chunk);
}
static void redo_remove_frame(UndoStream *stream, UndoChunk *chunk, int state)
static void redo_remove_cel(UndoStream *stream, UndoChunk *chunk, int state)
{
unsigned long layer_id = undo_chunk_get32(chunk);
Layer *layer = (Layer *)gfxobj_find(layer_id);
if (layer) {
Frame *frame = undo_chunk_read_frame(chunk);
Cel *cel = undo_chunk_read_cel(chunk);
/* ji_assert (frame); */
/* ji_assert (cel); */
chunk_add_frame(stream, layer, frame);
layer_add_frame(layer, frame);
chunk_add_cel(stream, layer, cel);
layer_add_cel(layer, cel);
}
}
@ -1383,30 +1383,30 @@ static void undo_chunk_write_string(UndoChunk *chunk, const char *string)
undo_chunk_write(chunk, string, count);
}
static Frame *undo_chunk_read_frame(UndoChunk *chunk)
static Cel *undo_chunk_read_cel(UndoChunk *chunk)
{
unsigned long frame_id = undo_chunk_get32(chunk);
unsigned long cel_id = undo_chunk_get32(chunk);
int frpos = undo_chunk_get16(chunk);
int image = undo_chunk_get16(chunk);
int x = (short)undo_chunk_get16(chunk);
int y = (short)undo_chunk_get16(chunk);
int opacity = undo_chunk_get8(chunk);
Frame *frame = frame_new(frpos, image);
frame_set_position(frame, x, y);
frame_set_opacity(frame, opacity);
Cel *cel = cel_new(frpos, image);
cel_set_position(cel, x, y);
cel_set_opacity(cel, opacity);
_gfxobj_set_id ((GfxObj *)frame, frame_id);
return frame;
_gfxobj_set_id((GfxObj *)cel, cel_id);
return cel;
}
static void undo_chunk_write_frame(UndoChunk *chunk, Frame *frame)
static void undo_chunk_write_cel(UndoChunk *chunk, Cel *cel)
{
undo_chunk_put32(chunk, frame->gfxobj.id);
undo_chunk_put16(chunk, frame->frpos);
undo_chunk_put16(chunk, frame->image);
undo_chunk_put16(chunk, frame->x);
undo_chunk_put16(chunk, frame->y);
undo_chunk_put8(chunk, frame->opacity);
undo_chunk_put32(chunk, cel->gfxobj.id);
undo_chunk_put16(chunk, cel->frpos);
undo_chunk_put16(chunk, cel->image);
undo_chunk_put16(chunk, cel->x);
undo_chunk_put16(chunk, cel->y);
undo_chunk_put8(chunk, cel->opacity);
}
static Layer *undo_chunk_read_layer(UndoChunk *chunk)
@ -1423,7 +1423,7 @@ static Layer *undo_chunk_read_layer(UndoChunk *chunk)
int imgtype = undo_chunk_get8(chunk); /* imgtype */
int blend_mode = undo_chunk_get8(chunk); /* blend mode */
Stock *stock = undo_chunk_read_stock(chunk); /* stock */
int c, frames = undo_chunk_get16(chunk); /* how many frames */
int c, cels = undo_chunk_get16(chunk); /* how many cels */
/* create layer */
layer = layer_new(imgtype);
@ -1435,9 +1435,9 @@ static Layer *undo_chunk_read_layer(UndoChunk *chunk)
stock_free(layer->stock);
layer->stock = stock;
/* read frames */
for (c=0; c<frames; c++)
layer_add_frame(layer, undo_chunk_read_frame(chunk));
/* read cels */
for (c=0; c<cels; c++)
layer_add_cel(layer, undo_chunk_read_cel(chunk));
break;
}
@ -1498,10 +1498,10 @@ static void undo_chunk_write_layer(UndoChunk *chunk, Layer *layer)
undo_chunk_put8(chunk, layer->blend_mode); /* blend mode */
/* stock */
undo_chunk_write_stock(chunk, layer->stock); /* stock */
/* frames */
undo_chunk_put16(chunk, jlist_length(layer->frames));
JI_LIST_FOR_EACH(layer->frames, link)
undo_chunk_write_frame(chunk, link->data);
/* cels */
undo_chunk_put16(chunk, jlist_length(layer->cels));
JI_LIST_FOR_EACH(layer->cels, link)
undo_chunk_write_cel(chunk, link->data);
break;
case GFXOBJ_LAYER_SET:

View File

@ -23,8 +23,8 @@
#include "raster/gfxobj.h"
struct Cel;
struct Dirty;
struct Frame;
struct Image;
struct Layer;
struct Mask;
@ -70,8 +70,8 @@ void undo_dirty(Undo *undo, struct Dirty *dirty);
void undo_add_image(Undo *undo, struct Stock *stock, struct Image *image);
void undo_remove_image(Undo *undo, struct Stock *stock, struct Image *image);
void undo_replace_image(Undo *undo, struct Stock *stock, int index);
void undo_add_frame(Undo *undo, struct Layer *layer, struct Frame *frame);
void undo_remove_frame(Undo *undo, struct Layer *layer, struct Frame *frame);
void undo_add_cel(Undo *undo, struct Layer *layer, struct Cel *cel);
void undo_remove_cel(Undo *undo, struct Layer *layer, struct Cel *cel);
void undo_add_layer(Undo *undo, struct Layer *set, struct Layer *layer);
void undo_remove_layer(Undo *undo, struct Layer *layer);
void undo_move_layer(Undo *undo, struct Layer *layer);

View File

@ -54,7 +54,7 @@ enum {
/* graphic objects */
Type_Image,
Type_Frame,
Type_Cel,
Type_Layer,
Type_Mask,
Type_Path,
@ -249,20 +249,20 @@ static int metatable_index(lua_State *L)
break;
}
case Type_Frame: {
Frame *frame = userdata->ptr;
case Type_Cel: {
Cel *cel = userdata->ptr;
if (strcmp (index, "frpos") == 0)
lua_pushnumber (L, frame->frpos);
lua_pushnumber (L, cel->frpos);
else if (strcmp (index, "image") == 0)
lua_pushnumber (L, frame->image);
lua_pushnumber (L, cel->image);
else if (strcmp (index, "x") == 0)
lua_pushnumber (L, frame->x);
lua_pushnumber (L, cel->x);
else if (strcmp (index, "y") == 0)
lua_pushnumber (L, frame->y);
lua_pushnumber (L, cel->y);
else if (strcmp (index, "opacity") == 0)
lua_pushnumber (L, frame->opacity);
/* XXXX */
lua_pushnumber (L, cel->opacity);
/* TODO */
/* else if (strcmp (index, "next") == 0) */
/* lua_pushnumber (L, ); */
/* else if (strcmp (index, "prev") == 0) */
@ -303,9 +303,9 @@ static int metatable_index(lua_State *L)
lua_pushnumber (L, layer->blend_mode);
else if (strcmp (index, "stock") == 0)
push_userdata (L, Type_Stock, layer->stock);
else if (strcmp (index, "frames") == 0)
push_userdata (L, Type_Frame,
jlist_first_data(layer->frames));
else if (strcmp (index, "cels") == 0)
push_userdata(L, Type_Cel,
jlist_first_data(layer->cels));
else
return 0;
break;
@ -731,9 +731,9 @@ static int bind_jwidget_hook_signal (lua_State *L)
#include "intl/intl.h"
#include "modules/rootmenu.h"
#include "util/autocrop.h"
#include "util/celmove.h"
#include "util/clipbrd.h"
#include "util/crop.h"
#include "util/frmove.h"
#include "util/mapgen.h"
#include "util/msk_file.h"
#include "util/quantize.h"

View File

@ -223,15 +223,15 @@ void paste_from_clipboard(void);
void crop_sprite(void);
void crop_layer(void);
void crop_frame(void);
void crop_cel(void);
/* util/frame.c */
/* util/celmove.c */
void set_frame_to_handle(Layer *layer, Frame *frame);
void set_cel_to_handle(Layer *layer, Cel *cel);
void move_frame(void);
void copy_frame(void);
void link_frame(void);
void move_cel(void);
void copy_cel(void);
void link_cel(void);
/* util/mapgen.c */
@ -303,7 +303,7 @@ Image *RenderText(const char *fontname, int size, int color, const char *text);
#define GFXOBJ_IMAGE
#define GFXOBJ_STOCK
#define GFXOBJ_FRAME
#define GFXOBJ_CEL
#define GFXOBJ_LAYER_IMAGE
#define GFXOBJ_LAYER_SET
#define GFXOBJ_LAYER_TEXT
@ -387,18 +387,18 @@ void image_scale(Image *dst, Image *src, int x, int y, int w, int h);
void image_rotate(Image *dst, Image *src, int x, int y, int w, int h, int cx, int cy, double angle);
void image_parallelogram(Image *bmp, Image *sprite, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
/* Frame ************************************************************/
/* Cel ************************************************************/
Frame *frame_new(int frpos, int image);
Frame *frame_new_copy(Frame *frame);
void frame_free(Frame *frame);
Cel *cel_new(int frpos, int image);
Cel *cel_new_copy(Cel *cel);
void cel_free(Cel *cel);
Frame *frame_is_link(Frame *frame, Layer *layer);
Cel *cel_is_link(Cel *cel, Layer *layer);
void frame_set_frpos(Frame *frame, int frpos);
void frame_set_image(Frame *frame, int image);
void frame_set_position(Frame *frame, int x, int y);
void frame_set_opacity(Frame *frame, int opacity);
void cel_set_frpos(Cel *cel, int frpos);
void cel_set_image(Cel *cel, int image);
void cel_set_position(Cel *cel, int x, int y);
void cel_set_opacity(Cel *cel, int opacity);
/* Layer ************************************************************/
@ -420,9 +420,9 @@ void layer_set_blend_mode(Layer *layer, int blend_mode);
/* void layer_set_parent(Layer *layer, GfxObj *gfxobj); */
/* for LAYER_IMAGE */
void layer_add_frame(Layer *layer, Frame *frame);
void layer_remove_frame(Layer *layer, Frame *frame);
Frame *layer_get_frame(Layer *layer, int frpos);
void layer_add_cel(Layer *layer, Cel *cel);
void layer_remove_cel(Layer *layer, Cel *cel);
Cel *layer_get_cel(Layer *layer, int frpos);
/* for LAYER_SET */
void layer_add_layer(Layer *set, Layer *layer);
@ -554,8 +554,8 @@ void undo_flip(Undo *undo, Image *image, int x1, int y1, int x2, int y2, int hor
void undo_add_image(Undo *undo, Stock *stock, Image *image);
void undo_remove_image(Undo *undo, Stock *stock, Image *image);
void undo_replace_image(Undo *undo, Stock *stock, int index);
void undo_add_frame(Undo *undo, Layer *layer, Frame *frame);
void undo_remove_frame(Undo *undo, Layer *layer, Frame *frame);
void undo_add_cel(Undo *undo, Layer *layer, Cel *cel);
void undo_remove_cel(Undo *undo, Layer *layer, Cel *cel);
void undo_add_layer(Undo *undo, Layer *set, Layer *layer);
void undo_remove_layer(Undo *undo, Layer *layer);
void undo_move_layer(Undo *undo, Layer *layer);

View File

@ -26,8 +26,8 @@
#include "modules/gui.h"
#include "modules/sprites.h"
#include "raster/blend.h"
#include "raster/cel.h"
#include "raster/image.h"
#include "raster/frame.h"
#include "raster/layer.h"
#include "raster/sprite.h"
#include "raster/stock.h"
@ -85,7 +85,7 @@ Layer *NewLayer(const char *name, int x, int y, int w, int h)
Sprite *sprite = current_sprite;
Layer *layer = NULL;
Image *image;
Frame *frame;
Cel *cel;
int index;
if (sprite && name) {
@ -114,12 +114,12 @@ Layer *NewLayer(const char *name, int x, int y, int w, int h)
/* add image in the layer stock */
index = stock_add_image(layer->stock, image);
/* create a new frame in the current frpos */
frame = frame_new(sprite->frpos, index);
frame_set_position(frame, x, y);
/* create a new cel in the current frame */
cel = cel_new(sprite->frpos, index);
cel_set_position(cel, x, y);
/* add frame */
layer_add_frame(layer, frame);
/* add cel */
layer_add_cel(layer, cel);
/* undo stuff */
if (undo_is_enabled(sprite->undo)) {
@ -244,13 +244,15 @@ Layer *FlattenLayers(void)
JI_LIST_FOR_EACH_SAFE(sprite->set->layers, link, next) {
if (link->data != flat_layer) {
Layer *old_layer = link->data;
/* undo */
if (undo_is_enabled(sprite->undo))
undo_remove_layer(sprite->undo, link->data);
undo_remove_layer(sprite->undo, old_layer);
/* remove and destroy this layer */
layer_remove_layer(sprite->set, link->data);
layer_free(link->data);
layer_remove_layer(sprite->set, old_layer);
layer_free(old_layer);
}
}
@ -264,24 +266,24 @@ Layer *FlattenLayers(void)
}
/* ======================================= */
/* Frame */
/* Cel */
/* ======================================= */
void RemoveFrame(Layer *layer, Frame *frame)
void RemoveCel(Layer *layer, Cel *cel)
{
Sprite *sprite = current_sprite;
Image *image;
Frame *it;
Cel *it;
int frpos;
bool used;
if (sprite != NULL && layer_is_image(layer) && frame != NULL) {
/* find if the image that use the frame to remove, is used by
another frames */
if (sprite != NULL && layer_is_image(layer) && cel != NULL) {
/* find if the image that use the cel to remove, is used by
another cels */
used = FALSE;
for (frpos=0; frpos<sprite->frames; ++frpos) {
it = layer_get_frame(layer, frpos);
if (it != NULL && it != frame && it->image == frame->image) {
it = layer_get_cel(layer, frpos);
if (it != NULL && it != cel && it->image == cel->image) {
used = TRUE;
break;
}
@ -289,18 +291,18 @@ void RemoveFrame(Layer *layer, Frame *frame)
undo_open(sprite->undo);
if (!used) {
/* if the image is only used by this frame, we can remove the
/* if the image is only used by this cel, we can remove the
image from the stock */
image = stock_get_image(layer->stock, frame->image);
image = stock_get_image(layer->stock, cel->image);
undo_remove_image(sprite->undo, layer->stock, image);
stock_remove_image(layer->stock, image);
image_free(image);
}
undo_remove_frame(sprite->undo, layer, frame);
undo_remove_cel(sprite->undo, layer, cel);
undo_close(sprite->undo);
/* remove the frame */
layer_remove_frame(layer, frame);
frame_free(frame);
/* remove the cel */
layer_remove_cel(layer, cel);
cel_free(cel);
}
}

View File

@ -21,7 +21,7 @@
struct Sprite;
struct Layer;
struct Frame;
struct Cel;
/* ======================================= */
/* Sprite */
@ -40,9 +40,9 @@ void RemoveLayer(void);
struct Layer *FlattenLayers(void);
/* ======================================= */
/* Frame */
/* Cel */
/* ======================================= */
void RemoveFrame(struct Layer *layer, struct Frame *frame);
void RemoveCel(struct Layer *layer, struct Cel *cel);
#endif /* SCRIPT_FUNCTIONS_H */

View File

@ -1127,37 +1127,37 @@ static int bind_crop_layer(lua_State *L)
return 0;
}
static int bind_crop_frame(lua_State *L)
static int bind_crop_cel(lua_State *L)
{
crop_frame();
crop_cel();
return 0;
}
static int bind_set_frame_to_handle(lua_State *L)
static int bind_set_cel_to_handle(lua_State *L)
{
Layer *layer;
Frame *frame;
Cel *cel;
GetUD(1, layer, Layer);
GetUD(2, frame, Frame);
set_frame_to_handle(layer, frame);
GetUD(2, cel, Cel);
set_cel_to_handle(layer, cel);
return 0;
}
static int bind_move_frame(lua_State *L)
static int bind_move_cel(lua_State *L)
{
move_frame();
move_cel();
return 0;
}
static int bind_copy_frame(lua_State *L)
static int bind_copy_cel(lua_State *L)
{
copy_frame();
copy_cel();
return 0;
}
static int bind_link_frame(lua_State *L)
static int bind_link_cel(lua_State *L)
{
link_frame();
link_cel();
return 0;
}
@ -1805,87 +1805,87 @@ static int bind_image_parallelogram(lua_State *L)
return 0;
}
static int bind_frame_new(lua_State *L)
static int bind_cel_new(lua_State *L)
{
Frame *return_value;
Cel *return_value;
int frpos;
int image;
GetArg(1, frpos, int, number);
GetArg(2, image, int, number);
return_value = frame_new(frpos, image);
push_userdata(L, Type_Frame, return_value);
return_value = cel_new(frpos, image);
push_userdata(L, Type_Cel, return_value);
return 1;
}
static int bind_frame_new_copy(lua_State *L)
static int bind_cel_new_copy(lua_State *L)
{
Frame *return_value;
Frame *frame;
GetUD(1, frame, Frame);
return_value = frame_new_copy(frame);
push_userdata(L, Type_Frame, return_value);
Cel *return_value;
Cel *cel;
GetUD(1, cel, Cel);
return_value = cel_new_copy(cel);
push_userdata(L, Type_Cel, return_value);
return 1;
}
static int bind_frame_free(lua_State *L)
static int bind_cel_free(lua_State *L)
{
Frame *frame;
GetUD(1, frame, Frame);
frame_free(frame);
Cel *cel;
GetUD(1, cel, Cel);
cel_free(cel);
return 0;
}
static int bind_frame_is_link(lua_State *L)
static int bind_cel_is_link(lua_State *L)
{
Frame *return_value;
Frame *frame;
Cel *return_value;
Cel *cel;
Layer *layer;
GetUD(1, frame, Frame);
GetUD(1, cel, Cel);
GetUD(2, layer, Layer);
return_value = frame_is_link(frame, layer);
push_userdata(L, Type_Frame, return_value);
return_value = cel_is_link(cel, layer);
push_userdata(L, Type_Cel, return_value);
return 1;
}
static int bind_frame_set_frpos(lua_State *L)
static int bind_cel_set_frpos(lua_State *L)
{
Frame *frame;
Cel *cel;
int frpos;
GetUD(1, frame, Frame);
GetUD(1, cel, Cel);
GetArg(2, frpos, int, number);
frame_set_frpos(frame, frpos);
cel_set_frpos(cel, frpos);
return 0;
}
static int bind_frame_set_image(lua_State *L)
static int bind_cel_set_image(lua_State *L)
{
Frame *frame;
Cel *cel;
int image;
GetUD(1, frame, Frame);
GetUD(1, cel, Cel);
GetArg(2, image, int, number);
frame_set_image(frame, image);
cel_set_image(cel, image);
return 0;
}
static int bind_frame_set_position(lua_State *L)
static int bind_cel_set_position(lua_State *L)
{
Frame *frame;
Cel *cel;
int x;
int y;
GetUD(1, frame, Frame);
GetUD(1, cel, Cel);
GetArg(2, x, int, number);
GetArg(3, y, int, number);
frame_set_position(frame, x, y);
cel_set_position(cel, x, y);
return 0;
}
static int bind_frame_set_opacity(lua_State *L)
static int bind_cel_set_opacity(lua_State *L)
{
Frame *frame;
Cel *cel;
int opacity;
GetUD(1, frame, Frame);
GetUD(1, cel, Cel);
GetArg(2, opacity, int, number);
frame_set_opacity(frame, opacity);
cel_set_opacity(cel, opacity);
return 0;
}
@ -2005,35 +2005,35 @@ static int bind_layer_set_blend_mode(lua_State *L)
return 0;
}
static int bind_layer_add_frame(lua_State *L)
static int bind_layer_add_cel(lua_State *L)
{
Layer *layer;
Frame *frame;
Cel *cel;
GetUD(1, layer, Layer);
GetUD(2, frame, Frame);
layer_add_frame(layer, frame);
GetUD(2, cel, Cel);
layer_add_cel(layer, cel);
return 0;
}
static int bind_layer_remove_frame(lua_State *L)
static int bind_layer_remove_cel(lua_State *L)
{
Layer *layer;
Frame *frame;
Cel *cel;
GetUD(1, layer, Layer);
GetUD(2, frame, Frame);
layer_remove_frame(layer, frame);
GetUD(2, cel, Cel);
layer_remove_cel(layer, cel);
return 0;
}
static int bind_layer_get_frame(lua_State *L)
static int bind_layer_get_cel(lua_State *L)
{
Frame *return_value;
Cel *return_value;
Layer *layer;
int frpos;
GetUD(1, layer, Layer);
GetArg(2, frpos, int, number);
return_value = layer_get_frame(layer, frpos);
push_userdata(L, Type_Frame, return_value);
return_value = layer_get_cel(layer, frpos);
push_userdata(L, Type_Cel, return_value);
return 1;
}
@ -2931,27 +2931,27 @@ static int bind_undo_replace_image(lua_State *L)
return 0;
}
static int bind_undo_add_frame(lua_State *L)
static int bind_undo_add_cel(lua_State *L)
{
Undo *undo;
Layer *layer;
Frame *frame;
Cel *cel;
GetUD(1, undo, Undo);
GetUD(2, layer, Layer);
GetUD(3, frame, Frame);
undo_add_frame(undo, layer, frame);
GetUD(3, cel, Cel);
undo_add_cel(undo, layer, cel);
return 0;
}
static int bind_undo_remove_frame(lua_State *L)
static int bind_undo_remove_cel(lua_State *L)
{
Undo *undo;
Layer *layer;
Frame *frame;
Cel *cel;
GetUD(1, undo, Undo);
GetUD(2, layer, Layer);
GetUD(3, frame, Frame);
undo_remove_frame(undo, layer, frame);
GetUD(3, cel, Cel);
undo_remove_cel(undo, layer, cel);
return 0;
}
@ -5682,11 +5682,11 @@ const luaL_reg bindings_routines[] = {
{ "paste_from_clipboard", bind_paste_from_clipboard },
{ "crop_sprite", bind_crop_sprite },
{ "crop_layer", bind_crop_layer },
{ "crop_frame", bind_crop_frame },
{ "set_frame_to_handle", bind_set_frame_to_handle },
{ "move_frame", bind_move_frame },
{ "copy_frame", bind_copy_frame },
{ "link_frame", bind_link_frame },
{ "crop_cel", bind_crop_cel },
{ "set_cel_to_handle", bind_set_cel_to_handle },
{ "move_cel", bind_move_cel },
{ "copy_cel", bind_copy_cel },
{ "link_cel", bind_link_cel },
{ "mapgen", bind_mapgen },
{ "GetImage", bind_GetImage },
{ "GetImage2", bind_GetImage2 },
@ -5745,14 +5745,14 @@ const luaL_reg bindings_routines[] = {
{ "image_scale", bind_image_scale },
{ "image_rotate", bind_image_rotate },
{ "image_parallelogram", bind_image_parallelogram },
{ "frame_new", bind_frame_new },
{ "frame_new_copy", bind_frame_new_copy },
{ "frame_free", bind_frame_free },
{ "frame_is_link", bind_frame_is_link },
{ "frame_set_frpos", bind_frame_set_frpos },
{ "frame_set_image", bind_frame_set_image },
{ "frame_set_position", bind_frame_set_position },
{ "frame_set_opacity", bind_frame_set_opacity },
{ "cel_new", bind_cel_new },
{ "cel_new_copy", bind_cel_new_copy },
{ "cel_free", bind_cel_free },
{ "cel_is_link", bind_cel_is_link },
{ "cel_set_frpos", bind_cel_set_frpos },
{ "cel_set_image", bind_cel_set_image },
{ "cel_set_position", bind_cel_set_position },
{ "cel_set_opacity", bind_cel_set_opacity },
{ "layer_new", bind_layer_new },
{ "layer_set_new", bind_layer_set_new },
{ "layer_new_copy", bind_layer_new_copy },
@ -5764,9 +5764,9 @@ const luaL_reg bindings_routines[] = {
{ "layer_get_next", bind_layer_get_next },
{ "layer_set_name", bind_layer_set_name },
{ "layer_set_blend_mode", bind_layer_set_blend_mode },
{ "layer_add_frame", bind_layer_add_frame },
{ "layer_remove_frame", bind_layer_remove_frame },
{ "layer_get_frame", bind_layer_get_frame },
{ "layer_add_cel", bind_layer_add_cel },
{ "layer_remove_cel", bind_layer_remove_cel },
{ "layer_get_cel", bind_layer_get_cel },
{ "layer_add_layer", bind_layer_add_layer },
{ "layer_remove_layer", bind_layer_remove_layer },
{ "layer_move_layer", bind_layer_move_layer },
@ -5847,8 +5847,8 @@ const luaL_reg bindings_routines[] = {
{ "undo_add_image", bind_undo_add_image },
{ "undo_remove_image", bind_undo_remove_image },
{ "undo_replace_image", bind_undo_replace_image },
{ "undo_add_frame", bind_undo_add_frame },
{ "undo_remove_frame", bind_undo_remove_frame },
{ "undo_add_cel", bind_undo_add_cel },
{ "undo_remove_cel", bind_undo_remove_cel },
{ "undo_add_layer", bind_undo_add_layer },
{ "undo_remove_layer", bind_undo_remove_layer },
{ "undo_move_layer", bind_undo_move_layer },
@ -6120,7 +6120,7 @@ struct _bindings_constants bindings_constants[] = {
{ "PI", PI },
{ "GFXOBJ_IMAGE", GFXOBJ_IMAGE },
{ "GFXOBJ_STOCK", GFXOBJ_STOCK },
{ "GFXOBJ_FRAME", GFXOBJ_FRAME },
{ "GFXOBJ_CEL", GFXOBJ_CEL },
{ "GFXOBJ_LAYER_IMAGE", GFXOBJ_LAYER_IMAGE },
{ "GFXOBJ_LAYER_SET", GFXOBJ_LAYER_SET },
{ "GFXOBJ_LAYER_TEXT", GFXOBJ_LAYER_TEXT },

View File

@ -5,7 +5,7 @@
#include "jinete/base.h"
#include "effect/colcurve.h"
#include "raster/frame.h"
#include "raster/cel.h"
#include "raster/image.h"
#include "raster/layer.h"
#include "raster/sprite.h"

148
src/util/celmove.c Normal file
View File

@ -0,0 +1,148 @@
/* ASE - Allegro Sprite Editor
* Copyright (C) 2001-2005, 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 "console/console.h"
#include "core/app.h"
#include "core/core.h"
#include "modules/color.h"
#include "modules/gui.h"
#include "modules/sprites.h"
#include "raster/cel.h"
#include "raster/image.h"
#include "raster/layer.h"
#include "raster/sprite.h"
#include "raster/stock.h"
#include "raster/undo.h"
#include "script/functions.h"
#include "util/celmove.h"
#include "widgets/colbar.h"
#endif
/* these variables indicate what cel to move (and the current_sprite
frame indicates to where move it) */
static Layer *handle_layer = NULL;
static Cel *handle_cel = NULL;
void set_cel_to_handle(Layer *layer, Cel *cel)
{
handle_layer = layer;
handle_cel = cel;
}
void move_cel(void)
{
if (handle_layer && handle_cel &&
!layer_get_cel(current_sprite->layer,
current_sprite->frpos)) {
/* move a cel in the same layer */
if (handle_layer == current_sprite->layer) {
undo_open (current_sprite->undo);
undo_remove_cel (current_sprite->undo, handle_layer, handle_cel);
handle_cel->frpos = current_sprite->frpos;
undo_add_cel (current_sprite->undo, handle_layer, handle_cel);
undo_close (current_sprite->undo);
}
/* move a cel from "handle_layer" to "current_sprite->layer" */
else {
Layer *handle_layer_bkp = handle_layer;
Cel *handle_cel_bkp = handle_cel;
undo_open(current_sprite->undo);
copy_cel();
RemoveCel(handle_layer_bkp, handle_cel_bkp);
undo_close(current_sprite->undo);
}
}
handle_layer = NULL;
handle_cel = NULL;
}
void copy_cel(void)
{
if (handle_layer && handle_cel &&
!layer_get_cel(current_sprite->layer,
current_sprite->frpos)) {
Cel *cel;
Image *image;
int image_index = 0;
/* create a new cel with a new image (a copy of the
"handle_cel" one) from "handle_layer" to "current_sprite->layer" */
undo_open(current_sprite->undo);
cel = cel_new_copy(handle_cel);
if (stock_get_image(handle_layer->stock, handle_cel->image)) {
/* create a copy of the image */
image = image_new_copy(stock_get_image(handle_layer->stock,
handle_cel->image));
/* add the image in the stock of current layer */
image_index = stock_add_image(current_sprite->layer->stock, image);
undo_add_image(current_sprite->undo,
current_sprite->layer->stock, image);
}
/* setup the cel */
cel_set_frpos(cel, current_sprite->frpos);
cel_set_image(cel, image_index);
/* add the cel in the current layer */
undo_add_cel(current_sprite->undo, current_sprite->layer, cel);
layer_add_cel(current_sprite->layer, cel);
undo_close(current_sprite->undo);
}
handle_layer = NULL;
handle_cel = NULL;
}
void link_cel(void)
{
if (handle_layer && handle_cel &&
!layer_get_cel (current_sprite->layer,
current_sprite->frpos)) {
if (handle_layer == current_sprite->layer) {
Cel *new_cel;
/* create a new copy of the cel with the same image index but in
the new frame */
new_cel = cel_new_copy(handle_cel);
cel_set_frpos(new_cel, current_sprite->frpos);
undo_add_cel(current_sprite->undo, handle_layer, new_cel);
layer_add_cel(handle_layer, new_cel);
}
else {
console_printf(_("Error: You can't link a cel from other layer\n"));
}
}
handle_layer = NULL;
handle_cel = NULL;
}

View File

@ -16,15 +16,18 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef UTIL_FRMOVE_H
#define UTIL_FRMOVE_H
#ifndef UTIL_CELMOVE_H
#define UTIL_CELMOVE_H
void set_frame_to_handle (Layer *layer, Frame *frame);
struct Cel;
struct Layer;
void new_frame (void);
void move_frame (void);
void copy_frame (void);
void link_frame (void);
void set_cel_to_handle(struct Layer *layer, struct Cel *cel);
#endif /* UTIL_FRMOVE_H */
void new_cel(void);
void move_cel(void);
void copy_cel(void);
void link_cel(void);
#endif /* UTIL_CELMOVE_H */

View File

@ -35,7 +35,7 @@
#include "modules/sprites.h"
#include "modules/tools.h"
#include "modules/tools2.h"
#include "raster/frame.h"
#include "raster/cel.h"
#include "raster/image.h"
#include "raster/layer.h"
#include "raster/rotate.h"
@ -97,12 +97,12 @@ bool has_clipboard_image(int *w, int *h)
{
Sprite *clipboard = get_clipboard_sprite ();
Image *image = NULL;
Frame *frame;
Cel *cel;
if (clipboard) {
frame = layer_get_frame (clipboard->layer, clipboard->frpos);
if (frame)
image = stock_get_image (clipboard->layer->stock, frame->image);
cel = layer_get_cel(clipboard->layer, clipboard->frpos);
if (cel)
image = stock_get_image(clipboard->layer->stock, cel->image);
}
if (image) {
@ -158,7 +158,7 @@ void copy_to_clipboard(void)
void paste_from_clipboard(void)
{
Sprite *clipboard = get_clipboard_sprite();
Frame *frame;
Cel *cel;
Image *image;
Image *dest_image;
int xout[4], yout[4];
@ -173,11 +173,11 @@ void paste_from_clipboard(void)
return;
}
frame = layer_get_frame(clipboard->layer, clipboard->frpos);
if (!frame)
cel = layer_get_cel(clipboard->layer, clipboard->frpos);
if (!cel)
return;
image = stock_get_image(clipboard->layer->stock, frame->image);
image = stock_get_image(clipboard->layer->stock, cel->image);
if (!image)
return;

View File

@ -25,7 +25,7 @@
#include "console/console.h"
#include "modules/gui.h"
#include "modules/sprites.h"
#include "raster/frame.h"
#include "raster/cel.h"
#include "raster/image.h"
#include "raster/layer.h"
#include "raster/mask.h"
@ -77,10 +77,10 @@ void crop_layer(void)
if ((sprite) && (!mask_is_empty(sprite->mask)) &&
(sprite->layer) && (layer_is_image(sprite->layer))) {
Layer *layer = sprite->layer;
Frame *frame;
Cel *cel;
Image *image;
Layer *new_layer;
Frame *new_frame;
Cel *new_cel;
Image *new_image;
Layer *set = (Layer *)layer->parent;
JLink link;
@ -94,36 +94,36 @@ void crop_layer(void)
layer_set_name (new_layer, layer->name);
layer_set_blend_mode (new_layer, layer->blend_mode);
JI_LIST_FOR_EACH(layer->frames, link) {
frame = link->data;
image = stock_get_image(layer->stock, frame->image);
JI_LIST_FOR_EACH(layer->cels, link) {
cel = link->data;
image = stock_get_image(layer->stock, cel->image);
if (!image)
continue;
new_frame = frame_new_copy(frame);
if (!new_frame) {
new_cel = cel_new_copy(cel);
if (!new_cel) {
layer_free(new_layer);
console_printf(_("Not enough memory\n"));
return;
}
new_image = image_crop(image,
sprite->mask->x-frame->x,
sprite->mask->y-frame->y,
sprite->mask->x-cel->x,
sprite->mask->y-cel->y,
sprite->mask->w,
sprite->mask->h);
if (!new_image) {
layer_free(new_layer);
frame_free(new_frame);
cel_free(new_cel);
console_printf(_("Not enough memory\n"));
return;
}
new_frame->image = stock_add_image(new_layer->stock, new_image);
new_frame->x = sprite->mask->x;
new_frame->y = sprite->mask->y;
new_cel->image = stock_add_image(new_layer->stock, new_image);
new_cel->x = sprite->mask->x;
new_cel->y = sprite->mask->y;
layer_add_frame(new_layer, new_frame);
layer_add_cel(new_layer, new_cel);
}
/* add the new layer */
@ -160,34 +160,34 @@ void crop_layer(void)
}
}
void crop_frame(void)
void crop_cel(void)
{
Sprite *sprite = current_sprite;
Image *image = GetImage ();
Image *image = GetImage();
if ((sprite) && (!mask_is_empty (sprite->mask)) && (image)) {
Frame *frame = layer_get_frame (sprite->layer, sprite->frpos);
Cel *cel = layer_get_cel(sprite->layer, sprite->frpos);
/* undo */
undo_open(sprite->undo);
undo_int(sprite->undo, (GfxObj *)frame, &frame->x);
undo_int(sprite->undo, (GfxObj *)frame, &frame->y);
undo_replace_image(sprite->undo, sprite->layer->stock, frame->image);
undo_int(sprite->undo, (GfxObj *)cel, &cel->x);
undo_int(sprite->undo, (GfxObj *)cel, &cel->y);
undo_replace_image(sprite->undo, sprite->layer->stock, cel->image);
undo_close(sprite->undo);
/* replace the image */
sprite->layer->stock->image[frame->image] =
sprite->layer->stock->image[cel->image] =
image_crop(image,
sprite->mask->x-frame->x,
sprite->mask->y-frame->y,
sprite->mask->x-cel->x,
sprite->mask->y-cel->y,
sprite->mask->w,
sprite->mask->h);
image_free(image); /* destroy the old image */
/* change the frame position */
frame->x = sprite->mask->x;
frame->y = sprite->mask->y;
/* change the cel position */
cel->x = sprite->mask->x;
cel->y = sprite->mask->y;
GUI_Refresh(sprite);
}
@ -200,19 +200,19 @@ static void displace_layers(Undo *undo, Layer *layer, int x, int y)
switch (layer->gfxobj.type) {
case GFXOBJ_LAYER_IMAGE: {
Frame *frame;
Cel *cel;
JLink link;
JI_LIST_FOR_EACH(layer->frames, link) {
frame = link->data;
JI_LIST_FOR_EACH(layer->cels, link) {
cel = link->data;
if (undo_is_enabled(undo)) {
undo_int(undo, (GfxObj *)frame, &frame->x);
undo_int(undo, (GfxObj *)frame, &frame->y);
undo_int(undo, (GfxObj *)cel, &cel->x);
undo_int(undo, (GfxObj *)cel, &cel->y);
}
frame->x += x;
frame->y += y;
cel->x += x;
cel->y += y;
}
break;
}
@ -225,7 +225,7 @@ static void displace_layers(Undo *undo, Layer *layer, int x, int y)
}
case GFXOBJ_LAYER_TEXT:
/* XXX */
/* TODO */
break;
}
}

View File

@ -21,7 +21,7 @@
void crop_sprite(void);
void crop_layer(void);
void crop_frame(void);
void crop_cel(void);
#endif /* UTIL_CROP_H */

View File

@ -1,148 +0,0 @@
/* ASE - Allegro Sprite Editor
* Copyright (C) 2001-2005, 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 "console/console.h"
#include "core/app.h"
#include "core/core.h"
#include "modules/color.h"
#include "modules/gui.h"
#include "modules/sprites.h"
#include "raster/frame.h"
#include "raster/image.h"
#include "raster/layer.h"
#include "raster/sprite.h"
#include "raster/stock.h"
#include "raster/undo.h"
#include "script/functions.h"
#include "util/frmove.h"
#include "widgets/colbar.h"
#endif
/* these variables indicate what frame to move (and the current_sprite
frame indicates to where move it) */
static Layer *handle_layer = NULL;
static Frame *handle_frame = NULL;
void set_frame_to_handle (Layer *layer, Frame *frame)
{
handle_layer = layer;
handle_frame = frame;
}
void move_frame (void)
{
if (handle_layer && handle_frame &&
!layer_get_frame (current_sprite->layer,
current_sprite->frpos)) {
/* move a frame in the same layer */
if (handle_layer == current_sprite->layer) {
undo_open (current_sprite->undo);
undo_remove_frame (current_sprite->undo, handle_layer, handle_frame);
handle_frame->frpos = current_sprite->frpos;
undo_add_frame (current_sprite->undo, handle_layer, handle_frame);
undo_close (current_sprite->undo);
}
/* move a frame from "handle_layer" to "current_sprite->layer" */
else {
Layer *handle_layer_bkp = handle_layer;
Frame *handle_frame_bkp = handle_frame;
undo_open (current_sprite->undo);
copy_frame ();
RemoveFrame (handle_layer_bkp, handle_frame_bkp);
undo_close (current_sprite->undo);
}
}
handle_layer = NULL;
handle_frame = NULL;
}
void copy_frame (void)
{
if (handle_layer && handle_frame &&
!layer_get_frame (current_sprite->layer,
current_sprite->frpos)) {
Frame *frame;
Image *image;
int image_index = 0;
/* create a new frame with a new image (a copy of the
"handle_frame" one) from "handle_layer" to "current_sprite->layer" */
undo_open (current_sprite->undo);
frame = frame_new_copy (handle_frame);
if (stock_get_image (handle_layer->stock, handle_frame->image)) {
/* create a copy of the image */
image = image_new_copy (stock_get_image (handle_layer->stock,
handle_frame->image));
/* add the image in the stock of current layer */
image_index = stock_add_image (current_sprite->layer->stock, image);
undo_add_image (current_sprite->undo,
current_sprite->layer->stock, image);
}
/* setup the frame */
frame_set_frpos (frame, current_sprite->frpos);
frame_set_image (frame, image_index);
/* add the frame in the current layer */
undo_add_frame (current_sprite->undo, current_sprite->layer, frame);
layer_add_frame (current_sprite->layer, frame);
undo_close (current_sprite->undo);
}
handle_layer = NULL;
handle_frame = NULL;
}
void link_frame (void)
{
if (handle_layer && handle_frame &&
!layer_get_frame (current_sprite->layer,
current_sprite->frpos)) {
if (handle_layer == current_sprite->layer) {
Frame *new_frame;
/* create a new copy of the frame with the same image index but in
the new frame position */
new_frame = frame_new_copy (handle_frame);
frame_set_frpos (new_frame, current_sprite->frpos);
undo_add_frame (current_sprite->undo, handle_layer, new_frame);
layer_add_frame (handle_layer, new_frame);
}
else {
console_printf (_("Error: You can't link a frame from other layer\n"));
}
}
handle_layer = NULL;
handle_frame = NULL;
}

View File

@ -38,7 +38,7 @@
#include "modules/sprites.h"
#include "modules/tools2.h"
#include "raster/blend.h"
#include "raster/frame.h"
#include "raster/cel.h"
#include "raster/image.h"
#include "raster/layer.h"
#include "raster/mask.h"
@ -51,39 +51,39 @@
#endif
Image *GetImage (void)
Image *GetImage(void)
{
Sprite *sprite = current_sprite;
Image *image = NULL;
if (sprite && sprite->layer && layer_is_image (sprite->layer)) {
Frame *frame = layer_get_frame (sprite->layer, sprite->frpos);
Cel *cel = layer_get_cel(sprite->layer, sprite->frpos);
if (frame) {
if ((frame->image >= 0) &&
(frame->image < sprite->layer->stock->nimage))
image = sprite->layer->stock->image[frame->image];
if (cel) {
if ((cel->image >= 0) &&
(cel->image < sprite->layer->stock->nimage))
image = sprite->layer->stock->image[cel->image];
}
}
return image;
}
Image *GetImage2 (Sprite *sprite, int *x, int *y, int *opacity)
Image *GetImage2(Sprite *sprite, int *x, int *y, int *opacity)
{
Image *image = NULL;
if (sprite && sprite->layer && layer_is_image (sprite->layer)) {
Frame *frame = layer_get_frame (sprite->layer, sprite->frpos);
Cel *cel = layer_get_cel (sprite->layer, sprite->frpos);
if (frame) {
if ((frame->image >= 0) &&
(frame->image < sprite->layer->stock->nimage))
image = sprite->layer->stock->image[frame->image];
if (cel) {
if ((cel->image >= 0) &&
(cel->image < sprite->layer->stock->nimage))
image = sprite->layer->stock->image[cel->image];
if (x) *x = frame->x;
if (y) *y = frame->y;
if (opacity) *opacity = MID (0, frame->opacity, 255);
if (x) *x = cel->x;
if (y) *y = cel->y;
if (opacity) *opacity = MID(0, cel->opacity, 255);
}
}
@ -128,7 +128,7 @@ void LoadPalette(const char *filename)
}
/* clears the mask region in the current sprite with the BG color */
void ClearMask (void)
void ClearMask(void)
{
Sprite *sprite = current_sprite;
int x, y, u, v, putx, puty;
@ -184,25 +184,25 @@ void ClearMask (void)
/* returns a new layer created from the current mask in the current
sprite, the layer isn't added to the sprite */
Layer *NewLayerFromMask (void)
Layer *NewLayerFromMask(void)
{
Sprite *sprite = current_sprite;
unsigned char *address;
int x, y, u, v, getx, gety;
Image *dst, *src = GetImage2 (sprite, &x, &y, NULL);
Layer *layer;
Frame *frame;
Cel *cel;
div_t d;
if (!sprite || !sprite->mask || !sprite->mask->bitmap || !src)
return NULL;
dst = image_new (sprite->imgtype, sprite->mask->w, sprite->mask->h);
dst = image_new(sprite->imgtype, sprite->mask->w, sprite->mask->h);
if (!dst)
return NULL;
/* clear the new image */
image_clear (dst, 0);
image_clear(dst, 0);
/* copy the masked zones */
for (v=0; v<sprite->mask->h; v++) {
@ -224,37 +224,36 @@ Layer *NewLayerFromMask (void)
}
}
layer = layer_new (sprite->imgtype);
layer = layer_new(sprite->imgtype);
if (!layer) {
image_free (dst);
return NULL;
}
layer_set_blend_mode (layer, BLEND_MODE_NORMAL);
layer_set_blend_mode(layer, BLEND_MODE_NORMAL);
frame = frame_new (sprite->frpos,
stock_add_image (layer->stock, dst));
frame_set_position (frame, sprite->mask->x, sprite->mask->y);
cel = cel_new(sprite->frpos, stock_add_image(layer->stock, dst));
cel_set_position(cel, sprite->mask->x, sprite->mask->y);
layer_add_frame (layer, frame);
layer_add_cel(layer, cel);
return layer;
}
Image *GetLayerImage (Layer *layer, int *x, int *y, int frpos)
Image *GetLayerImage(Layer *layer, int *x, int *y, int frpos)
{
Image *image = NULL;
if (layer_is_image (layer)) {
Frame *frame = layer_get_frame (layer, frpos);
Cel *cel = layer_get_cel(layer, frpos);
if (frame) {
if ((frame->image >= 0) &&
(frame->image < layer->stock->nimage))
image = layer->stock->image[frame->image];
if (cel) {
if ((cel->image >= 0) &&
(cel->image < layer->stock->nimage))
image = layer->stock->image[cel->image];
if (x) *x = frame->x;
if (y) *y = frame->y;
if (x) *x = cel->x;
if (y) *y = cel->y;
}
}
@ -269,7 +268,7 @@ int interactive_move_layer (int mode, int use_undo, int (*callback) (void))
JWidget editor = current_editor;
Sprite *sprite = editor_get_sprite (editor);
Layer *layer = sprite->layer;
Frame *frame = layer_get_frame (layer, sprite->frpos);
Cel *cel = layer_get_cel(layer, sprite->frpos);
int start_x, new_x;
int start_y, new_y;
int start_b;
@ -281,11 +280,11 @@ int interactive_move_layer (int mode, int use_undo, int (*callback) (void))
int begin_y;
int delay;
if (!frame)
if (!cel)
return FALSE;
begin_x = frame->x;
begin_y = frame->y;
begin_x = cel->x;
begin_y = cel->y;
delay = get_config_int ("Options", "MoveDelay", 250);
delay = MID (0, delay, 1000);
@ -298,8 +297,8 @@ int interactive_move_layer (int mode, int use_undo, int (*callback) (void))
do {
if (update) {
frame->x = begin_x - start_x + new_x;
frame->y = begin_y - start_y + new_y;
cel->x = begin_x - start_x + new_x;
cel->y = begin_y - start_y + new_y;
/* update layer-bounds */
jmouse_hide();
@ -311,10 +310,10 @@ int interactive_move_layer (int mode, int use_undo, int (*callback) (void))
status_bar_set_text
(app_get_status_bar(), 0,
"Pos %3d %3d Offset %3d %3d",
(int)frame->x,
(int)frame->y,
(int)(frame->x - begin_x),
(int)(frame->y - begin_y));
(int)cel->x,
(int)cel->y,
(int)(cel->x - begin_x),
(int)(cel->y - begin_y));
jwidget_flush_redraw(app_get_status_bar());
jmanager_dispatch_messages();
@ -344,16 +343,16 @@ int interactive_move_layer (int mode, int use_undo, int (*callback) (void))
/* the position was changed */
if (!editor_click_cancel(editor)) {
if (use_undo && undo_is_enabled(sprite->undo)) {
new_x = frame->x;
new_y = frame->y;
new_x = cel->x;
new_y = cel->y;
undo_open(sprite->undo);
frame->x = begin_x;
frame->y = begin_y;
undo_int(sprite->undo, (GfxObj *)frame, &frame->x);
undo_int(sprite->undo, (GfxObj *)frame, &frame->y);
frame->x = new_x;
frame->y = new_y;
cel->x = begin_x;
cel->y = begin_y;
undo_int(sprite->undo, (GfxObj *)cel, &cel->x);
undo_int(sprite->undo, (GfxObj *)cel, &cel->y);
cel->x = new_x;
cel->y = new_y;
undo_close(sprite->undo);
}
@ -361,8 +360,8 @@ int interactive_move_layer (int mode, int use_undo, int (*callback) (void))
}
/* the position wasn't changed */
else {
frame->x = begin_x;
frame->y = begin_y;
cel->x = begin_x;
cel->y = begin_y;
ret = FALSE;
}

View File

@ -41,6 +41,7 @@ static int rec_clock;
static s_fli_header *fli_header;
static unsigned char *omap;
static unsigned char *cmap;
static BITMAP *new_bmp;
static BITMAP *old_bmp;
bool is_rec_screen(void)
@ -76,11 +77,11 @@ void rec_screen_on(void)
fseek(rec_file, 128, SEEK_SET);
/* prepare fli header */
fli_header = jnew (s_fli_header, 1);
fli_header = jnew(s_fli_header, 1);
fli_header->filesize = 0;
fli_header->frames = 0;
fli_header->width = JI_SCREEN_W;
fli_header->height = JI_SCREEN_H;
fli_header->width = SCREEN_W;
fli_header->height = SCREEN_H;
fli_header->magic = HEADER_FLC;
fli_header->depth = 8;
fli_header->flags = 3;
@ -96,6 +97,7 @@ void rec_screen_on(void)
cmap = jmalloc(768);
/* prepare old bitmap */
new_bmp = NULL;
old_bmp = NULL;
/* set the position of the mouse in the center of the screen */
@ -114,8 +116,8 @@ void rec_screen_off(void)
rec_file = NULL;
/* free memory */
if (old_bmp)
destroy_bitmap(old_bmp);
if (new_bmp) destroy_bitmap(new_bmp);
if (old_bmp) destroy_bitmap(old_bmp);
jfree(fli_header);
jfree(cmap);
@ -123,13 +125,13 @@ void rec_screen_off(void)
}
}
void rec_screen_poll (void)
void rec_screen_poll(void)
{
if (!is_interactive() || !rec_file)
return;
else if (ji_clock-rec_clock > JI_TICKS_PER_SEC/FRAMES_PER_SECOND) {
BITMAP *t;
int old_flag;
BITMAP *bmp;
int c, i;
/* save the active flag which indicate if the mouse is freeze or not */
@ -146,28 +148,31 @@ void rec_screen_poll (void)
}
/* save in a bitmap the visible screen portion */
bmp = create_bitmap_ex(8, JI_SCREEN_W, JI_SCREEN_H);
if (ji_screen != screen)
jmouse_draw_cursor();
blit(ji_screen, bmp, 0, 0, 0, 0, JI_SCREEN_W, JI_SCREEN_H);
if (!new_bmp) new_bmp = create_bitmap_ex(8, SCREEN_W, SCREEN_H);
/* if (ji_screen != screen) */
/* jmouse_draw_cursor(); */
blit(screen, new_bmp, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
/* write the frame in FLC file */
if (old_bmp)
fli_write_frame(rec_file, fli_header,
(unsigned char *)old_bmp->dat, omap,
(unsigned char *)bmp->dat, cmap, W_ALL);
(unsigned char *)new_bmp->dat, cmap, W_ALL);
else
fli_write_frame(rec_file, fli_header, NULL, NULL,
(unsigned char *)bmp->dat, cmap, W_ALL);
(unsigned char *)new_bmp->dat, cmap, W_ALL);
/* copy this palette to the old one */
memcpy(omap, cmap, 768);
/* fixup old bitmap */
if (old_bmp)
destroy_bitmap(old_bmp);
/* if (old_bmp) */
/* destroy_bitmap(old_bmp); */
old_bmp = bmp;
/* swap bitmaps */
t = old_bmp;
old_bmp = new_bmp;
new_bmp = t;
/* restore the freeze flag by the previous value */
freeze_mouse_flag = old_flag;

View File

@ -37,24 +37,15 @@ static int global_opacity = 255;
static Layer *selected_layer = NULL;
static Image *rastering_image = NULL;
static void render_layer (Layer *layer, Image *image,
int source_x, int source_y,
int zoom,
int frpos,
void (*zoomed_func)(Image *, Image *, int, int, int, int, int));
static void render_layer(Layer *layer, Image *image,
int source_x, int source_y,
int zoom,
int frpos,
void (*zoomed_func)(Image *, Image *, int, int, int, int, int));
static void merge_zoomed_image1 (Image *dst, Image *src, int x, int y, int opacity, int blend_mode, int zoom);
static void merge_zoomed_image2 (Image *dst, Image *src, int x, int y, int opacity, int blend_mode, int zoom);
static void merge_zoomed_image4 (Image *dst, Image *src, int x, int y, int opacity, int blend_mode, int zoom);
int init_module_render (void)
{
return 0;
}
void exit_module_render (void)
{
}
static void merge_zoomed_image1(Image *dst, Image *src, int x, int y, int opacity, int blend_mode, int zoom);
static void merge_zoomed_image2(Image *dst, Image *src, int x, int y, int opacity, int blend_mode, int zoom);
static void merge_zoomed_image4(Image *dst, Image *src, int x, int y, int opacity, int blend_mode, int zoom);
void set_preview_image (Layer *layer, Image *image)
{
@ -66,10 +57,10 @@ void set_preview_image (Layer *layer, Image *image)
return image, all positions must have the zoom applied
(sorce_x<<zoom, dest_x<<zoom, width<<zoom, etc.)
*/
Image *render_sprite (Sprite *sprite,
int source_x, int source_y,
int width, int height,
int frpos, int zoom)
Image *render_sprite(Sprite *sprite,
int source_x, int source_y,
int width, int height,
int frpos, int zoom)
{
void (*zoomed_func)(Image *, Image *, int, int, int, int, int);
int need_grid, depth;
@ -172,11 +163,11 @@ Image *render_sprite (Sprite *sprite,
return image;
}
static void render_layer (Layer *layer, Image *image,
int source_x, int source_y,
int zoom,
int frpos,
void (*zoomed_func)(Image *, Image *, int, int, int, int, int))
static void render_layer(Layer *layer, Image *image,
int source_x, int source_y,
int zoom,
int frpos,
void (*zoomed_func)(Image *, Image *, int, int, int, int, int))
{
/* we can't read from this layer */
if (!layer->readable)
@ -200,13 +191,13 @@ static void render_layer (Layer *layer, Image *image,
switch (layer->gfxobj.type) {
case GFXOBJ_LAYER_IMAGE: {
Frame *frame = layer_get_frame (layer, frpos);
Cel *cel = layer_get_cel(layer, frpos);
Image *src_image;
if (frame) {
if ((frame->image >= 0) &&
(frame->image < layer->stock->nimage))
src_image = layer->stock->image[frame->image];
if (cel) {
if ((cel->image >= 0) &&
(cel->image < layer->stock->nimage))
src_image = layer->stock->image[cel->image];
else
src_image = NULL;
@ -217,22 +208,20 @@ static void render_layer (Layer *layer, Image *image,
if ((selected_layer == layer) && (rastering_image))
src_image = rastering_image;
output_opacity = MID (0, frame->opacity, 255);
output_opacity = INT_MULT (output_opacity, global_opacity, t);
output_opacity = MID(0, cel->opacity, 255);
output_opacity = INT_MULT(output_opacity, global_opacity, t);
if (zoom == 0) {
image_merge
(image, src_image,
frame->x - source_x,
frame->y - source_y,
output_opacity, layer->blend_mode);
image_merge (image, src_image,
cel->x - source_x,
cel->y - source_y,
output_opacity, layer->blend_mode);
}
else {
(*zoomed_func)
(image, src_image,
(frame->x << zoom) - source_x,
(frame->y << zoom) - source_y,
output_opacity, layer->blend_mode, zoom);
(*zoomed_func) (image, src_image,
(cel->x << zoom) - source_x,
(cel->y << zoom) - source_y,
output_opacity, layer->blend_mode, zoom);
}
}
}

View File

@ -16,21 +16,18 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef MODULES_RENDER_H
#define MODULES_RENDER_H
#ifndef UTIL_RENDER_H
#define UTIL_RENDER_H
struct Image;
struct Layer;
struct Sprite;
int init_module_render (void);
void exit_module_render (void);
void set_preview_image(struct Layer *layer, struct Image *drawable);
void set_preview_image (struct Layer *layer, struct Image *drawable);
struct Image *render_sprite(struct Sprite *sprite,
int source_x, int source_y,
int width, int height,
int frpos, int zoom);
struct Image *render_sprite (struct Sprite *sprite,
int source_x, int source_y,
int width, int height,
int frpos, int zoom);
#endif /* MODULES_RENDER_H */
#endif /* UTIL_RENDER_H */

View File

@ -19,7 +19,7 @@
#ifndef UTIL_SETGFX_H
#define UTIL_SETGFX_H
int set_gfx (const char *card, int w, int h, int depth);
int set_gfx(const char *card, int w, int h, int depth);
#endif /* UTIL_SETGFX_H */

View File

@ -27,7 +27,7 @@
#include "jinete/list.h"
#include "modules/palette.h"
#include "raster/frame.h"
#include "raster/cel.h"
#include "raster/image.h"
#include "raster/layer.h"
#include "raster/stock.h"
@ -37,7 +37,7 @@
static JList thumbnails = NULL;
static Thumbnail *thumbnail_new(Frame *frame, BITMAP *bmp);
static Thumbnail *thumbnail_new(Cel *cel, BITMAP *bmp);
static void thumbnail_free(Thumbnail *thumbnail);
static void thumbnail_create_bitmap(BITMAP *bmp, Image *image);
@ -54,7 +54,7 @@ void destroy_thumbnails(void)
}
}
BITMAP *generate_thumbnail(Frame *frame, Layer *layer)
BITMAP *generate_thumbnail(Cel *cel, Layer *layer)
{
Thumbnail *thumbnail;
BITMAP *bmp;
@ -65,19 +65,17 @@ BITMAP *generate_thumbnail(Frame *frame, Layer *layer)
#if 0 /* this must be done by the caller */
{
Frame *link_frame;
/* search original frame */
link_frame = frame_is_link(frame, layer);
if (link_frame)
frame = link_frame;
/* search original cel */
Cel *link_cel = cel_is_link(cel, layer);
if (link_cel)
cel = link_cel;
}
#endif
/* find the thumbnail */
JI_LIST_FOR_EACH(thumbnails, link) {
thumbnail = link->data;
if (thumbnail->frame == frame)
if (thumbnail->cel == cel)
return thumbnail->bmp;
}
@ -85,9 +83,9 @@ BITMAP *generate_thumbnail(Frame *frame, Layer *layer)
if (!bmp)
return NULL;
thumbnail_create_bitmap(bmp, stock_get_image(layer->stock, frame->image));
thumbnail_create_bitmap(bmp, stock_get_image(layer->stock, cel->image));
thumbnail = thumbnail_new(frame, bmp);
thumbnail = thumbnail_new(cel, bmp);
if (!thumbnail) {
destroy_bitmap(bmp);
return NULL;
@ -97,15 +95,15 @@ BITMAP *generate_thumbnail(Frame *frame, Layer *layer)
return thumbnail->bmp;
}
static Thumbnail *thumbnail_new(Frame *frame, BITMAP *bmp)
static Thumbnail *thumbnail_new(Cel *cel, BITMAP *bmp)
{
Thumbnail *thumbnail;
thumbnail = jnew (Thumbnail, 1);
thumbnail = jnew(Thumbnail, 1);
if (!thumbnail)
return NULL;
thumbnail->frame = frame;
thumbnail->cel = cel;
thumbnail->bmp = bmp;
return thumbnail;
@ -113,16 +111,16 @@ static Thumbnail *thumbnail_new(Frame *frame, BITMAP *bmp)
static void thumbnail_free(Thumbnail *thumbnail)
{
destroy_bitmap (thumbnail->bmp);
jfree (thumbnail);
destroy_bitmap(thumbnail->bmp);
jfree(thumbnail);
}
static void thumbnail_create_bitmap(BITMAP *bmp, Image *image)
{
if (!image) {
clear_to_color (bmp, makecol (128, 128, 128));
line (bmp, 0, 0, bmp->w-1, bmp->h-1, makecol (0, 0, 0));
line (bmp, 0, bmp->h-1, bmp->w-1, 0, makecol (0, 0, 0));
clear_to_color(bmp, makecol(128, 128, 128));
line(bmp, 0, 0, bmp->w-1, bmp->h-1, makecol(0, 0, 0));
line(bmp, 0, bmp->h-1, bmp->w-1, 0, makecol(0, 0, 0));
}
else {
int c, x, y, w, h, x1, y1;
@ -130,47 +128,47 @@ static void thumbnail_create_bitmap(BITMAP *bmp, Image *image)
sx = (double)image->w / (double)bmp->w;
sy = (double)image->h / (double)bmp->h;
scale = MAX (sx, sy);
scale = MAX(sx, sy);
w = image->w / scale;
h = image->h / scale;
w = MIN (bmp->w, w);
h = MIN (bmp->h, h);
w = MIN(bmp->w, w);
h = MIN(bmp->h, h);
x1 = bmp->w/2 - w/2;
y1 = bmp->h/2 - h/2;
x1 = MAX (0, x1);
y1 = MAX (0, y1);
x1 = MAX(0, x1);
y1 = MAX(0, y1);
clear_to_color (bmp, makecol (128, 128, 128));
clear_to_color(bmp, makecol(128, 128, 128));
switch (image->imgtype) {
case IMAGE_RGB:
for (y=0; y<h; y++)
for (x=0; x<w; x++) {
c = image_getpixel (image, x*scale, y*scale);
putpixel (bmp, x1+x, y1+y, makecol (_rgba_getr (c),
_rgba_getg (c),
_rgba_getb (c)));
c = image_getpixel(image, x*scale, y*scale);
putpixel(bmp, x1+x, y1+y, makecol(_rgba_getr(c),
_rgba_getg(c),
_rgba_getb(c)));
}
break;
case IMAGE_GRAYSCALE:
for (y=0; y<h; y++)
for (x=0; x<w; x++) {
c = image_getpixel (image, x*scale, y*scale);
putpixel (bmp, x1+x, y1+y, makecol (_graya_getk (c),
_graya_getk (c),
_graya_getk (c)));
c = image_getpixel(image, x*scale, y*scale);
putpixel(bmp, x1+x, y1+y, makecol(_graya_getk(c),
_graya_getk(c),
_graya_getk(c)));
}
break;
case IMAGE_INDEXED: {
for (y=0; y<h; y++)
for (x=0; x<w; x++) {
c = image_getpixel (image, x*scale, y*scale);
putpixel (bmp, x1+x, y1+y,
makecol (_rgb_scale_6[current_palette[c].r],
_rgb_scale_6[current_palette[c].g],
_rgb_scale_6[current_palette[c].b]));
c = image_getpixel(image, x*scale, y*scale);
putpixel(bmp, x1+x, y1+y,
makecol(_rgb_scale_6[current_palette[c].r],
_rgb_scale_6[current_palette[c].g],
_rgb_scale_6[current_palette[c].b]));
}
break;
}

View File

@ -19,19 +19,19 @@
#ifndef UTIL_THMBNAIL_H
#define UTIL_THMBNAIL_H
struct Frame;
struct Cel;
struct BITMAP;
#define THUMBNAIL_W 32
#define THUMBNAIL_H 32
typedef struct Thumbnail {
struct Frame *frame;
struct Cel *cel;
struct BITMAP *bmp;
} Thumbnail;
void destroy_thumbnails (void);
struct BITMAP *generate_thumbnail (struct Frame *frame, struct Layer *layer);
void destroy_thumbnails(void);
struct BITMAP *generate_thumbnail(struct Cel *cel, struct Layer *layer);
#endif /* UTIL_THMBNAIL_H */

View File

@ -42,7 +42,6 @@
#include "modules/gfx.h"
#include "modules/gui.h"
#include "modules/palette.h"
#include "modules/render.h"
#include "modules/sprites.h"
#include "modules/tools.h"
#include "raster/brush.h"
@ -56,6 +55,7 @@
#include "util/boundary.h"
#include "util/misc.h"
#include "util/recscr.h"
#include "util/render.h"
#include "widgets/colbar.h"
#include "widgets/editor.h"
#include "widgets/statebar.h"

View File

@ -24,8 +24,8 @@
#include "jinete/widget.h"
#include "effect/effect.h"
#include "modules/render.h"
#include "raster/sprite.h"
#include "util/render.h"
#include "widgets/preview.h"
#endif
@ -35,61 +35,61 @@ typedef struct Preview
Effect *effect;
} Preview;
static bool preview_msg_proc (JWidget widget, JMessage msg);
static bool preview_msg_proc(JWidget widget, JMessage msg);
JWidget preview_new (Effect *effect)
JWidget preview_new(Effect *effect)
{
JWidget widget = jwidget_new (preview_type ());
Preview *preview = jnew (Preview, 1);
JWidget widget = jwidget_new(preview_type());
Preview *preview = jnew(Preview, 1);
preview->effect = effect;
jwidget_add_hook (widget, preview_type (), preview_msg_proc, preview);
jwidget_hide (widget);
jwidget_add_hook(widget, preview_type(), preview_msg_proc, preview);
jwidget_hide(widget);
return widget;
}
int preview_type (void)
int preview_type(void)
{
static int type = 0;
if (!type)
type = ji_register_widget_type ();
type = ji_register_widget_type();
return type;
}
void preview_restart (JWidget widget)
void preview_restart(JWidget widget)
{
effect_begin_for_preview (preview_get_effect (widget));
effect_begin_for_preview(preview_get_effect(widget));
}
Effect *preview_get_effect (JWidget widget)
Effect *preview_get_effect(JWidget widget)
{
return ((Preview *)jwidget_get_data (widget, preview_type ()))->effect;
return ((Preview *)jwidget_get_data(widget, preview_type()))->effect;
}
static bool preview_msg_proc (JWidget widget, JMessage msg)
static bool preview_msg_proc(JWidget widget, JMessage msg)
{
Effect *effect = preview_get_effect (widget);
Effect *effect = preview_get_effect(widget);
switch (msg->type) {
case JM_DESTROY:
jfree (jwidget_get_data (widget, preview_type ()));
jfree(jwidget_get_data(widget, preview_type()));
break;
case JM_OPEN:
set_preview_image (effect->sprite->layer, effect->dst);
set_preview_image(effect->sprite->layer, effect->dst);
break;
case JM_CLOSE:
set_preview_image (NULL, NULL);
set_preview_image(NULL, NULL);
break;
case JM_IDLE:
if (effect) {
if (effect_apply_step (effect))
effect_flush (effect);
if (effect_apply_step(effect))
effect_flush(effect);
}
break;
}

View File

@ -33,7 +33,7 @@
#include "modules/gui.h"
#include "modules/palette.h"
#include "modules/sprites.h"
#include "raster/frame.h"
#include "raster/cel.h"
#include "raster/layer.h"
#include "raster/sprite.h"
#include "script/script.h"
@ -349,11 +349,11 @@ static int slider_change_signal(JWidget widget, int user_data)
if (sprite) {
if ((sprite->layer) &&
(sprite->layer->gfxobj.type == GFXOBJ_LAYER_IMAGE)) {
Frame *frame = layer_get_frame (sprite->layer, sprite->frpos);
Cel *cel = layer_get_cel(sprite->layer, sprite->frpos);
if (frame) {
if (cel) {
/* update the opacity */
frame->opacity = jslider_get_value (widget);
cel->opacity = jslider_get_value(widget);
/* update the editors */
GUI_Refresh(sprite);
@ -410,30 +410,30 @@ static void button_command(JWidget widget, void *data)
static void update_from_layer(StatusBar *status_bar)
{
Sprite *sprite = current_sprite;
Frame *frame;
Cel *cel;
/* layer button */
if (sprite && sprite->layer) {
char buf[512];
usprintf (buf, "[%d] %s", sprite->frpos, sprite->layer->name);
jwidget_set_text (status_bar->b_layer, buf);
jwidget_enable (status_bar->b_layer);
usprintf(buf, "[%d] %s", sprite->frpos, sprite->layer->name);
jwidget_set_text(status_bar->b_layer, buf);
jwidget_enable(status_bar->b_layer);
}
else {
jwidget_set_text (status_bar->b_layer, "Nothing");
jwidget_disable (status_bar->b_layer);
jwidget_set_text(status_bar->b_layer, "Nothing");
jwidget_disable(status_bar->b_layer);
}
/* opacity layer */
if (sprite && sprite->layer &&
sprite->layer->gfxobj.type == GFXOBJ_LAYER_IMAGE &&
(frame = layer_get_frame (sprite->layer, sprite->frpos))) {
jslider_set_value (status_bar->slider, MID (0, frame->opacity, 255));
jwidget_enable (status_bar->slider);
(cel = layer_get_cel(sprite->layer, sprite->frpos))) {
jslider_set_value(status_bar->slider, MID(0, cel->opacity, 255));
jwidget_enable(status_bar->slider);
}
else {
jslider_set_value (status_bar->slider, 0);
jwidget_disable (status_bar->slider);
jslider_set_value(status_bar->slider, 0);
jwidget_disable(status_bar->slider);
}
}