diff --git a/ChangeLog b/ChangeLog index 72aa8aa08..e25f990f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2008-09-29 David A. Capello + + * src/script/functions.c (FlattenLayers): Fixed a bug calling + 'layer_configure_as_background' without 'undo_move_layer' before. + + * src/util/clipbrd.c (paste_from_clipboard): Fixed a bug when + paste the clipboard outside the sprite. + + * src/modules/tools.c (M_PI): Defined for MSVC8. + + * src/widgets/colbut.c (colorbutton_draw): Fixed compilation error + in MSVC8. + + * src/widgets/colbar.c (colorbar_msg_proc): Fixed a bug little bug + when drop color in nowhere. + 2008-09-28 David A. Capello * src/modules/tools.c: Added new Curve tool. diff --git a/makefile.dj b/makefile.dj index 1145232ef..1bc4b3483 100644 --- a/makefile.dj +++ b/makefile.dj @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2005, 2007 by David A. Capello -*-Makefile-*- +# Copyright (C) 2001-2008 by David A. Capello -*-Makefile-*- ifndef CONFIGURED include makefile.cfg diff --git a/makefile.gcc b/makefile.gcc index ce2073501..9c4580613 100644 --- a/makefile.gcc +++ b/makefile.gcc @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2005, 2007, 2008 by David A. Capello -*-Makefile-*- +# Copyright (C) 2001-2008 by David A. Capello -*-Makefile-*- .PHONY = _default _default: default @@ -21,8 +21,8 @@ ifdef PROFILE LFLAGS += -pg else ifdef DEBUGMODE - CFLAGS += -g3 -O3 -DDEBUGMODE - LFLAGS += -g3 -O3 + CFLAGS += -g3 -DDEBUGMODE + LFLAGS += -g3 else CFLAGS += -s -O3 -DNDEBUG LFLAGS += -s -O3 -DNDEBUG diff --git a/makefile.lnx b/makefile.lnx index 2e0338f1e..dbb0ccfb0 100644 --- a/makefile.lnx +++ b/makefile.lnx @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2005, 2007 by David A. Capello -*-Makefile-*- +# Copyright (C) 2001-2008 by David A. Capello -*-Makefile-*- ifndef CONFIGURED include makefile.cfg diff --git a/makefile.lst b/makefile.lst index 09a8c3795..b47f7b38c 100644 --- a/makefile.lst +++ b/makefile.lst @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2005, 2007, 2008 by David A. Capello -*-Makefile-*- +# Copyright (C) 2001-2008 by David A. Capello -*-Makefile-*- ###################################################################### # ASE @@ -235,7 +235,7 @@ ASE_OBJS = $(addprefix $(OBJ_DIR)/, \ ###################################################################### # Libart -LIBART_LIB = $(OBJ_DIR)/libart$(LIB) +LIBART_LIB = $(OBJ_DIR)/libart$(LIB_EXT) LIBART_DIR = third_party/libart_lgpl LIBART_SOURCES = \ $(LIBART_DIR)/art_affine.c \ @@ -283,7 +283,7 @@ LIBART_OBJS = $(addprefix $(OBJ_DIR)/art., \ ###################################################################### # Freetype -LIBFREETYPE_LIB = $(OBJ_DIR)/libfreetype$(LIB) +LIBFREETYPE_LIB = $(OBJ_DIR)/libfreetype$(LIB_EXT) LIBFREETYPE_DIR = third_party/freetype LIBFREETYPE_SOURCES = \ $(LIBFREETYPE_DIR)/src/base/ftsystem.c \ @@ -315,7 +315,7 @@ LIBFREETYPE_OBJS = $(addprefix $(OBJ_DIR)/freetype., \ ###################################################################### # GD Library -LIBGD_LIB = $(OBJ_DIR)/libgd$(LIB) +LIBGD_LIB = $(OBJ_DIR)/libgd$(LIB_EXT) LIBGD_DIR = third_party/gd LIBGD_SOURCES = \ $(LIBGD_DIR)/gd \ @@ -354,7 +354,7 @@ LIBGD_OBJS = $(addprefix $(OBJ_DIR)/gd., \ ###################################################################### # JPEG -LIBJPEG_LIB = $(OBJ_DIR)/libjpeg$(LIB) +LIBJPEG_LIB = $(OBJ_DIR)/libjpeg$(LIB_EXT) LIBJPEG_DIR = third_party/jpeg LIBJPEG_SOURCES = \ $(LIBJPEG_DIR)/jcapimin.c \ @@ -411,7 +411,7 @@ LIBJPEG_OBJS = $(addprefix $(OBJ_DIR)/jpeg., \ ###################################################################### # LibPNG -LIBPNG_LIB = $(OBJ_DIR)/libpng$(LIB) +LIBPNG_LIB = $(OBJ_DIR)/libpng$(LIB_EXT) LIBPNG_DIR = third_party/libpng LIBPNG_SOURCES = \ $(LIBPNG_DIR)/png.c \ @@ -437,7 +437,7 @@ LIBPNG_OBJS = $(addprefix $(OBJ_DIR)/png., \ ###################################################################### # ZLib -ZLIB_LIB = $(OBJ_DIR)/libzlib$(LIB) +ZLIB_LIB = $(OBJ_DIR)/libzlib$(LIB_EXT) ZLIB_DIR = third_party/zlib ZLIB_SOURCES = \ $(ZLIB_DIR)/adler32.c \ diff --git a/makefile.mgw b/makefile.mgw index 4e6863a9c..4c0e98b19 100644 --- a/makefile.mgw +++ b/makefile.mgw @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2005, 2007, 2008 by David A. Capello -*-Makefile-*- +# Copyright (C) 2001-2008 by David A. Capello -*-Makefile-*- ifndef CONFIGURED include makefile.cfg diff --git a/src/dialogs/aniedit.c b/src/dialogs/aniedit.c index 550df751b..4cee9a49c 100644 --- a/src/dialogs/aniedit.c +++ b/src/dialogs/aniedit.c @@ -136,6 +136,7 @@ static void anieditor_draw_header_part(JWidget widget, JRect clip, int x1, int y const char *line2, int align2); static void anieditor_draw_separator(JWidget widget, JRect clip); static void anieditor_draw_layer(JWidget widget, JRect clip, int layer_index); +static void anieditor_draw_layer_padding(JWidget widget); static void anieditor_draw_cel(JWidget widget, JRect clip, int layer_index, int frame); static bool anieditor_draw_part(JWidget widget, int part, int layer, int frame); static void anieditor_regenerate_layers(JWidget widget); @@ -283,6 +284,8 @@ static bool anieditor_msg_proc(JWidget widget, JMessage msg) anieditor_draw_cel(widget, clip, layer, frame); } + anieditor_draw_layer_padding(widget); + return TRUE; } @@ -1083,16 +1086,26 @@ static void anieditor_draw_layer(JWidget widget, JRect clip, int layer_index) } set_clip_rect(ji_screen, cx1, cy1, cx2, cy2); +} + +static void anieditor_draw_layer_padding(JWidget widget) +{ + AniEditor *anieditor = anieditor_data(widget); + int layer_index = anieditor->nlayers-1; + int x1, y1, x2, y2; + + x1 = widget->rc->x1; + y1 = widget->rc->y1 + HDRSIZE + LAYSIZE*layer_index - anieditor->scroll_y; + x2 = x1 + anieditor->separator_x - 1; + y2 = y1 + LAYSIZE - 1; /* padding in the bottom side */ - if (layer_index == anieditor->nlayers-1) { - if (y2+1 <= widget->rc->y2-1) { - rectfill(ji_screen, x1, y2+1, x2, widget->rc->y2-1, ji_color_disabled()); - rectfill(ji_screen, - x2+1+anieditor->separator_w, y2+1, - widget->rc->x2-1, widget->rc->y2-1, - ji_color_disabled()); - } + if (y2+1 <= widget->rc->y2-1) { + rectfill(ji_screen, x1, y2+1, x2, widget->rc->y2-1, ji_color_disabled()); + rectfill(ji_screen, + x2+1+anieditor->separator_w, y2+1, + widget->rc->x2-1, widget->rc->y2-1, + ji_color_disabled()); } } diff --git a/src/file/png_format.c b/src/file/png_format.c index b4bf7df8a..bfadce25e 100644 --- a/src/file/png_format.c +++ b/src/file/png_format.c @@ -299,7 +299,7 @@ static bool save_PNG(FileOp *fop) png_infop info_ptr; png_colorp palette = NULL; png_bytep row_pointer; - int color_type; + int color_type = 0; int pass, number_passes; FILE *fp; diff --git a/src/jinete/jfilesel.c b/src/jinete/jfilesel.c index 7e15b7d5a..ecad8aacc 100644 --- a/src/jinete/jfilesel.c +++ b/src/jinete/jfilesel.c @@ -47,6 +47,7 @@ # define HAVE_DRIVES #endif +#undef FA_ALL #define FA_TO_SHOW FA_RDONLY | FA_DIREC | FA_ARCH | FA_SYSTEM #define FA_ALL FA_RDONLY | FA_DIREC | FA_ARCH | FA_HIDDEN | FA_SYSTEM diff --git a/src/jinete/jmanager.c b/src/jinete/jmanager.c index b6a6dc4f3..8b66ac5c7 100644 --- a/src/jinete/jmanager.c +++ b/src/jinete/jmanager.c @@ -360,17 +360,18 @@ bool jmanager_generate_messages(JWidget manager) /* mouse movement */ if (mousemove) { + JWidget dst; + /* reset double click status */ double_click_level = DOUBLE_CLICK_NONE; - JWidget destination; if (capture_widget && capture_widget->flags & JI_HARDCAPTURE) - destination = capture_widget; + dst = capture_widget; else - destination = mouse_widget; + dst = mouse_widget; /* send the mouse movement message */ - msg = new_mouse_msg(JM_MOTION, destination); + msg = new_mouse_msg(JM_MOTION, dst); jmanager_enqueue_message(msg); generate_setcursor_message(); @@ -1356,17 +1357,17 @@ static void manager_redraw_region(JWidget widget, JRegion region) static void generate_setcursor_message(void) { - JWidget destination; + JWidget dst; JMessage msg; if (capture_widget && capture_widget->flags & JI_HARDCAPTURE) - destination = capture_widget; + dst = capture_widget; else - destination = mouse_widget; + dst = mouse_widget; - if (destination) { - msg = new_mouse_msg(JM_SETCURSOR, destination); + if (dst) { + msg = new_mouse_msg(JM_SETCURSOR, dst); jmanager_enqueue_message(msg); } else diff --git a/src/jinete/jmutex.c b/src/jinete/jmutex.c index a0d5e4990..01411dd63 100644 --- a/src/jinete/jmutex.c +++ b/src/jinete/jmutex.c @@ -47,7 +47,7 @@ void jmutex_free(JMutex mutex) assert(system_driver != NULL); assert(system_driver->destroy_mutex != NULL); - return system_driver->destroy_mutex(mutex); + system_driver->destroy_mutex(mutex); } void jmutex_lock(JMutex mutex) diff --git a/src/modules/tools.c b/src/modules/tools.c index 7635518d6..864d8a974 100644 --- a/src/modules/tools.c +++ b/src/modules/tools.c @@ -51,6 +51,10 @@ #include "widgets/statebar.h" #include "widgets/toolbar.h" +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + /* tool flags */ #define TOOL_COPY_SRC2DST 0x00000001 #define TOOL_COPY_DST2SRC 0x00000002 @@ -97,32 +101,32 @@ enum { MAX_INKS }; -static void ink_hline4_opaque(int x1, int y, int x2, ToolData *data); -static void ink_hline2_opaque(int x1, int y, int x2, ToolData *data); -static void ink_hline1_opaque(int x1, int y, int x2, ToolData *data); +static void ink_hline32_opaque(int x1, int y, int x2, ToolData *data); +static void ink_hline16_opaque(int x1, int y, int x2, ToolData *data); +static void ink_hline8_opaque(int x1, int y, int x2, ToolData *data); -static void ink_hline4_glass(int x1, int y, int x2, ToolData *data); -static void ink_hline2_glass(int x1, int y, int x2, ToolData *data); -static void ink_hline1_glass(int x1, int y, int x2, ToolData *data); +static void ink_hline32_glass(int x1, int y, int x2, ToolData *data); +static void ink_hline16_glass(int x1, int y, int x2, ToolData *data); +static void ink_hline8_glass(int x1, int y, int x2, ToolData *data); -static void ink_hline4_soften(int x1, int y, int x2, ToolData *data); -static void ink_hline2_soften(int x1, int y, int x2, ToolData *data); -static void ink_hline1_soften(int x1, int y, int x2, ToolData *data); +static void ink_hline32_soften(int x1, int y, int x2, ToolData *data); +static void ink_hline16_soften(int x1, int y, int x2, ToolData *data); +static void ink_hline8_soften(int x1, int y, int x2, ToolData *data); -static void ink_hline4_replace(int x1, int y, int x2, ToolData *data); -static void ink_hline2_replace(int x1, int y, int x2, ToolData *data); -static void ink_hline1_replace(int x1, int y, int x2, ToolData *data); +static void ink_hline32_replace(int x1, int y, int x2, ToolData *data); +static void ink_hline16_replace(int x1, int y, int x2, ToolData *data); +static void ink_hline8_replace(int x1, int y, int x2, ToolData *data); -static void ink_hline4_jumble(int x1, int y, int x2, ToolData *data); -static void ink_hline2_jumble(int x1, int y, int x2, ToolData *data); -static void ink_hline1_jumble(int x1, int y, int x2, ToolData *data); +static void ink_hline32_jumble(int x1, int y, int x2, ToolData *data); +static void ink_hline16_jumble(int x1, int y, int x2, ToolData *data); +static void ink_hline8_jumble(int x1, int y, int x2, ToolData *data); static AlgoHLine inks_hline[][3] = { #define DEF_INK(name) \ - { (AlgoHLine)ink_hline4_##name, \ - (AlgoHLine)ink_hline2_##name, \ - (AlgoHLine)ink_hline1_##name } + { (AlgoHLine)ink_hline32_##name, \ + (AlgoHLine)ink_hline16_##name, \ + (AlgoHLine)ink_hline8_##name } DEF_INK(opaque), DEF_INK(glass), @@ -600,7 +604,8 @@ static void tool_spray_draw_trace(int x1, int y1, int x2, int y2, ToolData *data { int c, x, y, times = (spray_width*spray_width/4) * air_speed / 100; -#ifdef __MINGW32__ /* MinGW32 has a RAND_MAX too small */ + /* in Windows, rand() has a RAND_MAX too small */ +#if RAND_MAX <= 0xffff fixed angle, radius; for (c=0; clayer); + /* First of all we have to dispatch the enqueue messages. Why is it needed? To dispatch the JM_CLOSE and redrawing messages if a color-selector was shown to the user before to click. This is @@ -1699,7 +1706,7 @@ static void line_for_spline(int x1, int y1, int x2, int y2, ToolData *data) addresses_initialize, \ addresses_increment, \ processing) \ - addresses_define; \ + addresses_define \ register int x; \ \ /* with mask */ \ @@ -1755,7 +1762,7 @@ static void line_for_spline(int x1, int y1, int x2, int y2, ToolData *data) /* Opaque Ink */ /**********************************************************************/ -static void ink_hline4_opaque(int x1, int y, int x2, ToolData *data) +static void ink_hline32_opaque(int x1, int y, int x2, ToolData *data) { int c = data->color; @@ -1764,7 +1771,7 @@ static void ink_hline4_opaque(int x1, int y, int x2, ToolData *data) *dst_address = c ); } -static void ink_hline2_opaque(int x1, int y, int x2, ToolData *data) +static void ink_hline16_opaque(int x1, int y, int x2, ToolData *data) { int c = data->color; @@ -1773,7 +1780,7 @@ static void ink_hline2_opaque(int x1, int y, int x2, ToolData *data) *dst_address = c ); } -static void ink_hline1_opaque(int x1, int y, int x2, ToolData *data) +static void ink_hline8_opaque(int x1, int y, int x2, ToolData *data) { int c = data->color; @@ -1788,7 +1795,7 @@ static void ink_hline1_opaque(int x1, int y, int x2, ToolData *data) /* Glass Ink */ /**********************************************************************/ -static void ink_hline4_glass(int x1, int y, int x2, ToolData *data) +static void ink_hline32_glass(int x1, int y, int x2, ToolData *data) { int color = data->color; int opacity = data->opacity; @@ -1798,7 +1805,7 @@ static void ink_hline4_glass(int x1, int y, int x2, ToolData *data) *dst_address = _rgba_blend_normal(*src_address, color, opacity)); } -static void ink_hline2_glass(int x1, int y, int x2, ToolData *data) +static void ink_hline16_glass(int x1, int y, int x2, ToolData *data) { int color = data->color; int opacity = data->opacity; @@ -1808,7 +1815,7 @@ static void ink_hline2_glass(int x1, int y, int x2, ToolData *data) *dst_address = _graya_blend_normal(*src_address, color, opacity)); } -static void ink_hline1_glass(int x1, int y, int x2, ToolData *data) +static void ink_hline8_glass(int x1, int y, int x2, ToolData *data) { Palette *pal = get_current_palette(); ase_uint32 c; @@ -1830,7 +1837,7 @@ static void ink_hline1_glass(int x1, int y, int x2, ToolData *data) /* Soften Ink */ /**********************************************************************/ -static void ink_hline4_soften(int x1, int y, int x2, ToolData *data) +static void ink_hline32_soften(int x1, int y, int x2, ToolData *data) { int c, r, g, b, a; int opacity = data->opacity; @@ -1880,7 +1887,7 @@ static void ink_hline4_soften(int x1, int y, int x2, ToolData *data) }); } -static void ink_hline2_soften(int x1, int y, int x2, ToolData *data) +static void ink_hline16_soften(int x1, int y, int x2, ToolData *data) { int c, v, a; int opacity = data->opacity; @@ -1924,7 +1931,7 @@ static void ink_hline2_soften(int x1, int y, int x2, ToolData *data) }); } -static void ink_hline1_soften(int x1, int y, int x2, ToolData *data) +static void ink_hline8_soften(int x1, int y, int x2, ToolData *data) { Palette *pal = get_current_palette(); int c, r, g, b, a; @@ -1978,7 +1985,7 @@ static void ink_hline1_soften(int x1, int y, int x2, ToolData *data) /* Replace Ink */ /**********************************************************************/ -static void ink_hline4_replace(int x1, int y, int x2, ToolData *data) +static void ink_hline32_replace(int x1, int y, int x2, ToolData *data) { int color = data->color; int other_color = data->other_color; @@ -1991,7 +1998,7 @@ static void ink_hline4_replace(int x1, int y, int x2, ToolData *data) }); } -static void ink_hline2_replace(int x1, int y, int x2, ToolData *data) +static void ink_hline16_replace(int x1, int y, int x2, ToolData *data) { int color = data->color; int other_color = data->other_color; @@ -2004,7 +2011,7 @@ static void ink_hline2_replace(int x1, int y, int x2, ToolData *data) }); } -static void ink_hline1_replace(int x1, int y, int x2, ToolData *data) +static void ink_hline8_replace(int x1, int y, int x2, ToolData *data) { int other_color = data->other_color; Palette *pal = get_current_palette(); @@ -2048,7 +2055,7 @@ static void ink_hline1_replace(int x1, int y, int x2, ToolData *data) } \ color = image_getpixel(data->src_image, u, v); -static void ink_hline4_jumble(int x1, int y, int x2, ToolData *data) +static void ink_hline32_jumble(int x1, int y, int x2, ToolData *data) { int opacity = data->opacity; int speed_x = data->vector.x/4; @@ -2065,7 +2072,7 @@ static void ink_hline4_jumble(int x1, int y, int x2, ToolData *data) ); } -static void ink_hline2_jumble(int x1, int y, int x2, ToolData *data) +static void ink_hline16_jumble(int x1, int y, int x2, ToolData *data) { int opacity = data->opacity; int speed_x = data->vector.x/4; @@ -2082,7 +2089,7 @@ static void ink_hline2_jumble(int x1, int y, int x2, ToolData *data) ); } -static void ink_hline1_jumble(int x1, int y, int x2, ToolData *data) +static void ink_hline8_jumble(int x1, int y, int x2, ToolData *data) { Palette *pal = get_current_palette(); ase_uint32 c, tc; diff --git a/src/raster/blend.h b/src/raster/blend.h index e2b4ab48e..1dfa8d32e 100644 --- a/src/raster/blend.h +++ b/src/raster/blend.h @@ -50,6 +50,7 @@ enum { BLEND_MODE_COLOR, BLEND_MODE_LUMINOSITY, BLEND_MODE_COPY, + BLEND_MODE_MAX, }; typedef int (*BLEND_COLOR) (int back, int front, int opacity); diff --git a/src/raster/image.h b/src/raster/image.h index 224911ff4..6f65005a8 100644 --- a/src/raster/image.h +++ b/src/raster/image.h @@ -54,7 +54,7 @@ } #define IMAGE_ADDRESS(image,x,y) \ - ((void *)(image)->line[(y)] + IMAGE_LINE_SIZE((image), (x))) \ + ((void *)((image)->line[(y)] + IMAGE_LINE_SIZE((image), (x)))) \ #define IMAGE_SHIFT(d) \ (((d)->imgtype == IMAGE_RGB)? 2: \ diff --git a/src/script/functions.c b/src/script/functions.c index b4f8b7139..9d2d2780e 100644 --- a/src/script/functions.c +++ b/src/script/functions.c @@ -226,54 +226,21 @@ static int get_max_layer_num(Layer *layer); Layer *NewLayer(Sprite *sprite) { Layer *layer; -#if 0 - Image *image; - Cel *cel; - int index; -#endif if (sprite == NULL) { console_printf("NewLayer: No current sprite\n"); return NULL; } - /* new image */ -#if 0 - image = image_new(sprite->imgtype, sprite->w, sprite->h); - if (!image) { - console_printf("NewLayer: Not enough memory\n"); - return NULL; - } -#endif - /* new layer */ layer = layer_new(sprite); if (!layer) { -#if 0 - image_free(image); -#endif console_printf("NewLayer: Not enough memory\n"); return NULL; } -#if 0 - /* clear with mask color */ - image_clear(image, 0); -#endif - /* configure layer name and blend mode */ layer_set_blend_mode(layer, BLEND_MODE_NORMAL); - -#if 0 - /* add image in the layer stock */ - index = stock_add_image(sprite->stock, image); - - /* create a new cel in the current frame */ - cel = cel_new(sprite->frame, index); - - /* add cel */ - layer_add_cel(layer, cel); -#endif /* undo stuff */ if (undo_is_enabled(sprite->undo)) { @@ -386,7 +353,6 @@ char *GetUniqueLayerName(Sprite *sprite) Layer *FlattenLayers(Sprite *sprite) { - bool is_new_background = FALSE; JLink link, next; Layer *background; Image *image; @@ -406,6 +372,10 @@ Layer *FlattenLayers(Sprite *sprite) return NULL; } + /* open undo */ + if (undo_is_enabled(sprite->undo)) + undo_open(sprite->undo); + /* get the background layer from the sprite */ background = sprite_get_background_layer(sprite); if (!background) { @@ -417,9 +387,15 @@ Layer *FlattenLayers(Sprite *sprite) return NULL; } - layer_configure_as_background(background); + if (undo_is_enabled(sprite->undo)) + undo_add_layer(sprite->undo, sprite->set, background); - is_new_background = TRUE; + layer_add_layer(sprite->set, background); + + if (undo_is_enabled(sprite->undo)) + undo_move_layer(sprite->undo, background); + + layer_configure_as_background(background); /* get the color to clean the temporary image in each frame */ bgcolor = get_color_for_image(sprite->imgtype, @@ -428,18 +404,6 @@ Layer *FlattenLayers(Sprite *sprite) else bgcolor = 0; - /* open undo */ - if (undo_is_enabled(sprite->undo)) - undo_open(sprite->undo); - - /* add the new layer */ - if (is_new_background) { - if (undo_is_enabled(sprite->undo)) - undo_add_layer(sprite->undo, sprite->set, background); - - layer_add_layer(sprite->set, background); - } - /* copy all frames to the background */ for (frame=0; frameframes; frame++) { /* clear the image and render this frame */ @@ -462,8 +426,7 @@ Layer *FlattenLayers(Sprite *sprite) } else { /* if there aren't a cel in this frame in the background, we - have to create a copy of the image for the new cel which will - be created */ + have to create a copy of the image for the new cel */ cel_image = image_new_copy(image); /* TODO error handling: if (!cel_image) { ... } */ diff --git a/src/util/celmove.c b/src/util/celmove.c index 807caaeb5..9d9cafad4 100644 --- a/src/util/celmove.c +++ b/src/util/celmove.c @@ -44,8 +44,6 @@ static Layer *dst_layer = NULL; static int src_frame = 0; static int dst_frame = 0; -static bool frame_is_empty(Sprite *sprite, Layer *layer, int frame); - void set_frame_to_handle(Layer *_src_layer, int _src_frame, Layer *_dst_layer, int _dst_frame) { @@ -230,27 +228,3 @@ void copy_cel(void) set_frame_to_handle(NULL, 0, NULL, 0); } - -static bool frame_is_empty(Sprite *sprite, Layer *layer, int frame) -{ - switch (layer->gfxobj.type) { - - case GFXOBJ_LAYER_IMAGE: { - Cel *cel = layer_get_cel(layer, frame); - if (cel != NULL) - return FALSE; - break; - } - - case GFXOBJ_LAYER_SET: { - JLink link; - JI_LIST_FOR_EACH(layer->layers, link) - if (!frame_is_empty(sprite, link->data, frame)) - return FALSE; - break; - } - - } - - return TRUE; -} diff --git a/src/util/clipbrd.c b/src/util/clipbrd.c index 25df9563f..d4e0336b4 100644 --- a/src/util/clipbrd.c +++ b/src/util/clipbrd.c @@ -212,7 +212,7 @@ void paste_from_clipboard(void) } if (paste) { - int c, u1, v1, u2, v2; + int c, w, h, u1, v1, u2, v2; /* align to the destination cel-position */ for (c=0; c<4; ++c) { @@ -226,14 +226,19 @@ void paste_from_clipboard(void) u2 = MIN(dest_image->w-1, MAX(xout[0], MAX(xout[1], MAX(xout[2], xout[3])))); v2 = MIN(dest_image->h-1, MAX(yout[0], MAX(yout[1], MAX(yout[2], yout[3])))); - /* undo region */ - if (undo_is_enabled(current_sprite->undo)) - undo_image(current_sprite->undo, dest_image, u1, v1, u2-u1+1, v2-v1+1); + w = u2-u1+1; + h = v2-v1+1; - /* draw the transformed image */ - image_parallelogram(dest_image, image, - xout[0], yout[0], xout[1], yout[1], - xout[2], yout[2], xout[3], yout[3]); + if (w >= 1 && h >= 1) { + /* undo region */ + if (undo_is_enabled(current_sprite->undo)) + undo_image(current_sprite->undo, dest_image, u1, v1, w, h); + + /* draw the transformed image */ + image_parallelogram(dest_image, image, + xout[0], yout[0], xout[1], yout[1], + xout[2], yout[2], xout[3], yout[3]); + } } update_screen_for_sprite(current_sprite); diff --git a/src/util/render.c b/src/util/render.c index be398a214..142b650ed 100644 --- a/src/util/render.c +++ b/src/util/render.c @@ -21,6 +21,8 @@ #include "config.h" +#include + #include "jinete/jlist.h" #include "modules/palettes.h" @@ -42,9 +44,9 @@ static void render_layer(Sprite *sprite, Layer *layer, Image *image, bool render_background, bool render_transparent); -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); +static void merge_zoomed_image8(Image *dst, Image *src, int x, int y, int opacity, int blend_mode, int zoom); +static void merge_zoomed_image16(Image *dst, Image *src, int x, int y, int opacity, int blend_mode, int zoom); +static void merge_zoomed_image32(Image *dst, Image *src, int x, int y, int opacity, int blend_mode, int zoom); void set_preview_image(Layer *layer, Image *image) { @@ -74,17 +76,17 @@ Image *render_sprite(Sprite *sprite, case IMAGE_RGB: depth = 32; - zoomed_func = merge_zoomed_image4; + zoomed_func = merge_zoomed_image32; break; case IMAGE_GRAYSCALE: depth = 8; - zoomed_func = merge_zoomed_image2; + zoomed_func = merge_zoomed_image16; break; case IMAGE_INDEXED: depth = 8; - zoomed_func = merge_zoomed_image1; + zoomed_func = merge_zoomed_image8; break; default: @@ -258,7 +260,7 @@ static void render_layer(Sprite *sprite, Layer *layer, Image *image, } } -static void merge_zoomed_image1(Image *dst, Image *src, +static void merge_zoomed_image8(Image *dst, Image *src, int x, int y, int opacity, int blend_mode, int zoom) { @@ -408,11 +410,11 @@ done_with_blit:; jfree(scanline); } -static void merge_zoomed_image2(Image *dst, Image *src, - int x, int y, int opacity, - int blend_mode, int zoom) +static void merge_zoomed_image16(Image *dst, Image *src, + int x, int y, int opacity, + int blend_mode, int zoom) { - BLEND_COLOR blender = _graya_blenders[blend_mode]; + BLEND_COLOR blender; ase_uint16 *src_address; ase_uint16 *dst_address; ase_uint16 *scanline, *scanline_address; @@ -422,6 +424,10 @@ static void merge_zoomed_image2(Image *dst, Image *src, int sizeof_box, offsetx, offsety; int line_x, line_h, right, bottom; + assert(blend_mode >= 0 && blend_mode < BLEND_MODE_MAX); + + blender = _graya_blenders[blend_mode]; + box_w = 1<= 0 && blend_mode < BLEND_MODE_MAX); + + blender = _rgba_blenders[blend_mode]; + box_w = 1<hot_drag != colorbar->hot_drop) { - color_t color = colorbar_get_hotcolor(widget, colorbar->hot_drag); - colorbar_set_hotcolor(widget, colorbar->hot_drop, color); + if (colorbar->hot_drop != HOTCOLOR_NONE) { + color_t color = colorbar_get_hotcolor(widget, colorbar->hot_drag); + colorbar_set_hotcolor(widget, colorbar->hot_drop, color); + } jwidget_dirty(widget); } /* pick the color */ diff --git a/src/widgets/colbut.c b/src/widgets/colbut.c index 385e2262c..e8d8b2552 100644 --- a/src/widgets/colbut.c +++ b/src/widgets/colbut.c @@ -216,9 +216,10 @@ static void colorbutton_draw(JWidget widget) { ColorButton *colorbutton = colorbutton_data(widget); struct jrect box, text, icon; - jwidget_get_texticon_info(widget, &box, &text, &icon, 0, 0, 0); char buf[256]; + jwidget_get_texticon_info(widget, &box, &text, &icon, 0, 0, 0); + draw_color_button (ji_screen, widget->rc->x1, widget->rc->y1, diff --git a/src/widgets/editor/editor.c b/src/widgets/editor/editor.c index ab82def49..d25052c9b 100644 --- a/src/widgets/editor/editor.c +++ b/src/widgets/editor/editor.c @@ -1071,7 +1071,7 @@ static bool editor_msg_proc(JWidget widget, JMessage msg) return TRUE; } /* draw */ - else if (current_tool) { + else if (current_tool && editor->sprite->layer) { editor->state = EDIT_DRAWING; } diff --git a/src/widgets/statebar.c b/src/widgets/statebar.c index b0d9a303c..4e742de31 100644 --- a/src/widgets/statebar.c +++ b/src/widgets/statebar.c @@ -144,7 +144,7 @@ void statusbar_set_text(JWidget widget, int msecs, const char *format, ...) if (widget->text) jfree(widget->text); - widget->text = buf ? jstrdup(buf) : NULL; + widget->text = jstrdup(buf); statusbar->timeout = ji_clock + msecs; jwidget_dirty(widget); } diff --git a/third_party/jpeg/jconfig.h b/third_party/jpeg/jconfig.h index 9594ec56b..e92cfb870 100644 --- a/third_party/jpeg/jconfig.h +++ b/third_party/jpeg/jconfig.h @@ -20,7 +20,11 @@ #ifdef JPEG_INTERNALS #undef RIGHT_SHIFT_IS_UNSIGNED -#define INLINE __inline__ +#ifdef __GNUC__ + #define INLINE __inline__ +#else + #define INLINE +#endif /* These are for configuring the JPEG memory manager. */ #undef DEFAULT_MAX_MEM #undef NO_MKTEMP