Added JMutex, lock_current_sprite, and locked & mutex fields for Sprite.

Added readable/writable buttons in the Film Editor. Added forbidden cursor.
Fixed some bugs in editors_draw_sprite_tiled and cmd_configure_tools.
This commit is contained in:
David Capello 2008-01-23 16:16:43 +00:00
parent dc6d0467ac
commit 33cde18bf1
49 changed files with 530 additions and 288 deletions

View File

@ -1,3 +1,17 @@
2008-01-23 David A. Capello <dacap@users.sourceforge.net>
* 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 <dacap@users.sourceforge.net> 2008-01-21 David A. Capello <dacap@users.sourceforge.net>
* src/jinete/jmanager.c (jmanager_generate_messages): Focus magnet * src/jinete/jmanager.c (jmanager_generate_messages): Focus magnet

View File

@ -5,25 +5,25 @@ NEWS
0.6 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. + Replaced the "List" menu with the tabs selector.
+ Better file selector. + Better file selector.
+ Restructured all the menus (more user friendly options). + Restructured all the menus (more user friendly options).
- Temporaly removed a lot of complex functionality: - Temporaly removed a lot of complex functionality:
Mask-Repository (but you can use .msk files yet), Draw-Text, 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. + New XML format for the menus.
- Removed menu scripting customization. - Removed menu scripting customization.
- Removed screen saver. - Removed screen saver.
- Removed sessions. - Removed sessions.
+ GUI enhanced: + Enhanced GUI:
+ more borders for windows and more spacing between widgets. + more borders for windows and more spacing between widgets.
+ better mouse behavior (in Windows). + better mouse behavior (now in Windows the mouse is captured).
+ Finished the support for ICO files.
+ Finally screen scaling supported (with double-buffering). This means + Finally screen scaling supported (with double-buffering). This means
that you can use a screen of 320x240 between a window of 640x480 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. (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 0.5
--- ---

View File

@ -4,9 +4,7 @@ High priority work
- the user_data of hook_signal should be void*. - the user_data of hook_signal should be void*.
- search for TODO; - search for TODO;
- Problems: - Problems:
- 100% CPU
- test UNDO in 64bits plataforms (reported by Jon Rafkind); - 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. - ver por el nuevo load_font de Allegro.
- complete palette operations, and palette editor (it needs a slider - complete palette operations, and palette editor (it needs a slider
or something to move between palette changes); or something to move between palette changes);
@ -20,17 +18,17 @@ High priority work
+ 09lists + 09lists
+ 20combo + 20combo
+ 21manage + 21manage
- fix "tiled mode" when it's used in frames that doesn't have the same + finished the support for ICO files.
size of the sprite;
- add "size" to GUI font (for TTF fonts); - 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; - quick swap;
+ the regions mustn't be overlapped; + the regions mustn't be overlapped;
- options to change the curve type (in curedit.c); - options to change the curve type (in curedit.c);
- sprite resize; - More Commands:
- canvas size; + resize sprite;
+ with the current crop this isn't necessary anymore; + rotate sprite;
+ anyway, it's a good way to expand the graphics + canvas size;
- gauss blur; - gauss blur;
- pal-operations (sort, quantize, gamma by color-curves, etc.); - pal-operations (sort, quantize, gamma by color-curves, etc.);
- RGB and HSV effects; - RGB and HSV effects;
@ -54,11 +52,8 @@ Wish-list
+ better dialogs: widder buttons, more borders. + better dialogs: widder buttons, more borders.
+ better film editor + better film editor
+ "middle mouse button" for the film editor. + "middle mouse button" for the film editor.
+ don't use LINKs when load a sequence of bitmaps.
- manuq wish-list: - manuq wish-list:
+ layer-with-constant-cel + layer-with-constant-cel
+ onion skin for all layers in a frame
- add menu customization through UI (Tools/Customize).
- Mateusz Czaplinski ideas: - Mateusz Czaplinski ideas:
+ when move selections, will be good the possibility to see relative + when move selections, will be good the possibility to see relative
position from the starting point of movement; position from the starting point of movement;

View File

@ -137,6 +137,7 @@ COMMON_SOURCES = \
src/jinete/jmem.c \ src/jinete/jmem.c \
src/jinete/jmenu.c \ src/jinete/jmenu.c \
src/jinete/jmessage.c \ src/jinete/jmessage.c \
src/jinete/jmutex.c \
src/jinete/jpanel.c \ src/jinete/jpanel.c \
src/jinete/jquickmenu.c \ src/jinete/jquickmenu.c \
src/jinete/jrect.c \ src/jinete/jrect.c \

View File

@ -1,5 +1,5 @@
/* ASE - Allegro Sprite Editor /* 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 * 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 * 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) 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) 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; Sprite *sprite;
Layer *layer; Layer *layer;
Cel *cel; Cel *cel;
char buf[1024]; char buf[1024];
/* get current sprite */ /* get current sprite */
sprite = current_sprite; sprite = lock_current_sprite();
if (!sprite) if (!sprite)
return; return;
/* get selected layer */ /* get selected layer */
layer = sprite->layer; layer = sprite->layer;
if (!layer) if (!layer)
return; goto done;
/* get current cel */ /* get current cel */
cel = layer_get_cel(layer, sprite->frame); cel = layer_get_cel(layer, sprite->frame);
if (!cel) if (!cel)
return; goto done;
window = load_widget("celprop.jid", "cel_properties"); window = load_widget("celprop.jid", "cel_properties");
if (!window) if (!window)
return; goto done;
entry_frame = jwidget_find_name(window, "frame"); entry_frame = jwidget_find_name(window, "frame");
entry_xpos = jwidget_find_name(window, "xpos"); 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"); slider_opacity = jwidget_find_name(window, "opacity");
button_ok = jwidget_find_name(window, "ok"); 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); sprintf(buf, "%d", cel->frame+1);
jwidget_set_text(entry_frame, buf); jwidget_set_text(entry_frame, buf);
@ -136,7 +147,11 @@ static void cmd_cel_properties_execute(const char *argument)
break; break;
} }
jwidget_free(window); done:;
if (window)
jwidget_free(window);
sprite_unlock(sprite);
} }
Command cmd_cel_properties = { Command cmd_cel_properties = {

View File

@ -1,5 +1,5 @@
/* ASE - Allegro Sprite Editor /* 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 * 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 * it under the terms of the GNU General Public License as published by
@ -21,10 +21,12 @@
#ifndef USE_PRECOMPILED_HEADER #ifndef USE_PRECOMPILED_HEADER
#include "commands/commands.h" #include "commands/commands.h"
#include "core/app.h"
#include "modules/gui.h" #include "modules/gui.h"
#include "modules/sprites.h" #include "modules/sprites.h"
#include "raster/sprite.h" #include "raster/sprite.h"
#include "util/misc.h" #include "util/misc.h"
#include "widgets/colbar.h"
#endif #endif
@ -39,7 +41,7 @@ static void cmd_clear_execute(const char *argument)
Sprite *sprite = current_sprite; Sprite *sprite = current_sprite;
/* clear the mask */ /* clear the mask */
ClearMask(); ClearMask(color_bar_get_color(app_get_color_bar(), 1));
/* refresh the sprite */ /* refresh the sprite */
update_screen_for_sprite(sprite); update_screen_for_sprite(sprite);

View File

@ -74,11 +74,14 @@ static void cmd_configure_tools_execute(const char *argument)
JWidget brush_mode_box, brush_mode; JWidget brush_mode_box, brush_mode;
JWidget check_onionskin; JWidget check_onionskin;
JWidget brush_preview; JWidget brush_preview;
bool first_time = FALSE;
if (!window) { if (!window) {
window = load_widget("toolconf.jid", "configure_tool"); window = load_widget("toolconf.jid", "configure_tool");
if (!window) if (!window)
return; return;
first_time = TRUE;
} }
/* if the window is opened, close it */ /* if the window is opened, close it */
else if (jwidget_is_visible(window)) { else if (jwidget_is_visible(window)) {
@ -108,29 +111,53 @@ static void cmd_configure_tools_execute(const char *argument)
} }
/* cursor-color */ /* cursor-color */
cursor_color = color_button_new(get_cursor_color(), IMAGE_INDEXED); if (first_time) {
/* brush-preview */ cursor_color = color_button_new(get_cursor_color(), IMAGE_INDEXED);
brush_preview = jwidget_new(JI_WIDGET); jwidget_set_name(cursor_color, "cursor_color");
brush_preview->min_w = 32 + 4; }
brush_preview->min_h = 32 + 4; else {
jwidget_add_hook(brush_preview, JI_WIDGET, cursor_color = jwidget_find_name(window, "cursor_color");
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);
/* append children */ /* brush-preview */
jwidget_add_child(cursor_color_box, cursor_color); if (first_time) {
jwidget_add_child(brush_preview_box, brush_preview); brush_preview = jwidget_new(JI_WIDGET);
jwidget_add_child(brush_type_box, brush_type); brush_preview->min_w = 32 + 4;
jwidget_add_child(brush_mode_box, brush_mode); 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_filled_mode()) jwidget_select(filled);
if (get_tiled_mode()) jwidget_select(tiled); 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()); jslider_set_value(air_speed, get_air_speed());
if (get_onionskin()) jwidget_select(check_onionskin); if (get_onionskin()) jwidget_select(check_onionskin);
HOOK(window, JI_SIGNAL_WINDOW_CLOSE, window_close_hook, 0); if (first_time) {
HOOK(filled, JI_SIGNAL_CHECK_CHANGE, filled_check_change_hook, 0); /* append children */
HOOK(tiled, JI_SIGNAL_CHECK_CHANGE, tiled_check_change_hook, 0); jwidget_add_child(cursor_color_box, cursor_color);
HOOK(use_grid, JI_SIGNAL_CHECK_CHANGE, use_grid_check_change_hook, 0); jwidget_add_child(brush_preview_box, brush_preview);
HOOK(view_grid, JI_SIGNAL_CHECK_CHANGE, view_grid_check_change_hook, 0); jwidget_add_child(brush_type_box, brush_type);
HOOK(set_grid, JI_SIGNAL_BUTTON_SELECT, set_grid_button_select_hook, 0); jwidget_add_child(brush_mode_box, brush_mode);
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); /* append hooks */
HOOK(brush_type, SIGNAL_GROUP_BUTTON_CHANGE, brush_type_change_hook, brush_preview); HOOK(window, JI_SIGNAL_WINDOW_CLOSE, window_close_hook, 0);
HOOK(brush_mode, SIGNAL_GROUP_BUTTON_CHANGE, brush_mode_change_hook, 0); HOOK(filled, JI_SIGNAL_CHECK_CHANGE, filled_check_change_hook, 0);
HOOK(glass_dirty, JI_SIGNAL_SLIDER_CHANGE, glass_dirty_slider_change_hook, 0); HOOK(tiled, JI_SIGNAL_CHECK_CHANGE, tiled_check_change_hook, 0);
HOOK(air_speed, JI_SIGNAL_SLIDER_CHANGE, air_speed_slider_change_hook, 0); HOOK(use_grid, JI_SIGNAL_CHECK_CHANGE, use_grid_check_change_hook, 0);
HOOK(spray_width, JI_SIGNAL_SLIDER_CHANGE, spray_width_slider_change_hook, 0); HOOK(view_grid, JI_SIGNAL_CHECK_CHANGE, view_grid_check_change_hook, 0);
HOOK(cursor_color, SIGNAL_COLOR_BUTTON_CHANGE, cursor_button_change_hook, 0); HOOK(set_grid, JI_SIGNAL_BUTTON_SELECT, set_grid_button_select_hook, 0);
HOOK(check_onionskin, JI_SIGNAL_CHECK_CHANGE, onionskin_check_change_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 */ /* default position */
jwindow_remap(window); jwindow_remap(window);

View File

@ -1,5 +1,5 @@
/* ASE - Allegro Sprite Editor /* 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 * 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 * 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)) (!current_sprite->mask->bitmap))
return FALSE; return FALSE;
else else
return GetImage() ? TRUE: FALSE; return GetImage(current_sprite) ? TRUE: FALSE;
} }
static void cmd_copy_execute(const char *argument) static void cmd_copy_execute(const char *argument)

View File

@ -1,5 +1,5 @@
/* ASE - Allegro Sprite Editor /* 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 * 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 * 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)) (!current_sprite->mask->bitmap))
return FALSE; return FALSE;
else else
return GetImage() ? TRUE: FALSE; return GetImage(current_sprite) ? TRUE: FALSE;
} }
Command cmd_crop_sprite = { Command cmd_crop_sprite = {

View File

@ -1,5 +1,5 @@
/* ASE - Allegro Sprite Editor /* 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 * 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 * 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)) (!current_sprite->mask->bitmap))
return FALSE; return FALSE;
else else
return GetImage() ? TRUE: FALSE; return GetImage(current_sprite) ? TRUE: FALSE;
} }
static void cmd_cut_execute(const char *argument) static void cmd_cut_execute(const char *argument)

View File

@ -70,7 +70,7 @@ static void cmd_color_curve_execute(const char *argument)
curve_add_point(the_curve, curve_point_new(255, 255)); curve_add_point(the_curve, curve_point_new(255, 255));
} }
image = GetImage(); image = GetImage(current_sprite);
if (!image) if (!image)
return; return;

View File

@ -87,7 +87,7 @@ static void cmd_convolution_matrix_execute(const char *argument)
Image *image; Image *image;
Effect *effect; Effect *effect;
image = GetImage(); image = GetImage(current_sprite);
if (!image) if (!image)
return; return;

View File

@ -70,7 +70,7 @@ static void cmd_despeckle_execute(const char *argument)
Effect *effect; Effect *effect;
char buf[32]; char buf[32];
image = GetImage(); image = GetImage(current_sprite);
if (!image) if (!image)
return; return;

View File

@ -64,7 +64,7 @@ static void cmd_invert_color_execute(const char *argument)
Image *image; Image *image;
Effect *effect; Effect *effect;
image = GetImage(); image = GetImage(current_sprite);
if (!image) if (!image)
return; return;

View File

@ -59,26 +59,32 @@ static void make_preview(void);
static bool cmd_replace_color_enabled(const char *argument) 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) 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 button1_1, button1_2;
JWidget button2_1, button2_2; JWidget button2_1, button2_2;
JWidget box_target, target_button; JWidget box_target, target_button;
JWidget button_ok; JWidget button_ok;
Image *image; Image *image;
Effect *effect; Effect *effect;
Sprite *sprite;
image = GetImage(); sprite = lock_current_sprite();
if (!image) if (!sprite)
return; return;
image = GetImage(current_sprite);
if (!image)
goto done;
window = load_widget("replcol.jid", "replace_color"); window = load_widget("replcol.jid", "replace_color");
if (!window) if (!window)
return; goto done;
if (!get_widgets(window, if (!get_widgets(window,
"color_buttons_box", &color_buttons_box, "color_buttons_box", &color_buttons_box,
@ -90,15 +96,13 @@ static void cmd_replace_color_execute(const char *argument)
"fuzziness", &slider_fuzziness, "fuzziness", &slider_fuzziness,
"target", &box_target, "target", &box_target,
"button_ok", &button_ok, NULL)) { "button_ok", &button_ok, NULL)) {
jwidget_free(window); goto done;
return;
} }
effect = effect_new(current_sprite, "replace_color"); effect = effect_new(sprite, "replace_color");
if (!effect) { if (!effect) {
console_printf(_("Error creating the effect applicator for this sprite\n")); console_printf(_("Error creating the effect applicator for this sprite\n"));
jwidget_free(window); goto done;
return;
} }
preview = preview_new(effect); preview = preview_new(effect);
@ -160,7 +164,11 @@ static void cmd_replace_color_execute(const char *argument)
/* save window configuration */ /* save window configuration */
save_window_pos(window, "ReplaceColor"); 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) static int button_1_select_hook(JWidget widget, int user_data)

View File

@ -102,7 +102,7 @@ void dialogs_mapgen(void)
sprite = sprite_new_with_layer(IMAGE_INDEXED, 256, 256); sprite = sprite_new_with_layer(IMAGE_INDEXED, 256, 256);
set_current_sprite(sprite); set_current_sprite(sprite);
preview_map = image_viewer_new(GetImage()); preview_map = image_viewer_new(GetImage(current_sprite));
/* set palette */ /* set palette */
if (new_palette) if (new_palette)
@ -194,7 +194,7 @@ static void regen_map(int forced)
} }
/* generate the map */ /* generate the map */
mapgen(GetImage(), seed, factor); mapgen(GetImage(current_sprite), seed, factor);
jwidget_dirty(preview_map); jwidget_dirty(preview_map);
} }
} }

