From 36f861ddd789c72acb439370a5bb6b3f198c6994 Mon Sep 17 00:00:00 2001 From: David Capello Date: Thu, 8 Nov 2007 00:54:31 +0000 Subject: [PATCH] Removed src/dialogs/effect/*.c --- ChangeLog | 16 +- TODO.txt | 12 +- data/{defgui-en.xml => gui-en.xml} | 5 - data/{defgui-es.xml => gui-es.xml} | 0 jinete/src/jtheme.c | 1 - jinete/src/themes/jsimple.c | 1273 +++++++++++++---- makefile.gcc | 2 +- makefile.lst | 345 +++-- misc/dist.sh | 4 +- misc/gendeps.sh | 2 +- src/commands/cmd_color_curve.c | 33 - src/commands/cmd_convolution_matrix.c | 33 - src/commands/cmd_despeckle.c | 33 - src/{util/flip.c => commands/cmd_flip.c} | 197 +-- src/commands/cmd_flip_horizontal.c | 33 - src/commands/cmd_flip_vertical.c | 33 - src/commands/cmd_invert_color.c | 33 - src/commands/cmd_quick_copy.c | 33 - src/commands/cmd_quick_move.c | 33 - src/commands/cmd_replace_color.c | 33 - src/commands/commands.c | 25 +- src/commands/commands.h | 2 - .../fx/cmd_color_curve.c} | 342 ++--- .../fx/cmd_convolution_matrix.c} | 690 ++++----- .../dmedian.c => commands/fx/cmd_despeckle.c} | 395 ++--- .../fx/cmd_invert_color.c} | 295 ++-- src/commands/fx/cmd_replace_color.c | 233 +++ src/dialogs/effect.h | 28 - src/dialogs/effect/dreplcol.c | 232 --- src/modules/rootmenu.c | 4 +- src/script/bindings.c | 4 +- src/script/export.h | 10 - src/script/genbinds.c | 49 - src/util/flip.h | 26 - 34 files changed, 2388 insertions(+), 2101 deletions(-) rename data/{defgui-en.xml => gui-en.xml} (95%) rename data/{defgui-es.xml => gui-es.xml} (100%) delete mode 100644 src/commands/cmd_color_curve.c delete mode 100644 src/commands/cmd_convolution_matrix.c delete mode 100644 src/commands/cmd_despeckle.c rename src/{util/flip.c => commands/cmd_flip.c} (57%) delete mode 100644 src/commands/cmd_flip_horizontal.c delete mode 100644 src/commands/cmd_flip_vertical.c delete mode 100644 src/commands/cmd_invert_color.c delete mode 100644 src/commands/cmd_quick_copy.c delete mode 100644 src/commands/cmd_quick_move.c delete mode 100644 src/commands/cmd_replace_color.c rename src/{dialogs/effect/dcolcurv.c => commands/fx/cmd_color_curve.c} (92%) rename src/{dialogs/effect/dconvmtr.c => commands/fx/cmd_convolution_matrix.c} (94%) rename src/{dialogs/effect/dmedian.c => commands/fx/cmd_despeckle.c} (93%) rename src/{dialogs/effect/dinvcol.c => commands/fx/cmd_invert_color.c} (52%) create mode 100644 src/commands/fx/cmd_replace_color.c delete mode 100644 src/dialogs/effect.h delete mode 100644 src/dialogs/effect/dreplcol.c delete mode 100644 src/util/flip.h diff --git a/ChangeLog b/ChangeLog index 72cbaea1d..cf756e44a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,21 @@ +2007-11-07 David A. Capello + + * src/commands/cmd_color_curve.c: Done. Removed src/dialogs/effect/dcolcurv.c + + * src/commands/cmd_convolution_matrix.c: Done. Removed src/dialogs/effect/dconvmtr.c + + * src/commands/cmd_despeckle.c: Done. Removed src/dialogs/effect/dmedian.c + + * src/commands/cmd_replace_color.c: Done. Removed src/dialogs/effect/dreplcol.c + + * src/commands/cmd_invert_color.c: Done. Removed src/dialogs/effect/dinvcol.c + + * src/commands/cmd_flip.c: Done. Removed src/util/flip.c + 2007-10-07 David A. Capello * src/commands/cmd_new_frame.c (command_execute_new_frame): Added - from new_frame() routine (now with undo of everything). + from new_frame() routine (now with undo of sprite_set_frames). * src/raster/undo.c (undo_set_frames): Added. diff --git a/TODO.txt b/TODO.txt index 8532492cf..883ee3464 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,9 +1,10 @@ High priority work ------------------ +- search for XXX (XXXX is supposed to be high priority); + + replace XXX to TODO; - add support for PNG files. - ver por el nuevo load_font de Allegro. -- 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); - fix undo of big chunks (more than limit): @@ -44,7 +45,14 @@ High priority work Wish-list --------- -- Add menu customization through UI (Tools/Customize). +- my wish-list: + + keyboard shortcuts for snap-to-grid and view-grid + + different snap-to-grid for paste operation + + better dialogs: widder buttons, more borders. + + better film editor + + "middle mouse button" for the film editor. + + don't use LINKs when load a sequence of bitmaps. +- add menu customization through UI (Tools/Customize). - Mateusz Czaplinski ideas: + when move selections, will be good the possibility to see relative position from the starting point of movement; diff --git a/data/defgui-en.xml b/data/gui-en.xml similarity index 95% rename from data/defgui-en.xml rename to data/gui-en.xml index 2718f589d..3dd865ce2 100644 --- a/data/defgui-en.xml +++ b/data/gui-en.xml @@ -21,8 +21,6 @@ - - @@ -99,9 +97,6 @@ - - - diff --git a/data/defgui-es.xml b/data/gui-es.xml similarity index 100% rename from data/defgui-es.xml rename to data/gui-es.xml diff --git a/jinete/src/jtheme.c b/jinete/src/jtheme.c index 63a7a418a..caf332afc 100644 --- a/jinete/src/jtheme.c +++ b/jinete/src/jtheme.c @@ -146,7 +146,6 @@ void ji_set_standard_theme(void) { if (!ji_standard_theme) { ji_standard_theme = jtheme_new_standard(); -/* ji_standard_theme = jtheme_new_simple(); */ if (!ji_standard_theme) return; } diff --git a/jinete/src/themes/jsimple.c b/jinete/src/themes/jsimple.c index c8c1a7bdb..a2223bc68 100644 --- a/jinete/src/themes/jsimple.c +++ b/jinete/src/themes/jsimple.c @@ -35,39 +35,95 @@ #include "jinete.h" #include "jinete/intern.h" -#define CHARACTER_LENGTH(f, c) ((f)->vtable->char_length ((f), (c))) +/* data related */ +#include "stdicons.c" +#include "pcx2data.c" -static void theme_destroy (void); -static void theme_regen (void); -static BITMAP *theme_set_cursor (int type, int *focus_x, int *focus_y); -static void theme_init_widget (JWidget widget); -static JRegion theme_get_window_mask (JWidget widget); -static void theme_map_decorative_widget (JWidget widget); -static void theme_draw_box (JWidget widget); -static void theme_draw_button (JWidget widget); -static void theme_draw_check (JWidget widget); -static void theme_draw_entry (JWidget widget); -static void theme_draw_label (JWidget widget); -static void theme_draw_listbox (JWidget widget); -static void theme_draw_listitem (JWidget widget); -static void theme_draw_menu (JWidget widget); -static void theme_draw_menuitem (JWidget widget); -static void theme_draw_panel (JWidget widget); -static void theme_draw_radio (JWidget widget); -static void theme_draw_separator (JWidget widget); -static void theme_draw_slider (JWidget widget); -static void theme_draw_textbox (JWidget widget); -static void theme_draw_view (JWidget widget); -static void theme_draw_view_scrollbar (JWidget widget); -static void theme_draw_view_viewport (JWidget widget); -static void theme_draw_window (JWidget widget); +#define CHARACTER_LENGTH(f, c) ((f)->vtable->char_length ((f), (c))) -static void draw_entry_cursor (JWidget widget, int x, int y); -static void get_colors (JWidget widget, int *fg, int *bg); +#define BGCOLOR (get_bg_color(widget)) + +/* "icons_data" indexes */ +enum { + FIRST_CURSOR = 0, + LAST_CURSOR = 11, + ICON_CHECK_EDGE = 12, + ICON_CHECK_MARK, + ICON_CLOSE, + ICON_MENU_MARK, + ICON_RADIO_EDGE, + ICON_RADIO_MARK, + ICONS, +}; + +static struct { + bool mask : 1; + unsigned char *data; +} icons_data[ICONS] = { + { FALSE, default_theme_cnormal }, + { FALSE, default_theme_cnoradd }, + { FALSE, default_theme_chand }, + { FALSE, default_theme_cmove }, + { FALSE, default_theme_csizetl }, + { FALSE, default_theme_csizet }, + { FALSE, default_theme_csizetr }, + { FALSE, default_theme_csizel }, + { FALSE, default_theme_csizer }, + { FALSE, default_theme_csizebl }, + { FALSE, default_theme_csizeb }, + { FALSE, default_theme_csizebr }, + { FALSE, default_theme_ichecke }, + { FALSE, default_theme_icheckm }, + { FALSE, default_theme_iclose }, + { TRUE, default_theme_imenum }, + { FALSE, default_theme_iradioe }, + { FALSE, default_theme_iradiom }, +}; + +static BITMAP *icons_bitmap[ICONS] = { + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, +}; + +static void theme_destroy(void); +static void theme_regen(void); +static BITMAP *theme_set_cursor(int type, int *focus_x, int *focus_y); +static void theme_init_widget(JWidget widget); +static JRegion theme_get_window_mask(JWidget widget); +static void theme_map_decorative_widget(JWidget widget); +static void theme_draw_box(JWidget widget); +static void theme_draw_button(JWidget widget); +static void theme_draw_check(JWidget widget); +static void theme_draw_entry(JWidget widget); +static void theme_draw_label(JWidget widget); +static void theme_draw_listbox(JWidget widget); +static void theme_draw_listitem(JWidget widget); +static void theme_draw_menu(JWidget widget); +static void theme_draw_menuitem(JWidget widget); +static void theme_draw_panel(JWidget widget); +static void theme_draw_radio(JWidget widget); +static void theme_draw_separator(JWidget widget); +static void theme_draw_slider(JWidget widget); +static void theme_draw_textbox(JWidget widget); +static void theme_draw_view(JWidget widget); +static void theme_draw_view_scrollbar(JWidget widget); +static void theme_draw_view_viewport(JWidget widget); +static void theme_draw_window(JWidget widget); + +static int get_bg_color(JWidget widget); +static void draw_textstring(const char *t, int fg_color, int bg_color, + bool fill_bg, JWidget widget, const JRect rect, + int selected_offset); +static void draw_entry_cursor(JWidget widget, int x, int y); +static void draw_icons(int x, int y, JWidget widget, int edge_icon); +static void draw_bevel_box(int x1, int y1, int x2, int y2, int c1, int c2, int *bevel); +static void draw_round_rect(int x1, int y1, int x2, int y2, int radius_w, int radius_h, int color); +static void fill_round_rect(int x1, int y1, int x2, int y2, int radius_w, int radius_h, int color); +static void less_bevel(int *bevel); static bool theme_button_msg_proc (JWidget widget, JMessage msg); -JTheme jtheme_new_simple (void) +JTheme jtheme_new_simple(void) { JTheme theme; @@ -78,7 +134,7 @@ JTheme jtheme_new_simple (void) theme->name = "Simple Theme"; theme->check_icon_size = 8; theme->radio_icon_size = 8; - theme->scrollbar_size = 10; + theme->scrollbar_size = 12; theme->destroy = theme_destroy; theme->regen = theme_regen; @@ -87,49 +143,118 @@ JTheme jtheme_new_simple (void) theme->get_window_mask = theme_get_window_mask; theme->map_decorative_widget = theme_map_decorative_widget; - jtheme_set_method (theme, JI_BOX, theme_draw_box); - jtheme_set_method (theme, JI_BUTTON, theme_draw_button); - jtheme_set_method (theme, JI_CHECK, theme_draw_check); - jtheme_set_method (theme, JI_ENTRY, theme_draw_entry); - jtheme_set_method (theme, JI_LABEL, theme_draw_label); - jtheme_set_method (theme, JI_LISTBOX, theme_draw_listbox); - jtheme_set_method (theme, JI_LISTITEM, theme_draw_listitem); - jtheme_set_method (theme, JI_MENU, theme_draw_menu); - jtheme_set_method (theme, JI_MENUITEM, theme_draw_menuitem); - jtheme_set_method (theme, JI_PANEL, theme_draw_panel); - jtheme_set_method (theme, JI_RADIO, theme_draw_radio); - jtheme_set_method (theme, JI_SEPARATOR, theme_draw_separator); - jtheme_set_method (theme, JI_SLIDER, theme_draw_slider); - jtheme_set_method (theme, JI_TEXTBOX, theme_draw_textbox); - jtheme_set_method (theme, JI_VIEW, theme_draw_view); - jtheme_set_method (theme, JI_VIEW_SCROLLBAR, theme_draw_view_scrollbar); - jtheme_set_method (theme, JI_VIEW_VIEWPORT, theme_draw_view_viewport); - jtheme_set_method (theme, JI_WINDOW, theme_draw_window); + jtheme_set_method(theme, JI_BOX, theme_draw_box); + jtheme_set_method(theme, JI_BUTTON, theme_draw_button); + jtheme_set_method(theme, JI_CHECK, theme_draw_check); + jtheme_set_method(theme, JI_ENTRY, theme_draw_entry); + jtheme_set_method(theme, JI_LABEL, theme_draw_label); + jtheme_set_method(theme, JI_LISTBOX, theme_draw_listbox); + jtheme_set_method(theme, JI_LISTITEM, theme_draw_listitem); + jtheme_set_method(theme, JI_MENU, theme_draw_menu); + jtheme_set_method(theme, JI_MENUITEM, theme_draw_menuitem); + jtheme_set_method(theme, JI_PANEL, theme_draw_panel); + jtheme_set_method(theme, JI_RADIO, theme_draw_radio); + jtheme_set_method(theme, JI_SEPARATOR, theme_draw_separator); + jtheme_set_method(theme, JI_SLIDER, theme_draw_slider); + jtheme_set_method(theme, JI_TEXTBOX, theme_draw_textbox); + jtheme_set_method(theme, JI_VIEW, theme_draw_view); + jtheme_set_method(theme, JI_VIEW_SCROLLBAR, theme_draw_view_scrollbar); + jtheme_set_method(theme, JI_VIEW_VIEWPORT, theme_draw_view_viewport); + jtheme_set_method(theme, JI_WINDOW, theme_draw_window); return theme; } static void theme_destroy (void) { + int c; + + for (c=0; cdesktop_color = makecol(255,255,255); - theme->textbox_fg_color = makecol(0,0,0); - theme->textbox_bg_color = makecol(255,255,255); + theme->desktop_color = makecol(255, 255, 255); + theme->textbox_fg_color = makecol(0, 0, 0); + theme->textbox_bg_color = makecol(255, 255, 255); + + /* fixup cursors */ + + cmap[0] = bitmap_mask_color(ji_screen); + cmap[1] = makecol(0, 0, 0); + cmap[2] = makecol(128, 128, 128); + cmap[3] = makecol(255, 255, 255); + cmap[4] = makecol(192, 192, 192); + cmap[5] = makecol(224, 224, 224); + + mask_cmap[0] = 0; + mask_cmap[1] = 1; + + for (c=0; c= FIRST_CURSOR && icon_index <= LAST_CURSOR) { + if (icons_bitmap[icon_index]) + sprite = icons_bitmap[icon_index]; + + switch (type) { + case JI_CURSOR_NULL: + case JI_CURSOR_NORMAL: + case JI_CURSOR_NORMAL_ADD: + *focus_x = 0; + *focus_y = 0; + break; + case JI_CURSOR_HAND: + *focus_x = 5; + *focus_y = 3; + break; + case JI_CURSOR_MOVE: + *focus_x = 8; + *focus_y = 8; + break; + case JI_CURSOR_SIZE_TL: + case JI_CURSOR_SIZE_T: + case JI_CURSOR_SIZE_TR: + case JI_CURSOR_SIZE_L: + case JI_CURSOR_SIZE_R: + case JI_CURSOR_SIZE_BL: + case JI_CURSOR_SIZE_B: + case JI_CURSOR_SIZE_BR: + *focus_x = 8; + *focus_y = 8; + break; + } + } + + return sprite; } -static void theme_init_widget (JWidget widget) +static void theme_init_widget(JWidget widget) { #define BORDER(n) \ widget->border_width.l = n; \ @@ -151,56 +276,59 @@ static void theme_init_widget (JWidget widget) case JI_BOX: BORDER(0); - widget->child_spacing = -1; +/* widget->child_spacing = 2; */ + widget->child_spacing = 4; break; case JI_BUTTON: - BORDER4(2, 2, 2, 3); + BORDER(4); widget->child_spacing = 0; break; case JI_CHECK: BORDER(2); - widget->child_spacing = 1; +/* widget->child_spacing = 2; */ + widget->child_spacing = 4; break; case JI_ENTRY: - BORDER(2); + BORDER(3); break; case JI_LABEL: - BORDER(2); + BORDER(1); break; case JI_LISTBOX: - BORDER (0); + BORDER(0); widget->child_spacing = 0; break; case JI_LISTITEM: - BORDER (0); + BORDER(1); break; case JI_MENU: case JI_MENUBAR: case JI_MENUBOX: - BORDER (0); + BORDER(0); widget->child_spacing = 0; break; case JI_MENUITEM: - BORDER (0); + BORDER(2); widget->child_spacing = 18; break; case JI_PANEL: - BORDER (0); + BORDER(0); widget->child_spacing = 3; break; case JI_RADIO: - BORDER (2); - widget->child_spacing = 1; + BORDER(2); +/* widget->child_spacing = 2; */ + widget->child_spacing = 4; break; case JI_SEPARATOR: @@ -227,58 +355,54 @@ static void theme_init_widget (JWidget widget) break; case JI_SLIDER: - BORDER (4); + BORDER(4); widget->child_spacing = jwidget_get_text_height (widget); break; case JI_TEXTBOX: - BORDER (2); + BORDER(2); widget->child_spacing = 0; break; case JI_VIEW: - BORDER (1); + BORDER(2); widget->child_spacing = 0; break; case JI_VIEW_SCROLLBAR: - if (widget->align & JI_HORIZONTAL) { - BORDER4 (0, 1, 0, 0); - } - else { - BORDER4 (1, 0, 0, 0); - } + BORDER(1); widget->child_spacing = 0; break; case JI_VIEW_VIEWPORT: - BORDER (0); + BORDER(0); widget->child_spacing = 0; break; case JI_WINDOW: if (!jwindow_is_desktop (widget)) { if (widget->text) { - BORDER4 (3, 2+jwidget_get_text_height (widget)+1, 3, 3); + BORDER4(6, 4+jwidget_get_text_height(widget)+6, 6, 6); #if 1 /* add close button */ if (!(widget->flags & JI_INITIALIZED)) { - JWidget button = jbutton_new ("x"); - jwidget_add_hook (button, JI_WIDGET, - theme_button_msg_proc, NULL); - jwidget_decorative (button, TRUE); - jwidget_add_child (widget, button); - jwidget_set_name (button, "theme_close_button"); + JWidget button = jbutton_new("x"); + jbutton_set_bevel(button, 0, 0, 0, 0); + jwidget_add_hook(button, JI_WIDGET, + theme_button_msg_proc, NULL); + jwidget_decorative(button, TRUE); + jwidget_add_child(widget, button); + jwidget_set_name(button, "theme_close_button"); } #endif } else if (!(widget->flags & JI_INITIALIZED)) { - BORDER (3); + BORDER(3); } } else { BORDER (0); } - widget->child_spacing = 2; + widget->child_spacing = 4; break; default: @@ -293,140 +417,235 @@ static JRegion theme_get_window_mask (JWidget widget) static void theme_map_decorative_widget (JWidget widget) { - if (ustrcmp (widget->name, "theme_close_button") == 0) { + if (ustrcmp(widget->name, "theme_close_button") == 0) { JWidget window = widget->parent; - JRect rect = jrect_new (0, 0, 0, 0); + JRect rect = jrect_new(0, 0, 0, 0); - rect->x2 = 2 + jwidget_get_text_height (widget) + 2; - rect->y2 = 2 + jwidget_get_text_height (widget) + 2; + rect->x2 = jwidget_get_text_height(widget) + 2; + rect->y2 = jwidget_get_text_height(widget) + 2; - jrect_displace (rect, - window->rc->x2 - jrect_w(rect), - window->rc->y1); + jrect_displace(rect, + window->rc->x2 - 4 - jrect_w(rect), + window->rc->y1 + 4); - jwidget_set_rect (widget, rect); - jrect_free (rect); + jwidget_set_rect(widget, rect); + jrect_free(rect); } } -static void theme_draw_box (JWidget widget) +static void theme_draw_box(JWidget widget) { - int fg, bg; - - get_colors(widget, &fg, &bg); - jdraw_rectfill(widget->rc, bg); + jdraw_rectfill (widget->rc, BGCOLOR); } -static void theme_draw_button (JWidget widget) +static void theme_draw_button(JWidget widget) { BITMAP *icon_bmp = ji_generic_button_get_icon(widget); int icon_align = ji_generic_button_get_icon_align(widget); - JRect pos = jwidget_get_rect(widget); struct jrect box, text, icon; - int fg, bg; + int x1, y1, x2, y2; + int fg, bg/* , c1, c2 */; + int bevel[4]; + JRect crect; - get_colors(widget, &fg, &bg); jwidget_get_texticon_info(widget, &box, &text, &icon, icon_align, icon_bmp ? icon_bmp->w : 0, icon_bmp ? icon_bmp->h : 0); - /* border */ - jdraw_rect(pos, makecol(0,0,0)); - jrect_shrink(pos, 1); + /* with mouse */ +/* if (jwidget_has_mouse(widget)) */ +/* bg = makecol(143, 158, 211); */ + /* without mouse */ + if (jwidget_is_disabled(widget)) { + fg = makecol(255, 255, 255); + bg = makecol(210, 230, 220); + } + else { + fg = jwidget_has_mouse(widget) ? makecol(255, 255, 255): makecol(143, 158, 211); + bg = jwidget_has_mouse(widget) ? makecol(143, 158, 211): makecol(255, 255, 255); + } + + /* selected */ +/* if (jwidget_is_selected(widget)) { */ +/* c1 = makecol(128, 128, 128); */ +/* c2 = makecol(255, 255, 255); */ +/* } */ +/* /\* non-selected *\/ */ +/* else { */ +/* c1 = makecol(255, 255, 255); */ +/* c2 = makecol(128, 128, 128); */ +/* } */ + + /* widget position */ + x1 = widget->rc->x1; + y1 = widget->rc->y1; + x2 = widget->rc->x2-1; + y2 = widget->rc->y2-1; + + /* extern background */ + rectfill(ji_screen, x1, y1, x2, y2, BGCOLOR); /* background */ - jdraw_rectfill(pos, bg); + fill_round_rect(x1, y1, x2, y2, 6, 6, bg); + if (!jwidget_has_mouse(widget)) + draw_round_rect(x1, y1, x2, y2, 6, 6, fg); + + /* get bevel info */ +/* jbutton_get_bevel(widget, bevel); */ + + /* 1st border */ +/* if (jwidget_has_focus(widget)) */ +/* draw_bevel_box(x1, y1, x2, y2, */ +/* makecol(0, 0, 0), makecol(0, 0, 0), bevel); */ +/* else { */ +/* less_bevel(bevel); */ +/* draw_bevel_box(x1, y1, x2, y2, c1, c2, bevel); */ +/* } */ + +/* less_bevel(bevel); */ + + /* 2nd border */ +/* x1++, y1++, x2--, y2--; */ +/* if (jwidget_has_focus(widget)) */ +/* draw_bevel_box(x1, y1, x2, y2, c1, c2, bevel); */ +/* else */ +/* draw_bevel_box(x1, y1, x2, y2, bg, bg, bevel); */ + +/* less_bevel(bevel); */ + + /* more borders */ +/* while ((bevel[0] > 0) || (bevel[1] > 0) || */ +/* (bevel[2] > 0) || (bevel[3] > 0)) { */ +/* x1++, y1++, x2--, y2--; */ +/* draw_bevel_box(x1, y1, x2, y2, bg, bg, bevel); */ +/* less_bevel(bevel); */ +/* } */ + + /* background */ + x1++, y1++, x2--, y2--; +/* rectfill(ji_screen, x1, y1, x2, y2, bg); */ /* text */ - if (widget->text) - jdraw_text(widget->text_font, widget->text, - text.x1, text.y1, fg, bg, FALSE); + crect = jwidget_get_child_rect(widget); + draw_textstring(NULL, fg, bg, FALSE, widget, crect, 1); + jrect_free(crect); /* icon */ if (icon_bmp) { - if (jwidget_is_enabled(widget)) - draw_sprite(ji_screen, icon_bmp, icon.x1, icon.y1); - else - _ji_theme_draw_sprite_color(ji_screen, icon_bmp, icon.x1, icon.y1, fg); - } + if (jwidget_is_selected(widget)) + jrect_displace(&icon, 1, 1); - jrect_free(pos); + if (jwidget_is_enabled (widget)) + draw_sprite(ji_screen, icon_bmp, icon.x1, icon.y1); + else { + _ji_theme_draw_sprite_color(ji_screen, icon_bmp, icon.x1+1, icon.y1+1, + makecol(255, 255, 255)); + _ji_theme_draw_sprite_color(ji_screen, icon_bmp, icon.x1, icon.y1, + makecol(128, 128, 128)); + } + } } -static void theme_draw_check (JWidget widget) +static void theme_draw_check(JWidget widget) { struct jrect box, text, icon; - int fg, bg; + int bg; - get_colors (widget, &fg, &bg); jwidget_get_texticon_info(widget, &box, &text, &icon, ji_generic_button_get_icon_align(widget), widget->theme->check_icon_size, widget->theme->check_icon_size); /* background */ - jdraw_rectfill (widget->rc, bg); + jdraw_rectfill (widget->rc, bg = BGCOLOR); + + /* mouse */ + if (jwidget_has_mouse (widget)) + jdraw_rectfill (&box, bg = makecol (224, 224, 224)); /* focus */ - /* XXX */ + if (jwidget_has_focus (widget)) { + jrect_stretch (&box, 1); + jdraw_rect (&box, makecol (0, 0, 0)); + } /* text */ - jdraw_text(widget->text_font, widget->text, - text.x1, text.y1, fg, bg, FALSE); + draw_textstring (NULL, -1, bg, FALSE, widget, &text, 0); /* icon */ - jdraw_rect(&icon, fg); - jrect_shrink(&icon, 1); - if (jwidget_is_selected(widget)) { - line(ji_screen, icon.x1, icon.y1, icon.x2-1, icon.y2-1, fg); - line(ji_screen, icon.x1, icon.y2-1, icon.x2-1, icon.y1, fg); - } + draw_icons (icon.x1, icon.y1, widget, ICON_CHECK_EDGE); } -static void theme_draw_entry (JWidget widget) +static void theme_draw_entry(JWidget widget) { - JRect rect = jwidget_get_rect (widget); bool password = jentry_is_password (widget); int scroll, cursor, state, selbeg, selend; - int c, ch, x, y, w, fg, bg, cfg, cbg; const char *text = widget->text; + int c, ch, x, y, w, fg, bg; + int x1, y1, x2, y2; int cursor_x; - get_colors (widget, &fg, &bg); jtheme_entry_info (widget, &scroll, &cursor, &state, &selbeg, &selend); - /* border */ - jdraw_rect (rect, fg); - jrect_shrink (rect, 1); + /* main pos */ + x1 = widget->rc->x1; + y1 = widget->rc->y1; + x2 = widget->rc->x2 - 1; + y2 = widget->rc->y2 - 1; - /* background */ - jdraw_rectfill (rect, bg); + bg = makecol (255, 255, 255); + + /* 1st border */ + _ji_theme_rectedge (ji_screen, x1, y1, x2, y2, + makecol (128, 128, 128), makecol (255, 255, 255)); + + /* 2nd border */ + x1++, y1++, x2--, y2--; + if (jwidget_has_focus (widget)) + rect (ji_screen, x1, y1, x2, y2, makecol (0, 0, 0)); + else + rect (ji_screen, x1, y1, x2, y2, BGCOLOR); + + /* background border */ + x1++, y1++, x2--, y2--; + rectfill (ji_screen, x1, y1, x2, y2, bg); /* draw the text */ - x = rect->x1; - y = rect->y1; + x = widget->rc->x1 + widget->border_width.l; + y = (widget->rc->y1+widget->rc->y2)/2 - jwidget_get_text_height (widget)/2; for (c=scroll; ugetat (text, c); c++) { ch = password ? '*': ugetat (text, c); + /* normal text */ + bg = -1; + fg = makecol (0, 0, 0); + + /* selected */ if ((c >= selbeg) && (c <= selend)) { - cbg = fg; - cfg = bg; + if (jwidget_has_focus (widget)) + bg = makecol (44, 76, 145); + else + bg = makecol (128, 128, 128); + fg = makecol (255, 255, 255); } - else { - cbg = bg; - cfg = fg; + + /* disabled */ + if (jwidget_is_disabled (widget)) { + bg = -1; + fg = makecol (128, 128, 128); } w = CHARACTER_LENGTH (widget->text_font, ch); - if (x+w >= rect->x2) + if (x+w > widget->rc->x2-3) return; cursor_x = x; - ji_font_set_aa_mode (widget->text_font, cbg); + ji_font_set_aa_mode (widget->text_font, + bg >= 0 ? bg: makecol (255, 255, 255)); widget->text_font->vtable->render_char (widget->text_font, - ch, cfg, cbg, ji_screen, x, y); + ch, fg, bg, ji_screen, x, y); x += w; /* cursor */ @@ -439,63 +658,76 @@ static void theme_draw_entry (JWidget widget) (jwidget_has_focus (widget)) && (jwidget_is_enabled (widget))) draw_entry_cursor (widget, x, y); - - jrect_free (rect); } -static void theme_draw_label (JWidget widget) +static void theme_draw_label(JWidget widget) { - JRect rect = jwidget_get_rect (widget); - struct jrect text; - int fg, bg; + int bg = BGCOLOR; - get_colors(widget, &fg, &bg); - jwidget_get_texticon_info(widget, NULL, &text, NULL, 0, 0, 0); + jdraw_rectfill (widget->rc, bg); - jdraw_rect(rect, makecol(0,0,0)); - jrect_shrink(rect, 1); - - jdraw_rectfill(rect, bg); - jdraw_text(widget->text_font, widget->text, - text.x1, text.y1, fg, bg, FALSE); - - jrect_free(rect); + draw_textstring (NULL, -1, bg, FALSE, widget, widget->rc, 0); } static void theme_draw_listbox(JWidget widget) { - int fg, bg; + int bg; - get_colors(widget, &fg, &bg); - jdraw_rectfill(widget->rc, bg); + if (jwidget_is_disabled (widget)) + bg = makecol (192, 192, 192); + else + bg = makecol (255, 255, 255); + + jdraw_rectfill (widget->rc, makecol (255, 255, 255)); } -static void theme_draw_listitem (JWidget widget) +static void theme_draw_listitem(JWidget widget) { - JRect rect = jwidget_get_rect (widget); int fg, bg; + int x, y; - get_colors(widget, &fg, &bg); - jdraw_rectfill(rect, bg); + if (jwidget_is_disabled (widget)) { + bg = makecol (192, 192, 192); + fg = makecol (128, 128, 128); + } + else if (jwidget_is_selected (widget)) { + bg = makecol (44, 76, 145); + fg = makecol (255, 255, 255); + } + else { + bg = makecol (255, 255, 255); + fg = makecol (0, 0, 0); + } - if (widget->text) - jdraw_text(widget->text_font, widget->text, - rect->x1, rect->y1, fg, bg, TRUE); + x = widget->rc->x1+widget->border_width.l; + y = widget->rc->y1+widget->border_width.t; - jrect_free(rect); + if (widget->text) { + /* text */ + jdraw_text(widget->text_font, widget->text, x, y, fg, bg, TRUE); + + /* background */ + _ji_theme_rectfill_exclude + (ji_screen, + widget->rc->x1, widget->rc->y1, + widget->rc->x2-1, widget->rc->y2-1, + x, y, + x+jwidget_get_text_length(widget)-1, + y+jwidget_get_text_height(widget)-1, bg); + } + /* background */ + else { + jdraw_rectfill(widget->rc, bg); + } } static void theme_draw_menu (JWidget widget) { - int fg, bg; - - get_colors (widget, &fg, &bg); - jdraw_rectfill (widget->rc, bg); + jdraw_rectfill (widget->rc, BGCOLOR); } static void theme_draw_menuitem (JWidget widget) { -#if 0 int c, bg, fg, bar; int x1, y1, x2, y2; JRect pos; @@ -513,16 +745,16 @@ static void theme_draw_menuitem (JWidget widget) } else { if (jmenuitem_is_highlight (widget)) { - bg = makecol(44,76,145); - fg = makecol(255,255,255); + bg = makecol (44, 76, 145); + fg = makecol (255, 255, 255); } else if (jwidget_has_mouse (widget)) { - bg = makecol(224,224,224); - fg = makecol(0,0,0); + bg = makecol (224, 224, 224); + fg = makecol (0, 0, 0); } else { bg = BGCOLOR; - fg = makecol(0,0,0); + fg = makecol (0, 0, 0); } } @@ -532,27 +764,20 @@ static void theme_draw_menuitem (JWidget widget) x2 = widget->rc->x2-1; y2 = widget->rc->y2-1; - /* border */ - if ((jwidget_is_enabled (widget)) && - (jmenuitem_is_highlight (widget))) { - rect (ji_screen, x1, y1, x2, y2, makecol (0, 0, 0)); - x1++, y1++, x2--, y2--; - } - /* background */ rectfill (ji_screen, x1, y1, x2, y2, bg); /* draw an indicator for selected items */ if (jwidget_is_selected (widget)) { BITMAP *icon = icons_bitmap[ICON_MENU_MARK]; - int x = widget->rc->x+4-icon->w/2; - int y = widget->rc->y+widget->rc->h/2-icon->h/2; + int x = widget->rc->x1+4-icon->w/2; + int y = (widget->rc->y1+widget->rc->y2)/2-icon->h/2; - if (jwidget_is_enabled (widget)) - draw_character (ji_screen, icon, x, y, fg); + if (jwidget_is_enabled(widget)) + draw_character(ji_screen, icon, x, y, fg); else { - draw_character (ji_screen, icon, x+1, y+1, makecol (255, 255, 255)); - draw_character (ji_screen, icon, x, y, makecol (128, 128, 128)); + draw_character(ji_screen, icon, x+1, y+1, makecol (255, 255, 255)); + draw_character(ji_screen, icon, x, y, makecol (128, 128, 128)); } } @@ -564,7 +789,7 @@ static void theme_draw_menuitem (JWidget widget) pos = jwidget_get_rect (widget); if (!bar) - pos->x += widget->child_spacing/2; + jrect_displace (pos, widget->child_spacing/2, 0); draw_textstring (NULL, fg, bg, FALSE, widget, pos, 0); jrect_free (pos); @@ -576,22 +801,22 @@ static void theme_draw_menuitem (JWidget widget) if (jwidget_is_enabled (widget)) { for (c=0; c<3; c++) vline (ji_screen, - widget->rect->x+widget->rect->w-3-c, - widget->rect->y+widget->rect->h/2-c, - widget->rect->y+widget->rect->h/2+c, fg); + widget->rc->x2-3-c, + (widget->rc->y1+widget->rc->y2)/2-c, + (widget->rc->y1+widget->rc->y2)/2+c, fg); } /* disabled */ else { for (c=0; c<3; c++) vline (ji_screen, - widget->rect->x+widget->rect->w-3-c+1, - widget->rect->y+widget->rect->h/2-c+1, - widget->rect->y+widget->rect->h/2+c+1, makecol (255, 255, 255)); + widget->rc->x2-3-c+1, + (widget->rc->y1+widget->rc->y2)/2-c+1, + (widget->rc->y1+widget->rc->y2)/2+c+1, makecol (255, 255, 255)); for (c=0; c<3; c++) vline (ji_screen, - widget->rect->x+widget->rect->w-3-c, - widget->rect->y+widget->rect->h/2-c, - widget->rect->y+widget->rect->h/2+c, makecol (128, 128, 128)); + widget->rc->x2-3-c, + (widget->rc->y1+widget->rc->y2)/2-c, + (widget->rc->y1+widget->rc->y2)/2+c, makecol (128, 128, 128)); } } /* draw the keyboard shortcut */ @@ -600,7 +825,7 @@ static void theme_draw_menuitem (JWidget widget) char buf[256]; pos = jwidget_get_rect (widget); - pos->w -= widget->child_spacing/4; + pos->x2 -= widget->child_spacing/4; jaccel_to_string (jmenuitem_get_accel (widget), buf); @@ -611,52 +836,95 @@ static void theme_draw_menuitem (JWidget widget) jrect_free (pos); } } -#endif } static void theme_draw_panel (JWidget widget) { - JRect rect = jwidget_get_rect (widget); - int fg, bg; + JWidget c1, c2; + JLink link; + int c; - get_colors (widget, &fg, &bg); - jdraw_rect (rect, fg); - jrect_shrink (rect, 1); - jdraw_rectfill (rect, bg); +/* jdraw_rectfill(widget->rc, */ +/* (jwidget_pick(widget, */ +/* ji_mouse_x(0), */ +/* ji_mouse_y(0)) == widget) ? */ +/* makecol (224, 224, 224): makecol (192, 192, 192)); */ + jdraw_rectfill(widget->rc, makecol (192, 192, 192)); - jrect_free (rect); + JI_LIST_FOR_EACH(widget->children, link) { + if (link->next != widget->children->end) { + c1 = (JWidget)link->data; + c2 = (JWidget)link->next->data; + + if (widget->align & JI_HORIZONTAL) { +/* vline (ji_screen, */ +/* (c1->pos->x+c1->pos->w+c2->pos->x-1)/2, */ +/* widget->rect->y, */ +/* widget->rect->y+widget->rect->h/2-4, makecol (0, 0, 0)); */ + +/* vline (ji_screen, */ +/* (c1->pos->x+c1->pos->w+c2->pos->x-1)/2, */ +/* widget->rect->y+widget->rect->h/2+4, */ +/* widget->rect->y+widget->rect->h-1, makecol (0, 0, 0)); */ + + for (c=-4; c<=4; c+=2) + hline(ji_screen, + c1->rc->x2+2, + (widget->rc->y1+widget->rc->y2)/2+c, + c2->rc->x1-3, makecol(0, 0, 0)); + } + else { +/* hline (ji_screen, */ +/* widget->rect->x, */ +/* (c1->pos->y+c1->pos->h+c2->pos->y-1)/2, */ +/* widget->rect->x+widget->rect->w/2-4, makecol (0, 0, 0)); */ + +/* hline (ji_screen, */ +/* widget->rect->x+widget->rect->w/2+4, */ +/* (c1->pos->y+c1->pos->h+c2->pos->y-1)/2, */ +/* widget->rect->x+widget->rect->w-1, makecol (0, 0, 0)); */ + + for (c=-4; c<=4; c+=2) + vline(ji_screen, + (widget->rc->x1+widget->rc->x2)/2+c, + c1->rc->y2+2, + c2->rc->y1-3, makecol(0, 0, 0)); + } + } + } } static void theme_draw_radio (JWidget widget) { struct jrect box, text, icon; - int fg, bg; + int bg = BGCOLOR; - get_colors(widget, &fg, &bg); jwidget_get_texticon_info(widget, &box, &text, &icon, ji_generic_button_get_icon_align(widget), - widget->theme->check_icon_size, - widget->theme->check_icon_size); + widget->theme->radio_icon_size, + widget->theme->radio_icon_size); /* background */ - jdraw_rectfill(widget->rc, bg); + jdraw_rectfill (widget->rc, bg); + + /* mouse */ + if (jwidget_has_mouse (widget)) + jdraw_rectfill (&box, bg = makecol (224, 224, 224)); /* focus */ - /* XXX */ + if (jwidget_has_focus (widget)) + rect (ji_screen, box.x1-1, box.y1-1, box.x2, box.y2, + makecol (0, 0, 0)); /* text */ - jdraw_text(widget->text_font, widget->text, - text.x1, text.y1, fg, bg, FALSE); + draw_textstring (NULL, -1, bg, FALSE, widget, &text, 0); /* icon */ - circle(ji_screen, (icon.x1+icon.x2)/2, (icon.y1+icon.y2)/2, 4, fg); - if (jwidget_is_selected(widget)) - circlefill(ji_screen, (icon.x1+icon.x2)/2, (icon.y1+icon.y2)/2, 2, fg); + draw_icons (icon.x1, icon.y1, widget, ICON_RADIO_EDGE); } static void theme_draw_separator (JWidget widget) { -#if 0 int x1, y1, x2, y2; /* frame position */ @@ -666,9 +934,7 @@ static void theme_draw_separator (JWidget widget) y2 = widget->rc->y2 - 1 - widget->border_width.b/2; /* background */ - rectfill (ji_screen, widget->rect->x, widget->rect->y, - widget->rect->x + widget->rect->w - 1, - widget->rect->y + widget->rect->h - 1, BGCOLOR); + jdraw_rectfill (widget->rc, BGCOLOR); /* TOP line */ if (widget->align & JI_HORIZONTAL) { @@ -706,12 +972,30 @@ static void theme_draw_separator (JWidget widget) struct jrect r = { x1+h/2, y1-h/2, x2+1-h, y2+1+h }; draw_textstring (NULL, -1, BGCOLOR, FALSE, widget, &r, 0); } -#endif } +#if 1 +/* XXXX when Allegro 4.1 will be officially released, replace this + with the get_clip_rect, add_clip_rect, set_clip_rect functions */ +static int my_add_clip_rect (BITMAP *bitmap, int x1, int y1, int x2, int y2) +{ + int u1 = MAX (x1, bitmap->cl); + int v1 = MAX (y1, bitmap->ct); + int u2 = MIN (x2, bitmap->cr-1); + int v2 = MIN (y2, bitmap->cb-1); + + if (u1 > u2 || v1 > v2) + return FALSE; + else + set_clip(bitmap, u1, v1, u2, v2); + + return TRUE; +} +#endif + static void theme_draw_slider (JWidget widget) { -#if 0 +#if 1 int x, x1, y1, x2, y2, bg, c1, c2; int min, max, value; char buf[256]; @@ -719,10 +1003,10 @@ static void theme_draw_slider (JWidget widget) jtheme_slider_info (widget, &min, &max, &value); /* main pos */ - x1 = widget->rect->x; - y1 = widget->rect->y; - x2 = widget->rect->x + widget->rect->w - 1; - y2 = widget->rect->y + widget->rect->h - 1; + x1 = widget->rc->x1; + y1 = widget->rc->y1; + x2 = widget->rc->x2 - 1; + y2 = widget->rc->y2 - 1; /* with mouse */ if (jwidget_has_mouse (widget)) @@ -758,7 +1042,10 @@ static void theme_draw_slider (JWidget widget) /* progress bar */ x1++, y1++, x2--, y2--; - x = x1 + (x2-x1) * (value-min) / (max-min); + if (min != max) + x = x1 + (x2-x1) * (value-min) / (max-min); + else + x = x1; if (value == min) { rectfill (ji_screen, x1, y1, x2, y2, bg); @@ -778,12 +1065,12 @@ static void theme_draw_slider (JWidget widget) int cx1, cy1, cx2, cy2; JRect r; - usprintf (buf, "%d", value); + usprintf(buf, "%d", value); widget->align = JI_CENTER | JI_MIDDLE; widget->text = buf; - r = jrect_new (x1, y1, x2-x1+1, y2-y1+1); + r = jrect_new(x1, y1, x2+1, y2+1); /* XXXX when Allegro 4.1 will be officially released, replace this with the get_clip_rect, add_clip_rect, set_clip_rect functions */ @@ -793,102 +1080,304 @@ static void theme_draw_slider (JWidget widget) cx2 = ji_screen->cr-1; cy2 = ji_screen->cb-1; - if (my_add_clip_rect (ji_screen, x1, y1, x, y2)) - draw_textstring (NULL, makecol (255, 255, 255), - jwidget_is_disabled (widget) ? - bg: makecol (44, 76, 145), FALSE, widget, r, 0); + if (my_add_clip_rect(ji_screen, x1, y1, x, y2)) + draw_textstring(NULL, makecol(255, 255, 255), + jwidget_is_disabled(widget) ? + bg: makecol(44, 76, 145), FALSE, widget, r, 0); - set_clip (ji_screen, cx1, cy1, cx2, cy2); + set_clip(ji_screen, cx1, cy1, cx2, cy2); - if (my_add_clip_rect (ji_screen, x+1, y1, x2, y2)) - draw_textstring (NULL, makecol (0, 0, 0), bg, FALSE, widget, r, 0); + if (my_add_clip_rect(ji_screen, x+1, y1, x2, y2)) + draw_textstring(NULL, makecol (0, 0, 0), bg, FALSE, widget, r, 0); - set_clip (ji_screen, cx1, cy1, cx2, cy2); + set_clip(ji_screen, cx1, cy1, cx2, cy2); widget->text = old_text; - jrect_free (r); + jrect_free(r); } +#else + int min, max, value, bg, c1, c2; + char buf[256]; + JRect pos = jwidget_get_rect(widget); + + jtheme_slider_info(widget, &min, &max, &value); + + /* with mouse */ + if (jwidget_has_mouse(widget)) + bg = makecol(224, 224, 224); + /* without mouse */ + else + bg = makecol(192, 192, 192); + + /* 1st border */ + jdraw_rectedge(pos, makecol(128, 128, 128), makecol(255, 255, 255)); + + /* 2nd border */ + jrect_shrink(pos, 1); + if (jwidget_has_focus(widget)) + jdraw_rect(pos, makecol(0, 0, 0)); + else + jdraw_rect(pos, bg); + + /* 3rd border */ + if (!jwidget_is_selected (widget)) { + c1 = makecol(255, 255, 255); + c2 = makecol(128, 128, 128); + } + else { + c1 = makecol(128, 128, 128); + c2 = makecol(255, 255, 255); + } + + jrect_shrink(pos, 1); + jdraw_rectedge(pos, c1, c2); + + /* background and text */ + jrect_shrink(pos, 1); + + if (min != max) { + char *old_text = widget->text; + int x1, x2; + JRect rc; + + usprintf(buf, "%d", value); + widget->align = JI_CENTER | JI_MIDDLE; + widget->text = buf; + +#if 0 + x = pos->x1 + (pos->x2-pos->x1) * (value-min) / (max-min+1); + w = jwidget_get_text_length(widget)+2; + if (x-w/2 < pos->x1) { + x1 = pos->x1; + x2 = MIN(pos->x1+w, pos->x2); + } + else if (x+w/2 > pos->x2) { + x1 = pos->x2-w; + x2 = pos->x2; + } + else { + x1 = x-w/2; + x2 = x+w/2; + } +#else + if (max == min) { + x1 = pos->x1; + x2 = pos->x2; + } + else { + int x, w; + + w = ji_font_text_len(widget->text_font, "888"); + w = MAX(w, (pos->x2-pos->x1) / (max-min+1)); + x = pos->x1 + ((value-min) * w); + + x1 = x; + if (x1 < pos->x1) + x1 = pos->x1; + x2 = x+w; + if (x2 > pos->x2) + x1 = pos->x2-w; + } +#endif + rc = jrect_new(x1, pos->y1, x2, pos->y2); + + jdraw_rectfill(pos, bg); + jdraw_rectfill(rc, (jwidget_is_disabled(widget)) ? + bg: makecol(44, 76, 145)); + + draw_textstring(NULL, makecol(255, 255, 255), + jwidget_is_disabled(widget) ? + bg: makecol(44, 76, 145), FALSE, widget, rc, 0); + + jrect_free(rc); + widget->text = old_text; + } + + jrect_free(pos); #endif } -static void theme_draw_textbox (JWidget widget) +static void theme_draw_textbox(JWidget widget) { - _ji_theme_textbox_draw (ji_screen, widget, NULL, NULL); + _ji_theme_textbox_draw(ji_screen, widget, NULL, NULL); } -static void theme_draw_view (JWidget widget) +static void theme_draw_view(JWidget widget) { - JRect pos = jwidget_get_rect(widget); - int fg, bg; + JRect pos = jwidget_get_rect (widget); - get_colors(widget, &fg, &bg); - jdraw_rect(pos, fg); + if (jwidget_has_focus(widget)) { + /* 1st border */ + jdraw_rectedge(pos, makecol (128, 128, 128), makecol (255, 255, 255)); + + /* 2nd border */ + jrect_shrink(pos, 1); + jdraw_rect(pos, makecol (0, 0, 0)); + } + else { + /* 1st border */ + jdraw_rectedge(pos, makecol (128, 128, 128), makecol (255, 255, 255)); + + /* 2nd border */ + jrect_shrink(pos, 1); + jdraw_rect(pos, BGCOLOR); + } + + /* background */ jrect_shrink(pos, 1); - jdraw_rectfill(pos, bg); - jrect_replace(pos, - widget->rc->x2-widget->theme->scrollbar_size-1, - widget->rc->y2-widget->theme->scrollbar_size-1, - widget->rc->x2, widget->rc->y2); - jdraw_rect(pos, fg); - jrect_free(pos); + jdraw_rectfill(pos, BGCOLOR); + + jrect_free (pos); } static void theme_draw_view_scrollbar (JWidget widget) { - JRect rect = jwidget_get_rect(widget); - JRect cpos = jwidget_get_child_rect(widget); + int x1, y1, x2, y2; + int u1, v1, u2, v2; int pos, len; - int fg, bg; - get_colors(widget, &fg, &bg); - jtheme_scrollbar_info(widget, &pos, &len); + jtheme_scrollbar_info (widget, &pos, &len); - jdraw_rect(rect, makecol (0, 0, 0)); - jdraw_rectfill(cpos, bg); + x1 = widget->rc->x1; + y1 = widget->rc->y1; + x2 = widget->rc->x2-1; + y2 = widget->rc->y2-1; + + /* border */ + rect (ji_screen, x1, y1, x2, y2, BGCOLOR); + + /* draw the content */ + x1++, y1++, x2--, y2--; /* horizontal bar */ if (widget->align & JI_HORIZONTAL) { - cpos->x1 += pos; - cpos->x2 = cpos->x1+len; + u1 = x1+pos; + v1 = y1; + u2 = x1+pos+len-1; + v2 = y2; } /* vertical bar */ else { - cpos->y1 += pos; - cpos->y2 = cpos->y1+len; + u1 = x1; + v1 = y1+pos; + u2 = x2; + v2 = y1+pos+len-1; } - jdraw_rectfill(cpos, fg); - jrect_free(rect); - jrect_free(cpos); + /* background */ + _ji_theme_rectfill_exclude (ji_screen, + x1, y1, x2, y2, + u1, v1, u2, v2, BGCOLOR); + + /* 1st border */ + if (jwidget_is_selected (widget)) + _ji_theme_rectedge (ji_screen, u1, v1, u2, v2, + makecol (128, 128, 128), makecol (255, 255, 255)); + else + _ji_theme_rectedge (ji_screen, u1, v1, u2, v2, + makecol (255, 255, 255), makecol (128, 128, 128)); + + /* bar-block background */ + u1++, v1++, u2--, v2--; + if (jwidget_has_mouse (widget)) + rectfill (ji_screen, u1, v1, u2, v2, makecol (224, 224, 224)); + else + rectfill (ji_screen, u1, v1, u2, v2, BGCOLOR); +#if 0 + int x1, y1, x2, y2; + int u1, v1, u2, v2; + int pos, len; + + jtheme_scrollbar_info (widget, &pos, &len); + + x1 = widget->rc->x1; + y1 = widget->rc->y1; + x2 = widget->rc->x2-1; + y2 = widget->rc->y2-1; + + /* 1st border */ + _ji_theme_rectedge (ji_screen, x1, y1, x2, y2, + makecol (255, 255, 255), makecol (128, 128, 128)); + + /* 2nd border */ + x1++, y1++, x2--, y2--; + rect (ji_screen, x1, y1, x2, y2, BGCOLOR); + + /* draw the content */ + x1++, y1++, x2--, y2--; + + /* horizontal bar */ + if (widget->align & JI_HORIZONTAL) { + u1 = x1+pos; + v1 = y1; + u2 = x1+pos+len-1; + v2 = y2; + } + /* vertical bar */ + else { + u1 = x1; + v1 = y1+pos; + u2 = x2; + v2 = y1+pos+len-1; + } + + /* background */ + _ji_theme_rectfill_exclude (ji_screen, + x1, y1, x2, y2, + u1, v1, u2, v2, BGCOLOR); + + /* 1st border */ + if (jwidget_is_selected (widget)) + _ji_theme_rectedge (ji_screen, u1, v1, u2, v2, + makecol (128, 128, 128), makecol (255, 255, 255)); + else + _ji_theme_rectedge (ji_screen, u1, v1, u2, v2, + makecol (255, 255, 255), makecol (128, 128, 128)); + + /* bar-block background */ + u1++, v1++, u2--, v2--; + if (jwidget_has_mouse (widget)) + rectfill (ji_screen, u1, v1, u2, v2, makecol (224, 224, 224)); + else + rectfill (ji_screen, u1, v1, u2, v2, BGCOLOR); +#endif } static void theme_draw_view_viewport (JWidget widget) { - int fg, bg; - - get_colors(widget, &fg, &bg); - jdraw_rectfill(widget->rc, bg); + jdraw_rectfill(widget->rc, BGCOLOR); } -static void theme_draw_window (JWidget widget) +static void theme_draw_window(JWidget widget) { - JRect pos = jwidget_get_rect (widget); - int fg, bg; - - get_colors(widget, &fg, &bg); + JRect pos = jwidget_get_rect(widget); + JRect cpos = jwidget_get_child_rect(widget); /* extra lines */ - if (!jwindow_is_desktop (widget)) { - jdraw_rect(pos, fg); + if (!jwindow_is_desktop(widget)) { + jdraw_rect(pos, makecol(0, 0, 0)); jrect_shrink(pos, 1); - jdraw_rectfill(pos, bg); - hline(ji_screen, pos->x1, pos->y1+1+text_height(font)+1, pos->x2-1, fg); + jdraw_rectedge(pos, makecol(255, 255, 255), makecol(128, 128, 128)); jrect_shrink(pos, 1); + jdraw_rectfill(pos, BGCOLOR); /* draw title bar */ - if (widget->text) + if (widget->text) { + int bg = makecol(44, 76, 145); + + jrect_shrink(pos, 1); +/* pos->y2 = cpos->y1-1; */ + pos->y2 = cpos->y1-3; + jdraw_rectfill(pos, bg); + + jrect_stretch(pos, 1); + jdraw_rectedge(cpos, makecol(128, 128, 128), makecol(255, 255, 255)); + jdraw_text(widget->text_font, widget->text, - pos->x1, pos->y1, fg, bg, FALSE); + cpos->x1, + pos->y1+jrect_h(pos)/2-text_height(widget->text_font)/2, + makecol(255, 255, 255), bg, FALSE); + } } /* desktop */ else { @@ -896,47 +1385,213 @@ static void theme_draw_window (JWidget widget) } jrect_free(pos); + jrect_free(cpos); +} + +static int get_bg_color (JWidget widget) +{ + int c = jwidget_get_bg_color (widget); + int decorative = jwidget_is_decorative (widget); + + return c >= 0 ? c: (decorative ? makecol(44, 76, 145): + makecol(255, 255, 255)); +} + +static void draw_textstring (const char *t, int fg_color, int bg_color, + bool fill_bg, JWidget widget, const JRect rect, + int selected_offset) +{ + if (t || widget->text) { + int x, y, w, h; + + if (!t) { + t = widget->text; + w = jwidget_get_text_length (widget); + h = jwidget_get_text_height (widget); + } + else { + w = ji_font_text_len (widget->text_font, t); + h = text_height (widget->text_font); + } + + /* horizontally text alignment */ + + if (widget->align & JI_RIGHT) + x = rect->x2 - w; + else if (widget->align & JI_CENTER) + x = (rect->x1+rect->x2)/2 - w/2; + else + x = rect->x1; + + /* vertically text alignment */ + + if (widget->align & JI_BOTTOM) + y = rect->y2 - h; + else if (widget->align & JI_MIDDLE) + y = (rect->y1+rect->y2)/2 - h/2; + else + y = rect->y1; + + if (jwidget_is_selected (widget)) { + x += selected_offset; + y += selected_offset; + } + + /* background */ + if (bg_color >= 0) { + if (jwidget_is_disabled (widget)) + rectfill (ji_screen, x, y, x+w, y+h, bg_color); + else + rectfill (ji_screen, x, y, x+w-1, y+h-1, bg_color); + } + + /* text */ + if (jwidget_is_disabled (widget)) { + /* XXXX avoid this */ + if (fill_bg) /* only to draw the background */ + jdraw_text(widget->text_font, t, x, y, 0, bg_color, fill_bg); + + /* draw white part */ + jdraw_text(widget->text_font, t, x+1, y+1, + makecol(255, 255, 255), bg_color, fill_bg); + + if (fill_bg) + fill_bg = FALSE; + } + + jdraw_text(widget->text_font, t, x, y, + jwidget_is_disabled(widget) ? + makecol(128, 128, 128): (fg_color >= 0 ? fg_color : + makecol(0, 0, 0)), + bg_color, fill_bg); + } } static void draw_entry_cursor(JWidget widget, int x, int y) { int h = jwidget_get_text_height(widget); - vline(ji_screen, x, y-1, y+h, makecol(0, 0, 0)); + vline(ji_screen, x, y-1, y+h, makecol (0, 0, 0)); + vline(ji_screen, x+1, y-1, y+h, makecol (0, 0, 0)); } -static void get_colors(JWidget widget, int *fg, int *bg) +static void draw_icons(int x, int y, JWidget widget, int edge_icon) { - if (jwidget_is_disabled(widget)) { - *bg = makecol(255, 255, 255); - *fg = makecol(128, 128, 128); - } - else if (jwidget_is_selected(widget)) { - *bg = makecol(0, 0, 0); - *fg = makecol(255, 255, 255); - } - else { - *bg = makecol(255, 255, 255); - *fg = makecol(0, 0, 0); - } + draw_sprite(ji_screen, icons_bitmap[edge_icon], x, y); + + if (jwidget_is_selected(widget)) + draw_sprite(ji_screen, icons_bitmap[edge_icon+1], x, y); } +static void draw_bevel_box(int x1, int y1, int x2, int y2, int c1, int c2, int *bevel) +{ + hline(ji_screen, x1+bevel[0], y1, x2-bevel[1], c1); /* top */ + hline(ji_screen, x1+bevel[2], y2, x2-bevel[3], c2); /* bottom */ + + vline(ji_screen, x1, y1+bevel[0], y2-bevel[2], c1); /* left */ + vline(ji_screen, x2, y1+bevel[1], y2-bevel[3], c2); /* right */ + + line(ji_screen, x1, y1+bevel[0], x1+bevel[0], y1, c1); /* top-left */ + line(ji_screen, x1, y2-bevel[2], x1+bevel[2], y2, c2); /* bottom-left */ + + line(ji_screen, x2-bevel[1], y1, x2, y1+bevel[1], c2); /* top-right */ + line(ji_screen, x2-bevel[3], y2, x2, y2-bevel[3], c2); /* bottom-right */ +} + +static void draw_round_rect(int x1, int y1, int x2, int y2, int radius_w, int radius_h, int color) +{ + int old_x1, old_y1, old_x2, old_y2; + get_clip_rect(ji_screen, &old_x1, &old_y1, &old_x2, &old_y2); + + /* horizontal lines */ + hline(ji_screen, x1+radius_w, y1, x2-radius_w, color); + hline(ji_screen, x1+radius_w, y2, x2-radius_w, color); + + /* vertical lines */ + vline(ji_screen, x1, y1+radius_h, y2-radius_h, color); + vline(ji_screen, x2, y1+radius_h, y2-radius_h, color); + + /* top-left corner */ + add_clip_rect(ji_screen, x1, y1, x1+radius_w, y1+radius_h); + ellipse(ji_screen, x1+radius_w, y1+radius_h, radius_w, radius_h, color); + + /* top-right */ + set_clip_rect(ji_screen, old_x1, old_y1, old_x2, old_y2); + add_clip_rect(ji_screen, x2-radius_w, y1, x2, y1+radius_h); + ellipse(ji_screen, x2-radius_w, y1+radius_h, radius_w, radius_h, color); + + /* bottom-left */ + set_clip_rect(ji_screen, old_x1, old_y1, old_x2, old_y2); + add_clip_rect(ji_screen, x1, y2-radius_h, x1+radius_w, y2); + ellipse(ji_screen, x1+radius_w, y2-radius_h, radius_w, radius_h, color); + + /* bottom-right */ + set_clip_rect(ji_screen, old_x1, old_y1, old_x2, old_y2); + add_clip_rect(ji_screen, x2-radius_w, y2-radius_h, x2, y2); + ellipse(ji_screen, x2-radius_h, y2-radius_h, radius_w, radius_h, color); + + /* restore clip */ + set_clip_rect(ji_screen, old_x1, old_y1, old_x2, old_y2); +} + +static void fill_round_rect(int x1, int y1, int x2, int y2, int radius_w, int radius_h, int color) +{ + int old_x1, old_y1, old_x2, old_y2; + get_clip_rect(ji_screen, &old_x1, &old_y1, &old_x2, &old_y2); + + /* fill */ + rectfill(ji_screen, x1+radius_w, y1, x2-radius_w, y1+radius_h, color); + rectfill(ji_screen, x1, y1+radius_h, x2, y2-radius_h, color); + rectfill(ji_screen, x1+radius_w, y2-radius_h, x2-radius_w, y2, color); + + /* top-left corner */ + add_clip_rect(ji_screen, x1, y1, x1+radius_w, y1+radius_h); + ellipsefill(ji_screen, x1+radius_w, y1+radius_h, radius_w, radius_h, color); + + /* top-right */ + set_clip_rect(ji_screen, old_x1, old_y1, old_x2, old_y2); + add_clip_rect(ji_screen, x2-radius_w, y1, x2, y1+radius_h); + ellipsefill(ji_screen, x2-radius_w, y1+radius_h, radius_w, radius_h, color); + + /* bottom-left */ + set_clip_rect(ji_screen, old_x1, old_y1, old_x2, old_y2); + add_clip_rect(ji_screen, x1, y2-radius_h, x1+radius_w, y2); + ellipsefill(ji_screen, x1+radius_w, y2-radius_h, radius_w, radius_h, color); + + /* bottom-right */ + set_clip_rect(ji_screen, old_x1, old_y1, old_x2, old_y2); + add_clip_rect(ji_screen, x2-radius_w, y2-radius_h, x2, y2); + ellipsefill(ji_screen, x2-radius_h, y2-radius_h, radius_w, radius_h, color); + + /* restore clip */ + set_clip_rect(ji_screen, old_x1, old_y1, old_x2, old_y2); +} + +static void less_bevel(int *bevel) +{ + if (bevel[0] > 0) --bevel[0]; + if (bevel[1] > 0) --bevel[1]; + if (bevel[2] > 0) --bevel[2]; + if (bevel[3] > 0) --bevel[3]; +} + +/* controls the "X" button in a window to close it */ static bool theme_button_msg_proc(JWidget widget, JMessage msg) { switch (msg->type) { case JM_KEYPRESSED: if (msg->key.scancode == KEY_ESC) { - jwidget_select (widget); + jwidget_select(widget); return TRUE; } break; case JM_KEYRELEASED: if (msg->key.scancode == KEY_ESC) { - if (jwidget_is_selected (widget)) { - jwidget_deselect (widget); - jwidget_close_window (widget); + if (jwidget_is_selected(widget)) { + jwidget_deselect(widget); + jwidget_close_window(widget); return TRUE; } } diff --git a/makefile.gcc b/makefile.gcc index 3be69f36e..3b755dd4d 100644 --- a/makefile.gcc +++ b/makefile.gcc @@ -84,10 +84,10 @@ $(ZLIB_LIB): $(ZLIB_OBJS) VPATH = src \ src/commands \ + src/commands/fx \ src/console \ src/core \ src/dialogs \ - src/dialogs/effect \ src/effect \ src/file \ src/file/gif \ diff --git a/makefile.lst b/makefile.lst index 7ff823751..e549ee23d 100644 --- a/makefile.lst +++ b/makefile.lst @@ -5,182 +5,175 @@ ASE = ase$(EXE) -ASE_SOURCES = \ - src/commands/cmd_about.c \ - src/commands/cmd_advanced_mode.c \ - src/commands/cmd_change_image_type.c \ - src/commands/cmd_clear.c \ - src/commands/cmd_close_file.c \ - src/commands/cmd_color_curve.c \ - src/commands/cmd_configure_screen.c \ - src/commands/cmd_configure_tools.c \ - src/commands/cmd_convolution_matrix.c \ - src/commands/cmd_copy.c \ - src/commands/cmd_copy_frame.c \ - src/commands/cmd_crop.c \ - src/commands/cmd_cut.c \ - src/commands/cmd_deselect_mask.c \ - src/commands/cmd_despeckle.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_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_frame_properties.c \ - src/commands/cmd_invert_color.c \ - src/commands/cmd_invert_mask.c \ - src/commands/cmd_layer_properties.c \ - src/commands/cmd_link_frame.c \ - src/commands/cmd_load_mask.c \ - src/commands/cmd_mapgen.c \ - src/commands/cmd_mask_all.c \ - src/commands/cmd_mask_by_color.c \ - src/commands/cmd_merge_down_layer.c \ - src/commands/cmd_move_frame.c \ - src/commands/cmd_new_file.c \ - src/commands/cmd_new_frame.c \ - src/commands/cmd_new_layer.c \ - src/commands/cmd_new_layer_set.c \ - src/commands/cmd_open_file.c \ - src/commands/cmd_options.c \ - src/commands/cmd_palette_editor.c \ - src/commands/cmd_paste.c \ - src/commands/cmd_play_flic.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_redo.c \ - src/commands/cmd_refresh.c \ - src/commands/cmd_remove_frame.c \ - src/commands/cmd_remove_layer.c \ - src/commands/cmd_replace_color.c \ - src/commands/cmd_reselect_mask.c \ - src/commands/cmd_run_script.c \ - src/commands/cmd_save_file.c \ - src/commands/cmd_save_file_as.c \ - src/commands/cmd_save_mask.c \ - src/commands/cmd_screen_shot.c \ - src/commands/cmd_select_file.c \ - src/commands/cmd_sprite_properties.c \ - src/commands/cmd_tips.c \ - src/commands/cmd_undo.c \ - src/commands/commands.c \ - src/console/console.c \ - src/core/app.c \ - src/core/config.c \ - src/core/cfg.c \ - src/core/core.c \ - src/core/dirs.c \ - src/core/modules.c \ - src/dialogs/canvasze.c \ - src/dialogs/colsel.c \ - src/dialogs/dmapgen.c \ - src/dialogs/dpaledit.c \ - src/dialogs/drawtext.c \ - src/dialogs/effect/dcolcurv.c \ - src/dialogs/effect/dconvmtr.c \ - src/dialogs/effect/dinvcol.c \ - src/dialogs/effect/dmedian.c \ - src/dialogs/effect/dreplcol.c \ - src/dialogs/filesel.c \ - src/dialogs/filmedit.c \ - src/dialogs/gfxsel.c \ - src/dialogs/maskcol.c \ - src/dialogs/minipal.c \ - src/dialogs/options.c \ - src/dialogs/playfli.c \ - src/dialogs/quick.c \ - src/dialogs/repo.c \ - src/dialogs/scrsaver.c \ - src/dialogs/tips.c \ - src/dialogs/vectmap.c \ - src/effect/colcurve.c \ - src/effect/convmatr.c \ - src/effect/effect.c \ - src/effect/invrtcol.c \ - src/effect/median.c \ - src/effect/replcol.c \ - src/file/ase.c \ - src/file/bmp.c \ - src/file/file.c \ - src/file/fli.c \ - src/file/ico.c \ - src/file/jpeg.c \ - src/file/pcx.c \ - src/file/png_file.c \ - src/file/tga.c \ - src/file/gif.c \ - src/file/gif/format.c \ - src/file/gif/lzw.c \ - src/intl/intl.c \ - src/intl/msgids.c \ - src/main.c \ - src/modules/color.c \ - src/modules/editors.c \ - src/modules/gfx.c \ - src/modules/gui.c \ - src/modules/palette.c \ - src/modules/recent.c \ - src/modules/render.c \ - src/modules/rootmenu.c \ - src/modules/sprites.c \ - src/modules/tools.c \ - src/modules/tools2.c \ - src/raster/algo.c \ - src/raster/algofill.c \ - src/raster/blend.c \ - src/raster/brush.c \ - src/raster/dirty.c \ - src/raster/frame.c \ - src/raster/gfxobj.c \ - src/raster/image.c \ - src/raster/layer.c \ - src/raster/mask.c \ - src/raster/path.c \ - src/raster/quant.c \ - src/raster/rotate.c \ - src/raster/sprite.c \ - src/raster/stock.c \ - src/raster/undo.c \ - src/script/bindings.c \ - src/script/script.c \ - src/util/autocrop.c \ - src/util/boundary.c \ - src/util/clipbrd.c \ - src/util/col_file.c \ - src/util/crop.c \ - src/util/filetoks.c \ - src/util/flip.c \ - src/util/frmove.c \ - src/util/hash.c \ - src/util/mapgen.c \ - src/util/misc.c \ - src/util/msk_file.c \ - src/util/pic_file.c \ - src/util/quantize.c \ - src/util/recscr.c \ - src/util/setgfx.c \ - src/util/thmbnail.c \ - src/widgets/colbar.c \ - src/widgets/colbut.c \ - src/widgets/colview.c \ - src/widgets/curvedit.c \ - src/widgets/editor/click.c \ - src/widgets/editor/cursor.c \ - src/widgets/editor/editor.c \ - src/widgets/editor/keys.c \ - src/widgets/groupbut.c \ - src/widgets/menuitem.c \ - src/widgets/paledit.c \ - src/widgets/preview.c \ - src/widgets/statebar.c \ - src/widgets/target.c \ +ASE_SOURCES = \ + src/commands/cmd_about.c \ + src/commands/cmd_advanced_mode.c \ + src/commands/cmd_change_image_type.c \ + src/commands/cmd_clear.c \ + src/commands/cmd_close_file.c \ + src/commands/cmd_configure_screen.c \ + src/commands/cmd_configure_tools.c \ + src/commands/cmd_copy.c \ + src/commands/cmd_copy_frame.c \ + src/commands/cmd_crop.c \ + src/commands/cmd_cut.c \ + src/commands/cmd_deselect_mask.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_exit.c \ + src/commands/cmd_film_editor.c \ + src/commands/cmd_flatten_layers.c \ + src/commands/cmd_flip.c \ + src/commands/cmd_frame_properties.c \ + src/commands/cmd_invert_mask.c \ + src/commands/cmd_layer_properties.c \ + src/commands/cmd_link_frame.c \ + src/commands/cmd_load_mask.c \ + src/commands/cmd_mapgen.c \ + src/commands/cmd_mask_all.c \ + src/commands/cmd_mask_by_color.c \ + src/commands/cmd_merge_down_layer.c \ + src/commands/cmd_move_frame.c \ + src/commands/cmd_new_file.c \ + src/commands/cmd_new_frame.c \ + src/commands/cmd_new_layer.c \ + src/commands/cmd_new_layer_set.c \ + src/commands/cmd_open_file.c \ + src/commands/cmd_options.c \ + src/commands/cmd_palette_editor.c \ + src/commands/cmd_paste.c \ + src/commands/cmd_play_flic.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_redo.c \ + src/commands/cmd_refresh.c \ + src/commands/cmd_remove_frame.c \ + src/commands/cmd_remove_layer.c \ + src/commands/cmd_reselect_mask.c \ + src/commands/cmd_run_script.c \ + src/commands/cmd_save_file.c \ + src/commands/cmd_save_file_as.c \ + src/commands/cmd_save_mask.c \ + src/commands/cmd_screen_shot.c \ + src/commands/cmd_select_file.c \ + src/commands/cmd_sprite_editor.c \ + src/commands/cmd_sprite_properties.c \ + src/commands/cmd_tips.c \ + src/commands/cmd_undo.c \ + src/commands/commands.c \ + src/commands/fx/cmd_color_curve.c \ + src/commands/fx/cmd_convolution_matrix.c \ + src/commands/fx/cmd_despeckle.c \ + src/commands/fx/cmd_invert_color.c \ + src/commands/fx/cmd_replace_color.c \ + src/console/console.c \ + src/core/app.c \ + src/core/config.c \ + src/core/cfg.c \ + src/core/core.c \ + src/core/dirs.c \ + src/core/modules.c \ + src/dialogs/canvasze.c \ + src/dialogs/colsel.c \ + src/dialogs/dmapgen.c \ + src/dialogs/dpaledit.c \ + src/dialogs/drawtext.c \ + src/dialogs/filesel.c \ + src/dialogs/filmedit.c \ + src/dialogs/gfxsel.c \ + src/dialogs/maskcol.c \ + src/dialogs/minipal.c \ + src/dialogs/options.c \ + src/dialogs/playfli.c \ + src/dialogs/quick.c \ + src/dialogs/repo.c \ + src/dialogs/scrsaver.c \ + src/dialogs/tips.c \ + src/dialogs/vectmap.c \ + src/effect/colcurve.c \ + src/effect/convmatr.c \ + src/effect/effect.c \ + src/effect/invrtcol.c \ + src/effect/median.c \ + src/effect/replcol.c \ + src/file/ase.c \ + src/file/bmp.c \ + src/file/file.c \ + src/file/fli.c \ + src/file/ico.c \ + src/file/jpeg.c \ + src/file/pcx.c \ + src/file/png_file.c \ + src/file/tga.c \ + src/file/gif.c \ + src/file/gif/format.c \ + src/file/gif/lzw.c \ + src/intl/intl.c \ + src/intl/msgids.c \ + src/main.c \ + src/modules/color.c \ + src/modules/editors.c \ + src/modules/gfx.c \ + src/modules/gui.c \ + src/modules/palette.c \ + src/modules/recent.c \ + src/modules/render.c \ + src/modules/rootmenu.c \ + src/modules/sprites.c \ + src/modules/tools.c \ + src/modules/tools2.c \ + src/raster/algo.c \ + src/raster/algofill.c \ + src/raster/blend.c \ + src/raster/brush.c \ + src/raster/dirty.c \ + src/raster/frame.c \ + src/raster/gfxobj.c \ + src/raster/image.c \ + src/raster/layer.c \ + src/raster/mask.c \ + src/raster/path.c \ + src/raster/quant.c \ + src/raster/rotate.c \ + src/raster/sprite.c \ + src/raster/stock.c \ + src/raster/undo.c \ + src/script/bindings.c \ + src/script/script.c \ + src/util/autocrop.c \ + src/util/boundary.c \ + src/util/clipbrd.c \ + src/util/col_file.c \ + src/util/crop.c \ + src/util/filetoks.c \ + src/util/frmove.c \ + src/util/hash.c \ + src/util/mapgen.c \ + src/util/misc.c \ + src/util/msk_file.c \ + src/util/pic_file.c \ + src/util/quantize.c \ + src/util/recscr.c \ + src/util/setgfx.c \ + src/util/thmbnail.c \ + src/widgets/colbar.c \ + src/widgets/colbut.c \ + src/widgets/colview.c \ + src/widgets/curvedit.c \ + src/widgets/editor/click.c \ + src/widgets/editor/cursor.c \ + src/widgets/editor/editor.c \ + src/widgets/editor/keys.c \ + src/widgets/groupbut.c \ + src/widgets/menuitem.c \ + src/widgets/paledit.c \ + src/widgets/preview.c \ + src/widgets/statebar.c \ + src/widgets/target.c \ src/widgets/toolbar.c ASE_OBJS = $(addprefix $(OBJ_DIR)/, \ diff --git a/misc/dist.sh b/misc/dist.sh index efbd222cd..d23441a6d 100644 --- a/misc/dist.sh +++ b/misc/dist.sh @@ -102,8 +102,8 @@ ase_files="all.h \ *.txt \ data/aseicon.* \ data/convmatr.def \ - data/defgui-en.xml \ - data/defgui-es.xml \ + data/gui-en.xml \ + data/gui-es.xml \ data/fonts/*.pcx \ data/jids/*.jid \ data/palettes/*.col \ diff --git a/misc/gendeps.sh b/misc/gendeps.sh index 35adc6fb2..9401aa03b 100644 --- a/misc/gendeps.sh +++ b/misc/gendeps.sh @@ -27,10 +27,10 @@ rm -f makefile.dep $GCC $CFLAGS jinete/src/*.c \ src/*.c \ src/commands/*.c \ + src/commands/fx/*.c \ src/console/*.c \ src/core/*.c \ src/dialogs/*.c \ - src/dialogs/effect/*.c \ src/effect/*.c \ src/file/*.c \ src/intl/*.c \ diff --git a/src/commands/cmd_color_curve.c b/src/commands/cmd_color_curve.c deleted file mode 100644 index faa027dd5..000000000 --- a/src/commands/cmd_color_curve.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_color_curve(const char *argument) -{ -} diff --git a/src/commands/cmd_convolution_matrix.c b/src/commands/cmd_convolution_matrix.c deleted file mode 100644 index 4946b17c8..000000000 --- a/src/commands/cmd_convolution_matrix.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_convolution_matrix(const char *argument) -{ -} diff --git a/src/commands/cmd_despeckle.c b/src/commands/cmd_despeckle.c deleted file mode 100644 index 7d6b5745e..000000000 --- a/src/commands/cmd_despeckle.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_despeckle(const char *argument) -{ -} diff --git a/src/util/flip.c b/src/commands/cmd_flip.c similarity index 57% rename from src/util/flip.c rename to src/commands/cmd_flip.c index ce803d045..7daef359c 100644 --- a/src/util/flip.c +++ b/src/commands/cmd_flip.c @@ -1,85 +1,112 @@ -/* 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 - */ - -#include "config.h" - -#ifndef USE_PRECOMPILED_HEADER - -#include "modules/editors.h" -#include "modules/sprites.h" -#include "raster/image.h" -#include "raster/mask.h" -#include "raster/sprite.h" -#include "raster/undo.h" -#include "util/misc.h" - -#endif - -static void do_flip (int horz); - -void flip_horizontal (void) { do_flip (TRUE); } -void flip_vertical (void) { do_flip (FALSE); } - -static void do_flip (int horz) -{ - Sprite *sprite = current_sprite; - Image *image, *area; - int x1, y1, x2, y2; - int x, y; - - if (!sprite) - return; - - image = GetImage2 (sprite, &x, &y, NULL); - if (!image) - return; - - if (mask_is_empty (sprite->mask)) { - x1 = 0; - y1 = 0; - x2 = image->w-1; - y2 = image->h-1; - } - else { - /* apply the frame offset */ - x1 = sprite->mask->x - x; - y1 = sprite->mask->y - y; - x2 = sprite->mask->x + sprite->mask->w - 1 - x; - y2 = sprite->mask->y + sprite->mask->h - 1 - y; - - /* clip */ - x1 = MID (0, x1, image->w-1); - y1 = MID (0, y1, image->h-1); - x2 = MID (0, x2, image->w-1); - y2 = MID (0, y2, image->h-1); - } - - /* insert the undo operation */ - if (undo_is_enabled (sprite->undo)) - undo_flip (sprite->undo, image, x1, y1, x2, y2, horz); - - /* flip the portion of the bitmap */ - 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); -} +/* 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/editors.h" +#include "modules/gui.h" +#include "modules/sprites.h" +#include "raster/image.h" +#include "raster/mask.h" +#include "raster/sprite.h" +#include "raster/undo.h" +#include "util/misc.h" + +#endif + +static void do_flip(int horz); + +/* ======================== */ +/* flip_horizontal */ +/* ======================== */ + +bool command_enabled_flip_horizontal(const char *argument) +{ + return current_sprite != NULL; +} + +void command_execute_flip_horizontal(const char *argument) +{ + do_flip(TRUE); +} + +/* ======================== */ +/* flip_vertical */ +/* ======================== */ + +bool command_enabled_flip_vertical(const char *argument) +{ + return current_sprite != NULL; +} + +void command_execute_flip_vertical(const char *argument) +{ + do_flip(FALSE); +} + +/************************************************************/ +/* do_flip */ + +static void do_flip(int horz) +{ + Sprite *sprite = current_sprite; + Image *image, *area; + int x1, y1, x2, y2; + int x, y; + + image = GetImage2(sprite, &x, &y, NULL); + if (!image) + return; + + if (mask_is_empty(sprite->mask)) { + x1 = 0; + y1 = 0; + x2 = image->w-1; + y2 = image->h-1; + } + else { + /* apply the frame offset */ + x1 = sprite->mask->x - x; + y1 = sprite->mask->y - y; + x2 = sprite->mask->x + sprite->mask->w - 1 - x; + y2 = sprite->mask->y + sprite->mask->h - 1 - y; + + /* clip */ + x1 = MID (0, x1, image->w-1); + y1 = MID (0, y1, image->h-1); + x2 = MID (0, x2, image->w-1); + y2 = MID (0, y2, image->h-1); + } + + /* insert the undo operation */ + if (undo_is_enabled(sprite->undo)) + undo_flip(sprite->undo, image, x1, y1, x2, y2, horz); + + /* flip the portion of the bitmap */ + 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); + GUI_Refresh(current_sprite); +} diff --git a/src/commands/cmd_flip_horizontal.c b/src/commands/cmd_flip_horizontal.c deleted file mode 100644 index 15882c70b..000000000 --- a/src/commands/cmd_flip_horizontal.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_flip_horizontal(const char *argument) -{ -} diff --git a/src/commands/cmd_flip_vertical.c b/src/commands/cmd_flip_vertical.c deleted file mode 100644 index 5d5fc168f..000000000 --- a/src/commands/cmd_flip_vertical.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_flip_vertical(const char *argument) -{ -} diff --git a/src/commands/cmd_invert_color.c b/src/commands/cmd_invert_color.c deleted file mode 100644 index 07048c42d..000000000 --- a/src/commands/cmd_invert_color.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_invert_color(const char *argument) -{ -} diff --git a/src/commands/cmd_quick_copy.c b/src/commands/cmd_quick_copy.c deleted file mode 100644 index 2db42976c..000000000 --- a/src/commands/cmd_quick_copy.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_quick_copy(const char *argument) -{ -} diff --git a/src/commands/cmd_quick_move.c b/src/commands/cmd_quick_move.c deleted file mode 100644 index 312326743..000000000 --- a/src/commands/cmd_quick_move.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_quick_move(const char *argument) -{ -} diff --git a/src/commands/cmd_replace_color.c b/src/commands/cmd_replace_color.c deleted file mode 100644 index 364e05230..000000000 --- a/src/commands/cmd_replace_color.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_replace_color(const char *argument) -{ -} diff --git a/src/commands/commands.c b/src/commands/commands.c index b758de1d5..e6cf33bf5 100644 --- a/src/commands/commands.c +++ b/src/commands/commands.c @@ -63,11 +63,13 @@ bool command_enabled_paste(const char *argument); void command_execute_paste(const char *argument); bool command_enabled_clear(const char *argument); void command_execute_clear(const char *argument); -void command_execute_quick_move(const char *argument); -void command_execute_quick_copy(const char *argument); +bool command_enabled_flip_horizontal(const char *argument); void command_execute_flip_horizontal(const char *argument); +bool command_enabled_flip_vertical(const char *argument); void command_execute_flip_vertical(const char *argument); +bool command_enabled_replace_color(const char *argument); void command_execute_replace_color(const char *argument); +bool command_enabled_invert_color(const char *argument); void command_execute_invert_color(const char *argument); void command_execute_refresh(const char *argument); void command_execute_configure_screen(const char *argument); @@ -150,8 +152,11 @@ void command_execute_ellipse_tool(const char *argument); bool command_enabled_film_editor(const char *argument); void command_execute_film_editor(const char *argument); void command_execute_palette_editor(const char *argument); +bool command_enabled_convolution_matrix(const char *argument); void command_execute_convolution_matrix(const char *argument); +bool command_enabled_color_curve(const char *argument); void command_execute_color_curve(const char *argument); +bool command_enabled_despeckle(const char *argument); void command_execute_despeckle(const char *argument); /* void command_execute_draw_text(const char *argument); */ /* void command_execute_play_flic(const char *argument); */ @@ -188,12 +193,10 @@ static Command commands[] = { CMD_EXE_ENA(copy), CMD_EXE_ENA(paste), CMD_EXE_ENA(clear), - { CMD_QUICK_MOVE, NULL, NULL, NULL, NULL }, - { CMD_QUICK_COPY, NULL, NULL, NULL, NULL }, - { CMD_FLIP_HORIZONTAL, NULL, NULL, NULL, NULL }, - { CMD_FLIP_VERTICAL, NULL, NULL, NULL, NULL }, - { CMD_REPLACE_COLOR, NULL, NULL, NULL, NULL }, - { CMD_INVERT_COLOR, NULL, NULL, NULL, NULL }, + CMD_EXE_ENA(flip_horizontal), + CMD_EXE_ENA(flip_vertical), + CMD_EXE_ENA(replace_color), + CMD_EXE_ENA(invert_color), CMD_EXE(refresh), { CMD_CONFIGURE_SCREEN, NULL, NULL, NULL, NULL }, CMD_EXE(advanced_mode), @@ -243,9 +246,9 @@ static Command commands[] = { CMD_EXE_CHK(ellipse_tool), CMD_EXE_ENA(film_editor), { CMD_PALETTE_EDITOR, NULL, NULL, NULL, NULL }, - { CMD_CONVOLUTION_MATRIX, NULL, NULL, NULL, NULL }, - { CMD_COLOR_CURVE, NULL, NULL, NULL, NULL }, - { CMD_DESPECKLE, NULL, NULL, NULL, NULL }, + CMD_EXE_ENA(convolution_matrix), + CMD_EXE_ENA(color_curve), + CMD_EXE_ENA(despeckle), /* { CMD_DRAW_TEXT, NULL, NULL, NULL, NULL }, */ /* { CMD_PLAY_FLIC, NULL, NULL, NULL, NULL }, */ /* { CMD_MAPGEN, NULL, NULL, NULL, NULL }, */ diff --git a/src/commands/commands.h b/src/commands/commands.h index ac3de6fb2..2475ef467 100644 --- a/src/commands/commands.h +++ b/src/commands/commands.h @@ -39,8 +39,6 @@ #define CMD_COPY "copy" #define CMD_PASTE "paste" #define CMD_CLEAR "clear" -#define CMD_QUICK_MOVE "quick_move" -#define CMD_QUICK_COPY "quick_copy" #define CMD_FLIP_HORIZONTAL "flip_horizontal" #define CMD_FLIP_VERTICAL "flip_vertical" #define CMD_REPLACE_COLOR "replace_color" diff --git a/src/dialogs/effect/dcolcurv.c b/src/commands/fx/cmd_color_curve.c similarity index 92% rename from src/dialogs/effect/dcolcurv.c rename to src/commands/fx/cmd_color_curve.c index 4bde02062..a4c67ed50 100644 --- a/src/dialogs/effect/dcolcurv.c +++ b/src/commands/fx/cmd_color_curve.c @@ -1,170 +1,172 @@ -/* 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.h" - -#include "console/console.h" -#include "core/cfg.h" -#include "core/core.h" -#include "effect/colcurve.h" -#include "effect/effect.h" -#include "modules/color.h" -/* #include "modules/editors.h" */ -#include "modules/gui.h" -#include "modules/sprites.h" -#include "raster/image.h" -#include "raster/mask.h" -#include "raster/sprite.h" -#include "util/misc.h" -#include "widgets/colbar.h" -#include "widgets/colbut.h" -#include "widgets/curvedit.h" -#include "widgets/preview.h" -#include "widgets/target.h" - -#endif - -static Curve *the_curve = NULL; -static JWidget check_preview, preview; - -static bool hooked_msg_proc (JWidget widget, JMessage msg); -static void make_preview (void); - -void dialogs_color_curve(void) -{ - JWidget window, button_ok; - JWidget view_curve, curve_editor; - JWidget box_target, target_button; - Sprite *sprite = current_sprite; - Image *image; - Effect *effect; - - if (!the_curve) { - /* default curve */ - the_curve = curve_new (CURVE_LINEAR); - curve_add_point (the_curve, curve_point_new (0, 0)); - curve_add_point (the_curve, curve_point_new (255, 255)); - } - - if (!is_interactive () || !sprite) - return; - - image = GetImage (); - if (!image) - return; - - window = load_widget ("colcurv.jid", "color_curve"); - if (!window) - return; - - if (!get_widgets (window, - "preview", &check_preview, - "button_ok", &button_ok, - "curve", &view_curve, - "target", &box_target, NULL)) { - jwidget_free (window); - return; - } - - effect = effect_new (sprite, "color_curve"); - if (!effect) { - console_printf (_("Error creating the effect applicator for this sprite\n")); - jwidget_free (window); - return; - } - - preview = preview_new (effect); - - set_color_curve (the_curve); - - curve_editor = curve_editor_new (the_curve, 0, 0, 255, 255); - target_button = target_button_new (sprite->imgtype, TRUE); - - if (get_config_bool ("ColorCurve", "Preview", TRUE)) - jwidget_select (check_preview); - - jview_attach (view_curve, curve_editor); - jwidget_set_static_size (view_curve, 64, 64); - - jwidget_add_child (box_target, target_button); - jwidget_add_child (window, preview); - - jwidget_add_hook (window, JI_WIDGET, hooked_msg_proc, NULL); - - /* default position */ - jwindow_remap (window); - jwindow_center (window); - - /* first preview */ - make_preview (); - - /* load window configuration */ - load_window_pos (window, "ColorCurve"); - - /* open the window */ - jwindow_open_fg (window); - - if (jwindow_get_killer (window) == button_ok) { - effect_apply_to_target (effect); - } - - effect_free (effect); - - /* update editors */ - GUI_Refresh (sprite); - - /* save window configuration */ - save_window_pos (window, "ColorCurve"); - - jwidget_free (window); -} - -static bool hooked_msg_proc (JWidget widget, JMessage msg) -{ - if (msg->type == JM_SIGNAL) { - switch (msg->signal.num) { - - case SIGNAL_CURVE_EDITOR_CHANGE: - set_color_curve (curve_editor_get_curve (msg->signal.from)); - make_preview (); - break; - - case SIGNAL_TARGET_BUTTON_CHANGE: - effect_load_target (preview_get_effect (preview)); - make_preview (); - break; - - case JI_SIGNAL_CHECK_CHANGE: - set_config_bool ("ColorCurve", "Preview", - jwidget_is_selected (msg->signal.from)); - make_preview (); - break; - } - } - return FALSE; -} - -static void make_preview (void) -{ - if (jwidget_is_selected (check_preview)) - preview_restart (preview); -} +/* 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 "console/console.h" +#include "core/cfg.h" +#include "core/core.h" +#include "effect/colcurve.h" +#include "effect/effect.h" +#include "modules/color.h" +/* #include "modules/editors.h" */ +#include "modules/gui.h" +#include "modules/sprites.h" +#include "raster/image.h" +#include "raster/mask.h" +#include "raster/sprite.h" +#include "util/misc.h" +#include "widgets/colbar.h" +#include "widgets/colbut.h" +#include "widgets/curvedit.h" +#include "widgets/preview.h" +#include "widgets/target.h" + +#endif + +static Curve *the_curve = NULL; +static JWidget check_preview, preview; + +static bool hooked_msg_proc (JWidget widget, JMessage msg); +static void make_preview (void); + +bool command_enabled_color_curve(const char *argument) +{ + return current_sprite != NULL; +} + +void command_execute_color_curve(const char *argument) +{ + JWidget window, button_ok; + JWidget view_curve, curve_editor; + JWidget box_target, target_button; + Sprite *sprite = current_sprite; + Image *image; + Effect *effect; + + if (!the_curve) { + /* default curve */ + the_curve = curve_new (CURVE_LINEAR); + curve_add_point (the_curve, curve_point_new (0, 0)); + curve_add_point (the_curve, curve_point_new (255, 255)); + } + + image = GetImage (); + if (!image) + return; + + window = load_widget ("colcurv.jid", "color_curve"); + if (!window) + return; + + if (!get_widgets (window, + "preview", &check_preview, + "button_ok", &button_ok, + "curve", &view_curve, + "target", &box_target, NULL)) { + jwidget_free (window); + return; + } + + effect = effect_new (sprite, "color_curve"); + if (!effect) { + console_printf (_("Error creating the effect applicator for this sprite\n")); + jwidget_free (window); + return; + } + + preview = preview_new (effect); + + set_color_curve (the_curve); + + curve_editor = curve_editor_new (the_curve, 0, 0, 255, 255); + target_button = target_button_new (sprite->imgtype, TRUE); + + if (get_config_bool ("ColorCurve", "Preview", TRUE)) + jwidget_select (check_preview); + + jview_attach (view_curve, curve_editor); + jwidget_set_static_size (view_curve, 64, 64); + + jwidget_add_child (box_target, target_button); + jwidget_add_child (window, preview); + + jwidget_add_hook (window, JI_WIDGET, hooked_msg_proc, NULL); + + /* default position */ + jwindow_remap (window); + jwindow_center (window); + + /* first preview */ + make_preview (); + + /* load window configuration */ + load_window_pos (window, "ColorCurve"); + + /* open the window */ + jwindow_open_fg (window); + + if (jwindow_get_killer (window) == button_ok) { + effect_apply_to_target (effect); + } + + effect_free (effect); + + /* update editors */ + GUI_Refresh (sprite); + + /* save window configuration */ + save_window_pos (window, "ColorCurve"); + + jwidget_free (window); +} + +static bool hooked_msg_proc (JWidget widget, JMessage msg) +{ + if (msg->type == JM_SIGNAL) { + switch (msg->signal.num) { + + case SIGNAL_CURVE_EDITOR_CHANGE: + set_color_curve (curve_editor_get_curve (msg->signal.from)); + make_preview (); + break; + + case SIGNAL_TARGET_BUTTON_CHANGE: + effect_load_target (preview_get_effect (preview)); + make_preview (); + break; + + case JI_SIGNAL_CHECK_CHANGE: + set_config_bool ("ColorCurve", "Preview", + jwidget_is_selected (msg->signal.from)); + make_preview (); + break; + } + } + return FALSE; +} + +static void make_preview (void) +{ + if (jwidget_is_selected (check_preview)) + preview_restart (preview); +} diff --git a/src/dialogs/effect/dconvmtr.c b/src/commands/fx/cmd_convolution_matrix.c similarity index 94% rename from src/dialogs/effect/dconvmtr.c rename to src/commands/fx/cmd_convolution_matrix.c index 4fec4a156..0940cfedb 100644 --- a/src/dialogs/effect/dconvmtr.c +++ b/src/commands/fx/cmd_convolution_matrix.c @@ -1,344 +1,346 @@ -/* 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/box.h" -#include "jinete/button.h" -#include "jinete/hook.h" -#include "jinete/label.h" -#include "jinete/list.h" -#include "jinete/listbox.h" -#include "jinete/slider.h" -#include "jinete/view.h" -#include "jinete/widget.h" -#include "jinete/window.h" - -#include "console/console.h" -#include "core/cfg.h" -#include "core/core.h" -#include "effect/colcurve.h" -#include "effect/convmatr.h" -#include "effect/effect.h" -#include "modules/color.h" -/* #include "modules/editors.h" */ -#include "modules/gui.h" -#include "modules/sprites.h" -#include "modules/tools.h" -#include "raster/image.h" -#include "raster/mask.h" -#include "raster/sprite.h" -#include "util/misc.h" -#include "widgets/colbar.h" -#include "widgets/colbut.h" -#include "widgets/curvedit.h" -#include "widgets/preview.h" -#include "widgets/target.h" - -#endif - -static JWidget check_preview, preview; -static JWidget check_tiled; - -static JWidget listbox_generate_convmatg (void); -static void listbox_fill_convmatg (JWidget listbox); -static void listbox_select_current_convmatr (JWidget listbox); - -static int reload_select_hook (JWidget widget, int user_data); -static int generate_select_hook (JWidget widget, int user_data); - -static int list_change_hook (JWidget widget, int user_data); -static int target_change_hook (JWidget widget, int user_data); -static int preview_change_hook (JWidget widget, int user_data); -static int tiled_change_hook (JWidget widget, int user_data); -static void make_preview (void); - -void dialogs_convolution_matrix(void) -{ - JWidget window, button_ok; - JWidget view_convmatr, list_convmatr; - JWidget box_target, target_button; - JWidget reload, generate; - Sprite *sprite = current_sprite; - Image *image; - Effect *effect; - - if (!is_interactive () || !sprite) - return; - - image = GetImage (); - if (!image) - return; - - window = load_widget ("convmatr.jid", "convolution_matrix"); - if (!window) - return; - - if (!get_widgets (window, - "preview", &check_preview, - "tiled", &check_tiled, - "button_ok", &button_ok, - "view", &view_convmatr, - "target", &box_target, - "reload", &reload, - "generate", &generate, NULL)) { - jwidget_free (window); - return; - } - - effect = effect_new (sprite, "convolution_matrix"); - if (!effect) { - console_printf (_("Error creating the effect applicator for this sprite\n")); - jwidget_free (window); - return; - } - - preview = preview_new (effect); - - list_convmatr = listbox_generate_convmatg (); - target_button = target_button_new (sprite->imgtype, TRUE); - - if (get_config_bool ("ConvolutionMatrix", "Preview", TRUE)) - jwidget_select (check_preview); - - if (get_tiled_mode ()) - jwidget_select (check_tiled); - - jview_attach (view_convmatr, list_convmatr); - jwidget_set_static_size (view_convmatr, 64, 64); - - jwidget_add_child (box_target, target_button); - jwidget_add_child (window, preview); - - HOOK (target_button, SIGNAL_TARGET_BUTTON_CHANGE, target_change_hook, 0); - HOOK (check_preview, JI_SIGNAL_CHECK_CHANGE, preview_change_hook, 0); - HOOK (check_tiled, JI_SIGNAL_CHECK_CHANGE, tiled_change_hook, 0); - HOOK (reload, JI_SIGNAL_BUTTON_SELECT, reload_select_hook, list_convmatr); - HOOK (generate, JI_SIGNAL_BUTTON_SELECT, generate_select_hook, 0); - - /* XXXX enable this someday */ - jwidget_disable (generate); - - /* default position */ - jwindow_remap (window); - jwindow_center (window); - - /* load window configuration */ - load_window_pos (window, "ConvolutionMatrix"); - - /* select default convmatr */ - listbox_select_current_convmatr (list_convmatr); - - /* open the window */ - jwindow_open_fg (window); - - if (jwindow_get_killer (window) == button_ok) { - effect_apply_to_target (effect); - } - - effect_free (effect); - - /* update editors */ - GUI_Refresh (sprite); - - /* save window configuration */ - save_window_pos (window, "ConvolutionMatrix"); - - jwidget_free (window); -} - -static JWidget listbox_generate_convmatg (void) -{ - JWidget listbox = jlistbox_new (); - listbox_fill_convmatg (listbox); - HOOK (listbox, JI_SIGNAL_LISTBOX_CHANGE, list_change_hook, 0); - return listbox; -} - -static void listbox_fill_convmatg (JWidget listbox) -{ - ConvMatr *convmatr; - JWidget listitem; - JLink link; - - JI_LIST_FOR_EACH(get_convmatr_stock(), link) { - convmatr = link->data; - listitem = jlistitem_new(convmatr->name); - listitem->user_data[0] = convmatr; - jwidget_add_child(listbox, listitem); - } -} - -static void listbox_select_current_convmatr (JWidget listbox) -{ - const char *selected = get_config_string ("ConvolutionMatrix", - "Selected", ""); - JWidget select_this = jlist_first_data(listbox->children); - JWidget child = NULL; - JLink link; - - if (selected && *selected) { - JI_LIST_FOR_EACH(listbox->children, link) { - child = link->data; - - if (strcmp(jwidget_get_text(child), selected) == 0) { - select_this = child; - break; - } - } - } - - if (select_this) { - jwidget_select (select_this); - list_change_hook (listbox, 0); - } -} - -static int reload_select_hook(JWidget widget, int user_data) -{ - JWidget listbox = (JWidget)user_data; - JWidget listitem; - JLink link, next; - - /* clean the list */ - JI_LIST_FOR_EACH_SAFE(listbox->children, link, next) { - listitem = link->data; - jwidget_remove_child (listbox, listitem); - jwidget_free (listitem); - } - - /* re-load the convolution matrix stock */ - reload_matrices_stock (); - - /* re-fill the list */ - listbox_fill_convmatg (listbox); - listbox_select_current_convmatr (listbox); - jview_update (jwidget_get_view (listbox)); - - return TRUE; /* do not close */ -} - -static int generate_select_hook (JWidget widget, int user_data) -{ - JWidget window; - JWidget view_x; - JWidget view_y; - JWidget curvedit_x; - JWidget curvedit_y; - Curve *curve_x; - Curve *curve_y; - JWidget div, div_auto; - JWidget bias, bias_auto; - - window = load_widget ("convmatr.jid", "generate_convolution_matrix"); - if (!window) - return TRUE; /* don't close */ - - if (!get_widgets (window, - "view_x", &view_x, - "view_y", &view_y, - "div", &div, - "bias", &bias, - "div_auto", &div_auto, - "bias_auto", &bias_auto, NULL)) { - jwidget_free (window); - return TRUE; /* don't close */ - } - - /* curve_x = curve_new (CURVE_SPLINE); */ - /* curve_y = curve_new (CURVE_SPLINE); */ - curve_x = curve_new (CURVE_LINEAR); - curve_y = curve_new (CURVE_LINEAR); - curve_add_point (curve_x, curve_point_new (-100, 0)); - curve_add_point (curve_x, curve_point_new (0, +100)); - curve_add_point (curve_x, curve_point_new (+100, 0)); - curve_add_point (curve_y, curve_point_new (-100, 0)); - curve_add_point (curve_y, curve_point_new (0, +100)); - curve_add_point (curve_y, curve_point_new (+100, 0)); - - curvedit_x = curve_editor_new (curve_x, -200, -200, 200, 200); - curvedit_y = curve_editor_new (curve_y, -200, -200, 200, 200); - - jview_attach (view_x, curvedit_x); - jview_attach (view_y, curvedit_y); - - jwidget_set_static_size (view_x, 64, 64); - jwidget_set_static_size (view_y, 64, 64); - - /* XXX fix this */ - /* jwidget_get_vtable (div)->request_size = NULL; */ - /* jwidget_get_vtable (bias)->request_size = NULL; */ - - jwidget_set_static_size (div, 1, 1); - jwidget_set_static_size (bias, 1, 1); - - jwindow_open_fg (window); - - /* XXX do something */ - - jwidget_free (window); - - curve_free (curve_x); - curve_free (curve_y); - - return TRUE; /* do not close */ -} - -static int list_change_hook (JWidget widget, int user_data) -{ - JWidget selected = jlistbox_get_selected_child (widget); - ConvMatr *convmatr = selected->user_data[0]; - - set_config_string ("ConvolutionMatrix", "Selected", convmatr->name); - - set_convmatr (convmatr); - make_preview (); - return FALSE; -} - -static int target_change_hook (JWidget widget, int user_data) -{ - effect_load_target (preview_get_effect (preview)); - make_preview (); - return FALSE; -} - -static int preview_change_hook (JWidget widget, int user_data) -{ - set_config_bool ("ConvolutionMatrix", "Preview", - jwidget_is_selected (widget)); - make_preview (); - return FALSE; -} - -static int tiled_change_hook (JWidget widget, int user_data) -{ - set_tiled_mode (jwidget_is_selected (widget)); - make_preview (); - return FALSE; -} - -static void make_preview (void) -{ - if (jwidget_is_selected (check_preview)) - preview_restart (preview); -} +/* 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 + +#include "jinete/box.h" +#include "jinete/button.h" +#include "jinete/hook.h" +#include "jinete/label.h" +#include "jinete/list.h" +#include "jinete/listbox.h" +#include "jinete/slider.h" +#include "jinete/view.h" +#include "jinete/widget.h" +#include "jinete/window.h" + +#include "console/console.h" +#include "core/cfg.h" +#include "core/core.h" +#include "effect/colcurve.h" +#include "effect/convmatr.h" +#include "effect/effect.h" +#include "modules/color.h" +/* #include "modules/editors.h" */ +#include "modules/gui.h" +#include "modules/sprites.h" +#include "modules/tools.h" +#include "raster/image.h" +#include "raster/mask.h" +#include "raster/sprite.h" +#include "util/misc.h" +#include "widgets/colbar.h" +#include "widgets/colbut.h" +#include "widgets/curvedit.h" +#include "widgets/preview.h" +#include "widgets/target.h" + +#endif + +static JWidget check_preview, preview; +static JWidget check_tiled; + +static JWidget listbox_generate_convmatg (void); +static void listbox_fill_convmatg (JWidget listbox); +static void listbox_select_current_convmatr (JWidget listbox); + +static int reload_select_hook (JWidget widget, int user_data); +static int generate_select_hook (JWidget widget, int user_data); + +static int list_change_hook (JWidget widget, int user_data); +static int target_change_hook (JWidget widget, int user_data); +static int preview_change_hook (JWidget widget, int user_data); +static int tiled_change_hook (JWidget widget, int user_data); +static void make_preview (void); + +bool command_enabled_convolution_matrix(const char *argument) +{ + return current_sprite != NULL; +} + +void command_execute_convolution_matrix(const char *argument) +{ + JWidget window, button_ok; + JWidget view_convmatr, list_convmatr; + JWidget box_target, target_button; + JWidget reload, generate; + Sprite *sprite = current_sprite; + Image *image; + Effect *effect; + + image = GetImage (); + if (!image) + return; + + window = load_widget ("convmatr.jid", "convolution_matrix"); + if (!window) + return; + + if (!get_widgets (window, + "preview", &check_preview, + "tiled", &check_tiled, + "button_ok", &button_ok, + "view", &view_convmatr, + "target", &box_target, + "reload", &reload, + "generate", &generate, NULL)) { + jwidget_free (window); + return; + } + + effect = effect_new (sprite, "convolution_matrix"); + if (!effect) { + console_printf (_("Error creating the effect applicator for this sprite\n")); + jwidget_free (window); + return; + } + + preview = preview_new (effect); + + list_convmatr = listbox_generate_convmatg (); + target_button = target_button_new (sprite->imgtype, TRUE); + + if (get_config_bool ("ConvolutionMatrix", "Preview", TRUE)) + jwidget_select (check_preview); + + if (get_tiled_mode ()) + jwidget_select (check_tiled); + + jview_attach (view_convmatr, list_convmatr); + jwidget_set_static_size (view_convmatr, 64, 64); + + jwidget_add_child (box_target, target_button); + jwidget_add_child (window, preview); + + HOOK (target_button, SIGNAL_TARGET_BUTTON_CHANGE, target_change_hook, 0); + HOOK (check_preview, JI_SIGNAL_CHECK_CHANGE, preview_change_hook, 0); + HOOK (check_tiled, JI_SIGNAL_CHECK_CHANGE, tiled_change_hook, 0); + HOOK (reload, JI_SIGNAL_BUTTON_SELECT, reload_select_hook, list_convmatr); + HOOK (generate, JI_SIGNAL_BUTTON_SELECT, generate_select_hook, 0); + + /* XXXX enable this someday */ + jwidget_disable (generate); + + /* default position */ + jwindow_remap (window); + jwindow_center (window); + + /* load window configuration */ + load_window_pos (window, "ConvolutionMatrix"); + + /* select default convmatr */ + listbox_select_current_convmatr (list_convmatr); + + /* open the window */ + jwindow_open_fg (window); + + if (jwindow_get_killer (window) == button_ok) { + effect_apply_to_target (effect); + } + + effect_free (effect); + + /* update editors */ + GUI_Refresh (sprite); + + /* save window configuration */ + save_window_pos (window, "ConvolutionMatrix"); + + jwidget_free (window); +} + +static JWidget listbox_generate_convmatg (void) +{ + JWidget listbox = jlistbox_new (); + listbox_fill_convmatg (listbox); + HOOK (listbox, JI_SIGNAL_LISTBOX_CHANGE, list_change_hook, 0); + return listbox; +} + +static void listbox_fill_convmatg (JWidget listbox) +{ + ConvMatr *convmatr; + JWidget listitem; + JLink link; + + JI_LIST_FOR_EACH(get_convmatr_stock(), link) { + convmatr = link->data; + listitem = jlistitem_new(convmatr->name); + listitem->user_data[0] = convmatr; + jwidget_add_child(listbox, listitem); + } +} + +static void listbox_select_current_convmatr (JWidget listbox) +{ + const char *selected = get_config_string ("ConvolutionMatrix", + "Selected", ""); + JWidget select_this = jlist_first_data(listbox->children); + JWidget child = NULL; + JLink link; + + if (selected && *selected) { + JI_LIST_FOR_EACH(listbox->children, link) { + child = link->data; + + if (strcmp(jwidget_get_text(child), selected) == 0) { + select_this = child; + break; + } + } + } + + if (select_this) { + jwidget_select (select_this); + list_change_hook (listbox, 0); + } +} + +static int reload_select_hook(JWidget widget, int user_data) +{ + JWidget listbox = (JWidget)user_data; + JWidget listitem; + JLink link, next; + + /* clean the list */ + JI_LIST_FOR_EACH_SAFE(listbox->children, link, next) { + listitem = link->data; + jwidget_remove_child (listbox, listitem); + jwidget_free (listitem); + } + + /* re-load the convolution matrix stock */ + reload_matrices_stock (); + + /* re-fill the list */ + listbox_fill_convmatg (listbox); + listbox_select_current_convmatr (listbox); + jview_update (jwidget_get_view (listbox)); + + return TRUE; /* do not close */ +} + +static int generate_select_hook (JWidget widget, int user_data) +{ + JWidget window; + JWidget view_x; + JWidget view_y; + JWidget curvedit_x; + JWidget curvedit_y; + Curve *curve_x; + Curve *curve_y; + JWidget div, div_auto; + JWidget bias, bias_auto; + + window = load_widget ("convmatr.jid", "generate_convolution_matrix"); + if (!window) + return TRUE; /* don't close */ + + if (!get_widgets (window, + "view_x", &view_x, + "view_y", &view_y, + "div", &div, + "bias", &bias, + "div_auto", &div_auto, + "bias_auto", &bias_auto, NULL)) { + jwidget_free (window); + return TRUE; /* don't close */ + } + + /* curve_x = curve_new (CURVE_SPLINE); */ + /* curve_y = curve_new (CURVE_SPLINE); */ + curve_x = curve_new (CURVE_LINEAR); + curve_y = curve_new (CURVE_LINEAR); + curve_add_point (curve_x, curve_point_new (-100, 0)); + curve_add_point (curve_x, curve_point_new (0, +100)); + curve_add_point (curve_x, curve_point_new (+100, 0)); + curve_add_point (curve_y, curve_point_new (-100, 0)); + curve_add_point (curve_y, curve_point_new (0, +100)); + curve_add_point (curve_y, curve_point_new (+100, 0)); + + curvedit_x = curve_editor_new (curve_x, -200, -200, 200, 200); + curvedit_y = curve_editor_new (curve_y, -200, -200, 200, 200); + + jview_attach (view_x, curvedit_x); + jview_attach (view_y, curvedit_y); + + jwidget_set_static_size (view_x, 64, 64); + jwidget_set_static_size (view_y, 64, 64); + + /* XXX fix this */ + /* jwidget_get_vtable (div)->request_size = NULL; */ + /* jwidget_get_vtable (bias)->request_size = NULL; */ + + jwidget_set_static_size (div, 1, 1); + jwidget_set_static_size (bias, 1, 1); + + jwindow_open_fg (window); + + /* XXX do something */ + + jwidget_free (window); + + curve_free (curve_x); + curve_free (curve_y); + + return TRUE; /* do not close */ +} + +static int list_change_hook (JWidget widget, int user_data) +{ + JWidget selected = jlistbox_get_selected_child (widget); + ConvMatr *convmatr = selected->user_data[0]; + + set_config_string ("ConvolutionMatrix", "Selected", convmatr->name); + + set_convmatr (convmatr); + make_preview (); + return FALSE; +} + +static int target_change_hook (JWidget widget, int user_data) +{ + effect_load_target (preview_get_effect (preview)); + make_preview (); + return FALSE; +} + +static int preview_change_hook (JWidget widget, int user_data) +{ + set_config_bool ("ConvolutionMatrix", "Preview", + jwidget_is_selected (widget)); + make_preview (); + return FALSE; +} + +static int tiled_change_hook (JWidget widget, int user_data) +{ + set_tiled_mode (jwidget_is_selected (widget)); + make_preview (); + return FALSE; +} + +static void make_preview (void) +{ + if (jwidget_is_selected (check_preview)) + preview_restart (preview); +} diff --git a/src/dialogs/effect/dmedian.c b/src/commands/fx/cmd_despeckle.c similarity index 93% rename from src/dialogs/effect/dmedian.c rename to src/commands/fx/cmd_despeckle.c index 280dc80d0..c568d36ec 100644 --- a/src/dialogs/effect/dmedian.c +++ b/src/commands/fx/cmd_despeckle.c @@ -1,197 +1,198 @@ -/* 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/box.h" -#include "jinete/button.h" -#include "jinete/entry.h" -#include "jinete/hook.h" -#include "jinete/widget.h" -#include "jinete/window.h" - -#include "console/console.h" -#include "core/cfg.h" -#include "core/core.h" -#include "effect/effect.h" -#include "effect/median.h" -/* #include "modules/editors.h" */ -#include "modules/gui.h" -#include "modules/sprites.h" -#include "modules/tools.h" -#include "raster/image.h" -#include "raster/mask.h" -#include "raster/sprite.h" -#include "util/misc.h" -#include "widgets/preview.h" -#include "widgets/target.h" - -#endif - -static JWidget entry_width, entry_height; -static JWidget check_preview, preview; -static JWidget check_tiled; - -static int width_change_hook (JWidget widget, int user_data); -static int height_change_hook (JWidget widget, int user_data); -static int target_change_hook (JWidget widget, int user_data); -static int preview_change_hook (JWidget widget, int user_data); -static int tiled_change_hook (JWidget widget, int user_data); -static void make_preview (void); - -void dialogs_median_filter(void) -{ - JWidget window, box_target, target_button, button_ok; - Image *image; - Effect *effect; - char buf[32]; - - if (!is_interactive () || !current_sprite) - return; - - image = GetImage (); - if (!image) - return; - - window = load_widget ("median.jid", "median"); - if (!window) - return; - - if (!get_widgets (window, - "width", &entry_width, - "height", &entry_height, - "preview", &check_preview, - "tiled", &check_tiled, - "target", &box_target, - "button_ok", &button_ok, NULL)) { - jwidget_free (window); - return; - } - - effect = effect_new (current_sprite, "median"); - if (!effect) { - console_printf (_("Error creating the effect applicator for this sprite\n")); - jwidget_free (window); - return; - } - - preview = preview_new (effect); - - target_button = target_button_new (current_sprite->imgtype, TRUE); - - sprintf (buf, "%d", get_config_int ("Median", "Width", 3)); - jwidget_set_text (entry_width, buf); - sprintf (buf, "%d", get_config_int ("Median", "Height", 3)); - jwidget_set_text (entry_height, buf); - - if (get_config_bool ("Median", "Preview", TRUE)) - jwidget_select (check_preview); - - if (get_tiled_mode ()) - jwidget_select (check_tiled); - - jwidget_add_child (box_target, target_button); - jwidget_add_child (window, preview); - - HOOK (entry_width, JI_SIGNAL_ENTRY_CHANGE, width_change_hook, 0); - HOOK (entry_height, JI_SIGNAL_ENTRY_CHANGE, height_change_hook, 0); - HOOK (target_button, SIGNAL_TARGET_BUTTON_CHANGE, target_change_hook, 0); - HOOK (check_preview, JI_SIGNAL_CHECK_CHANGE, preview_change_hook, 0); - HOOK (check_tiled, JI_SIGNAL_CHECK_CHANGE, tiled_change_hook, 0); - - /* default position */ - jwindow_remap (window); - jwindow_center (window); - - /* first preview */ - make_preview (); - - /* load window configuration */ - load_window_pos (window, "Median"); - - /* open the window */ - jwindow_open_fg (window); - - if (jwindow_get_killer (window) == button_ok) { - effect_apply_to_target (effect); - } - - effect_free (effect); - - /* update editors */ - GUI_Refresh (current_sprite); - - /* save window configuration */ - save_window_pos (window, "Median"); - - jwidget_free (window); -} - -static int width_change_hook (JWidget widget, int user_data) -{ - set_config_int ("Median", "Width", - strtol (jwidget_get_text (widget), NULL, 10)); - make_preview (); - return TRUE; -} - -static int height_change_hook (JWidget widget, int user_data) -{ - set_config_int ("Median", "Height", - strtol (jwidget_get_text (widget), NULL, 10)); - make_preview (); - return TRUE; -} - -static int target_change_hook (JWidget widget, int user_data) -{ - effect_load_target (preview_get_effect (preview)); - make_preview (); - return FALSE; -} - -static int preview_change_hook (JWidget widget, int user_data) -{ - set_config_bool ("Median", "Preview", jwidget_is_selected (widget)); - make_preview (); - return FALSE; -} - -static int tiled_change_hook (JWidget widget, int user_data) -{ - set_tiled_mode (jwidget_is_selected (widget)); - make_preview (); - return FALSE; -} - -static void make_preview (void) -{ - int w, h; - - w = get_config_int ("Median", "Width", 3); - h = get_config_int ("Median", "Height", 3); - - set_median_size (MID (1, w, 32), MID (1, h, 32)); - - if (jwidget_is_selected (check_preview)) - preview_restart (preview); -} +/* 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 + +#include "jinete/box.h" +#include "jinete/button.h" +#include "jinete/entry.h" +#include "jinete/hook.h" +#include "jinete/widget.h" +#include "jinete/window.h" + +#include "console/console.h" +#include "core/cfg.h" +#include "core/core.h" +#include "effect/effect.h" +#include "effect/median.h" +#include "modules/gui.h" +#include "modules/sprites.h" +#include "modules/tools.h" +#include "raster/image.h" +#include "raster/mask.h" +#include "raster/sprite.h" +#include "util/misc.h" +#include "widgets/preview.h" +#include "widgets/target.h" + +#endif + +static JWidget entry_width, entry_height; +static JWidget check_preview, preview; +static JWidget check_tiled; + +static int width_change_hook (JWidget widget, int user_data); +static int height_change_hook (JWidget widget, int user_data); +static int target_change_hook (JWidget widget, int user_data); +static int preview_change_hook (JWidget widget, int user_data); +static int tiled_change_hook (JWidget widget, int user_data); +static void make_preview (void); + +bool command_enabled_despeckle(const char *argument) +{ + return current_sprite != NULL; +} + +void command_execute_despeckle(const char *argument) +{ + JWidget window, box_target, target_button, button_ok; + Image *image; + Effect *effect; + char buf[32]; + + image = GetImage (); + if (!image) + return; + + window = load_widget ("median.jid", "median"); + if (!window) + return; + + if (!get_widgets (window, + "width", &entry_width, + "height", &entry_height, + "preview", &check_preview, + "tiled", &check_tiled, + "target", &box_target, + "button_ok", &button_ok, NULL)) { + jwidget_free (window); + return; + } + + effect = effect_new (current_sprite, "median"); + if (!effect) { + console_printf (_("Error creating the effect applicator for this sprite\n")); + jwidget_free (window); + return; + } + + preview = preview_new (effect); + + target_button = target_button_new (current_sprite->imgtype, TRUE); + + sprintf (buf, "%d", get_config_int ("Median", "Width", 3)); + jwidget_set_text (entry_width, buf); + sprintf (buf, "%d", get_config_int ("Median", "Height", 3)); + jwidget_set_text (entry_height, buf); + + if (get_config_bool ("Median", "Preview", TRUE)) + jwidget_select (check_preview); + + if (get_tiled_mode ()) + jwidget_select (check_tiled); + + jwidget_add_child (box_target, target_button); + jwidget_add_child (window, preview); + + HOOK (entry_width, JI_SIGNAL_ENTRY_CHANGE, width_change_hook, 0); + HOOK (entry_height, JI_SIGNAL_ENTRY_CHANGE, height_change_hook, 0); + HOOK (target_button, SIGNAL_TARGET_BUTTON_CHANGE, target_change_hook, 0); + HOOK (check_preview, JI_SIGNAL_CHECK_CHANGE, preview_change_hook, 0); + HOOK (check_tiled, JI_SIGNAL_CHECK_CHANGE, tiled_change_hook, 0); + + /* default position */ + jwindow_remap (window); + jwindow_center (window); + + /* first preview */ + make_preview (); + + /* load window configuration */ + load_window_pos (window, "Median"); + + /* open the window */ + jwindow_open_fg (window); + + if (jwindow_get_killer (window) == button_ok) { + effect_apply_to_target (effect); + } + + effect_free (effect); + + /* update editors */ + GUI_Refresh (current_sprite); + + /* save window configuration */ + save_window_pos (window, "Median"); + + jwidget_free (window); +} + +static int width_change_hook (JWidget widget, int user_data) +{ + set_config_int ("Median", "Width", + strtol (jwidget_get_text (widget), NULL, 10)); + make_preview (); + return TRUE; +} + +static int height_change_hook (JWidget widget, int user_data) +{ + set_config_int ("Median", "Height", + strtol (jwidget_get_text (widget), NULL, 10)); + make_preview (); + return TRUE; +} + +static int target_change_hook (JWidget widget, int user_data) +{ + effect_load_target (preview_get_effect (preview)); + make_preview (); + return FALSE; +} + +static int preview_change_hook (JWidget widget, int user_data) +{ + set_config_bool ("Median", "Preview", jwidget_is_selected (widget)); + make_preview (); + return FALSE; +} + +static int tiled_change_hook (JWidget widget, int user_data) +{ + set_tiled_mode (jwidget_is_selected (widget)); + make_preview (); + return FALSE; +} + +static void make_preview (void) +{ + int w, h; + + w = get_config_int ("Median", "Width", 3); + h = get_config_int ("Median", "Height", 3); + + set_median_size (MID (1, w, 32), MID (1, h, 32)); + + if (jwidget_is_selected (check_preview)) + preview_restart (preview); +} diff --git a/src/dialogs/effect/dinvcol.c b/src/commands/fx/cmd_invert_color.c similarity index 52% rename from src/dialogs/effect/dinvcol.c rename to src/commands/fx/cmd_invert_color.c index a3cffa460..0efdfb389 100644 --- a/src/dialogs/effect/dinvcol.c +++ b/src/commands/fx/cmd_invert_color.c @@ -1,147 +1,148 @@ -/* 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/box.h" -#include "jinete/button.h" -#include "jinete/hook.h" -#include "jinete/label.h" -#include "jinete/slider.h" -#include "jinete/widget.h" -#include "jinete/window.h" - -#include "console/console.h" -#include "core/cfg.h" -#include "core/core.h" -#include "effect/effect.h" -#include "modules/color.h" -/* #include "modules/editors.h" */ -#include "modules/gui.h" -#include "modules/sprites.h" -#include "raster/image.h" -#include "raster/mask.h" -#include "raster/sprite.h" -#include "util/misc.h" -#include "widgets/colbar.h" -#include "widgets/colbut.h" -#include "widgets/preview.h" -#include "widgets/target.h" - -#endif - -static JWidget check_preview, preview; - -static int target_change_hook (JWidget widget, int user_data); -static int preview_change_hook (JWidget widget, int user_data); -static void make_preview (void); - -void dialogs_invert_color(void) -{ - JWidget window, box_target, target_button, button_ok; - Sprite *sprite = current_sprite; - Image *image; - Effect *effect; - - if (!is_interactive () || !sprite) - return; - - image = GetImage (); - if (!image) - return; - - window = load_widget ("invrtcol.jid", "invert_color"); - if (!window) - return; - - if (!get_widgets (window, - "target", &box_target, - "preview", &check_preview, - "button_ok", &button_ok, NULL)) { - jwidget_free (window); - return; - } - - effect = effect_new (sprite, "invert_color"); - if (!effect) { - console_printf (_("Error creating the effect applicator for this sprite\n")); - jwidget_free (window); - return; - } - - preview = preview_new (effect); - target_button = target_button_new (sprite->imgtype, TRUE); - - if (get_config_bool ("InvertColor", "Preview", TRUE)) - jwidget_select (check_preview); - - jwidget_add_child (box_target, target_button); - jwidget_add_child (window, preview); - - HOOK (target_button, SIGNAL_TARGET_BUTTON_CHANGE, target_change_hook, 0); - HOOK (check_preview, JI_SIGNAL_CHECK_CHANGE, preview_change_hook, 0); - - /* default position */ - jwindow_remap (window); - jwindow_center (window); - - /* first preview */ - make_preview (); - - /* load window configuration */ - load_window_pos (window, "InvertColor"); - - /* open the window */ - jwindow_open_fg (window); - - if (jwindow_get_killer (window) == button_ok) { - effect_apply_to_target (effect); - } - - effect_free (effect); - - /* update editors */ - GUI_Refresh (sprite); - - /* save window configuration */ - save_window_pos (window, "InvertColor"); - - jwidget_free (window); -} - -static int target_change_hook (JWidget widget, int user_data) -{ - effect_load_target (preview_get_effect (preview)); - make_preview (); - return FALSE; -} - -static int preview_change_hook (JWidget widget, int user_data) -{ - set_config_bool ("InvertColor", "Preview", jwidget_is_selected (widget)); - make_preview (); - return FALSE; -} - -static void make_preview (void) -{ - if (jwidget_is_selected (check_preview)) - preview_restart (preview); -} +/* 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/box.h" +#include "jinete/button.h" +#include "jinete/hook.h" +#include "jinete/label.h" +#include "jinete/slider.h" +#include "jinete/widget.h" +#include "jinete/window.h" + +#include "console/console.h" +#include "core/cfg.h" +#include "core/core.h" +#include "effect/effect.h" +#include "modules/color.h" +#include "modules/gui.h" +#include "modules/sprites.h" +#include "raster/image.h" +#include "raster/mask.h" +#include "raster/sprite.h" +#include "util/misc.h" +#include "widgets/colbar.h" +#include "widgets/colbut.h" +#include "widgets/preview.h" +#include "widgets/target.h" + +#endif + +static JWidget check_preview, preview; + +static int target_change_hook (JWidget widget, int user_data); +static int preview_change_hook (JWidget widget, int user_data); +static void make_preview (void); + +bool command_enabled_invert_color(const char *argument) +{ + return current_sprite != NULL; +} + +void command_execute_invert_color(const char *argument) +{ + JWidget window, box_target, target_button, button_ok; + Sprite *sprite = current_sprite; + Image *image; + Effect *effect; + + image = GetImage(); + if (!image) + return; + + window = load_widget("invrtcol.jid", "invert_color"); + if (!window) + return; + + if (!get_widgets(window, + "target", &box_target, + "preview", &check_preview, + "button_ok", &button_ok, NULL)) { + jwidget_free(window); + return; + } + + effect = effect_new(sprite, "invert_color"); + if (!effect) { + console_printf(_("Error creating the effect applicator for this sprite\n")); + jwidget_free(window); + return; + } + + preview = preview_new(effect); + target_button = target_button_new(sprite->imgtype, TRUE); + + if (get_config_bool("InvertColor", "Preview", TRUE)) + jwidget_select(check_preview); + + jwidget_add_child(box_target, target_button); + jwidget_add_child(window, preview); + + HOOK(target_button, SIGNAL_TARGET_BUTTON_CHANGE, target_change_hook, 0); + HOOK(check_preview, JI_SIGNAL_CHECK_CHANGE, preview_change_hook, 0); + + /* default position */ + jwindow_remap(window); + jwindow_center(window); + + /* first preview */ + make_preview(); + + /* load window configuration */ + load_window_pos(window, "InvertColor"); + + /* open the window */ + jwindow_open_fg(window); + + if (jwindow_get_killer(window) == button_ok) { + effect_apply_to_target(effect); + } + + effect_free(effect); + + /* update editors */ + GUI_Refresh(sprite); + + /* save window configuration */ + save_window_pos(window, "InvertColor"); + + jwidget_free(window); +} + +static int target_change_hook(JWidget widget, int user_data) +{ + effect_load_target(preview_get_effect(preview)); + make_preview(); + return FALSE; +} + +static int preview_change_hook(JWidget widget, int user_data) +{ + set_config_bool("InvertColor", "Preview", jwidget_is_selected(widget)); + make_preview(); + return FALSE; +} + +static void make_preview(void) +{ + if (jwidget_is_selected(check_preview)) + preview_restart(preview); +} diff --git a/src/commands/fx/cmd_replace_color.c b/src/commands/fx/cmd_replace_color.c new file mode 100644 index 000000000..d8a8b1ec2 --- /dev/null +++ b/src/commands/fx/cmd_replace_color.c @@ -0,0 +1,233 @@ +/* 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 + +#include "jinete.h" + +#include "console/console.h" +#include "core/app.h" +#include "core/cfg.h" +#include "core/core.h" +#include "effect/effect.h" +#include "effect/replcol.h" +#include "modules/color.h" +#include "modules/gui.h" +#include "modules/sprites.h" +#include "raster/image.h" +#include "raster/mask.h" +#include "raster/sprite.h" +#include "util/misc.h" +#include "widgets/colbar.h" +#include "widgets/colbut.h" +#include "widgets/preview.h" +#include "widgets/target.h" + +#endif + +static JWidget button_color1, button_color2; +static JWidget slider_fuzziness, check_preview; +static JWidget preview; + +static int button_1_select_hook(JWidget widget, int user_data); +static int button_2_select_hook(JWidget widget, int user_data); +static int color_change_hook(JWidget widget, int user_data); +static int target_change_hook(JWidget widget, int user_data); +static int slider_change_hook(JWidget widget, int user_data); +static int preview_change_hook(JWidget widget, int user_data); +static void make_preview(void); + +bool command_enabled_replace_color(const char *argument) +{ + return current_sprite != NULL; +} + +void command_execute_replace_color(const char *argument) +{ + JWidget window, color_buttons_box; + JWidget button1_1, button1_2; + JWidget button2_1, button2_2; + JWidget box_target, target_button; + JWidget button_ok; + Image *image; + Effect *effect; + + image = GetImage(); + if (!image) + return; + + window = load_widget("replcol.jid", "replace_color"); + if (!window) + return; + + if (!get_widgets(window, + "color_buttons_box", &color_buttons_box, + "button1_1", &button1_1, + "button1_2", &button1_2, + "button2_1", &button2_1, + "button2_2", &button2_2, + "preview", &check_preview, + "fuzziness", &slider_fuzziness, + "target", &box_target, + "button_ok", &button_ok, NULL)) { + jwidget_free(window); + return; + } + + effect = effect_new(current_sprite, "replace_color"); + if (!effect) { + console_printf(_("Error creating the effect applicator for this sprite\n")); + jwidget_free(window); + return; + } + + preview = preview_new(effect); + + button_color1 = color_button_new + (get_config_string("ReplaceColor", "Color1", + color_bar_get_color(app_get_color_bar(), 0)), + current_sprite->imgtype); + + button_color2 = color_button_new + (get_config_string("ReplaceColor", "Color2", + color_bar_get_color(app_get_color_bar(), 1)), + current_sprite->imgtype); + + target_button = target_button_new(current_sprite->imgtype, FALSE); + + jslider_set_value(slider_fuzziness, + get_config_int ("ReplaceColor", "Fuzziness", 0)); + if (get_config_bool("ReplaceColor", "Preview", TRUE)) + jwidget_select(check_preview); + + jwidget_add_child(color_buttons_box, button_color1); + jwidget_add_child(color_buttons_box, button_color2); + jwidget_add_child(box_target, target_button); + jwidget_add_child(window, preview); + + HOOK(button1_1, JI_SIGNAL_BUTTON_SELECT, button_1_select_hook, 1); + HOOK(button1_2, JI_SIGNAL_BUTTON_SELECT, button_2_select_hook, 1); + HOOK(button2_1, JI_SIGNAL_BUTTON_SELECT, button_1_select_hook, 2); + HOOK(button2_2, JI_SIGNAL_BUTTON_SELECT, button_2_select_hook, 2); + HOOK(button_color1, SIGNAL_COLOR_BUTTON_CHANGE, color_change_hook, 1); + HOOK(button_color2, SIGNAL_COLOR_BUTTON_CHANGE, color_change_hook, 2); + HOOK(target_button, SIGNAL_TARGET_BUTTON_CHANGE, target_change_hook, 0); + HOOK(slider_fuzziness, JI_SIGNAL_SLIDER_CHANGE, slider_change_hook, 0); + HOOK(check_preview, JI_SIGNAL_CHECK_CHANGE, preview_change_hook, 0); + + /* default position */ + jwindow_remap(window); + jwindow_center(window); + + /* first preview */ + make_preview(); + + /* load window configuration */ + load_window_pos(window, "ReplaceColor"); + + /* open the window */ + jwindow_open_fg(window); + + if (jwindow_get_killer(window) == button_ok) { + effect_apply_to_target(effect); + } + + effect_free(effect); + + /* update editors */ + GUI_Refresh(current_sprite); + + /* save window configuration */ + save_window_pos(window, "ReplaceColor"); + + jwidget_free(window); +} + +static int button_1_select_hook (JWidget widget, int user_data) +{ + JWidget w = user_data == 1 ? button_color1: button_color2; + + color_button_set_color(w, color_bar_get_color(app_get_color_bar(), 0)); + color_change_hook(w, user_data); + + return TRUE; +} + +static int button_2_select_hook (JWidget widget, int user_data) +{ + JWidget w = user_data == 1 ? button_color1: button_color2; + + color_button_set_color(w, color_bar_get_color(app_get_color_bar(), 1)); + color_change_hook(w, user_data); + + return TRUE; +} + +static int color_change_hook(JWidget widget, int user_data) +{ + char buf[64]; + + sprintf(buf, "Color%d", user_data); + set_config_string("ReplaceColor", buf, color_button_get_color(widget)); + + make_preview(); + return FALSE; +} + +static int target_change_hook(JWidget widget, int user_data) +{ + effect_load_target(preview_get_effect(preview)); + make_preview(); + return FALSE; +} + +static int slider_change_hook(JWidget widget, int user_data) +{ + set_config_int("ReplaceColor", "Fuzziness", jslider_get_value (widget)); + make_preview(); + return FALSE; +} + +static int preview_change_hook(JWidget widget, int user_data) +{ + set_config_bool("ReplaceColor", "Preview", jwidget_is_selected (widget)); + make_preview(); + return FALSE; +} + +static void make_preview(void) +{ + Effect *effect = preview_get_effect(preview); + const char *from, *to; + int fuzziness; + + from = get_config_string("ReplaceColor", "Color1", "mask"); + to = get_config_string("ReplaceColor", "Color2", "mask"); + fuzziness = get_config_int("ReplaceColor", "Fuzziness", 0); + + set_replace_colors(get_color_for_image(effect->dst->imgtype, from), + get_color_for_image(effect->dst->imgtype, to), + MID(0, fuzziness, 255)); + + if (jwidget_is_selected(check_preview)) + preview_restart(preview); +} diff --git a/src/dialogs/effect.h b/src/dialogs/effect.h deleted file mode 100644 index d99724de3..000000000 --- a/src/dialogs/effect.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_EFFECT_H -#define DIALOGS_EFFECT_H - -void dialogs_color_curve(void); -void dialogs_convolution_matrix(void); -void dialogs_invert_color(void); -void dialogs_median_filter(void); -void dialogs_replace_color(void); - -#endif /* DIALOGS_EFFECT_H */ diff --git a/src/dialogs/effect/dreplcol.c b/src/dialogs/effect/dreplcol.c deleted file mode 100644 index 689811d2b..000000000 --- a/src/dialogs/effect/dreplcol.c +++ /dev/null @@ -1,232 +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 - -#include "jinete.h" - -#include "console/console.h" -#include "core/app.h" -#include "core/cfg.h" -#include "core/core.h" -#include "effect/effect.h" -#include "effect/replcol.h" -#include "modules/color.h" -/* #include "modules/editors.h" */ -#include "modules/gui.h" -#include "modules/sprites.h" -#include "raster/image.h" -#include "raster/mask.h" -#include "raster/sprite.h" -#include "util/misc.h" -#include "widgets/colbar.h" -#include "widgets/colbut.h" -#include "widgets/preview.h" -#include "widgets/target.h" - -#endif - -static JWidget button_color1, button_color2; -static JWidget slider_fuzziness, check_preview; -static JWidget preview; - -static int button_1_select_hook (JWidget widget, int user_data); -static int button_2_select_hook (JWidget widget, int user_data); -static int color_change_hook (JWidget widget, int user_data); -static int target_change_hook (JWidget widget, int user_data); -static int slider_change_hook (JWidget widget, int user_data); -static int preview_change_hook (JWidget widget, int user_data); -static void make_preview (void); - -void dialogs_replace_color(void) -{ - JWidget window, color_buttons_box; - JWidget button1_1, button1_2; - JWidget button2_1, button2_2; - JWidget box_target, target_button; - JWidget button_ok; - Image *image; - Effect *effect; - - if (!is_interactive () || !current_sprite) - return; - - image = GetImage (); - if (!image) - return; - - window = load_widget ("replcol.jid", "replace_color"); - if (!window) - return; - - if (!get_widgets (window, - "color_buttons_box", &color_buttons_box, - "button1_1", &button1_1, - "button1_2", &button1_2, - "button2_1", &button2_1, - "button2_2", &button2_2, - "preview", &check_preview, - "fuzziness", &slider_fuzziness, - "target", &box_target, - "button_ok", &button_ok, NULL)) { - jwidget_free (window); - return; - } - - effect = effect_new (current_sprite, "replace_color"); - if (!effect) { - console_printf (_("Error creating the effect applicator for this sprite\n")); - jwidget_free (window); - return; - } - - preview = preview_new (effect); - - button_color1 = color_button_new - (get_config_string ("ReplaceColor", "Color1", - color_bar_get_color (app_get_color_bar (), 0)), - current_sprite->imgtype); - - button_color2 = color_button_new - (get_config_string ("ReplaceColor", "Color2", - color_bar_get_color (app_get_color_bar (), 1)), - current_sprite->imgtype); - - target_button = target_button_new (current_sprite->imgtype, FALSE); - - jslider_set_value (slider_fuzziness, - get_config_int ("ReplaceColor", "Fuzziness", 0)); - if (get_config_bool ("ReplaceColor", "Preview", TRUE)) - jwidget_select (check_preview); - - jwidget_add_child (color_buttons_box, button_color1); - jwidget_add_child (color_buttons_box, button_color2); - jwidget_add_child (box_target, target_button); - jwidget_add_child (window, preview); - - HOOK (button1_1, JI_SIGNAL_BUTTON_SELECT, button_1_select_hook, 1); - HOOK (button1_2, JI_SIGNAL_BUTTON_SELECT, button_2_select_hook, 1); - HOOK (button2_1, JI_SIGNAL_BUTTON_SELECT, button_1_select_hook, 2); - HOOK (button2_2, JI_SIGNAL_BUTTON_SELECT, button_2_select_hook, 2); - HOOK (button_color1, SIGNAL_COLOR_BUTTON_CHANGE, color_change_hook, 1); - HOOK (button_color2, SIGNAL_COLOR_BUTTON_CHANGE, color_change_hook, 2); - HOOK (target_button, SIGNAL_TARGET_BUTTON_CHANGE, target_change_hook, 0); - HOOK (slider_fuzziness, JI_SIGNAL_SLIDER_CHANGE, slider_change_hook, 0); - HOOK (check_preview, JI_SIGNAL_CHECK_CHANGE, preview_change_hook, 0); - - /* default position */ - jwindow_remap (window); - jwindow_center (window); - - /* first preview */ - make_preview (); - - /* load window configuration */ - load_window_pos (window, "ReplaceColor"); - - /* open the window */ - jwindow_open_fg (window); - - if (jwindow_get_killer (window) == button_ok) { - effect_apply_to_target (effect); - } - - effect_free (effect); - - /* update editors */ - GUI_Refresh (current_sprite); - - /* save window configuration */ - save_window_pos (window, "ReplaceColor"); - - jwidget_free (window); -} - -static int button_1_select_hook (JWidget widget, int user_data) -{ - JWidget w = user_data == 1 ? button_color1: button_color2; - - color_button_set_color (w, color_bar_get_color (app_get_color_bar (), 0)); - color_change_hook (w, user_data); - - return TRUE; -} - -static int button_2_select_hook (JWidget widget, int user_data) -{ - JWidget w = user_data == 1 ? button_color1: button_color2; - - color_button_set_color (w, color_bar_get_color (app_get_color_bar (), 1)); - color_change_hook (w, user_data); - - return TRUE; -} - -static int color_change_hook (JWidget widget, int user_data) -{ - char buf[64]; - - sprintf (buf, "Color%d", user_data); - set_config_string ("ReplaceColor", buf, color_button_get_color (widget)); - - make_preview (); - return FALSE; -} - -static int target_change_hook (JWidget widget, int user_data) -{ - effect_load_target (preview_get_effect (preview)); - make_preview (); - return FALSE; -} - -static int slider_change_hook (JWidget widget, int user_data) -{ - set_config_int ("ReplaceColor", "Fuzziness", jslider_get_value (widget)); - make_preview (); - return FALSE; -} - -static int preview_change_hook (JWidget widget, int user_data) -{ - set_config_bool ("ReplaceColor", "Preview", jwidget_is_selected (widget)); - make_preview (); - return FALSE; -} - -static void make_preview (void) -{ - Effect *effect = preview_get_effect (preview); - const char *from, *to; - int fuzziness; - - from = get_config_string ("ReplaceColor", "Color1", "mask"); - to = get_config_string ("ReplaceColor", "Color2", "mask"); - fuzziness = get_config_int ("ReplaceColor", "Fuzziness", 0); - - set_replace_colors (get_color_for_image (effect->dst->imgtype, from), - get_color_for_image (effect->dst->imgtype, to), - MID (0, fuzziness, 255)); - - if (jwidget_is_selected (check_preview)) - preview_restart (preview); -} diff --git a/src/modules/rootmenu.c b/src/modules/rootmenu.c index 3f9633cc7..4d1745f57 100644 --- a/src/modules/rootmenu.c +++ b/src/modules/rootmenu.c @@ -95,9 +95,9 @@ int load_root_menu(void) dirs = filename_in_datadir("usergui.xml"); { char buf[256]; - sprintf(buf, "defgui-%s.xml", intl_get_lang()); + sprintf(buf, "gui-%s.xml", intl_get_lang()); dirs_cat_dirs(dirs, filename_in_datadir(buf)); - dirs_cat_dirs(dirs, filename_in_datadir("defgui-en.xml")); + dirs_cat_dirs(dirs, filename_in_datadir("gui-en.xml")); } for (dir=dirs; dir; dir=dir->next) { diff --git a/src/script/bindings.c b/src/script/bindings.c index 773de0f85..778cc1a68 100644 --- a/src/script/bindings.c +++ b/src/script/bindings.c @@ -287,7 +287,7 @@ static int metatable_index(lua_State *L) else if (strcmp (index, "writable") == 0) lua_pushboolean (L, layer->writable); else if (strcmp (index, "prev") == 0) - push_userdata (L, Type_Layer, layer_get_prev (layer)); + push_userdata (L, Type_Layer, layer_get_prev (layer)); else if (strcmp (index, "next") == 0) push_userdata (L, Type_Layer, layer_get_next (layer)); else { @@ -719,7 +719,6 @@ static int bind_jwidget_hook_signal (lua_State *L) #include "dialogs/canvasze.h" #include "dialogs/dmapgen.h" #include "dialogs/drawtext.h" -#include "dialogs/effect.h" #include "dialogs/filmedit.h" #include "dialogs/maskcol.h" #include "dialogs/options.h" @@ -734,7 +733,6 @@ static int bind_jwidget_hook_signal (lua_State *L) #include "util/autocrop.h" #include "util/clipbrd.h" #include "util/crop.h" -#include "util/flip.h" #include "util/frmove.h" #include "util/mapgen.h" #include "util/msk_file.h" diff --git a/src/script/export.h b/src/script/export.h index 1cf35d763..367434cba 100644 --- a/src/script/export.h +++ b/src/script/export.h @@ -225,11 +225,6 @@ void crop_sprite(void); void crop_layer(void); void crop_frame(void); -/* util/flip.c */ - -void flip_horizontal(void); -void flip_vertical(void); - /* util/frame.c */ void set_frame_to_handle(Layer *layer, Frame *frame); @@ -285,17 +280,12 @@ int set_gfx(const char *card, int w, int h, int depth); /* dialogs/... */ -void dialogs_color_curve(void); -void dialogs_convolution_matrix(void); void dialogs_draw_text(void); void switch_between_film_and_sprite_editor(void); -void dialogs_invert_color(void); void dialogs_mapgen(void); void dialogs_mask_color(void); -void dialogs_median_filter(void); void dialogs_options(void); void dialogs_palette_editor(void); -void dialogs_replace_color(void); void dialogs_screen_saver(void); void dialogs_select_language(bool force); void dialogs_tips(bool forced); diff --git a/src/script/genbinds.c b/src/script/genbinds.c index d58614376..7da86bcb3 100644 --- a/src/script/genbinds.c +++ b/src/script/genbinds.c @@ -1133,18 +1133,6 @@ static int bind_crop_frame(lua_State *L) return 0; } -static int bind_flip_horizontal(lua_State *L) -{ - flip_horizontal(); - return 0; -} - -static int bind_flip_vertical(lua_State *L) -{ - flip_vertical(); - return 0; -} - static int bind_set_frame_to_handle(lua_State *L) { Layer *layer; @@ -1317,18 +1305,6 @@ static int bind_set_gfx(lua_State *L) return 1; } -static int bind_dialogs_color_curve(lua_State *L) -{ - dialogs_color_curve(); - return 0; -} - -static int bind_dialogs_convolution_matrix(lua_State *L) -{ - dialogs_convolution_matrix(); - return 0; -} - static int bind_dialogs_draw_text(lua_State *L) { dialogs_draw_text(); @@ -1341,12 +1317,6 @@ static int bind_switch_between_film_and_sprite_editor(lua_State *L) return 0; } -static int bind_dialogs_invert_color(lua_State *L) -{ - dialogs_invert_color(); - return 0; -} - static int bind_dialogs_mapgen(lua_State *L) { dialogs_mapgen(); @@ -1359,12 +1329,6 @@ static int bind_dialogs_mask_color(lua_State *L) return 0; } -static int bind_dialogs_median_filter(lua_State *L) -{ - dialogs_median_filter(); - return 0; -} - static int bind_dialogs_options(lua_State *L) { dialogs_options(); @@ -1377,12 +1341,6 @@ static int bind_dialogs_palette_editor(lua_State *L) return 0; } -static int bind_dialogs_replace_color(lua_State *L) -{ - dialogs_replace_color(); - return 0; -} - static int bind_dialogs_screen_saver(lua_State *L) { dialogs_screen_saver(); @@ -5725,8 +5683,6 @@ const luaL_reg bindings_routines[] = { { "crop_sprite", bind_crop_sprite }, { "crop_layer", bind_crop_layer }, { "crop_frame", bind_crop_frame }, - { "flip_horizontal", bind_flip_horizontal }, - { "flip_vertical", bind_flip_vertical }, { "set_frame_to_handle", bind_set_frame_to_handle }, { "move_frame", bind_move_frame }, { "copy_frame", bind_copy_frame }, @@ -5749,17 +5705,12 @@ const luaL_reg bindings_routines[] = { { "quick_swap", bind_quick_swap }, { "play_fli_animation", bind_play_fli_animation }, { "set_gfx", bind_set_gfx }, - { "dialogs_color_curve", bind_dialogs_color_curve }, - { "dialogs_convolution_matrix", bind_dialogs_convolution_matrix }, { "dialogs_draw_text", bind_dialogs_draw_text }, { "switch_between_film_and_sprite_editor", bind_switch_between_film_and_sprite_editor }, - { "dialogs_invert_color", bind_dialogs_invert_color }, { "dialogs_mapgen", bind_dialogs_mapgen }, { "dialogs_mask_color", bind_dialogs_mask_color }, - { "dialogs_median_filter", bind_dialogs_median_filter }, { "dialogs_options", bind_dialogs_options }, { "dialogs_palette_editor", bind_dialogs_palette_editor }, - { "dialogs_replace_color", bind_dialogs_replace_color }, { "dialogs_screen_saver", bind_dialogs_screen_saver }, { "dialogs_select_language", bind_dialogs_select_language }, { "dialogs_tips", bind_dialogs_tips }, diff --git a/src/util/flip.h b/src/util/flip.h deleted file mode 100644 index 7efc661a5..000000000 --- a/src/util/flip.h +++ /dev/null @@ -1,26 +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 UTIL_FLIP_H -#define UTIL_FLIP_H - -void flip_horizontal (void); -void flip_vertical (void); - -#endif /* UTIL_FLIP_H */ -