From a68a9e2e564cf5d8d5cd8d79e4bed65132df5de4 Mon Sep 17 00:00:00 2001 From: David Capello Date: Thu, 27 Sep 2007 18:02:23 +0000 Subject: [PATCH] Added cmd_drawing_tools.c. Fixed some errors with double memory free (from 'menuitems' and from 'commands'). Added the four main commands for the editor of sprites (close_editor, make_unique_editor, split_editor). --- ChangeLog | 25 + TODO.txt | 3 - jinete/include/jinete/accel.h | 1 + jinete/src/jaccel.c | 18 + jinete/src/jmenu.c | 10 + jinete/src/jsystem.c | 9 +- jinete/src/jwidget.c | 9 + makefile.lst | 23 +- misc/dist.sh | 276 +++++ misc/etags.sh | 7 + misc/gendeps.sh | 43 + src/commands/cmd_advanced_mode.c | 48 +- src/commands/cmd_brush_tool.c | 33 - src/commands/cmd_close_all_files.c | 22 + src/commands/cmd_close_editor.c | 33 - src/commands/cmd_close_file.c | 40 +- src/commands/cmd_dots_tool.c | 33 - src/commands/cmd_drawing_tools.c | 101 ++ src/commands/cmd_ellipse_tool.c | 33 - src/commands/cmd_floodfill_tool.c | 33 - src/commands/cmd_line_tool.c | 33 - src/commands/cmd_make_unique_editor.c | 33 - src/commands/cmd_marker_tool.c | 33 - src/commands/cmd_pencil_tool.c | 33 - .../viewspr.c => commands/cmd_preview.c} | 473 +++++---- src/commands/cmd_preview_fit_to_screen.c | 36 - src/commands/cmd_preview_normal.c | 46 - src/commands/cmd_preview_tiled.c | 36 - src/commands/cmd_rectangle_tool.c | 33 - src/commands/cmd_select_file.c | 38 + src/commands/cmd_split_editor_horizontally.c | 5 + src/commands/cmd_spray_tool.c | 33 - ...ditor_vertically.c => cmd_sprite_editor.c} | 22 +- src/commands/commands.c | 40 +- src/commands/commands.h | 1 + src/core/app.c | 33 +- src/core/app.h | 2 - src/core/cfg.c | 11 +- src/core/modules.c | 2 - src/dialogs/options.c | 30 +- src/dialogs/viewspr.h | 28 - src/modules/chkmthds.c | 344 ------ src/modules/chkmthds.h | 31 - src/modules/rootmenu.c | 22 +- src/raster/gfxobj.h | 8 +- src/raster/undo.c | 990 +++++++++--------- src/raster/undo.h | 60 +- src/script/bindings.c | 1 - src/widgets/menuitem.c | 1 - 49 files changed, 1500 insertions(+), 1758 deletions(-) create mode 100644 misc/dist.sh create mode 100644 misc/etags.sh create mode 100644 misc/gendeps.sh delete mode 100644 src/commands/cmd_brush_tool.c delete mode 100644 src/commands/cmd_close_editor.c delete mode 100644 src/commands/cmd_dots_tool.c create mode 100644 src/commands/cmd_drawing_tools.c delete mode 100644 src/commands/cmd_ellipse_tool.c delete mode 100644 src/commands/cmd_floodfill_tool.c delete mode 100644 src/commands/cmd_line_tool.c delete mode 100644 src/commands/cmd_make_unique_editor.c delete mode 100644 src/commands/cmd_marker_tool.c delete mode 100644 src/commands/cmd_pencil_tool.c rename src/{dialogs/viewspr.c => commands/cmd_preview.c} (81%) delete mode 100644 src/commands/cmd_preview_fit_to_screen.c delete mode 100644 src/commands/cmd_preview_normal.c delete mode 100644 src/commands/cmd_preview_tiled.c delete mode 100644 src/commands/cmd_rectangle_tool.c delete mode 100644 src/commands/cmd_spray_tool.c rename src/commands/{cmd_split_editor_vertically.c => cmd_sprite_editor.c} (68%) delete mode 100644 src/dialogs/viewspr.h delete mode 100644 src/modules/chkmthds.c delete mode 100644 src/modules/chkmthds.h diff --git a/ChangeLog b/ChangeLog index 3cdeb4492..95720dbfc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,30 @@ +2007-09-27 David A. Capello + + * src/commands/cmd_drawing_tools.c: Added. All change of + drawing-tool is in this file. + + * jinete/src/jaccel.c (jaccel_new_copy): Added to fix an error of + double freed (from 'menuitems' and from 'commands'). + + * src/commands/commands.c (command_reset_keys): Added to fix a + error of duplicate accelerators.. + + * src/commands/cmd_sprite_editor.c: Added with the four main + commands for the editor of sprites: close_editor, + make_unique_editor, split_editor_horizontally, + split_editor_vertically. + 2007-09-26 David A. Capello + * src/commands/cmd_preview.c: Added. + + * src/dialogs/viewspr.c: Removed. + + * src/commands/cmd_advanced_mode.c (command_execute_advanced_mode): + Added a warning message. + + * src/core/app.c (app_switch): Removed. + * src/commands/cmd_open_file.c (command_execute_open_file): Added (based on openspr.lua). diff --git a/TODO.txt b/TODO.txt index 66d3b353e..65346db3e 100644 --- a/TODO.txt +++ b/TODO.txt @@ -3,7 +3,6 @@ High priority work - add support for PNG files. - ver por el nuevo load_font de Allegro. -- borrar src/core/config.c - search for XXX (XXXX is supposed to be high priority); - complete palette operations, and palette editor (it needs a slider or something to move between palette changes); @@ -41,8 +40,6 @@ High priority work - drawing tools: + real-spray; + Animator Pro like: oval, petal, rpoly, star, poly, spiral; -- Add suppport to load old .ase files: - + I don't think so, nobody tell me "I need load an old .ase file!!!" Wish-list --------- diff --git a/jinete/include/jinete/accel.h b/jinete/include/jinete/accel.h index bbf36b232..5409d1dd2 100644 --- a/jinete/include/jinete/accel.h +++ b/jinete/include/jinete/accel.h @@ -37,6 +37,7 @@ JI_BEGIN_DECLS JAccel jaccel_new(void); +JAccel jaccel_new_copy(JAccel accel); void jaccel_free(JAccel accel); void jaccel_add_key(JAccel accel, int shifts, int ascii, int scancode); diff --git a/jinete/src/jaccel.c b/jinete/src/jaccel.c index df1814b5c..ad6a43d76 100644 --- a/jinete/src/jaccel.c +++ b/jinete/src/jaccel.c @@ -61,6 +61,24 @@ JAccel jaccel_new(void) return accel; } +JAccel jaccel_new_copy(JAccel accel) +{ + KeyCombo *key; + JAccel copy; + JLink link; + + copy = jaccel_new(); + if (!copy) + return NULL; + + JI_LIST_FOR_EACH(accel->key_list, link) { + key = (KeyCombo *)link->data; + jaccel_add_key(copy, key->shifts, key->ascii, key->scancode); + } + + return copy; +} + void jaccel_free(JAccel accel) { JLink link; diff --git a/jinete/src/jmenu.c b/jinete/src/jmenu.c index cb78d5477..6b6cdf3e4 100644 --- a/jinete/src/jmenu.c +++ b/jinete/src/jmenu.c @@ -208,10 +208,20 @@ void jmenuitem_set_submenu(JWidget widget, JWidget widget_menu) menuitem->submenu = widget_menu; } +/** + * Changes the keyboard shortcuts (accelerators) for the specified + * widget (a menu-item). + * + * @warning The specified @a accel will be freed automatically when + * the menu-item'll receive JM_DESTROY message. + */ void jmenuitem_set_accel(JWidget widget, JAccel accel) { MenuItem *menuitem = MITEM (widget); + if (menuitem->accel) + jaccel_free(menuitem->accel); + menuitem->accel = accel; } diff --git a/jinete/src/jsystem.c b/jinete/src/jsystem.c index 1fd093f18..857630ee8 100644 --- a/jinete/src/jsystem.c +++ b/jinete/src/jsystem.c @@ -29,7 +29,6 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include #include "jinete/intern.h" @@ -272,7 +271,7 @@ void jmouse_draw_cursor() void jmouse_hide() { - assert(mouse_scares >= 0); + ASSERT(mouse_scares >= 0); if (ji_screen == screen) scare_mouse(); mouse_scares++; @@ -280,7 +279,7 @@ void jmouse_hide() void jmouse_show() { - assert(mouse_scares > 0); + ASSERT(mouse_scares > 0); mouse_scares--; if (ji_screen == screen) unscare_mouse(); @@ -288,13 +287,13 @@ void jmouse_show() bool jmouse_is_hidden() { - assert(mouse_scares >= 0); + ASSERT(mouse_scares >= 0); return mouse_scares > 0; } bool jmouse_is_shown() { - assert(mouse_scares >= 0); + ASSERT(mouse_scares >= 0); return mouse_scares == 0; } diff --git a/jinete/src/jwidget.c b/jinete/src/jwidget.c index f053e1298..7a5050f25 100644 --- a/jinete/src/jwidget.c +++ b/jinete/src/jwidget.c @@ -38,6 +38,9 @@ # include #endif #include +#ifdef ALLEGRO_WINDOWS +#include +#endif #include "jinete.h" #include "jinete/intern.h" @@ -1238,6 +1241,9 @@ void jwidget_hard_capture_mouse(JWidget widget) { if (!jmanager_get_capture()) { jmanager_set_capture(widget); +#ifdef ALLEGRO_WINDOWS + SetCapture(win_get_window()); +#endif if (jmanager_get_capture() == widget) widget->flags |= JI_HARDCAPTURE; @@ -1248,6 +1254,9 @@ void jwidget_release_mouse(JWidget widget) { if (jmanager_get_capture() == widget) { jmanager_free_capture(); +#ifdef ALLEGRO_WINDOWS + ReleaseCapture(); +#endif widget->flags &= ~JI_HARDCAPTURE; } diff --git a/makefile.lst b/makefile.lst index 1b4b0ac56..ccb7f683f 100644 --- a/makefile.lst +++ b/makefile.lst @@ -9,11 +9,8 @@ ASE_SOURCES = \ src/commands/cmd_about.c \ src/commands/cmd_advanced_mode.c \ src/commands/cmd_auto_crop_sprite.c \ - src/commands/cmd_brush_tool.c \ src/commands/cmd_change_image_type.c \ src/commands/cmd_clear.c \ - src/commands/cmd_close_all_files.c \ - src/commands/cmd_close_editor.c \ src/commands/cmd_close_file.c \ src/commands/cmd_color_curve.c \ src/commands/cmd_configure_screen.c \ @@ -28,28 +25,24 @@ ASE_SOURCES = \ src/commands/cmd_cut.c \ src/commands/cmd_deselect_mask.c \ src/commands/cmd_despeckle.c \ - src/commands/cmd_dots_tool.c \ src/commands/cmd_draw_text.c \ + src/commands/cmd_drawing_tools.c \ src/commands/cmd_duplicate_layer.c \ src/commands/cmd_duplicate_sprite.c \ - src/commands/cmd_ellipse_tool.c \ + src/commands/cmd_sprite_editor.c \ src/commands/cmd_exit.c \ src/commands/cmd_film_editor.c \ src/commands/cmd_flatten_layers.c \ src/commands/cmd_flip_horizontal.c \ src/commands/cmd_flip_vertical.c \ - src/commands/cmd_floodfill_tool.c \ src/commands/cmd_frame_properties.c \ src/commands/cmd_invert_color.c \ src/commands/cmd_invert_mask.c \ src/commands/cmd_layer_properties.c \ - src/commands/cmd_line_tool.c \ src/commands/cmd_link_frame.c \ src/commands/cmd_load_mask.c \ src/commands/cmd_load_session.c \ - src/commands/cmd_make_unique_editor.c \ src/commands/cmd_mapgen.c \ - src/commands/cmd_marker_tool.c \ src/commands/cmd_mask_all.c \ src/commands/cmd_mask_by_color.c \ src/commands/cmd_mask_repository.c \ @@ -63,15 +56,11 @@ ASE_SOURCES = \ src/commands/cmd_options.c \ src/commands/cmd_palette_editor.c \ src/commands/cmd_paste.c \ - src/commands/cmd_pencil_tool.c \ src/commands/cmd_play_flic.c \ - src/commands/cmd_preview_fit_to_screen.c \ - src/commands/cmd_preview_normal.c \ - src/commands/cmd_preview_tiled.c \ + src/commands/cmd_preview.c \ src/commands/cmd_quick_copy.c \ src/commands/cmd_quick_move.c \ src/commands/cmd_record_screen.c \ - src/commands/cmd_rectangle_tool.c \ src/commands/cmd_redo.c \ src/commands/cmd_refresh.c \ src/commands/cmd_remove_frame.c \ @@ -85,9 +74,6 @@ ASE_SOURCES = \ src/commands/cmd_save_session.c \ src/commands/cmd_screen_shot.c \ src/commands/cmd_select_file.c \ - src/commands/cmd_split_editor_horizontally.c \ - src/commands/cmd_split_editor_vertically.c \ - src/commands/cmd_spray_tool.c \ src/commands/cmd_sprite_properties.c \ src/commands/cmd_tips.c \ src/commands/cmd_undo.c \ @@ -100,7 +86,6 @@ ASE_SOURCES = \ src/core/dirs.c \ src/core/modules.c \ src/core/shutdown.c \ - src/dialogs/about.c \ src/dialogs/canvasze.c \ src/dialogs/colsel.c \ src/dialogs/dfrlen.c \ @@ -126,7 +111,6 @@ ASE_SOURCES = \ src/dialogs/tips.c \ src/dialogs/toolconf.c \ src/dialogs/vectmap.c \ - src/dialogs/viewspr.c \ src/effect/colcurve.c \ src/effect/convmatr.c \ src/effect/effect.c \ @@ -148,7 +132,6 @@ ASE_SOURCES = \ src/intl/intl.c \ src/intl/msgids.c \ src/main.c \ - src/modules/chkmthds.c \ src/modules/color.c \ src/modules/editors.c \ src/modules/gfx.c \ diff --git a/misc/dist.sh b/misc/dist.sh new file mode 100644 index 000000000..6f1bffe12 --- /dev/null +++ b/misc/dist.sh @@ -0,0 +1,276 @@ +#! /bin/sh + +dir="`pwd`" +version=0.6 +distdir=ase-$version + +freetype_files="jinete/freetype/ChangeLog \ + jinete/freetype/descrip.mms \ + jinete/freetype/INSTALL \ + jinete/freetype/README \ + jinete/freetype/README.UNX \ + jinete/freetype/docs/* \ + jinete/freetype/include/*.h \ + jinete/freetype/include/freetype/*.h \ + jinete/freetype/include/freetype/cache/*.h \ + jinete/freetype/include/freetype/config/*.h \ + jinete/freetype/include/freetype/internal/*.h \ + jinete/freetype/src/autohint/*.[ch] \ + jinete/freetype/src/autohint/*.py \ + jinete/freetype/src/autohint/*.txt \ + jinete/freetype/src/base/*.[ch] \ + jinete/freetype/src/cache/*.[ch] \ + jinete/freetype/src/cff/*.[ch] \ + jinete/freetype/src/cid/*.[ch] \ + jinete/freetype/src/pcf/*.[ch] \ + jinete/freetype/src/psaux/*.[ch] \ + jinete/freetype/src/pshinter/*.[ch] \ + jinete/freetype/src/psnames/*.[ch] \ + jinete/freetype/src/raster/*.[ch] \ + jinete/freetype/src/sfnt/*.[ch] \ + jinete/freetype/src/smooth/*.[ch] \ + jinete/freetype/src/truetype/*.[ch] \ + jinete/freetype/src/type1/*.[ch] \ + jinete/freetype/src/winfonts/*.[ch]" + +jinete_files="jinete/*.txt \ + jinete/makefile.dj \ + jinete/makefile.gcc \ + jinete/makefile.lnx \ + jinete/makefile.lst \ + jinete/makefile.mgw \ + jinete/docs/*.html \ + jinete/docs/*.info \ + jinete/docs/*.texi \ + jinete/docs/*.txt \ + jinete/examples/*.[ch] \ + jinete/examples/*.jid \ + jinete/examples/*.pcx \ + jinete/examples/*.ttf \ + jinete/examples/*.txt \ + jinete/include/*.h \ + jinete/include/jinete/*.h \ + jinete/lib/*.txt \ + jinete/lib/djgpp/*.txt \ + jinete/lib/mingw32/*.txt \ + jinete/lib/unix/*.txt \ + jinete/obj/*.txt \ + jinete/obj/djgpp/*.txt \ + jinete/obj/mingw32/*.txt \ + jinete/obj/unix/*.txt \ + jinete/src/*.c \ + jinete/src/themes/*.c \ + jinete/src/themes/Makefile.icons \ + jinete/src/themes/stand/*.pcx \ + $freetype_files" + +gfli_files="third_party/gfli/*.[ch] \ + third_party/gfli/README \ + third_party/gfli/TODO" + +lua_files="third_party/lua/COPYRIGHT \ + third_party/lua/HISTORY \ + third_party/lua/README \ + third_party/lua/doc/idx.html \ + third_party/lua/doc/index.html \ + third_party/lua/doc/manual.html \ + third_party/lua/include/*.h \ + third_party/lua/src/*.[ch] \ + third_party/lua/src/lib/*.[ch] \ + third_party/lua/src/lib/README" + +libart_files="third_party/libart_lgpl/AUTHORS \ + third_party/libart_lgpl/ChangeLog \ + third_party/libart_lgpl/COPYING \ + third_party/libart_lgpl/INSTALL \ + third_party/libart_lgpl/NEWS \ + third_party/libart_lgpl/README \ + third_party/libart_lgpl/*.[ch]" + +ase_files="all.h \ + config.h \ + ChangeLog \ + COPYING \ + fix.bat \ + fix.sh \ + makefile.cfg \ + makefile.dj \ + makefile.gcc \ + makefile.lnx \ + makefile.lst \ + makefile.mgw \ + *.txt \ + data/aseicon.* \ + data/convmatr.def \ + data/defgui-en.xml \ + data/defgui-es.xml \ + data/fonts/*.pcx \ + data/jids/*.jid \ + data/palettes/*.col \ + data/po/*.po \ + data/scripts/*.lua \ + data/scripts/examples/*.lua \ + data/session/*.txt \ + data/tips/*.pcx \ + data/tips/tips.en \ + data/tips/tips.es \ + docs/*.html \ + docs/*.info \ + docs/*.pdf \ + docs/*.texi \ + docs/*.txt \ + docs/files/*.txt \ + docs/licenses/*.txt \ + obj/*.txt \ + obj/djgpp/*.txt \ + obj/mingw32/*.txt \ + obj/unix/*.txt \ + src/*.[ch] \ + src/*.rc \ + src/commands/*.[ch] \ + src/console/*.[ch] \ + src/core/*.[ch] \ + src/dialogs/*.[ch] \ + src/dialogs/effect/*.[ch] \ + src/effect/*.[ch] \ + src/file/*.[ch] \ + src/file/gif/*.[ch] \ + src/intl/*.[ch] \ + src/modules/*.[ch] \ + src/raster/*.[ch] \ + src/raster/examples/*.c \ + src/raster/x86/*.s \ + src/script/*.[ch] \ + src/script/bindings.py \ + src/util/*.[ch] \ + src/widgets/*.[ch] \ + src/widgets/editor/*.[ch] \ + src/widgets/editor/*.txt \ + third_party/*.txt" + +###################################################################### +# Source Distribution + +# if [ ! -f $distdir.tar.gz ] ; then +if [ ! -f $distdir.zip ] ; then + +cd "$dir/.." +mkdir "$dir/$distdir" +cp --parents \ + $jinete_files \ + $gfli_files \ + $lua_files \ + $libart_files \ + $ase_files \ + "$dir/$distdir" +cd "$dir" + +# tar vczf $distdir.tar.gz $distdir +# tar vcjf $distdir.tar.bz2 $distdir +zip -r -9 $distdir.zip $distdir +rm -fr $distdir + +fi + +exit + +###################################################################### +# Files for binary distributions + +function def_common_files () +{ + txt_files=" \ +$1/*.txt \ +$1/COPYING \ +$1/data/convmatr.def \ +$1/data/fonts/*.txt \ +$1/data/jids/*.jid \ +$1/data/menus.en \ +$1/data/menus.es \ +$1/data/po/es.po \ +$1/data/scripts/*.lua \ +$1/data/scripts/examples/*.lua \ +$1/data/session/*.txt \ +$1/data/tips/*.en \ +$1/data/tips/*.es \ +$1/docs/*.html \ +$1/docs/*.info \ +$1/docs/*.texi \ +$1/docs/*.txt \ +$1/docs/files/*.txt \ +$1/docs/licenses/*.txt" + + bin_files=" \ +$1/data/aseicon.* \ +$1/data/fonts/*.pcx \ +$1/data/fonts/*.ttf \ +$1/data/palettes/*.col \ +$1/data/tips/*.pcx \ +$1/docs/*.pdf" +} + +###################################################################### +# Unix Distribution + +# if [ ! -f $distdir-unix.tar.gz ] ; then + +# cd $dir/.. +# rm ase +# make -f makefile.lnx CONFIGURED=1 HAVE_LIBJPEG=1 +# strip ase +# def_common_files . +# mkdir $dir/$distdir-unix +# cp -r --parents $txt_files $bin_files ase $dir/$distdir-unix + +# cd $dir +# tar vczf $distdir-unix.tar.gz $distdir-unix +# rm -fr $distdir-unix + +# fi + +###################################################################### +# DOS Distribution + +# if [ ! -f $distdir-dos.zip ] ; then + +# cd $dir/.. +# rm ase.exe +# djgpp make -f makefile.dj CONFIGURED=1 HAVE_LIBJPEG=1 +# djgpp strip ase.exe +# def_common_files . +# mkdir $dir/$distdir-dos +# cp -r --parents $txt_files $bin_files ase.exe cwsdpmi.doc cwsdpmi.exe $dir/$distdir-dos + +# cd $dir +# def_common_files $distdir-dos +# zip -l -9 $distdir-dos.zip $txt_files +# zip -9 $distdir-dos.zip $bin_files \ +# $distdir-dos/ase.exe \ +# $distdir-dos/cwsdpmi.* +# rm -fr $distdir-dos + +# fi + +###################################################################### +# Win32 Distribution + +if [ ! -f $distdir-win32.zip ] ; then + +cd "$dir/.." +rm ase +mingw32 make -f makefile.mgw CONFIGURED=1 HAVE_LIBJPEG=1 +mingw32 strip ase.exe +def_common_files . +mkdir "$dir/$distdir-win32" +cp -r --parents $txt_files $bin_files ase.exe "$dir/$distdir-win32" +cp alleg42.dll "$dir/$distdir-win32" + +cd "$dir" +def_common_files $distdir-win32 +zip -l -9 $distdir-win32.zip $txt_files +zip -9 $distdir-win32.zip $bin_files \ + $distdir-win32/ase.exe \ + $distdir-win32/alleg42.dll +rm -fr $distdir-win32 + +fi diff --git a/misc/etags.sh b/misc/etags.sh new file mode 100644 index 000000000..e64a994a7 --- /dev/null +++ b/misc/etags.sh @@ -0,0 +1,7 @@ +#! /bin/sh + +find data/scripts jinete src third_party \ + \( -name '*.[ch]' -o \ + -name '*.lua' \) -print | \ + sed -e "/_old/D" | \ + etags - diff --git a/misc/gendeps.sh b/misc/gendeps.sh new file mode 100644 index 000000000..35adc6fb2 --- /dev/null +++ b/misc/gendeps.sh @@ -0,0 +1,43 @@ +#! /bin/sh + +# Jinete dependencies + +GCC="gcc -MM" +CFLAGS="-Iinclude -Ifreetype/include" + +cd jinete +$GCC $CFLAGS src/*.c \ + | sed -e 's/^\([a-z_\-]*\.o\)/obj\/mingw32\/\1/' > makefile.dep +cd .. + +# ASE dependencies + +CFLAGS="-I. \ + -Isrc -Ijinete/include -Ilibase \ + -Ithird_party/lua/include \ + -Ithird_party/gfli \ + -Ithird_party/intl \ + -Ithird_party/libpng \ + -Ithird_party/zlib \ + -Ijinete/freetype/include \ + -Ithird_party" + +rm -f makefile.dep + +$GCC $CFLAGS jinete/src/*.c \ + src/*.c \ + src/commands/*.c \ + src/console/*.c \ + src/core/*.c \ + src/dialogs/*.c \ + src/dialogs/effect/*.c \ + src/effect/*.c \ + src/file/*.c \ + src/intl/*.c \ + src/modules/*.c \ + src/raster/*.c \ + src/script/bindings.c src/script/script.c \ + src/util/*.c \ + src/widgets/*.c \ + src/widgets/editor/*.c \ + | sed -e 's/^\([a-z_\-]*\.o\)/obj\/mingw32\/\1/' >> makefile.dep diff --git a/src/commands/cmd_advanced_mode.c b/src/commands/cmd_advanced_mode.c index dd6e3bc6e..10e25d0d9 100644 --- a/src/commands/cmd_advanced_mode.c +++ b/src/commands/cmd_advanced_mode.c @@ -20,14 +20,54 @@ #ifndef USE_PRECOMPILED_HEADER +#include "jinete.h" + +#include "commands/commands.h" #include "core/app.h" +#include "core/cfg.h" #endif +static bool advanced_mode = FALSE; + void command_execute_advanced_mode(const char *argument) { - app_switch(app_get_tool_bar()); - app_switch(app_get_menu_bar()); - app_switch(app_get_status_bar()); - app_switch(app_get_color_bar()); + advanced_mode = !advanced_mode; + + if (advanced_mode) { + jwidget_hide(app_get_tool_bar()); + jwidget_hide(app_get_menu_bar()); + jwidget_hide(app_get_status_bar()); + jwidget_hide(app_get_color_bar()); + } + else { + jwidget_show(app_get_tool_bar()); + jwidget_show(app_get_menu_bar()); + jwidget_show(app_get_status_bar()); + jwidget_show(app_get_color_bar()); + } + + jwindow_remap(app_get_top_window()); + jwidget_dirty(app_get_top_window()); + + if (advanced_mode && + get_config_bool("AdvancedMode", "Warning", TRUE)) { + Command *cmd_advanced_mode = command_get_by_name(CMD_ADVANCED_MODE); + char warning[1024]; + char key[1024]; + char buf[1024]; + + strcpy(warning, _("You are going to enter in \"Advanced Mode\"." + "<accel, key); + + sprintf(buf, warning, key); + + if (jalert("%s<<%s||%s||%s", + _("Warning - Important"), + buf, + _("&Don't show it again"), _("&Continue")) == 1) { + set_config_bool("AdvancedMode", "Warning", FALSE); + } + } } diff --git a/src/commands/cmd_brush_tool.c b/src/commands/cmd_brush_tool.c deleted file mode 100644 index 6299ea3d3..000000000 --- a/src/commands/cmd_brush_tool.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ase -- allegro-sprite-editor: the ultimate sprites factory - * Copyright (C) 2007 David A. Capello - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config.h" - -#ifndef USE_PRECOMPILED_HEADER - -#include "jinete.h" - -#include "core/app.h" -#include "modules/sprites.h" -#include "raster/sprite.h" - -#endif - -void command_execute_brush_tool(const char *argument) -{ -} diff --git a/src/commands/cmd_close_all_files.c b/src/commands/cmd_close_all_files.c index ddf5a7521..3ae51fb14 100644 --- a/src/commands/cmd_close_all_files.c +++ b/src/commands/cmd_close_all_files.c @@ -28,6 +28,28 @@ #endif +bool command_enabled_close_all_file(const char *argument) +{ + return !jlist_empty(get_sprite_list()); +} + void command_execute_close_all_files(const char *argument) { + Sprite *sprite = get_first_sprite(); + Sprite *clipboard = get_clipboard_sprite(); + + while (sprite) { + sprite = current_sprite; + + /* check if this sprite is modified */ + if (sprite_is_modified(sprite) && + (!clipboard || sprite->gfxobj.id != clipboard->gfxobj.id)) { + command_execute_close_file(); + break; + } + sprite = get_next_sprite(sprite); + } + + /* close the window */ + jwindow_close(app_get_top_window(), 0); } diff --git a/src/commands/cmd_close_editor.c b/src/commands/cmd_close_editor.c deleted file mode 100644 index 77f757627..000000000 --- a/src/commands/cmd_close_editor.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ase -- allegro-sprite-editor: the ultimate sprites factory - * Copyright (C) 2007 David A. Capello - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config.h" - -#ifndef USE_PRECOMPILED_HEADER - -#include "jinete.h" - -#include "core/app.h" -#include "modules/sprites.h" -#include "raster/sprite.h" - -#endif - -void command_execute_close_editor(const char *argument) -{ -} diff --git a/src/commands/cmd_close_file.c b/src/commands/cmd_close_file.c index db059fc80..1cb0c0b10 100644 --- a/src/commands/cmd_close_file.c +++ b/src/commands/cmd_close_file.c @@ -30,23 +30,52 @@ #endif +static bool close_current_sprite(void); + +/* ======================== */ +/* close_file */ +/* ======================== */ + bool command_enabled_close_file(const char *argument) { return current_sprite != NULL; } void command_execute_close_file(const char *argument) +{ + close_current_sprite(); +} + +/* ======================== */ +/* close_all_files */ +/* ======================== */ + +bool command_enabled_close_all_files(const char *argument) +{ + return !jlist_empty(get_sprite_list()); +} + +void command_execute_close_all_files(const char *argument) +{ + while (close_current_sprite()) + ; +} + +/** + * Closes the current sprite, asking to the user if to save it if it's + * modified. + */ +static bool close_current_sprite(void) { Sprite *sprite = current_sprite; /* see if the sprite has changes */ while (sprite_is_modified(sprite)) { /* ask what want to do the user with the changes in the sprite */ - int ret = jalert("%s<<%s<<%s||%s", - _("Warning"), - _("Saving changes in:"), + int ret = jalert("%s<<%s<<%s||%s||%s||%s", + _("Warning"), _("Saving changes in:"), get_filename(sprite->filename), - _("&Save||&Discard||&Cancel")); + _("&Save"), _("&Discard"), _("&Cancel")); if (ret == 1) { /* "save": save the changes */ @@ -54,7 +83,7 @@ void command_execute_close_file(const char *argument) } else if (ret != 2) { /* "cancel" or "ESC" */ - return; /* we back doing nothing */ + return FALSE; /* we back doing nothing */ } else { /* "discard" */ @@ -65,4 +94,5 @@ void command_execute_close_file(const char *argument) /* closes the sprite */ sprite_unmount(sprite); sprite_free(sprite); + return TRUE; } diff --git a/src/commands/cmd_dots_tool.c b/src/commands/cmd_dots_tool.c deleted file mode 100644 index d699a4064..000000000 --- a/src/commands/cmd_dots_tool.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ase -- allegro-sprite-editor: the ultimate sprites factory - * Copyright (C) 2007 David A. Capello - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config.h" - -#ifndef USE_PRECOMPILED_HEADER - -#include "jinete.h" - -#include "core/app.h" -#include "modules/sprites.h" -#include "raster/sprite.h" - -#endif - -void command_execute_dots_tool(const char *argument) -{ -} diff --git a/src/commands/cmd_drawing_tools.c b/src/commands/cmd_drawing_tools.c new file mode 100644 index 000000000..8cad0d505 --- /dev/null +++ b/src/commands/cmd_drawing_tools.c @@ -0,0 +1,101 @@ +/* ase -- allegro-sprite-editor: the ultimate sprites factory + * Copyright (C) 2007 David A. Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "config.h" + +#ifndef USE_PRECOMPILED_HEADER + +#include "jinete.h" + +#include "core/app.h" +#include "modules/sprites.h" +#include "raster/sprite.h" + +#endif + +/* ======================== */ +/* brush_tool */ +/* ======================== */ + +void command_execute_brush_tool(const char *argument) +{ +} + +/* ======================== */ +/* dots_tool */ +/* ======================== */ + +void command_execute_dots_tool(const char *argument) +{ +} + +/* ======================== */ +/* ellipse_tool */ +/* ======================== */ + +void command_execute_ellipse_tool(const char *argument) +{ +} + +/* ======================== */ +/* floodfill_tool */ +/* ======================== */ + +void command_execute_floodfill_tool(const char *argument) +{ +} + +/* ======================== */ +/* line_tool */ +/* ======================== */ + +void command_execute_line_tool(const char *argument) +{ +} + +/* ======================== */ +/* marker_tool */ +/* ======================== */ + +void command_execute_marker_tool(const char *argument) +{ +} + +/* ======================== */ +/* pencil_tool */ +/* ======================== */ + +void command_execute_pencil_tool(const char *argument) +{ +} + +/* ======================== */ +/* rectangle_tool */ +/* ======================== */ + +void command_execute_rectangle_tool(const char *argument) +{ +} + +/* ======================== */ +/* spray_tool */ +/* ======================== */ + +void command_execute_spray_tool(const char *argument) +{ +} diff --git a/src/commands/cmd_ellipse_tool.c b/src/commands/cmd_ellipse_tool.c deleted file mode 100644 index a027af289..000000000 --- a/src/commands/cmd_ellipse_tool.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ase -- allegro-sprite-editor: the ultimate sprites factory - * Copyright (C) 2007 David A. Capello - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config.h" - -#ifndef USE_PRECOMPILED_HEADER - -#include "jinete.h" - -#include "core/app.h" -#include "modules/sprites.h" -#include "raster/sprite.h" - -#endif - -void command_execute_ellipse_tool(const char *argument) -{ -} diff --git a/src/commands/cmd_floodfill_tool.c b/src/commands/cmd_floodfill_tool.c deleted file mode 100644 index 22ff1d0a7..000000000 --- a/src/commands/cmd_floodfill_tool.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ase -- allegro-sprite-editor: the ultimate sprites factory - * Copyright (C) 2007 David A. Capello - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config.h" - -#ifndef USE_PRECOMPILED_HEADER - -#include "jinete.h" - -#include "core/app.h" -#include "modules/sprites.h" -#include "raster/sprite.h" - -#endif - -void command_execute_floodfill_tool(const char *argument) -{ -} diff --git a/src/commands/cmd_line_tool.c b/src/commands/cmd_line_tool.c deleted file mode 100644 index 0f2079840..000000000 --- a/src/commands/cmd_line_tool.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ase -- allegro-sprite-editor: the ultimate sprites factory - * Copyright (C) 2007 David A. Capello - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config.h" - -#ifndef USE_PRECOMPILED_HEADER - -#include "jinete.h" - -#include "core/app.h" -#include "modules/sprites.h" -#include "raster/sprite.h" - -#endif - -void command_execute_line_tool(const char *argument) -{ -} diff --git a/src/commands/cmd_make_unique_editor.c b/src/commands/cmd_make_unique_editor.c deleted file mode 100644 index 1226566a3..000000000 --- a/src/commands/cmd_make_unique_editor.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ase -- allegro-sprite-editor: the ultimate sprites factory - * Copyright (C) 2007 David A. Capello - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config.h" - -#ifndef USE_PRECOMPILED_HEADER - -#include "jinete.h" - -#include "core/app.h" -#include "modules/sprites.h" -#include "raster/sprite.h" - -#endif - -void command_execute_make_unique_editor(const char *argument) -{ -} diff --git a/src/commands/cmd_marker_tool.c b/src/commands/cmd_marker_tool.c deleted file mode 100644 index 17bbf4eca..000000000 --- a/src/commands/cmd_marker_tool.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ase -- allegro-sprite-editor: the ultimate sprites factory - * Copyright (C) 2007 David A. Capello - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config.h" - -#ifndef USE_PRECOMPILED_HEADER - -#include "jinete.h" - -#include "core/app.h" -#include "modules/sprites.h" -#include "raster/sprite.h" - -#endif - -void command_execute_marker_tool(const char *argument) -{ -} diff --git a/src/commands/cmd_pencil_tool.c b/src/commands/cmd_pencil_tool.c deleted file mode 100644 index b1718fe03..000000000 --- a/src/commands/cmd_pencil_tool.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ase -- allegro-sprite-editor: the ultimate sprites factory - * Copyright (C) 2007 David A. Capello - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config.h" - -#ifndef USE_PRECOMPILED_HEADER - -#include "jinete.h" - -#include "core/app.h" -#include "modules/sprites.h" -#include "raster/sprite.h" - -#endif - -void command_execute_pencil_tool(const char *argument) -{ -} diff --git a/src/dialogs/viewspr.c b/src/commands/cmd_preview.c similarity index 81% rename from src/dialogs/viewspr.c rename to src/commands/cmd_preview.c index 8b75a1e52..24ee5ec00 100644 --- a/src/dialogs/viewspr.c +++ b/src/commands/cmd_preview.c @@ -1,216 +1,257 @@ -/* ase -- allegro-sprite-editor: the ultimate sprites factory - * Copyright (C) 2001-2005, 2007 David A. Capello - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config.h" - -#ifndef USE_PRECOMPILED_HEADER - -#include - -#include "jinete.h" - -#include "core/app.h" -#include "core/core.h" -#include "dialogs/viewspr.h" -#include "modules/editors.h" -#include "modules/gfx.h" -#include "modules/gui.h" -#include "modules/render.h" -#include "raster/raster.h" -#include "widgets/editor.h" -#include "widgets/statebar.h" - -#endif - -void preview_sprite(int flags) -{ - JWidget widget = current_editor; - - if (is_interactive() && widget && editor_get_sprite(widget)) { - Editor *editor = editor_data (widget); - Sprite *sprite = editor_get_sprite (widget); - JWidget view = jwidget_get_view (widget); - int old_mouse_x, old_mouse_y; - int scroll_x, scroll_y; - int u, v, x, y, w, h; - int shiftx, shifty; - Image *image; - BITMAP *bmp; - int redraw; - JRect vp; - int bg_color, index_bg_color = -1; - - jmanager_free_mouse(); - - vp = jview_get_viewport_position(view); - jview_get_scroll(view, &scroll_x, &scroll_y); - - old_mouse_x = jmouse_x(0); - old_mouse_y = jmouse_y(0); - - bmp = create_bitmap (sprite->w, sprite->h); - if (bmp) { - /* print a informative text */ - status_bar_set_text(app_get_status_bar(), 1, _("Rendering...")); - jwidget_flush_redraw(app_get_status_bar()); - jmanager_dispatch_messages(); - - jmouse_set_cursor(JI_CURSOR_NULL); - jmouse_set_position(JI_SCREEN_W/2, JI_SCREEN_H/2); - - /* render the sprite in the bitmap */ - image = render_sprite(sprite, 0, 0, sprite->w, sprite->h, - sprite->frpos, 0); - if (image) { - image_to_allegro(image, bmp, 0, 0); - image_free(image); - } - - if (!(flags & PREVIEW_TILED)) - bg_color = palette_color[index_bg_color=0]; - else - bg_color = makecol(128, 128, 128); - - shiftx = - scroll_x + vp->x1 + editor->offset_x; - shifty = - scroll_y + vp->y1 + editor->offset_y; - - w = sprite->w << editor->zoom; - h = sprite->h << editor->zoom; - - redraw = TRUE; - do { - /* update scroll */ - if (jmouse_poll()) { - shiftx += jmouse_x(0) - JI_SCREEN_W/2; - shifty += jmouse_y(0) - JI_SCREEN_H/2; - jmouse_set_position(JI_SCREEN_W/2, JI_SCREEN_H/2); - jmouse_poll(); - - redraw = TRUE; - } - - if (redraw) { - redraw = FALSE; - - /* fit on screen */ - if (flags & PREVIEW_FIT_ON_SCREEN) { - double sx, sy, scale, outw, outh; - - sx = (double)JI_SCREEN_W / (double)bmp->w; - sy = (double)JI_SCREEN_H / (double)bmp->h; - scale = MIN (sx, sy); - - outw = (double)bmp->w * (double)scale; - outh = (double)bmp->h * (double)scale; - - stretch_blit(bmp, ji_screen, 0, 0, bmp->w, bmp->h, 0, 0, outw, outh); - rectfill_exclude(ji_screen, 0, 0, JI_SCREEN_W-1, JI_SCREEN_H-1, - 0, 0, outw-1, outh-1, bg_color); - } - /* draw in normal size */ - else { - if (!(flags & PREVIEW_TILED)) { - x = shiftx; - y = shifty; - } - else { - x = SGN(shiftx) * (ABS(shiftx)%w); - y = SGN(shifty) * (ABS(shifty)%h); - } - - if (!(flags & PREVIEW_TILED)) { -/* rectfill_exclude(ji_screen, 0, 0, JI_SCREEN_W-1, JI_SCREEN_H-1, */ -/* x, y, x+w-1, y+h-1, bg_color); */ - clear_to_color(ji_screen, bg_color); - } - - if (!editor->zoom) { - /* in the center */ - if (!(flags & PREVIEW_TILED)) - draw_sprite(ji_screen, bmp, x, y); - /* tiled */ - else - for (v=y-h; vw, bmp->h, x, y, w, h); - /* tiled */ - else - for (v=y-h; vw, bmp->h, u, v, w, h); - } - } - } - - gui_feedback(); - - if (keypressed()) { - int c = readkey()>>8; - - /* change frame */ - if (editor_keys_toset_frpos(widget, c)) { - /* redraw */ - redraw = TRUE; - - /* render the sprite in the bitmap */ - image = render_sprite(sprite, 0, 0, sprite->w, sprite->h, - sprite->frpos, 0); - if (image) { - image_to_allegro(image, bmp, 0, 0); - image_free(image); - } - } - /* change background color */ - else if (c == KEY_PLUS_PAD) { - if (index_bg_color < 255) { - bg_color = palette_color[++index_bg_color]; - redraw = TRUE; - } - } - else if (c == KEY_MINUS_PAD) { - if (index_bg_color > 0) { - bg_color = palette_color[--index_bg_color]; - redraw = TRUE; - } - } - else - break; - } - } while (!jmouse_b(0)); - - destroy_bitmap(bmp); - } - - do { - jmouse_poll(); - gui_feedback(); - } while (jmouse_b(0)); - clear_keybuf(); - - jmouse_set_position(old_mouse_x, old_mouse_y); - jmouse_set_cursor(JI_CURSOR_NORMAL); - - jmanager_refresh_screen(); - jrect_free(vp); - } -} +/* ase -- allegro-sprite-editor: the ultimate sprites factory + * Copyright (C) 2007 David A. Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "config.h" + +#ifndef USE_PRECOMPILED_HEADER + +#include "modules/sprites.h" + +#include + +#include "jinete.h" + +#include "core/app.h" +#include "modules/editors.h" +#include "modules/gfx.h" +#include "modules/gui.h" +#include "modules/render.h" +#include "raster/image.h" +#include "raster/sprite.h" +#include "widgets/editor.h" +#include "widgets/statebar.h" + +#endif + +#define PREVIEW_TILED 1 +#define PREVIEW_FIT_ON_SCREEN 2 + +static void preview_sprite(int flags); + +bool command_enabled_preview(const char *argument) +{ + return current_sprite != NULL; +} + +/* ======================== */ +/* preview_fit_to_screen */ +/* ======================== */ + +void command_execute_preview_fit_to_screen(const char *argument) +{ + preview_sprite(PREVIEW_FIT_ON_SCREEN); +} + +/* ======================== */ +/* preview_normal */ +/* ======================== */ + +void command_execute_preview_normal(const char *argument) +{ + preview_sprite(0); +} + +/* ======================== */ +/* preview_tiled */ +/* ======================== */ + +void command_execute_preview_tiled(const char *argument) +{ + preview_sprite(PREVIEW_TILED); +} + +/** + * Shows the sprite using the complete screen. + */ +static void preview_sprite(int flags) +{ + JWidget widget = current_editor; + + if (widget && editor_get_sprite(widget)) { + Editor *editor = editor_data (widget); + Sprite *sprite = editor_get_sprite (widget); + JWidget view = jwidget_get_view (widget); + int old_mouse_x, old_mouse_y; + int scroll_x, scroll_y; + int u, v, x, y, w, h; + int shiftx, shifty; + Image *image; + BITMAP *bmp; + int redraw; + JRect vp; + int bg_color, index_bg_color = -1; + + jmanager_free_mouse(); + + vp = jview_get_viewport_position(view); + jview_get_scroll(view, &scroll_x, &scroll_y); + + old_mouse_x = jmouse_x(0); + old_mouse_y = jmouse_y(0); + + bmp = create_bitmap (sprite->w, sprite->h); + if (bmp) { + /* print a informative text */ + status_bar_set_text(app_get_status_bar(), 1, _("Rendering...")); + jwidget_flush_redraw(app_get_status_bar()); + jmanager_dispatch_messages(); + + jmouse_set_cursor(JI_CURSOR_NULL); + jmouse_set_position(JI_SCREEN_W/2, JI_SCREEN_H/2); + + /* render the sprite in the bitmap */ + image = render_sprite(sprite, 0, 0, sprite->w, sprite->h, + sprite->frpos, 0); + if (image) { + image_to_allegro(image, bmp, 0, 0); + image_free(image); + } + + if (!(flags & PREVIEW_TILED)) + bg_color = palette_color[index_bg_color=0]; + else + bg_color = makecol(128, 128, 128); + + shiftx = - scroll_x + vp->x1 + editor->offset_x; + shifty = - scroll_y + vp->y1 + editor->offset_y; + + w = sprite->w << editor->zoom; + h = sprite->h << editor->zoom; + + redraw = TRUE; + do { + /* update scroll */ + if (jmouse_poll()) { + shiftx += jmouse_x(0) - JI_SCREEN_W/2; + shifty += jmouse_y(0) - JI_SCREEN_H/2; + jmouse_set_position(JI_SCREEN_W/2, JI_SCREEN_H/2); + jmouse_poll(); + + redraw = TRUE; + } + + if (redraw) { + redraw = FALSE; + + /* fit on screen */ + if (flags & PREVIEW_FIT_ON_SCREEN) { + double sx, sy, scale, outw, outh; + + sx = (double)JI_SCREEN_W / (double)bmp->w; + sy = (double)JI_SCREEN_H / (double)bmp->h; + scale = MIN (sx, sy); + + outw = (double)bmp->w * (double)scale; + outh = (double)bmp->h * (double)scale; + + stretch_blit(bmp, ji_screen, 0, 0, bmp->w, bmp->h, 0, 0, outw, outh); + rectfill_exclude(ji_screen, 0, 0, JI_SCREEN_W-1, JI_SCREEN_H-1, + 0, 0, outw-1, outh-1, bg_color); + } + /* draw in normal size */ + else { + if (!(flags & PREVIEW_TILED)) { + x = shiftx; + y = shifty; + } + else { + x = SGN(shiftx) * (ABS(shiftx)%w); + y = SGN(shifty) * (ABS(shifty)%h); + } + + if (!(flags & PREVIEW_TILED)) { +/* rectfill_exclude(ji_screen, 0, 0, JI_SCREEN_W-1, JI_SCREEN_H-1, */ +/* x, y, x+w-1, y+h-1, bg_color); */ + clear_to_color(ji_screen, bg_color); + } + + if (!editor->zoom) { + /* in the center */ + if (!(flags & PREVIEW_TILED)) + draw_sprite(ji_screen, bmp, x, y); + /* tiled */ + else + for (v=y-h; vw, bmp->h, x, y, w, h); + /* tiled */ + else + for (v=y-h; vw, bmp->h, u, v, w, h); + } + } + } + + gui_feedback(); + + if (keypressed()) { + int c = readkey()>>8; + + /* change frame */ + if (editor_keys_toset_frpos(widget, c)) { + /* redraw */ + redraw = TRUE; + + /* render the sprite in the bitmap */ + image = render_sprite(sprite, 0, 0, sprite->w, sprite->h, + sprite->frpos, 0); + if (image) { + image_to_allegro(image, bmp, 0, 0); + image_free(image); + } + } + /* change background color */ + else if (c == KEY_PLUS_PAD) { + if (index_bg_color < 255) { + bg_color = palette_color[++index_bg_color]; + redraw = TRUE; + } + } + else if (c == KEY_MINUS_PAD) { + if (index_bg_color > 0) { + bg_color = palette_color[--index_bg_color]; + redraw = TRUE; + } + } + else + break; + } + } while (!jmouse_b(0)); + + destroy_bitmap(bmp); + } + + do { + jmouse_poll(); + gui_feedback(); + } while (jmouse_b(0)); + clear_keybuf(); + + jmouse_set_position(old_mouse_x, old_mouse_y); + jmouse_set_cursor(JI_CURSOR_NORMAL); + + jmanager_refresh_screen(); + jrect_free(vp); + } +} diff --git a/src/commands/cmd_preview_fit_to_screen.c b/src/commands/cmd_preview_fit_to_screen.c deleted file mode 100644 index 2eaa3e466..000000000 --- a/src/commands/cmd_preview_fit_to_screen.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ase -- allegro-sprite-editor: the ultimate sprites factory - * Copyright (C) 2007 David A. Capello - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config.h" - -#ifndef USE_PRECOMPILED_HEADER - -#include "dialogs/viewspr.h" -#include "modules/sprites.h" - -#endif - -bool command_enabled_preview_fit_to_screen(const char *argument) -{ - return current_sprite != NULL; -} - -void command_execute_preview_fit_to_screen(const char *argument) -{ - preview_sprite(PREVIEW_FIT_ON_SCREEN); -} diff --git a/src/commands/cmd_preview_normal.c b/src/commands/cmd_preview_normal.c deleted file mode 100644 index 5ed466cd2..000000000 --- a/src/commands/cmd_preview_normal.c +++ /dev/null @@ -1,46 +0,0 @@ -/* ase -- allegro-sprite-editor: the ultimate sprites factory - * Copyright (C) 2007 David A. Capello - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config.h" - -#ifndef USE_PRECOMPILED_HEADER - -#include "dialogs/viewspr.h" -#include "modules/sprites.h" - -#endif - -bool command_enabled_preview(const char *argument) -{ - return current_sprite != NULL; -} - -void command_execute_preview_fit_to_screen(const char *argument) -{ - preview_sprite(PREVIEW_FIT_ON_SCREEN); -} - -void command_execute_preview_normal(const char *argument) -{ - preview_sprite(0); -} - -void command_execute_preview_tiled(const char *argument) -{ - preview_sprite(PREVIEW_TILED); -} diff --git a/src/commands/cmd_preview_tiled.c b/src/commands/cmd_preview_tiled.c deleted file mode 100644 index ae5745603..000000000 --- a/src/commands/cmd_preview_tiled.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ase -- allegro-sprite-editor: the ultimate sprites factory - * Copyright (C) 2007 David A. Capello - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config.h" - -#ifndef USE_PRECOMPILED_HEADER - -#include "dialogs/viewspr.h" -#include "modules/sprites.h" - -#endif - -bool command_enabled_preview_tiled(const char *argument) -{ - return current_sprite != NULL; -} - -void command_execute_preview_tiled(const char *argument) -{ - preview_sprite(PREVIEW_TILED); -} diff --git a/src/commands/cmd_rectangle_tool.c b/src/commands/cmd_rectangle_tool.c deleted file mode 100644 index c105171f1..000000000 --- a/src/commands/cmd_rectangle_tool.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ase -- allegro-sprite-editor: the ultimate sprites factory - * Copyright (C) 2007 David A. Capello - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config.h" - -#ifndef USE_PRECOMPILED_HEADER - -#include "jinete.h" - -#include "core/app.h" -#include "modules/sprites.h" -#include "raster/sprite.h" - -#endif - -void command_execute_rectangle_tool(const char *argument) -{ -} diff --git a/src/commands/cmd_select_file.c b/src/commands/cmd_select_file.c index d5d232ceb..76c11b81b 100644 --- a/src/commands/cmd_select_file.c +++ b/src/commands/cmd_select_file.c @@ -20,6 +20,9 @@ #ifndef USE_PRECOMPILED_HEADER +#include +#include + #include "jinete.h" #include "core/app.h" @@ -28,6 +31,41 @@ #endif +bool command_enabled_select_file(const char *argument) +{ + if (argument) { + int sprite_id = ustrtol(argument, NULL, 10); + GfxObj *gfxobj = gfxobj_find(sprite_id); + return + gfxobj && gfxobj->type == GFXOBJ_SPRITE; + } + else + return TRUE; +} + +bool command_selected_select_file(const char *argument) +{ + if (argument) { + int sprite_id = ustrtol(argument, NULL, 10); + GfxObj *gfxobj = gfxobj_find(sprite_id); + return + gfxobj && gfxobj->type == GFXOBJ_SPRITE && + current_sprite == (Sprite *)gfxobj; + } + else + return current_sprite == NULL; +} + void command_execute_select_file(const char *argument) { + if (argument) { + int sprite_id = ustrtol(argument, NULL, 10); + GfxObj *gfxobj = gfxobj_find(sprite_id); + ASSERT(gfxobj != NULL); + + sprite_show((Sprite *)gfxobj); + } + else { + sprite_show(NULL); + } } diff --git a/src/commands/cmd_split_editor_horizontally.c b/src/commands/cmd_split_editor_horizontally.c index 61d9815c7..8c0c8975c 100644 --- a/src/commands/cmd_split_editor_horizontally.c +++ b/src/commands/cmd_split_editor_horizontally.c @@ -30,4 +30,9 @@ void command_execute_split_editor_horizontally(const char *argument) { + "Make &Unique" = always "make_unique_editor(current_editor)" ; + ---- + "Split &Vertically" = always "split_editor(current_editor, JI_VERTICAL)" ; + "Split &Horizontally" = always "split_editor(current_editor, JI_HORIZONTAL)" ; + ---- } diff --git a/src/commands/cmd_spray_tool.c b/src/commands/cmd_spray_tool.c deleted file mode 100644 index 7cbb0b15d..000000000 --- a/src/commands/cmd_spray_tool.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ase -- allegro-sprite-editor: the ultimate sprites factory - * Copyright (C) 2007 David A. Capello - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config.h" - -#ifndef USE_PRECOMPILED_HEADER - -#include "jinete.h" - -#include "core/app.h" -#include "modules/sprites.h" -#include "raster/sprite.h" - -#endif - -void command_execute_spray_tool(const char *argument) -{ -} diff --git a/src/commands/cmd_split_editor_vertically.c b/src/commands/cmd_sprite_editor.c similarity index 68% rename from src/commands/cmd_split_editor_vertically.c rename to src/commands/cmd_sprite_editor.c index 7d6182ae5..148bbef31 100644 --- a/src/commands/cmd_split_editor_vertically.c +++ b/src/commands/cmd_sprite_editor.c @@ -20,14 +20,26 @@ #ifndef USE_PRECOMPILED_HEADER -#include "jinete.h" - -#include "core/app.h" -#include "modules/sprites.h" -#include "raster/sprite.h" +#include "modules/editors.h" #endif +void command_execute_close_editor(const char *argument) +{ + close_editor(current_editor); +} + +void command_execute_make_unique_editor(const char *argument) +{ + make_unique_editor(current_editor); +} + +void command_execute_split_editor_horizontally(const char *argument) +{ + split_editor(current_editor, JI_HORIZONTAL); +} + void command_execute_split_editor_vertically(const char *argument) { + split_editor(current_editor, JI_VERTICAL); } diff --git a/src/commands/commands.c b/src/commands/commands.c index a1108776f..afb191032 100644 --- a/src/commands/commands.c +++ b/src/commands/commands.c @@ -32,8 +32,8 @@ #define CMD0(name) { #name, NULL, NULL, command_execute_##name, NULL } #define CMD1(name) { #name, command_enabled_##name, NULL, command_execute_##name, NULL } -/* #define CMD2(name) { #name, NULL, NULL, NULL, NULL } */ -/* #define CMD3(name) { #name, NULL, NULL, NULL, NULL } */ +#define CMD2(name,name2) { #name, command_enabled_##name2, NULL, command_execute_##name, NULL } +#define CMD3(name) { #name, command_enabled_##name, command_selected_##name, command_execute_##name, NULL } /* #define CMD4(name) { #name, NULL, NULL, NULL, NULL } */ void command_execute_about(const char *argument); @@ -42,6 +42,7 @@ void command_execute_auto_crop_sprite(const char *argument); void command_execute_brush_tool(const char *argument); void command_execute_change_image_type(const char *argument); void command_execute_clear(const char *argument); +bool command_enabled_close_all_files(const char *argument); void command_execute_close_all_files(const char *argument); void command_execute_close_editor(const char *argument); bool command_enabled_close_file(const char *argument); @@ -97,11 +98,9 @@ void command_execute_palette_editor(const char *argument); void command_execute_paste(const char *argument); void command_execute_pencil_tool(const char *argument); void command_execute_play_flic(const char *argument); -bool command_enabled_preview_fit_to_screen(const char *argument); +bool command_enabled_preview(const char *argument); void command_execute_preview_fit_to_screen(const char *argument); -bool command_enabled_preview_normal(const char *argument); void command_execute_preview_normal(const char *argument); -bool command_enabled_preview_tiled(const char *argument); void command_execute_preview_tiled(const char *argument); void command_execute_quick_copy(const char *argument); void command_execute_quick_move(const char *argument); @@ -119,6 +118,8 @@ void command_execute_save_file_as(const char *argument); void command_execute_save_mask(const char *argument); void command_execute_save_session(const char *argument); void command_execute_screen_shot(const char *argument); +bool command_enabled_select_file(const char *argument); +bool command_selected_select_file(const char *argument); void command_execute_select_file(const char *argument); void command_execute_split_editor_horizontally(const char *argument); void command_execute_split_editor_vertically(const char *argument); @@ -133,7 +134,7 @@ static Command commands[] = { { CMD_SAVE_FILE, NULL, NULL, NULL, NULL }, { CMD_SAVE_FILE_AS, NULL, NULL, NULL, NULL }, CMD1(close_file), - { CMD_CLOSE_ALL_FILES, NULL, NULL, NULL, NULL }, + CMD1(close_all_files), { CMD_SCREEN_SHOT, NULL, NULL, NULL, NULL }, { CMD_RECORD_SCREEN, NULL, NULL, NULL, NULL }, { CMD_LOAD_SESSION, NULL, NULL, NULL, NULL }, @@ -155,13 +156,13 @@ static Command commands[] = { { CMD_REFRESH, NULL, NULL, NULL, NULL }, { CMD_CONFIGURE_SCREEN, NULL, NULL, NULL, NULL }, CMD0(advanced_mode), - { CMD_MAKE_UNIQUE_EDITOR, NULL, NULL, NULL, NULL }, - { CMD_SPLIT_EDITOR_VERTICALLY, NULL, NULL, NULL, NULL }, - { CMD_SPLIT_EDITOR_HORIZONTALLY, NULL, NULL, NULL, NULL }, - { CMD_CLOSE_EDITOR, NULL, NULL, NULL, NULL }, - CMD1(preview_tiled), - CMD1(preview_normal), - CMD1(preview_fit_to_screen), + CMD0(make_unique_editor), + CMD0(split_editor_vertically), + CMD0(split_editor_horizontally), + CMD0(close_editor), + CMD2(preview_tiled,preview), + CMD2(preview_normal,preview), + CMD2(preview_fit_to_screen,preview), { CMD_SPRITE_PROPERTIES, NULL, NULL, NULL, NULL }, { CMD_DUPLICATE_SPRITE, NULL, NULL, NULL, NULL }, { CMD_CHANGE_IMAGE_TYPE, NULL, NULL, NULL, NULL }, @@ -212,6 +213,7 @@ static Command commands[] = { CMD0(tips), { CMD_CUSTOMIZE, NULL, NULL, NULL, NULL }, { CMD_OPTIONS, NULL, NULL, NULL, NULL }, + CMD3(select_file), { NULL, NULL, NULL, NULL, NULL } }; @@ -288,3 +290,15 @@ void command_add_key(Command *command, const char *string) usprintf(buf, "<%s>", string); jaccel_add_keys_from_string(command->accel, buf); } + +void command_reset_keys() +{ + Command *cmd; + + for (cmd=commands; cmd->name; cmd++) { + if (cmd->accel) { + jaccel_free(cmd->accel); + cmd->accel = NULL; + } + } +} diff --git a/src/commands/commands.h b/src/commands/commands.h index fed4b770b..71643b042 100644 --- a/src/commands/commands.h +++ b/src/commands/commands.h @@ -127,5 +127,6 @@ void command_execute(Command *command, const char *argument); bool command_is_key_pressed(Command *command, JMessage msg); void command_add_key(Command *command, const char *string); +void command_reset_keys(); #endif /* COMMANDS_COMMANDS_H */ diff --git a/src/core/app.c b/src/core/app.c index 55f766135..a5e21afc8 100644 --- a/src/core/app.c +++ b/src/core/app.c @@ -217,12 +217,6 @@ void app_loop(void) jwidget_add_child(box_tool_bar, tool_bar); jwidget_add_child(box_status_bar, status_bar); - /* layout */ - if (!get_config_bool("Layout", "MenuBar", TRUE)) jwidget_hide(menu_bar); - if (!get_config_bool("Layout", "StatusBar", TRUE)) jwidget_hide(status_bar); - if (!get_config_bool("Layout", "ColorBar", TRUE)) jwidget_hide(color_bar); - if (!get_config_bool("Layout", "ToolBar", TRUE)) jwidget_hide(tool_bar); - /* prepare the window */ jwindow_remap(top_window); @@ -318,12 +312,6 @@ void app_loop(void) if (is_rec_screen()) rec_screen_off(); - /* save layout */ - set_config_bool("Layout", "MenuBar", !(menu_bar->flags & JI_HIDDEN)); - set_config_bool("Layout", "StatusBar", !(status_bar->flags & JI_HIDDEN)); - set_config_bool("Layout", "ColorBar", !(color_bar->flags & JI_HIDDEN)); - set_config_bool("Layout", "ToolBar", !(tool_bar->flags & JI_HIDDEN)); - /* remove the root-menu from the menu-bar (because the rootmenu module should destroy it) */ jmenubar_set_menu(menu_bar, NULL); @@ -417,7 +405,7 @@ void app_realloc_sprite_list(void) usprintf(buf, "%d", clipboard->gfxobj.id); menuitem = menuitem_new(_("Clipboard"), cmd_select_file, - clipboard ? buf: NULL); + clipboard ? buf: "0"); /* if (!clipboard) */ /* jwidget_disable(menuitem); */ @@ -532,25 +520,6 @@ JWidget app_get_status_bar(void) { return status_bar; } JWidget app_get_color_bar(void) { return color_bar; } JWidget app_get_tool_bar(void) { return tool_bar; } -void app_switch(JWidget widget) -{ - JWidget parent = jwidget_get_parent(widget); - - if (jwidget_is_visible(widget)) { - jwidget_hide(widget); - if (parent) - jwidget_hide(parent); - } - else { - jwidget_show(widget); - if (parent) - jwidget_show(parent); - } - - jwindow_remap(top_window); - jwidget_dirty(top_window); -} - void app_default_status_bar_message(void) { status_bar_set_text(app_get_status_bar(), 250, diff --git a/src/core/app.h b/src/core/app.h index 47ebf007c..85df97fd4 100644 --- a/src/core/app.h +++ b/src/core/app.h @@ -38,8 +38,6 @@ JWidget app_get_status_bar(void); JWidget app_get_color_bar(void); JWidget app_get_tool_bar(void); -void app_switch(JWidget widget); - void app_default_status_bar_message(void); #endif /* CORE_APP_H */ diff --git a/src/core/cfg.c b/src/core/cfg.c index 1f6eae8f3..269d0060c 100644 --- a/src/core/cfg.c +++ b/src/core/cfg.c @@ -1,5 +1,5 @@ /* ase -- allegro-sprite-editor: the ultimate sprites factory - * Copyright (C) 2001-2005 David A. Capello + * Copyright (C) 2001-2005, 2007 David A. Capello * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -66,13 +66,16 @@ void ase_config_exit(void) bool get_config_bool(const char *section, const char *name, bool value) { - return (ustrcmp(get_config_string(section, name, value ? "TRUE": "FALSE"), - "TRUE") == 0) ? TRUE: FALSE; + const char *got = get_config_string(section, name, value ? "yes": "no"); + return (got && + (ustricmp(got, "yes") == 0 || + ustricmp(got, "true") == 0 || + ustricmp(got, "1") == 0)) ? TRUE: FALSE; } void set_config_bool(const char *section, const char *name, bool value) { - set_config_string(section, name, value ? "TRUE": "FALSE"); + set_config_string(section, name, value ? "yes": "no"); } void get_config_rect(const char *section, const char *name, JRect rect) diff --git a/src/core/modules.c b/src/core/modules.c index cb1acb51d..5ed7dbf68 100644 --- a/src/core/modules.c +++ b/src/core/modules.c @@ -23,7 +23,6 @@ #include "core/core.h" #include "core/modules.h" #include "effect/effect.h" -#include "modules/chkmthds.h" #include "modules/color.h" #include "modules/editors.h" #include "modules/gfx.h" @@ -65,7 +64,6 @@ static Module module[] = DEF_MODULE(render, REQUIRE_INTERFACE), DEF_MODULE(gui, REQUIRE_INTERFACE), DEF_MODULE(recent, REQUIRE_INTERFACE), - DEF_MODULE(check_methods, REQUIRE_INTERFACE), DEF_MODULE(rootmenu, REQUIRE_INTERFACE), DEF_MODULE(editors, REQUIRE_INTERFACE), }; diff --git a/src/dialogs/options.c b/src/dialogs/options.c index da07fe617..76f5a3f6e 100644 --- a/src/dialogs/options.c +++ b/src/dialogs/options.c @@ -35,34 +35,34 @@ /* show the language selection dialog */ void dialogs_select_language(bool force) { - bool select_language = get_config_bool ("Options", "SelectLanguage", TRUE); + bool select_language = get_config_bool("Options", "SelectLanguage", TRUE); if (force || select_language) { - JWidget window = jwindow_new ("Select Language"); - JWidget box = jbox_new (JI_HORIZONTAL + JI_HOMOGENEOUS); - JWidget button_en = jbutton_new ("English"); - JWidget button_es = jbutton_new ("Español"); + JWidget window = jwindow_new("Select Language"); + JWidget box = jbox_new(JI_HORIZONTAL + JI_HOMOGENEOUS); + JWidget button_en = jbutton_new("English"); + JWidget button_es = jbutton_new("Español"); JWidget killer; - jwidget_add_child (window, box); - jwidget_add_child (box, button_en); - jwidget_add_child (box, button_es); + jwidget_add_child(window, box); + jwidget_add_child(box, button_en); + jwidget_add_child(box, button_es); - jwindow_open_fg (window); - killer = jwindow_get_killer (window); + jwindow_open_fg(window); + killer = jwindow_get_killer(window); /* en */ if (killer == button_en) { - intl_set_lang ("en"); - set_config_bool ("Options", "SelectLanguage", FALSE); + intl_set_lang("en"); + set_config_bool("Options", "SelectLanguage", FALSE); } /* es */ else if (killer == button_es) { - intl_set_lang ("es"); - set_config_bool ("Options", "SelectLanguage", FALSE); + intl_set_lang("es"); + set_config_bool("Options", "SelectLanguage", FALSE); } - jwidget_free (window); + jwidget_free(window); } } diff --git a/src/dialogs/viewspr.h b/src/dialogs/viewspr.h deleted file mode 100644 index 67ec91e42..000000000 --- a/src/dialogs/viewspr.h +++ /dev/null @@ -1,28 +0,0 @@ -/* ase -- allegro-sprite-editor: the ultimate sprites factory - * Copyright (C) 2001-2005, 2007 David A. Capello - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef DIALOGS_VIEWSPR_H -#define DIALOGS_VIEWSPR_H - -#define PREVIEW_TILED 1 -#define PREVIEW_FIT_ON_SCREEN 2 - -void preview_sprite(int flags); - -#endif /* DIALOGS_VIEWSPR_H */ - diff --git a/src/modules/chkmthds.c b/src/modules/chkmthds.c deleted file mode 100644 index 0ec195dee..000000000 --- a/src/modules/chkmthds.c +++ /dev/null @@ -1,344 +0,0 @@ -/* ase -- allegro-sprite-editor: the ultimate sprites factory - * Copyright (C) 2001-2005, 2007 David A. Capello - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config.h" - -#ifndef USE_PRECOMPILED_HEADER - -#include "jinete/widget.h" - -#include "core/app.h" -#include "dialogs/filmedit.h" -#include "modules/chkmthds.h" -#include "modules/sprites.h" -#include "modules/tools.h" -#include "raster/image.h" -#include "raster/layer.h" -#include "raster/mask.h" -#include "raster/sprite.h" -#include "raster/undo.h" -#include "util/hash.h" -#include "util/misc.h" -#include "util/recscr.h" - -#endif - -static HashTable *table; - -static bool method_always (JWidget menuitem); -static bool method_has_sprite (JWidget menuitem); -static bool method_has_layer (JWidget menuitem); -static bool method_has_layerimage (JWidget menuitem); -static bool method_has_image (JWidget menuitem); -static bool method_can_undo (JWidget menuitem); -static bool method_can_redo (JWidget menuitem); -static bool method_has_path (JWidget menuitem); -static bool method_has_mask (JWidget menuitem); -static bool method_has_imagemask (JWidget menuitem); -static bool method_has_clipboard (JWidget menuitem); -static bool method_menu_bar (JWidget menuitem); -static bool method_status_bar (JWidget menuitem); -static bool method_color_bar (JWidget menuitem); -static bool method_tool_bar (JWidget menuitem); -static bool method_tool_marker (JWidget menuitem); -static bool method_tool_dots (JWidget menuitem); -static bool method_tool_pencil (JWidget menuitem); -static bool method_tool_brush (JWidget menuitem); -static bool method_tool_floodfill (JWidget menuitem); -static bool method_tool_spray (JWidget menuitem); -static bool method_tool_line (JWidget menuitem); -static bool method_tool_rectangle (JWidget menuitem); -static bool method_tool_ellipse (JWidget menuitem); -static bool method_is_rec (JWidget menuitem); -static bool method_is_movingframe (JWidget menuitem); - -int init_module_check_methods (void) -{ - table = hash_new (16); - - hash_insert (table, "always", method_always); - hash_insert (table, "has_sprite", method_has_sprite); - hash_insert (table, "has_layer", method_has_layer); - hash_insert (table, "has_layerimage", method_has_layerimage); - hash_insert (table, "has_image", method_has_image); - hash_insert (table, "can_undo", method_can_undo); - hash_insert (table, "can_redo", method_can_redo); - hash_insert (table, "has_path", method_has_path); - hash_insert (table, "has_mask", method_has_mask); - hash_insert (table, "has_imagemask", method_has_imagemask); - hash_insert (table, "has_clipboard", method_has_clipboard); - - hash_insert (table, "menu_bar", method_menu_bar); - hash_insert (table, "status_bar", method_status_bar); - hash_insert (table, "color_bar", method_color_bar); - hash_insert (table, "tool_bar", method_tool_bar); - - hash_insert (table, "tool_marker", method_tool_marker); - hash_insert (table, "tool_dots", method_tool_dots); - hash_insert (table, "tool_pencil", method_tool_pencil); - hash_insert (table, "tool_brush", method_tool_brush); - hash_insert (table, "tool_floodfill", method_tool_floodfill); - hash_insert (table, "tool_spray", method_tool_spray); - hash_insert (table, "tool_line", method_tool_line); - hash_insert (table, "tool_rectangle", method_tool_rectangle); - hash_insert (table, "tool_ellipse", method_tool_ellipse); - - hash_insert (table, "is_rec", method_is_rec); - hash_insert (table, "is_movingframe", method_is_movingframe); - - return 0; -} - -void exit_module_check_methods(void) -{ - hash_free(table, NULL); -} - -CheckMethod get_check_method(const char *name) -{ - return (CheckMethod)hash_lookup(table, name); -} - -static bool method_always(JWidget menuitem) -{ - return TRUE; -} - -static bool method_has_sprite(JWidget menuitem) -{ - return (current_sprite) ? TRUE: FALSE; -} - -static bool method_has_layer(JWidget menuitem) -{ - return (current_sprite && - current_sprite->layer) ? TRUE: FALSE; -} - -static bool method_has_layerimage(JWidget menuitem) -{ - return (current_sprite && - current_sprite->layer && - layer_is_image(current_sprite->layer)); -} - -static bool method_has_image(JWidget menuitem) -{ - if ((!current_sprite) || - (!current_sprite->layer) || - (!current_sprite->layer->readable) || - (!current_sprite->layer->writeable)) - return FALSE; - else - return GetImage () ? TRUE: FALSE; -} - -static bool method_can_undo(JWidget menuitem) -{ - return current_sprite && undo_can_undo(current_sprite->undo); -} - -static bool method_can_redo(JWidget menuitem) -{ - return current_sprite && undo_can_redo(current_sprite->undo); -} - -static bool method_has_path(JWidget menuitem) -{ - if (!current_sprite) - return FALSE; - else - return (current_sprite->path) ? TRUE: FALSE; -} - -static bool method_has_mask(JWidget menuitem) -{ - if (!current_sprite) - return FALSE; - else - return (current_sprite->mask && - current_sprite->mask->bitmap) ? TRUE: FALSE; -} - -static bool method_has_imagemask(JWidget menuitem) -{ - if ((!current_sprite) || - (!current_sprite->layer) || - (!current_sprite->layer->readable) || - (!current_sprite->layer->writeable) || - (!current_sprite->mask) || - (!current_sprite->mask->bitmap)) - return FALSE; - else - return GetImage() ? TRUE: FALSE; -} - -static bool method_has_clipboard(JWidget menuitem) -{ - Sprite *sprite = current_sprite; - Sprite *clipboard = get_clipboard_sprite(); - - return (sprite && - clipboard && - (clipboard != sprite)); -} - -static bool method_menu_bar(JWidget menuitem) -{ - if (jwidget_is_visible(app_get_menu_bar())) - jwidget_select(menuitem); - else - jwidget_deselect(menuitem); - - return TRUE; -} - -static bool method_status_bar(JWidget menuitem) -{ - if (jwidget_is_visible(app_get_status_bar())) - jwidget_select(menuitem); - else - jwidget_deselect(menuitem); - - return TRUE; -} - -static bool method_color_bar(JWidget menuitem) -{ - if (jwidget_is_visible(app_get_color_bar())) - jwidget_select(menuitem); - else - jwidget_deselect(menuitem); - - return TRUE; -} - -static bool method_tool_bar(JWidget menuitem) -{ - if (jwidget_is_visible(app_get_tool_bar())) - jwidget_select(menuitem); - else - jwidget_deselect(menuitem); - - return TRUE; -} - -static bool method_tool_marker(JWidget menuitem) -{ - if (current_tool == &ase_tool_marker) - jwidget_select(menuitem); - else - jwidget_deselect(menuitem); - - return TRUE; -} - -static bool method_tool_dots(JWidget menuitem) -{ - if (current_tool == &ase_tool_dots) - jwidget_select(menuitem); - else - jwidget_deselect(menuitem); - - return TRUE; -} - -static bool method_tool_pencil(JWidget menuitem) -{ - if (current_tool == &ase_tool_pencil) - jwidget_select(menuitem); - else - jwidget_deselect(menuitem); - - return TRUE; -} - -static bool method_tool_brush(JWidget menuitem) -{ - if (current_tool == &ase_tool_brush) - jwidget_select(menuitem); - else - jwidget_deselect(menuitem); - - return TRUE; -} - -static bool method_tool_floodfill (JWidget menuitem) -{ - if (current_tool == &ase_tool_floodfill) - jwidget_select (menuitem); - else - jwidget_deselect (menuitem); - - return TRUE; -} - -static bool method_tool_spray (JWidget menuitem) -{ - if (current_tool == &ase_tool_spray) - jwidget_select (menuitem); - else - jwidget_deselect (menuitem); - - return TRUE; -} - -static bool method_tool_line (JWidget menuitem) -{ - if (current_tool == &ase_tool_line) - jwidget_select (menuitem); - else - jwidget_deselect (menuitem); - - return TRUE; -} - -static bool method_tool_rectangle (JWidget menuitem) -{ - if (current_tool == &ase_tool_rectangle) - jwidget_select (menuitem); - else - jwidget_deselect (menuitem); - - return TRUE; -} - -static bool method_tool_ellipse(JWidget menuitem) -{ - if (current_tool == &ase_tool_ellipse) - jwidget_select(menuitem); - else - jwidget_deselect(menuitem); - - return TRUE; -} - -static bool method_is_rec(JWidget menuitem) -{ - if (is_rec_screen()) - jwidget_select(menuitem); - else - jwidget_deselect(menuitem); - - return TRUE; -} - -static bool method_is_movingframe(JWidget menuitem) -{ - return is_movingframe (); -} diff --git a/src/modules/chkmthds.h b/src/modules/chkmthds.h deleted file mode 100644 index d8785954c..000000000 --- a/src/modules/chkmthds.h +++ /dev/null @@ -1,31 +0,0 @@ -/* ase -- allegro-sprite-editor: the ultimate sprites factory - * Copyright (C) 2001-2005 David A. Capello - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef MODULES_CHKMTHDS_H -#define MODULES_CHKMTHDS_H - -#include "jinete/base.h" - -typedef bool (*CheckMethod) (JWidget menuitem); - -int init_module_check_methods (void); -void exit_module_check_methods (void); - -CheckMethod get_check_method (const char *name); - -#endif /* MODULES_CHKMTHDS_H */ diff --git a/src/modules/rootmenu.c b/src/modules/rootmenu.c index 12fac0d66..5e54a582b 100644 --- a/src/modules/rootmenu.c +++ b/src/modules/rootmenu.c @@ -31,7 +31,6 @@ #include "core/core.h" #include "core/dirs.h" #include "intl/intl.h" -#include "modules/chkmthds.h" #include "modules/rootmenu.h" #include "util/filetoks.h" #include "widgets/menuitem.h" @@ -45,7 +44,6 @@ static JWidget recent_list_menuitem; static JWidget layer_popup_menuitem; static JWidget frame_popup_menuitem; static JWidget filters_popup_menuitem; -/* static JWidget accel_menuitem[ACCEL_MAX]; */ static JWidget convert_xmlelem_to_menu(JXmlElem elem); static JWidget convert_xmlelem_to_menuitem(JXmlElem elem); @@ -66,6 +64,7 @@ void exit_module_rootmenu(void) frame_popup_menuitem = 0; filters_popup_menuitem = 0; + command_reset_keys(); jwidget_free(root_menu); } @@ -80,8 +79,10 @@ int load_root_menu(void) jmenubar_set_menu(app_get_menu_bar(), NULL); /* destroy `root-menu' if it exists */ - if (root_menu) + if (root_menu) { + command_reset_keys(); jwidget_free(root_menu); + } /* create a new empty-menu */ root_menu = NULL; @@ -209,19 +210,6 @@ JWidget get_recent_list_menuitem(void) { return recent_list_menuitem; } JWidget get_layer_popup_menuitem(void) { return layer_popup_menuitem; } JWidget get_frame_popup_menuitem(void) { return frame_popup_menuitem; } -/* int check_for_accel(int accel_type, JMessage msg) */ -/* { */ -/* if (accel_menuitem[accel_type]) { */ -/* JAccel accel = jmenuitem_get_accel(accel_menuitem[accel_type]); */ -/* if (accel) */ -/* return jaccel_check(accel, */ -/* msg->any.shifts, */ -/* msg->key.ascii, */ -/* msg->key.scancode); */ -/* } */ -/* return FALSE; */ -/* } */ - void show_fx_popup_menu(void) { if (is_interactive() && @@ -328,7 +316,7 @@ static void apply_shortcut_to_menuitems_with_command(JWidget menu, Command *comm if (jwidget_get_type(menuitem) == JI_MENUITEM) { if (menuitem_get_command(menuitem) == command) { - jmenuitem_set_accel(menuitem, command->accel); + jmenuitem_set_accel(menuitem, jaccel_new_copy(command->accel)); } submenu = jmenuitem_get_submenu(menuitem); diff --git a/src/raster/gfxobj.h b/src/raster/gfxobj.h index ad56f0cc3..a152cc429 100644 --- a/src/raster/gfxobj.h +++ b/src/raster/gfxobj.h @@ -1,5 +1,5 @@ /* ase -- allegro-sprite-editor: the ultimate sprites factory - * Copyright (C) 2001-2005 David A. Capello + * Copyright (C) 2001-2005, 2007 David A. Capello * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,9 +37,9 @@ enum { /* struct GfxObjProperty; */ -typedef struct GfxObj GfxObj; - -struct GfxObj +typedef struct GfxObj GfxObj; + +struct GfxObj { int type; unsigned int id; diff --git a/src/raster/undo.c b/src/raster/undo.c index adaf0bb01..8b32ba2fb 100644 --- a/src/raster/undo.c +++ b/src/raster/undo.c @@ -1,5 +1,5 @@ /* ase -- allegro-sprite-editor: the ultimate sprites factory - * Copyright (C) 2001-2005 David A. Capello + * Copyright (C) 2001-2005, 2007 David A. Capello * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -97,59 +97,59 @@ typedef struct UndoAction void (*redo) (UndoStream *stream, UndoChunk *chunk, int state); } UndoAction; -static void run_undo (Undo *undo, int state, int discard); -static int count_undo_groups (UndoStream *undo_stream); -static void update_undo (Undo *undo); +static void run_undo(Undo *undo, int state, int discard); +static int count_undo_groups(UndoStream *undo_stream); +static void update_undo(Undo *undo); /* Undo actions */ -static void chunk_open (UndoStream *stream); -static void redo_open (UndoStream *stream, UndoChunk *chunk, int state); +static void chunk_open(UndoStream *stream); +static void redo_open(UndoStream *stream, UndoChunk *chunk, int state); -static void chunk_close (UndoStream *stream); -static void redo_close (UndoStream *stream, UndoChunk *chunk, int state); +static void chunk_close(UndoStream *stream); +static void redo_close(UndoStream *stream, UndoChunk *chunk, int state); -static void chunk_data (UndoStream *stream, GfxObj *gfxobj, void *data, int size); -static void redo_data (UndoStream *stream, UndoChunk *chunk, int state); +static void chunk_data(UndoStream *stream, GfxObj *gfxobj, void *data, int size); +static void redo_data(UndoStream *stream, UndoChunk *chunk, int state); -static void chunk_image (UndoStream *stream, Image *image, int x, int y, int w, int h); -static void redo_image (UndoStream *stream, UndoChunk *chunk, int state); +static void chunk_image(UndoStream *stream, Image *image, int x, int y, int w, int h); +static void redo_image(UndoStream *stream, UndoChunk *chunk, int state); -static void chunk_flip (UndoStream *stream, Image *image, int x1, int y1, int x2, int y2, int horz); -static void redo_flip (UndoStream *stream, UndoChunk *chunk, int state); +static void chunk_flip(UndoStream *stream, Image *image, int x1, int y1, int x2, int y2, int horz); +static void redo_flip(UndoStream *stream, UndoChunk *chunk, int state); -static void chunk_dirty (UndoStream *stream, Dirty *dirty); -static void redo_dirty (UndoStream *stream, UndoChunk *chunk, int state); +static void chunk_dirty(UndoStream *stream, Dirty *dirty); +static void redo_dirty(UndoStream *stream, UndoChunk *chunk, int state); -static void chunk_add_image (UndoStream *stream, Stock *stock, Image *image); -static void redo_add_image (UndoStream *stream, UndoChunk *chunk, int state); +static void chunk_add_image(UndoStream *stream, Stock *stock, Image *image); +static void redo_add_image(UndoStream *stream, UndoChunk *chunk, int state); -static void chunk_remove_image (UndoStream *stream, Stock *stock, Image *image); -static void redo_remove_image (UndoStream *stream, UndoChunk *chunk, int state); +static void chunk_remove_image(UndoStream *stream, Stock *stock, Image *image); +static void redo_remove_image(UndoStream *stream, UndoChunk *chunk, int state); -static void chunk_replace_image (UndoStream *stream, Stock *stock, int index); -static void redo_replace_image (UndoStream *stream, UndoChunk *chunk, int state); +static void chunk_replace_image(UndoStream *stream, Stock *stock, int index); +static void redo_replace_image(UndoStream *stream, UndoChunk *chunk, int state); -static void chunk_add_frame (UndoStream *stream, Layer *layer, Frame *frame); -static void redo_add_frame (UndoStream *stream, UndoChunk *chunk, int state); +static void chunk_add_frame(UndoStream *stream, Layer *layer, Frame *frame); +static void redo_add_frame(UndoStream *stream, UndoChunk *chunk, int state); -static void chunk_remove_frame (UndoStream *stream, Layer *layer, Frame *frame); -static void redo_remove_frame (UndoStream *stream, UndoChunk *chunk, int state); +static void chunk_remove_frame(UndoStream *stream, Layer *layer, Frame *frame); +static void redo_remove_frame(UndoStream *stream, UndoChunk *chunk, int state); -static void chunk_add_layer (UndoStream *stream, Layer *set, Layer *layer); -static void redo_add_layer (UndoStream *stream, UndoChunk *chunk, int state); +static void chunk_add_layer(UndoStream *stream, Layer *set, Layer *layer); +static void redo_add_layer(UndoStream *stream, UndoChunk *chunk, int state); -static void chunk_remove_layer (UndoStream *stream, Layer *layer); -static void redo_remove_layer (UndoStream *stream, UndoChunk *chunk, int state); +static void chunk_remove_layer(UndoStream *stream, Layer *layer); +static void redo_remove_layer(UndoStream *stream, UndoChunk *chunk, int state); -static void chunk_move_layer (UndoStream *stream, Layer *layer); -static void redo_move_layer (UndoStream *stream, UndoChunk *chunk, int state); +static void chunk_move_layer(UndoStream *stream, Layer *layer); +static void redo_move_layer(UndoStream *stream, UndoChunk *chunk, int state); -static void chunk_set_layer (UndoStream *stream, Sprite *sprite); -static void redo_set_layer (UndoStream *stream, UndoChunk *chunk, int state); +static void chunk_set_layer(UndoStream *stream, Sprite *sprite); +static void redo_set_layer(UndoStream *stream, UndoChunk *chunk, int state); -static void chunk_set_mask (UndoStream *stream, Sprite *sprite); -static void redo_set_mask (UndoStream *stream, UndoChunk *chunk, int state); +static void chunk_set_mask(UndoStream *stream, Sprite *sprite); +static void redo_set_mask(UndoStream *stream, UndoChunk *chunk, int state); static UndoAction undo_actions[] = { /* in UNDO_TYPEs order */ { "Open", redo_open }, @@ -172,55 +172,55 @@ static UndoAction undo_actions[] = { /* in UNDO_TYPEs order */ /* UndoChunk */ -static UndoChunk *undo_chunk_new (int type); -static void undo_chunk_free (UndoChunk *chunk); +static UndoChunk *undo_chunk_new(int type); +static void undo_chunk_free(UndoChunk *chunk); -static int undo_chunk_get8 (UndoChunk *chunk); -static void undo_chunk_put8 (UndoChunk *chunk, int c); +static int undo_chunk_get8(UndoChunk *chunk); +static void undo_chunk_put8(UndoChunk *chunk, int c); -static int undo_chunk_get16 (UndoChunk *chunk); -static void undo_chunk_put16 (UndoChunk *chunk, int c); +static int undo_chunk_get16(UndoChunk *chunk); +static void undo_chunk_put16(UndoChunk *chunk, int c); -static long undo_chunk_get32 (UndoChunk *chunk); -static void undo_chunk_put32 (UndoChunk *chunk, long c); +static long undo_chunk_get32(UndoChunk *chunk); +static void undo_chunk_put32(UndoChunk *chunk, long c); -/* static double undo_chunk_get64 (UndoChunk *chunk); */ -/* static void undo_chunk_put64 (UndoChunk *chunk, double c); */ +/* static double undo_chunk_get64(UndoChunk *chunk); */ +/* static void undo_chunk_put64(UndoChunk *chunk, double c); */ -static int undo_chunk_read (UndoChunk *chunk, unsigned char *buf, int size); -static void undo_chunk_write (UndoChunk *chunk, const unsigned char *buf, int size); +static int undo_chunk_read(UndoChunk *chunk, unsigned char *buf, int size); +static void undo_chunk_write(UndoChunk *chunk, const unsigned char *buf, int size); -static char *undo_chunk_read_string (UndoChunk *chunk); -static void undo_chunk_write_string (UndoChunk *chunk, const char *string); +static char *undo_chunk_read_string(UndoChunk *chunk); +static void undo_chunk_write_string(UndoChunk *chunk, const char *string); -static Frame *undo_chunk_read_frame (UndoChunk *chunk); -static void undo_chunk_write_frame (UndoChunk *chunk, Frame *frame); +static Frame *undo_chunk_read_frame(UndoChunk *chunk); +static void undo_chunk_write_frame(UndoChunk *chunk, Frame *frame); -static Layer *undo_chunk_read_layer (UndoChunk *chunk); -static void undo_chunk_write_layer (UndoChunk *chunk, Layer *layer); +static Layer *undo_chunk_read_layer(UndoChunk *chunk); +static void undo_chunk_write_layer(UndoChunk *chunk, Layer *layer); -static Image *undo_chunk_read_image (UndoChunk *chunk); -static void undo_chunk_write_image (UndoChunk *chunk, Image *image); +static Image *undo_chunk_read_image(UndoChunk *chunk); +static void undo_chunk_write_image(UndoChunk *chunk, Image *image); -static Stock *undo_chunk_read_stock (UndoChunk *chunk); -static void undo_chunk_write_stock (UndoChunk *chunk, Stock *stock); +static Stock *undo_chunk_read_stock(UndoChunk *chunk); +static void undo_chunk_write_stock(UndoChunk *chunk, Stock *stock); -static Mask *undo_chunk_read_mask (UndoChunk *chunk); -static void undo_chunk_write_mask (UndoChunk *chunk, Mask *mask); +static Mask *undo_chunk_read_mask(UndoChunk *chunk); +static void undo_chunk_write_mask(UndoChunk *chunk, Mask *mask); /* UndoStream */ -static UndoStream *undo_stream_new (void); -static void undo_stream_free (UndoStream *stream); +static UndoStream *undo_stream_new(void); +static void undo_stream_free(UndoStream *stream); -static UndoChunk *undo_stream_pop_chunk (UndoStream *stream, int tail); -static void undo_stream_push_chunk (UndoStream *stream, UndoChunk *chunk); +static UndoChunk *undo_stream_pop_chunk(UndoStream *stream, int tail); +static void undo_stream_push_chunk(UndoStream *stream, UndoChunk *chunk); -/* static long undo_stream_raw_read_dword (UndoStream *stream); */ -/* static void undo_stream_raw_write_dword (UndoStream *stream, long dword); */ +/* static long undo_stream_raw_read_dword(UndoStream *stream); */ +/* static void undo_stream_raw_write_dword(UndoStream *stream, long dword); */ -/* static int undo_stream_raw_read (UndoStream *stream, unsigned char *buf, int size); */ -/* static void undo_stream_raw_write (UndoStream *stream, unsigned char *buf, int size); */ +/* static int undo_stream_raw_read(UndoStream *stream, unsigned char *buf, int size); */ +/* static void undo_stream_raw_write(UndoStream *stream, unsigned char *buf, int size); */ /* General undo routines */ @@ -241,15 +241,15 @@ Undo *undo_new(Sprite *sprite) return undo; } -void undo_free (Undo *undo) +void undo_free(Undo *undo) { - undo_stream_free (undo->undo_stream); - undo_stream_free (undo->redo_stream); + undo_stream_free(undo->undo_stream); + undo_stream_free(undo->redo_stream); - jfree (undo); + jfree(undo); } -void undo_enable (Undo *undo) +void undo_enable(Undo *undo) { undo->enabled = TRUE; } @@ -274,22 +274,22 @@ bool undo_can_undo(Undo *undo) return !jlist_empty(undo->undo_stream->chunks); } -bool undo_can_redo (Undo *undo) +bool undo_can_redo(Undo *undo) { return !jlist_empty(undo->redo_stream->chunks); } -void undo_undo (Undo *undo) +void undo_undo(Undo *undo) { - run_undo (undo, DO_UNDO, FALSE); + run_undo(undo, DO_UNDO, FALSE); } -void undo_redo (Undo *undo) +void undo_redo(Undo *undo) { - run_undo (undo, DO_REDO, FALSE); + run_undo(undo, DO_REDO, FALSE); } -static void run_undo (Undo *undo, int state, int discard_tail) +static void run_undo(Undo *undo, int state, int discard_tail) { UndoStream *undo_stream = ((state == DO_UNDO)? undo->undo_stream: undo->redo_stream); @@ -300,7 +300,7 @@ static void run_undo (Undo *undo, int state, int discard_tail) if (!discard_tail) { do { - chunk = undo_stream_pop_chunk (undo_stream, FALSE); /* read from head */ + chunk = undo_stream_pop_chunk(undo_stream, FALSE); /* read from head */ if (!chunk) break; @@ -311,7 +311,7 @@ static void run_undo (Undo *undo, int state, int discard_tail) /* (state == DO_UNDO) ? "Undo": "Redo", */ /* undo_actions[chunk->type].name); } */ - (undo_actions[chunk->type].redo) (redo_stream, chunk, state); + (undo_actions[chunk->type].redo)(redo_stream, chunk, state); if (chunk->type == UNDO_TYPE_OPEN) level++; @@ -328,7 +328,7 @@ static void run_undo (Undo *undo, int state, int discard_tail) } else { do { - chunk = undo_stream_pop_chunk (undo_stream, TRUE); /* read from tail */ + chunk = undo_stream_pop_chunk(undo_stream, TRUE); /* read from tail */ if (!chunk) break; @@ -337,12 +337,12 @@ static void run_undo (Undo *undo, int state, int discard_tail) else if (chunk->type == UNDO_TYPE_CLOSE) level--; - undo_chunk_free (chunk); + undo_chunk_free(chunk); } while (level); } } -static int count_undo_groups (UndoStream *undo_stream) +static int count_undo_groups(UndoStream *undo_stream) { UndoChunk *chunk; int groups = 0; @@ -400,22 +400,22 @@ static void update_undo(Undo *undo) ***********************************************************************/ -void undo_open (Undo *undo) +void undo_open(Undo *undo) { - chunk_open (undo->undo_stream); - update_undo (undo); + chunk_open(undo->undo_stream); + update_undo(undo); } -static void chunk_open (UndoStream *stream) +static void chunk_open(UndoStream *stream) { - UndoChunk *chunk = undo_chunk_new (UNDO_TYPE_OPEN); + UndoChunk *chunk = undo_chunk_new(UNDO_TYPE_OPEN); - undo_stream_push_chunk (stream, chunk); + undo_stream_push_chunk(stream, chunk); } -static void redo_open (UndoStream *stream, UndoChunk *chunk, int state) +static void redo_open(UndoStream *stream, UndoChunk *chunk, int state) { - chunk_close (stream); + chunk_close(stream); } /*********************************************************************** @@ -426,22 +426,22 @@ static void redo_open (UndoStream *stream, UndoChunk *chunk, int state) ***********************************************************************/ -void undo_close (Undo *undo) +void undo_close(Undo *undo) { - chunk_close (undo->undo_stream); - update_undo (undo); + chunk_close(undo->undo_stream); + update_undo(undo); } -static void chunk_close (UndoStream *stream) +static void chunk_close(UndoStream *stream) { - UndoChunk *chunk = undo_chunk_new (UNDO_TYPE_CLOSE); + UndoChunk *chunk = undo_chunk_new(UNDO_TYPE_CLOSE); - undo_stream_push_chunk (stream, chunk); + undo_stream_push_chunk(stream, chunk); } -static void redo_close (UndoStream *stream, UndoChunk *chunk, int state) +static void redo_close(UndoStream *stream, UndoChunk *chunk, int state) { - chunk_open (stream); + chunk_open(stream); } /*********************************************************************** @@ -455,43 +455,43 @@ static void redo_close (UndoStream *stream, UndoChunk *chunk, int state) ***********************************************************************/ -void undo_data (Undo *undo, GfxObj *gfxobj, void *data, int size) +void undo_data(Undo *undo, GfxObj *gfxobj, void *data, int size) { - chunk_data (undo->undo_stream, gfxobj, data, size); - update_undo (undo); + chunk_data(undo->undo_stream, gfxobj, data, size); + update_undo(undo); } -static void chunk_data (UndoStream *stream, GfxObj *gfxobj, void *data, int size) +static void chunk_data(UndoStream *stream, GfxObj *gfxobj, void *data, int size) { - UndoChunk *chunk = undo_chunk_new (UNDO_TYPE_DATA); + UndoChunk *chunk = undo_chunk_new(UNDO_TYPE_DATA); unsigned int offset = (unsigned int)(((unsigned char *)data) - ((unsigned char *)gfxobj)); unsigned int c; - undo_chunk_put32 (chunk, gfxobj->id); - undo_chunk_put32 (chunk, offset); - undo_chunk_put32 (chunk, size); + undo_chunk_put32(chunk, gfxobj->id); + undo_chunk_put32(chunk, offset); + undo_chunk_put32(chunk, size); for (c=0; cundo_stream, image, x, y, w, h); - update_undo (undo); + chunk_image(undo->undo_stream, image, x, y, w, h); + update_undo(undo); } -static void chunk_image (UndoStream *stream, Image *image, int x, int y, int w, int h) +static void chunk_image(UndoStream *stream, Image *image, int x, int y, int w, int h) { - UndoChunk *chunk = undo_chunk_new (UNDO_TYPE_IMAGE); + UndoChunk *chunk = undo_chunk_new(UNDO_TYPE_IMAGE); int v, size; /* if (x < 0) { */ @@ -537,43 +537,43 @@ static void chunk_image (UndoStream *stream, Image *image, int x, int y, int w, /* if (y+h-1 > image->h-1) */ /* h = image->h-y; */ - size = IMAGE_LINE_SIZE (image, w); + size = IMAGE_LINE_SIZE(image, w); - undo_chunk_put32 (chunk, image->gfxobj.id); - undo_chunk_put8 (chunk, image->imgtype); - undo_chunk_put16 (chunk, x); - undo_chunk_put16 (chunk, y); - undo_chunk_put16 (chunk, w); - undo_chunk_put16 (chunk, h); + undo_chunk_put32(chunk, image->gfxobj.id); + undo_chunk_put8(chunk, image->imgtype); + undo_chunk_put16(chunk, x); + undo_chunk_put16(chunk, y); + undo_chunk_put16(chunk, w); + undo_chunk_put16(chunk, h); for (v=0; vgfxobj.type == GFXOBJ_IMAGE) && (image->imgtype == imgtype)) { int x, y, w, h; int v, size; - x = undo_chunk_get16 (chunk); - y = undo_chunk_get16 (chunk); - w = undo_chunk_get16 (chunk); - h = undo_chunk_get16 (chunk); + x = undo_chunk_get16(chunk); + y = undo_chunk_get16(chunk); + w = undo_chunk_get16(chunk); + h = undo_chunk_get16(chunk); - chunk_image (stream, image, x, y, w, h); + chunk_image(stream, image, x, y, w, h); - size = IMAGE_LINE_SIZE (image, w); + size = IMAGE_LINE_SIZE(image, w); for (v=0; vundo_stream, image, x1, y1, x2, y2, horz); - update_undo (undo); + chunk_flip(undo->undo_stream, image, x1, y1, x2, y2, horz); + update_undo(undo); } -static void chunk_flip (UndoStream *stream, Image *image, int x1, int y1, int x2, int y2, int horz) +static void chunk_flip(UndoStream *stream, Image *image, int x1, int y1, int x2, int y2, int horz) { - UndoChunk *chunk = undo_chunk_new (UNDO_TYPE_FLIP); + UndoChunk *chunk = undo_chunk_new(UNDO_TYPE_FLIP); - undo_chunk_put32 (chunk, image->gfxobj.id); - undo_chunk_put8 (chunk, image->imgtype); - undo_chunk_put16 (chunk, x1); - undo_chunk_put16 (chunk, y1); - undo_chunk_put16 (chunk, x2); - undo_chunk_put16 (chunk, y2); - undo_chunk_put8 (chunk, horz); + undo_chunk_put32(chunk, image->gfxobj.id); + undo_chunk_put8(chunk, image->imgtype); + undo_chunk_put16(chunk, x1); + undo_chunk_put16(chunk, y1); + undo_chunk_put16(chunk, x2); + undo_chunk_put16(chunk, y2); + undo_chunk_put8(chunk, horz); - undo_stream_push_chunk (stream, chunk); + undo_stream_push_chunk(stream, chunk); } -static void redo_flip (UndoStream *stream, UndoChunk *chunk, int state) +static void redo_flip(UndoStream *stream, UndoChunk *chunk, int state) { - unsigned long id = undo_chunk_get32 (chunk); - int imgtype = undo_chunk_get8 (chunk); - Image *image = (Image *)gfxobj_find (id); + unsigned long id = undo_chunk_get32(chunk); + int imgtype = undo_chunk_get8(chunk); + Image *image = (Image *)gfxobj_find(id); if ((image) && (image->gfxobj.type == GFXOBJ_IMAGE) && (image->imgtype == imgtype)) { @@ -621,22 +621,22 @@ static void redo_flip (UndoStream *stream, UndoChunk *chunk, int state) int x, y, horz; Image *area; - x1 = undo_chunk_get16 (chunk); - y1 = undo_chunk_get16 (chunk); - x2 = undo_chunk_get16 (chunk); - y2 = undo_chunk_get16 (chunk); - horz = undo_chunk_get8 (chunk); + x1 = undo_chunk_get16(chunk); + y1 = undo_chunk_get16(chunk); + x2 = undo_chunk_get16(chunk); + y2 = undo_chunk_get16(chunk); + horz = undo_chunk_get8(chunk); - chunk_flip (stream, image, x1, y1, x2, y2, horz); + chunk_flip(stream, image, x1, y1, x2, y2, horz); - area = image_crop (image, x1, y1, x2-x1+1, y2-y1+1); + area = image_crop(image, x1, y1, x2-x1+1, y2-y1+1); for (y=0; y<(y2-y1+1); y++) for (x=0; x<(x2-x1+1); x++) - image_putpixel (image, - horz ? x2-x: x1+x, - !horz? y2-y: y1+y, - image_getpixel (area, x, y)); - image_free (area); + image_putpixel(image, + horz ? x2-x: x1+x, + !horz? y2-y: y1+y, + image_getpixel(area, x, y)); + image_free(area); } } @@ -660,40 +660,40 @@ static void redo_flip (UndoStream *stream, UndoChunk *chunk, int state) ***********************************************************************/ -void undo_dirty (Undo *undo, Dirty *dirty) +void undo_dirty(Undo *undo, Dirty *dirty) { - chunk_dirty (undo->undo_stream, dirty); - update_undo (undo); + chunk_dirty(undo->undo_stream, dirty); + update_undo(undo); } -static void chunk_dirty (UndoStream *stream, Dirty *dirty) +static void chunk_dirty(UndoStream *stream, Dirty *dirty) { - UndoChunk *chunk = undo_chunk_new (UNDO_TYPE_DIRTY); + UndoChunk *chunk = undo_chunk_new(UNDO_TYPE_DIRTY); int u, v; - undo_chunk_put32 (chunk, dirty->image->gfxobj.id); - undo_chunk_put8 (chunk, dirty->image->imgtype); - undo_chunk_put16 (chunk, dirty->x1); - undo_chunk_put16 (chunk, dirty->y1); - undo_chunk_put16 (chunk, dirty->x2); - undo_chunk_put16 (chunk, dirty->y2); + undo_chunk_put32(chunk, dirty->image->gfxobj.id); + undo_chunk_put8(chunk, dirty->image->imgtype); + undo_chunk_put16(chunk, dirty->x1); + undo_chunk_put16(chunk, dirty->y1); + undo_chunk_put16(chunk, dirty->x2); + undo_chunk_put16(chunk, dirty->y2); - undo_chunk_put16 (chunk, dirty->rows); + undo_chunk_put16(chunk, dirty->rows); for (v=0; vrows; v++) { - undo_chunk_put16 (chunk, dirty->row[v].y); - undo_chunk_put16 (chunk, dirty->row[v].cols); + undo_chunk_put16(chunk, dirty->row[v].y); + undo_chunk_put16(chunk, dirty->row[v].cols); for (u=0; urow[v].cols; u++) { - undo_chunk_put16 (chunk, dirty->row[v].col[u].x); - undo_chunk_put16 (chunk, dirty->row[v].col[u].w); - undo_chunk_write (chunk, dirty->row[v].col[u].data, - dirty->row[v].col[u].w << IMAGE_SHIFT (dirty->image)); + undo_chunk_put16(chunk, dirty->row[v].col[u].x); + undo_chunk_put16(chunk, dirty->row[v].col[u].w); + undo_chunk_write(chunk, dirty->row[v].col[u].data, + dirty->row[v].col[u].w << IMAGE_SHIFT(dirty->image)); } } - undo_stream_push_chunk (stream, chunk); + undo_stream_push_chunk(stream, chunk); } -static void redo_dirty (UndoStream *stream, UndoChunk *chunk, int state) +static void redo_dirty(UndoStream *stream, UndoChunk *chunk, int state) { unsigned long id = undo_chunk_get32 (chunk); int imgtype = undo_chunk_get8 (chunk); @@ -705,37 +705,37 @@ static void redo_dirty (UndoStream *stream, UndoChunk *chunk, int state) int u, v, x, y; Dirty *dirty; - x1 = undo_chunk_get16 (chunk); - y1 = undo_chunk_get16 (chunk); - x2 = undo_chunk_get16 (chunk); - y2 = undo_chunk_get16 (chunk); + x1 = undo_chunk_get16(chunk); + y1 = undo_chunk_get16(chunk); + x2 = undo_chunk_get16(chunk); + y2 = undo_chunk_get16(chunk); - dirty = dirty_new (image, x1, y1, x2, y2, FALSE); - dirty->rows = undo_chunk_get16 (chunk); - dirty->row = jmalloc (sizeof (struct DirtyRow) * dirty->rows); + dirty = dirty_new(image, x1, y1, x2, y2, FALSE); + dirty->rows = undo_chunk_get16(chunk); + dirty->row = jmalloc(sizeof(struct DirtyRow) * dirty->rows); for (v=0; vrows; v++) { - dirty->row[v].y = y = undo_chunk_get16 (chunk); - dirty->row[v].cols = undo_chunk_get16 (chunk); - dirty->row[v].col = jmalloc (sizeof (struct DirtyCol) * dirty->row[v].cols); + dirty->row[v].y = y = undo_chunk_get16(chunk); + dirty->row[v].cols = undo_chunk_get16(chunk); + dirty->row[v].col = jmalloc(sizeof(struct DirtyCol) * dirty->row[v].cols); for (u=0; urow[v].cols; u++) { - dirty->row[v].col[u].x = x = undo_chunk_get16 (chunk); - dirty->row[v].col[u].w = undo_chunk_get16 (chunk); + dirty->row[v].col[u].x = x = undo_chunk_get16(chunk); + dirty->row[v].col[u].w = undo_chunk_get16(chunk); - size = dirty->row[v].col[u].w << IMAGE_SHIFT (dirty->image); + size = dirty->row[v].col[u].w << IMAGE_SHIFT(dirty->image); dirty->row[v].col[u].flags = DIRTY_VALID_COLUMN; dirty->row[v].col[u].data = jmalloc (size); - dirty->row[v].col[u].ptr = IMAGE_ADDRESS (dirty->image, x, y); + dirty->row[v].col[u].ptr = IMAGE_ADDRESS(dirty->image, x, y); - undo_chunk_read (chunk, dirty->row[v].col[u].data, size); + undo_chunk_read(chunk, dirty->row[v].col[u].data, size); } } - dirty_swap (dirty); - chunk_dirty (stream, dirty); - dirty_free (dirty); + dirty_swap(dirty); + chunk_dirty(stream, dirty); + dirty_free(dirty); } } @@ -748,39 +748,39 @@ static void redo_dirty (UndoStream *stream, UndoChunk *chunk, int state) ***********************************************************************/ -void undo_add_image (Undo *undo, Stock *stock, Image *image) +void undo_add_image(Undo *undo, Stock *stock, Image *image) { - chunk_add_image (undo->undo_stream, stock, image); - update_undo (undo); + chunk_add_image(undo->undo_stream, stock, image); + update_undo(undo); } -static void chunk_add_image (UndoStream *stream, Stock *stock, Image *image) +static void chunk_add_image(UndoStream *stream, Stock *stock, Image *image) { - UndoChunk *chunk = undo_chunk_new (UNDO_TYPE_ADD_IMAGE); + UndoChunk *chunk = undo_chunk_new(UNDO_TYPE_ADD_IMAGE); int index; for (index=0; indexnimage; index++) if (stock->image[index] == image) break; - undo_chunk_put32 (chunk, stock->gfxobj.id); - undo_chunk_put32 (chunk, index); + undo_chunk_put32(chunk, stock->gfxobj.id); + undo_chunk_put32(chunk, index); - undo_stream_push_chunk (stream, chunk); + undo_stream_push_chunk(stream, chunk); } -static void redo_add_image (UndoStream *stream, UndoChunk *chunk, int state) +static void redo_add_image(UndoStream *stream, UndoChunk *chunk, int state) { - unsigned long stock_id = undo_chunk_get32 (chunk); - unsigned long index = undo_chunk_get32 (chunk); - Stock *stock = (Stock *)gfxobj_find (stock_id); + unsigned long stock_id = undo_chunk_get32(chunk); + unsigned long index = undo_chunk_get32(chunk); + Stock *stock = (Stock *)gfxobj_find(stock_id); if (stock) { - Image *image = stock_get_image (stock, index); + Image *image = stock_get_image(stock, index); if (image) { - chunk_remove_image (stream, stock, image); - stock_remove_image (stock, image); - image_free (image); + chunk_remove_image(stream, stock, image); + stock_remove_image(stock, image); + image_free(image); } } } @@ -795,41 +795,41 @@ static void redo_add_image (UndoStream *stream, UndoChunk *chunk, int state) ***********************************************************************/ -void undo_remove_image (Undo *undo, Stock *stock, Image *image) +void undo_remove_image(Undo *undo, Stock *stock, Image *image) { - chunk_remove_image (undo->undo_stream, stock, image); - update_undo (undo); + chunk_remove_image(undo->undo_stream, stock, image); + update_undo(undo); } -static void chunk_remove_image (UndoStream *stream, Stock *stock, Image *image) +static void chunk_remove_image(UndoStream *stream, Stock *stock, Image *image) { - UndoChunk *chunk = undo_chunk_new (UNDO_TYPE_REMOVE_IMAGE); + UndoChunk *chunk = undo_chunk_new(UNDO_TYPE_REMOVE_IMAGE); int index; for (index=0; indexnimage; index++) if (stock->image[index] == image) break; - undo_chunk_put32 (chunk, stock->gfxobj.id); - undo_chunk_put32 (chunk, index); - undo_chunk_write_image (chunk, image); + undo_chunk_put32(chunk, stock->gfxobj.id); + undo_chunk_put32(chunk, index); + undo_chunk_write_image(chunk, image); - undo_stream_push_chunk (stream, chunk); + undo_stream_push_chunk(stream, chunk); } -static void redo_remove_image (UndoStream *stream, UndoChunk *chunk, int state) +static void redo_remove_image(UndoStream *stream, UndoChunk *chunk, int state) { - unsigned long stock_id = undo_chunk_get32 (chunk); - unsigned long index = undo_chunk_get32 (chunk); - Stock *stock = (Stock *)gfxobj_find (stock_id); + unsigned long stock_id = undo_chunk_get32(chunk); + unsigned long index = undo_chunk_get32(chunk); + Stock *stock = (Stock *)gfxobj_find(stock_id); if (stock) { - Image *image = undo_chunk_read_image (chunk); + Image *image = undo_chunk_read_image(chunk); - /* ji_assert (image); */ + /* ji_assert(image); */ - stock_replace_image (stock, index, image); - chunk_add_image (stream, stock, image); + stock_replace_image(stock, index, image); + chunk_add_image(stream, stock, image); } } @@ -843,40 +843,40 @@ static void redo_remove_image (UndoStream *stream, UndoChunk *chunk, int state) ***********************************************************************/ -void undo_replace_image (Undo *undo, Stock *stock, int index) +void undo_replace_image(Undo *undo, Stock *stock, int index) { - chunk_replace_image (undo->undo_stream, stock, index); - update_undo (undo); + chunk_replace_image(undo->undo_stream, stock, index); + update_undo(undo); } -static void chunk_replace_image (UndoStream *stream, Stock *stock, int index) +static void chunk_replace_image(UndoStream *stream, Stock *stock, int index) { - UndoChunk *chunk = undo_chunk_new (UNDO_TYPE_REPLACE_IMAGE); + UndoChunk *chunk = undo_chunk_new(UNDO_TYPE_REPLACE_IMAGE); - undo_chunk_put32 (chunk, stock->gfxobj.id); - undo_chunk_put32 (chunk, index); - undo_chunk_write_image (chunk, stock->image[index]); + undo_chunk_put32(chunk, stock->gfxobj.id); + undo_chunk_put32(chunk, index); + undo_chunk_write_image(chunk, stock->image[index]); - undo_stream_push_chunk (stream, chunk); + undo_stream_push_chunk(stream, chunk); } -static void redo_replace_image (UndoStream *stream, UndoChunk *chunk, int state) +static void redo_replace_image(UndoStream *stream, UndoChunk *chunk, int state) { - unsigned long stock_id = undo_chunk_get32 (chunk); - unsigned long index = undo_chunk_get32 (chunk); - Stock *stock = (Stock *)gfxobj_find (stock_id); + unsigned long stock_id = undo_chunk_get32(chunk); + unsigned long index = undo_chunk_get32(chunk); + Stock *stock = (Stock *)gfxobj_find(stock_id); if (stock) { - Image *image = undo_chunk_read_image (chunk); + Image *image = undo_chunk_read_image(chunk); - /* ji_assert (image); */ + /* ji_assert(image); */ - chunk_replace_image (stream, stock, index); + chunk_replace_image(stream, stock, index); if (stock->image[index]) - image_free (stock->image[index]); + image_free(stock->image[index]); - stock_replace_image (stock, index, image); + stock_replace_image(stock, index, image); } } @@ -889,33 +889,33 @@ static void redo_replace_image (UndoStream *stream, UndoChunk *chunk, int state) ***********************************************************************/ -void undo_add_frame (Undo *undo, Layer *layer, Frame *frame) +void undo_add_frame(Undo *undo, Layer *layer, Frame *frame) { - chunk_add_frame (undo->undo_stream, layer, frame); - update_undo (undo); + chunk_add_frame(undo->undo_stream, layer, frame); + update_undo(undo); } -static void chunk_add_frame (UndoStream *stream, Layer *layer, Frame *frame) +static void chunk_add_frame(UndoStream *stream, Layer *layer, Frame *frame) { - UndoChunk *chunk = undo_chunk_new (UNDO_TYPE_ADD_FRAME); + UndoChunk *chunk = undo_chunk_new(UNDO_TYPE_ADD_FRAME); - undo_chunk_put32 (chunk, layer->gfxobj.id); - undo_chunk_put32 (chunk, frame->gfxobj.id); + undo_chunk_put32(chunk, layer->gfxobj.id); + undo_chunk_put32(chunk, frame->gfxobj.id); - undo_stream_push_chunk (stream, chunk); + undo_stream_push_chunk(stream, chunk); } -static void redo_add_frame (UndoStream *stream, UndoChunk *chunk, int state) +static void redo_add_frame(UndoStream *stream, UndoChunk *chunk, int state) { - unsigned long layer_id = undo_chunk_get32 (chunk); - unsigned long frame_id = undo_chunk_get32 (chunk); - Layer *layer = (Layer *)gfxobj_find (layer_id); - Frame *frame = (Frame *)gfxobj_find (frame_id); + unsigned long layer_id = undo_chunk_get32(chunk); + unsigned long frame_id = undo_chunk_get32(chunk); + Layer *layer = (Layer *)gfxobj_find(layer_id); + Frame *frame = (Frame *)gfxobj_find(frame_id); if (layer && frame) { - chunk_remove_frame (stream, layer, frame); - layer_remove_frame (layer, frame); - frame_free (frame); + chunk_remove_frame(stream, layer, frame); + layer_remove_frame(layer, frame); + frame_free(frame); } } @@ -928,34 +928,34 @@ static void redo_add_frame (UndoStream *stream, UndoChunk *chunk, int state) ***********************************************************************/ -void undo_remove_frame (Undo *undo, Layer *layer, Frame *frame) +void undo_remove_frame(Undo *undo, Layer *layer, Frame *frame) { - chunk_remove_frame (undo->undo_stream, layer, frame); - update_undo (undo); + chunk_remove_frame(undo->undo_stream, layer, frame); + update_undo(undo); } -static void chunk_remove_frame (UndoStream *stream, Layer *layer, Frame *frame) +static void chunk_remove_frame(UndoStream *stream, Layer *layer, Frame *frame) { - UndoChunk *chunk = undo_chunk_new (UNDO_TYPE_REMOVE_FRAME); + UndoChunk *chunk = undo_chunk_new(UNDO_TYPE_REMOVE_FRAME); - undo_chunk_put32 (chunk, layer->gfxobj.id); - undo_chunk_write_frame (chunk, frame); + undo_chunk_put32(chunk, layer->gfxobj.id); + undo_chunk_write_frame(chunk, frame); - undo_stream_push_chunk (stream, chunk); + undo_stream_push_chunk(stream, chunk); } -static void redo_remove_frame (UndoStream *stream, UndoChunk *chunk, int state) +static void redo_remove_frame(UndoStream *stream, UndoChunk *chunk, int state) { - unsigned long layer_id = undo_chunk_get32 (chunk); - Layer *layer = (Layer *)gfxobj_find (layer_id); + unsigned long layer_id = undo_chunk_get32(chunk); + Layer *layer = (Layer *)gfxobj_find(layer_id); if (layer) { - Frame *frame = undo_chunk_read_frame (chunk); + Frame *frame = undo_chunk_read_frame(chunk); /* ji_assert (frame); */ - chunk_add_frame (stream, layer, frame); - layer_add_frame (layer, frame); + chunk_add_frame(stream, layer, frame); + layer_add_frame(layer, frame); } } @@ -968,33 +968,33 @@ static void redo_remove_frame (UndoStream *stream, UndoChunk *chunk, int state) ***********************************************************************/ -void undo_add_layer (Undo *undo, Layer *set, Layer *layer) +void undo_add_layer(Undo *undo, Layer *set, Layer *layer) { - chunk_add_layer (undo->undo_stream, set, layer); - update_undo (undo); + chunk_add_layer(undo->undo_stream, set, layer); + update_undo(undo); } -static void chunk_add_layer (UndoStream *stream, Layer *set, Layer *layer) +static void chunk_add_layer(UndoStream *stream, Layer *set, Layer *layer) { - UndoChunk *chunk = undo_chunk_new (UNDO_TYPE_ADD_LAYER); + UndoChunk *chunk = undo_chunk_new(UNDO_TYPE_ADD_LAYER); - undo_chunk_put32 (chunk, set->gfxobj.id); - undo_chunk_put32 (chunk, layer->gfxobj.id); + undo_chunk_put32(chunk, set->gfxobj.id); + undo_chunk_put32(chunk, layer->gfxobj.id); - undo_stream_push_chunk (stream, chunk); + undo_stream_push_chunk(stream, chunk); } -static void redo_add_layer (UndoStream *stream, UndoChunk *chunk, int state) +static void redo_add_layer(UndoStream *stream, UndoChunk *chunk, int state) { - unsigned long set_id = undo_chunk_get32 (chunk); - unsigned long layer_id = undo_chunk_get32 (chunk); - Layer *set = (Layer *)gfxobj_find (set_id); - Layer *layer = (Layer *)gfxobj_find (layer_id); + unsigned long set_id = undo_chunk_get32(chunk); + unsigned long layer_id = undo_chunk_get32(chunk); + Layer *set = (Layer *)gfxobj_find(set_id); + Layer *layer = (Layer *)gfxobj_find(layer_id); if (set && layer) { - chunk_remove_layer (stream, layer); - layer_remove_layer (set, layer); - layer_free (layer); + chunk_remove_layer(stream, layer); + layer_remove_layer(set, layer); + layer_free(layer); } } @@ -1008,40 +1008,40 @@ static void redo_add_layer (UndoStream *stream, UndoChunk *chunk, int state) ***********************************************************************/ -void undo_remove_layer (Undo *undo, Layer *layer) +void undo_remove_layer(Undo *undo, Layer *layer) { - chunk_remove_layer (undo->undo_stream, layer); - update_undo (undo); + chunk_remove_layer(undo->undo_stream, layer); + update_undo(undo); } -static void chunk_remove_layer (UndoStream *stream, Layer *layer) +static void chunk_remove_layer(UndoStream *stream, Layer *layer) { - UndoChunk *chunk = undo_chunk_new (UNDO_TYPE_REMOVE_LAYER); + UndoChunk *chunk = undo_chunk_new(UNDO_TYPE_REMOVE_LAYER); Layer *set = (Layer *)layer->parent; - Layer *after = layer_get_prev (layer); + Layer *after = layer_get_prev(layer); - undo_chunk_put32 (chunk, set->gfxobj.id); - undo_chunk_put32 (chunk, after ? after->gfxobj.id: 0); - undo_chunk_write_layer (chunk, layer); + undo_chunk_put32(chunk, set->gfxobj.id); + undo_chunk_put32(chunk, after ? after->gfxobj.id: 0); + undo_chunk_write_layer(chunk, layer); - undo_stream_push_chunk (stream, chunk); + undo_stream_push_chunk(stream, chunk); } -static void redo_remove_layer (UndoStream *stream, UndoChunk *chunk, int state) +static void redo_remove_layer(UndoStream *stream, UndoChunk *chunk, int state) { - unsigned long set_id = undo_chunk_get32 (chunk); - unsigned long after_id = undo_chunk_get32 (chunk); - Layer *set = (Layer *)gfxobj_find (set_id); - Layer *after = (Layer *)gfxobj_find (after_id); + unsigned long set_id = undo_chunk_get32(chunk); + unsigned long after_id = undo_chunk_get32(chunk); + Layer *set = (Layer *)gfxobj_find(set_id); + Layer *after = (Layer *)gfxobj_find(after_id); if (set) { - Layer *layer = undo_chunk_read_layer (chunk); + Layer *layer = undo_chunk_read_layer(chunk); - /* ji_assert (layer); */ + /* ji_assert(layer); */ - chunk_add_layer (stream, set, layer); - layer_add_layer (set, layer); - layer_move_layer (set, layer, after); + chunk_add_layer(stream, set, layer); + layer_add_layer(set, layer); + layer_move_layer(set, layer, after); } } @@ -1055,37 +1055,37 @@ static void redo_remove_layer (UndoStream *stream, UndoChunk *chunk, int state) ***********************************************************************/ -void undo_move_layer (Undo *undo, Layer *layer) +void undo_move_layer(Undo *undo, Layer *layer) { - chunk_move_layer (undo->undo_stream, layer); - update_undo (undo); + chunk_move_layer(undo->undo_stream, layer); + update_undo(undo); } -static void chunk_move_layer (UndoStream *stream, Layer *layer) +static void chunk_move_layer(UndoStream *stream, Layer *layer) { - UndoChunk *chunk = undo_chunk_new (UNDO_TYPE_MOVE_LAYER); + UndoChunk *chunk = undo_chunk_new(UNDO_TYPE_MOVE_LAYER); Layer *set = (Layer *)layer->parent; - Layer *after = layer_get_prev (layer); + Layer *after = layer_get_prev(layer); - undo_chunk_put32 (chunk, set->gfxobj.id); - undo_chunk_put32 (chunk, layer->gfxobj.id); - undo_chunk_put32 (chunk, after ? after->gfxobj.id: 0); + undo_chunk_put32(chunk, set->gfxobj.id); + undo_chunk_put32(chunk, layer->gfxobj.id); + undo_chunk_put32(chunk, after ? after->gfxobj.id: 0); - undo_stream_push_chunk (stream, chunk); + undo_stream_push_chunk(stream, chunk); } static void redo_move_layer (UndoStream *stream, UndoChunk *chunk, int state) { - unsigned long set_id = undo_chunk_get32 (chunk); - unsigned long layer_id = undo_chunk_get32 (chunk); - unsigned long after_id = undo_chunk_get32 (chunk); - Layer *set = (Layer *)gfxobj_find (set_id); - Layer *layer = (Layer *)gfxobj_find (layer_id); - Layer *after = (Layer *)gfxobj_find (after_id); + unsigned long set_id = undo_chunk_get32(chunk); + unsigned long layer_id = undo_chunk_get32(chunk); + unsigned long after_id = undo_chunk_get32(chunk); + Layer *set = (Layer *)gfxobj_find(set_id); + Layer *layer = (Layer *)gfxobj_find(layer_id); + Layer *after = (Layer *)gfxobj_find(after_id); if (set && layer) { - chunk_move_layer (stream, layer); - layer_move_layer (set, layer, after); + chunk_move_layer(stream, layer); + layer_move_layer(set, layer, after); } } @@ -1098,31 +1098,31 @@ static void redo_move_layer (UndoStream *stream, UndoChunk *chunk, int state) ***********************************************************************/ -void undo_set_layer (Undo *undo, Sprite *sprite) +void undo_set_layer(Undo *undo, Sprite *sprite) { - chunk_set_layer (undo->undo_stream, sprite); - update_undo (undo); + chunk_set_layer(undo->undo_stream, sprite); + update_undo(undo); } -static void chunk_set_layer (UndoStream *stream, Sprite *sprite) +static void chunk_set_layer(UndoStream *stream, Sprite *sprite) { - UndoChunk *chunk = undo_chunk_new (UNDO_TYPE_SET_LAYER); + UndoChunk *chunk = undo_chunk_new(UNDO_TYPE_SET_LAYER); - undo_chunk_put32 (chunk, sprite->gfxobj.id); - undo_chunk_put32 (chunk, sprite->layer ? sprite->layer->gfxobj.id: 0); + undo_chunk_put32(chunk, sprite->gfxobj.id); + undo_chunk_put32(chunk, sprite->layer ? sprite->layer->gfxobj.id: 0); - undo_stream_push_chunk (stream, chunk); + undo_stream_push_chunk(stream, chunk); } -static void redo_set_layer (UndoStream *stream, UndoChunk *chunk, int state) +static void redo_set_layer(UndoStream *stream, UndoChunk *chunk, int state) { - unsigned long sprite_id = undo_chunk_get32 (chunk); - unsigned long layer_id = undo_chunk_get32 (chunk); - Sprite *sprite = (Sprite *)gfxobj_find (sprite_id); - Layer *layer = (Layer *)gfxobj_find (layer_id); + unsigned long sprite_id = undo_chunk_get32(chunk); + unsigned long layer_id = undo_chunk_get32(chunk); + Sprite *sprite = (Sprite *)gfxobj_find(sprite_id); + Layer *layer = (Layer *)gfxobj_find(layer_id); if (sprite) { - chunk_set_layer (stream, sprite); + chunk_set_layer(stream, sprite); sprite->layer = layer; } @@ -1137,37 +1137,37 @@ static void redo_set_layer (UndoStream *stream, UndoChunk *chunk, int state) ***********************************************************************/ -void undo_set_mask (Undo *undo, Sprite *sprite) +void undo_set_mask(Undo *undo, Sprite *sprite) { - chunk_set_mask (undo->undo_stream, sprite); - update_undo (undo); + chunk_set_mask(undo->undo_stream, sprite); + update_undo(undo); } -static void chunk_set_mask (UndoStream *stream, Sprite *sprite) +static void chunk_set_mask(UndoStream *stream, Sprite *sprite) { - UndoChunk *chunk = undo_chunk_new (UNDO_TYPE_SET_MASK); + UndoChunk *chunk = undo_chunk_new(UNDO_TYPE_SET_MASK); - undo_chunk_put32 (chunk, sprite->gfxobj.id); - undo_chunk_write_mask (chunk, sprite->mask); + undo_chunk_put32(chunk, sprite->gfxobj.id); + undo_chunk_write_mask(chunk, sprite->mask); - undo_stream_push_chunk (stream, chunk); + undo_stream_push_chunk(stream, chunk); } -static void redo_set_mask (UndoStream *stream, UndoChunk *chunk, int state) +static void redo_set_mask(UndoStream *stream, UndoChunk *chunk, int state) { - unsigned long sprite_id = undo_chunk_get32 (chunk); - Sprite *sprite = (Sprite *)gfxobj_find (sprite_id); + unsigned long sprite_id = undo_chunk_get32(chunk); + Sprite *sprite = (Sprite *)gfxobj_find(sprite_id); if (sprite) { - Mask *mask = undo_chunk_read_mask (chunk); + Mask *mask = undo_chunk_read_mask(chunk); - /* ji_assert (mask); */ + /* ji_assert(mask); */ - chunk_set_mask (stream, sprite); - mask_copy (sprite->mask, mask); + chunk_set_mask(stream, sprite); + mask_copy(sprite->mask, mask); /* change the sprite mask directly */ -/* mask_free (sprite->mask); */ +/* mask_free(sprite->mask); */ /* sprite->mask = mask; */ } } @@ -1178,11 +1178,11 @@ static void redo_set_mask (UndoStream *stream, UndoChunk *chunk, int state) ***********************************************************************/ -static UndoChunk *undo_chunk_new (int type) +static UndoChunk *undo_chunk_new(int type) { UndoChunk *chunk; - chunk = jnew (UndoChunk, 1); + chunk = jnew(UndoChunk, 1); if (!chunk) return NULL; @@ -1195,15 +1195,15 @@ static UndoChunk *undo_chunk_new (int type) return chunk; } -static void undo_chunk_free (UndoChunk *chunk) +static void undo_chunk_free(UndoChunk *chunk) { if (chunk->data) - jfree (chunk->data); + jfree(chunk->data); - jfree (chunk); + jfree(chunk); } -static int undo_chunk_get8 (UndoChunk *chunk) +static int undo_chunk_get8(UndoChunk *chunk) { if (chunk->pos < chunk->size) return chunk->data[chunk->pos++]; @@ -1211,52 +1211,52 @@ static int undo_chunk_get8 (UndoChunk *chunk) return EOF; } -static void undo_chunk_put8 (UndoChunk *chunk, int c) +static void undo_chunk_put8(UndoChunk *chunk, int c) { if (chunk->size == chunk->max_size) { chunk->max_size += 4096; - chunk->data = jrealloc (chunk->data, chunk->max_size); + chunk->data = jrealloc(chunk->data, chunk->max_size); } chunk->data[chunk->size++] = c; } -static int undo_chunk_get16 (UndoChunk *chunk) +static int undo_chunk_get16(UndoChunk *chunk) { int b1, b2; - if ((b1 = undo_chunk_get8 (chunk)) != EOF) - if ((b2 = undo_chunk_get8 (chunk)) != EOF) + if ((b1 = undo_chunk_get8(chunk)) != EOF) + if ((b2 = undo_chunk_get8(chunk)) != EOF) return ((b2 << 8) | b1); return EOF; } -static void undo_chunk_put16 (UndoChunk *chunk, int c) +static void undo_chunk_put16(UndoChunk *chunk, int c) { int b1, b2; b1 = (c & 0xFF00) >> 8; b2 = c & 0x00FF; - undo_chunk_put8 (chunk, b2); - undo_chunk_put8 (chunk, b1); + undo_chunk_put8(chunk, b2); + undo_chunk_put8(chunk, b1); } -static long undo_chunk_get32 (UndoChunk *chunk) +static long undo_chunk_get32(UndoChunk *chunk) { int b1, b2, b3, b4; - if ((b1 = undo_chunk_get8 (chunk)) != EOF) - if ((b2 = undo_chunk_get8 (chunk)) != EOF) - if ((b3 = undo_chunk_get8 (chunk)) != EOF) - if ((b4 = undo_chunk_get8 (chunk)) != EOF) + if ((b1 = undo_chunk_get8(chunk)) != EOF) + if ((b2 = undo_chunk_get8(chunk)) != EOF) + if ((b3 = undo_chunk_get8(chunk)) != EOF) + if ((b4 = undo_chunk_get8(chunk)) != EOF) return (((long)b4 << 24) | ((long)b3 << 16) | ((long)b2 << 8) | (long)b1); return EOF; } -static void undo_chunk_put32 (UndoChunk *chunk, long c) +static void undo_chunk_put32(UndoChunk *chunk, long c) { int b1, b2, b3, b4; @@ -1265,64 +1265,64 @@ static void undo_chunk_put32 (UndoChunk *chunk, long c) b3 = (int)((c & 0x0000FF00L) >> 8); b4 = (int)c & 0x00FF; - undo_chunk_put8 (chunk, b4); - undo_chunk_put8 (chunk, b3); - undo_chunk_put8 (chunk, b2); - undo_chunk_put8 (chunk, b1); + undo_chunk_put8(chunk, b4); + undo_chunk_put8(chunk, b3); + undo_chunk_put8(chunk, b2); + undo_chunk_put8(chunk, b1); } -/* static double undo_chunk_get64 (UndoChunk *chunk) */ +/* static double undo_chunk_get64(UndoChunk *chunk) */ /* { */ /* unsigned long longs[2]; */ /* double value; */ -/* longs[0] = undo_chunk_get32 (chunk); */ -/* longs[1] = undo_chunk_get32 (chunk); */ +/* longs[0] = undo_chunk_get32(chunk); */ +/* longs[1] = undo_chunk_get32(chunk); */ -/* memcpy (&value, longs, sizeof (longs)); */ +/* memcpy(&value, longs, sizeof (longs)); */ /* return value; */ /* } */ -/* static void undo_chunk_put64 (UndoChunk *chunk, double c) */ +/* static void undo_chunk_put64(UndoChunk *chunk, double c) */ /* { */ /* unsigned long longs[2]; */ -/* memcpy (longs, &c, sizeof (longs)); */ +/* memcpy(longs, &c, sizeof (longs)); */ -/* undo_chunk_put32 (chunk, longs[0]); */ -/* undo_chunk_put32 (chunk, longs[1]); */ +/* undo_chunk_put32(chunk, longs[0]); */ +/* undo_chunk_put32(chunk, longs[1]); */ /* } */ -static int undo_chunk_read (UndoChunk *chunk, unsigned char *buf, int size) +static int undo_chunk_read(UndoChunk *chunk, unsigned char *buf, int size) { if (chunk->pos+size > chunk->size) return 0; - memcpy (buf, chunk->data+chunk->pos, size); + memcpy(buf, chunk->data+chunk->pos, size); chunk->pos += size; return size; } -static void undo_chunk_write (UndoChunk *chunk, const unsigned char *buf, int size) +static void undo_chunk_write(UndoChunk *chunk, const unsigned char *buf, int size) { if (chunk->size+size > chunk->max_size) { chunk->max_size = chunk->size+size; - chunk->data = jrealloc (chunk->data, chunk->max_size); + chunk->data = jrealloc(chunk->data, chunk->max_size); } - memcpy (chunk->data+chunk->size, buf, size); + memcpy(chunk->data+chunk->size, buf, size); chunk->size += size; } -static char *undo_chunk_read_string (UndoChunk *chunk) +static char *undo_chunk_read_string(UndoChunk *chunk) { - unsigned int count = undo_chunk_get16 (chunk); + unsigned int count = undo_chunk_get16(chunk); char *string; if (count > 0) { - string = jmalloc (count+1); - undo_chunk_read (chunk, string, count); + string = jmalloc(count+1); + undo_chunk_read(chunk, string, count); string[count] = 0; } else @@ -1331,16 +1331,16 @@ static char *undo_chunk_read_string (UndoChunk *chunk) return string; } -static void undo_chunk_write_string (UndoChunk *chunk, const char *string) +static void undo_chunk_write_string(UndoChunk *chunk, const char *string) { - int count = string ? strlen (string): 0; + int count = string ? strlen(string): 0; - undo_chunk_put16 (chunk, count); + undo_chunk_put16(chunk, count); if (string) - undo_chunk_write (chunk, string, count); + undo_chunk_write(chunk, string, count); } -static Frame *undo_chunk_read_frame (UndoChunk *chunk) +static Frame *undo_chunk_read_frame(UndoChunk *chunk) { unsigned long frame_id = undo_chunk_get32(chunk); int frpos = undo_chunk_get16(chunk); @@ -1356,58 +1356,58 @@ static Frame *undo_chunk_read_frame (UndoChunk *chunk) return frame; } -static void undo_chunk_write_frame (UndoChunk *chunk, Frame *frame) +static void undo_chunk_write_frame(UndoChunk *chunk, Frame *frame) { - undo_chunk_put32 (chunk, frame->gfxobj.id); - undo_chunk_put16 (chunk, frame->frpos); - undo_chunk_put16 (chunk, frame->image); - undo_chunk_put16 (chunk, frame->x); - undo_chunk_put16 (chunk, frame->y); - undo_chunk_put8 (chunk, frame->opacity); + undo_chunk_put32(chunk, frame->gfxobj.id); + undo_chunk_put16(chunk, frame->frpos); + undo_chunk_put16(chunk, frame->image); + undo_chunk_put16(chunk, frame->x); + undo_chunk_put16(chunk, frame->y); + undo_chunk_put8(chunk, frame->opacity); } -static Layer *undo_chunk_read_layer (UndoChunk *chunk) +static Layer *undo_chunk_read_layer(UndoChunk *chunk) { - unsigned long layer_id = undo_chunk_get32 (chunk); - char *name = undo_chunk_read_string (chunk); /* name */ - int flags = undo_chunk_get8 (chunk); /* properties */ - int type = undo_chunk_get32 (chunk); /* type */ + unsigned long layer_id = undo_chunk_get32(chunk); + char *name = undo_chunk_read_string(chunk); /* name */ + int flags = undo_chunk_get8(chunk); /* properties */ + int type = undo_chunk_get32(chunk); /* type */ Layer *layer = NULL; switch (type) { case GFXOBJ_LAYER_IMAGE: { - int imgtype = undo_chunk_get8 (chunk); /* imgtype */ - int blend_mode = undo_chunk_get8 (chunk); /* blend mode */ - Stock *stock = undo_chunk_read_stock (chunk); /* stock */ - int c, frames = undo_chunk_get16 (chunk); /* how many frames */ + int imgtype = undo_chunk_get8(chunk); /* imgtype */ + int blend_mode = undo_chunk_get8(chunk); /* blend mode */ + Stock *stock = undo_chunk_read_stock(chunk); /* stock */ + int c, frames = undo_chunk_get16(chunk); /* how many frames */ /* create layer */ - layer = layer_new (imgtype); + layer = layer_new(imgtype); /* set blend mode */ - layer_set_blend_mode (layer, blend_mode); + layer_set_blend_mode(layer, blend_mode); /* set stock */ - stock_free (layer->stock); + stock_free(layer->stock); layer->stock = stock; /* read frames */ for (c=0; creadable = TRUE; @@ -1428,16 +1428,16 @@ static Layer *undo_chunk_read_layer (UndoChunk *chunk) if (flags & 2) layer->writeable = TRUE; - _gfxobj_set_id ((GfxObj *)layer, layer_id); + _gfxobj_set_id((GfxObj *)layer, layer_id); } if (name) - jfree (name); + jfree(name); return layer; } -static void undo_chunk_write_layer (UndoChunk *chunk, Layer *layer) +static void undo_chunk_write_layer(UndoChunk *chunk, Layer *layer) { JLink link; @@ -1475,7 +1475,7 @@ static void undo_chunk_write_layer (UndoChunk *chunk, Layer *layer) } } -static Image *undo_chunk_read_image (UndoChunk *chunk) +static Image *undo_chunk_read_image(UndoChunk *chunk) { unsigned long image_id; int imgtype; @@ -1484,110 +1484,110 @@ static Image *undo_chunk_read_image (UndoChunk *chunk) Image *image; int c, size; - image_id = undo_chunk_get32 (chunk); /* ID */ + image_id = undo_chunk_get32(chunk); /* ID */ if (!image_id) return NULL; - imgtype = undo_chunk_get8 (chunk); /* imgtype */ - width = undo_chunk_get16 (chunk); /* width */ - height = undo_chunk_get16 (chunk); /* height */ + imgtype = undo_chunk_get8(chunk); /* imgtype */ + width = undo_chunk_get16(chunk); /* width */ + height = undo_chunk_get16(chunk); /* height */ - image = image_new (imgtype, width, height); - size = IMAGE_LINE_SIZE (image, image->w); + image = image_new(imgtype, width, height); + size = IMAGE_LINE_SIZE(image, image->w); for (c=0; ch; c++) - undo_chunk_read (chunk, image->line[c], size); + undo_chunk_read(chunk, image->line[c], size); - _gfxobj_set_id ((GfxObj *)image, image_id); + _gfxobj_set_id((GfxObj *)image, image_id); return image; } -static void undo_chunk_write_image (UndoChunk *chunk, Image *image) +static void undo_chunk_write_image(UndoChunk *chunk, Image *image) { int c, size; - undo_chunk_put32 (chunk, image ? image->gfxobj.id: 0); /* ID */ + undo_chunk_put32(chunk, image ? image->gfxobj.id: 0); /* ID */ if (!image) return; - size = IMAGE_LINE_SIZE (image, image->w); + size = IMAGE_LINE_SIZE(image, image->w); - undo_chunk_put8 (chunk, image->imgtype); /* imgtype */ - undo_chunk_put16 (chunk, image->w); /* width */ - undo_chunk_put16 (chunk, image->h); /* height */ + undo_chunk_put8(chunk, image->imgtype); /* imgtype */ + undo_chunk_put16(chunk, image->w); /* width */ + undo_chunk_put16(chunk, image->h); /* height */ for (c=0; ch; c++) - undo_chunk_write (chunk, image->line[c], size); + undo_chunk_write(chunk, image->line[c], size); } -static Stock *undo_chunk_read_stock (UndoChunk *chunk) +static Stock *undo_chunk_read_stock(UndoChunk *chunk) { - unsigned long stock_id = undo_chunk_get32 (chunk); /* ID */ - int imgtype = undo_chunk_get8 (chunk); /* imgtype */ - int nimage = undo_chunk_get16 (chunk); /* nimage */ + unsigned long stock_id = undo_chunk_get32(chunk); /* ID */ + int imgtype = undo_chunk_get8(chunk); /* imgtype */ + int nimage = undo_chunk_get16(chunk); /* nimage */ Stock *stock; int c; - stock = stock_new (imgtype); + stock = stock_new(imgtype); for (c=0; cgfxobj.id); /* ID */ - undo_chunk_put8 (chunk, stock->imgtype); /* imgtype */ - undo_chunk_put16 (chunk, stock->nimage-1); /* nimage */ + undo_chunk_put32(chunk, stock->gfxobj.id); /* ID */ + undo_chunk_put8(chunk, stock->imgtype); /* imgtype */ + undo_chunk_put16(chunk, stock->nimage-1); /* nimage */ /* c=1 because the first NULL image is added by default */ for (c=1; cnimage; c++) - undo_chunk_write_image (chunk, stock->image[c]); + undo_chunk_write_image(chunk, stock->image[c]); } -static Mask *undo_chunk_read_mask (UndoChunk *chunk) +static Mask *undo_chunk_read_mask(UndoChunk *chunk) { -/* unsigned long mask_id = undo_chunk_get32 (chunk); /\* ID *\/ */ - int x = (short)undo_chunk_get16 (chunk); /* xpos */ - int y = (short)undo_chunk_get16 (chunk); /* ypos */ - int width = undo_chunk_get16 (chunk); /* width */ - int height = undo_chunk_get16 (chunk); /* height */ +/* unsigned long mask_id = undo_chunk_get32(chunk); /\* ID *\/ */ + int x = (short)undo_chunk_get16(chunk); /* xpos */ + int y = (short)undo_chunk_get16(chunk); /* ypos */ + int width = undo_chunk_get16(chunk); /* width */ + int height = undo_chunk_get16(chunk); /* height */ int c, size = (width+7)/8; Mask *mask; - mask = mask_new (); + mask = mask_new(); if (!mask) return NULL; if (width > 0 && height > 0) { - mask_union (mask, x, y, width, height); + mask_union(mask, x, y, width, height); for (c=0; ch; c++) - undo_chunk_read (chunk, mask->bitmap->line[c], size); + undo_chunk_read(chunk, mask->bitmap->line[c], size); } -/* _gfxobj_set_id ((GfxObj *)mask, mask_id); */ +/* _gfxobj_set_id((GfxObj *)mask, mask_id); */ return mask; } -static void undo_chunk_write_mask (UndoChunk *chunk, Mask *mask) +static void undo_chunk_write_mask(UndoChunk *chunk, Mask *mask) { int c, size = (mask->w+7)/8; /* undo_chunk_put32 (chunk, mask->gfxobj.id); /\* ID *\/ */ - undo_chunk_put16 (chunk, mask->x); /* xpos */ - undo_chunk_put16 (chunk, mask->y); /* ypos */ - undo_chunk_put16 (chunk, mask->bitmap ? mask->w: 0); /* width */ - undo_chunk_put16 (chunk, mask->bitmap ? mask->h: 0); /* height */ + undo_chunk_put16(chunk, mask->x); /* xpos */ + undo_chunk_put16(chunk, mask->y); /* ypos */ + undo_chunk_put16(chunk, mask->bitmap ? mask->w: 0); /* width */ + undo_chunk_put16(chunk, mask->bitmap ? mask->h: 0); /* height */ if (mask->bitmap) for (c=0; ch; c++) - undo_chunk_write (chunk, mask->bitmap->line[c], size); + undo_chunk_write(chunk, mask->bitmap->line[c], size); } /*********************************************************************** @@ -1596,11 +1596,11 @@ static void undo_chunk_write_mask (UndoChunk *chunk, Mask *mask) ***********************************************************************/ -static UndoStream *undo_stream_new (void) +static UndoStream *undo_stream_new(void) { UndoStream *stream; - stream = jnew (UndoStream, 1); + stream = jnew(UndoStream, 1); if (!stream) return NULL; @@ -1642,7 +1642,7 @@ static UndoChunk *undo_stream_pop_chunk(UndoStream *stream, int tail) return chunk; } -static void undo_stream_push_chunk (UndoStream *stream, UndoChunk *chunk) +static void undo_stream_push_chunk(UndoStream *stream, UndoChunk *chunk) { jlist_prepend(stream->chunks, chunk); stream->size += chunk->size; diff --git a/src/raster/undo.h b/src/raster/undo.h index 280ece0b0..dc7195a05 100644 --- a/src/raster/undo.h +++ b/src/raster/undo.h @@ -1,5 +1,5 @@ /* ase -- allegro-sprite-editor: the ultimate sprites factory - * Copyright (C) 2001-2005 David A. Capello + * Copyright (C) 2001-2005, 2007 David A. Capello * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -46,45 +46,45 @@ struct Undo int size_limit; /* limit for undo stream size */ }; -Undo *undo_new (struct Sprite *sprite); -void undo_free (Undo *undo); +Undo *undo_new(struct Sprite *sprite); +void undo_free(Undo *undo); -void undo_enable (Undo *undo); -void undo_disable (Undo *undo); +void undo_enable(Undo *undo); +void undo_disable(Undo *undo); -bool undo_is_enabled (Undo *undo); -bool undo_is_disabled (Undo *undo); +bool undo_is_enabled(Undo *undo); +bool undo_is_disabled(Undo *undo); -bool undo_can_undo (Undo *undo); -bool undo_can_redo (Undo *undo); +bool undo_can_undo(Undo *undo); +bool undo_can_redo(Undo *undo); -void undo_undo (Undo *undo); -void undo_redo (Undo *undo); +void undo_undo(Undo *undo); +void undo_redo(Undo *undo); -void undo_open (Undo *undo); -void undo_close (Undo *undo); -void undo_data (Undo *undo, GfxObj *gfxobj, void *data, int size); -void undo_image (Undo *undo, struct Image *image, int x, int y, int w, int h); -void undo_flip (Undo *undo, struct Image *image, int x1, int y1, int x2, int y2, int horz); -void undo_dirty (Undo *undo, struct Dirty *dirty); -void undo_add_image (Undo *undo, struct Stock *stock, struct Image *image); -void undo_remove_image (Undo *undo, struct Stock *stock, struct Image *image); -void undo_replace_image (Undo *undo, struct Stock *stock, int index); -void undo_add_frame (Undo *undo, struct Layer *layer, struct Frame *frame); -void undo_remove_frame (Undo *undo, struct Layer *layer, struct Frame *frame); -void undo_add_layer (Undo *undo, struct Layer *set, struct Layer *layer); -void undo_remove_layer (Undo *undo, struct Layer *layer); -void undo_move_layer (Undo *undo, struct Layer *layer); -void undo_set_layer (Undo *undo, struct Sprite *sprite); -void undo_set_mask (Undo *undo, struct Sprite *sprite); +void undo_open(Undo *undo); +void undo_close(Undo *undo); +void undo_data(Undo *undo, GfxObj *gfxobj, void *data, int size); +void undo_image(Undo *undo, struct Image *image, int x, int y, int w, int h); +void undo_flip(Undo *undo, struct Image *image, int x1, int y1, int x2, int y2, int horz); +void undo_dirty(Undo *undo, struct Dirty *dirty); +void undo_add_image(Undo *undo, struct Stock *stock, struct Image *image); +void undo_remove_image(Undo *undo, struct Stock *stock, struct Image *image); +void undo_replace_image(Undo *undo, struct Stock *stock, int index); +void undo_add_frame(Undo *undo, struct Layer *layer, struct Frame *frame); +void undo_remove_frame(Undo *undo, struct Layer *layer, struct Frame *frame); +void undo_add_layer(Undo *undo, struct Layer *set, struct Layer *layer); +void undo_remove_layer(Undo *undo, struct Layer *layer); +void undo_move_layer(Undo *undo, struct Layer *layer); +void undo_set_layer(Undo *undo, struct Sprite *sprite); +void undo_set_mask(Undo *undo, struct Sprite *sprite); #define undo_int(undo, gfxobj, value_address) \ - undo_data ((undo), (gfxobj), (void *)(value_address), sizeof (int)) + undo_data((undo), (gfxobj), (void *)(value_address), sizeof(int)) #define undo_double(undo, gfxobj, value_address) \ - undo_data ((undo), (gfxobj), (void *)(value_address), sizeof (double)) + undo_data((undo), (gfxobj), (void *)(value_address), sizeof(double)) #define undo_string(undo, gfxobj, string) \ - undo_data ((undo), (gfxobj), (void *)(string), strlen (string)+1) + undo_data((undo), (gfxobj), (void *)(string), strlen(string)+1) #endif /* RASTER_UNDO_H */ diff --git a/src/script/bindings.c b/src/script/bindings.c index 36a7c81a4..81d486198 100644 --- a/src/script/bindings.c +++ b/src/script/bindings.c @@ -731,7 +731,6 @@ static int bind_jwidget_hook_signal (lua_State *L) #include "dialogs/tips.h" #include "dialogs/toolconf.h" #include "dialogs/vectmap.h" -#include "dialogs/viewspr.h" #include "file/file.h" #include "intl/intl.h" #include "modules/rootmenu.h" diff --git a/src/widgets/menuitem.c b/src/widgets/menuitem.c index 1e663fa84..3667b71c5 100644 --- a/src/widgets/menuitem.c +++ b/src/widgets/menuitem.c @@ -31,7 +31,6 @@ #include "commands/commands.h" #include "core/core.h" -#include "modules/chkmthds.h" #include "modules/gui.h" #include "script/script.h"