View File

@ -62,7 +62,7 @@ void dialogs_draw_text(void)
if (!is_interactive() || !current_sprite) if (!is_interactive() || !current_sprite)
return; return;
dest_image = GetImage(); dest_image = GetImage(current_sprite);
if (!dest_image) if (!dest_image)
return; return;

View File

@ -253,11 +253,12 @@ static bool layer_box_msg_proc(JWidget widget, JMessage msg)
JWidget view = jwidget_get_view(widget); JWidget view = jwidget_get_view(widget);
JRect vp = jview_get_viewport_position(view); JRect vp = jview_get_viewport_position(view);
BITMAP *bmp = create_bitmap(jrect_w(vp), jrect_h(vp)); BITMAP *bmp = create_bitmap(jrect_w(vp), jrect_h(vp));
BITMAP *icon;
int scroll_x, scroll_y; int scroll_x, scroll_y;
bool selected_layer; bool selected_layer;
int pos, layers; int pos, layers;
Layer *layer; Layer *layer;
int y, h; int y, h, y_mid;
jview_get_scroll(view, &scroll_x, &scroll_y); 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); layers = count_layers(sprite->set);
for (pos=0; pos<layers; pos++) { for (pos=0; pos<layers; pos++) {
layer = get_layer_in_pos(sprite->set, pos); layer = get_layer_in_pos(sprite->set, pos);
y_mid = y+h/2;
selected_layer = selected_layer =
(state != STATE_MOVING) ? (sprite->layer == layer): (state != STATE_MOVING) ? (sprite->layer == layer):
(layer == layer_box->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, bmp->w-1, makecol(0, 0, 0));
hline(bmp, 0, y+h, 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 #if 0
{ {
int count, pos; int count, pos;
@ -308,20 +326,23 @@ static bool layer_box_msg_proc(JWidget widget, JMessage msg)
#else #else
{ {
int tabs = -2; int tabs = -2;
int final_y = y+h/2;
Layer *l = layer; Layer *l = layer;
while (l->gfxobj.type != GFXOBJ_SPRITE) { while (l->gfxobj.type != GFXOBJ_SPRITE) {
if (++tabs > 0) { if (++tabs > 0) {
/* JList item = jlist_find(((Layer *)l->parent)->layers, l); */ /* JList item = jlist_find(((Layer *)l->parent)->layers, l); */
int y1 = final_y-LAYSIZE/2; int y1 = y_mid-LAYSIZE/2;
int y2 = final_y+LAYSIZE/2; int y2 = y_mid+LAYSIZE/2;
/* int y2 = item->prev ? final_y+LAYSIZE/2 : final_y; */ /* int y2 = item->prev ? y_mid+LAYSIZE/2 : y_mid; */
vline(bmp, tabs*16-1, y1, y2, makecol(0, 0, 0)); vline(bmp, tabs*16-1, y1, y2, makecol(0, 0, 0));
} }
l = (Layer *)l->parent; l = (Layer *)l->parent;
} }
/* draw the layer name */
textout(bmp, widget->text_font, 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 ? selected_layer ?
makecol(255, 255, 255): makecol(0, 0, 0)); 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: case JM_BUTTONPRESSED:
jwidget_hard_capture_mouse(widget); 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; state = STATE_SCROLLING;
jmouse_set_cursor(JI_CURSOR_MOVE); jmouse_set_cursor(JI_CURSOR_MOVE);
} }
else { else {
state = STATE_MOVING;
jmouse_set_cursor(JI_CURSOR_MOVE);
select_layer_motion(widget, layer_box, layer_box->cel_box); select_layer_motion(widget, layer_box, layer_box->cel_box);
layer_box->layer = current_sprite->layer; layer_box->layer = current_sprite->layer;
/* layer_box->rect = rect; */ /* layer_box->rect = rect; */
/* layer_box->rect_data = NULL; */ /* 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: case JM_MOTION:
if (jwidget_has_capture (widget)) { if (jwidget_has_capture(widget)) {
/* scroll */ /* scroll */
if (state == STATE_SCROLLING) if (state == STATE_SCROLLING)
control_scroll_motion(widget, layer_box, layer_box->cel_box); control_scroll_motion(widget, layer_box, layer_box->cel_box);

View File

@ -68,7 +68,7 @@ void dialogs_mask_color(void)
if (!is_interactive () || !sprite) if (!is_interactive () || !sprite)
return; return;
image = GetImage(); image = GetImage(current_sprite);
if (!image) if (!image)
return; return;

View File

@ -22,6 +22,7 @@
#include <allegro/keyboard.h> #include <allegro/keyboard.h>
#include "core/app.h"
#include "core/cfg.h" #include "core/cfg.h"
#include "core/core.h" #include "core/core.h"
#include "modules/gui.h" #include "modules/gui.h"
@ -36,6 +37,7 @@
#include "raster/sprite.h" #include "raster/sprite.h"
#include "raster/undo.h" #include "raster/undo.h"
#include "util/misc.h" #include "util/misc.h"
#include "widgets/colbar.h"
#endif #endif
@ -97,7 +99,7 @@ static void do_quick(int action)
if (action == ACTION_MOVE) { if (action == ACTION_MOVE) {
int enabled = undo_is_enabled(sprite->undo); int enabled = undo_is_enabled(sprite->undo);
undo_disable(sprite->undo); undo_disable(sprite->undo);
ClearMask(); ClearMask(color_bar_get_color(app_get_color_bar(), 1));
if (enabled) if (enabled)
undo_enable(sprite->undo); undo_enable(sprite->undo);
} }

View File

@ -139,7 +139,7 @@ void dialogs_vector_map(void)
if (!is_interactive () || !sprite) if (!is_interactive () || !sprite)
return; return;
image = GetImage(); image = GetImage(current_sprite);
if (!image) if (!image)
return; return;

View File

@ -1,5 +1,5 @@
/* ASE - Allegro Sprite Editor /* 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 * 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 * 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) static Sprite *load_ICO(const char *filename)
{ {
return NULL; return NULL; /* TODO */
} }
static int save_ICO(Sprite *sprite) static int save_ICO(Sprite *sprite)

View File

@ -231,6 +231,7 @@ enum {
typedef unsigned int JID; typedef unsigned int JID;
typedef void *JMutex;
typedef struct jaccel *JAccel; typedef struct jaccel *JAccel;
typedef struct jhook *JHook; typedef struct jhook *JHook;
typedef struct jquickmenu *JQuickMenu; typedef struct jquickmenu *JQuickMenu;

View File

@ -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; v<sprite->h; ++v) {
for (u=0; u<sprite->w; ++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) void ji_blit_region(JRegion region, int dx, int dy)
{ {
int c, nrects = JI_REGION_NUM_RECTS(region); int c, nrects = JI_REGION_NUM_RECTS(region);

View File

@ -47,6 +47,7 @@ JI_BEGIN_DECLS
getb(c1)+(getb(c2)-getb(c1)) * step / max) getb(c1)+(getb(c2)-getb(c1)) * step / max)
struct FONT; struct FONT;
struct BITMAP;
void jdraw_rect(const JRect rect, int color); void jdraw_rect(const JRect rect, int color);
void jdraw_rectfill(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_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_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); void ji_blit_region(JRegion region, int dx, int dy);
JI_END_DECLS JI_END_DECLS

View File

@ -52,6 +52,7 @@
#include "jinete/jmanager.h" #include "jinete/jmanager.h"
#include "jinete/jmenu.h" #include "jinete/jmenu.h"
#include "jinete/jmessage.h" #include "jinete/jmessage.h"
#include "jinete/jmutex.h"
#include "jinete/jpanel.h" #include "jinete/jpanel.h"
#include "jinete/jquickmenu.h" #include "jinete/jquickmenu.h"
#include "jinete/jrect.h" #include "jinete/jrect.h"

View File

@ -72,6 +72,7 @@ enum {
JI_CURSOR_NULL, JI_CURSOR_NULL,
JI_CURSOR_NORMAL, JI_CURSOR_NORMAL,
JI_CURSOR_NORMAL_ADD, JI_CURSOR_NORMAL_ADD,
JI_CURSOR_FORBIDDEN,
JI_CURSOR_HAND, JI_CURSOR_HAND,
JI_CURSOR_MOVE, JI_CURSOR_MOVE,
JI_CURSOR_SIZE_TL, JI_CURSOR_SIZE_TL,

View File

@ -4,4 +4,4 @@ pcx2data.exe: pcx2data.c
all: pcx2data.exe all: pcx2data.exe
gen: all gen: all
pcx2data.exe stand/*.pcx > stdicons.c ./pcx2data.exe stand/*.pcx > jstandard_theme_icons.h

View File

@ -53,8 +53,8 @@
/* "icons_data" indexes */ /* "icons_data" indexes */
enum { enum {
FIRST_CURSOR = 0, FIRST_CURSOR = 0,
LAST_CURSOR = 11, LAST_CURSOR = 12,
ICON_CHECK_EDGE = 12, ICON_CHECK_EDGE = 13,
ICON_CHECK_MARK, ICON_CHECK_MARK,
ICON_CLOSE, ICON_CLOSE,
ICON_MENU_MARK, ICON_MENU_MARK,
@ -69,6 +69,7 @@ static struct {
} icons_data[ICONS] = { } icons_data[ICONS] = {
{ FALSE, default_theme_cnormal }, { FALSE, default_theme_cnormal },
{ FALSE, default_theme_cnoradd }, { FALSE, default_theme_cnoradd },
{ FALSE, default_theme_cforbidden },
{ FALSE, default_theme_chand }, { FALSE, default_theme_chand },
{ FALSE, default_theme_cmove }, { FALSE, default_theme_cmove },
{ FALSE, default_theme_csizetl }, { 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_NULL:
case JI_CURSOR_NORMAL: case JI_CURSOR_NORMAL:
case JI_CURSOR_NORMAL_ADD: case JI_CURSOR_NORMAL_ADD:
case JI_CURSOR_FORBIDDEN:
*focus_x = 0; *focus_x = 0;
*focus_y = 0; *focus_y = 0;
break; break;
@ -581,19 +583,7 @@ static void theme_draw_button(JWidget widget)
if (jwidget_is_enabled(widget)) { if (jwidget_is_enabled(widget)) {
/* selected */ /* selected */
if (jwidget_is_selected(widget)) { if (jwidget_is_selected(widget)) {
register int c, mask = bitmap_mask_color(icon_bmp); jdraw_inverted_sprite(ji_screen, icon_bmp, icon.x1, icon.y1);
int x, y;
for (y=0; y<icon_bmp->h; ++y) {
for (x=0; x<icon_bmp->w; ++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)));
}
}
} }
/* non-selected */ /* non-selected */
else { else {

View File

@ -1,5 +1,25 @@
/* Generated by pcx2data */ /* 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] = { static unsigned char default_theme_chand[258] = {
16, 16, 16, 16,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

View File

@ -40,9 +40,6 @@ static struct {
int data; int data;
} color_struct; } color_struct;
static char *fg_color = NULL;
static char *bg_color = NULL;
static void fill_color_struct(const char *color); static void fill_color_struct(const char *color);
static int get_mask_for_bitmap(int depth); static int get_mask_for_bitmap(int depth);
@ -53,50 +50,6 @@ int init_module_color(void)
void exit_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) int color_type(const char *color)

View File

@ -1,5 +1,5 @@
/* ASE - Allegro Sprite Editor /* 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 * 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 * it under the terms of the GNU General Public License as published by
@ -19,9 +19,6 @@
#ifndef MODULES_COLOR_H #ifndef MODULES_COLOR_H
#define 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 BITMAP;
struct Image; struct Image;
@ -35,11 +32,6 @@ enum {
int init_module_color(void); int init_module_color(void);
void exit_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); int color_type(const char *color);
char *color_mask(void); char *color_mask(void);
char *color_rgb(int r, int g, int b, int a); char *color_rgb(int r, int g, int b, int a);

View File

@ -27,7 +27,9 @@
#include "modules/gui.h" #include "modules/gui.h"
#include "modules/palette.h" #include "modules/palette.h"
#include "modules/sprites.h" #include "modules/sprites.h"
#include "raster/image.h"
#include "raster/sprite.h" #include "raster/sprite.h"
#include "util/misc.h"
#include "widgets/editor.h" #include "widgets/editor.h"
#endif #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) void editors_draw_sprite(Sprite *sprite, int x1, int y1, int x2, int y2)
{ {
JWidget widget; JWidget widget;
@ -125,42 +114,47 @@ void editors_draw_sprite(Sprite *sprite, int x1, int y1, int x2, int y2)
recursivity) */ recursivity) */
void editors_draw_sprite_tiled(Sprite *sprite, int x1, int y1, int x2, int y2) 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); cx2 = cx1+image->w-1;
ly1 = MAX(y1, 0); cy2 = cy1+image->h-1;
lx2 = MIN(x2, sprite->w-1);
ly2 = MIN(y2, sprite->h-1); lx1 = MAX(x1, cx1);
ly1 = MAX(y1, cy1);
lx2 = MIN(x2, cx2);
ly2 = MIN(y2, cy2);
/* draw the rectangles inside the editor */ /* draw the rectangles inside the editor */
editors_draw_sprite(sprite, lx1, ly1, lx2, ly2); editors_draw_sprite(sprite, lx1, ly1, lx2, ly2);
/* left */ /* left */
if (x1 < 0 && lx2 < sprite->w-1) { if (x1 < cx1 && lx2 < cx2) {
editors_draw_sprite_tiled(sprite, editors_draw_sprite_tiled(sprite,
MAX(lx2, sprite->w+x1), y1, MAX(lx2+1, cx2+1+(x1-cx1)), y1,
sprite->w-1, y2); cx2, y2);
} }
/* top */ /* top */
if (y1 < 0 && ly2 < sprite->h-1) { if (y1 < cy1 && ly2 < cy2) {
editors_draw_sprite_tiled(sprite, editors_draw_sprite_tiled(sprite,
x1, MAX(ly2, sprite->h+y1), x1, MAX(ly2+1, cy2+1+(y1-cx1)),
x2, sprite->h-1); x2, cy2);
} }
/* right */ /* right */
if (x2 >= sprite->w && lx1 > 0) { if (x2 >= cx2+1 && lx1 > cx1) {
editors_draw_sprite_tiled(sprite, editors_draw_sprite_tiled(sprite,
0, y1, cx1, y1,
MIN(lx1, x2-sprite->w), y2); MIN(lx1-1, x2-image->w), y2);
} }
/* bottom */ /* bottom */
if (y2 >= sprite->h && ly1 > 0) { if (y2 >= cy2+1 && ly1 > cy1) {
editors_draw_sprite_tiled(sprite, editors_draw_sprite_tiled(sprite,
x1, 0, x1, cy1,
x2, MIN(ly1, y2-sprite->h)); x2, MIN(ly1-1, y2-image->h));
} }
} }

View File

@ -1,5 +1,5 @@
/* ASE - Allegro Sprite Editor /* 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 * 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 * it under the terms of the GNU General Public License as published by
@ -82,6 +82,11 @@ enum {
GFX_ARROW_LEFT, GFX_ARROW_LEFT,
GFX_ARROW_RIGHT, GFX_ARROW_RIGHT,
GFX_BOX_SHOW,
GFX_BOX_HIDE,
GFX_BOX_LOCK,
GFX_BOX_UNLOCK,
GFX_BITMAP_COUNT, GFX_BITMAP_COUNT,
}; };

View File

@ -1,5 +1,5 @@
/* ASE - Allegro Sprite Editor /* 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 * 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 * 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,
" #### "
" # # "
" # "
"########"
"# #"
"# #"
"# #"
" ###### " },
}; };

View File

@ -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 /* sets current sprite (doesn't show it, only sets the
"current_sprite" pointer). */ "current_sprite" pointer). */
void set_current_sprite(Sprite *sprite) void set_current_sprite(Sprite *sprite)
@ -193,6 +186,35 @@ void sprite_show(Sprite *sprite)
set_sprite_in_more_reliable_editor(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) Stock *sprite_get_images(Sprite *sprite, int target, int write, int **x, int **y)
{ {
Layer *layer = (target & TARGET_LAYERS) ? sprite->set: sprite->layer; Layer *layer = (target & TARGET_LAYERS) ? sprite->set: sprite->layer;

View File

@ -1,5 +1,5 @@
/* ASE - Allegro Sprite Editor /* 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 * 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 * 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_mount(struct Sprite *sprite);
void sprite_unmount(struct Sprite *sprite); void sprite_unmount(struct Sprite *sprite);
void sprite_close(struct Sprite *sprite);
void set_current_sprite(struct Sprite *sprite); void set_current_sprite(struct Sprite *sprite);
void send_sprite_to_top(struct Sprite *sprite); void send_sprite_to_top(struct Sprite *sprite);
void sprite_show(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); struct Stock *sprite_get_images(struct Sprite *sprite, int target, int write, int **x, int **y);
#endif /* MODULES_SPRITES_H */ #endif /* MODULES_SPRITES_H */

View File

@ -1028,9 +1028,10 @@ void control_tool(JWidget widget, Tool *tool, const char *_color)
int x1, y1, x2, y2; int x1, y1, x2, y2;
editor_to_screen(widget, 0, 0, &x1, &y1); editor_to_screen(widget, 0, 0, &x1, &y1);
editor_to_screen(widget, editor_to_screen(widget,
editor->sprite->w-1, editor->sprite->w,
editor->sprite->h-1, &x2, &y2); editor->sprite->h, &x2, &y2);
rectfill(ji_screen, x1, y1, x2, y2, 0); rectfill(ji_screen, x1, y1, x2-1, y2-1, makecol(255, 0, 0));
vsync();
} }
#endif #endif

View File

@ -119,7 +119,7 @@ void SetDrawMode(const char *string)
rectangle, ellipse rectangle, ellipse
uses the current FG color uses the current FG color
*/ */
void ToolTrace(const char *string) void ToolTrace(const char *string, const char *color)
{ {
Sprite *sprite = current_sprite; Sprite *sprite = current_sprite;
@ -158,7 +158,7 @@ void ToolTrace(const char *string)
} }
if (npoints > 0) { 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(x);
jfree(y); jfree(y);
} }
@ -201,10 +201,6 @@ void ResetConfig(void)
{ {
JRect rect; JRect rect;
/* colors */
set_fg_color(DEFAULT_FG);
set_bg_color(DEFAULT_BG);
/* movement */ /* movement */
cfg_options_move_mask = get_config_bool("QuickMovement", "UseMask", TRUE); cfg_options_move_mask = get_config_bool("QuickMovement", "UseMask", TRUE);
@ -275,10 +271,6 @@ void ResetConfig(void)
void RestoreConfig(void) void RestoreConfig(void)
{ {
/* colors */
set_fg_color(NULL);
set_bg_color(NULL);
/* movement */ /* movement */
set_config_bool("QuickMovement", "UseMask", cfg_options_move_mask); set_config_bool("QuickMovement", "UseMask", cfg_options_move_mask);

View File

@ -1,5 +1,5 @@
/* ASE - Allegro Sprite Editor /* 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 * 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 * it under the terms of the GNU General Public License as published by
@ -21,7 +21,7 @@
void SetBrush(const char *string); void SetBrush(const char *string);
void SetDrawMode(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 ResetConfig(void);
void RestoreConfig(void); void RestoreConfig(void);

View File

@ -1,5 +1,5 @@
/* ASE - Allegro Sprite Editor /* 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 * 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 * 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; \ layer->layers = NULL; \
} while (0); } 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_new(Sprite *sprite)
{ {
Layer *layer = (Layer *)gfxobj_new(GFXOBJ_LAYER_IMAGE, sizeof(Layer)); Layer *layer = (Layer *)gfxobj_new(GFXOBJ_LAYER_IMAGE, sizeof(Layer));
@ -167,19 +169,41 @@ void layer_free(Layer *layer)
gfxobj_free((GfxObj *)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) int layer_is_image(const Layer *layer)
{ {
return (layer->gfxobj.type == GFXOBJ_LAYER_IMAGE) ? TRUE: FALSE; 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) int layer_is_set(const Layer *layer)
{ {
return (layer->gfxobj.type == GFXOBJ_LAYER_SET) ? TRUE: FALSE; 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) Layer *layer_get_prev(Layer *layer)
{ {
if (layer->parent && layer->parent->type == GFXOBJ_LAYER_SET) { 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; 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) static bool has_cels(Layer *layer, int frame)
{ {
if (!layer->readable) if (!layer->readable)

View File

@ -1,5 +1,5 @@
/* ASE - Allegro Sprite Editor /* 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 * 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 * 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_image(const Layer *layer);
int layer_is_set(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_prev(Layer *layer);
Layer *layer_get_next(Layer *layer); Layer *layer_get_next(Layer *layer);

View File

@ -1,5 +1,5 @@
/* ASE - Allegro Sprite Editor /* 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 * 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 * it under the terms of the GNU General Public License as published by
@ -20,9 +20,11 @@
#ifndef USE_PRECOMPILED_HEADER #ifndef USE_PRECOMPILED_HEADER
#include <assert.h>
#include <string.h> #include <string.h>
#include "jinete/jlist.h" #include "jinete/jlist.h"
#include "jinete/jmutex.h"
#include "modules/palette.h" #include "modules/palette.h"
#include "raster/raster.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_palette(sprite, pal, sprite->frame);
sprite_set_speed(sprite, 42); sprite_set_speed(sprite, 42);
/* multiple access */
sprite->locked = FALSE;
sprite->mutex = jmutex_new();
return sprite; return sprite;
} }
@ -239,6 +245,8 @@ void sprite_free(Sprite *sprite)
{ {
JLink link; JLink link;
assert(!sprite->locked);
/* destroy images' stock */ /* destroy images' stock */
if (sprite->stock) if (sprite->stock)
stock_free(sprite->stock); stock_free(sprite->stock);
@ -274,6 +282,9 @@ void sprite_free(Sprite *sprite)
if (sprite->set) layer_free(sprite->set); if (sprite->set) layer_free(sprite->set);
if (sprite->bound.seg) jfree(sprite->bound.seg); if (sprite->bound.seg) jfree(sprite->bound.seg);
/* destroy mutex */
jmutex_free(sprite->mutex);
gfxobj_free((GfxObj *)sprite); gfxobj_free((GfxObj *)sprite);
} }
@ -288,12 +299,45 @@ bool sprite_is_associated_to_file(Sprite *sprite)
return sprite->associated_to_file; 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) void sprite_mark_as_saved(Sprite *sprite)
{ {
sprite->undo->diff_saved = sprite->undo->diff_count; sprite->undo->diff_saved = sprite->undo->diff_count;
sprite->associated_to_file = TRUE; 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 *sprite_get_palette(Sprite *sprite, int frame)
{ {
RGB *rgb = NULL; RGB *rgb = NULL;

View File

@ -1,5 +1,5 @@
/* ASE - Allegro Sprite Editor /* 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 * 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 * 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 frames; /* how many frames has this sprite */
int *frlens; /* duration per frame */ int *frlens; /* duration per frame */
int frame; /* current frame, range [0,frames) */ int frame; /* current frame, range [0,frames) */
/* RGB *palette; /\* sprite palette *\/ */
JList palettes; /* list of palettes */ JList palettes; /* list of palettes */
struct Stock *stock; /* stock to get images */ struct Stock *stock; /* stock to get images */
struct Layer *set; /* layer list */ struct Layer *set; /* layer list */
@ -65,6 +64,9 @@ struct Sprite
int scroll_y; int scroll_y;
int zoom; int zoom;
} preferred; } 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); 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_modified(Sprite *sprite);
bool sprite_is_associated_to_file(Sprite *sprite); bool sprite_is_associated_to_file(Sprite *sprite);
bool sprite_is_locked(Sprite *sprite);
void sprite_mark_as_saved(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); RGB *sprite_get_palette(Sprite *sprite, int frame);
void sprite_set_palette(Sprite *sprite, RGB *rgb, int frame); void sprite_set_palette(Sprite *sprite, RGB *rgb, int frame);
void sprite_reset_palettes(Sprite *sprite); void sprite_reset_palettes(Sprite *sprite);

View File

@ -44,6 +44,7 @@
#include "raster/undo.h" #include "raster/undo.h"
#include "util/clipbrd.h" #include "util/clipbrd.h"
#include "util/misc.h" #include "util/misc.h"
#include "widgets/colbar.h"
#include "widgets/statebar.h" #include "widgets/statebar.h"
#endif #endif
@ -141,7 +142,7 @@ void cut_to_clipboard(void)
if (!low_copy()) if (!low_copy())
console_printf("Can't copying an image portion from the current layer\n"); console_printf("Can't copying an image portion from the current layer\n");
else { else {
ClearMask(); ClearMask(color_bar_get_color(app_get_color_bar(), 1));
update_screen_for_sprite(current_sprite); update_screen_for_sprite(current_sprite);
} }
} }

View File

@ -1,5 +1,5 @@
/* ASE - Allegro Sprite Editor /* 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 * 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 * 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) void crop_cel(void)
{ {
Sprite *sprite = current_sprite; Sprite *sprite = current_sprite;
Image *image = GetImage(); Image *image = GetImage(current_sprite);
if ((sprite) && (!mask_is_empty (sprite->mask)) && (image)) { if ((sprite) && (!mask_is_empty (sprite->mask)) && (image)) {
Cel *cel = layer_get_cel(sprite->layer, sprite->frame); Cel *cel = layer_get_cel(sprite->layer, sprite->frame);

View File

@ -51,9 +51,8 @@
#endif #endif
Image *GetImage(void) Image *GetImage(Sprite *sprite)
{ {
Sprite *sprite = current_sprite;
Image *image = NULL; Image *image = NULL;
if (sprite && sprite->layer && layer_is_image(sprite->layer)) { 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 */ /* 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; Sprite *sprite = current_sprite;
int x, y, u, v, putx, puty; int x, y, u, v, putx, puty;
@ -138,43 +137,43 @@ void ClearMask(void)
int color; int color;
if (sprite) { if (sprite) {
image = GetImage2 (sprite, &x, &y, NULL); image = GetImage2(sprite, &x, &y, NULL);
if (image) { 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 (mask_is_empty(sprite->mask)) {
if (undo_is_enabled (sprite->undo)) if (undo_is_enabled(sprite->undo))
undo_image (sprite->undo, image, 0, 0, image->w, image->h); undo_image(sprite->undo, image, 0, 0, image->w, image->h);
/* clear all */ /* clear all */
image_clear (image, color); image_clear(image, color);
} }
else { else {
int x1 = MAX (0, sprite->mask->x); int x1 = MAX(0, sprite->mask->x);
int y1 = MAX (0, sprite->mask->y); int y1 = MAX(0, sprite->mask->y);
int x2 = MIN (image->w-1, sprite->mask->x+sprite->mask->w-1); 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 y2 = MIN(image->h-1, sprite->mask->y+sprite->mask->h-1);
/* do nothing */ /* do nothing */
if (x1 > x2 || y1 > y2) if (x1 > x2 || y1 > y2)
return; return;
if (undo_is_enabled (sprite->undo)) if (undo_is_enabled(sprite->undo))
undo_image (sprite->undo, image, x1, y1, x2-x1+1, y2-y1+1); undo_image(sprite->undo, image, x1, y1, x2-x1+1, y2-y1+1);
/* clear the masked zones */ /* clear the masked zones */
for (v=0; v<sprite->mask->h; v++) { for (v=0; v<sprite->mask->h; v++) {
d = div (0, 8); d = div(0, 8);
address = ((ase_uint8 **)sprite->mask->bitmap->line)[v]+d.quot; address = ((ase_uint8 **)sprite->mask->bitmap->line)[v]+d.quot;
for (u=0; u<sprite->mask->w; u++) { for (u=0; u<sprite->mask->w; u++) {
if ((*address & (1<<d.rem))) { if ((*address & (1<<d.rem))) {
putx = u+sprite->mask->x-x; putx = u+sprite->mask->x-x;
puty = v+sprite->mask->y-y; 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);
} }
} }
} }

View File

@ -1,5 +1,5 @@
/* ASE - Allegro Sprite Editor /* 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 * 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 * it under the terms of the GNU General Public License as published by
@ -27,12 +27,12 @@ struct Layer;
struct Sprite; struct Sprite;
struct Undo; struct Undo;
struct Image *GetImage(void); struct Image *GetImage(struct Sprite *sprite);
struct Image *GetImage2(struct Sprite *sprite, int *x, int *y, int *opacity); struct Image *GetImage2(struct Sprite *sprite, int *x, int *y, int *opacity);
void LoadPalette(const char *filename); void LoadPalette(const char *filename);
void ClearMask(void); void ClearMask(const char *color);
struct Layer *NewLayerFromMask(struct Sprite *src, struct Sprite *dst); struct Layer *NewLayerFromMask(struct Sprite *src, struct Sprite *dst);
struct Image *GetLayerImage(struct Layer *layer, int *x, int *y, int frame); struct Image *GetLayerImage(struct Layer *layer, int *x, int *y, int frame);

View File

@ -23,19 +23,11 @@
#ifndef USE_PRECOMPILED_HEADER #ifndef USE_PRECOMPILED_HEADER
#include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <allegro.h> #include <allegro.h>
#include "jinete/jdraw.h" #include "jinete/jinete.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 "core/app.h" #include "core/app.h"
#include "core/cfg.h" #include "core/cfg.h"
@ -89,6 +81,7 @@ JWidget editor_view_new(void)
{ {
JWidget widget = jview_new(); JWidget widget = jview_new();
jwidget_set_border(widget, 3, 3, 3, 3);
jview_without_bars(widget); jview_without_bars(widget);
jwidget_add_hook(widget, JI_WIDGET, editor_view_msg_proc, NULL); 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) void show_drawing_cursor(JWidget widget)
{ {
jmouse_set_cursor(JI_CURSOR_NULL); Editor *editor = editor_data(widget);
if (!editor_data(widget)->cursor_thick) { assert(editor->sprite != NULL);
jmouse_hide();
editor_draw_cursor(widget, jmouse_x(0), jmouse_y(0)); if (!sprite_is_locked(editor->sprite) &&
jmouse_show(); 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) void hide_drawing_cursor(JWidget widget)
{ {
if (editor_data(widget)->cursor_thick) { Editor *editor = editor_data(widget);
if (editor->cursor_thick) {
jmouse_hide(); jmouse_hide();
editor_clean_cursor(widget); editor_clean_cursor(widget);
jmouse_show(); jmouse_show();
@ -909,19 +918,27 @@ static bool editor_view_msg_proc(JWidget widget, JMessage msg)
if (has_focus) { if (has_focus) {
/* 1st border */ /* 1st border */
jdraw_rectedge(pos, makecol (128, 128, 128), makecol (255, 255, 255)); jdraw_rect(pos, ji_color_selected());
/* 2nd border */ /* 2nd border */
jrect_shrink(pos, 1); 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 { else {
/* 1st border */ /* 1st border */
jdraw_rectedge(pos, makecol (128, 128, 128), makecol (255, 255, 255)); jdraw_rect(pos, makecol(192, 192, 192));
/* 2nd border */ /* 2nd border */
jrect_shrink(pos, 1); 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); jrect_free(pos);