diff --git a/ChangeLog b/ChangeLog index d966282b0..6d3d21fde 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2008-01-23 David A. Capello + + * src/widgets/editor/editor.c (show_drawing_cursor): Added the + 'forbidden' cursor. + + * src/modules/editors.c (editors_draw_sprite_tiled): Fixed for + cels with differents position. + + * src/dialogs/filmedit.c (layer_box_msg_proc): Added buttons to + toggle readable/writable flags to layers. + + * src/raster/sprite.h (struct Sprite): Added 'locked' and 'mutex' + fields. + 2008-01-21 David A. Capello * src/jinete/jmanager.c (jmanager_generate_messages): Focus magnet diff --git a/NEWS.txt b/NEWS.txt index 926dfa9d0..dcd6bd168 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -5,25 +5,25 @@ NEWS 0.6 --- -+ Added support to load and save PNG files (through libpng). ++ Added support to load and save PNG files (through 'libpng'). + Replaced the "List" menu with the tabs selector. + Better file selector. + Restructured all the menus (more user friendly options). - Temporaly removed a lot of complex functionality: Mask-Repository (but you can use .msk files yet), Draw-Text, - Layer-Sets and Link-Cels. + Layer-Sets and Linked-Cels. + New XML format for the menus. - Removed menu scripting customization. - Removed screen saver. - Removed sessions. -+ GUI enhanced: ++ Enhanced GUI: + more borders for windows and more spacing between widgets. - + better mouse behavior (in Windows). -+ Finished the support for ICO files. + + better mouse behavior (now in Windows the mouse is captured). + Finally screen scaling supported (with double-buffering). This means that you can use a screen of 320x240 between a window of 640x480 (screen-scaling x2). This is the new default video mode for ASE. -+ Fixed compilations errors for Allegro 4.2 ++ Fixed other minor problems when you drawn in 'tiled mode' or 'paste' + the clipboard. 0.5 --- diff --git a/TODO.txt b/TODO.txt index 7a6fe7e6b..1a0cfe866 100644 --- a/TODO.txt +++ b/TODO.txt @@ -4,9 +4,7 @@ High priority work - the user_data of hook_signal should be void*. - search for TODO; - Problems: - - 100% CPU - test UNDO in 64bits plataforms (reported by Jon Rafkind); - - Add menus for play animation, a menu for all animation stuff - ver por el nuevo load_font de Allegro. - complete palette operations, and palette editor (it needs a slider or something to move between palette changes); @@ -20,17 +18,17 @@ High priority work + 09lists + 20combo + 21manage -- fix "tiled mode" when it's used in frames that doesn't have the same - size of the sprite; ++ finished the support for ICO files. - add "size" to GUI font (for TTF fonts); -- layer movement (between sets) in filmeditor; +- layer movement between sets in filmeditor; + + add all the "set" stuff again; - quick swap; + the regions mustn't be overlapped; - options to change the curve type (in curedit.c); -- sprite resize; -- canvas size; - + with the current crop this isn't necessary anymore; - + anyway, it's a good way to expand the graphics +- More Commands: + + resize sprite; + + rotate sprite; + + canvas size; - gauss blur; - pal-operations (sort, quantize, gamma by color-curves, etc.); - RGB and HSV effects; @@ -54,11 +52,8 @@ Wish-list + 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: + 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 position from the starting point of movement; diff --git a/makefile.lst b/makefile.lst index 3d2f4aafe..e58e84024 100644 --- a/makefile.lst +++ b/makefile.lst @@ -137,6 +137,7 @@ COMMON_SOURCES = \ src/jinete/jmem.c \ src/jinete/jmenu.c \ src/jinete/jmessage.c \ + src/jinete/jmutex.c \ src/jinete/jpanel.c \ src/jinete/jquickmenu.c \ src/jinete/jrect.c \ diff --git a/src/commands/cmd_cel_properties.c b/src/commands/cmd_cel_properties.c index 5c0f4bc90..10d1dc142 100644 --- a/src/commands/cmd_cel_properties.c +++ b/src/commands/cmd_cel_properties.c @@ -1,5 +1,5 @@ /* ASE - Allegro Sprite Editor - * Copyright (C) 2007 David A. Capello + * Copyright (C) 2007, 2008 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 @@ -35,35 +35,40 @@ static bool cmd_cel_properties_enabled(const char *argument) { - return current_sprite != NULL; + return + is_current_sprite_not_locked() + && current_sprite->layer + && layer_get_cel(current_sprite->layer, + current_sprite->frame) != NULL; } static void cmd_cel_properties_execute(const char *argument) { - JWidget window, entry_frame, entry_xpos, entry_ypos, slider_opacity, button_ok; + JWidget window = NULL; + JWidget entry_frame, entry_xpos, entry_ypos, slider_opacity, button_ok; Sprite *sprite; Layer *layer; Cel *cel; char buf[1024]; /* get current sprite */ - sprite = current_sprite; + sprite = lock_current_sprite(); if (!sprite) return; /* get selected layer */ layer = sprite->layer; if (!layer) - return; + goto done; /* get current cel */ cel = layer_get_cel(layer, sprite->frame); if (!cel) - return; + goto done; window = load_widget("celprop.jid", "cel_properties"); if (!window) - return; + goto done; entry_frame = jwidget_find_name(window, "frame"); entry_xpos = jwidget_find_name(window, "xpos"); @@ -71,6 +76,12 @@ static void cmd_cel_properties_execute(const char *argument) slider_opacity = jwidget_find_name(window, "opacity"); button_ok = jwidget_find_name(window, "ok"); + /* if the layer isn't writable */ + if (!layer_is_writable(layer)) { + jwidget_set_text(button_ok, _("Locked")); + jwidget_disable(button_ok); + } + sprintf(buf, "%d", cel->frame+1); jwidget_set_text(entry_frame, buf); @@ -136,7 +147,11 @@ static void cmd_cel_properties_execute(const char *argument) break; } - jwidget_free(window); +done:; + if (window) + jwidget_free(window); + + sprite_unlock(sprite); } Command cmd_cel_properties = { diff --git a/src/commands/cmd_clear.c b/src/commands/cmd_clear.c index bbb362dc1..524e509a8 100644 --- a/src/commands/cmd_clear.c +++ b/src/commands/cmd_clear.c @@ -1,5 +1,5 @@ /* ASE - Allegro Sprite Editor - * Copyright (C) 2007 David A. Capello + * Copyright (C) 2007, 2008 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 @@ -21,10 +21,12 @@ #ifndef USE_PRECOMPILED_HEADER #include "commands/commands.h" +#include "core/app.h" #include "modules/gui.h" #include "modules/sprites.h" #include "raster/sprite.h" #include "util/misc.h" +#include "widgets/colbar.h" #endif @@ -39,7 +41,7 @@ static void cmd_clear_execute(const char *argument) Sprite *sprite = current_sprite; /* clear the mask */ - ClearMask(); + ClearMask(color_bar_get_color(app_get_color_bar(), 1)); /* refresh the sprite */ update_screen_for_sprite(sprite); diff --git a/src/commands/cmd_configure_tools.c b/src/commands/cmd_configure_tools.c index 582570ae1..a67a4cc22 100644 --- a/src/commands/cmd_configure_tools.c +++ b/src/commands/cmd_configure_tools.c @@ -74,11 +74,14 @@ static void cmd_configure_tools_execute(const char *argument) JWidget brush_mode_box, brush_mode; JWidget check_onionskin; JWidget brush_preview; + bool first_time = FALSE; if (!window) { window = load_widget("toolconf.jid", "configure_tool"); if (!window) return; + + first_time = TRUE; } /* if the window is opened, close it */ else if (jwidget_is_visible(window)) { @@ -108,29 +111,53 @@ static void cmd_configure_tools_execute(const char *argument) } /* cursor-color */ - cursor_color = color_button_new(get_cursor_color(), IMAGE_INDEXED); - /* brush-preview */ - brush_preview = jwidget_new(JI_WIDGET); - brush_preview->min_w = 32 + 4; - brush_preview->min_h = 32 + 4; - jwidget_add_hook(brush_preview, JI_WIDGET, - brush_preview_msg_proc, NULL); - /* brush-type */ - brush_type = group_button_new(3, 1, get_brush_type(), - GFX_BRUSH_CIRCLE, - GFX_BRUSH_SQUARE, - GFX_BRUSH_LINE); - /* brush-type */ - brush_mode = group_button_new(3, 1, get_brush_mode(), - GFX_DRAWMODE_OPAQUE, - GFX_DRAWMODE_GLASS, - GFX_DRAWMODE_SEMI); + if (first_time) { + cursor_color = color_button_new(get_cursor_color(), IMAGE_INDEXED); + jwidget_set_name(cursor_color, "cursor_color"); + } + else { + cursor_color = jwidget_find_name(window, "cursor_color"); + } - /* append children */ - jwidget_add_child(cursor_color_box, cursor_color); - jwidget_add_child(brush_preview_box, brush_preview); - jwidget_add_child(brush_type_box, brush_type); - jwidget_add_child(brush_mode_box, brush_mode); + /* brush-preview */ + if (first_time) { + brush_preview = jwidget_new(JI_WIDGET); + brush_preview->min_w = 32 + 4; + brush_preview->min_h = 32 + 4; + + jwidget_set_name(brush_preview, "brush_preview"); + jwidget_add_hook(brush_preview, JI_WIDGET, + brush_preview_msg_proc, NULL); + } + else { + brush_preview = jwidget_find_name(window, "brush_preview"); + } + + /* brush-type */ + if (first_time) { + brush_type = group_button_new(3, 1, get_brush_type(), + GFX_BRUSH_CIRCLE, + GFX_BRUSH_SQUARE, + GFX_BRUSH_LINE); + + jwidget_set_name(brush_type, "brush_type"); + } + else { + brush_type = jwidget_find_name(window, "brush_type"); + } + + /* brush-mode */ + if (first_time) { + brush_mode = group_button_new(3, 1, get_brush_mode(), + GFX_DRAWMODE_OPAQUE, + GFX_DRAWMODE_GLASS, + GFX_DRAWMODE_SEMI); + + jwidget_set_name(brush_mode, "brush_mode"); + } + else { + brush_mode = jwidget_find_name(window, "brush_mode"); + } if (get_filled_mode()) jwidget_select(filled); if (get_tiled_mode()) jwidget_select(tiled); @@ -143,21 +170,30 @@ static void cmd_configure_tools_execute(const char *argument) jslider_set_value(air_speed, get_air_speed()); if (get_onionskin()) jwidget_select(check_onionskin); - HOOK(window, JI_SIGNAL_WINDOW_CLOSE, window_close_hook, 0); - HOOK(filled, JI_SIGNAL_CHECK_CHANGE, filled_check_change_hook, 0); - HOOK(tiled, JI_SIGNAL_CHECK_CHANGE, tiled_check_change_hook, 0); - HOOK(use_grid, JI_SIGNAL_CHECK_CHANGE, use_grid_check_change_hook, 0); - HOOK(view_grid, JI_SIGNAL_CHECK_CHANGE, view_grid_check_change_hook, 0); - HOOK(set_grid, JI_SIGNAL_BUTTON_SELECT, set_grid_button_select_hook, 0); - HOOK(brush_size, JI_SIGNAL_SLIDER_CHANGE, brush_size_slider_change_hook, brush_preview); - HOOK(brush_angle, JI_SIGNAL_SLIDER_CHANGE, brush_angle_slider_change_hook, brush_preview); - HOOK(brush_type, SIGNAL_GROUP_BUTTON_CHANGE, brush_type_change_hook, brush_preview); - HOOK(brush_mode, SIGNAL_GROUP_BUTTON_CHANGE, brush_mode_change_hook, 0); - HOOK(glass_dirty, JI_SIGNAL_SLIDER_CHANGE, glass_dirty_slider_change_hook, 0); - HOOK(air_speed, JI_SIGNAL_SLIDER_CHANGE, air_speed_slider_change_hook, 0); - HOOK(spray_width, JI_SIGNAL_SLIDER_CHANGE, spray_width_slider_change_hook, 0); - HOOK(cursor_color, SIGNAL_COLOR_BUTTON_CHANGE, cursor_button_change_hook, 0); - HOOK(check_onionskin, JI_SIGNAL_CHECK_CHANGE, onionskin_check_change_hook, 0); + if (first_time) { + /* append children */ + jwidget_add_child(cursor_color_box, cursor_color); + jwidget_add_child(brush_preview_box, brush_preview); + jwidget_add_child(brush_type_box, brush_type); + jwidget_add_child(brush_mode_box, brush_mode); + + /* append hooks */ + HOOK(window, JI_SIGNAL_WINDOW_CLOSE, window_close_hook, 0); + HOOK(filled, JI_SIGNAL_CHECK_CHANGE, filled_check_change_hook, 0); + HOOK(tiled, JI_SIGNAL_CHECK_CHANGE, tiled_check_change_hook, 0); + HOOK(use_grid, JI_SIGNAL_CHECK_CHANGE, use_grid_check_change_hook, 0); + HOOK(view_grid, JI_SIGNAL_CHECK_CHANGE, view_grid_check_change_hook, 0); + HOOK(set_grid, JI_SIGNAL_BUTTON_SELECT, set_grid_button_select_hook, 0); + HOOK(brush_size, JI_SIGNAL_SLIDER_CHANGE, brush_size_slider_change_hook, brush_preview); + HOOK(brush_angle, JI_SIGNAL_SLIDER_CHANGE, brush_angle_slider_change_hook, brush_preview); + HOOK(brush_type, SIGNAL_GROUP_BUTTON_CHANGE, brush_type_change_hook, brush_preview); + HOOK(brush_mode, SIGNAL_GROUP_BUTTON_CHANGE, brush_mode_change_hook, 0); + HOOK(glass_dirty, JI_SIGNAL_SLIDER_CHANGE, glass_dirty_slider_change_hook, 0); + HOOK(air_speed, JI_SIGNAL_SLIDER_CHANGE, air_speed_slider_change_hook, 0); + HOOK(spray_width, JI_SIGNAL_SLIDER_CHANGE, spray_width_slider_change_hook, 0); + HOOK(cursor_color, SIGNAL_COLOR_BUTTON_CHANGE, cursor_button_change_hook, 0); + HOOK(check_onionskin, JI_SIGNAL_CHECK_CHANGE, onionskin_check_change_hook, 0); + } /* default position */ jwindow_remap(window); diff --git a/src/commands/cmd_copy.c b/src/commands/cmd_copy.c index 697029b0f..465e5af55 100644 --- a/src/commands/cmd_copy.c +++ b/src/commands/cmd_copy.c @@ -1,5 +1,5 @@ /* ASE - Allegro Sprite Editor - * Copyright (C) 2007 David A. Capello + * Copyright (C) 2007, 2008 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 @@ -42,7 +42,7 @@ static bool cmd_copy_enabled(const char *argument) (!current_sprite->mask->bitmap)) return FALSE; else - return GetImage() ? TRUE: FALSE; + return GetImage(current_sprite) ? TRUE: FALSE; } static void cmd_copy_execute(const char *argument) diff --git a/src/commands/cmd_crop.c b/src/commands/cmd_crop.c index 248bff411..883d9366d 100644 --- a/src/commands/cmd_crop.c +++ b/src/commands/cmd_crop.c @@ -1,5 +1,5 @@ /* ASE - Allegro Sprite Editor - * Copyright (C) 2007 David A. Capello + * Copyright (C) 2007, 2008 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 @@ -103,7 +103,7 @@ static bool cmd_crop_enabled(const char *argument) (!current_sprite->mask->bitmap)) return FALSE; else - return GetImage() ? TRUE: FALSE; + return GetImage(current_sprite) ? TRUE: FALSE; } Command cmd_crop_sprite = { diff --git a/src/commands/cmd_cut.c b/src/commands/cmd_cut.c index 8341df0e9..50c03544d 100644 --- a/src/commands/cmd_cut.c +++ b/src/commands/cmd_cut.c @@ -1,5 +1,5 @@ /* ASE - Allegro Sprite Editor - * Copyright (C) 2007 David A. Capello + * Copyright (C) 2007, 2008 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 @@ -42,7 +42,7 @@ static bool cmd_cut_enabled(const char *argument) (!current_sprite->mask->bitmap)) return FALSE; else - return GetImage() ? TRUE: FALSE; + return GetImage(current_sprite) ? TRUE: FALSE; } static void cmd_cut_execute(const char *argument) diff --git a/src/commands/fx/cmd_color_curve.c b/src/commands/fx/cmd_color_curve.c index 748bb000e..096d8ebf4 100644 --- a/src/commands/fx/cmd_color_curve.c +++ b/src/commands/fx/cmd_color_curve.c @@ -70,7 +70,7 @@ static void cmd_color_curve_execute(const char *argument) curve_add_point(the_curve, curve_point_new(255, 255)); } - image = GetImage(); + image = GetImage(current_sprite); if (!image) return; diff --git a/src/commands/fx/cmd_convolution_matrix.c b/src/commands/fx/cmd_convolution_matrix.c index c4a111d10..b9c59cfbf 100644 --- a/src/commands/fx/cmd_convolution_matrix.c +++ b/src/commands/fx/cmd_convolution_matrix.c @@ -87,7 +87,7 @@ static void cmd_convolution_matrix_execute(const char *argument) Image *image; Effect *effect; - image = GetImage(); + image = GetImage(current_sprite); if (!image) return; diff --git a/src/commands/fx/cmd_despeckle.c b/src/commands/fx/cmd_despeckle.c index 7a62b34e4..c50fda0f7 100644 --- a/src/commands/fx/cmd_despeckle.c +++ b/src/commands/fx/cmd_despeckle.c @@ -70,7 +70,7 @@ static void cmd_despeckle_execute(const char *argument) Effect *effect; char buf[32]; - image = GetImage(); + image = GetImage(current_sprite); if (!image) return; diff --git a/src/commands/fx/cmd_invert_color.c b/src/commands/fx/cmd_invert_color.c index fbee4e6c0..ce3015e94 100644 --- a/src/commands/fx/cmd_invert_color.c +++ b/src/commands/fx/cmd_invert_color.c @@ -64,7 +64,7 @@ static void cmd_invert_color_execute(const char *argument) Image *image; Effect *effect; - image = GetImage(); + image = GetImage(current_sprite); if (!image) return; diff --git a/src/commands/fx/cmd_replace_color.c b/src/commands/fx/cmd_replace_color.c index d113236dd..7ca0354a2 100644 --- a/src/commands/fx/cmd_replace_color.c +++ b/src/commands/fx/cmd_replace_color.c @@ -59,26 +59,32 @@ static void make_preview(void); static bool cmd_replace_color_enabled(const char *argument) { - return current_sprite != NULL; + return is_current_sprite_not_locked(); } static void cmd_replace_color_execute(const char *argument) { - JWidget window, color_buttons_box; + JWidget window = NULL; + JWidget color_buttons_box; JWidget button1_1, button1_2; JWidget button2_1, button2_2; JWidget box_target, target_button; JWidget button_ok; Image *image; Effect *effect; + Sprite *sprite; - image = GetImage(); - if (!image) + sprite = lock_current_sprite(); + if (!sprite) return; + image = GetImage(current_sprite); + if (!image) + goto done; + window = load_widget("replcol.jid", "replace_color"); if (!window) - return; + goto done; if (!get_widgets(window, "color_buttons_box", &color_buttons_box, @@ -90,15 +96,13 @@ static void cmd_replace_color_execute(const char *argument) "fuzziness", &slider_fuzziness, "target", &box_target, "button_ok", &button_ok, NULL)) { - jwidget_free(window); - return; + goto done; } - effect = effect_new(current_sprite, "replace_color"); + effect = effect_new(sprite, "replace_color"); if (!effect) { console_printf(_("Error creating the effect applicator for this sprite\n")); - jwidget_free(window); - return; + goto done; } preview = preview_new(effect); @@ -160,7 +164,11 @@ static void cmd_replace_color_execute(const char *argument) /* save window configuration */ save_window_pos(window, "ReplaceColor"); - jwidget_free(window); +done:; + if (window) + jwidget_free(window); + + sprite_unlock(sprite); } static int button_1_select_hook(JWidget widget, int user_data) diff --git a/src/dialogs/dmapgen.c b/src/dialogs/dmapgen.c index e45bab3bb..14942e413 100644 --- a/src/dialogs/dmapgen.c +++ b/src/dialogs/dmapgen.c @@ -102,7 +102,7 @@ void dialogs_mapgen(void) sprite = sprite_new_with_layer(IMAGE_INDEXED, 256, 256); set_current_sprite(sprite); - preview_map = image_viewer_new(GetImage()); + preview_map = image_viewer_new(GetImage(current_sprite)); /* set palette */ if (new_palette) @@ -194,7 +194,7 @@ static void regen_map(int forced) } /* generate the map */ - mapgen(GetImage(), seed, factor); + mapgen(GetImage(current_sprite), seed, factor); jwidget_dirty(preview_map); } } diff --git a/src/dialogs/drawtext.c b/src/dialogs/drawtext.c index cea80a9b6..47a1c3582 100644 --- a/src/dialogs/drawtext.c +++ b/src/dialogs/drawtext.c @@ -62,7 +62,7 @@ void dialogs_draw_text(void) if (!is_interactive() || !current_sprite) return; - dest_image = GetImage(); + dest_image = GetImage(current_sprite); if (!dest_image) return; diff --git a/src/dialogs/filmedit.c b/src/dialogs/filmedit.c index 6d3d7124d..7da8fd000 100644 --- a/src/dialogs/filmedit.c +++ b/src/dialogs/filmedit.c @@ -253,11 +253,12 @@ static bool layer_box_msg_proc(JWidget widget, JMessage msg) JWidget view = jwidget_get_view(widget); JRect vp = jview_get_viewport_position(view); BITMAP *bmp = create_bitmap(jrect_w(vp), jrect_h(vp)); + BITMAP *icon; int scroll_x, scroll_y; bool selected_layer; int pos, layers; Layer *layer; - int y, h; + int y, h, y_mid; jview_get_scroll(view, &scroll_x, &scroll_y); @@ -273,7 +274,8 @@ static bool layer_box_msg_proc(JWidget widget, JMessage msg) layers = count_layers(sprite->set); for (pos=0; posset, pos); - + y_mid = y+h/2; + selected_layer = (state != STATE_MOVING) ? (sprite->layer == layer): (layer == layer_box->layer); @@ -289,6 +291,22 @@ static bool layer_box_msg_proc(JWidget widget, JMessage msg) hline(bmp, 0, y, bmp->w-1, makecol(0, 0, 0)); hline(bmp, 0, y+h, bmp->w-1, makecol(0, 0, 0)); + /* draw the eye (readable flag) */ + icon = get_gfx(layer_is_readable(layer) ? GFX_BOX_SHOW: + GFX_BOX_HIDE); + if (selected_layer) + jdraw_inverted_sprite(bmp, icon, 2, y_mid-4); + else + draw_sprite(bmp, icon, 2, y_mid-4); + + /* draw the padlock (writable flag) */ + icon = get_gfx(layer_is_writable(layer) ? GFX_BOX_UNLOCK: + GFX_BOX_LOCK); + if (selected_layer) + jdraw_inverted_sprite(bmp, icon, 2+8+2, y_mid-4); + else + draw_sprite(bmp, icon, 2+8+2, y_mid-4); + #if 0 { int count, pos; @@ -308,20 +326,23 @@ static bool layer_box_msg_proc(JWidget widget, JMessage msg) #else { int tabs = -2; - int final_y = y+h/2; Layer *l = layer; + while (l->gfxobj.type != GFXOBJ_SPRITE) { if (++tabs > 0) { /* JList item = jlist_find(((Layer *)l->parent)->layers, l); */ - int y1 = final_y-LAYSIZE/2; - int y2 = final_y+LAYSIZE/2; -/* int y2 = item->prev ? final_y+LAYSIZE/2 : final_y; */ + int y1 = y_mid-LAYSIZE/2; + int y2 = y_mid+LAYSIZE/2; +/* int y2 = item->prev ? y_mid+LAYSIZE/2 : y_mid; */ vline(bmp, tabs*16-1, y1, y2, makecol(0, 0, 0)); } l = (Layer *)l->parent; } + + /* draw the layer name */ textout(bmp, widget->text_font, layer->name, - 2+tabs*16, final_y-text_height(widget->text_font)/2, + 2+8+2+8+2+8+tabs*16, + y_mid-text_height(widget->text_font)/2, selected_layer ? makecol(255, 255, 255): makecol(0, 0, 0)); } @@ -390,22 +411,37 @@ static bool layer_box_msg_proc(JWidget widget, JMessage msg) case JM_BUTTONPRESSED: jwidget_hard_capture_mouse(widget); - if (msg->any.shifts & KB_SHIFT_FLAG) { + /* scroll */ + if (msg->any.shifts & KB_SHIFT_FLAG || + msg->mouse.middle) { state = STATE_SCROLLING; jmouse_set_cursor(JI_CURSOR_MOVE); } else { - state = STATE_MOVING; - jmouse_set_cursor(JI_CURSOR_MOVE); - 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; */ + + /* toggle icon status (eye or the padlock) */ + if (msg->mouse.x < 2+8+2+8+2) { + if (msg->mouse.x <= 2+8+1) { + layer_box->layer->readable = !layer_box->layer->readable; + } + else { + layer_box->layer->writable = !layer_box->layer->writable; + } + jwidget_dirty(widget); + } + /* move */ + else { + state = STATE_MOVING; + jmouse_set_cursor(JI_CURSOR_MOVE); + } } case JM_MOTION: - if (jwidget_has_capture (widget)) { + if (jwidget_has_capture(widget)) { /* scroll */ if (state == STATE_SCROLLING) control_scroll_motion(widget, layer_box, layer_box->cel_box); diff --git a/src/dialogs/maskcol.c b/src/dialogs/maskcol.c index a54d50e17..b7a62e833 100644 --- a/src/dialogs/maskcol.c +++ b/src/dialogs/maskcol.c @@ -68,7 +68,7 @@ void dialogs_mask_color(void) if (!is_interactive () || !sprite) return; - image = GetImage(); + image = GetImage(current_sprite); if (!image) return; diff --git a/src/dialogs/quick.c b/src/dialogs/quick.c index 41c628de2..8883927cf 100644 --- a/src/dialogs/quick.c +++ b/src/dialogs/quick.c @@ -22,6 +22,7 @@ #include +#include "core/app.h" #include "core/cfg.h" #include "core/core.h" #include "modules/gui.h" @@ -36,6 +37,7 @@ #include "raster/sprite.h" #include "raster/undo.h" #include "util/misc.h" +#include "widgets/colbar.h" #endif @@ -97,7 +99,7 @@ static void do_quick(int action) if (action == ACTION_MOVE) { int enabled = undo_is_enabled(sprite->undo); undo_disable(sprite->undo); - ClearMask(); + ClearMask(color_bar_get_color(app_get_color_bar(), 1)); if (enabled) undo_enable(sprite->undo); } diff --git a/src/dialogs/vectmap.c b/src/dialogs/vectmap.c index aa0ad163a..b339955e4 100644 --- a/src/dialogs/vectmap.c +++ b/src/dialogs/vectmap.c @@ -139,7 +139,7 @@ void dialogs_vector_map(void) if (!is_interactive () || !sprite) return; - image = GetImage(); + image = GetImage(current_sprite); if (!image) return; diff --git a/src/file/ico_format.c b/src/file/ico_format.c index 71cae2263..0b78a933f 100644 --- a/src/file/ico_format.c +++ b/src/file/ico_format.c @@ -1,5 +1,5 @@ /* ASE - Allegro Sprite Editor - * Copyright (C) 2001-2005, 2007 David A. Capello + * Copyright (C) 2001-2005, 2007, 2008 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 @@ -47,7 +47,7 @@ FileFormat format_ico = static Sprite *load_ICO(const char *filename) { - return NULL; + return NULL; /* TODO */ } static int save_ICO(Sprite *sprite) diff --git a/src/jinete/jbase.h b/src/jinete/jbase.h index 9adddcde9..8d5a28e85 100644 --- a/src/jinete/jbase.h +++ b/src/jinete/jbase.h @@ -231,6 +231,7 @@ enum { typedef unsigned int JID; +typedef void *JMutex; typedef struct jaccel *JAccel; typedef struct jhook *JHook; typedef struct jquickmenu *JQuickMenu; diff --git a/src/jinete/jdraw.c b/src/jinete/jdraw.c index 76df6b6fb..4bb1cc21a 100644 --- a/src/jinete/jdraw.c +++ b/src/jinete/jdraw.c @@ -185,6 +185,23 @@ void jdraw_widget_text(JWidget widget, int fg, int bg, bool fill_bg) } } +void jdraw_inverted_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y) +{ + register int c, mask = bitmap_mask_color(sprite); + int u, v; + + for (v=0; vh; ++v) { + for (u=0; uw; ++u) { + c = getpixel(sprite, u, v); + if (c != mask) + putpixel(bmp, x+u, y+v, + makecol(255-getr(c), + 255-getg(c), + 255-getb(c))); + } + } +} + void ji_blit_region(JRegion region, int dx, int dy) { int c, nrects = JI_REGION_NUM_RECTS(region); diff --git a/src/jinete/jdraw.h b/src/jinete/jdraw.h index 6bcc59a8c..dc268494e 100644 --- a/src/jinete/jdraw.h +++ b/src/jinete/jdraw.h @@ -47,6 +47,7 @@ JI_BEGIN_DECLS getb(c1)+(getb(c2)-getb(c1)) * step / max) struct FONT; +struct BITMAP; void jdraw_rect(const JRect rect, int color); void jdraw_rectfill(const JRect rect, int color); @@ -58,6 +59,8 @@ void jdraw_char(struct FONT *f, int chr, int x, int y, int fg, int bg, bool fill void jdraw_text(struct FONT *f, const char *text, int x, int y, int fg, int bg, bool fill_bg); void jdraw_widget_text(JWidget widget, int fg, int bg, bool fill_bg); +void jdraw_inverted_sprite(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); + void ji_blit_region(JRegion region, int dx, int dy); JI_END_DECLS diff --git a/src/jinete/jinete.h b/src/jinete/jinete.h index d13a7357c..4700f5f83 100644 --- a/src/jinete/jinete.h +++ b/src/jinete/jinete.h @@ -52,6 +52,7 @@ #include "jinete/jmanager.h" #include "jinete/jmenu.h" #include "jinete/jmessage.h" +#include "jinete/jmutex.h" #include "jinete/jpanel.h" #include "jinete/jquickmenu.h" #include "jinete/jrect.h" diff --git a/src/jinete/jsystem.h b/src/jinete/jsystem.h index 49f0f0e45..62adf18b8 100644 --- a/src/jinete/jsystem.h +++ b/src/jinete/jsystem.h @@ -72,6 +72,7 @@ enum { JI_CURSOR_NULL, JI_CURSOR_NORMAL, JI_CURSOR_NORMAL_ADD, + JI_CURSOR_FORBIDDEN, JI_CURSOR_HAND, JI_CURSOR_MOVE, JI_CURSOR_SIZE_TL, diff --git a/src/jinete/themes/Makefile.icons b/src/jinete/themes/Makefile.icons index feb711d2e..4fe9f23cc 100644 --- a/src/jinete/themes/Makefile.icons +++ b/src/jinete/themes/Makefile.icons @@ -4,4 +4,4 @@ pcx2data.exe: pcx2data.c all: pcx2data.exe gen: all - pcx2data.exe stand/*.pcx > stdicons.c + ./pcx2data.exe stand/*.pcx > jstandard_theme_icons.h diff --git a/src/jinete/themes/jstandard_theme.c b/src/jinete/themes/jstandard_theme.c index 04637b996..319d47ce8 100644 --- a/src/jinete/themes/jstandard_theme.c +++ b/src/jinete/themes/jstandard_theme.c @@ -53,8 +53,8 @@ /* "icons_data" indexes */ enum { FIRST_CURSOR = 0, - LAST_CURSOR = 11, - ICON_CHECK_EDGE = 12, + LAST_CURSOR = 12, + ICON_CHECK_EDGE = 13, ICON_CHECK_MARK, ICON_CLOSE, ICON_MENU_MARK, @@ -69,6 +69,7 @@ static struct { } icons_data[ICONS] = { { FALSE, default_theme_cnormal }, { FALSE, default_theme_cnoradd }, + { FALSE, default_theme_cforbidden }, { FALSE, default_theme_chand }, { FALSE, default_theme_cmove }, { FALSE, default_theme_csizetl }, @@ -243,6 +244,7 @@ static BITMAP *theme_set_cursor(int type, int *focus_x, int *focus_y) case JI_CURSOR_NULL: case JI_CURSOR_NORMAL: case JI_CURSOR_NORMAL_ADD: + case JI_CURSOR_FORBIDDEN: *focus_x = 0; *focus_y = 0; break; @@ -581,19 +583,7 @@ static void theme_draw_button(JWidget widget) if (jwidget_is_enabled(widget)) { /* selected */ if (jwidget_is_selected(widget)) { - register int c, mask = bitmap_mask_color(icon_bmp); - int x, y; - - for (y=0; yh; ++y) { - for (x=0; xw; ++x) { - c = getpixel(icon_bmp, x, y); - if (c != mask) - putpixel(ji_screen, icon.x1+x, icon.y1+y, - makecol(255-getr(c), - 255-getg(c), - 255-getb(c))); - } - } + jdraw_inverted_sprite(ji_screen, icon_bmp, icon.x1, icon.y1); } /* non-selected */ else { diff --git a/src/jinete/themes/jstandard_theme_icons.h b/src/jinete/themes/jstandard_theme_icons.h index 37c6ddab2..872f5c810 100644 --- a/src/jinete/themes/jstandard_theme_icons.h +++ b/src/jinete/themes/jstandard_theme_icons.h @@ -1,5 +1,25 @@ /* Generated by pcx2data */ +static unsigned char default_theme_cforbidden[258] = { + 16, 16, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 3, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 3, 3, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 3, 3, 3, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 3, 3, 3, 3, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 3, 3, 3, 3, 3, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 3, 3, 3, 3, 3, 3, 3, 1, 0, 1, 1, 1, 0, 0, 0, + 1, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 0, + 1, 3, 3, 3, 3, 3, 1, 1, 1, 1, 3, 3, 1, 1, 1, 0, + 1, 3, 3, 1, 3, 3, 1, 1, 1, 3, 3, 1, 1, 1, 1, 1, + 0, 1, 1, 1, 3, 3, 3, 1, 1, 3, 1, 1, 1, 3, 1, 1, + 0, 0, 0, 0, 1, 3, 3, 1, 1, 1, 1, 1, 3, 3, 1, 1, + 0, 0, 0, 0, 1, 3, 3, 1, 1, 1, 1, 3, 3, 1, 1, 0, + 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0 +}; + static unsigned char default_theme_chand[258] = { 16, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/src/modules/color.c b/src/modules/color.c index 7b4b82ae2..853f60a68 100644 --- a/src/modules/color.c +++ b/src/modules/color.c @@ -40,9 +40,6 @@ static struct { int data; } color_struct; -static char *fg_color = NULL; -static char *bg_color = NULL; - static void fill_color_struct(const char *color); static int get_mask_for_bitmap(int depth); @@ -53,50 +50,6 @@ int init_module_color(void) void exit_module_color(void) { - set_bg_color(NULL); - set_bg_color(NULL); -} - -const char *get_fg_color(void) -{ - JWidget color_bar = app_get_color_bar(); - - if (color_bar && !fg_color) - return color_bar_get_color(color_bar, 0); - else - return fg_color ? fg_color: DEFAULT_FG; -} - -const char *get_bg_color(void) -{ - JWidget color_bar = app_get_color_bar(); - - if (color_bar && !bg_color) - return color_bar_get_color(color_bar, 1); - else - return bg_color ? bg_color: DEFAULT_BG; -} - -void set_fg_color(const char *string) -{ - if (fg_color) { - jfree(fg_color); - fg_color = NULL; - } - - if (string) - fg_color = jstrdup(string); -} - -void set_bg_color(const char *string) -{ - if (bg_color) { - jfree(bg_color); - bg_color = NULL; - } - - if (string) - bg_color = jstrdup(string); } int color_type(const char *color) diff --git a/src/modules/color.h b/src/modules/color.h index fe87d98b7..84a45919c 100644 --- a/src/modules/color.h +++ b/src/modules/color.h @@ -1,5 +1,5 @@ /* ASE - Allegro Sprite Editor - * Copyright (C) 2001-2005, 2007 David A. Capello + * Copyright (C) 2001-2005, 2007, 2008 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 @@ -19,9 +19,6 @@ #ifndef MODULES_COLOR_H #define MODULES_COLOR_H -#define DEFAULT_FG "rgb{0,0,0,255}" -#define DEFAULT_BG "rgb{255,255,255,255}" - struct BITMAP; struct Image; @@ -35,11 +32,6 @@ enum { int init_module_color(void); void exit_module_color(void); -const char *get_fg_color(void); -const char *get_bg_color(void); -void set_fg_color(const char *string); -void set_bg_color(const char *string); - int color_type(const char *color); char *color_mask(void); char *color_rgb(int r, int g, int b, int a); diff --git a/src/modules/editors.c b/src/modules/editors.c index cd99842fb..8083873f8 100644 --- a/src/modules/editors.c +++ b/src/modules/editors.c @@ -27,7 +27,9 @@ #include "modules/gui.h" #include "modules/palette.h" #include "modules/sprites.h" +#include "raster/image.h" #include "raster/sprite.h" +#include "util/misc.h" #include "widgets/editor.h" #endif @@ -95,19 +97,6 @@ void update_editors_with_sprite(Sprite *sprite) } } -/* void dirty_editors_with_sprite(Sprite *sprite) */ -/* { */ -/* JWidget widget; */ -/* JLink link; */ - -/* JI_LIST_FOR_EACH(editors, link) { */ -/* widget = link->data; */ - -/* if (sprite == editor_get_sprite(widget)) */ -/* jwidget_dirty(widget); */ -/* } */ -/* } */ - void editors_draw_sprite(Sprite *sprite, int x1, int y1, int x2, int y2) { JWidget widget; @@ -125,42 +114,47 @@ void editors_draw_sprite(Sprite *sprite, int x1, int y1, int x2, int y2) recursivity) */ void editors_draw_sprite_tiled(Sprite *sprite, int x1, int y1, int x2, int y2) { - int lx1, ly1, lx2, ly2; + int cx1, cy1, cx2, cy2; /* cel rectangle */ + int lx1, ly1, lx2, ly2; /* limited rectangle to the cel rectangle */ + Image *image = GetImage2(sprite, &cx1, &cy1, NULL); - lx1 = MAX(x1, 0); - ly1 = MAX(y1, 0); - lx2 = MIN(x2, sprite->w-1); - ly2 = MIN(y2, sprite->h-1); + cx2 = cx1+image->w-1; + cy2 = cy1+image->h-1; + + lx1 = MAX(x1, cx1); + ly1 = MAX(y1, cy1); + lx2 = MIN(x2, cx2); + ly2 = MIN(y2, cy2); /* draw the rectangles inside the editor */ editors_draw_sprite(sprite, lx1, ly1, lx2, ly2); /* left */ - if (x1 < 0 && lx2 < sprite->w-1) { + if (x1 < cx1 && lx2 < cx2) { editors_draw_sprite_tiled(sprite, - MAX(lx2, sprite->w+x1), y1, - sprite->w-1, y2); + MAX(lx2+1, cx2+1+(x1-cx1)), y1, + cx2, y2); } /* top */ - if (y1 < 0 && ly2 < sprite->h-1) { + if (y1 < cy1 && ly2 < cy2) { editors_draw_sprite_tiled(sprite, - x1, MAX(ly2, sprite->h+y1), - x2, sprite->h-1); + x1, MAX(ly2+1, cy2+1+(y1-cx1)), + x2, cy2); } /* right */ - if (x2 >= sprite->w && lx1 > 0) { + if (x2 >= cx2+1 && lx1 > cx1) { editors_draw_sprite_tiled(sprite, - 0, y1, - MIN(lx1, x2-sprite->w), y2); + cx1, y1, + MIN(lx1-1, x2-image->w), y2); } /* bottom */ - if (y2 >= sprite->h && ly1 > 0) { + if (y2 >= cy2+1 && ly1 > cy1) { editors_draw_sprite_tiled(sprite, - x1, 0, - x2, MIN(ly1, y2-sprite->h)); + x1, cy1, + x2, MIN(ly1-1, y2-image->h)); } } diff --git a/src/modules/gfx.h b/src/modules/gfx.h index 14daf8d6f..d3aee7a96 100644 --- a/src/modules/gfx.h +++ b/src/modules/gfx.h @@ -1,5 +1,5 @@ /* ASE - Allegro Sprite Editor - * Copyright (C) 2001-2005, 2007 David A. Capello + * Copyright (C) 2001-2005, 2007, 2008 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 @@ -82,6 +82,11 @@ enum { GFX_ARROW_LEFT, GFX_ARROW_RIGHT, + GFX_BOX_SHOW, + GFX_BOX_HIDE, + GFX_BOX_LOCK, + GFX_BOX_UNLOCK, + GFX_BITMAP_COUNT, }; diff --git a/src/modules/gfxdata.c b/src/modules/gfxdata.c index 9eeee16ca..715ae530a 100644 --- a/src/modules/gfxdata.c +++ b/src/modules/gfxdata.c @@ -1,5 +1,5 @@ /* ASE - Allegro Sprite Editor - * Copyright (C) 2001-2005, 2007 David A. Capello + * Copyright (C) 2001-2005, 2007, 2008 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 @@ -450,4 +450,44 @@ static DATA gfx_data[GFX_BITMAP_COUNT] = " ## " " # " " " }, + /* GFX_BOX_SHOW */ + { 8, 8, + " #### " + " # # " + "# #### #" + "#### ###" + "# #### #" + "# ## #" + " # # " + " #### " }, + /* GFX_BOX_HIDE */ + { 8, 8, + "## # " + " ## # " + " #### " + " ## " + " #### " + " # ## " + " # # " + "# "}, + /* GFX_BOX_LOCK */ + { 8, 8, + " " + " #### " + " # # " + "########" + "# #" + "# #" + "# #" + " ###### " }, + /* GFX_BOX_UNLOCK */ + { 8, 8, + " #### " + " # # " + " # " + "########" + "# #" + "# #" + "# #" + " ###### " }, }; diff --git a/src/modules/sprites.c b/src/modules/sprites.c index f14dd0cea..f94fa76d5 100644 --- a/src/modules/sprites.c +++ b/src/modules/sprites.c @@ -160,13 +160,6 @@ void sprite_unmount(Sprite *sprite) } } -/* closes the specified sprite */ -void sprite_close(Sprite *sprite) -{ - sprite_unmount(sprite); - sprite_free(sprite); -} - /* sets current sprite (doesn't show it, only sets the "current_sprite" pointer). */ void set_current_sprite(Sprite *sprite) @@ -193,6 +186,35 @@ void sprite_show(Sprite *sprite) set_sprite_in_more_reliable_editor(sprite); } +bool is_current_sprite_not_locked(void) +{ + return + current_sprite != NULL && + !sprite_is_locked(current_sprite); +} + +bool is_current_sprite_writable(void) +{ + return + current_sprite != NULL + && !sprite_is_locked(current_sprite) + && current_sprite->layer != NULL + && layer_is_readable(current_sprite->layer) + && layer_is_writable(current_sprite->layer) + && layer_is_image(current_sprite->layer) + && layer_get_cel(current_sprite->layer, + current_sprite->frame) != NULL; +} + +Sprite *lock_current_sprite(void) +{ + if (current_sprite != NULL && + sprite_lock(current_sprite)) + return current_sprite; + else + return NULL; +} + Stock *sprite_get_images(Sprite *sprite, int target, int write, int **x, int **y) { Layer *layer = (target & TARGET_LAYERS) ? sprite->set: sprite->layer; diff --git a/src/modules/sprites.h b/src/modules/sprites.h index eca2fb9db..8343fdefb 100644 --- a/src/modules/sprites.h +++ b/src/modules/sprites.h @@ -1,5 +1,5 @@ /* ASE - Allegro Sprite Editor - * Copyright (C) 2001-2005, 2007 David A. Capello + * Copyright (C) 2001-2005, 2007, 2008 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 @@ -42,12 +42,16 @@ void set_clipboard_sprite(struct Sprite *sprite); void sprite_mount(struct Sprite *sprite); void sprite_unmount(struct Sprite *sprite); -void sprite_close(struct Sprite *sprite); void set_current_sprite(struct Sprite *sprite); void send_sprite_to_top(struct Sprite *sprite); void sprite_show(struct Sprite *sprite); +bool is_current_sprite_not_locked(void); +bool is_current_sprite_writable(void); + +struct Sprite *lock_current_sprite(void); + struct Stock *sprite_get_images(struct Sprite *sprite, int target, int write, int **x, int **y); #endif /* MODULES_SPRITES_H */ diff --git a/src/modules/tools.c b/src/modules/tools.c index 1b00603ae..fdeed6539 100644 --- a/src/modules/tools.c +++ b/src/modules/tools.c @@ -1028,9 +1028,10 @@ void control_tool(JWidget widget, Tool *tool, const char *_color) int x1, y1, x2, y2; editor_to_screen(widget, 0, 0, &x1, &y1); editor_to_screen(widget, - editor->sprite->w-1, - editor->sprite->h-1, &x2, &y2); - rectfill(ji_screen, x1, y1, x2, y2, 0); + editor->sprite->w, + editor->sprite->h, &x2, &y2); + rectfill(ji_screen, x1, y1, x2-1, y2-1, makecol(255, 0, 0)); + vsync(); } #endif diff --git a/src/modules/tools2.c b/src/modules/tools2.c index 5b01b242c..7b2c82cd5 100644 --- a/src/modules/tools2.c +++ b/src/modules/tools2.c @@ -119,7 +119,7 @@ void SetDrawMode(const char *string) rectangle, ellipse uses the current FG color */ -void ToolTrace(const char *string) +void ToolTrace(const char *string, const char *color) { Sprite *sprite = current_sprite; @@ -158,7 +158,7 @@ void ToolTrace(const char *string) } if (npoints > 0) { - do_tool_points(sprite, current_tool, get_fg_color(), npoints, x, y); + do_tool_points(sprite, current_tool, color, npoints, x, y); jfree(x); jfree(y); } @@ -201,10 +201,6 @@ void ResetConfig(void) { JRect rect; - /* colors */ - set_fg_color(DEFAULT_FG); - set_bg_color(DEFAULT_BG); - /* movement */ cfg_options_move_mask = get_config_bool("QuickMovement", "UseMask", TRUE); @@ -275,10 +271,6 @@ void ResetConfig(void) void RestoreConfig(void) { - /* colors */ - set_fg_color(NULL); - set_bg_color(NULL); - /* movement */ set_config_bool("QuickMovement", "UseMask", cfg_options_move_mask); diff --git a/src/modules/tools2.h b/src/modules/tools2.h index 6cbd0f1e6..ca7806b3a 100644 --- a/src/modules/tools2.h +++ b/src/modules/tools2.h @@ -1,5 +1,5 @@ /* ASE - Allegro Sprite Editor - * Copyright (C) 2001-2005, 2007 David A. Capello + * Copyright (C) 2001-2005, 2007, 2008 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 @@ -21,7 +21,7 @@ void SetBrush(const char *string); void SetDrawMode(const char *string); -void ToolTrace(const char *string); +void ToolTrace(const char *string, const char *color); void ResetConfig(void); void RestoreConfig(void); diff --git a/src/raster/layer.c b/src/raster/layer.c index 80c4d96e3..0c048bbf9 100644 --- a/src/raster/layer.c +++ b/src/raster/layer.c @@ -1,5 +1,5 @@ /* ASE - Allegro Sprite Editor - * Copyright (C) 2001-2005, 2007 David A. Capello + * Copyright (C) 2001-2005, 2007, 2008 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 @@ -50,7 +50,9 @@ static bool has_cels(Layer *layer, int frame); layer->layers = NULL; \ } while (0); -/* creates a new empty (without frames) normal (image) layer */ +/** + * Creates a new empty (without frames) normal (image) layer. + */ Layer *layer_new(Sprite *sprite) { Layer *layer = (Layer *)gfxobj_new(GFXOBJ_LAYER_IMAGE, sizeof(Layer)); @@ -167,19 +169,41 @@ void layer_free(Layer *layer) gfxobj_free((GfxObj *)layer); } -/* returns TRUE if "layer" is a normal layer type (an image layer) */ +/** + * Returns TRUE if "layer" is a normal layer type (an image 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 */ +/** + * Returns TRUE if "layer" is a set of layers + */ int layer_is_set(const Layer *layer) { return (layer->gfxobj.type == GFXOBJ_LAYER_SET) ? TRUE: FALSE; } -/* gets the previous layer of "layer" that are in the parent set */ +/** + * Returns TRUE if the layer is readable/viewable. + */ +bool layer_is_readable(const Layer *layer) +{ + return layer->readable; +} + +/** + * Returns TRUE if the layer is writable/editable. + */ +bool layer_is_writable(const Layer *layer) +{ + return layer->writable; +} + +/** + * Gets the previous layer of "layer" that are in the parent set. + */ Layer *layer_get_prev(Layer *layer) { if (layer->parent && layer->parent->type == GFXOBJ_LAYER_SET) { @@ -371,7 +395,10 @@ Layer *layer_flatten(Layer *layer, int x, int y, int w, int h, int frmin, int fr return flat_layer; } -/* returns TRUE if the "layer" (or him childs) has cels to render in frame */ +/** + * Returns TRUE if the "layer" (or him childs) has cels to render in + * frame. + */ static bool has_cels(Layer *layer, int frame) { if (!layer->readable) diff --git a/src/raster/layer.h b/src/raster/layer.h index 0c82edc30..4725e9e75 100644 --- a/src/raster/layer.h +++ b/src/raster/layer.h @@ -1,5 +1,5 @@ /* ASE - Allegro Sprite Editor - * Copyright (C) 2001-2005, 2007 David A. Capello + * Copyright (C) 2001-2005, 2007, 2008 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 @@ -53,6 +53,9 @@ void layer_free(Layer *layer); int layer_is_image(const Layer *layer); int layer_is_set(const Layer *layer); +bool layer_is_readable(const Layer *layer); +bool layer_is_writable(const Layer *layer); + Layer *layer_get_prev(Layer *layer); Layer *layer_get_next(Layer *layer); diff --git a/src/raster/sprite.c b/src/raster/sprite.c index a72228bc8..974aa6b2f 100644 --- a/src/raster/sprite.c +++ b/src/raster/sprite.c @@ -1,5 +1,5 @@ /* ASE - Allegro Sprite Editor - * Copyright (C) 2001-2005, 2007 David A. Capello + * Copyright (C) 2001-2005, 2007, 2008 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 @@ -20,9 +20,11 @@ #ifndef USE_PRECOMPILED_HEADER +#include #include #include "jinete/jlist.h" +#include "jinete/jmutex.h" #include "modules/palette.h" #include "raster/raster.h" @@ -112,6 +114,10 @@ Sprite *sprite_new(int imgtype, int w, int h) sprite_set_palette(sprite, pal, sprite->frame); sprite_set_speed(sprite, 42); + /* multiple access */ + sprite->locked = FALSE; + sprite->mutex = jmutex_new(); + return sprite; } @@ -239,6 +245,8 @@ void sprite_free(Sprite *sprite) { JLink link; + assert(!sprite->locked); + /* destroy images' stock */ if (sprite->stock) stock_free(sprite->stock); @@ -274,6 +282,9 @@ void sprite_free(Sprite *sprite) if (sprite->set) layer_free(sprite->set); if (sprite->bound.seg) jfree(sprite->bound.seg); + /* destroy mutex */ + jmutex_free(sprite->mutex); + gfxobj_free((GfxObj *)sprite); } @@ -288,12 +299,45 @@ bool sprite_is_associated_to_file(Sprite *sprite) return sprite->associated_to_file; } +bool sprite_is_locked(Sprite *sprite) +{ + bool locked; + + jmutex_lock(sprite->mutex); + locked = sprite->locked; + jmutex_unlock(sprite->mutex); + + return locked; +} + void sprite_mark_as_saved(Sprite *sprite) { sprite->undo->diff_saved = sprite->undo->diff_count; sprite->associated_to_file = TRUE; } +bool sprite_lock(Sprite *sprite) +{ + bool res = FALSE; + + jmutex_lock(sprite->mutex); + if (!sprite->locked) { + sprite->locked = TRUE; + res = TRUE; + } + jmutex_unlock(sprite->mutex); + + return res; +} + +void sprite_unlock(Sprite *sprite) +{ + jmutex_lock(sprite->mutex); + assert(sprite->locked); + sprite->locked = FALSE; + jmutex_unlock(sprite->mutex); +} + RGB *sprite_get_palette(Sprite *sprite, int frame) { RGB *rgb = NULL; diff --git a/src/raster/sprite.h b/src/raster/sprite.h index 04935108b..248f5d424 100644 --- a/src/raster/sprite.h +++ b/src/raster/sprite.h @@ -1,5 +1,5 @@ /* ASE - Allegro Sprite Editor - * Copyright (C) 2001-2005, 2007 David A. Capello + * Copyright (C) 2001-2005, 2007, 2008 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 @@ -44,7 +44,6 @@ struct Sprite int frames; /* how many frames has this sprite */ int *frlens; /* duration per frame */ int frame; /* current frame, range [0,frames) */ -/* RGB *palette; /\* sprite palette *\/ */ JList palettes; /* list of palettes */ struct Stock *stock; /* stock to get images */ struct Layer *set; /* layer list */ @@ -65,6 +64,9 @@ struct Sprite int scroll_y; int zoom; } preferred; + JMutex mutex; /* mutex to modify the 'locked' flag */ + bool locked; /* true when a thread is + reading/writing the sprite */ }; Sprite *sprite_new(int imgtype, int w, int h); @@ -75,8 +77,12 @@ void sprite_free(Sprite *sprite); bool sprite_is_modified(Sprite *sprite); bool sprite_is_associated_to_file(Sprite *sprite); +bool sprite_is_locked(Sprite *sprite); void sprite_mark_as_saved(Sprite *sprite); +bool sprite_lock(Sprite *sprite); +void sprite_unlock(Sprite *sprite); + RGB *sprite_get_palette(Sprite *sprite, int frame); void sprite_set_palette(Sprite *sprite, RGB *rgb, int frame); void sprite_reset_palettes(Sprite *sprite); diff --git a/src/util/clipbrd.c b/src/util/clipbrd.c index 4d0caa95d..959379724 100644 --- a/src/util/clipbrd.c +++ b/src/util/clipbrd.c @@ -44,6 +44,7 @@ #include "raster/undo.h" #include "util/clipbrd.h" #include "util/misc.h" +#include "widgets/colbar.h" #include "widgets/statebar.h" #endif @@ -141,7 +142,7 @@ void cut_to_clipboard(void) if (!low_copy()) console_printf("Can't copying an image portion from the current layer\n"); else { - ClearMask(); + ClearMask(color_bar_get_color(app_get_color_bar(), 1)); update_screen_for_sprite(current_sprite); } } diff --git a/src/util/crop.c b/src/util/crop.c index b1ece3797..61698c857 100644 --- a/src/util/crop.c +++ b/src/util/crop.c @@ -1,5 +1,5 @@ /* ASE - Allegro Sprite Editor - * Copyright (C) 2001-2005, 2007 David A. Capello + * Copyright (C) 2001-2005, 2007, 2008 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 @@ -163,7 +163,7 @@ void crop_layer(void) void crop_cel(void) { Sprite *sprite = current_sprite; - Image *image = GetImage(); + Image *image = GetImage(current_sprite); if ((sprite) && (!mask_is_empty (sprite->mask)) && (image)) { Cel *cel = layer_get_cel(sprite->layer, sprite->frame); diff --git a/src/util/misc.c b/src/util/misc.c index 140d483df..c8566312a 100644 --- a/src/util/misc.c +++ b/src/util/misc.c @@ -51,9 +51,8 @@ #endif -Image *GetImage(void) +Image *GetImage(Sprite *sprite) { - Sprite *sprite = current_sprite; Image *image = NULL; if (sprite && sprite->layer && layer_is_image(sprite->layer)) { @@ -128,7 +127,7 @@ void LoadPalette(const char *filename) } /* clears the mask region in the current sprite with the BG color */ -void ClearMask(void) +void ClearMask(const char *str_color) { Sprite *sprite = current_sprite; int x, y, u, v, putx, puty; @@ -138,43 +137,43 @@ void ClearMask(void) int color; if (sprite) { - image = GetImage2 (sprite, &x, &y, NULL); + image = GetImage2(sprite, &x, &y, NULL); if (image) { - color = get_color_for_image (sprite->imgtype, get_bg_color ()); + color = get_color_for_image(sprite->imgtype, str_color); - if (mask_is_empty (sprite->mask)) { - if (undo_is_enabled (sprite->undo)) - undo_image (sprite->undo, image, 0, 0, image->w, image->h); + if (mask_is_empty(sprite->mask)) { + if (undo_is_enabled(sprite->undo)) + undo_image(sprite->undo, image, 0, 0, image->w, image->h); /* clear all */ - image_clear (image, color); + image_clear(image, color); } else { - int x1 = MAX (0, sprite->mask->x); - int y1 = MAX (0, sprite->mask->y); - int x2 = MIN (image->w-1, sprite->mask->x+sprite->mask->w-1); - int y2 = MIN (image->h-1, sprite->mask->y+sprite->mask->h-1); + int x1 = MAX(0, sprite->mask->x); + int y1 = MAX(0, sprite->mask->y); + int x2 = MIN(image->w-1, sprite->mask->x+sprite->mask->w-1); + int y2 = MIN(image->h-1, sprite->mask->y+sprite->mask->h-1); /* do nothing */ if (x1 > x2 || y1 > y2) return; - if (undo_is_enabled (sprite->undo)) - undo_image (sprite->undo, image, x1, y1, x2-x1+1, y2-y1+1); + if (undo_is_enabled(sprite->undo)) + undo_image(sprite->undo, image, x1, y1, x2-x1+1, y2-y1+1); /* clear the masked zones */ for (v=0; vmask->h; v++) { - d = div (0, 8); + d = div(0, 8); address = ((ase_uint8 **)sprite->mask->bitmap->line)[v]+d.quot; for (u=0; umask->w; u++) { if ((*address & (1<mask->x-x; puty = v+sprite->mask->y-y; - image_putpixel (image, putx, puty, color); + image_putpixel(image, putx, puty, color); } - _image_bitmap_next_bit (d, address); + _image_bitmap_next_bit(d, address); } } } diff --git a/src/util/misc.h b/src/util/misc.h index d49e0e22d..71e990385 100644 --- a/src/util/misc.h +++ b/src/util/misc.h @@ -1,5 +1,5 @@ /* ASE - Allegro Sprite Editor - * Copyright (C) 2001-2005, 2007 David A. Capello + * Copyright (C) 2001-2005, 2007, 2008 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 @@ -27,12 +27,12 @@ struct Layer; struct Sprite; struct Undo; -struct Image *GetImage(void); +struct Image *GetImage(struct Sprite *sprite); struct Image *GetImage2(struct Sprite *sprite, int *x, int *y, int *opacity); void LoadPalette(const char *filename); -void ClearMask(void); +void ClearMask(const char *color); struct Layer *NewLayerFromMask(struct Sprite *src, struct Sprite *dst); struct Image *GetLayerImage(struct Layer *layer, int *x, int *y, int frame); diff --git a/src/widgets/editor/editor.c b/src/widgets/editor/editor.c index a9ae8d3da..f1bef5851 100644 --- a/src/widgets/editor/editor.c +++ b/src/widgets/editor/editor.c @@ -23,19 +23,11 @@ #ifndef USE_PRECOMPILED_HEADER +#include #include #include -#include "jinete/jdraw.h" -#include "jinete/jlist.h" -#include "jinete/jmanager.h" -#include "jinete/jmessage.h" -#include "jinete/jrect.h" -#include "jinete/jregion.h" -#include "jinete/jsystem.h" -#include "jinete/jview.h" -#include "jinete/jwidget.h" -#include "jinete/jwindow.h" +#include "jinete/jinete.h" #include "core/app.h" #include "core/cfg.h" @@ -89,6 +81,7 @@ JWidget editor_view_new(void) { JWidget widget = jview_new(); + jwidget_set_border(widget, 3, 3, 3, 3); jview_without_bars(widget); jwidget_add_hook(widget, JI_WIDGET, editor_view_msg_proc, NULL); @@ -808,18 +801,34 @@ void editor_to_screen(JWidget widget, int xin, int yin, int *xout, int *yout) void show_drawing_cursor(JWidget widget) { - jmouse_set_cursor(JI_CURSOR_NULL); + Editor *editor = editor_data(widget); - if (!editor_data(widget)->cursor_thick) { - jmouse_hide(); - editor_draw_cursor(widget, jmouse_x(0), jmouse_y(0)); - jmouse_show(); + assert(editor->sprite != NULL); + + if (!sprite_is_locked(editor->sprite) && + editor->sprite->layer != NULL && + layer_is_image(editor->sprite->layer) && + layer_is_readable(editor->sprite->layer) && + layer_is_writable(editor->sprite->layer) && + layer_get_cel(editor->sprite->layer, editor->sprite->frame) != NULL) { + jmouse_set_cursor(JI_CURSOR_NULL); + + if (!editor->cursor_thick) { + jmouse_hide(); + editor_draw_cursor(widget, jmouse_x(0), jmouse_y(0)); + jmouse_show(); + } + } + else { + jmouse_set_cursor(JI_CURSOR_FORBIDDEN); } } void hide_drawing_cursor(JWidget widget) { - if (editor_data(widget)->cursor_thick) { + Editor *editor = editor_data(widget); + + if (editor->cursor_thick) { jmouse_hide(); editor_clean_cursor(widget); jmouse_show(); @@ -909,19 +918,27 @@ static bool editor_view_msg_proc(JWidget widget, JMessage msg) if (has_focus) { /* 1st border */ - jdraw_rectedge(pos, makecol (128, 128, 128), makecol (255, 255, 255)); + jdraw_rect(pos, ji_color_selected()); /* 2nd border */ jrect_shrink(pos, 1); - jdraw_rect(pos, makecol (0, 0, 0)); + jdraw_rect(pos, ji_color_selected()); + + /* 3rd border */ + jrect_shrink(pos, 1); + jdraw_rectedge(pos, makecol(128, 128, 128), makecol(255, 255, 255)); } else { /* 1st border */ - jdraw_rectedge(pos, makecol (128, 128, 128), makecol (255, 255, 255)); + jdraw_rect(pos, makecol(192, 192, 192)); /* 2nd border */ jrect_shrink(pos, 1); - jdraw_rect(pos, makecol (192, 192, 192)); + jdraw_rect(pos, makecol(192, 192, 192)); + + /* 3rd border */ + jrect_shrink(pos, 1); + jdraw_rectedge(pos, makecol(128, 128, 128), makecol(255, 255, 255)); } jrect_free(pos);