mirror of https://github.com/aseprite/aseprite.git
Files reformatted (changed "function_call ()" to "function_call()" ).
This commit is contained in:
parent
7fe8991db2
commit
8cc8d732e2
|
|
@ -103,71 +103,71 @@ static void cmd_configure_tools_execute(const char *argument)
|
|||
"brush_type_box", &brush_type_box,
|
||||
"brush_mode_box", &brush_mode_box,
|
||||
"onionskin", &check_onionskin, NULL)) {
|
||||
jwidget_free (window);
|
||||
jwidget_free(window);
|
||||
return;
|
||||
}
|
||||
|
||||
/* cursor-color */
|
||||
cursor_color = color_button_new (get_cursor_color (), IMAGE_INDEXED);
|
||||
cursor_color = color_button_new(get_cursor_color(), IMAGE_INDEXED);
|
||||
/* brush-preview */
|
||||
brush_preview = jwidget_new (JI_WIDGET);
|
||||
brush_preview = jwidget_new(JI_WIDGET);
|
||||
brush_preview->min_w = 32 + 4;
|
||||
brush_preview->min_h = 32 + 4;
|
||||
jwidget_add_hook(brush_preview, JI_WIDGET,
|
||||
brush_preview_msg_proc, NULL);
|
||||
/* brush-type */
|
||||
brush_type = group_button_new (3, 1, get_brush_type (),
|
||||
GFX_BRUSH_CIRCLE,
|
||||
GFX_BRUSH_SQUARE,
|
||||
GFX_BRUSH_LINE);
|
||||
brush_type = group_button_new(3, 1, get_brush_type(),
|
||||
GFX_BRUSH_CIRCLE,
|
||||
GFX_BRUSH_SQUARE,
|
||||
GFX_BRUSH_LINE);
|
||||
/* brush-type */
|
||||
brush_mode = group_button_new (3, 1, get_brush_mode (),
|
||||
GFX_DRAWMODE_OPAQUE,
|
||||
GFX_DRAWMODE_GLASS,
|
||||
GFX_DRAWMODE_SEMI);
|
||||
brush_mode = group_button_new(3, 1, get_brush_mode(),
|
||||
GFX_DRAWMODE_OPAQUE,
|
||||
GFX_DRAWMODE_GLASS,
|
||||
GFX_DRAWMODE_SEMI);
|
||||
|
||||
/* append children */
|
||||
jwidget_add_child (cursor_color_box, cursor_color);
|
||||
jwidget_add_child (brush_preview_box, brush_preview);
|
||||
jwidget_add_child (brush_type_box, brush_type);
|
||||
jwidget_add_child (brush_mode_box, brush_mode);
|
||||
jwidget_add_child(cursor_color_box, cursor_color);
|
||||
jwidget_add_child(brush_preview_box, brush_preview);
|
||||
jwidget_add_child(brush_type_box, brush_type);
|
||||
jwidget_add_child(brush_mode_box, brush_mode);
|
||||
|
||||
if (get_filled_mode ()) jwidget_select (filled);
|
||||
if (get_tiled_mode ()) jwidget_select (tiled);
|
||||
if (get_use_grid ()) jwidget_select (use_grid);
|
||||
if (get_view_grid ()) jwidget_select (view_grid);
|
||||
jslider_set_value (brush_size, get_brush_size ());
|
||||
jslider_set_value (brush_angle, get_brush_angle ());
|
||||
jslider_set_value (glass_dirty, get_glass_dirty ());
|
||||
jslider_set_value (spray_width, get_spray_width ());
|
||||
jslider_set_value (air_speed, get_air_speed ());
|
||||
if (get_onionskin ()) jwidget_select (check_onionskin);
|
||||
if (get_filled_mode()) jwidget_select(filled);
|
||||
if (get_tiled_mode()) jwidget_select(tiled);
|
||||
if (get_use_grid()) jwidget_select(use_grid);
|
||||
if (get_view_grid()) jwidget_select(view_grid);
|
||||
jslider_set_value(brush_size, get_brush_size());
|
||||
jslider_set_value(brush_angle, get_brush_angle());
|
||||
jslider_set_value(glass_dirty, get_glass_dirty());
|
||||
jslider_set_value(spray_width, get_spray_width());
|
||||
jslider_set_value(air_speed, get_air_speed());
|
||||
if (get_onionskin()) jwidget_select(check_onionskin);
|
||||
|
||||
HOOK (window, JI_SIGNAL_WINDOW_CLOSE, window_close_hook, 0);
|
||||
HOOK (filled, JI_SIGNAL_CHECK_CHANGE, filled_check_change_hook, 0);
|
||||
HOOK (tiled, JI_SIGNAL_CHECK_CHANGE, tiled_check_change_hook, 0);
|
||||
HOOK (use_grid, JI_SIGNAL_CHECK_CHANGE, use_grid_check_change_hook, 0);
|
||||
HOOK (view_grid, JI_SIGNAL_CHECK_CHANGE, view_grid_check_change_hook, 0);
|
||||
HOOK (set_grid, JI_SIGNAL_BUTTON_SELECT, set_grid_button_select_hook, 0);
|
||||
HOOK (brush_size, JI_SIGNAL_SLIDER_CHANGE, brush_size_slider_change_hook, brush_preview);
|
||||
HOOK (brush_angle, JI_SIGNAL_SLIDER_CHANGE, brush_angle_slider_change_hook, brush_preview);
|
||||
HOOK (brush_type, SIGNAL_GROUP_BUTTON_CHANGE, brush_type_change_hook, brush_preview);
|
||||
HOOK (brush_mode, SIGNAL_GROUP_BUTTON_CHANGE, brush_mode_change_hook, 0);
|
||||
HOOK (glass_dirty, JI_SIGNAL_SLIDER_CHANGE, glass_dirty_slider_change_hook, 0);
|
||||
HOOK (air_speed, JI_SIGNAL_SLIDER_CHANGE, air_speed_slider_change_hook, 0);
|
||||
HOOK (spray_width, JI_SIGNAL_SLIDER_CHANGE, spray_width_slider_change_hook, 0);
|
||||
HOOK (cursor_color, SIGNAL_COLOR_BUTTON_CHANGE, cursor_button_change_hook, 0);
|
||||
HOOK (check_onionskin, JI_SIGNAL_CHECK_CHANGE, onionskin_check_change_hook, 0);
|
||||
HOOK(window, JI_SIGNAL_WINDOW_CLOSE, window_close_hook, 0);
|
||||
HOOK(filled, JI_SIGNAL_CHECK_CHANGE, filled_check_change_hook, 0);
|
||||
HOOK(tiled, JI_SIGNAL_CHECK_CHANGE, tiled_check_change_hook, 0);
|
||||
HOOK(use_grid, JI_SIGNAL_CHECK_CHANGE, use_grid_check_change_hook, 0);
|
||||
HOOK(view_grid, JI_SIGNAL_CHECK_CHANGE, view_grid_check_change_hook, 0);
|
||||
HOOK(set_grid, JI_SIGNAL_BUTTON_SELECT, set_grid_button_select_hook, 0);
|
||||
HOOK(brush_size, JI_SIGNAL_SLIDER_CHANGE, brush_size_slider_change_hook, brush_preview);
|
||||
HOOK(brush_angle, JI_SIGNAL_SLIDER_CHANGE, brush_angle_slider_change_hook, brush_preview);
|
||||
HOOK(brush_type, SIGNAL_GROUP_BUTTON_CHANGE, brush_type_change_hook, brush_preview);
|
||||
HOOK(brush_mode, SIGNAL_GROUP_BUTTON_CHANGE, brush_mode_change_hook, 0);
|
||||
HOOK(glass_dirty, JI_SIGNAL_SLIDER_CHANGE, glass_dirty_slider_change_hook, 0);
|
||||
HOOK(air_speed, JI_SIGNAL_SLIDER_CHANGE, air_speed_slider_change_hook, 0);
|
||||
HOOK(spray_width, JI_SIGNAL_SLIDER_CHANGE, spray_width_slider_change_hook, 0);
|
||||
HOOK(cursor_color, SIGNAL_COLOR_BUTTON_CHANGE, cursor_button_change_hook, 0);
|
||||
HOOK(check_onionskin, JI_SIGNAL_CHECK_CHANGE, onionskin_check_change_hook, 0);
|
||||
|
||||
/* default position */
|
||||
jwindow_remap (window);
|
||||
jwindow_center (window);
|
||||
jwindow_remap(window);
|
||||
jwindow_center(window);
|
||||
|
||||
/* load window configuration */
|
||||
load_window_pos (window, "ConfigureTool");
|
||||
load_window_pos(window, "ConfigureTool");
|
||||
|
||||
/* open the window */
|
||||
jwindow_open_bg (window);
|
||||
jwindow_open_bg(window);
|
||||
}
|
||||
|
||||
static bool brush_preview_msg_proc(JWidget widget, JMessage msg)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2007 David A. Capello
|
||||
* Copyright (C) 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -107,7 +107,7 @@ static void do_flip(int horz)
|
|||
image_putpixel(image,
|
||||
horz ? x2-x: x1+x,
|
||||
!horz? y2-y: y1+y,
|
||||
image_getpixel (area, x, y));
|
||||
image_getpixel(area, x, y));
|
||||
image_free(area);
|
||||
update_screen_for_sprite(current_sprite);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,9 +84,9 @@ static void preview_sprite(int flags)
|
|||
JWidget widget = current_editor;
|
||||
|
||||
if (widget && editor_get_sprite(widget)) {
|
||||
Editor *editor = editor_data (widget);
|
||||
Sprite *sprite = editor_get_sprite (widget);
|
||||
JWidget view = jwidget_get_view (widget);
|
||||
Editor *editor = editor_data(widget);
|
||||
Sprite *sprite = editor_get_sprite(widget);
|
||||
JWidget view = jwidget_get_view(widget);
|
||||
int old_mouse_x, old_mouse_y;
|
||||
int scroll_x, scroll_y;
|
||||
int u, v, x, y, w, h;
|
||||
|
|
@ -105,7 +105,7 @@ static void preview_sprite(int flags)
|
|||
old_mouse_x = jmouse_x(0);
|
||||
old_mouse_y = jmouse_y(0);
|
||||
|
||||
bmp = create_bitmap (sprite->w, sprite->h);
|
||||
bmp = create_bitmap(sprite->w, sprite->h);
|
||||
if (bmp) {
|
||||
/* print a informative text */
|
||||
status_bar_set_text(app_get_status_bar(), 1, _("Rendering..."));
|
||||
|
|
@ -155,7 +155,7 @@ static void preview_sprite(int flags)
|
|||
|
||||
sx = (double)JI_SCREEN_W / (double)bmp->w;
|
||||
sy = (double)JI_SCREEN_H / (double)bmp->h;
|
||||
scale = MIN (sx, sy);
|
||||
scale = MIN(sx, sy);
|
||||
|
||||
outw = (double)bmp->w * (double)scale;
|
||||
outh = (double)bmp->h * (double)scale;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2007 David A. Capello
|
||||
* Copyright (C) 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -66,8 +66,8 @@ static void cmd_color_curve_execute(const char *argument)
|
|||
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));
|
||||
curve_add_point(the_curve, curve_point_new(0, 0));
|
||||
curve_add_point(the_curve, curve_point_new(255, 255));
|
||||
}
|
||||
|
||||
image = GetImage();
|
||||
|
|
@ -140,7 +140,7 @@ static void cmd_color_curve_execute(const char *argument)
|
|||
jwidget_free(window);
|
||||
}
|
||||
|
||||
static bool hooked_msg_proc (JWidget widget, JMessage msg)
|
||||
static bool hooked_msg_proc(JWidget widget, JMessage msg)
|
||||
{
|
||||
if (msg->type == JM_SIGNAL) {
|
||||
switch (msg->signal.num) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2007 David A. Capello
|
||||
* Copyright (C) 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -59,18 +59,18 @@
|
|||
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 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 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);
|
||||
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);
|
||||
|
||||
static bool cmd_convolution_matrix_enabled(const char *argument)
|
||||
{
|
||||
|
|
@ -87,11 +87,11 @@ static void cmd_convolution_matrix_execute(const char *argument)
|
|||
Image *image;
|
||||
Effect *effect;
|
||||
|
||||
image = GetImage ();
|
||||
image = GetImage();
|
||||
if (!image)
|
||||
return;
|
||||
|
||||
window = load_widget ("convmatr.jid", "convolution_matrix");
|
||||
window = load_widget("convmatr.jid", "convolution_matrix");
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
|
|
@ -131,52 +131,52 @@ static void cmd_convolution_matrix_execute(const char *argument)
|
|||
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);
|
||||
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);
|
||||
|
||||
/* TODO enable this someday */
|
||||
jwidget_disable (generate);
|
||||
jwidget_disable(generate);
|
||||
|
||||
/* default position */
|
||||
jwindow_remap (window);
|
||||
jwindow_center (window);
|
||||
jwindow_remap(window);
|
||||
jwindow_center(window);
|
||||
|
||||
/* load window configuration */
|
||||
load_window_pos (window, "ConvolutionMatrix");
|
||||
load_window_pos(window, "ConvolutionMatrix");
|
||||
|
||||
/* select default convmatr */
|
||||
listbox_select_current_convmatr (list_convmatr);
|
||||
listbox_select_current_convmatr(list_convmatr);
|
||||
|
||||
/* open the window */
|
||||
jwindow_open_fg (window);
|
||||
jwindow_open_fg(window);
|
||||
|
||||
if (jwindow_get_killer (window) == button_ok) {
|
||||
effect_apply_to_target (effect);
|
||||
if (jwindow_get_killer(window) == button_ok) {
|
||||
effect_apply_to_target(effect);
|
||||
}
|
||||
|
||||
effect_free (effect);
|
||||
effect_free(effect);
|
||||
|
||||
/* update editors */
|
||||
update_screen_for_sprite (sprite);
|
||||
update_screen_for_sprite(sprite);
|
||||
|
||||
/* save window configuration */
|
||||
save_window_pos (window, "ConvolutionMatrix");
|
||||
save_window_pos(window, "ConvolutionMatrix");
|
||||
|
||||
jwidget_free (window);
|
||||
jwidget_free(window);
|
||||
}
|
||||
|
||||
static JWidget listbox_generate_convmatg (void)
|
||||
static JWidget listbox_generate_convmatg(void)
|
||||
{
|
||||
JWidget listbox = jlistbox_new ();
|
||||
listbox_fill_convmatg (listbox);
|
||||
HOOK (listbox, JI_SIGNAL_LISTBOX_CHANGE, list_change_hook, 0);
|
||||
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)
|
||||
static void listbox_fill_convmatg(JWidget listbox)
|
||||
{
|
||||
ConvMatr *convmatr;
|
||||
JWidget listitem;
|
||||
|
|
@ -190,10 +190,10 @@ static void listbox_fill_convmatg (JWidget listbox)
|
|||
}
|
||||
}
|
||||
|
||||
static void listbox_select_current_convmatr (JWidget listbox)
|
||||
static void listbox_select_current_convmatr(JWidget listbox)
|
||||
{
|
||||
const char *selected = get_config_string ("ConvolutionMatrix",
|
||||
"Selected", "");
|
||||
const char *selected = get_config_string("ConvolutionMatrix",
|
||||
"Selected", "");
|
||||
JWidget select_this = jlist_first_data(listbox->children);
|
||||
JWidget child = NULL;
|
||||
JLink link;
|
||||
|
|
@ -210,8 +210,8 @@ static void listbox_select_current_convmatr (JWidget listbox)
|
|||
}
|
||||
|
||||
if (select_this) {
|
||||
jwidget_select (select_this);
|
||||
list_change_hook (listbox, 0);
|
||||
jwidget_select(select_this);
|
||||
list_change_hook(listbox, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -224,17 +224,17 @@ static int reload_select_hook(JWidget widget, int user_data)
|
|||
/* clean the list */
|
||||
JI_LIST_FOR_EACH_SAFE(listbox->children, link, next) {
|
||||
listitem = link->data;
|
||||
jwidget_remove_child (listbox, listitem);
|
||||
jwidget_free (listitem);
|
||||
jwidget_remove_child(listbox, listitem);
|
||||
jwidget_free(listitem);
|
||||
}
|
||||
|
||||
/* re-load the convolution matrix stock */
|
||||
reload_matrices_stock ();
|
||||
reload_matrices_stock();
|
||||
|
||||
/* re-fill the list */
|
||||
listbox_fill_convmatg (listbox);
|
||||
listbox_select_current_convmatr (listbox);
|
||||
jview_update (jwidget_get_view (listbox));
|
||||
listbox_fill_convmatg(listbox);
|
||||
listbox_select_current_convmatr(listbox);
|
||||
jview_update(jwidget_get_view(listbox));
|
||||
|
||||
return TRUE; /* do not close */
|
||||
}
|
||||
|
|
@ -270,12 +270,12 @@ static int generate_select_hook(JWidget widget, int user_data)
|
|||
/* 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));
|
||||
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);
|
||||
|
|
@ -287,8 +287,8 @@ static int generate_select_hook(JWidget widget, int user_data)
|
|||
jwidget_set_min_size(view_y, 64, 64);
|
||||
|
||||
/* TODO fix this */
|
||||
/* jwidget_get_vtable (div)->request_size = NULL; */
|
||||
/* jwidget_get_vtable (bias)->request_size = NULL; */
|
||||
/* jwidget_get_vtable(div)->request_size = NULL; */
|
||||
/* jwidget_get_vtable(bias)->request_size = NULL; */
|
||||
|
||||
jwidget_set_min_size(div, 1, 1);
|
||||
jwidget_set_min_size(bias, 1, 1);
|
||||
|
|
@ -307,27 +307,27 @@ static int generate_select_hook(JWidget widget, int user_data)
|
|||
|
||||
static int list_change_hook(JWidget widget, int user_data)
|
||||
{
|
||||
JWidget selected = jlistbox_get_selected_child (widget);
|
||||
JWidget selected = jlistbox_get_selected_child(widget);
|
||||
ConvMatr *convmatr = selected->user_data[0];
|
||||
|
||||
set_config_string ("ConvolutionMatrix", "Selected", convmatr->name);
|
||||
set_config_string("ConvolutionMatrix", "Selected", convmatr->name);
|
||||
|
||||
set_convmatr (convmatr);
|
||||
make_preview ();
|
||||
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 ();
|
||||
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));
|
||||
jwidget_is_selected(widget));
|
||||
make_preview();
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -339,10 +339,10 @@ static int tiled_change_hook(JWidget widget, int user_data)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static void make_preview (void)
|
||||
static void make_preview(void)
|
||||
{
|
||||
if (jwidget_is_selected (check_preview))
|
||||
preview_restart (preview);
|
||||
preview_restart(preview);
|
||||
}
|
||||
|
||||
Command cmd_convolution_matrix = {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2007 David A. Capello
|
||||
* Copyright (C) 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -51,12 +51,12 @@ 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);
|
||||
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);
|
||||
|
||||
static bool cmd_despeckle_enabled(const char *argument)
|
||||
{
|
||||
|
|
@ -70,132 +70,132 @@ static void cmd_despeckle_execute(const char *argument)
|
|||
Effect *effect;
|
||||
char buf[32];
|
||||
|
||||
image = GetImage ();
|
||||
image = GetImage();
|
||||
if (!image)
|
||||
return;
|
||||
|
||||
window = load_widget ("median.jid", "median");
|
||||
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);
|
||||
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");
|
||||
effect = effect_new(current_sprite, "median");
|
||||
if (!effect) {
|
||||
console_printf (_("Error creating the effect applicator for this sprite\n"));
|
||||
jwidget_free (window);
|
||||
console_printf(_("Error creating the effect applicator for this sprite\n"));
|
||||
jwidget_free(window);
|
||||
return;
|
||||
}
|
||||
|
||||
preview = preview_new (effect);
|
||||
preview = preview_new(effect);
|
||||
|
||||
target_button = target_button_new (current_sprite->imgtype, TRUE);
|
||||
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);
|
||||
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_config_bool("Median", "Preview", TRUE))
|
||||
jwidget_select(check_preview);
|
||||
|
||||
if (get_tiled_mode ())
|
||||
jwidget_select (check_tiled);
|
||||
if (get_tiled_mode())
|
||||
jwidget_select(check_tiled);
|
||||
|
||||
jwidget_add_child (box_target, target_button);
|
||||
jwidget_add_child (window, preview);
|
||||
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);
|
||||
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);
|
||||
jwindow_remap(window);
|
||||
jwindow_center(window);
|
||||
|
||||
/* first preview */
|
||||
make_preview ();
|
||||
make_preview();
|
||||
|
||||
/* load window configuration */
|
||||
load_window_pos (window, "Median");
|
||||
load_window_pos(window, "Median");
|
||||
|
||||
/* open the window */
|
||||
jwindow_open_fg (window);
|
||||
jwindow_open_fg(window);
|
||||
|
||||
if (jwindow_get_killer (window) == button_ok) {
|
||||
effect_apply_to_target (effect);
|
||||
if (jwindow_get_killer(window) == button_ok) {
|
||||
effect_apply_to_target(effect);
|
||||
}
|
||||
|
||||
effect_free (effect);
|
||||
effect_free(effect);
|
||||
|
||||
/* update editors */
|
||||
update_screen_for_sprite (current_sprite);
|
||||
update_screen_for_sprite(current_sprite);
|
||||
|
||||
/* save window configuration */
|
||||
save_window_pos (window, "Median");
|
||||
save_window_pos(window, "Median");
|
||||
|
||||
jwidget_free (window);
|
||||
jwidget_free(window);
|
||||
}
|
||||
|
||||
static int width_change_hook (JWidget widget, int user_data)
|
||||
static int width_change_hook(JWidget widget, int user_data)
|
||||
{
|
||||
set_config_int ("Median", "Width",
|
||||
strtol (jwidget_get_text (widget), NULL, 10));
|
||||
make_preview ();
|
||||
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)
|
||||
static int height_change_hook(JWidget widget, int user_data)
|
||||
{
|
||||
set_config_int ("Median", "Height",
|
||||
strtol (jwidget_get_text (widget), NULL, 10));
|
||||
make_preview ();
|
||||
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)
|
||||
static int target_change_hook(JWidget widget, int user_data)
|
||||
{
|
||||
effect_load_target (preview_get_effect (preview));
|
||||
make_preview ();
|
||||
effect_load_target(preview_get_effect(preview));
|
||||
make_preview();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int preview_change_hook (JWidget widget, int user_data)
|
||||
static int preview_change_hook(JWidget widget, int user_data)
|
||||
{
|
||||
set_config_bool ("Median", "Preview", jwidget_is_selected (widget));
|
||||
make_preview ();
|
||||
set_config_bool("Median", "Preview", jwidget_is_selected(widget));
|
||||
make_preview();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int tiled_change_hook (JWidget widget, int user_data)
|
||||
static int tiled_change_hook(JWidget widget, int user_data)
|
||||
{
|
||||
set_tiled_mode (jwidget_is_selected (widget));
|
||||
make_preview ();
|
||||
set_tiled_mode(jwidget_is_selected(widget));
|
||||
make_preview();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void make_preview (void)
|
||||
static void make_preview(void)
|
||||
{
|
||||
int w, h;
|
||||
|
||||
w = get_config_int ("Median", "Width", 3);
|
||||
h = get_config_int ("Median", "Height", 3);
|
||||
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));
|
||||
set_median_size(MID(1, w, 32), MID(1, h, 32));
|
||||
|
||||
if (jwidget_is_selected (check_preview))
|
||||
preview_restart (preview);
|
||||
preview_restart(preview);
|
||||
}
|
||||
|
||||
Command cmd_despeckle = {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2007 David A. Capello
|
||||
* Copyright (C) 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -48,9 +48,9 @@
|
|||
|
||||
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);
|
||||
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);
|
||||
|
||||
static bool cmd_invert_color_enabled(const char *argument)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2007 David A. Capello
|
||||
* Copyright (C) 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -116,7 +116,7 @@ static void cmd_replace_color_execute(const char *argument)
|
|||
target_button = target_button_new(current_sprite->imgtype, FALSE);
|
||||
|
||||
jslider_set_value(slider_fuzziness,
|
||||
get_config_int ("ReplaceColor", "Fuzziness", 0));
|
||||
get_config_int("ReplaceColor", "Fuzziness", 0));
|
||||
if (get_config_bool("ReplaceColor", "Preview", TRUE))
|
||||
jwidget_select(check_preview);
|
||||
|
||||
|
|
@ -163,7 +163,7 @@ static void cmd_replace_color_execute(const char *argument)
|
|||
jwidget_free(window);
|
||||
}
|
||||
|
||||
static int button_1_select_hook (JWidget widget, int user_data)
|
||||
static int button_1_select_hook(JWidget widget, int user_data)
|
||||
{
|
||||
JWidget w = user_data == 1 ? button_color1: button_color2;
|
||||
|
||||
|
|
@ -173,7 +173,7 @@ static int button_1_select_hook (JWidget widget, int user_data)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static int button_2_select_hook (JWidget widget, int user_data)
|
||||
static int button_2_select_hook(JWidget widget, int user_data)
|
||||
{
|
||||
JWidget w = user_data == 1 ? button_color1: button_color2;
|
||||
|
||||
|
|
@ -203,14 +203,14 @@ static int target_change_hook(JWidget widget, int user_data)
|
|||
|
||||
static int slider_change_hook(JWidget widget, int user_data)
|
||||
{
|
||||
set_config_int("ReplaceColor", "Fuzziness", jslider_get_value (widget));
|
||||
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));
|
||||
set_config_bool("ReplaceColor", "Preview", jwidget_is_selected(widget));
|
||||
make_preview();
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ int app_init(int argc, char *argv[])
|
|||
REQUIRE_SCRIPTING) < 0)
|
||||
return -1;
|
||||
|
||||
_ji_font_init ();
|
||||
_ji_font_init();
|
||||
|
||||
/* custom default palette? */
|
||||
if (palette_filename) {
|
||||
|
|
@ -148,13 +148,13 @@ int app_init(int argc, char *argv[])
|
|||
return -1;
|
||||
}
|
||||
|
||||
destroy_bitmap (bmp);
|
||||
destroy_bitmap(bmp);
|
||||
|
||||
set_default_palette (pal);
|
||||
set_default_palette(pal);
|
||||
}
|
||||
|
||||
/* set system palette to the default one */
|
||||
set_current_palette (NULL, TRUE);
|
||||
set_current_palette(NULL, TRUE);
|
||||
|
||||
/* ok */
|
||||
return 0;
|
||||
|
|
@ -366,7 +366,7 @@ void app_refresh_screen(void)
|
|||
|
||||
/* updates the sprites list menu. WARNING!: This routine can't be used
|
||||
when a menu callback was called, because, it destroy some menus,
|
||||
you should use rebuild_sprite_list () instead (src/gui/gui.c) */
|
||||
you should use rebuild_sprite_list() instead (src/gui/gui.c) */
|
||||
void app_realloc_sprite_list(void)
|
||||
{
|
||||
Sprite *sprite;
|
||||
|
|
@ -395,10 +395,10 @@ void app_realloc_sprite_list(void)
|
|||
char buf[256];
|
||||
int c, count = 0;
|
||||
|
||||
submenu = jmenuitem_get_submenu (list_menuitem);
|
||||
submenu = jmenuitem_get_submenu(list_menuitem);
|
||||
if (submenu) {
|
||||
jmenuitem_set_submenu (list_menuitem, NULL);
|
||||
jwidget_free (submenu);
|
||||
jmenuitem_set_submenu(list_menuitem, NULL);
|
||||
jwidget_free(submenu);
|
||||
}
|
||||
|
||||
submenu = jmenu_new();
|
||||
|
|
@ -454,7 +454,7 @@ void app_realloc_sprite_list(void)
|
|||
menuitem = menuitem_new(_("More"), NULL, NULL);
|
||||
jwidget_add_child(submenu, menuitem);
|
||||
|
||||
submenu = jmenu_new ();
|
||||
submenu = jmenu_new();
|
||||
jmenuitem_set_submenu(menuitem, submenu);
|
||||
count = 0;
|
||||
}
|
||||
|
|
@ -477,7 +477,7 @@ void app_realloc_sprite_list(void)
|
|||
|
||||
/* updates the recent list menu. WARNING!: This routine can't be used
|
||||
when a menu callback was called, because, it destroy the menus,
|
||||
you should use rebuild_recent_list () instead (src/gui/gui.c). */
|
||||
you should use rebuild_recent_list() instead (src/gui/gui.c). */
|
||||
void app_realloc_recent_list(void)
|
||||
{
|
||||
JWidget list_menuitem = get_recent_list_menuitem();
|
||||
|
|
@ -490,7 +490,7 @@ void app_realloc_recent_list(void)
|
|||
Command *cmd_open_file = command_get_by_name(CMD_OPEN_FILE);
|
||||
JWidget submenu;
|
||||
|
||||
submenu = jmenuitem_get_submenu (list_menuitem);
|
||||
submenu = jmenuitem_get_submenu(list_menuitem);
|
||||
if (submenu) {
|
||||
jmenuitem_set_submenu(list_menuitem, NULL);
|
||||
jwidget_free(submenu);
|
||||
|
|
@ -566,7 +566,7 @@ static int check_args(int argc, char *argv[])
|
|||
if (++i < argc)
|
||||
jlist_append(options, option_new(DO_SCRIPT_EXPR, argv[i]));
|
||||
else
|
||||
usage (1);
|
||||
usage(1);
|
||||
}
|
||||
/* open script file */
|
||||
else if (strncmp(arg+n, "file", len) == 0) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -78,12 +78,12 @@ void core_exit(void)
|
|||
{
|
||||
#ifdef NEED_LOG
|
||||
if (log_fileptr) {
|
||||
fclose (log_fileptr);
|
||||
fclose(log_fileptr);
|
||||
log_fileptr = NULL;
|
||||
}
|
||||
|
||||
if (log_filename) {
|
||||
free (log_filename);
|
||||
free(log_filename);
|
||||
log_filename = NULL;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
#endif
|
||||
|
||||
void canvas_resize (void)
|
||||
void canvas_resize(void)
|
||||
{
|
||||
JWidget window, box1, box2, box3, box4, box5, box6;
|
||||
JWidget label_w, label_h;
|
||||
|
|
@ -56,64 +56,64 @@ void canvas_resize (void)
|
|||
if (!is_interactive () || !sprite)
|
||||
return;
|
||||
|
||||
window = jwindow_new (_("Canvas Size"));
|
||||
box1 = jbox_new (JI_VERTICAL);
|
||||
box2 = jbox_new (JI_HORIZONTAL);
|
||||
box3 = jbox_new (JI_VERTICAL | JI_HOMOGENEOUS);
|
||||
box4 = jbox_new (JI_VERTICAL | JI_HOMOGENEOUS);
|
||||
box5 = jbox_new (JI_VERTICAL | JI_HOMOGENEOUS);
|
||||
box6 = jbox_new (JI_HORIZONTAL | JI_HOMOGENEOUS);
|
||||
label_w = jlabel_new (_("Width:"));
|
||||
label_h = jlabel_new (_("Height:"));
|
||||
entry_w = jentry_new (8, "%d", sprite->w);
|
||||
entry_h = jentry_new (8, "%d", sprite->h);
|
||||
check_w = jcheck_new ("%");
|
||||
check_h = jcheck_new ("%");
|
||||
button_offset = group_button_new (3, 3, 4,
|
||||
-1, -1, -1,
|
||||
-1, -1, -1,
|
||||
-1, -1, -1);
|
||||
button_ok = jbutton_new (_("&OK"));
|
||||
button_cancel = jbutton_new (_("&Cancel"));
|
||||
window = jwindow_new(_("Canvas Size"));
|
||||
box1 = jbox_new(JI_VERTICAL);
|
||||
box2 = jbox_new(JI_HORIZONTAL);
|
||||
box3 = jbox_new(JI_VERTICAL | JI_HOMOGENEOUS);
|
||||
box4 = jbox_new(JI_VERTICAL | JI_HOMOGENEOUS);
|
||||
box5 = jbox_new(JI_VERTICAL | JI_HOMOGENEOUS);
|
||||
box6 = jbox_new(JI_HORIZONTAL | JI_HOMOGENEOUS);
|
||||
label_w = jlabel_new(_("Width:"));
|
||||
label_h = jlabel_new(_("Height:"));
|
||||
entry_w = jentry_new(8, "%d", sprite->w);
|
||||
entry_h = jentry_new(8, "%d", sprite->h);
|
||||
check_w = jcheck_new("%");
|
||||
check_h = jcheck_new("%");
|
||||
button_offset = group_button_new(3, 3, 4,
|
||||
-1, -1, -1,
|
||||
-1, -1, -1,
|
||||
-1, -1, -1);
|
||||
button_ok = jbutton_new(_("&OK"));
|
||||
button_cancel = jbutton_new(_("&Cancel"));
|
||||
|
||||
jwidget_magnetic (button_ok, TRUE);
|
||||
jwidget_magnetic(button_ok, TRUE);
|
||||
|
||||
jwidget_expansive (box2, TRUE);
|
||||
jwidget_expansive (button_offset, TRUE);
|
||||
jwidget_expansive(box2, TRUE);
|
||||
jwidget_expansive(button_offset, TRUE);
|
||||
|
||||
jwidget_add_child (box3, label_w);
|
||||
jwidget_add_child (box3, label_h);
|
||||
jwidget_add_child (box4, entry_w);
|
||||
jwidget_add_child (box4, entry_h);
|
||||
jwidget_add_child (box5, check_w);
|
||||
jwidget_add_child (box5, check_h);
|
||||
jwidget_add_child (box2, box3);
|
||||
jwidget_add_child (box2, box4);
|
||||
jwidget_add_child (box2, box5);
|
||||
jwidget_add_child (box2, button_offset);
|
||||
jwidget_add_child (box1, box2);
|
||||
jwidget_add_child (box6, button_ok);
|
||||
jwidget_add_child (box6, button_cancel);
|
||||
jwidget_add_child (box1, box6);
|
||||
jwidget_add_child (window, box1);
|
||||
jwidget_add_child(box3, label_w);
|
||||
jwidget_add_child(box3, label_h);
|
||||
jwidget_add_child(box4, entry_w);
|
||||
jwidget_add_child(box4, entry_h);
|
||||
jwidget_add_child(box5, check_w);
|
||||
jwidget_add_child(box5, check_h);
|
||||
jwidget_add_child(box2, box3);
|
||||
jwidget_add_child(box2, box4);
|
||||
jwidget_add_child(box2, box5);
|
||||
jwidget_add_child(box2, button_offset);
|
||||
jwidget_add_child(box1, box2);
|
||||
jwidget_add_child(box6, button_ok);
|
||||
jwidget_add_child(box6, button_cancel);
|
||||
jwidget_add_child(box1, box6);
|
||||
jwidget_add_child(window, box1);
|
||||
|
||||
/* default position */
|
||||
jwindow_remap (window);
|
||||
jwindow_center (window);
|
||||
jwindow_remap(window);
|
||||
jwindow_center(window);
|
||||
|
||||
/* load window configuration */
|
||||
load_window_pos (window, "CanvasSize");
|
||||
load_window_pos(window, "CanvasSize");
|
||||
|
||||
/* open the window */
|
||||
jwindow_open_fg (window);
|
||||
jwindow_open_fg(window);
|
||||
|
||||
if (jwindow_get_killer (window) == button_ok) {
|
||||
if (jwindow_get_killer(window) == button_ok) {
|
||||
/* update editors */
|
||||
update_screen_for_sprite(sprite);
|
||||
}
|
||||
|
||||
/* save window configuration */
|
||||
save_window_pos (window, "CanvasSize");
|
||||
save_window_pos(window, "CanvasSize");
|
||||
|
||||
jwidget_free (window);
|
||||
jwidget_free(window);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef DIALOGS_CANVASZE_H
|
||||
#define DIALOGS_CANVASZE_H
|
||||
|
||||
void canvas_resize (void);
|
||||
void canvas_resize(void);
|
||||
|
||||
#endif /* DIALOGS_CANVASZE_H */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -161,7 +161,7 @@ char *ji_color_select(int imgtype, const char *color)
|
|||
/* check the killer widget */
|
||||
if (jwindow_get_killer(window) == button_ok) {
|
||||
/* selected color */
|
||||
selected_color = jstrdup(color_viewer_get_color (color_viewer));
|
||||
selected_color = jstrdup(color_viewer_get_color(color_viewer));
|
||||
}
|
||||
/* cancel or ESC */
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef DIALOGS_COLSEL_H
|
||||
#define DIALOGS_COLSEL_H
|
||||
|
||||
char *ji_color_select (int imgtype, const char *color);
|
||||
char *ji_color_select(int imgtype, const char *color);
|
||||
|
||||
#endif /* DIALOGS_COLSEL_H */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -50,14 +50,14 @@
|
|||
static JWidget entry_width, entry_height, entry_seed, entry_factor;
|
||||
static JWidget preview_map, check_preview;
|
||||
|
||||
static void regen_map (int forced);
|
||||
static void random_seed_command (JWidget widget);
|
||||
static void sqrt2_factor_command (JWidget widget);
|
||||
static int change_hook (JWidget widget, int user_data);
|
||||
static void regen_map(int forced);
|
||||
static void random_seed_command(JWidget widget);
|
||||
static void sqrt2_factor_command(JWidget widget);
|
||||
static int change_hook(JWidget widget, int user_data);
|
||||
|
||||
static JWidget image_viewer_new(Image *image);
|
||||
static bool image_viewer_msg_proc(JWidget widget, JMessage msg);
|
||||
|
||||
static JWidget image_viewer_new (Image *image);
|
||||
static bool image_viewer_msg_proc (JWidget widget, JMessage msg);
|
||||
|
||||
void dialogs_mapgen(void)
|
||||
{
|
||||
JWidget window, view_map, check_tiled, button_ok;
|
||||
|
|
@ -68,7 +68,7 @@ void dialogs_mapgen(void)
|
|||
char buf[256];
|
||||
int w, h, seed;
|
||||
|
||||
window = load_widget ("mapgen.jid", "mapgen");
|
||||
window = load_widget("mapgen.jid", "mapgen");
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
|
|
@ -81,12 +81,12 @@ void dialogs_mapgen(void)
|
|||
"preview", &check_preview,
|
||||
"tiled", &check_tiled,
|
||||
"button_ok", &button_ok, NULL)) {
|
||||
jwidget_free (window);
|
||||
jwidget_free(window);
|
||||
return;
|
||||
}
|
||||
|
||||
/* get current palette */
|
||||
palette_copy (old_palette, current_palette);
|
||||
palette_copy(old_palette, current_palette);
|
||||
|
||||
/* load terrain palette */
|
||||
{
|
||||
|
|
@ -110,129 +110,129 @@ void dialogs_mapgen(void)
|
|||
set_current_palette(sprite_get_palette(sprite, 0), FALSE);
|
||||
jmanager_refresh_screen();
|
||||
|
||||
w = get_config_int ("MapGen", "Width", 256);
|
||||
sprintf (buf, "%d", MID (1, w, 9999));
|
||||
jwidget_set_text (entry_width, buf);
|
||||
w = get_config_int("MapGen", "Width", 256);
|
||||
sprintf(buf, "%d", MID(1, w, 9999));
|
||||
jwidget_set_text(entry_width, buf);
|
||||
|
||||
h = get_config_int ("MapGen", "Height", 256);
|
||||
sprintf (buf, "%d", MID (1, h, 9999));
|
||||
jwidget_set_text (entry_height, buf);
|
||||
h = get_config_int("MapGen", "Height", 256);
|
||||
sprintf(buf, "%d", MID(1, h, 9999));
|
||||
jwidget_set_text(entry_height, buf);
|
||||
|
||||
seed = get_config_int ("MapGen", "Seed", 662355502);
|
||||
sprintf (buf, "%d", seed);
|
||||
jwidget_set_text (entry_seed, buf);
|
||||
seed = get_config_int("MapGen", "Seed", 662355502);
|
||||
sprintf(buf, "%d", seed);
|
||||
jwidget_set_text(entry_seed, buf);
|
||||
|
||||
factor = get_config_float ("MapGen", "FractalFactor", M_SQRT2);
|
||||
sprintf (buf, "%.16g", factor);
|
||||
jwidget_set_text (entry_factor, buf);
|
||||
factor = get_config_float("MapGen", "FractalFactor", M_SQRT2);
|
||||
sprintf(buf, "%.16g", factor);
|
||||
jwidget_set_text(entry_factor, buf);
|
||||
|
||||
if (get_config_bool ("MapGen", "Preview", TRUE))
|
||||
jwidget_select (check_preview);
|
||||
if (get_config_bool("MapGen", "Preview", TRUE))
|
||||
jwidget_select(check_preview);
|
||||
|
||||
jwidget_select (check_tiled);
|
||||
jwidget_disable (check_tiled);
|
||||
jwidget_select(check_tiled);
|
||||
jwidget_disable(check_tiled);
|
||||
|
||||
HOOK (check_preview, JI_SIGNAL_CHECK_CHANGE, change_hook, 0);
|
||||
HOOK (entry_seed, JI_SIGNAL_ENTRY_CHANGE, change_hook, 0);
|
||||
HOOK (entry_factor, JI_SIGNAL_ENTRY_CHANGE, change_hook, 0);
|
||||
HOOK(check_preview, JI_SIGNAL_CHECK_CHANGE, change_hook, 0);
|
||||
HOOK(entry_seed, JI_SIGNAL_ENTRY_CHANGE, change_hook, 0);
|
||||
HOOK(entry_factor, JI_SIGNAL_ENTRY_CHANGE, change_hook, 0);
|
||||
|
||||
jbutton_add_command (jwidget_find_name (window, "random_seed"),
|
||||
random_seed_command);
|
||||
jbutton_add_command (jwidget_find_name (window, "sqrt2_factor"),
|
||||
sqrt2_factor_command);
|
||||
jbutton_add_command(jwidget_find_name(window, "random_seed"),
|
||||
random_seed_command);
|
||||
jbutton_add_command(jwidget_find_name(window, "sqrt2_factor"),
|
||||
sqrt2_factor_command);
|
||||
|
||||
jview_attach (view_map, preview_map);
|
||||
jview_attach(view_map, preview_map);
|
||||
|
||||
/* default position */
|
||||
jwindow_remap (window);
|
||||
jwindow_center (window);
|
||||
jwindow_remap(window);
|
||||
jwindow_center(window);
|
||||
|
||||
/* load window configuration */
|
||||
load_window_pos (window, "MapGen");
|
||||
load_window_pos(window, "MapGen");
|
||||
|
||||
/* open the window */
|
||||
regen_map (FALSE);
|
||||
jwindow_open_fg (window);
|
||||
regen_map(FALSE);
|
||||
jwindow_open_fg(window);
|
||||
|
||||
if (jwindow_get_killer (window) == button_ok) {
|
||||
if (jwindow_get_killer(window) == button_ok) {
|
||||
/* generate the map */
|
||||
regen_map (TRUE);
|
||||
regen_map(TRUE);
|
||||
|
||||
/* show the sprite */
|
||||
sprite_show (sprite);
|
||||
sprite_show(sprite);
|
||||
}
|
||||
else {
|
||||
set_current_sprite (old_sprite);
|
||||
set_current_palette (old_palette, FALSE);
|
||||
jmanager_refresh_screen ();
|
||||
set_current_sprite(old_sprite);
|
||||
set_current_palette(old_palette, FALSE);
|
||||
jmanager_refresh_screen();
|
||||
|
||||
sprite_free (sprite);
|
||||
sprite_free(sprite);
|
||||
}
|
||||
|
||||
/* save window configuration */
|
||||
save_window_pos (window, "MapGen");
|
||||
save_window_pos(window, "MapGen");
|
||||
|
||||
jwidget_free (window);
|
||||
jwidget_free(window);
|
||||
}
|
||||
|
||||
static void regen_map (int forced)
|
||||
|
||||
static void regen_map(int forced)
|
||||
{
|
||||
int w, h, seed;
|
||||
double factor;
|
||||
|
||||
if (forced || jwidget_is_selected (check_preview)) {
|
||||
w = strtol (jwidget_get_text (entry_width), NULL, 10);
|
||||
h = strtol (jwidget_get_text (entry_height), NULL, 10);
|
||||
seed = strtol (jwidget_get_text (entry_seed), NULL, 10);
|
||||
factor = strtod (jwidget_get_text (entry_factor), NULL);
|
||||
if (forced || jwidget_is_selected(check_preview)) {
|
||||
w = strtol(jwidget_get_text(entry_width), NULL, 10);
|
||||
h = strtol(jwidget_get_text(entry_height), NULL, 10);
|
||||
seed = strtol(jwidget_get_text(entry_seed), NULL, 10);
|
||||
factor = strtod(jwidget_get_text(entry_factor), NULL);
|
||||
|
||||
if (forced) {
|
||||
set_config_int ("MapGen", "Width", w);
|
||||
set_config_int ("MapGen", "Height", h);
|
||||
set_config_int ("MapGen", "Seed", seed);
|
||||
set_config_float ("MapGen", "FractalFactor", factor);
|
||||
set_config_int("MapGen", "Width", w);
|
||||
set_config_int("MapGen", "Height", h);
|
||||
set_config_int("MapGen", "Seed", seed);
|
||||
set_config_float("MapGen", "FractalFactor", factor);
|
||||
}
|
||||
|
||||
/* generate the map */
|
||||
mapgen (GetImage (), seed, factor);
|
||||
jwidget_dirty (preview_map);
|
||||
mapgen(GetImage(), seed, factor);
|
||||
jwidget_dirty(preview_map);
|
||||
}
|
||||
}
|
||||
|
||||
static void random_seed_command (JWidget widget)
|
||||
static void random_seed_command(JWidget widget)
|
||||
{
|
||||
char buf[256];
|
||||
sprintf (buf, "%d", rand ());
|
||||
jwidget_set_text (entry_seed, buf);
|
||||
regen_map (FALSE);
|
||||
sprintf(buf, "%d", rand());
|
||||
jwidget_set_text(entry_seed, buf);
|
||||
regen_map(FALSE);
|
||||
}
|
||||
|
||||
static void sqrt2_factor_command (JWidget widget)
|
||||
static void sqrt2_factor_command(JWidget widget)
|
||||
{
|
||||
char buf[256];
|
||||
sprintf (buf, "%.16g", M_SQRT2);
|
||||
jwidget_set_text (entry_factor, buf);
|
||||
regen_map (FALSE);
|
||||
sprintf(buf, "%.16g", M_SQRT2);
|
||||
jwidget_set_text(entry_factor, buf);
|
||||
regen_map(FALSE);
|
||||
}
|
||||
|
||||
static int change_hook (JWidget widget, int user_data)
|
||||
static int change_hook(JWidget widget, int user_data)
|
||||
{
|
||||
regen_map (FALSE);
|
||||
regen_map(FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* image viewer (simple preview) */
|
||||
|
||||
static JWidget image_viewer_new (Image *image)
|
||||
static JWidget image_viewer_new(Image *image)
|
||||
{
|
||||
JWidget widget = jwidget_new (JI_WIDGET);
|
||||
jwidget_add_hook (widget, JI_WIDGET, image_viewer_msg_proc, NULL);
|
||||
JWidget widget = jwidget_new(JI_WIDGET);
|
||||
jwidget_add_hook(widget, JI_WIDGET, image_viewer_msg_proc, NULL);
|
||||
widget->user_data[0] = image;
|
||||
return widget;
|
||||
}
|
||||
|
||||
static bool image_viewer_msg_proc (JWidget widget, JMessage msg)
|
||||
static bool image_viewer_msg_proc(JWidget widget, JMessage msg)
|
||||
{
|
||||
Image *image = widget->user_data[0];
|
||||
|
||||
|
|
@ -244,8 +244,8 @@ static bool image_viewer_msg_proc (JWidget widget, JMessage msg)
|
|||
return TRUE;
|
||||
|
||||
case JM_DRAW: {
|
||||
BITMAP *bmp = create_bitmap (image->w, image->h);
|
||||
image_to_allegro (image, bmp, 0, 0);
|
||||
BITMAP *bmp = create_bitmap(image->w, image->h);
|
||||
image_to_allegro(image, bmp, 0, 0);
|
||||
|
||||
_ji_theme_rectfill_exclude
|
||||
(ji_screen,
|
||||
|
|
@ -253,16 +253,16 @@ static bool image_viewer_msg_proc (JWidget widget, JMessage msg)
|
|||
widget->rc->x2-1, widget->rc->y2-1,
|
||||
widget->rc->x1, widget->rc->y1,
|
||||
widget->rc->x1+bmp->w-1,
|
||||
widget->rc->y1+bmp->h-1, jwidget_get_bg_color (widget));
|
||||
widget->rc->y1+bmp->h-1, jwidget_get_bg_color(widget));
|
||||
|
||||
blit (bmp, ji_screen,
|
||||
0, 0, widget->rc->x1, widget->rc->y1, bmp->w, bmp->h);
|
||||
destroy_bitmap (bmp);
|
||||
blit(bmp, ji_screen,
|
||||
0, 0, widget->rc->x1, widget->rc->y1, bmp->w, bmp->h);
|
||||
destroy_bitmap(bmp);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case JM_BUTTONPRESSED: {
|
||||
JWidget view = jwidget_get_view (widget);
|
||||
JWidget view = jwidget_get_view(widget);
|
||||
if (view) {
|
||||
jwidget_hard_capture_mouse(widget);
|
||||
jmouse_set_cursor(JI_CURSOR_MOVE);
|
||||
|
|
@ -274,7 +274,7 @@ static bool image_viewer_msg_proc (JWidget widget, JMessage msg)
|
|||
case JM_MOTION: {
|
||||
JWidget view = jwidget_get_view(widget);
|
||||
if (view && jwidget_has_capture(widget)) {
|
||||
JRect vp = jview_get_viewport_position (view);
|
||||
JRect vp = jview_get_viewport_position(view);
|
||||
int scroll_x, scroll_y;
|
||||
|
||||
jview_get_scroll(view, &scroll_x, &scroll_y);
|
||||
|
|
@ -289,9 +289,9 @@ static bool image_viewer_msg_proc (JWidget widget, JMessage msg)
|
|||
}
|
||||
|
||||
case JM_BUTTONRELEASED: {
|
||||
JWidget view = jwidget_get_view (widget);
|
||||
if (view && jwidget_has_capture (widget)) {
|
||||
jwidget_release_mouse (widget);
|
||||
JWidget view = jwidget_get_view(widget);
|
||||
if (view && jwidget_has_capture(widget)) {
|
||||
jwidget_release_mouse(widget);
|
||||
jmouse_set_cursor(JI_CURSOR_NORMAL);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -49,19 +49,19 @@ static JWidget color_viewer;
|
|||
static JWidget palette_editor;
|
||||
static JWidget slider_frame;
|
||||
|
||||
static void select_all_command (JWidget widget);
|
||||
static void load_command (JWidget widget);
|
||||
static void save_command (JWidget widget);
|
||||
static void ramp_command (JWidget widget);
|
||||
static void quantize_command (JWidget widget);
|
||||
static void select_all_command(JWidget widget);
|
||||
static void load_command(JWidget widget);
|
||||
static void save_command(JWidget widget);
|
||||
static void ramp_command(JWidget widget);
|
||||
static void quantize_command(JWidget widget);
|
||||
|
||||
static int sliderRGB_change_signal (JWidget widget, int user_data);
|
||||
static int sliderHSV_change_signal (JWidget widget, int user_data);
|
||||
static int slider_columns_change_signal (JWidget widget, int user_data);
|
||||
static int slider_frame_change_signal (JWidget widget, int user_data);
|
||||
static int palette_editor_change_signal (JWidget widget, int user_data);
|
||||
static int sliderRGB_change_signal(JWidget widget, int user_data);
|
||||
static int sliderHSV_change_signal(JWidget widget, int user_data);
|
||||
static int slider_columns_change_signal(JWidget widget, int user_data);
|
||||
static int slider_frame_change_signal(JWidget widget, int user_data);
|
||||
static int palette_editor_change_signal(JWidget widget, int user_data);
|
||||
|
||||
static void set_new_palette (RGB *palette);
|
||||
static void set_new_palette(RGB *palette);
|
||||
|
||||
void dialogs_palette_editor(void)
|
||||
{
|
||||
|
|
@ -77,12 +77,12 @@ void dialogs_palette_editor(void)
|
|||
int frame_bak = current_sprite ? current_sprite->frame : 0;
|
||||
|
||||
if (imgtype == IMAGE_GRAYSCALE) {
|
||||
jalert (_("Error<<You can't edit grayscale palette||&OK"));
|
||||
jalert(_("Error<<You can't edit grayscale palette||&OK"));
|
||||
return;
|
||||
}
|
||||
|
||||
/* load widgets */
|
||||
window = load_widget ("paledit.jid", "palette_editor");
|
||||
window = load_widget("paledit.jid", "palette_editor");
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
|
|
@ -105,15 +105,15 @@ void dialogs_palette_editor(void)
|
|||
"button_ok", &button_ok,
|
||||
"color_viewer", &color_viewer_box,
|
||||
"palette_editor", &palette_editor_view, NULL)) {
|
||||
jwidget_free (window);
|
||||
jwidget_free(window);
|
||||
return;
|
||||
}
|
||||
|
||||
/* create current_sprite->frames palettes */
|
||||
if (current_sprite) {
|
||||
palettes = jmalloc (sizeof(PALETTE) * current_sprite->frames);
|
||||
palettes = jmalloc(sizeof(PALETTE) * current_sprite->frames);
|
||||
if (!palettes) {
|
||||
jalert (_("Error<<Not enough memory||&OK"));
|
||||
jalert(_("Error<<Not enough memory||&OK"));
|
||||
return;
|
||||
}
|
||||
for (frame=0; frame<current_sprite->frames; frame++)
|
||||
|
|
@ -124,28 +124,28 @@ void dialogs_palette_editor(void)
|
|||
palettes = NULL;
|
||||
|
||||
/* get current palette */
|
||||
palette_copy (palette, current_palette);
|
||||
palette_copy(palette, current_palette);
|
||||
|
||||
/* get configuration */
|
||||
columns = get_config_int ("PaletteEditor", "Columns", 16);
|
||||
columns = MID (1, columns, 256);
|
||||
columns = get_config_int("PaletteEditor", "Columns", 16);
|
||||
columns = MID(1, columns, 256);
|
||||
|
||||
/* custom widgets */
|
||||
color_viewer = color_viewer_new ("index{0}", IMAGE_INDEXED);
|
||||
palette_editor = palette_editor_new (palette, TRUE, 6);
|
||||
color_viewer = color_viewer_new("index{0}", IMAGE_INDEXED);
|
||||
palette_editor = palette_editor_new(palette, TRUE, 6);
|
||||
|
||||
jwidget_expansive (color_viewer, TRUE);
|
||||
jwidget_add_child (color_viewer_box, color_viewer);
|
||||
jwidget_expansive(color_viewer, TRUE);
|
||||
jwidget_add_child(color_viewer_box, color_viewer);
|
||||
|
||||
jwidget_disable (button_undo);
|
||||
jwidget_disable (button_redo);
|
||||
jwidget_disable(button_undo);
|
||||
jwidget_disable(button_redo);
|
||||
|
||||
jview_attach (palette_editor_view, palette_editor);
|
||||
jview_maxsize (palette_editor_view);
|
||||
jview_attach(palette_editor_view, palette_editor);
|
||||
jview_maxsize(palette_editor_view);
|
||||
|
||||
/* set columns */
|
||||
jslider_set_value (slider_columns, columns);
|
||||
palette_editor_set_columns (palette_editor, columns);
|
||||
jslider_set_value(slider_columns, columns);
|
||||
palette_editor_set_columns(palette_editor, columns);
|
||||
|
||||
/* frame */
|
||||
if (current_sprite) {
|
||||
|
|
@ -173,22 +173,22 @@ void dialogs_palette_editor(void)
|
|||
jbutton_add_command(button_quantize, quantize_command);
|
||||
|
||||
/* default position */
|
||||
jwindow_remap (window);
|
||||
jwindow_center (window);
|
||||
jwindow_remap(window);
|
||||
jwindow_center(window);
|
||||
|
||||
/* load window configuration */
|
||||
load_window_pos (window, "PaletteEditor");
|
||||
load_window_pos(window, "PaletteEditor");
|
||||
|
||||
/* open and run the window */
|
||||
jwindow_open_fg (window);
|
||||
jwindow_open_fg(window);
|
||||
|
||||
/* check the killer widget */
|
||||
if (jwindow_get_killer (window) == button_ok) {
|
||||
if (current_sprite) {
|
||||
palette_copy (palettes[jslider_get_value(slider_frame)],
|
||||
current_palette);
|
||||
palette_copy(palettes[jslider_get_value(slider_frame)],
|
||||
current_palette);
|
||||
|
||||
sprite_reset_palettes (current_sprite);
|
||||
sprite_reset_palettes(current_sprite);
|
||||
for (frame=0; frame<current_sprite->frames; frame++) {
|
||||
if (frame == 0 ||
|
||||
palette_diff(palettes[frame], palettes[frame-1], NULL, NULL))
|
||||
|
|
@ -218,7 +218,7 @@ void dialogs_palette_editor(void)
|
|||
|
||||
/* save columns configuration */
|
||||
columns = jslider_get_value(slider_columns);
|
||||
set_config_int("PaletteEditors", "Columns", MID (1, columns, 256));
|
||||
set_config_int("PaletteEditors", "Columns", MID(1, columns, 256));
|
||||
|
||||
/* save window configuration */
|
||||
save_window_pos(window, "PaletteEditor");
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -93,10 +93,10 @@ void dialogs_draw_text(void)
|
|||
jwidget_add_child(color_box, color_but);
|
||||
|
||||
/* entries */
|
||||
usprintf(buf, "%d", get_config_int ("DrawText", "Size", 8));
|
||||
usprintf(buf, "%d", get_config_int("DrawText", "Size", 8));
|
||||
jwidget_set_text(entry_size, buf);
|
||||
jwidget_set_text(entry_text,
|
||||
get_config_string ("DrawText", "Text", "ABCabc"));
|
||||
get_config_string("DrawText", "Text", "ABCabc"));
|
||||
|
||||
/* window */
|
||||
jwindow_remap(window);
|
||||
|
|
@ -152,28 +152,28 @@ void dialogs_draw_text(void)
|
|||
}
|
||||
}
|
||||
|
||||
jwidget_free (window);
|
||||
jwidget_free(window);
|
||||
}
|
||||
|
||||
Image *RenderText (const char *fontname, int size, int color, const char *text)
|
||||
Image *RenderText(const char *fontname, int size, int color, const char *text)
|
||||
{
|
||||
Image *render;
|
||||
FONT *f;
|
||||
|
||||
f = my_load_font (fontname);
|
||||
f = my_load_font(fontname);
|
||||
if (!f)
|
||||
return NULL;
|
||||
|
||||
ji_font_set_size (f, size);
|
||||
ji_font_set_size(f, size);
|
||||
|
||||
render = render_text (f, text, color);
|
||||
render = render_text(f, text, color);
|
||||
|
||||
destroy_font (f);
|
||||
destroy_font(f);
|
||||
|
||||
return render;
|
||||
}
|
||||
|
||||
static Image *render_text (FONT *f, const char *text, int color)
|
||||
static Image *render_text(FONT *f, const char *text, int color)
|
||||
{
|
||||
#define DO(type, colfunc) \
|
||||
{ \
|
||||
|
|
@ -241,7 +241,7 @@ static Image *render_text (FONT *f, const char *text, int color)
|
|||
return image;
|
||||
}
|
||||
|
||||
static FONT *my_load_font (const char *filename)
|
||||
static FONT *my_load_font(const char *filename)
|
||||
{
|
||||
DIRS *dirs, *dir;
|
||||
FONT *f = NULL;
|
||||
|
|
@ -255,7 +255,7 @@ static FONT *my_load_font (const char *filename)
|
|||
usprintf(buf, "fonts/%s", filename);
|
||||
dirs_cat_dirs(dirs, filename_in_datadir(buf));
|
||||
|
||||
usprintf(buf, "fonts/%s", get_filename (filename));
|
||||
usprintf(buf, "fonts/%s", get_filename(filename));
|
||||
dirs_cat_dirs(dirs, filename_in_datadir(buf));
|
||||
|
||||
/* search the font */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -214,8 +214,8 @@ static void add_bookmark_command(JWidget widget, void *data)
|
|||
char buf[64], path[1024];
|
||||
int count;
|
||||
|
||||
count = get_config_int ("Bookmarks", "Count", 0);
|
||||
count = MID (0, count, 256);
|
||||
count = get_config_int("Bookmarks", "Count", 0);
|
||||
count = MID(0, count, 256);
|
||||
|
||||
if (count < 256) {
|
||||
replace_filename(path, ji_file_select_get_current_path(), "", 1024);
|
||||
|
|
@ -307,8 +307,8 @@ static void home_command(JWidget widget)
|
|||
else {
|
||||
char path[1024];
|
||||
|
||||
get_executable_name (path, sizeof (path));
|
||||
*get_filename (path) = 0;
|
||||
get_executable_name(path, sizeof(path));
|
||||
*get_filename(path) = 0;
|
||||
|
||||
ji_file_select_enter_to_path(path);
|
||||
}
|
||||
|
|
@ -319,16 +319,16 @@ static void home_command(JWidget widget)
|
|||
*/
|
||||
static void fonts_command(JWidget widget)
|
||||
{
|
||||
DIRS *dir, *dirs = filename_in_datadir ("fonts/");
|
||||
DIRS *dir, *dirs = filename_in_datadir("fonts/");
|
||||
|
||||
for (dir=dirs; dir; dir=dir->next) {
|
||||
if (ji_dir_exists (dir->path)) {
|
||||
ji_file_select_enter_to_path (dir->path);
|
||||
ji_file_select_enter_to_path(dir->path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
dirs_free (dirs);
|
||||
dirs_free(dirs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -336,16 +336,16 @@ static void fonts_command(JWidget widget)
|
|||
*/
|
||||
static void palettes_command(JWidget widget)
|
||||
{
|
||||
DIRS *dir, *dirs = filename_in_datadir ("palettes/");
|
||||
DIRS *dir, *dirs = filename_in_datadir("palettes/");
|
||||
|
||||
for (dir=dirs; dir; dir=dir->next) {
|
||||
if (ji_dir_exists (dir->path)) {
|
||||
ji_file_select_enter_to_path (dir->path);
|
||||
ji_file_select_enter_to_path(dir->path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
dirs_free (dirs);
|
||||
dirs_free(dirs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -45,9 +45,9 @@
|
|||
|
||||
#endif
|
||||
|
||||
#define THUMBSIZE (32)
|
||||
#define FRMSIZE (3 + THUMBSIZE + 2)
|
||||
#define LAYSIZE (3 + MAX (text_height (widget->text_font), THUMBSIZE) + 2)
|
||||
#define THUMBSIZE (32)
|
||||
#define FRMSIZE (3 + THUMBSIZE + 2)
|
||||
#define LAYSIZE (3 + MAX(text_height(widget->text_font), THUMBSIZE) + 2)
|
||||
|
||||
enum {
|
||||
STATE_NONE,
|
||||
|
|
@ -142,7 +142,7 @@ void switch_between_film_and_sprite_editor(void)
|
|||
jwidget_add_child(window, box1);
|
||||
|
||||
/* load window configuration */
|
||||
jpanel_set_pos(panel1, get_config_float ("LayerWindow", "PanelPos", 50));
|
||||
jpanel_set_pos(panel1, get_config_float("LayerWindow", "PanelPos", 50));
|
||||
jwindow_remap(window);
|
||||
|
||||
/* center scrolls in selected layer/frpos */
|
||||
|
|
@ -182,31 +182,31 @@ void switch_between_film_and_sprite_editor(void)
|
|||
LayerBox
|
||||
***********************************************************************/
|
||||
|
||||
static JWidget layer_box_new (void)
|
||||
static JWidget layer_box_new(void)
|
||||
{
|
||||
JWidget widget = jwidget_new (layer_box_type ());
|
||||
LayerBox *layer_box = jnew (LayerBox, 1);
|
||||
JWidget widget = jwidget_new(layer_box_type());
|
||||
LayerBox *layer_box = jnew(LayerBox, 1);
|
||||
|
||||
layer_box->widget = widget;
|
||||
|
||||
jwidget_add_hook (widget, layer_box_type (),
|
||||
layer_box_msg_proc, layer_box);
|
||||
jwidget_focusrest (widget, TRUE);
|
||||
jwidget_add_hook(widget, layer_box_type(),
|
||||
layer_box_msg_proc, layer_box);
|
||||
jwidget_focusrest(widget, TRUE);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
static int layer_box_type (void)
|
||||
static int layer_box_type(void)
|
||||
{
|
||||
static int type = 0;
|
||||
if (!type)
|
||||
type = ji_register_widget_type ();
|
||||
type = ji_register_widget_type();
|
||||
return type;
|
||||
}
|
||||
|
||||
static LayerBox *layer_box_data (JWidget widget)
|
||||
static LayerBox *layer_box_data(JWidget widget)
|
||||
{
|
||||
return jwidget_get_data (widget, layer_box_type ());
|
||||
return jwidget_get_data(widget, layer_box_type());
|
||||
}
|
||||
|
||||
static void layer_box_request_size(JWidget widget, int *w, int *h)
|
||||
|
|
@ -228,7 +228,7 @@ static bool layer_box_msg_proc(JWidget widget, JMessage msg)
|
|||
switch (msg->type) {
|
||||
|
||||
case JM_DESTROY:
|
||||
jfree (layer_box);
|
||||
jfree(layer_box);
|
||||
break;
|
||||
|
||||
case JM_REQSIZE:
|
||||
|
|
@ -250,9 +250,9 @@ static bool layer_box_msg_proc(JWidget widget, JMessage msg)
|
|||
}
|
||||
|
||||
case JM_DRAW: {
|
||||
JWidget view = jwidget_get_view (widget);
|
||||
JRect vp = jview_get_viewport_position (view);
|
||||
BITMAP *bmp = create_bitmap (jrect_w(vp), jrect_h(vp));
|
||||
JWidget view = jwidget_get_view(widget);
|
||||
JRect vp = jview_get_viewport_position(view);
|
||||
BITMAP *bmp = create_bitmap(jrect_w(vp), jrect_h(vp));
|
||||
int scroll_x, scroll_y;
|
||||
bool selected_layer;
|
||||
int pos, layers;
|
||||
|
|
@ -261,50 +261,50 @@ static bool layer_box_msg_proc(JWidget widget, JMessage msg)
|
|||
|
||||
jview_get_scroll(view, &scroll_x, &scroll_y);
|
||||
|
||||
text_mode (-1);
|
||||
clear_to_color (bmp, makecol (255, 255, 255));
|
||||
text_mode(-1);
|
||||
clear_to_color(bmp, makecol(255, 255, 255));
|
||||
|
||||
h = LAYSIZE;
|
||||
y = h-scroll_y;
|
||||
|
||||
hline (bmp, 0, h, bmp->w-1, makecol (0, 0, 0));
|
||||
set_clip (bmp, 0, h+1, bmp->w-1, bmp->h-1);
|
||||
hline(bmp, 0, h, bmp->w-1, makecol(0, 0, 0));
|
||||
set_clip(bmp, 0, h+1, bmp->w-1, bmp->h-1);
|
||||
|
||||
layers = count_layers (sprite->set);
|
||||
layers = count_layers(sprite->set);
|
||||
for (pos=0; pos<layers; pos++) {
|
||||
layer = get_layer_in_pos (sprite->set, pos);
|
||||
layer = get_layer_in_pos(sprite->set, pos);
|
||||
|
||||
selected_layer =
|
||||
(state != STATE_MOVING) ? (sprite->layer == layer):
|
||||
(layer == layer_box->layer);
|
||||
|
||||
if (selected_layer)
|
||||
rectfill (bmp, 0, y, bmp->w-1, y+h-1, makecol (44, 76, 145));
|
||||
rectfill(bmp, 0, y, bmp->w-1, y+h-1, makecol(44, 76, 145));
|
||||
|
||||
if (state == STATE_MOVING && sprite->layer == layer) {
|
||||
rectdotted (bmp, 0, y+1, bmp->w-1, y+2,
|
||||
makecol (0, 0, 0), makecol (255, 255, 255));
|
||||
rectdotted(bmp, 0, y+1, bmp->w-1, y+2,
|
||||
makecol(0, 0, 0), makecol(255, 255, 255));
|
||||
}
|
||||
|
||||
hline (bmp, 0, y, bmp->w-1, makecol (0, 0, 0));
|
||||
hline (bmp, 0, y+h, bmp->w-1, makecol (0, 0, 0));
|
||||
hline(bmp, 0, y, bmp->w-1, makecol(0, 0, 0));
|
||||
hline(bmp, 0, y+h, bmp->w-1, makecol(0, 0, 0));
|
||||
|
||||
#if 0
|
||||
{
|
||||
int count, pos;
|
||||
count = count_layers (sprite->set);
|
||||
get_layer_pos (sprite->set, layer, &pos);
|
||||
textprintf (bmp, widget->text_font,
|
||||
2, y+h/2-text_height (widget->text_font)/2,
|
||||
selected_layer ?
|
||||
makecol (255, 255, 255): makecol (0, 0, 0),
|
||||
"%d/%d", pos, count);
|
||||
count = count_layers(sprite->set);
|
||||
get_layer_pos(sprite->set, layer, &pos);
|
||||
textprintf(bmp, widget->text_font,
|
||||
2, y+h/2-text_height(widget->text_font)/2,
|
||||
selected_layer ?
|
||||
makecol(255, 255, 255): makecol(0, 0, 0),
|
||||
"%d/%d", pos, count);
|
||||
}
|
||||
#elif 0
|
||||
textout (bmp, widget->text_font, layer->name,
|
||||
2, y+h/2-text_height (widget->text_font)/2,
|
||||
selected_layer ?
|
||||
makecol (255, 255, 255): makecol (0, 0, 0));
|
||||
textout(bmp, widget->text_font, layer->name,
|
||||
2, y+h/2-text_height(widget->text_font)/2,
|
||||
selected_layer ?
|
||||
makecol(255, 255, 255): makecol(0, 0, 0));
|
||||
#else
|
||||
{
|
||||
int tabs = -2;
|
||||
|
|
@ -312,18 +312,18 @@ static bool layer_box_msg_proc(JWidget widget, JMessage msg)
|
|||
Layer *l = layer;
|
||||
while (l->gfxobj.type != GFXOBJ_SPRITE) {
|
||||
if (++tabs > 0) {
|
||||
/* JList item = jlist_find (((Layer *)l->parent)->layers, l); */
|
||||
/* JList item = jlist_find(((Layer *)l->parent)->layers, l); */
|
||||
int y1 = final_y-LAYSIZE/2;
|
||||
int y2 = final_y+LAYSIZE/2;
|
||||
/* int y2 = item->prev ? final_y+LAYSIZE/2 : final_y; */
|
||||
vline (bmp, tabs*16-1, y1, y2, makecol (0, 0, 0));
|
||||
vline(bmp, tabs*16-1, y1, y2, makecol(0, 0, 0));
|
||||
}
|
||||
l = (Layer *)l->parent;
|
||||
}
|
||||
textout(bmp, widget->text_font, layer->name,
|
||||
2+tabs*16, final_y-text_height (widget->text_font)/2,
|
||||
2+tabs*16, final_y-text_height(widget->text_font)/2,
|
||||
selected_layer ?
|
||||
makecol(255, 255, 255): makecol (0, 0, 0));
|
||||
makecol(255, 255, 255): makecol(0, 0, 0));
|
||||
}
|
||||
#endif
|
||||
y += h;
|
||||
|
|
@ -388,7 +388,7 @@ static bool layer_box_msg_proc(JWidget widget, JMessage msg)
|
|||
}
|
||||
|
||||
case JM_BUTTONPRESSED:
|
||||
jwidget_hard_capture_mouse (widget);
|
||||
jwidget_hard_capture_mouse(widget);
|
||||
|
||||
if (msg->any.shifts & KB_SHIFT_FLAG) {
|
||||
state = STATE_SCROLLING;
|
||||
|
|
@ -418,8 +418,8 @@ static bool layer_box_msg_proc(JWidget widget, JMessage msg)
|
|||
break;
|
||||
|
||||
case JM_BUTTONRELEASED:
|
||||
if (jwidget_has_capture (widget)) {
|
||||
jwidget_release_mouse (widget);
|
||||
if (jwidget_has_capture(widget)) {
|
||||
jwidget_release_mouse(widget);
|
||||
|
||||
if ((state == STATE_SCROLLING) || (state == STATE_MOVING))
|
||||
jmouse_set_cursor(JI_CURSOR_NORMAL);
|
||||
|
|
@ -447,7 +447,7 @@ static bool layer_box_msg_proc(JWidget widget, JMessage msg)
|
|||
jview_update(jwidget_get_view(layer_box->cel_box->widget));
|
||||
}
|
||||
else
|
||||
jwidget_dirty (widget);
|
||||
jwidget_dirty(widget);
|
||||
}
|
||||
|
||||
state = STATE_NONE;
|
||||
|
|
@ -501,17 +501,17 @@ static void cel_box_request_size(JWidget widget, int *w, int *h)
|
|||
|
||||
static bool cel_box_msg_proc(JWidget widget, JMessage msg)
|
||||
{
|
||||
CelBox *cel_box = cel_box_data (widget);
|
||||
CelBox *cel_box = cel_box_data(widget);
|
||||
Sprite *sprite = current_sprite;
|
||||
|
||||
switch (msg->type) {
|
||||
|
||||
case JM_DESTROY:
|
||||
jfree (cel_box);
|
||||
jfree(cel_box);
|
||||
break;
|
||||
|
||||
case JM_REQSIZE:
|
||||
cel_box_request_size (widget, &msg->reqsize.w, &msg->reqsize.h);
|
||||
cel_box_request_size(widget, &msg->reqsize.w, &msg->reqsize.h);
|
||||
return TRUE;
|
||||
|
||||
case JM_SETPOS: {
|
||||
|
|
@ -561,7 +561,7 @@ static bool cel_box_msg_proc(JWidget widget, JMessage msg)
|
|||
offset_x = scroll_x % FRMSIZE;
|
||||
|
||||
for (x=0; x<bmp->w+FRMSIZE; x += FRMSIZE) {
|
||||
vline(bmp, x-offset_x-1, 0, bmp->h, makecol (0, 0, 0));
|
||||
vline(bmp, x-offset_x-1, 0, bmp->h, makecol(0, 0, 0));
|
||||
|
||||
c = (x+scroll_x)/FRMSIZE;
|
||||
|
||||
|
|
@ -573,7 +573,7 @@ static bool cel_box_msg_proc(JWidget widget, JMessage msg)
|
|||
/* frame */
|
||||
textprintf_centre
|
||||
(bmp, widget->text_font,
|
||||
x-offset_x+FRMSIZE/2, y+h/2-text_height (widget->text_font)/2,
|
||||
x-offset_x+FRMSIZE/2, y+h/2-text_height(widget->text_font)/2,
|
||||
c == sprite->frame ? makecol(255, 255, 255): makecol(0, 0, 0),
|
||||
"%d", c+1);
|
||||
|
||||
|
|
@ -603,8 +603,8 @@ static bool cel_box_msg_proc(JWidget widget, JMessage msg)
|
|||
else if (layer->gfxobj.type == GFXOBJ_LAYER_SET)
|
||||
rectfill(bmp, 0, y, bmp->w-1, y+h-1, makecol(128, 128, 128));
|
||||
|
||||
hline(bmp, 0, y, bmp->w-1, makecol (0, 0, 0));
|
||||
hline(bmp, 0, y+h, bmp->w-1, makecol (0, 0, 0));
|
||||
hline(bmp, 0, y, bmp->w-1, makecol(0, 0, 0));
|
||||
hline(bmp, 0, y+h, bmp->w-1, makecol(0, 0, 0));
|
||||
|
||||
/* draw thumbnail of cels */
|
||||
|
||||
|
|
@ -696,7 +696,7 @@ static bool cel_box_msg_proc(JWidget widget, JMessage msg)
|
|||
rectdotted(ji_screen,
|
||||
cel_box->rect.x1, cel_box->rect.y1,
|
||||
cel_box->rect.x2-1, cel_box->rect.y2-1,
|
||||
makecol (0, 0, 0), makecol (255, 255, 255));
|
||||
makecol(0, 0, 0), makecol(255, 255, 255));
|
||||
jmouse_show();
|
||||
}
|
||||
}
|
||||
|
|
@ -1054,5 +1054,5 @@ static void get_cel_rect(JWidget widget, JRect rect)
|
|||
rect->x2 = rect->x1 + THUMBSIZE + 2;
|
||||
rect->y2 = rect->y1 + THUMBSIZE + 2;
|
||||
|
||||
jrect_free (vp);
|
||||
jrect_free(vp);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -47,14 +47,14 @@
|
|||
|
||||
static JWidget button_color, slider_fuzziness, check_preview;
|
||||
|
||||
static void button_1_command (JWidget widget);
|
||||
static void button_2_command (JWidget widget);
|
||||
static int color_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 button_1_command(JWidget widget);
|
||||
static void button_2_command(JWidget widget);
|
||||
static int color_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 Mask *gen_mask (void);
|
||||
static void mask_preview (void);
|
||||
static Mask *gen_mask(void);
|
||||
static void mask_preview(void);
|
||||
|
||||
void dialogs_mask_color(void)
|
||||
{
|
||||
|
|
@ -68,83 +68,83 @@ void dialogs_mask_color(void)
|
|||
if (!is_interactive () || !sprite)
|
||||
return;
|
||||
|
||||
image = GetImage ();
|
||||
image = GetImage();
|
||||
if (!image)
|
||||
return;
|
||||
|
||||
window = jwindow_new (_("Mask by Color"));
|
||||
box1 = jbox_new (JI_VERTICAL);
|
||||
box2 = jbox_new (JI_HORIZONTAL);
|
||||
box3 = jbox_new (JI_HORIZONTAL);
|
||||
box4 = jbox_new (JI_HORIZONTAL | JI_HOMOGENEOUS);
|
||||
label_color = jlabel_new (_("Color:"));
|
||||
window = jwindow_new(_("Mask by Color"));
|
||||
box1 = jbox_new(JI_VERTICAL);
|
||||
box2 = jbox_new(JI_HORIZONTAL);
|
||||
box3 = jbox_new(JI_HORIZONTAL);
|
||||
box4 = jbox_new(JI_HORIZONTAL | JI_HOMOGENEOUS);
|
||||
label_color = jlabel_new(_("Color:"));
|
||||
button_color = color_button_new
|
||||
(get_config_string ("MaskColor", "Color",
|
||||
color_bar_get_color (app_get_color_bar (), 0)),
|
||||
sprite->imgtype);
|
||||
button_1 = jbutton_new ("1");
|
||||
button_2 = jbutton_new ("2");
|
||||
label_fuzziness = jlabel_new (_("Fuzziness:"));
|
||||
(get_config_string("MaskColor", "Color",
|
||||
color_bar_get_color(app_get_color_bar(), 0)),
|
||||
sprite->imgtype);
|
||||
button_1 = jbutton_new("1");
|
||||
button_2 = jbutton_new("2");
|
||||
label_fuzziness = jlabel_new(_("Fuzziness:"));
|
||||
slider_fuzziness =
|
||||
jslider_new (0, 255, get_config_int ("MaskColor", "Fuzziness", 0));
|
||||
check_preview = jcheck_new (_("&Preview"));
|
||||
button_ok = jbutton_new (_("&OK"));
|
||||
button_cancel = jbutton_new (_("&Cancel"));
|
||||
jslider_new(0, 255, get_config_int("MaskColor", "Fuzziness", 0));
|
||||
check_preview = jcheck_new(_("&Preview"));
|
||||
button_ok = jbutton_new(_("&OK"));
|
||||
button_cancel = jbutton_new(_("&Cancel"));
|
||||
|
||||
if (get_config_bool ("MaskColor", "Preview", TRUE))
|
||||
jwidget_select (check_preview);
|
||||
if (get_config_bool("MaskColor", "Preview", TRUE))
|
||||
jwidget_select(check_preview);
|
||||
|
||||
jbutton_add_command (button_1, button_1_command);
|
||||
jbutton_add_command (button_2, button_2_command);
|
||||
jbutton_add_command(button_1, button_1_command);
|
||||
jbutton_add_command(button_2, button_2_command);
|
||||
|
||||
HOOK (button_color, SIGNAL_COLOR_BUTTON_CHANGE, color_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);
|
||||
HOOK(button_color, SIGNAL_COLOR_BUTTON_CHANGE, color_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);
|
||||
|
||||
jwidget_magnetic (button_ok, TRUE);
|
||||
jwidget_expansive (button_color, TRUE);
|
||||
jwidget_expansive (slider_fuzziness, TRUE);
|
||||
jwidget_expansive (box2, TRUE);
|
||||
jwidget_magnetic(button_ok, TRUE);
|
||||
jwidget_expansive(button_color, TRUE);
|
||||
jwidget_expansive(slider_fuzziness, TRUE);
|
||||
jwidget_expansive(box2, TRUE);
|
||||
|
||||
jwidget_add_child (window, box1);
|
||||
jwidget_add_childs (box1, box2, box3, check_preview, box4, NULL);
|
||||
jwidget_add_childs (box2, label_color, button_color, button_1, button_2, NULL);
|
||||
jwidget_add_childs (box3, label_fuzziness, slider_fuzziness, NULL);
|
||||
jwidget_add_childs (box4, button_ok, button_cancel, NULL);
|
||||
jwidget_add_child(window, box1);
|
||||
jwidget_add_childs(box1, box2, box3, check_preview, box4, NULL);
|
||||
jwidget_add_childs(box2, label_color, button_color, button_1, button_2, NULL);
|
||||
jwidget_add_childs(box3, label_fuzziness, slider_fuzziness, NULL);
|
||||
jwidget_add_childs(box4, button_ok, button_cancel, NULL);
|
||||
|
||||
/* default position */
|
||||
jwindow_remap (window);
|
||||
jwindow_center (window);
|
||||
jwindow_remap(window);
|
||||
jwindow_center(window);
|
||||
|
||||
/* mask first preview */
|
||||
mask_preview ();
|
||||
mask_preview();
|
||||
|
||||
/* load window configuration */
|
||||
load_window_pos (window, "MaskColor");
|
||||
load_window_pos(window, "MaskColor");
|
||||
|
||||
/* open the window */
|
||||
jwindow_open_fg (window);
|
||||
jwindow_open_fg(window);
|
||||
|
||||
if (jwindow_get_killer (window) == button_ok) {
|
||||
Mask *mask;
|
||||
|
||||
/* undo */
|
||||
if (undo_is_enabled (sprite->undo))
|
||||
undo_set_mask (sprite->undo, sprite);
|
||||
undo_set_mask(sprite->undo, sprite);
|
||||
|
||||
/* change the mask */
|
||||
mask = gen_mask ();
|
||||
sprite_set_mask (sprite, mask);
|
||||
mask_free (mask);
|
||||
mask = gen_mask();
|
||||
sprite_set_mask(sprite, mask);
|
||||
mask_free(mask);
|
||||
|
||||
set_config_string ("MaskColor", "Color",
|
||||
color_button_get_color (button_color));
|
||||
set_config_string("MaskColor", "Color",
|
||||
color_button_get_color(button_color));
|
||||
|
||||
set_config_int ("MaskColor", "Fuzziness",
|
||||
jslider_get_value (slider_fuzziness));
|
||||
set_config_int("MaskColor", "Fuzziness",
|
||||
jslider_get_value(slider_fuzziness));
|
||||
|
||||
set_config_bool ("MaskColor", "Preview",
|
||||
jwidget_is_selected (check_preview));
|
||||
set_config_bool("MaskColor", "Preview",
|
||||
jwidget_is_selected(check_preview));
|
||||
}
|
||||
|
||||
/* update boundaries and editors */
|
||||
|
|
@ -157,39 +157,39 @@ void dialogs_mask_color(void)
|
|||
jwidget_free(window);
|
||||
}
|
||||
|
||||
static void button_1_command (JWidget widget)
|
||||
static void button_1_command(JWidget widget)
|
||||
{
|
||||
color_button_set_color (button_color,
|
||||
color_bar_get_color (app_get_color_bar (), 0));
|
||||
mask_preview ();
|
||||
color_button_set_color(button_color,
|
||||
color_bar_get_color(app_get_color_bar(), 0));
|
||||
mask_preview();
|
||||
}
|
||||
|
||||
static void button_2_command (JWidget widget)
|
||||
static void button_2_command(JWidget widget)
|
||||
{
|
||||
color_button_set_color (button_color,
|
||||
color_bar_get_color (app_get_color_bar (), 1));
|
||||
mask_preview ();
|
||||
color_button_set_color(button_color,
|
||||
color_bar_get_color(app_get_color_bar(), 1));
|
||||
mask_preview();
|
||||
}
|
||||
|
||||
static int color_change_hook (JWidget widget, int user_data)
|
||||
static int color_change_hook(JWidget widget, int user_data)
|
||||
{
|
||||
mask_preview ();
|
||||
mask_preview();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int slider_change_hook (JWidget widget, int user_data)
|
||||
static int slider_change_hook(JWidget widget, int user_data)
|
||||
{
|
||||
mask_preview ();
|
||||
mask_preview();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int preview_change_hook (JWidget widget, int user_data)
|
||||
static int preview_change_hook(JWidget widget, int user_data)
|
||||
{
|
||||
mask_preview ();
|
||||
mask_preview();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static Mask *gen_mask (void)
|
||||
static Mask *gen_mask(void)
|
||||
{
|
||||
int xpos, ypos, color, fuzziness;
|
||||
const char *color_text;
|
||||
|
|
@ -200,18 +200,18 @@ static Mask *gen_mask (void)
|
|||
sprite = current_sprite;
|
||||
image = GetImage2 (sprite, &xpos, &ypos, NULL);
|
||||
|
||||
color_text = color_button_get_color (button_color);
|
||||
color = get_color_for_image (sprite->imgtype, color_text);
|
||||
fuzziness = jslider_get_value (slider_fuzziness);
|
||||
color_text = color_button_get_color(button_color);
|
||||
color = get_color_for_image(sprite->imgtype, color_text);
|
||||
fuzziness = jslider_get_value(slider_fuzziness);
|
||||
|
||||
mask = mask_new ();
|
||||
mask_by_color (mask, image, color, fuzziness);
|
||||
mask_move (mask, xpos, ypos);
|
||||
mask = mask_new();
|
||||
mask_by_color(mask, image, color, fuzziness);
|
||||
mask_move(mask, xpos, ypos);
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
static void mask_preview (void)
|
||||
static void mask_preview(void)
|
||||
{
|
||||
if (jwidget_is_selected (check_preview)) {
|
||||
Sprite *sprite = current_sprite;
|
||||
|
|
|
|||
|
|
@ -57,11 +57,11 @@ void ji_minipal_new(JWidget color_bar, int x, int y)
|
|||
static int paledit_change_signal(JWidget widget, int user_data)
|
||||
{
|
||||
if (jmouse_b(0)) {
|
||||
PaletteEditor *paledit = palette_editor_data (widget);
|
||||
PaletteEditor *paledit = palette_editor_data(widget);
|
||||
JWidget color_bar = (JWidget)user_data;
|
||||
|
||||
if (paledit->color[0] == paledit->color[1]) {
|
||||
char *color = color_index (paledit->color[1]);
|
||||
char *color = color_index(paledit->color[1]);
|
||||
|
||||
color_bar_set_color(color_bar,
|
||||
jmouse_b(0) == 1 ? 0: 1,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include "jinete/jbase.h"
|
||||
|
||||
void ji_minipal_new (JWidget color_bar, int x, int y);
|
||||
void ji_minipal_new(JWidget color_bar, int x, int y);
|
||||
|
||||
#endif /* DIALOGS_MINIPAL_H */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -75,7 +75,7 @@ void dialogs_options(void)
|
|||
"move_click2", &move_click2,
|
||||
"draw_click2", &draw_click2,
|
||||
"button_ok", &button_ok, NULL)) {
|
||||
jwidget_free (window);
|
||||
jwidget_free(window);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -35,11 +35,11 @@
|
|||
|
||||
#endif
|
||||
|
||||
static bool my_callback (void);
|
||||
static void my_play_fli (const char *filename, bool loop, bool fullscreen,
|
||||
bool (*callback) ());
|
||||
static bool my_callback(void);
|
||||
static void my_play_fli(const char *filename, bool loop, bool fullscreen,
|
||||
bool (*callback)());
|
||||
|
||||
void play_fli_animation (const char *filename, bool loop, bool fullscreen)
|
||||
void play_fli_animation(const char *filename, bool loop, bool fullscreen)
|
||||
{
|
||||
if (is_interactive()) {
|
||||
PALETTE backup;
|
||||
|
|
@ -60,7 +60,7 @@ void play_fli_animation (const char *filename, bool loop, bool fullscreen)
|
|||
|
||||
/* play the fli */
|
||||
my_play_fli(filename, loop, fullscreen, my_callback);
|
||||
/* play_fli (filename, ji_screen, loop, my_callback); */
|
||||
/* play_fli(filename, ji_screen, loop, my_callback); */
|
||||
|
||||
/* clear the screen */
|
||||
clear(ji_screen);
|
||||
|
|
@ -83,11 +83,11 @@ void play_fli_animation (const char *filename, bool loop, bool fullscreen)
|
|||
}
|
||||
}
|
||||
|
||||
static bool my_callback (void)
|
||||
static bool my_callback(void)
|
||||
{
|
||||
jmouse_poll();
|
||||
|
||||
return (keypressed () || jmouse_b(0));
|
||||
return (keypressed() || jmouse_b(0));
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
|
|
@ -95,7 +95,7 @@ static bool my_callback (void)
|
|||
|
||||
static int speed_timer;
|
||||
|
||||
static void speed_timer_callback (void)
|
||||
static void speed_timer_callback(void)
|
||||
{
|
||||
speed_timer++;
|
||||
}
|
||||
|
|
@ -150,11 +150,11 @@ static void my_play_fli(const char *filename, bool loop, bool fullscreen,
|
|||
x = JI_SCREEN_W/2 - w/2;
|
||||
y = JI_SCREEN_H/2 - h/2;
|
||||
|
||||
LOCK_VARIABLE (speed_timer);
|
||||
LOCK_FUNCTION (speed_timer_callback);
|
||||
LOCK_VARIABLE(speed_timer);
|
||||
LOCK_FUNCTION(speed_timer_callback);
|
||||
|
||||
speed_timer = 0;
|
||||
install_int_ex (speed_timer_callback, MSEC_TO_TIMER (fli_header.speed));
|
||||
install_int_ex(speed_timer_callback, MSEC_TO_TIMER(fli_header.speed));
|
||||
|
||||
frpos = 0;
|
||||
done = FALSE;
|
||||
|
|
@ -171,8 +171,8 @@ static void my_play_fli(const char *filename, bool loop, bool fullscreen,
|
|||
pal[c].g = cmap[i++]>>2;
|
||||
pal[c].b = cmap[i++]>>2;
|
||||
}
|
||||
set_palette (pal);
|
||||
memcpy (omap, cmap, 768);
|
||||
set_palette(pal);
|
||||
memcpy(omap, cmap, 768);
|
||||
}
|
||||
|
||||
if (fullscreen)
|
||||
|
|
@ -195,18 +195,18 @@ static void my_play_fli(const char *filename, bool loop, bool fullscreen,
|
|||
if (!loop)
|
||||
break;
|
||||
else {
|
||||
fseek (f, 128, SEEK_SET);
|
||||
fseek(f, 128, SEEK_SET);
|
||||
frpos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
blit (bmp, old, 0, 0, 0, 0, fli_header.width, fli_header.height);
|
||||
blit(bmp, old, 0, 0, 0, 0, fli_header.width, fli_header.height);
|
||||
speed_timer--;
|
||||
}
|
||||
|
||||
destroy_bitmap (bmp);
|
||||
destroy_bitmap (old);
|
||||
destroy_bitmap(bmp);
|
||||
destroy_bitmap(old);
|
||||
|
||||
fclose (f);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include "jinete/jbase.h"
|
||||
|
||||
void play_fli_animation (const char *filename, bool loop, bool fullscreen);
|
||||
void play_fli_animation(const char *filename, bool loop, bool fullscreen);
|
||||
|
||||
#endif /* DIALOGS_PLAYFLI_H */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -43,14 +43,14 @@ enum { ACTION_MOVE, ACTION_COPY, ACTION_SWAP };
|
|||
|
||||
static Layer *handle_layer;
|
||||
|
||||
static void do_quick (int action);
|
||||
static int my_callback (void);
|
||||
static void do_quick(int action);
|
||||
static int my_callback(void);
|
||||
|
||||
void quick_move (void) { do_quick (ACTION_MOVE); }
|
||||
void quick_copy (void) { do_quick (ACTION_COPY); }
|
||||
void quick_swap (void) { do_quick (ACTION_SWAP); }
|
||||
void quick_move(void) { do_quick(ACTION_MOVE); }
|
||||
void quick_copy(void) { do_quick(ACTION_COPY); }
|
||||
void quick_swap(void) { do_quick(ACTION_SWAP); }
|
||||
|
||||
static void do_quick (int action)
|
||||
static void do_quick(int action)
|
||||
{
|
||||
Sprite *sprite = current_sprite;
|
||||
Layer *dst_layer;
|
||||
|
|
@ -75,12 +75,12 @@ static void do_quick (int action)
|
|||
return;
|
||||
|
||||
if (get_config_bool ("QuickMovement", "UseMask", TRUE))
|
||||
layer_set_blend_mode (handle_layer, BLEND_MODE_NORMAL);
|
||||
layer_set_blend_mode(handle_layer, BLEND_MODE_NORMAL);
|
||||
else
|
||||
layer_set_blend_mode (handle_layer, BLEND_MODE_COPY);
|
||||
layer_set_blend_mode(handle_layer, BLEND_MODE_COPY);
|
||||
|
||||
/* create a new dirty */
|
||||
dirty = dirty_new (dst, 0, 0, dst->w-1, dst->h-1, FALSE);
|
||||
dirty = dirty_new(dst, 0, 0, dst->w-1, dst->h-1, FALSE);
|
||||
|
||||
/* save the current mask region */
|
||||
if (action != ACTION_COPY) {
|
||||
|
|
@ -115,7 +115,7 @@ static void do_quick (int action)
|
|||
/* select the layer */
|
||||
sprite_set_layer(sprite, handle_layer);
|
||||
|
||||
/* regenerate the boundaries (the mask was deselected) and redraw
|
||||
/* regenerate the boundaries(the mask was deselected) and redraw
|
||||
the sprite */
|
||||
sprite_generate_mask_boundaries(sprite);
|
||||
update_screen_for_sprite(sprite);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -19,9 +19,9 @@
|
|||
#ifndef DIALOGS_QUICK_H
|
||||
#define DIALOGS_QUICK_H
|
||||
|
||||
void quick_move (void);
|
||||
void quick_copy (void);
|
||||
void quick_swap (void);
|
||||
void quick_move(void);
|
||||
void quick_copy(void);
|
||||
void quick_swap(void);
|
||||
|
||||
#endif /* DIALOGS_QUICK_H */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -31,36 +31,36 @@
|
|||
|
||||
#endif
|
||||
|
||||
static void fill_listbox (RepoDlg *repo_dlg);
|
||||
static void kill_listbox (RepoDlg *repo_dlg);
|
||||
static void fill_listbox(RepoDlg *repo_dlg);
|
||||
static void kill_listbox(RepoDlg *repo_dlg);
|
||||
|
||||
static int repo_listbox_type (void);
|
||||
static bool repo_listbox_msg_proc (JWidget widget, JMessage msg);
|
||||
static int repo_listbox_type(void);
|
||||
static bool repo_listbox_msg_proc(JWidget widget, JMessage msg);
|
||||
|
||||
static void use_command (JWidget widget, void *data);
|
||||
static void add_command (JWidget widget, void *data);
|
||||
static void delete_command (JWidget widget, void *data);
|
||||
static void use_command(JWidget widget, void *data);
|
||||
static void add_command(JWidget widget, void *data);
|
||||
static void delete_command(JWidget widget, void *data);
|
||||
|
||||
void ji_show_repo_dlg (RepoDlg *repo_dlg)
|
||||
void ji_show_repo_dlg(RepoDlg *repo_dlg)
|
||||
{
|
||||
JWidget window, box1, box2, view, button_close;
|
||||
|
||||
window = jwindow_new (repo_dlg->title);
|
||||
box1 = jbox_new (JI_HORIZONTAL);
|
||||
box2 = jbox_new (JI_VERTICAL);
|
||||
view = jview_new ();
|
||||
repo_dlg->listbox = jlistbox_new ();
|
||||
repo_dlg->button_use = jbutton_new (repo_dlg->use_text);
|
||||
repo_dlg->button_add = jbutton_new (_("&Add"));
|
||||
repo_dlg->button_delete = jbutton_new (_("&Delete"));
|
||||
button_close = jbutton_new (_("&Close"));
|
||||
window = jwindow_new(repo_dlg->title);
|
||||
box1 = jbox_new(JI_HORIZONTAL);
|
||||
box2 = jbox_new(JI_VERTICAL);
|
||||
view = jview_new();
|
||||
repo_dlg->listbox = jlistbox_new();
|
||||
repo_dlg->button_use = jbutton_new(repo_dlg->use_text);
|
||||
repo_dlg->button_add = jbutton_new(_("&Add"));
|
||||
repo_dlg->button_delete = jbutton_new(_("&Delete"));
|
||||
button_close = jbutton_new(_("&Close"));
|
||||
|
||||
jwidget_add_hook (repo_dlg->listbox, repo_listbox_type (),
|
||||
repo_listbox_msg_proc, repo_dlg);
|
||||
jwidget_add_hook(repo_dlg->listbox, repo_listbox_type(),
|
||||
repo_listbox_msg_proc, repo_dlg);
|
||||
|
||||
jbutton_add_command_data (repo_dlg->button_use, use_command, repo_dlg);
|
||||
jbutton_add_command_data (repo_dlg->button_add, add_command, repo_dlg);
|
||||
jbutton_add_command_data (repo_dlg->button_delete, delete_command, repo_dlg);
|
||||
jbutton_add_command_data(repo_dlg->button_use, use_command, repo_dlg);
|
||||
jbutton_add_command_data(repo_dlg->button_add, add_command, repo_dlg);
|
||||
jbutton_add_command_data(repo_dlg->button_delete, delete_command, repo_dlg);
|
||||
|
||||
jwidget_magnetic(repo_dlg->button_use, TRUE);
|
||||
|
||||
|
|
@ -69,56 +69,56 @@ void ji_show_repo_dlg (RepoDlg *repo_dlg)
|
|||
jwidget_set_min_size(view, JI_SCREEN_W*25/100, JI_SCREEN_H*25/100);
|
||||
|
||||
/* fill the list */
|
||||
fill_listbox (repo_dlg);
|
||||
jlistbox_select_index (repo_dlg->listbox, 0);
|
||||
fill_listbox(repo_dlg);
|
||||
jlistbox_select_index(repo_dlg->listbox, 0);
|
||||
|
||||
/* no items? */
|
||||
if (jlistbox_get_selected_index (repo_dlg->listbox) != 0) {
|
||||
jwidget_disable (repo_dlg->button_use);
|
||||
jwidget_disable (repo_dlg->button_delete);
|
||||
if (jlistbox_get_selected_index(repo_dlg->listbox) != 0) {
|
||||
jwidget_disable(repo_dlg->button_use);
|
||||
jwidget_disable(repo_dlg->button_delete);
|
||||
}
|
||||
|
||||
/* hierarchy */
|
||||
jwidget_add_child (box2, repo_dlg->button_use);
|
||||
jwidget_add_child (box2, repo_dlg->button_add);
|
||||
jwidget_add_child (box2, repo_dlg->button_delete);
|
||||
jwidget_add_child (box2, button_close);
|
||||
jwidget_add_child (box1, box2);
|
||||
jwidget_add_child (box1, view);
|
||||
jwidget_add_child (window, box1);
|
||||
jwidget_add_child(box2, repo_dlg->button_use);
|
||||
jwidget_add_child(box2, repo_dlg->button_add);
|
||||
jwidget_add_child(box2, repo_dlg->button_delete);
|
||||
jwidget_add_child(box2, button_close);
|
||||
jwidget_add_child(box1, box2);
|
||||
jwidget_add_child(box1, view);
|
||||
jwidget_add_child(window, box1);
|
||||
|
||||
/* default position */
|
||||
jwindow_remap (window);
|
||||
jwindow_center (window);
|
||||
jwindow_remap(window);
|
||||
jwindow_center(window);
|
||||
|
||||
/* load window configuration */
|
||||
load_window_pos (window, repo_dlg->config_section);
|
||||
load_window_pos(window, repo_dlg->config_section);
|
||||
|
||||
/* open window */
|
||||
jwindow_open_fg (window);
|
||||
jwindow_open_fg(window);
|
||||
|
||||
/* kill the list */
|
||||
kill_listbox (repo_dlg);
|
||||
kill_listbox(repo_dlg);
|
||||
|
||||
/* save window configuration */
|
||||
save_window_pos (window, repo_dlg->config_section);
|
||||
save_window_pos(window, repo_dlg->config_section);
|
||||
|
||||
jwidget_free (window);
|
||||
jwidget_free(window);
|
||||
}
|
||||
|
||||
static void fill_listbox (RepoDlg *repo_dlg)
|
||||
static void fill_listbox(RepoDlg *repo_dlg)
|
||||
{
|
||||
/* no item selected (ID=0) */
|
||||
repo_dlg->listitem = 0;
|
||||
|
||||
/* load the entries */
|
||||
if (repo_dlg->load_listbox)
|
||||
(*repo_dlg->load_listbox) (repo_dlg);
|
||||
(*repo_dlg->load_listbox)(repo_dlg);
|
||||
|
||||
jview_update (jwidget_get_view (repo_dlg->listbox));
|
||||
jview_update(jwidget_get_view(repo_dlg->listbox));
|
||||
}
|
||||
|
||||
static void kill_listbox (RepoDlg *repo_dlg)
|
||||
static void kill_listbox(RepoDlg *repo_dlg)
|
||||
{
|
||||
JWidget listbox = repo_dlg->listbox;
|
||||
JWidget listitem;
|
||||
|
|
@ -132,14 +132,14 @@ static void kill_listbox (RepoDlg *repo_dlg)
|
|||
JI_LIST_FOR_EACH_SAFE(listbox->children, link, next) {
|
||||
listitem = link->data;
|
||||
|
||||
jwidget_remove_child (repo_dlg->listbox, listitem);
|
||||
jwidget_remove_child(repo_dlg->listbox, listitem);
|
||||
|
||||
if (repo_dlg->free_listitem) {
|
||||
repo_dlg->listitem = listitem;
|
||||
(*repo_dlg->free_listitem) (repo_dlg);
|
||||
}
|
||||
|
||||
jwidget_free (listitem);
|
||||
jwidget_free(listitem);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -153,7 +153,7 @@ static int repo_listbox_type(void)
|
|||
|
||||
static bool repo_listbox_msg_proc(JWidget widget, JMessage msg)
|
||||
{
|
||||
RepoDlg *repo_dlg = jwidget_get_data(widget, repo_listbox_type ());
|
||||
RepoDlg *repo_dlg = jwidget_get_data(widget, repo_listbox_type());
|
||||
|
||||
switch (msg->type) {
|
||||
|
||||
|
|
@ -207,8 +207,8 @@ static void add_command(JWidget widget, void *data)
|
|||
jview_update(jwidget_get_view(repo_dlg->listbox));
|
||||
|
||||
/* select the last item */
|
||||
jlistbox_select_index (repo_dlg->listbox,
|
||||
jlist_length(repo_dlg->listbox->children)-1);
|
||||
jlistbox_select_index(repo_dlg->listbox,
|
||||
jlist_length(repo_dlg->listbox->children)-1);
|
||||
}
|
||||
|
||||
if (!ret)
|
||||
|
|
@ -226,34 +226,34 @@ static void delete_command(JWidget widget, void *data)
|
|||
ret = (*repo_dlg->delete_listitem) (repo_dlg, &kill);
|
||||
|
||||
if (kill) {
|
||||
index = jlistbox_get_selected_index (repo_dlg->listbox);
|
||||
index = jlistbox_get_selected_index(repo_dlg->listbox);
|
||||
|
||||
/* delete "repo_dlg->listitem" */
|
||||
jwidget_remove_child (repo_dlg->listbox, repo_dlg->listitem);
|
||||
jwidget_remove_child(repo_dlg->listbox, repo_dlg->listitem);
|
||||
|
||||
if (repo_dlg->free_listitem)
|
||||
(*repo_dlg->free_listitem) (repo_dlg);
|
||||
|
||||
jwidget_free (repo_dlg->listitem);
|
||||
jwidget_free(repo_dlg->listitem);
|
||||
|
||||
/* disable buttons */
|
||||
if (!repo_dlg->listbox->children) {
|
||||
jwidget_disable (repo_dlg->button_use);
|
||||
jwidget_disable (repo_dlg->button_delete);
|
||||
jwidget_disable(repo_dlg->button_use);
|
||||
jwidget_disable(repo_dlg->button_delete);
|
||||
}
|
||||
/* select other item */
|
||||
else {
|
||||
last = jlist_length (repo_dlg->listbox->children)-1;
|
||||
last = jlist_length(repo_dlg->listbox->children)-1;
|
||||
|
||||
jlistbox_select_index (repo_dlg->listbox,
|
||||
index > last ? last: index);
|
||||
jlistbox_select_index(repo_dlg->listbox,
|
||||
index > last ? last: index);
|
||||
}
|
||||
|
||||
/* update the list-box */
|
||||
jview_update (jwidget_get_view (repo_dlg->listbox));
|
||||
jview_update(jwidget_get_view(repo_dlg->listbox));
|
||||
}
|
||||
|
||||
if (!ret)
|
||||
jwidget_close_window (widget);
|
||||
jwidget_close_window(widget);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -33,20 +33,20 @@ typedef struct RepoDlg { /* a window to shows repositories
|
|||
const char *use_text;
|
||||
|
||||
/* fill the list box (you should add items to "repo_dlg->listbox") */
|
||||
void (*load_listbox) (struct RepoDlg *repo_dlg);
|
||||
void (*load_listbox)(struct RepoDlg *repo_dlg);
|
||||
|
||||
/* when the dialog is closed (you should save the modified entries) */
|
||||
void (*save_listbox) (struct RepoDlg *repo_dlg);
|
||||
void (*save_listbox)(struct RepoDlg *repo_dlg);
|
||||
|
||||
/* free the "user_data" of "repo_dlg->listitem", don't call
|
||||
jwidget_free(), it's called automatically */
|
||||
void (*free_listitem) (struct RepoDlg *repo_dlg);
|
||||
void (*free_listitem)(struct RepoDlg *repo_dlg);
|
||||
|
||||
/* return FALSE if to close the window, TRUE to continue (use the
|
||||
"repo_dlg->listitem") */
|
||||
bool (*use_listitem) (struct RepoDlg *repo_dlg);
|
||||
bool (*add_listitem) (struct RepoDlg *repo_dlg, int *added);
|
||||
bool (*delete_listitem) (struct RepoDlg *repo_dlg, int *kill);
|
||||
bool (*use_listitem)(struct RepoDlg *repo_dlg);
|
||||
bool (*add_listitem)(struct RepoDlg *repo_dlg, int *added);
|
||||
bool (*delete_listitem)(struct RepoDlg *repo_dlg, int *kill);
|
||||
|
||||
void *user_data[4];
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ typedef struct RepoDlg { /* a window to shows repositories
|
|||
JWidget button_delete; /* "Delete" button */
|
||||
} RepoDlg;
|
||||
|
||||
void ji_show_repo_dlg (RepoDlg *repo_dlg);
|
||||
void ji_show_repo_dlg(RepoDlg *repo_dlg);
|
||||
|
||||
#endif /* DIALOGS_REPO_H */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -36,24 +36,24 @@
|
|||
|
||||
#endif
|
||||
|
||||
static JWidget tips_new (void);
|
||||
static int tips_type (void);
|
||||
static bool tips_msg_proc (JWidget widget, JMessage msg);
|
||||
static void tips_request_size (JWidget widget, int *w, int *h);
|
||||
static JWidget tips_new(void);
|
||||
static int tips_type(void);
|
||||
static bool tips_msg_proc(JWidget widget, JMessage msg);
|
||||
static void tips_request_size(JWidget widget, int *w, int *h);
|
||||
|
||||
static JWidget tips_image_new (BITMAP *bmp);
|
||||
static int tips_image_type (void);
|
||||
static bool tips_image_msg_proc (JWidget widget, JMessage msg);
|
||||
static JWidget tips_image_new(BITMAP *bmp);
|
||||
static int tips_image_type(void);
|
||||
static bool tips_image_msg_proc(JWidget widget, JMessage msg);
|
||||
|
||||
static FILE *tips_open_file (void);
|
||||
static int tips_count_pages (void);
|
||||
static void tips_load_page (JWidget widget);
|
||||
static JWidget tips_load_box (FILE *f, char *buf, int sizeof_buf, int *take);
|
||||
static BITMAP *tips_load_image (const char *filename, PALETTE pal);
|
||||
static FILE *tips_open_file(void);
|
||||
static int tips_count_pages(void);
|
||||
static void tips_load_page(JWidget widget);
|
||||
static JWidget tips_load_box(FILE *f, char *buf, int sizeof_buf, int *take);
|
||||
static BITMAP *tips_load_image(const char *filename, PALETTE pal);
|
||||
|
||||
static void prev_command (JWidget widget, void *data);
|
||||
static void next_command (JWidget widget, void *data);
|
||||
static int check_signal (JWidget widget, int user_data);
|
||||
static void prev_command(JWidget widget, void *data);
|
||||
static void next_command(JWidget widget, void *data);
|
||||
static int check_signal(JWidget widget, int user_data);
|
||||
|
||||
void dialogs_tips(bool forced)
|
||||
{
|
||||
|
|
@ -69,8 +69,8 @@ void dialogs_tips(bool forced)
|
|||
|
||||
/* next page */
|
||||
{
|
||||
int pages = tips_count_pages ();
|
||||
int page = get_config_int ("Tips", "Page", -1);
|
||||
int pages = tips_count_pages();
|
||||
int page = get_config_int("Tips", "Page", -1);
|
||||
|
||||
/* error? */
|
||||
if (!pages)
|
||||
|
|
@ -78,11 +78,11 @@ void dialogs_tips(bool forced)
|
|||
|
||||
/* first time */
|
||||
if (page == -1)
|
||||
set_config_int ("Tips", "Page", 0);
|
||||
set_config_int("Tips", "Page", 0);
|
||||
/* other times (go to next tip) */
|
||||
else {
|
||||
page = MID (0, page, pages-1);
|
||||
set_config_int ("Tips", "Page", (page+1) % pages);
|
||||
page = MID(0, page, pages-1);
|
||||
set_config_int("Tips", "Page", (page+1) % pages);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -135,7 +135,7 @@ void dialogs_tips(bool forced)
|
|||
jwidget_set_min_size(window, 0, 0);
|
||||
|
||||
/* load first page */
|
||||
memcpy(old_pal, current_palette, sizeof (PALETTE));
|
||||
memcpy(old_pal, current_palette, sizeof(PALETTE));
|
||||
tips_load_page(tips);
|
||||
|
||||
/* run the window */
|
||||
|
|
@ -166,7 +166,7 @@ static int tips_type(void)
|
|||
{
|
||||
static int type = 0;
|
||||
if (!type)
|
||||
type = ji_register_widget_type ();
|
||||
type = ji_register_widget_type();
|
||||
return type;
|
||||
}
|
||||
|
||||
|
|
@ -175,7 +175,7 @@ static bool tips_msg_proc(JWidget widget, JMessage msg)
|
|||
switch (msg->type) {
|
||||
|
||||
case JM_REQSIZE:
|
||||
tips_request_size (widget, &msg->reqsize.w, &msg->reqsize.h);
|
||||
tips_request_size(widget, &msg->reqsize.w, &msg->reqsize.h);
|
||||
return TRUE;
|
||||
|
||||
case JM_WHEEL:
|
||||
|
|
@ -247,33 +247,33 @@ static FILE *tips_open_file(void)
|
|||
char filename[1024];
|
||||
DIRS *dirs, *dir;
|
||||
|
||||
sprintf (filename, "tips/tips.%s", intl_get_lang ());
|
||||
dirs = filename_in_datadir (filename);
|
||||
sprintf(filename, "tips/tips.%s", intl_get_lang());
|
||||
dirs = filename_in_datadir(filename);
|
||||
|
||||
for (dir=dirs; dir; dir=dir->next) {
|
||||
if ((dir->path) && exists (dir->path)) {
|
||||
strcpy (filename, dir->path);
|
||||
strcpy(filename, dir->path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!dir)
|
||||
strcpy (filename, dirs->path);
|
||||
strcpy(filename, dirs->path);
|
||||
|
||||
dirs_free (dirs);
|
||||
dirs_free(dirs);
|
||||
|
||||
return fopen (filename, "rt");
|
||||
return fopen(filename, "rt");
|
||||
}
|
||||
|
||||
static int tips_count_pages (void)
|
||||
static int tips_count_pages(void)
|
||||
{
|
||||
char buf[1024];
|
||||
int page = 0;
|
||||
FILE *f;
|
||||
|
||||
f = tips_open_file ();
|
||||
f = tips_open_file();
|
||||
if (!f) {
|
||||
console_printf ("Error loading tips files\n");
|
||||
console_printf("Error loading tips files\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -282,10 +282,10 @@ static int tips_count_pages (void)
|
|||
page++;
|
||||
}
|
||||
|
||||
fclose (f);
|
||||
fclose(f);
|
||||
|
||||
if (!page)
|
||||
console_printf ("No pages tips file\n");
|
||||
console_printf("No pages tips file\n");
|
||||
|
||||
return page;
|
||||
}
|
||||
|
|
@ -318,7 +318,7 @@ static void tips_load_page(JWidget widget)
|
|||
if (*buf == 12) {
|
||||
/* read this page */
|
||||
if (use_page == page) {
|
||||
JWidget vbox = tips_load_box(f, buf, sizeof (buf), &take);
|
||||
JWidget vbox = tips_load_box(f, buf, sizeof(buf), &take);
|
||||
if (vbox)
|
||||
jwidget_add_child(widget, vbox);
|
||||
break;
|
||||
|
|
@ -337,9 +337,9 @@ static void tips_load_page(JWidget widget)
|
|||
|
||||
static JWidget tips_load_box(FILE *f, char *buf, int sizeof_buf, int *take)
|
||||
{
|
||||
JWidget vbox = jbox_new (JI_VERTICAL);
|
||||
JWidget vbox = jbox_new(JI_VERTICAL);
|
||||
|
||||
jwidget_set_border (vbox, 2, 2, 2, 2);
|
||||
jwidget_set_border(vbox, 2, 2, 2, 2);
|
||||
|
||||
for (;;) {
|
||||
if (*take) {
|
||||
|
|
@ -357,13 +357,13 @@ static JWidget tips_load_box(FILE *f, char *buf, int sizeof_buf, int *take)
|
|||
|
||||
/* remove trailing space chars */
|
||||
while (*buf && isspace (ugetat (buf, -1)))
|
||||
usetat (buf, -1, 0);
|
||||
usetat(buf, -1, 0);
|
||||
|
||||
/************************************************************/
|
||||
/* empty? */
|
||||
if (!*buf) {
|
||||
/* add a box with an static size to separate paragraphs */
|
||||
JWidget box = jbox_new (0);
|
||||
JWidget box = jbox_new(0);
|
||||
|
||||
jwidget_set_min_size(box, 0, text_height(box->text_font));
|
||||
|
||||
|
|
@ -373,38 +373,38 @@ static JWidget tips_load_box(FILE *f, char *buf, int sizeof_buf, int *take)
|
|||
/* special object (line start with \) */
|
||||
else if (*buf == '\\') {
|
||||
/* \split */
|
||||
if (ustrncmp (buf+1, "split", 5) == 0) {
|
||||
JWidget box, hbox = jbox_new (JI_HORIZONTAL | JI_HOMOGENEOUS);
|
||||
if (ustrncmp(buf+1, "split", 5) == 0) {
|
||||
JWidget box, hbox = jbox_new(JI_HORIZONTAL | JI_HOMOGENEOUS);
|
||||
|
||||
do {
|
||||
box = tips_load_box (f, buf, sizeof_buf, take);
|
||||
box = tips_load_box(f, buf, sizeof_buf, take);
|
||||
if (box)
|
||||
jwidget_add_child (hbox, box);
|
||||
} while (ustrncmp (buf, "\\next", 5) == 0);
|
||||
jwidget_add_child(hbox, box);
|
||||
} while (ustrncmp(buf, "\\next", 5) == 0);
|
||||
|
||||
jwidget_add_child (vbox, hbox);
|
||||
jwidget_add_child(vbox, hbox);
|
||||
*take = TRUE;
|
||||
}
|
||||
/* \next and \done */
|
||||
else if ((ustrncmp (buf+1, "next", 4) == 0) ||
|
||||
(ustrncmp (buf+1, "done", 4) == 0)) {
|
||||
else if ((ustrncmp(buf+1, "next", 4) == 0) ||
|
||||
(ustrncmp(buf+1, "done", 4) == 0)) {
|
||||
break;
|
||||
}
|
||||
/* \image filename */
|
||||
else if (ustrncmp (buf+1, "image", 5) == 0) {
|
||||
else if (ustrncmp(buf+1, "image", 5) == 0) {
|
||||
char filename[1024];
|
||||
PALETTE pal;
|
||||
BITMAP *bmp;
|
||||
|
||||
sprintf (filename, "tips/%s", strchr (buf, ' ')+1);
|
||||
bmp = tips_load_image (filename, pal);
|
||||
sprintf(filename, "tips/%s", strchr(buf, ' ')+1);
|
||||
bmp = tips_load_image(filename, pal);
|
||||
if (bmp) {
|
||||
JWidget image = tips_image_new (bmp);
|
||||
jwidget_add_child (vbox, image);
|
||||
JWidget image = tips_image_new(bmp);
|
||||
jwidget_add_child(vbox, image);
|
||||
}
|
||||
else {
|
||||
sprintf (buf, _("Error loading image %s"), filename);
|
||||
jwidget_add_child (vbox, jlabel_new (buf));
|
||||
sprintf(buf, _("Error loading image %s"), filename);
|
||||
jwidget_add_child(vbox, jlabel_new(buf));
|
||||
}
|
||||
}
|
||||
/* \palette filename */
|
||||
|
|
@ -413,22 +413,22 @@ static JWidget tips_load_box(FILE *f, char *buf, int sizeof_buf, int *take)
|
|||
PALETTE pal;
|
||||
BITMAP *bmp;
|
||||
|
||||
sprintf (filename, "tips/%s", strchr (buf, ' ')+1);
|
||||
bmp = tips_load_image (filename, pal);
|
||||
sprintf(filename, "tips/%s", strchr(buf, ' ')+1);
|
||||
bmp = tips_load_image(filename, pal);
|
||||
if (bmp) {
|
||||
set_current_palette (pal, FALSE);
|
||||
destroy_bitmap (bmp);
|
||||
set_current_palette(pal, FALSE);
|
||||
destroy_bitmap(bmp);
|
||||
}
|
||||
else {
|
||||
sprintf (buf, _("Error loading palette %s"), filename);
|
||||
jwidget_add_child (vbox, jlabel_new (buf));
|
||||
sprintf(buf, _("Error loading palette %s"), filename);
|
||||
jwidget_add_child(vbox, jlabel_new(buf));
|
||||
}
|
||||
}
|
||||
}
|
||||
/************************************************************/
|
||||
/* add text */
|
||||
else {
|
||||
char *text = jstrdup (buf);
|
||||
char *text = jstrdup(buf);
|
||||
|
||||
/* read more text (to generate a paragraph) */
|
||||
if (*text != '*') {
|
||||
|
|
@ -452,9 +452,9 @@ static JWidget tips_load_box(FILE *f, char *buf, int sizeof_buf, int *take)
|
|||
}
|
||||
|
||||
/* add chars */
|
||||
text = jrealloc(text, strlen (text) + 1 + strlen (buf) + 1);
|
||||
text = jrealloc(text, strlen(text) + 1 + strlen(buf) + 1);
|
||||
strcat(text, " ");
|
||||
strcpy(text+strlen (text), buf);
|
||||
strcpy(text+strlen(text), buf);
|
||||
}
|
||||
|
||||
/* add the textbox */
|
||||
|
|
@ -470,7 +470,7 @@ static JWidget tips_load_box(FILE *f, char *buf, int sizeof_buf, int *take)
|
|||
}
|
||||
|
||||
/* white background */
|
||||
jwidget_set_bg_color (vbox, makecol (255, 255, 255));
|
||||
jwidget_set_bg_color(vbox, makecol(255, 255, 255));
|
||||
|
||||
return vbox;
|
||||
}
|
||||
|
|
@ -493,26 +493,26 @@ static BITMAP *tips_load_image(const char *filename, PALETTE pal)
|
|||
return bmp;
|
||||
}
|
||||
|
||||
static void prev_command (JWidget widget, void *data)
|
||||
static void prev_command(JWidget widget, void *data)
|
||||
{
|
||||
int pages = tips_count_pages ();
|
||||
int page = get_config_int ("Tips", "Page", 0);
|
||||
int pages = tips_count_pages();
|
||||
int page = get_config_int("Tips", "Page", 0);
|
||||
|
||||
set_config_int ("Tips", "Page", page > 0 ? page-1: pages-1);
|
||||
tips_load_page ((JWidget)data);
|
||||
set_config_int("Tips", "Page", page > 0 ? page-1: pages-1);
|
||||
tips_load_page((JWidget)data);
|
||||
}
|
||||
|
||||
static void next_command (JWidget widget, void *data)
|
||||
static void next_command(JWidget widget, void *data)
|
||||
{
|
||||
int pages = tips_count_pages ();
|
||||
int page = get_config_int ("Tips", "Page", 0);
|
||||
int pages = tips_count_pages();
|
||||
int page = get_config_int("Tips", "Page", 0);
|
||||
|
||||
set_config_int ("Tips", "Page", page < pages-1 ? page+1: 0);
|
||||
tips_load_page ((JWidget)data);
|
||||
set_config_int("Tips", "Page", page < pages-1 ? page+1: 0);
|
||||
tips_load_page((JWidget)data);
|
||||
}
|
||||
|
||||
static int check_signal (JWidget widget, int user_data)
|
||||
static int check_signal(JWidget widget, int user_data)
|
||||
{
|
||||
set_config_bool ("Tips", "Show", jwidget_is_selected (widget));
|
||||
set_config_bool("Tips", "Show", jwidget_is_selected(widget));
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -33,20 +33,20 @@
|
|||
|
||||
#endif
|
||||
|
||||
static void project (Image *image, int x, int y, double dmax, double *out_x, double *out_y)
|
||||
static void project(Image *image, int x, int y, double dmax, double *out_x, double *out_y)
|
||||
{
|
||||
int center_x = image->w/2; /* center point */
|
||||
int center_y = image->h/2;
|
||||
int u = (x - center_x); /* vector from center to current point */
|
||||
int v = (y - center_y);
|
||||
int r = MIN (image->w, image->h)/2; /* radius */
|
||||
double d = sqrt (u*u + v*v); /* distance from center */
|
||||
double a = atan2 (-v, u); /* angle with center */
|
||||
int r = MIN(image->w, image->h)/2; /* radius */
|
||||
double d = sqrt(u*u + v*v); /* distance from center */
|
||||
double a = atan2(-v, u); /* angle with center */
|
||||
|
||||
#if 1
|
||||
/* sphere */
|
||||
double s = sin (PI*MIN(d, r)/r); /* scale factor for effect */
|
||||
/* double s = cos (PI/2*MIN(d, r)/r); /\* scale factor for effect *\/ */
|
||||
double s = sin(PI*MIN(d, r)/r); /* scale factor for effect */
|
||||
/* double s = cos(PI/2*MIN(d, r)/r); /\* scale factor for effect *\/ */
|
||||
double howmuch = 32;
|
||||
/* *out_x = s * (cos(a)*howmuch*(dmax-d)/dmax); */
|
||||
/* *out_y = s * (sin(a)*howmuch*(dmax-d)/dmax); */
|
||||
|
|
@ -62,7 +62,7 @@ static void project (Image *image, int x, int y, double dmax, double *out_x, dou
|
|||
#elif 1
|
||||
|
||||
/* twist */
|
||||
/* double s = sin (PI*4*MIN(d, r)/r); /\* scale factor for effect *\/ */
|
||||
/* double s = sin(PI*4*MIN(d, r)/r); /\* scale factor for effect *\/ */
|
||||
/* *out_x = s * (cos(a)*8); */
|
||||
/* *out_y = s * (sin(a)*8); */
|
||||
/* double twist_angle = 2*PI; */
|
||||
|
|
@ -97,39 +97,39 @@ static unsigned long bilinear4 (unsigned long A, unsigned long B,
|
|||
areaD = xy;
|
||||
|
||||
#define CHANNEL(channel) \
|
||||
res_##channel = ((areaA * _rgba_get##channel (A)) + \
|
||||
(areaB * _rgba_get##channel (B)) + \
|
||||
(areaC * _rgba_get##channel (C)) + \
|
||||
(areaD * _rgba_get##channel (D))) >> 5
|
||||
res_##channel = ((areaA * _rgba_get##channel(A)) + \
|
||||
(areaB * _rgba_get##channel(B)) + \
|
||||
(areaC * _rgba_get##channel(C)) + \
|
||||
(areaD * _rgba_get##channel(D))) >> 5
|
||||
|
||||
CHANNEL (r);
|
||||
CHANNEL (g);
|
||||
CHANNEL (b);
|
||||
CHANNEL (a);
|
||||
CHANNEL(r);
|
||||
CHANNEL(g);
|
||||
CHANNEL(b);
|
||||
CHANNEL(a);
|
||||
|
||||
return _rgba (res_r, res_g, res_b, res_a);
|
||||
return _rgba(res_r, res_g, res_b, res_a);
|
||||
}
|
||||
|
||||
static int image_getpixel4 (Image *image, double x, double y)
|
||||
{
|
||||
int x1, y1, x2, y2, a, b, c, d;
|
||||
|
||||
x1 = floor (x);
|
||||
y1 = floor (y);
|
||||
x2 = ceil (x);
|
||||
y2 = ceil (y);
|
||||
x1 = floor(x);
|
||||
y1 = floor(y);
|
||||
x2 = ceil(x);
|
||||
y2 = ceil(y);
|
||||
|
||||
a = image_getpixel (image, MID (0, x1, image->w-1), MID (0, y1, image->h-1));
|
||||
b = image_getpixel (image, MID (0, x2, image->w-1), MID (0, y1, image->h-1));
|
||||
c = image_getpixel (image, MID (0, x1, image->w-1), MID (0, y2, image->h-1));
|
||||
d = image_getpixel (image, MID (0, x2, image->w-1), MID (0, y2, image->h-1));
|
||||
a = image_getpixel(image, MID(0, x1, image->w-1), MID(0, y1, image->h-1));
|
||||
b = image_getpixel(image, MID(0, x2, image->w-1), MID(0, y1, image->h-1));
|
||||
c = image_getpixel(image, MID(0, x1, image->w-1), MID(0, y2, image->h-1));
|
||||
d = image_getpixel(image, MID(0, x2, image->w-1), MID(0, y2, image->h-1));
|
||||
|
||||
return bilinear4 (a, b, c, d, ftofix (x), ftofix (y));
|
||||
return bilinear4(a, b, c, d, ftofix(x), ftofix(y));
|
||||
}
|
||||
|
||||
void dialogs_vector_map(void)
|
||||
{
|
||||
#define PROJECT() project (image, x, y, dmax, &u, &v)
|
||||
#define PROJECT() project(image, x, y, dmax, &u, &v)
|
||||
|
||||
Sprite *sprite = current_sprite;
|
||||
Image *image, *image_copy;
|
||||
|
|
@ -139,24 +139,24 @@ void dialogs_vector_map(void)
|
|||
if (!is_interactive () || !sprite)
|
||||
return;
|
||||
|
||||
image = GetImage ();
|
||||
image = GetImage();
|
||||
if (!image)
|
||||
return;
|
||||
|
||||
image_copy = image_new_copy (image);
|
||||
image_copy = image_new_copy(image);
|
||||
if (!image_copy)
|
||||
return;
|
||||
|
||||
/* undo stuff */
|
||||
if (undo_is_enabled (sprite->undo))
|
||||
undo_image (sprite->undo, image, 0, 0, image->w, image->h);
|
||||
if (undo_is_enabled(sprite->undo))
|
||||
undo_image(sprite->undo, image, 0, 0, image->w, image->h);
|
||||
|
||||
dmax = sqrt (image->w/2*image->w/2 + image->h/2*image->h/2);
|
||||
dmax = sqrt(image->w/2*image->w/2 + image->h/2*image->h/2);
|
||||
for (y=0; y<image->h; y++) {
|
||||
for (x=0; x<image->w; x++) {
|
||||
PROJECT ();
|
||||
PROJECT();
|
||||
c = image_getpixel4 (image_copy, x-u, y+v);
|
||||
image_putpixel (image, x, y, c);
|
||||
image_putpixel(image, x, y, c);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -34,11 +34,11 @@ static struct {
|
|||
int cmap[256];
|
||||
} data;
|
||||
|
||||
CurvePoint *curve_point_new (int x, int y)
|
||||
CurvePoint *curve_point_new(int x, int y)
|
||||
{
|
||||
CurvePoint *point;
|
||||
|
||||
point = jnew (CurvePoint, 1);
|
||||
point = jnew(CurvePoint, 1);
|
||||
if (!point)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -48,16 +48,16 @@ CurvePoint *curve_point_new (int x, int y)
|
|||
return point;
|
||||
}
|
||||
|
||||
void curve_point_free (CurvePoint *point)
|
||||
void curve_point_free(CurvePoint *point)
|
||||
{
|
||||
jfree (point);
|
||||
jfree(point);
|
||||
}
|
||||
|
||||
Curve *curve_new (int type)
|
||||
Curve *curve_new(int type)
|
||||
{
|
||||
Curve *curve;
|
||||
|
||||
curve = jnew (Curve, 1);
|
||||
curve = jnew(Curve, 1);
|
||||
if (!curve)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ Curve *curve_new (int type)
|
|||
return curve;
|
||||
}
|
||||
|
||||
void curve_free (Curve *curve)
|
||||
void curve_free(Curve *curve)
|
||||
{
|
||||
JLink link;
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ void curve_free (Curve *curve)
|
|||
jfree(curve);
|
||||
}
|
||||
|
||||
void curve_add_point (Curve *curve, CurvePoint *point)
|
||||
void curve_add_point(Curve *curve, CurvePoint *point)
|
||||
{
|
||||
JLink link;
|
||||
|
||||
|
|
@ -89,7 +89,7 @@ void curve_add_point (Curve *curve, CurvePoint *point)
|
|||
jlist_insert_before(curve->points, link, point);
|
||||
}
|
||||
|
||||
void curve_remove_point (Curve *curve, CurvePoint *point)
|
||||
void curve_remove_point(Curve *curve, CurvePoint *point)
|
||||
{
|
||||
jlist_remove(curve->points, point);
|
||||
}
|
||||
|
|
@ -102,12 +102,12 @@ void curve_remove_point (Curve *curve, CurvePoint *point)
|
|||
derivatives for the interpolation points. (Based on Numerical
|
||||
Recipies 2nd Edition.) */
|
||||
static void
|
||||
spline_solve (int n, float x[], float y[], float y2[])
|
||||
spline_solve(int n, float x[], float y[], float y2[])
|
||||
{
|
||||
float p, sig, *u;
|
||||
int i, k;
|
||||
|
||||
u = jmalloc ((n - 1) * sizeof (u[0]));
|
||||
u = jmalloc((n - 1) * sizeof(u[0]));
|
||||
|
||||
y2[0] = u[0] = 0.0; /* set lower boundary condition to "natural" */
|
||||
|
||||
|
|
@ -125,11 +125,11 @@ spline_solve (int n, float x[], float y[], float y2[])
|
|||
for (k = n - 2; k >= 0; --k)
|
||||
y2[k] = y2[k] * y2[k + 1] + u[k];
|
||||
|
||||
jfree (u);
|
||||
jfree(u);
|
||||
}
|
||||
|
||||
static float
|
||||
spline_eval (int n, float x[], float y[], float y2[], float val)
|
||||
spline_eval(int n, float x[], float y[], float y2[], float val)
|
||||
{
|
||||
int k_lo, k_hi, k;
|
||||
float h, b, a;
|
||||
|
|
@ -147,7 +147,7 @@ spline_eval (int n, float x[], float y[], float y2[], float val)
|
|||
|
||||
h = x[k_hi] - x[k_lo];
|
||||
/* TODO */
|
||||
/* assert (h > 0.0); */
|
||||
/* assert(h > 0.0); */
|
||||
|
||||
a = (x[k_hi] - val) / h;
|
||||
b = (val - x[k_lo]) / h;
|
||||
|
|
@ -155,7 +155,7 @@ spline_eval (int n, float x[], float y[], float y2[], float val)
|
|||
((a*a*a - a)*y2[k_lo] + (b*b*b - b)*y2[k_hi]) * (h*h)/6.0;
|
||||
}
|
||||
|
||||
void curve_get_values (Curve *curve, int x1, int x2, int *values)
|
||||
void curve_get_values(Curve *curve, int x1, int x2, int *values)
|
||||
{
|
||||
int x, num_points = jlist_length(curve->points);
|
||||
|
||||
|
|
@ -209,7 +209,7 @@ void curve_get_values (Curve *curve, int x1, int x2, int *values)
|
|||
|
||||
min_x = 0;
|
||||
|
||||
mem = jmalloc (3 * num_points * sizeof (float));
|
||||
mem = jmalloc(3 * num_points * sizeof(float));
|
||||
xv = mem;
|
||||
yv = mem + num_points;
|
||||
y2v = mem + 2*num_points;
|
||||
|
|
@ -225,12 +225,12 @@ void curve_get_values (Curve *curve, int x1, int x2, int *values)
|
|||
}
|
||||
}
|
||||
|
||||
spline_solve (dst, xv, yv, y2v);
|
||||
spline_solve(dst, xv, yv, y2v);
|
||||
|
||||
rx = min_x;
|
||||
dx = (x2 - x1) / (veclen-1);
|
||||
for (x=0; x<veclen; ++x, rx+=dx) {
|
||||
ry = spline_eval (dst, xv, yv, y2v, rx);
|
||||
ry = spline_eval(dst, xv, yv, y2v, rx);
|
||||
#if 0
|
||||
/* if (ry < curve->min_y) ry = curve->min_y; */
|
||||
/* if (ry > curve->max_y) ry = curve->max_y; */
|
||||
|
|
@ -345,11 +345,11 @@ void apply_color_curve1(Effect *effect)
|
|||
if (!((*effect->mask_address) & (1<<effect->d.rem))) {
|
||||
src_address++;
|
||||
dst_address++;
|
||||
_image_bitmap_next_bit (effect->d, effect->mask_address);
|
||||
_image_bitmap_next_bit(effect->d, effect->mask_address);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
_image_bitmap_next_bit (effect->d, effect->mask_address);
|
||||
_image_bitmap_next_bit(effect->d, effect->mask_address);
|
||||
}
|
||||
|
||||
c = *(src_address++);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -39,16 +39,16 @@ typedef struct Curve
|
|||
JList points;
|
||||
} Curve;
|
||||
|
||||
CurvePoint *curve_point_new (int x, int y);
|
||||
void curve_point_free (CurvePoint *point);
|
||||
CurvePoint *curve_point_new(int x, int y);
|
||||
void curve_point_free(CurvePoint *point);
|
||||
|
||||
Curve *curve_new (int type);
|
||||
void curve_free (Curve *curve);
|
||||
void curve_add_point (Curve *curve, CurvePoint *point);
|
||||
void curve_remove_point (Curve *curve, CurvePoint *point);
|
||||
void curve_get_values (Curve *curve, int x1, int x2, int *values);
|
||||
Curve *curve_new(int type);
|
||||
void curve_free(Curve *curve);
|
||||
void curve_add_point(Curve *curve, CurvePoint *point);
|
||||
void curve_remove_point(Curve *curve, CurvePoint *point);
|
||||
void curve_get_values(Curve *curve, int x1, int x2, int *values);
|
||||
|
||||
void set_color_curve (Curve *curve);
|
||||
void set_color_curve(Curve *curve);
|
||||
|
||||
void apply_color_curve4 (struct Effect *effect);
|
||||
void apply_color_curve2 (struct Effect *effect);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -163,60 +163,60 @@ void reload_matrices_stock(void)
|
|||
clean_matrices_stock();
|
||||
|
||||
for (i=0; names[i]; i++) {
|
||||
dirs = filename_in_datadir (names[i]);
|
||||
dirs = filename_in_datadir(names[i]);
|
||||
|
||||
for (dir=dirs; dir; dir=dir->next) {
|
||||
/* open matrices stock file */
|
||||
f = fopen (dir->path, "r");
|
||||
f = fopen(dir->path, "r");
|
||||
if (!f)
|
||||
continue;
|
||||
|
||||
tok_reset_line_num ();
|
||||
tok_reset_line_num();
|
||||
|
||||
name = NULL;
|
||||
convmatr = NULL;
|
||||
strcpy (leavings, "");
|
||||
strcpy(leavings, "");
|
||||
|
||||
/* read the matrix name */
|
||||
while (tok_read (f, buf, leavings, sizeof (leavings))) {
|
||||
/* name of the matrix */
|
||||
name = jstrdup (buf);
|
||||
name = jstrdup(buf);
|
||||
|
||||
/* width and height */
|
||||
READ_INT (w);
|
||||
READ_INT (h);
|
||||
READ_INT(w);
|
||||
READ_INT(h);
|
||||
|
||||
if ((w <= 0) || (w > 32) ||
|
||||
(h <= 0) || (h > 32))
|
||||
break;
|
||||
|
||||
/* create the matrix data */
|
||||
convmatr = convmatr_new (w, h);
|
||||
convmatr = convmatr_new(w, h);
|
||||
if (!convmatr)
|
||||
break;
|
||||
|
||||
/* centre */
|
||||
READ_INT (convmatr->cx);
|
||||
READ_INT (convmatr->cy);
|
||||
READ_INT(convmatr->cx);
|
||||
READ_INT(convmatr->cy);
|
||||
|
||||
if ((convmatr->cx < 0) || (convmatr->cx >= w) ||
|
||||
(convmatr->cy < 0) || (convmatr->cy >= h))
|
||||
break;
|
||||
|
||||
/* data */
|
||||
READ_TOK (); /* jump the `{' char */
|
||||
READ_TOK(); /* jump the `{' char */
|
||||
if (*buf != '{')
|
||||
break;
|
||||
|
||||
c = 0;
|
||||
div = 0;
|
||||
for (c=0; c<w*h; c++) {
|
||||
READ_TOK ();
|
||||
convmatr->data[c] = ustrtod (buf, NULL) * PRECISION;
|
||||
READ_TOK();
|
||||
convmatr->data[c] = ustrtod(buf, NULL) * PRECISION;
|
||||
div += convmatr->data[c];
|
||||
}
|
||||
|
||||
READ_TOK (); /* jump the `}' char */
|
||||
READ_TOK(); /* jump the `}' char */
|
||||
if (*buf != '}')
|
||||
break;
|
||||
|
||||
|
|
@ -227,26 +227,26 @@ void reload_matrices_stock(void)
|
|||
bias = 128;
|
||||
}
|
||||
else {
|
||||
div = ABS (div);
|
||||
div = ABS(div);
|
||||
bias = 255;
|
||||
}
|
||||
|
||||
/* div */
|
||||
READ_TOK ();
|
||||
READ_TOK();
|
||||
if (ustricmp (buf, "auto") != 0)
|
||||
div = ustrtod (buf, NULL) * PRECISION;
|
||||
div = ustrtod(buf, NULL) * PRECISION;
|
||||
|
||||
convmatr->div = div;
|
||||
|
||||
/* bias */
|
||||
READ_TOK ();
|
||||
READ_TOK();
|
||||
if (ustricmp (buf, "auto") != 0)
|
||||
bias = ustrtod (buf, NULL);
|
||||
bias = ustrtod(buf, NULL);
|
||||
|
||||
convmatr->bias = bias;
|
||||
|
||||
/* target */
|
||||
READ_TOK ();
|
||||
READ_TOK();
|
||||
|
||||
for (s=buf; *s; s++) {
|
||||
switch (*s) {
|
||||
|
|
@ -269,16 +269,16 @@ void reload_matrices_stock(void)
|
|||
|
||||
/* destroy the last invalid matrix in case of error */
|
||||
if (name)
|
||||
jfree (name);
|
||||
jfree(name);
|
||||
|
||||
if (convmatr)
|
||||
convmatr_free (convmatr);
|
||||
convmatr_free(convmatr);
|
||||
|
||||
/* close the file */
|
||||
fclose (f);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
dirs_free (dirs);
|
||||
dirs_free(dirs);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -312,7 +312,7 @@ JList get_convmatr_stock(void)
|
|||
mdata++; \
|
||||
); \
|
||||
\
|
||||
color = src->method->getpixel (src, x, y); \
|
||||
color = src->method->getpixel(src, x, y); \
|
||||
if (div == 0) { \
|
||||
*(dst_address++) = color; \
|
||||
continue; \
|
||||
|
|
@ -341,11 +341,11 @@ void apply_convolution_matrix4(Effect *effect)
|
|||
if (effect->mask_address) {
|
||||
if (!((*effect->mask_address) & (1<<effect->d.rem))) {
|
||||
dst_address++;
|
||||
_image_bitmap_next_bit (effect->d, effect->mask_address);
|
||||
_image_bitmap_next_bit(effect->d, effect->mask_address);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
_image_bitmap_next_bit (effect->d, effect->mask_address);
|
||||
_image_bitmap_next_bit(effect->d, effect->mask_address);
|
||||
}
|
||||
|
||||
r = g = b = a = 0;
|
||||
|
|
@ -364,38 +364,38 @@ void apply_convolution_matrix4(Effect *effect)
|
|||
|
||||
if (effect->target.r) {
|
||||
r = r / div + matrix->bias;
|
||||
r = MID (0, r, 255);
|
||||
r = MID(0, r, 255);
|
||||
}
|
||||
else
|
||||
r = _rgba_getr (color);
|
||||
r = _rgba_getr(color);
|
||||
|
||||
if (effect->target.g) {
|
||||
g = g / div + matrix->bias;
|
||||
g = MID (0, g, 255);
|
||||
g = MID(0, g, 255);
|
||||
}
|
||||
else
|
||||
g = _rgba_getg (color);
|
||||
g = _rgba_getg(color);
|
||||
|
||||
if (effect->target.b) {
|
||||
b = b / div + matrix->bias;
|
||||
b = MID (0, b, 255);
|
||||
b = MID(0, b, 255);
|
||||
}
|
||||
else
|
||||
b = _rgba_getb (color);
|
||||
b = _rgba_getb(color);
|
||||
|
||||
if (effect->target.a) {
|
||||
a = a / matrix->div + matrix->bias;
|
||||
a = MID (0, a, 255);
|
||||
a = MID(0, a, 255);
|
||||
}
|
||||
else
|
||||
a = _rgba_geta (color);
|
||||
a = _rgba_geta(color);
|
||||
|
||||
*(dst_address++) = _rgba (r, g, b, a);
|
||||
*(dst_address++) = _rgba(r, g, b, a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void apply_convolution_matrix2 (Effect *effect)
|
||||
void apply_convolution_matrix2(Effect *effect)
|
||||
{
|
||||
ConvMatr *matrix = data.convmatr;
|
||||
Image *src = effect->src;
|
||||
|
|
@ -418,11 +418,11 @@ void apply_convolution_matrix2 (Effect *effect)
|
|||
if (effect->mask_address) {
|
||||
if (!((*effect->mask_address) & (1<<effect->d.rem))) {
|
||||
dst_address++;
|
||||
_image_bitmap_next_bit (effect->d, effect->mask_address);
|
||||
_image_bitmap_next_bit(effect->d, effect->mask_address);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
_image_bitmap_next_bit (effect->d, effect->mask_address);
|
||||
_image_bitmap_next_bit(effect->d, effect->mask_address);
|
||||
}
|
||||
|
||||
k = a = 0;
|
||||
|
|
@ -439,19 +439,19 @@ void apply_convolution_matrix2 (Effect *effect)
|
|||
|
||||
if (effect->target.k) {
|
||||
k = k / div + matrix->bias;
|
||||
k = MID (0, k, 255);
|
||||
k = MID(0, k, 255);
|
||||
}
|
||||
else
|
||||
k = _graya_getk (color);
|
||||
k = _graya_getk(color);
|
||||
|
||||
if (effect->target.a) {
|
||||
a = a / matrix->div + matrix->bias;
|
||||
a = MID (0, a, 255);
|
||||
a = MID(0, a, 255);
|
||||
}
|
||||
else
|
||||
a = _graya_geta (color);
|
||||
a = _graya_geta(color);
|
||||
|
||||
*(dst_address++) = _graya (k, a);
|
||||
*(dst_address++) = _graya(k, a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -479,11 +479,11 @@ void apply_convolution_matrix1(Effect *effect)
|
|||
if (effect->mask_address) {
|
||||
if (!((*effect->mask_address) & (1<<effect->d.rem))) {
|
||||
dst_address++;
|
||||
_image_bitmap_next_bit (effect->d, effect->mask_address);
|
||||
_image_bitmap_next_bit(effect->d, effect->mask_address);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
_image_bitmap_next_bit (effect->d, effect->mask_address);
|
||||
_image_bitmap_next_bit(effect->d, effect->mask_address);
|
||||
}
|
||||
|
||||
r = g = b = index = 0;
|
||||
|
|
@ -505,7 +505,7 @@ void apply_convolution_matrix1(Effect *effect)
|
|||
else {
|
||||
if (effect->target.r) {
|
||||
r = r / div + matrix->bias;
|
||||
r = MID (0, r, 255);
|
||||
r = MID(0, r, 255);
|
||||
}
|
||||
else
|
||||
r = _rgb_scale_6[current_palette[color].r];
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -40,20 +40,20 @@ typedef struct ConvMatr /* a convolution matrix */
|
|||
int default_target; /* targets by default */
|
||||
} ConvMatr;
|
||||
|
||||
ConvMatr *convmatr_new (int w, int h);
|
||||
ConvMatr *convmatr_new_string (const char *format);
|
||||
void convmatr_free (ConvMatr *convmatr);
|
||||
ConvMatr *convmatr_new(int w, int h);
|
||||
ConvMatr *convmatr_new_string(const char *format);
|
||||
void convmatr_free(ConvMatr *convmatr);
|
||||
|
||||
void set_convmatr (ConvMatr *convmatr);
|
||||
ConvMatr *get_convmatr (void);
|
||||
ConvMatr *get_convmatr_by_name (const char *name);
|
||||
void set_convmatr(ConvMatr *convmatr);
|
||||
ConvMatr *get_convmatr(void);
|
||||
ConvMatr *get_convmatr_by_name(const char *name);
|
||||
|
||||
void reload_matrices_stock (void);
|
||||
void clean_matrices_stock (void);
|
||||
JList get_convmatr_stock (void);
|
||||
void reload_matrices_stock(void);
|
||||
void clean_matrices_stock(void);
|
||||
JList get_convmatr_stock(void);
|
||||
|
||||
void init_convolution_matrix (void);
|
||||
void exit_convolution_matrix (void);
|
||||
void init_convolution_matrix(void);
|
||||
void exit_convolution_matrix(void);
|
||||
|
||||
void apply_convolution_matrix4 (struct Effect *effect);
|
||||
void apply_convolution_matrix2 (struct Effect *effect);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -52,39 +52,39 @@
|
|||
typedef struct EffectData
|
||||
{
|
||||
const char *name;
|
||||
void (*apply_4) (Effect *effect);
|
||||
void (*apply_2) (Effect *effect);
|
||||
void (*apply_1) (Effect *effect);
|
||||
void (*apply_4)(Effect *effect);
|
||||
void (*apply_2)(Effect *effect);
|
||||
void (*apply_1)(Effect *effect);
|
||||
} EffectData;
|
||||
|
||||
#define FXDATA(name) \
|
||||
{ #name, apply_##name##4, apply_##name##2, apply_##name##1 }
|
||||
|
||||
static EffectData effects_data[] = {
|
||||
FXDATA (color_curve),
|
||||
FXDATA (convolution_matrix),
|
||||
FXDATA (invert_color),
|
||||
FXDATA (median),
|
||||
FXDATA (replace_color),
|
||||
FXDATA(color_curve),
|
||||
FXDATA(convolution_matrix),
|
||||
FXDATA(invert_color),
|
||||
FXDATA(median),
|
||||
FXDATA(replace_color),
|
||||
{ NULL, NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
static EffectData *get_effect_data (const char *name);
|
||||
static int effect_init (Effect *effect, Image *image, int offset_x, int offset_y);
|
||||
static int effect_update_mask (Effect *effect, Mask *mask, Image *image);
|
||||
static EffectData *get_effect_data(const char *name);
|
||||
static int effect_init(Effect *effect, Image *image, int offset_x, int offset_y);
|
||||
static int effect_update_mask(Effect *effect, Mask *mask, Image *image);
|
||||
|
||||
int init_module_effect (void)
|
||||
int init_module_effect(void)
|
||||
{
|
||||
init_convolution_matrix ();
|
||||
init_convolution_matrix();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void exit_module_effect (void)
|
||||
void exit_module_effect(void)
|
||||
{
|
||||
exit_convolution_matrix ();
|
||||
exit_convolution_matrix();
|
||||
}
|
||||
|
||||
Effect *effect_new (Sprite *sprite, const char *name)
|
||||
Effect *effect_new(Sprite *sprite, const char *name)
|
||||
{
|
||||
int offset_x, offset_y;
|
||||
EffectData *effect_data;
|
||||
|
|
@ -92,7 +92,7 @@ Effect *effect_new (Sprite *sprite, const char *name)
|
|||
Image *image;
|
||||
void *apply;
|
||||
|
||||
effect_data = get_effect_data (name);
|
||||
effect_data = get_effect_data(name);
|
||||
if (!effect_data)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -105,7 +105,7 @@ Effect *effect_new (Sprite *sprite, const char *name)
|
|||
if (!apply)
|
||||
return NULL;
|
||||
|
||||
effect = jnew (Effect, 1);
|
||||
effect = jnew(Effect, 1);
|
||||
if (!effect)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -120,12 +120,12 @@ Effect *effect_new (Sprite *sprite, const char *name)
|
|||
effect->mask_address = NULL;
|
||||
effect->apply = apply;
|
||||
|
||||
effect_load_target (effect);
|
||||
effect_load_target(effect);
|
||||
|
||||
image = GetImage2 (sprite, &offset_x, &offset_y, NULL);
|
||||
image = GetImage2(sprite, &offset_x, &offset_y, NULL);
|
||||
if (image) {
|
||||
if (!effect_init (effect, image, offset_x, offset_y)) {
|
||||
effect_free (effect);
|
||||
if (!effect_init(effect, image, offset_x, offset_y)) {
|
||||
effect_free(effect);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -133,28 +133,28 @@ Effect *effect_new (Sprite *sprite, const char *name)
|
|||
return effect;
|
||||
}
|
||||
|
||||
void effect_free (Effect *effect)
|
||||
void effect_free(Effect *effect)
|
||||
{
|
||||
if (effect->preview_mask)
|
||||
mask_free (effect->preview_mask);
|
||||
mask_free(effect->preview_mask);
|
||||
|
||||
if (effect->dst)
|
||||
image_free (effect->dst);
|
||||
image_free(effect->dst);
|
||||
|
||||
jfree (effect);
|
||||
jfree(effect);
|
||||
}
|
||||
|
||||
void effect_load_target (Effect *effect)
|
||||
void effect_load_target(Effect *effect)
|
||||
{
|
||||
effect->target.r = get_config_bool ("Target", "Red", TRUE);
|
||||
effect->target.g = get_config_bool ("Target", "Green", TRUE);
|
||||
effect->target.b = get_config_bool ("Target", "Blue", TRUE);
|
||||
effect->target.k = get_config_bool ("Target", "Gray", TRUE);
|
||||
effect->target.a = get_config_bool ("Target", "Alpha", FALSE);
|
||||
effect->target.index = get_config_bool ("Target", "Index", FALSE);
|
||||
effect->target.r = get_config_bool("Target", "Red", TRUE);
|
||||
effect->target.g = get_config_bool("Target", "Green", TRUE);
|
||||
effect->target.b = get_config_bool("Target", "Blue", TRUE);
|
||||
effect->target.k = get_config_bool("Target", "Gray", TRUE);
|
||||
effect->target.a = get_config_bool("Target", "Alpha", FALSE);
|
||||
effect->target.index = get_config_bool("Target", "Index", FALSE);
|
||||
}
|
||||
|
||||
void effect_set_target (Effect *effect, bool r, bool g, bool b, bool k, bool a, bool index)
|
||||
void effect_set_target(Effect *effect, bool r, bool g, bool b, bool k, bool a, bool index)
|
||||
{
|
||||
effect->target.r = r;
|
||||
effect->target.g = g;
|
||||
|
|
@ -164,43 +164,43 @@ void effect_set_target (Effect *effect, bool r, bool g, bool b, bool k, bool a,
|
|||
effect->target.index = index;
|
||||
}
|
||||
|
||||
void effect_set_target_rgb (Effect *effect, bool r, bool g, bool b, bool a)
|
||||
void effect_set_target_rgb(Effect *effect, bool r, bool g, bool b, bool a)
|
||||
{
|
||||
effect_set_target (effect, r, g, b, FALSE, a, FALSE);
|
||||
effect_set_target(effect, r, g, b, FALSE, a, FALSE);
|
||||
}
|
||||
|
||||
void effect_set_target_grayscale (Effect *effect, bool k, bool a)
|
||||
void effect_set_target_grayscale(Effect *effect, bool k, bool a)
|
||||
{
|
||||
effect_set_target (effect, FALSE, FALSE, FALSE, k, a, FALSE);
|
||||
effect_set_target(effect, FALSE, FALSE, FALSE, k, a, FALSE);
|
||||
}
|
||||
|
||||
void effect_set_target_indexed (Effect *effect, bool r, bool g, bool b, bool index)
|
||||
void effect_set_target_indexed(Effect *effect, bool r, bool g, bool b, bool index)
|
||||
{
|
||||
effect_set_target (effect, r, g, b, FALSE, FALSE, index);
|
||||
effect_set_target(effect, r, g, b, FALSE, FALSE, index);
|
||||
}
|
||||
|
||||
void effect_begin (Effect *effect)
|
||||
void effect_begin(Effect *effect)
|
||||
{
|
||||
effect->row = 0;
|
||||
effect->mask = effect->sprite->mask;
|
||||
|
||||
effect_update_mask (effect, effect->mask, effect->src);
|
||||
effect_update_mask(effect, effect->mask, effect->src);
|
||||
}
|
||||
|
||||
void effect_begin_for_preview (Effect *effect)
|
||||
void effect_begin_for_preview(Effect *effect)
|
||||
{
|
||||
if (effect->preview_mask) {
|
||||
mask_free (effect->preview_mask);
|
||||
mask_free(effect->preview_mask);
|
||||
effect->preview_mask = NULL;
|
||||
}
|
||||
|
||||
if ((effect->sprite->mask) && (effect->sprite->mask->bitmap))
|
||||
effect->preview_mask = mask_new_copy (effect->sprite->mask);
|
||||
effect->preview_mask = mask_new_copy(effect->sprite->mask);
|
||||
else {
|
||||
effect->preview_mask = mask_new ();
|
||||
mask_replace (effect->preview_mask,
|
||||
effect->offset_x, effect->offset_y,
|
||||
effect->src->w, effect->src->h);
|
||||
effect->preview_mask = mask_new();
|
||||
mask_replace(effect->preview_mask,
|
||||
effect->offset_x, effect->offset_y,
|
||||
effect->src->w, effect->src->h);
|
||||
}
|
||||
|
||||
effect->row = 0;
|
||||
|
|
@ -208,14 +208,14 @@ void effect_begin_for_preview (Effect *effect)
|
|||
|
||||
{
|
||||
JWidget editor = current_editor;
|
||||
JRect vp = jview_get_viewport_position (jwidget_get_view (editor));
|
||||
JRect vp = jview_get_viewport_position(jwidget_get_view(editor));
|
||||
int x1, y1, x2, y2;
|
||||
int x, y, w, h;
|
||||
|
||||
screen_to_editor (editor, vp->x1, vp->y1, &x1, &y1);
|
||||
screen_to_editor (editor, vp->x2-1, vp->y2-1, &x2, &y2);
|
||||
screen_to_editor(editor, vp->x1, vp->y1, &x1, &y1);
|
||||
screen_to_editor(editor, vp->x2-1, vp->y2-1, &x2, &y2);
|
||||
|
||||
jrect_free (vp);
|
||||
jrect_free(vp);
|
||||
|
||||
if (x1 < 0) x1 = 0;
|
||||
if (y1 < 0) y1 = 0;
|
||||
|
|
@ -228,17 +228,17 @@ void effect_begin_for_preview (Effect *effect)
|
|||
h = y2 - y1 + 1;
|
||||
|
||||
if ((w < 1) || (h < 1)) {
|
||||
mask_free (effect->preview_mask);
|
||||
mask_free(effect->preview_mask);
|
||||
effect->preview_mask = NULL;
|
||||
effect->row = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
mask_intersect (effect->preview_mask, x, y, w, h);
|
||||
mask_intersect(effect->preview_mask, x, y, w, h);
|
||||
}
|
||||
|
||||
if (!effect_update_mask (effect, effect->mask, effect->src)) {
|
||||
mask_free (effect->preview_mask);
|
||||
if (!effect_update_mask(effect, effect->mask, effect->src)) {
|
||||
mask_free(effect->preview_mask);
|
||||
effect->preview_mask = NULL;
|
||||
effect->row = -1;
|
||||
return;
|
||||
|
|
@ -249,7 +249,7 @@ bool effect_apply_step(Effect *effect)
|
|||
{
|
||||
if ((effect->row >= 0) && (effect->row < effect->h)) {
|
||||
if ((effect->mask) && (effect->mask->bitmap)) {
|
||||
effect->d = div (effect->x-effect->mask->x+effect->offset_x, 8);
|
||||
effect->d = div(effect->x-effect->mask->x+effect->offset_x, 8);
|
||||
effect->mask_address =
|
||||
((ase_uint8 **)effect->mask->bitmap->line)
|
||||
[effect->row+effect->y-effect->mask->y+effect->offset_y]+effect->d.quot;
|
||||
|
|
@ -257,7 +257,7 @@ bool effect_apply_step(Effect *effect)
|
|||
else
|
||||
effect->mask_address = NULL;
|
||||
|
||||
(*effect->apply) (effect);
|
||||
(*effect->apply)(effect);
|
||||
effect->row++;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -340,33 +340,33 @@ void effect_apply_to_target(Effect *effect)
|
|||
if (images > 1) {
|
||||
/* open undo */
|
||||
if (undo_is_enabled (effect->sprite->undo))
|
||||
undo_open (effect->sprite->undo);
|
||||
undo_open(effect->sprite->undo);
|
||||
}
|
||||
|
||||
add_progress (images);
|
||||
add_progress(images);
|
||||
for (n=n2=0; n<stock->nimage; n++) {
|
||||
if (!stock->image[n])
|
||||
continue;
|
||||
|
||||
do_progress (n2++);
|
||||
effect_apply_to_image (effect, stock->image[n], x[n], y[n]);
|
||||
do_progress(n2++);
|
||||
effect_apply_to_image(effect, stock->image[n], x[n], y[n]);
|
||||
}
|
||||
del_progress ();
|
||||
del_progress();
|
||||
|
||||
if (images > 1) {
|
||||
/* close */
|
||||
if (undo_is_enabled (effect->sprite->undo))
|
||||
undo_close (effect->sprite->undo);
|
||||
undo_close(effect->sprite->undo);
|
||||
}
|
||||
|
||||
jfree (x);
|
||||
jfree (y);
|
||||
jfree(x);
|
||||
jfree(y);
|
||||
}
|
||||
|
||||
stock_free (stock);
|
||||
stock_free(stock);
|
||||
}
|
||||
|
||||
static EffectData *get_effect_data (const char *name)
|
||||
static EffectData *get_effect_data(const char *name)
|
||||
{
|
||||
int c;
|
||||
|
||||
|
|
@ -378,7 +378,7 @@ static EffectData *get_effect_data (const char *name)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static int effect_init (Effect *effect, Image *image, int offset_x, int offset_y)
|
||||
static int effect_init(Effect *effect, Image *image, int offset_x, int offset_y)
|
||||
{
|
||||
effect->offset_x = offset_x;
|
||||
effect->offset_y = offset_y;
|
||||
|
|
@ -387,17 +387,17 @@ static int effect_init (Effect *effect, Image *image, int offset_x, int offset_y
|
|||
return FALSE;
|
||||
|
||||
if (effect->preview_mask) {
|
||||
mask_free (effect->preview_mask);
|
||||
mask_free(effect->preview_mask);
|
||||
effect->preview_mask = NULL;
|
||||
}
|
||||
|
||||
if (effect->dst) {
|
||||
image_free (effect->dst);
|
||||
image_free(effect->dst);
|
||||
effect->dst = NULL;
|
||||
}
|
||||
|
||||
effect->src = image;
|
||||
effect->dst = image_crop (image, 0, 0, image->w, image->h);
|
||||
effect->dst = image_crop(image, 0, 0, image->w, image->h);
|
||||
effect->row = -1;
|
||||
effect->mask = NULL;
|
||||
effect->preview_mask = NULL;
|
||||
|
|
@ -406,7 +406,7 @@ static int effect_init (Effect *effect, Image *image, int offset_x, int offset_y
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static int effect_update_mask (Effect *effect, Mask *mask, Image *image)
|
||||
static int effect_update_mask(Effect *effect, Mask *mask, Image *image)
|
||||
{
|
||||
int x, y, w, h;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -26,8 +26,8 @@ struct Image;
|
|||
struct Mask;
|
||||
struct Sprite;
|
||||
|
||||
int init_module_effect (void);
|
||||
void exit_module_effect (void);
|
||||
int init_module_effect(void);
|
||||
void exit_module_effect(void);
|
||||
|
||||
typedef struct Effect
|
||||
{
|
||||
|
|
@ -40,7 +40,7 @@ typedef struct Effect
|
|||
struct Mask *preview_mask;
|
||||
unsigned char *mask_address;
|
||||
div_t d;
|
||||
void (*apply) (struct Effect *effect);
|
||||
void (*apply)(struct Effect *effect);
|
||||
struct {
|
||||
int r:1, g:1, b:1;
|
||||
int k:1;
|
||||
|
|
@ -49,24 +49,24 @@ typedef struct Effect
|
|||
} target;
|
||||
} Effect;
|
||||
|
||||
Effect *effect_new (struct Sprite *sprite, const char *name);
|
||||
void effect_free (Effect *effect);
|
||||
Effect *effect_new(struct Sprite *sprite, const char *name);
|
||||
void effect_free(Effect *effect);
|
||||
|
||||
void effect_load_target (Effect *effect);
|
||||
void effect_set_target (Effect *effect, bool r, bool g, bool b, bool k, bool a, bool index);
|
||||
void effect_set_target_rgb (Effect *effect, bool r, bool g, bool b, bool a);
|
||||
void effect_set_target_grayscale (Effect *effect, bool k, bool a);
|
||||
void effect_set_target_indexed (Effect *effect, bool r, bool g, bool b, bool index);
|
||||
void effect_load_target(Effect *effect);
|
||||
void effect_set_target(Effect *effect, bool r, bool g, bool b, bool k, bool a, bool index);
|
||||
void effect_set_target_rgb(Effect *effect, bool r, bool g, bool b, bool a);
|
||||
void effect_set_target_grayscale(Effect *effect, bool k, bool a);
|
||||
void effect_set_target_indexed(Effect *effect, bool r, bool g, bool b, bool index);
|
||||
|
||||
void effect_begin (Effect *effect);
|
||||
void effect_begin_for_preview (Effect *effect);
|
||||
bool effect_apply_step (Effect *effect);
|
||||
void effect_begin(Effect *effect);
|
||||
void effect_begin_for_preview(Effect *effect);
|
||||
bool effect_apply_step(Effect *effect);
|
||||
|
||||
void effect_apply (Effect *effect);
|
||||
void effect_flush (Effect *effect);
|
||||
void effect_apply(Effect *effect);
|
||||
void effect_flush(Effect *effect);
|
||||
|
||||
void effect_apply_to_image (Effect *effect, struct Image *image, int x, int y);
|
||||
void effect_apply_to_target (Effect *effect);
|
||||
void effect_apply_to_image(Effect *effect, struct Image *image, int x, int y);
|
||||
void effect_apply_to_target(Effect *effect);
|
||||
|
||||
/* macro to get contiguos pixels from an image */
|
||||
#define GET_MATRIX_DATA(ptr_type, width, height, cx, cy, do_job) \
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -40,26 +40,26 @@ void apply_invert_color4(Effect *effect)
|
|||
if (!((*effect->mask_address) & (1<<effect->d.rem))) {
|
||||
src_address++;
|
||||
dst_address++;
|
||||
_image_bitmap_next_bit (effect->d, effect->mask_address);
|
||||
_image_bitmap_next_bit(effect->d, effect->mask_address);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
_image_bitmap_next_bit (effect->d, effect->mask_address);
|
||||
_image_bitmap_next_bit(effect->d, effect->mask_address);
|
||||
}
|
||||
|
||||
c = *(src_address++);
|
||||
|
||||
r = _rgba_getr (c);
|
||||
g = _rgba_getg (c);
|
||||
b = _rgba_getb (c);
|
||||
a = _rgba_geta (c);
|
||||
r = _rgba_getr(c);
|
||||
g = _rgba_getg(c);
|
||||
b = _rgba_getb(c);
|
||||
a = _rgba_geta(c);
|
||||
|
||||
if (effect->target.r) r ^= 0xff;
|
||||
if (effect->target.g) g ^= 0xff;
|
||||
if (effect->target.b) b ^= 0xff;
|
||||
if (effect->target.a) a ^= 0xff;
|
||||
|
||||
*(dst_address++) = _rgba (r, g, b, a);
|
||||
*(dst_address++) = _rgba(r, g, b, a);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -77,22 +77,22 @@ void apply_invert_color2(Effect *effect)
|
|||
if (!((*effect->mask_address) & (1<<effect->d.rem))) {
|
||||
src_address++;
|
||||
dst_address++;
|
||||
_image_bitmap_next_bit (effect->d, effect->mask_address);
|
||||
_image_bitmap_next_bit(effect->d, effect->mask_address);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
_image_bitmap_next_bit (effect->d, effect->mask_address);
|
||||
_image_bitmap_next_bit(effect->d, effect->mask_address);
|
||||
}
|
||||
|
||||
c = *(src_address++);
|
||||
|
||||
k = _graya_getk (c);
|
||||
a = _graya_geta (c);
|
||||
k = _graya_getk(c);
|
||||
a = _graya_geta(c);
|
||||
|
||||
if (effect->target.k) k ^= 0xff;
|
||||
if (effect->target.a) a ^= 0xff;
|
||||
|
||||
*(dst_address++) = _graya (k, a);
|
||||
*(dst_address++) = _graya(k, a);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -40,22 +40,22 @@ void set_median_size(int w, int h)
|
|||
{
|
||||
int c;
|
||||
|
||||
data.tiled = get_tiled_mode ();
|
||||
data.tiled = get_tiled_mode();
|
||||
data.w = w;
|
||||
data.h = h;
|
||||
data.ncolors = w*h;
|
||||
|
||||
for (c=0; c<4; c++) {
|
||||
if (data.channel[c])
|
||||
jfree (data.channel[c]);
|
||||
jfree(data.channel[c]);
|
||||
|
||||
data.channel[c] = jmalloc(sizeof(unsigned char) * data.ncolors);
|
||||
}
|
||||
}
|
||||
|
||||
static int cmp_channel (const void *p1, const void *p2)
|
||||
static int cmp_channel(const void *p1, const void *p2)
|
||||
{
|
||||
return (*(unsigned char *)p2) - (*(unsigned char *)p1);
|
||||
return (*(unsigned char *)p2) -(*(unsigned char *)p1);
|
||||
}
|
||||
|
||||
void apply_median4(Effect *effect)
|
||||
|
|
@ -77,11 +77,11 @@ void apply_median4(Effect *effect)
|
|||
if (effect->mask_address) {
|
||||
if (!((*effect->mask_address) & (1<<effect->d.rem))) {
|
||||
dst_address++;
|
||||
_image_bitmap_next_bit (effect->d, effect->mask_address);
|
||||
_image_bitmap_next_bit(effect->d, effect->mask_address);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
_image_bitmap_next_bit (effect->d, effect->mask_address);
|
||||
_image_bitmap_next_bit(effect->d, effect->mask_address);
|
||||
}
|
||||
|
||||
c = 0;
|
||||
|
|
@ -89,39 +89,39 @@ void apply_median4(Effect *effect)
|
|||
GET_MATRIX_DATA
|
||||
(ase_uint32, data.w, data.h, data.w/2, data.h/2,
|
||||
color = *src_address;
|
||||
data.channel[0][c] = _rgba_getr (color);
|
||||
data.channel[1][c] = _rgba_getg (color);
|
||||
data.channel[2][c] = _rgba_getb (color);
|
||||
data.channel[3][c] = _rgba_geta (color);
|
||||
data.channel[0][c] = _rgba_getr(color);
|
||||
data.channel[1][c] = _rgba_getg(color);
|
||||
data.channel[2][c] = _rgba_getb(color);
|
||||
data.channel[3][c] = _rgba_geta(color);
|
||||
c++;
|
||||
);
|
||||
|
||||
for (c=0; c<4; c++)
|
||||
qsort (data.channel[c], data.ncolors, sizeof (unsigned char), cmp_channel);
|
||||
qsort(data.channel[c], data.ncolors, sizeof(unsigned char), cmp_channel);
|
||||
|
||||
color = src->method->getpixel (src, x, y);
|
||||
color = src->method->getpixel(src, x, y);
|
||||
|
||||
if (effect->target.r)
|
||||
r = data.channel[0][data.ncolors/2];
|
||||
else
|
||||
r = _rgba_getr (color);
|
||||
r = _rgba_getr(color);
|
||||
|
||||
if (effect->target.g)
|
||||
g = data.channel[1][data.ncolors/2];
|
||||
else
|
||||
g = _rgba_getg (color);
|
||||
g = _rgba_getg(color);
|
||||
|
||||
if (effect->target.b)
|
||||
b = data.channel[2][data.ncolors/2];
|
||||
else
|
||||
b = _rgba_getb (color);
|
||||
b = _rgba_getb(color);
|
||||
|
||||
if (effect->target.a)
|
||||
a = data.channel[3][data.ncolors/2];
|
||||
else
|
||||
a = _rgba_geta (color);
|
||||
a = _rgba_geta(color);
|
||||
|
||||
*(dst_address++) = _rgba (r, g, b, a);
|
||||
*(dst_address++) = _rgba(r, g, b, a);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -144,11 +144,11 @@ void apply_median2(Effect *effect)
|
|||
if (effect->mask_address) {
|
||||
if (!((*effect->mask_address) & (1<<effect->d.rem))) {
|
||||
dst_address++;
|
||||
_image_bitmap_next_bit (effect->d, effect->mask_address);
|
||||
_image_bitmap_next_bit(effect->d, effect->mask_address);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
_image_bitmap_next_bit (effect->d, effect->mask_address);
|
||||
_image_bitmap_next_bit(effect->d, effect->mask_address);
|
||||
}
|
||||
|
||||
c = 0;
|
||||
|
|
@ -162,21 +162,21 @@ void apply_median2(Effect *effect)
|
|||
);
|
||||
|
||||
for (c=0; c<2; c++)
|
||||
qsort (data.channel[c], data.ncolors, sizeof (unsigned char), cmp_channel);
|
||||
qsort(data.channel[c], data.ncolors, sizeof(unsigned char), cmp_channel);
|
||||
|
||||
color = src->method->getpixel (src, x, y);
|
||||
color = src->method->getpixel(src, x, y);
|
||||
|
||||
if (effect->target.k)
|
||||
k = data.channel[0][data.ncolors/2];
|
||||
else
|
||||
k = _graya_getk (color);
|
||||
k = _graya_getk(color);
|
||||
|
||||
if (effect->target.a)
|
||||
a = data.channel[1][data.ncolors/2];
|
||||
else
|
||||
a = _graya_geta (color);
|
||||
a = _graya_geta(color);
|
||||
|
||||
*(dst_address++) = _graya (k, a);
|
||||
*(dst_address++) = _graya(k, a);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -199,11 +199,11 @@ void apply_median1(Effect *effect)
|
|||
if (effect->mask_address) {
|
||||
if (!((*effect->mask_address) & (1<<effect->d.rem))) {
|
||||
dst_address++;
|
||||
_image_bitmap_next_bit (effect->d, effect->mask_address);
|
||||
_image_bitmap_next_bit(effect->d, effect->mask_address);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
_image_bitmap_next_bit (effect->d, effect->mask_address);
|
||||
_image_bitmap_next_bit(effect->d, effect->mask_address);
|
||||
}
|
||||
|
||||
c = 0;
|
||||
|
|
@ -226,14 +226,14 @@ void apply_median1(Effect *effect)
|
|||
qsort(data.channel[0], data.ncolors, sizeof(unsigned char), cmp_channel);
|
||||
else {
|
||||
for (c=0; c<3; c++)
|
||||
qsort (data.channel[c], data.ncolors, sizeof(unsigned char), cmp_channel);
|
||||
qsort(data.channel[c], data.ncolors, sizeof(unsigned char), cmp_channel);
|
||||
}
|
||||
|
||||
if (effect->target.index) {
|
||||
*(dst_address++) = data.channel[0][data.ncolors/2];
|
||||
}
|
||||
else {
|
||||
color = src->method->getpixel (src, x, y);
|
||||
color = src->method->getpixel(src, x, y);
|
||||
|
||||
if (effect->target.r)
|
||||
r = data.channel[0][data.ncolors/2];
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef EFFECT_MEDIAN_H
|
||||
#define EFFECT_MEDIAN_H
|
||||
|
||||
void set_median_size (int w, int h);
|
||||
void set_median_size(int w, int h);
|
||||
|
||||
void apply_median4 (struct Effect *effect);
|
||||
void apply_median2 (struct Effect *effect);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -31,11 +31,11 @@ static struct {
|
|||
int fuzziness;
|
||||
} data;
|
||||
|
||||
void set_replace_colors (int from, int to, int fuzziness)
|
||||
void set_replace_colors(int from, int to, int fuzziness)
|
||||
{
|
||||
data.from = from;
|
||||
data.to = to;
|
||||
data.fuzziness = MID (0, fuzziness, 255);
|
||||
data.fuzziness = MID(0, fuzziness, 255);
|
||||
}
|
||||
|
||||
void apply_replace_color4(Effect *effect)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -21,10 +21,10 @@
|
|||
|
||||
struct Effect;
|
||||
|
||||
void set_replace_colors (int from, int to, int fuzziness);
|
||||
void set_replace_colors(int from, int to, int fuzziness);
|
||||
|
||||
void apply_replace_color4 (struct Effect *effect);
|
||||
void apply_replace_color2 (struct Effect *effect);
|
||||
void apply_replace_color1 (struct Effect *effect);
|
||||
void apply_replace_color4(struct Effect *effect);
|
||||
void apply_replace_color2(struct Effect *effect);
|
||||
void apply_replace_color1(struct Effect *effect);
|
||||
|
||||
#endif /* EFFECT_REPLCOL_H */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -434,7 +434,7 @@ static void ase_file_prepare_header(FILE *f, ASE_Header *header, Sprite *sprite)
|
|||
|
||||
static void ase_file_write_header(FILE *f, ASE_Header *header)
|
||||
{
|
||||
header->size = ftell (f)-header->pos;
|
||||
header->size = ftell(f)-header->pos;
|
||||
|
||||
fseek(f, header->pos, SEEK_SET);
|
||||
|
||||
|
|
@ -706,8 +706,8 @@ static void ase_file_write_layer_chunk(FILE *f, Layer *layer)
|
|||
fputw((layer->readable & 1) | ((layer->writable & 1) << 1), f);
|
||||
|
||||
/* layer type */
|
||||
fputw(layer_is_image (layer) ? 0:
|
||||
layer_is_set (layer) ? 1: -1, f);
|
||||
fputw(layer_is_image(layer) ? 0:
|
||||
layer_is_set(layer) ? 1: -1, f);
|
||||
|
||||
/* layer child level */
|
||||
child_level = -1;
|
||||
|
|
@ -721,7 +721,7 @@ static void ase_file_write_layer_chunk(FILE *f, Layer *layer)
|
|||
/* width, height and blend mode */
|
||||
fputw(0, f);
|
||||
fputw(0, f);
|
||||
fputw(layer_is_image (layer) ? layer->blend_mode: 0, f);
|
||||
fputw(layer_is_image(layer) ? layer->blend_mode: 0, f);
|
||||
|
||||
/* padding */
|
||||
ase_file_write_padding(f, 4);
|
||||
|
|
@ -731,7 +731,7 @@ static void ase_file_write_layer_chunk(FILE *f, Layer *layer)
|
|||
|
||||
ase_file_write_close_chunk(f);
|
||||
|
||||
/* console_printf ("Layer name \"%s\" child level: %d\n", layer->name, child_level); */
|
||||
/* console_printf("Layer name \"%s\" child level: %d\n", layer->name, child_level); */
|
||||
}
|
||||
|
||||
static Cel *ase_file_read_cel_chunk(FILE *f, Sprite *sprite, int frpos, int imgtype)
|
||||
|
|
@ -753,7 +753,7 @@ static Cel *ase_file_read_cel_chunk(FILE *f, Sprite *sprite, int frpos, int imgt
|
|||
frpos, layer_index);
|
||||
return NULL;
|
||||
}
|
||||
/* console_printf ("Layer found: %d -> %s\n", layer_index, layer->name); */
|
||||
/* console_printf("Layer found: %d -> %s\n", layer_index, layer->name); */
|
||||
|
||||
/* create the new frame */
|
||||
cel = cel_new(frpos, 0);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -23,12 +23,12 @@
|
|||
|
||||
struct Sprite;
|
||||
|
||||
struct Sprite *ase_file_read_f (FILE *f);
|
||||
int ase_file_write_f (FILE *f, struct Sprite *sprite);
|
||||
struct Sprite *ase_file_read_f(FILE *f);
|
||||
int ase_file_write_f(FILE *f, struct Sprite *sprite);
|
||||
|
||||
int fgetw (FILE *file);
|
||||
long fgetl (FILE *file);
|
||||
int fputw (int w, FILE *file);
|
||||
int fputl (long l, FILE *file);
|
||||
int fgetw(FILE *file);
|
||||
long fgetl(FILE *file);
|
||||
int fputw(int w, FILE *file);
|
||||
int fputl(long l, FILE *file);
|
||||
|
||||
#endif /* FILE_ASE_H */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -196,7 +196,7 @@ static void read_1bit_line(int length, PACKFILE *f, Image *image, int line)
|
|||
}
|
||||
}
|
||||
pix = b[j];
|
||||
image_putpixel (image, i, line, pix);
|
||||
image_putpixel(image, i, line, pix);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -224,7 +224,7 @@ static void read_4bit_line(int length, PACKFILE *f, Image *image, int line)
|
|||
}
|
||||
}
|
||||
pix = b[j];
|
||||
image_putpixel (image, i, line, pix);
|
||||
image_putpixel(image, i, line, pix);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -248,7 +248,7 @@ static void read_8bit_line(int length, PACKFILE *f, Image *image, int line)
|
|||
}
|
||||
}
|
||||
pix = b[j];
|
||||
image_putpixel (image, i, line, pix);
|
||||
image_putpixel(image, i, line, pix);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -267,7 +267,7 @@ static void read_24bit_line(int length, PACKFILE *f, Image *image, int line)
|
|||
c.b = pack_getc(f);
|
||||
c.g = pack_getc(f);
|
||||
c.r = pack_getc(f);
|
||||
image_putpixel (image, i, line, _rgba (c.r, c.g, c.b, 255));
|
||||
image_putpixel(image, i, line, _rgba(c.r, c.g, c.b, 255));
|
||||
nbytes += 3;
|
||||
}
|
||||
|
||||
|
|
@ -333,7 +333,7 @@ static void read_RLE8_compressed_image(PACKFILE *f, Image *image, AL_CONST BITMA
|
|||
|
||||
if (count > 0) { /* repeat pixel count times */
|
||||
for (j=0;j<count;j++) {
|
||||
image_putpixel (image, pos, line, val);
|
||||
image_putpixel(image, pos, line, val);
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
|
|
@ -358,7 +358,7 @@ static void read_RLE8_compressed_image(PACKFILE *f, Image *image, AL_CONST BITMA
|
|||
default: /* read in absolute mode */
|
||||
for (j=0; j<val; j++) {
|
||||
val0 = pack_getc(f);
|
||||
image_putpixel (image, pos, line, val0);
|
||||
image_putpixel(image, pos, line, val0);
|
||||
pos++;
|
||||
}
|
||||
|
||||
|
|
@ -405,7 +405,7 @@ static void read_RLE4_compressed_image(PACKFILE *f, Image *image, AL_CONST BITMA
|
|||
b[1] = val & 15;
|
||||
b[0] = (val >> 4) & 15;
|
||||
for (j=0; j<count; j++) {
|
||||
image_putpixel (image, pos, line, b[j%2]);
|
||||
image_putpixel(image, pos, line, b[j%2]);
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
|
|
@ -438,7 +438,7 @@ static void read_RLE4_compressed_image(PACKFILE *f, Image *image, AL_CONST BITMA
|
|||
val0 = val0 >> 4;
|
||||
}
|
||||
}
|
||||
image_putpixel (image, pos, line, b[j%4]);
|
||||
image_putpixel(image, pos, line, b[j%4]);
|
||||
pos++;
|
||||
}
|
||||
break;
|
||||
|
|
@ -469,33 +469,33 @@ static void read_bitfields_image(PACKFILE *f, Image *image, int bpp, BITMAPINFOH
|
|||
|
||||
for (i=0; i<(int)infoheader->biHeight; i++) {
|
||||
for (k=0; k<(int)infoheader->biWidth; k++) {
|
||||
pack_fread (&buffer, bytesPerPixel, f);
|
||||
pack_fread(&buffer, bytesPerPixel, f);
|
||||
|
||||
if (bpp == 15) {
|
||||
red = (buffer >> 10) & 0x1f;
|
||||
grn = (buffer >> 5) & 0x1f;
|
||||
blu = (buffer) & 0x1f;
|
||||
buffer = _rgba (_rgb_scale_5[red],
|
||||
_rgb_scale_5[grn],
|
||||
_rgb_scale_5[blu], 255);
|
||||
buffer = _rgba(_rgb_scale_5[red],
|
||||
_rgb_scale_5[grn],
|
||||
_rgb_scale_5[blu], 255);
|
||||
}
|
||||
else if (bpp == 16) {
|
||||
red = (buffer >> 11) & 0x1f;
|
||||
grn = (buffer >> 5) & 0x3f;
|
||||
blu = (buffer) & 0x1f;
|
||||
buffer = _rgba (_rgb_scale_5[red],
|
||||
_rgb_scale_6[grn],
|
||||
_rgb_scale_5[blu], 255);
|
||||
buffer = _rgba(_rgb_scale_5[red],
|
||||
_rgb_scale_6[grn],
|
||||
_rgb_scale_5[blu], 255);
|
||||
}
|
||||
else {
|
||||
red = (buffer >> 16) & 0xff;
|
||||
grn = (buffer >> 8) & 0xff;
|
||||
blu = (buffer) & 0xff;
|
||||
buffer = _rgba (red, grn, blu, 255);
|
||||
buffer = _rgba(red, grn, blu, 255);
|
||||
}
|
||||
|
||||
image->method->putpixel (image,
|
||||
k, (infoheader->biHeight - i) - 1, buffer);
|
||||
image->method->putpixel(image,
|
||||
k, (infoheader->biHeight - i) - 1, buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -560,9 +560,9 @@ static Sprite *load_BMP(const char *filename)
|
|||
if (infoheader.biCompression == BI_BITFIELDS) {
|
||||
unsigned long redMask, bluMask;
|
||||
|
||||
redMask = pack_igetl (f);
|
||||
pack_igetl (f);
|
||||
bluMask = pack_igetl (f);
|
||||
redMask = pack_igetl(f);
|
||||
pack_igetl(f);
|
||||
bluMask = pack_igetl(f);
|
||||
|
||||
if ((bluMask == 0x001f) && (redMask == 0x7C00))
|
||||
bpp = 15;
|
||||
|
|
@ -572,42 +572,42 @@ static Sprite *load_BMP(const char *filename)
|
|||
bpp = 32;
|
||||
else {
|
||||
/* Unrecognised bit masks/depth */
|
||||
pack_fclose (f);
|
||||
pack_fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
image = file_sequence_image (type,
|
||||
infoheader.biWidth,
|
||||
infoheader.biHeight);
|
||||
image = file_sequence_image(type,
|
||||
infoheader.biWidth,
|
||||
infoheader.biHeight);
|
||||
if (!image) {
|
||||
pack_fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (type == IMAGE_RGB)
|
||||
image_clear (image, _rgba (0, 0, 0, 255));
|
||||
image_clear(image, _rgba(0, 0, 0, 255));
|
||||
else
|
||||
image_clear (image, 0);
|
||||
image_clear(image, 0);
|
||||
|
||||
sprite = file_sequence_sprite ();
|
||||
sprite = file_sequence_sprite();
|
||||
|
||||
switch (infoheader.biCompression) {
|
||||
|
||||
case BI_RGB:
|
||||
read_image (f, image, &infoheader);
|
||||
read_image(f, image, &infoheader);
|
||||
break;
|
||||
|
||||
case BI_RLE8:
|
||||
read_RLE8_compressed_image (f, image, &infoheader);
|
||||
read_RLE8_compressed_image(f, image, &infoheader);
|
||||
break;
|
||||
|
||||
case BI_RLE4:
|
||||
read_RLE4_compressed_image (f, image, &infoheader);
|
||||
read_RLE4_compressed_image(f, image, &infoheader);
|
||||
break;
|
||||
|
||||
case BI_BITFIELDS:
|
||||
read_bitfields_image (f, image, bpp, &infoheader);
|
||||
read_bitfields_image(f, image, bpp, &infoheader);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -639,13 +639,13 @@ static int save_BMP(Sprite *sprite)
|
|||
bfSize = 54 + biSizeImage; /* header + image data */
|
||||
}
|
||||
|
||||
f = pack_fopen (sprite->filename, F_WRITE);
|
||||
f = pack_fopen(sprite->filename, F_WRITE);
|
||||
if (!f) {
|
||||
console_printf (_("Error creating file.\n"));
|
||||
console_printf(_("Error creating file.\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
image = file_sequence_image_to_save ();
|
||||
image = file_sequence_image_to_save();
|
||||
|
||||
*allegro_errno = 0;
|
||||
|
||||
|
|
@ -685,8 +685,8 @@ static int save_BMP(Sprite *sprite)
|
|||
}
|
||||
}
|
||||
else {
|
||||
pack_iputl (0, f); /* biClrUsed */
|
||||
pack_iputl (0, f); /* biClrImportant */
|
||||
pack_iputl(0, f); /* biClrUsed */
|
||||
pack_iputl(0, f); /* biClrImportant */
|
||||
}
|
||||
|
||||
/* image data */
|
||||
|
|
@ -707,16 +707,16 @@ static int save_BMP(Sprite *sprite)
|
|||
}
|
||||
|
||||
for (j=0; j<filler; j++)
|
||||
pack_putc (0, f);
|
||||
pack_putc(0, f);
|
||||
|
||||
if (image->h > 1)
|
||||
do_progress (100 * (image->h-1-i) / (image->h-1));
|
||||
do_progress(100 * (image->h-1-i) / (image->h-1));
|
||||
}
|
||||
|
||||
pack_fclose (f);
|
||||
pack_fclose(f);
|
||||
|
||||
if (*allegro_errno) {
|
||||
console_printf (_("Error writing bytes.\n"));
|
||||
console_printf(_("Error writing bytes.\n"));
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -130,11 +130,11 @@ Image *file_sequence_image(int imgtype, int w, int h)
|
|||
/* create a bitmap */
|
||||
|
||||
if (file_sequence.last_cel) {
|
||||
console_printf(_("Error: called two times \"file_sequence_image ()\".\n"));
|
||||
console_printf(_("Error: called two times \"file_sequence_image()\".\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
image = image_new (imgtype, w, h);
|
||||
image = image_new(imgtype, w, h);
|
||||
if (!image) {
|
||||
console_printf(_("Not enough memory to allocate a bitmap.\n"));
|
||||
return NULL;
|
||||
|
|
@ -161,7 +161,7 @@ const char *get_readable_extensions(void)
|
|||
int c;
|
||||
|
||||
/* clear the string */
|
||||
ustrcpy (file_extensions, empty_string);
|
||||
ustrcpy(file_extensions, empty_string);
|
||||
|
||||
/* insert file format */
|
||||
for (c=0; formats[c]; c++) {
|
||||
|
|
@ -245,7 +245,7 @@ Sprite *sprite_load(const char *filename)
|
|||
sequence... */
|
||||
|
||||
/* per now, we want load just one file */
|
||||
jlist_append (file_names, jstrdup (filename));
|
||||
jlist_append(file_names, jstrdup(filename));
|
||||
|
||||
/* check is this could be a sequence */
|
||||
start_from = split_filename(filename, left, right, &width);
|
||||
|
|
@ -260,7 +260,7 @@ Sprite *sprite_load(const char *filename)
|
|||
break;
|
||||
|
||||
/* add this file name to the list */
|
||||
jlist_append (file_names, jstrdup (buf));
|
||||
jlist_append(file_names, jstrdup(buf));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -422,11 +422,11 @@ int sprite_save(Sprite *sprite)
|
|||
ustrcpy(extension, get_extension(sprite->filename));
|
||||
ustrlwr(extension);
|
||||
|
||||
PRINTF ("Saving sprite \"%s\" (%s)\n", sprite->filename, extension);
|
||||
PRINTF("Saving sprite \"%s\" (%s)\n", sprite->filename, extension);
|
||||
|
||||
file = get_fileformat(extension);
|
||||
if ((!file) || (!file->save)) {
|
||||
console_printf (_("Format \"%s\" isn't supported to save\n"), extension);
|
||||
console_printf(_("Format \"%s\" isn't supported to save\n"), extension);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -535,7 +535,7 @@ int sprite_save(Sprite *sprite)
|
|||
}
|
||||
|
||||
/* palette */
|
||||
/* memcpy(file_palette, sprite->palette, sizeof (PALETTE)); */
|
||||
/* memcpy(file_palette, sprite->palette, sizeof(PALETTE)); */
|
||||
|
||||
/* use the "sequence" interface */
|
||||
if (file->flags & FILE_SUPPORT_SEQUENCES) {
|
||||
|
|
@ -551,8 +551,8 @@ int sprite_save(Sprite *sprite)
|
|||
if (sprite->frames == 1) {
|
||||
/* draw all the sprite in the image */
|
||||
sprite->frame = 0;
|
||||
image_clear (image, 0);
|
||||
sprite_render (sprite, image, 0, 0);
|
||||
image_clear(image, 0);
|
||||
sprite_render(sprite, image, 0, 0);
|
||||
|
||||
/* save the temporary image */
|
||||
file_sequence.image = image;
|
||||
|
|
@ -568,7 +568,7 @@ int sprite_save(Sprite *sprite)
|
|||
char buf[256], left[256], right[256];
|
||||
int width, start_from;
|
||||
|
||||
start_from = split_filename (sprite->filename, left, right, &width);
|
||||
start_from = split_filename(sprite->filename, left, right, &width);
|
||||
if (start_from < 0) {
|
||||
start_from = 0;
|
||||
width = (sprite->frames < 10)? 1:
|
||||
|
|
@ -607,7 +607,7 @@ int sprite_save(Sprite *sprite)
|
|||
}
|
||||
|
||||
/* destroy the image */
|
||||
image_free (image);
|
||||
image_free(image);
|
||||
}
|
||||
else {
|
||||
console_printf(_("Not enough memory for the temporary bitmap.\n"));
|
||||
|
|
@ -660,23 +660,23 @@ static int split_filename(const char *filename, char *left, char *right, int *wi
|
|||
int chr, ret;
|
||||
|
||||
/* get the extension */
|
||||
ext = get_extension (filename);
|
||||
ext = get_extension(filename);
|
||||
|
||||
/* with extension */
|
||||
if ((ext) && (*ext)) {
|
||||
/* left side (the filename without the extension and without the '.') */
|
||||
ext--;
|
||||
*ext = 0;
|
||||
ustrcpy (left, filename);
|
||||
ustrcpy(left, filename);
|
||||
*ext = '.';
|
||||
|
||||
/* right side (the extension with the '.') */
|
||||
ustrcpy (right, ext);
|
||||
ustrcpy(right, ext);
|
||||
}
|
||||
/* without extension (without right side) */
|
||||
else {
|
||||
ustrcpy (left, filename);
|
||||
ustrcpy (right, empty_string);
|
||||
ustrcpy(left, filename);
|
||||
ustrcpy(right, empty_string);
|
||||
}
|
||||
|
||||
/* remove all trailing numbers in the "left" side, and pass they to "buf" */
|
||||
|
|
@ -689,7 +689,7 @@ static int split_filename(const char *filename, char *left, char *right, int *wi
|
|||
*width = 0;
|
||||
|
||||
for (;;) {
|
||||
chr = ugetat (left, -1);
|
||||
chr = ugetat(left, -1);
|
||||
if ((chr >= '0') && (chr <= '9')) {
|
||||
ret = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -31,8 +31,8 @@
|
|||
#define FILE_SUPPORT_MASKS_REPOSITORY (1<<9)
|
||||
#define FILE_SUPPORT_PATHS_REPOSITORY (1<<10)
|
||||
|
||||
typedef struct Sprite *(*FileLoad) (const char *filename);
|
||||
typedef int (*FileSave) (struct Sprite *sprite);
|
||||
typedef struct Sprite *(*FileLoad)(const char *filename);
|
||||
typedef int (*FileSave)(struct Sprite *sprite);
|
||||
|
||||
/* load or/and save a file format */
|
||||
typedef struct FileFormat
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -77,12 +77,12 @@ static Sprite *load_FLI(const char *filename)
|
|||
FILE *f;
|
||||
|
||||
/* open the file to read in binary mode */
|
||||
f = fopen (filename, "rb");
|
||||
f = fopen(filename, "rb");
|
||||
if (!f)
|
||||
return NULL;
|
||||
|
||||
fli_read_header (f, &fli_header);
|
||||
fseek (f, 128, SEEK_SET);
|
||||
fli_read_header(f, &fli_header);
|
||||
fseek(f, 128, SEEK_SET);
|
||||
|
||||
/* size by frame */
|
||||
w = fli_header.width;
|
||||
|
|
@ -106,8 +106,8 @@ static Sprite *load_FLI(const char *filename)
|
|||
layer_add_layer(sprite->set, layer);
|
||||
|
||||
/* set frames and speed */
|
||||
sprite_set_frames (sprite, fli_header.frames);
|
||||
sprite_set_speed (sprite, fli_header.speed);
|
||||
sprite_set_frames(sprite, fli_header.frames);
|
||||
sprite_set_speed(sprite, fli_header.speed);
|
||||
|
||||
/* write frame by frame */
|
||||
add_progress(100);
|
||||
|
|
@ -207,20 +207,20 @@ static int save_FLI(Sprite *sprite)
|
|||
fli_header.oframe1 = fli_header.oframe2 = 0;
|
||||
|
||||
/* open the file to write in binary mode */
|
||||
f = fopen (sprite->filename, "wb");
|
||||
f = fopen(sprite->filename, "wb");
|
||||
if (!f)
|
||||
return -1;
|
||||
|
||||
fseek (f, 128, SEEK_SET);
|
||||
fseek(f, 128, SEEK_SET);
|
||||
|
||||
/* create the bitmaps */
|
||||
bmp = image_new (IMAGE_INDEXED, sprite->w, sprite->h);
|
||||
old = image_new (IMAGE_INDEXED, sprite->w, sprite->h);
|
||||
bmp = image_new(IMAGE_INDEXED, sprite->w, sprite->h);
|
||||
old = image_new(IMAGE_INDEXED, sprite->w, sprite->h);
|
||||
if ((!bmp) || (!old)) {
|
||||
console_printf (_("Not enough memory for temporary bitmaps.\n"));
|
||||
if (bmp) image_free (bmp);
|
||||
if (old) image_free (old);
|
||||
fclose (f);
|
||||
console_printf(_("Not enough memory for temporary bitmaps.\n"));
|
||||
if (bmp) image_free(bmp);
|
||||
if (old) image_free(old);
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include <string.h>
|
||||
|
||||
GIF_ANIMATION *
|
||||
gif_create_animation (int frames_count)
|
||||
gif_create_animation(int frames_count)
|
||||
{
|
||||
GIF_ANIMATION *gif = calloc (1, sizeof *gif);
|
||||
/* Create frames. */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -43,8 +43,8 @@
|
|||
|
||||
#endif
|
||||
|
||||
static Sprite *load_GIF (const char *filename);
|
||||
static int save_GIF (Sprite *sprite);
|
||||
static Sprite *load_GIF(const char *filename);
|
||||
static int save_GIF(Sprite *sprite);
|
||||
|
||||
FileFormat format_gif =
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -201,7 +201,7 @@ static Sprite *load_JPEG(const char *filename)
|
|||
r = *(src_address++);
|
||||
g = *(src_address++);
|
||||
b = *(src_address++);
|
||||
*(dst_address++) = _rgba (r, g, b, 255);
|
||||
*(dst_address++) = _rgba(r, g, b, 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -57,7 +57,7 @@ static Sprite *load_PCX(const char *filename)
|
|||
int x, y;
|
||||
char ch = 0;
|
||||
|
||||
f = pack_fopen (filename, F_READ);
|
||||
f = pack_fopen(filename, F_READ);
|
||||
if (!f)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -66,8 +66,8 @@ static Sprite *load_PCX(const char *filename)
|
|||
pack_getc(f); /* skip encoding flag */
|
||||
|
||||
if (pack_getc(f) != 8) { /* we like 8 bit color planes */
|
||||
console_printf (_("This PCX doesn't have 8 bit color planes.\n"));
|
||||
pack_fclose (f);
|
||||
console_printf(_("This PCX doesn't have 8 bit color planes.\n"));
|
||||
pack_fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -98,16 +98,16 @@ static Sprite *load_PCX(const char *filename)
|
|||
for (c=0; c<60; c++) /* skip some more junk */
|
||||
pack_getc(f);
|
||||
|
||||
image = file_sequence_image (bpp == 8 ?
|
||||
IMAGE_INDEXED:
|
||||
IMAGE_RGB, width, height);
|
||||
image = file_sequence_image(bpp == 8 ?
|
||||
IMAGE_INDEXED:
|
||||
IMAGE_RGB, width, height);
|
||||
if (!image) {
|
||||
pack_fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (bpp == 24)
|
||||
image_clear (image, _rgba (0, 0, 0, 255));
|
||||
image_clear(image, _rgba(0, 0, 0, 255));
|
||||
|
||||
*allegro_errno = 0;
|
||||
|
||||
|
|
@ -151,7 +151,7 @@ static Sprite *load_PCX(const char *filename)
|
|||
}
|
||||
|
||||
if (height > 1)
|
||||
do_progress (100 * y / (height-1));
|
||||
do_progress(100 * y / (height-1));
|
||||
}
|
||||
|
||||
if (bpp == 8) { /* look for a 256 color palette */
|
||||
|
|
@ -241,10 +241,10 @@ static int save_PCX(Sprite *sprite)
|
|||
for (x=0; x<image->w*planes; x++) { /* for each pixel... */
|
||||
if (depth == 8) {
|
||||
if (image->imgtype == IMAGE_INDEXED)
|
||||
ch = image->method->getpixel (image, x, y);
|
||||
ch = image->method->getpixel(image, x, y);
|
||||
else if (image->imgtype == IMAGE_GRAYSCALE) {
|
||||
c = image->method->getpixel (image, x, y);
|
||||
ch = _graya_getk (c);
|
||||
c = image->method->getpixel(image, x, y);
|
||||
ch = _graya_getk(c);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -34,8 +34,8 @@
|
|||
|
||||
#endif
|
||||
|
||||
static int save_TGA (Sprite *sprite);
|
||||
static Sprite *load_TGA (const char *filename);
|
||||
static int save_TGA(Sprite *sprite);
|
||||
static Sprite *load_TGA(const char *filename);
|
||||
|
||||
FileFormat format_tga =
|
||||
{
|
||||
|
|
@ -107,14 +107,14 @@ static void rle_tga_read32 (ase_uint32 *address, int w, PACKFILE *f)
|
|||
c += count;
|
||||
pack_fread(value, 4, f);
|
||||
while (count--)
|
||||
*(address++) = _rgba (value[2], value[1], value[0], value[3]);
|
||||
*(address++) = _rgba(value[2], value[1], value[0], value[3]);
|
||||
}
|
||||
else {
|
||||
count++;
|
||||
c += count;
|
||||
while (count--) {
|
||||
pack_fread(value, 4, f);
|
||||
*(address++) = _rgba (value[2], value[1], value[0], value[3]);
|
||||
*(address++) = _rgba(value[2], value[1], value[0], value[3]);
|
||||
}
|
||||
}
|
||||
} while (c < w);
|
||||
|
|
@ -136,14 +136,14 @@ static void rle_tga_read24(ase_uint32 *address, int w, PACKFILE *f)
|
|||
c += count;
|
||||
pack_fread(value, 3, f);
|
||||
while (count--)
|
||||
*(address++) = _rgba (value[2], value[1], value[0], 255);
|
||||
*(address++) = _rgba(value[2], value[1], value[0], 255);
|
||||
}
|
||||
else {
|
||||
count++;
|
||||
c += count;
|
||||
while (count--) {
|
||||
pack_fread(value, 3, f);
|
||||
*(address++) = _rgba (value[2], value[1], value[0], 255);
|
||||
*(address++) = _rgba(value[2], value[1], value[0], 255);
|
||||
}
|
||||
}
|
||||
} while (c < w);
|
||||
|
|
@ -204,10 +204,10 @@ static Sprite *load_TGA(const char *filename)
|
|||
PACKFILE *f;
|
||||
int type;
|
||||
|
||||
f = pack_fopen (filename, F_READ);
|
||||
f = pack_fopen(filename, F_READ);
|
||||
if (!f) {
|
||||
if (!file_sequence_sprite ())
|
||||
console_printf (_("Error opening file.\n"));
|
||||
if (!file_sequence_sprite())
|
||||
console_printf(_("Error opening file.\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -226,7 +226,7 @@ static Sprite *load_TGA(const char *filename)
|
|||
bpp = pack_getc(f);
|
||||
descriptor_bits = pack_getc(f);
|
||||
|
||||
pack_fread (image_id, id_length, f);
|
||||
pack_fread(image_id, id_length, f);
|
||||
|
||||
if (palette_type == 1) {
|
||||
for (i=0; i<palette_colors; i++) {
|
||||
|
|
@ -318,7 +318,7 @@ static Sprite *load_TGA(const char *filename)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
image = file_sequence_image (type, image_width, image_height);
|
||||
image = file_sequence_image(type, image_width, image_height);
|
||||
if (!image) {
|
||||
pack_fclose(f);
|
||||
return NULL;
|
||||
|
|
@ -332,13 +332,13 @@ static Sprite *load_TGA(const char *filename)
|
|||
case 1:
|
||||
case 3:
|
||||
if (compressed)
|
||||
rle_tga_read (image->line[yc], image_width, image_type, f);
|
||||
rle_tga_read(image->line[yc], image_width, image_type, f);
|
||||
else if (image_type == 1)
|
||||
pack_fread (image->line[yc], image_width, f);
|
||||
pack_fread(image->line[yc], image_width, f);
|
||||
else {
|
||||
for (x=0; x<image_width; x++)
|
||||
*(((ase_uint16 **)image->line)[yc]+x) =
|
||||
_graya (pack_getc(f), 255);
|
||||
_graya(pack_getc(f), 255);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -363,7 +363,7 @@ static Sprite *load_TGA(const char *filename)
|
|||
for (x=0; x<image_width; x++) {
|
||||
pack_fread(rgb, 3, f);
|
||||
*(((ase_uint32 **)image->line)[yc]+x) =
|
||||
_rgba (rgb[2], rgb[1], rgb[0], 255);
|
||||
_rgba(rgb[2], rgb[1], rgb[0], 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -375,9 +375,9 @@ static Sprite *load_TGA(const char *filename)
|
|||
for (x=0; x<image_width; x++) {
|
||||
c = pack_igetw(f);
|
||||
*(((ase_uint32 **)image->line)[yc]+x) =
|
||||
_rgba (((c >> 10) & 0x1F),
|
||||
((c >> 5) & 0x1F),
|
||||
(c & 0x1F), 255);
|
||||
_rgba(((c >> 10) & 0x1F),
|
||||
((c >> 5) & 0x1F),
|
||||
(c & 0x1F), 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -385,24 +385,24 @@ static Sprite *load_TGA(const char *filename)
|
|||
}
|
||||
|
||||
if (image_height > 1)
|
||||
do_progress (100 * (image_height-y) / image_height);
|
||||
do_progress(100 * (image_height-y) / image_height);
|
||||
}
|
||||
|
||||
if (*allegro_errno) {
|
||||
console_printf (_("Error reading bytes.\n"));
|
||||
console_printf(_("Error reading bytes.\n"));
|
||||
pack_fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pack_fclose(f);
|
||||
return file_sequence_sprite ();
|
||||
return file_sequence_sprite();
|
||||
}
|
||||
|
||||
/* save_tga:
|
||||
* Writes a bitmap into a TGA file, using the specified palette (this
|
||||
* should be an array of at least 256 RGB structures).
|
||||
*/
|
||||
static int save_TGA (Sprite *sprite)
|
||||
static int save_TGA(Sprite *sprite)
|
||||
{
|
||||
unsigned char image_palette[256][3];
|
||||
int x, y, c, r, g, b;
|
||||
|
|
@ -411,7 +411,7 @@ static int save_TGA (Sprite *sprite)
|
|||
PACKFILE *f;
|
||||
Image *image;
|
||||
|
||||
f = pack_fopen (sprite->filename, F_WRITE);
|
||||
f = pack_fopen(sprite->filename, F_WRITE);
|
||||
if (!f) {
|
||||
console_printf(_("Error creating file.\n"));
|
||||
return -1;
|
||||
|
|
@ -454,35 +454,35 @@ static int save_TGA (Sprite *sprite)
|
|||
case IMAGE_RGB:
|
||||
for (y=image->h; y; y--) {
|
||||
for (x=0; x<image->w; x++) {
|
||||
c = image_getpixel (image, x, y-1);
|
||||
pack_putc(_rgba_getb (c), f);
|
||||
pack_putc(_rgba_getg (c), f);
|
||||
pack_putc(_rgba_getr (c), f);
|
||||
pack_putc(_rgba_geta (c), f);
|
||||
c = image_getpixel(image, x, y-1);
|
||||
pack_putc(_rgba_getb(c), f);
|
||||
pack_putc(_rgba_getg(c), f);
|
||||
pack_putc(_rgba_getr(c), f);
|
||||
pack_putc(_rgba_geta(c), f);
|
||||
}
|
||||
|
||||
if (image->h > 1)
|
||||
do_progress (100 * (image->h-y) / (image->h-1));
|
||||
do_progress(100 * (image->h-y) / (image->h-1));
|
||||
}
|
||||
break;
|
||||
|
||||
case IMAGE_GRAYSCALE:
|
||||
for (y=image->h; y; y--) {
|
||||
for (x=0; x<image->w; x++)
|
||||
pack_putc (_graya_getk (image_getpixel (image, x, y-1)), f);
|
||||
pack_putc(_graya_getk(image_getpixel(image, x, y-1)), f);
|
||||
|
||||
if (image->h > 1)
|
||||
do_progress (100 * (image->h-y) / (image->h-1));
|
||||
do_progress(100 * (image->h-y) / (image->h-1));
|
||||
}
|
||||
break;
|
||||
|
||||
case IMAGE_INDEXED:
|
||||
for (y=image->h; y; y--) {
|
||||
for (x=0; x<image->w; x++)
|
||||
pack_putc (image_getpixel(image, x, y-1), f);
|
||||
pack_putc(image_getpixel(image, x, y-1), f);
|
||||
|
||||
if (image->h > 1)
|
||||
do_progress (100 * (image->h-y) / (image->h-1));
|
||||
do_progress(100 * (image->h-y) / (image->h-1));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -490,7 +490,7 @@ static int save_TGA (Sprite *sprite)
|
|||
pack_fclose(f);
|
||||
|
||||
if (*allegro_errno) {
|
||||
console_printf (_("Error writing bytes.\n"));
|
||||
console_printf(_("Error writing bytes.\n"));
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -33,24 +33,24 @@
|
|||
|
||||
#endif
|
||||
|
||||
int intl_init (void)
|
||||
int intl_init(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void intl_exit (void)
|
||||
void intl_exit(void)
|
||||
{
|
||||
msgids_clear ();
|
||||
msgids_clear();
|
||||
}
|
||||
|
||||
void intl_load_lang (void)
|
||||
void intl_load_lang(void)
|
||||
{
|
||||
const char *lang = intl_get_lang ();
|
||||
const char *lang = intl_get_lang();
|
||||
DIRS *dirs, *dir;
|
||||
char buf[512];
|
||||
|
||||
sprintf (buf, "po/%s.po", lang);
|
||||
dirs = filename_in_datadir (buf);
|
||||
sprintf(buf, "po/%s.po", lang);
|
||||
dirs = filename_in_datadir(buf);
|
||||
|
||||
for (dir=dirs; dir; dir=dir->next) {
|
||||
if ((dir->path) && exists (dir->path)) {
|
||||
|
|
@ -61,58 +61,58 @@ void intl_load_lang (void)
|
|||
}
|
||||
}
|
||||
|
||||
dirs_free (dirs);
|
||||
dirs_free(dirs);
|
||||
}
|
||||
|
||||
const char *intl_get_lang (void)
|
||||
const char *intl_get_lang(void)
|
||||
{
|
||||
return get_config_string ("Options", "Language", "en");
|
||||
return get_config_string("Options", "Language", "en");
|
||||
}
|
||||
|
||||
void intl_set_lang (const char *lang)
|
||||
void intl_set_lang(const char *lang)
|
||||
{
|
||||
set_config_string ("Options", "Language", lang);
|
||||
set_config_string("Options", "Language", lang);
|
||||
|
||||
/* clear msgids and load them again */
|
||||
msgids_clear ();
|
||||
intl_load_lang ();
|
||||
msgids_clear();
|
||||
intl_load_lang();
|
||||
|
||||
/* reload the main menu */
|
||||
rebuild_root_menu ();
|
||||
rebuild_root_menu();
|
||||
}
|
||||
|
||||
/* int init_intl (void) */
|
||||
/* int init_intl(void) */
|
||||
/* { */
|
||||
/* #ifdef ENABLE_NLS */
|
||||
/* char buf[512], locale_path[512]; */
|
||||
/* DIRS *dirs, *dir; */
|
||||
|
||||
/* strcpy (buf, "locale"); */
|
||||
/* dirs = filename_in_datadir (buf); */
|
||||
/* strcpy(buf, "locale"); */
|
||||
/* dirs = filename_in_datadir(buf); */
|
||||
|
||||
/* /\* search the configuration file from first to last path *\/ */
|
||||
/* for (dir=dirs; dir; dir=dir->next) { */
|
||||
/* if ((dir->path) && file_exists (dir->path, FA_DIREC, NULL)) { */
|
||||
/* strcpy (buf, dir->path); */
|
||||
/* strcpy(buf, dir->path); */
|
||||
/* break; */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
/* dirs_free (dirs); */
|
||||
/* dirs_free(dirs); */
|
||||
|
||||
/* fix_filename_path (locale_path, buf, sizeof (locale_path)); */
|
||||
/* fix_filename_path(locale_path, buf, sizeof(locale_path)); */
|
||||
|
||||
/* #ifndef __MINGW32__ */
|
||||
/* setlocale (LC_MESSAGES, ""); */
|
||||
/* bindtextdomain (PACKAGE, locale_path); */
|
||||
/* textdomain (PACKAGE); */
|
||||
/* setenv ("OUTPUT_CHARSET", "ISO-8859-1", TRUE); */
|
||||
/* setlocale(LC_MESSAGES, ""); */
|
||||
/* bindtextdomain(PACKAGE, locale_path); */
|
||||
/* textdomain(PACKAGE); */
|
||||
/* setenv("OUTPUT_CHARSET", "ISO-8859-1", TRUE); */
|
||||
/* #endif */
|
||||
|
||||
/* /\* Set current language. *\/ */
|
||||
/* /\* const char *langname = get_config_string ("Options", "Language", ""); *\/ */
|
||||
/* /\* const char *langname = get_config_string("Options", "Language", ""); *\/ */
|
||||
|
||||
/* /\* setenv ("LANGUAGE", "en", 1); *\/ */
|
||||
/* /\* setenv("LANGUAGE", "en", 1); *\/ */
|
||||
/* /\* { *\/ */
|
||||
/* /\* extern int _nl_msg_cat_cntr; *\/ */
|
||||
/* /\* ++_nl_msg_cat_cntr; *\/ */
|
||||
|
|
@ -121,32 +121,32 @@ void intl_set_lang (const char *lang)
|
|||
/* return 0; */
|
||||
/* } */
|
||||
|
||||
/* const char *get_language_code (void) */
|
||||
/* const char *get_language_code(void) */
|
||||
/* { */
|
||||
/* #ifdef ENABLE_NLS */
|
||||
/* static char buf[8]; */
|
||||
/* const char *language; */
|
||||
|
||||
/* language = getenv ("LANGUAGE"); */
|
||||
/* language = getenv("LANGUAGE"); */
|
||||
/* if (language != NULL && language[0] == '\0') */
|
||||
/* language = NULL; */
|
||||
|
||||
/* if (!language) { */
|
||||
/* language = getenv ("LC_ALL"); */
|
||||
/* language = getenv("LC_ALL"); */
|
||||
/* if (language != NULL && language[0] == '\0') */
|
||||
/* language = NULL; */
|
||||
/* } */
|
||||
|
||||
/* if (!language) { */
|
||||
/* language = getenv ("LANG"); */
|
||||
/* language = getenv("LANG"); */
|
||||
/* if (language != NULL && language[0] == '\0') */
|
||||
/* language = NULL; */
|
||||
/* } */
|
||||
|
||||
/* if (language && language[0] && language[1]) */
|
||||
/* sprintf (buf, "%c%c", language[0], language[1]); */
|
||||
/* sprintf(buf, "%c%c", language[0], language[1]); */
|
||||
/* else */
|
||||
/* strcpy (buf, "en"); */
|
||||
/* strcpy(buf, "en"); */
|
||||
|
||||
/* return buf; */
|
||||
/* #else */
|
||||
|
|
@ -156,7 +156,7 @@ void intl_set_lang (const char *lang)
|
|||
|
||||
/* #ifdef ENABLE_NLS */
|
||||
/* #ifdef __MINGW32__ */
|
||||
/* char *gettext (const char *__msgid) */
|
||||
/* char *gettext(const char *__msgid) */
|
||||
/* { */
|
||||
/* return gettext__ (__msgid); */
|
||||
/* } */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -19,11 +19,11 @@
|
|||
#ifndef INTL_H
|
||||
#define INTL_H
|
||||
|
||||
int intl_init (void);
|
||||
void intl_exit (void);
|
||||
int intl_init(void);
|
||||
void intl_exit(void);
|
||||
|
||||
void intl_load_lang (void);
|
||||
const char *intl_get_lang (void);
|
||||
void intl_set_lang (const char *lang);
|
||||
void intl_load_lang(void);
|
||||
const char *intl_get_lang(void);
|
||||
void intl_set_lang(const char *lang);
|
||||
|
||||
#endif /* !INTL_H */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -32,65 +32,65 @@
|
|||
|
||||
static HashTable *msgids = NULL;
|
||||
|
||||
int msgids_load (const char *filename)
|
||||
int msgids_load(const char *filename)
|
||||
{
|
||||
char buf[4096], leavings[4096];
|
||||
char id[4096], trans[4096];
|
||||
int donotread = FALSE;
|
||||
FILE *f;
|
||||
|
||||
f = fopen (filename, "r");
|
||||
f = fopen(filename, "r");
|
||||
if (!f)
|
||||
return -1;
|
||||
|
||||
if (!msgids)
|
||||
msgids = hash_new (64);
|
||||
msgids = hash_new(64);
|
||||
|
||||
tok_reset_line_num ();
|
||||
strcpy (leavings, "");
|
||||
tok_reset_line_num();
|
||||
strcpy(leavings, "");
|
||||
|
||||
while (donotread || tok_read (f, buf, leavings, sizeof (leavings))) {
|
||||
donotread = FALSE;
|
||||
|
||||
/* new msgid */
|
||||
if (strncmp ("msgid", buf, 5) == 0) {
|
||||
strcpy (id, "");
|
||||
strcpy (trans, "");
|
||||
strcpy(id, "");
|
||||
strcpy(trans, "");
|
||||
|
||||
while (tok_read (f, buf, leavings, sizeof (leavings)) &&
|
||||
strncmp ("msgstr", buf, 6) != 0)
|
||||
strcat (id, buf);
|
||||
while (tok_read(f, buf, leavings, sizeof(leavings)) &&
|
||||
strncmp("msgstr", buf, 6) != 0)
|
||||
strcat(id, buf);
|
||||
|
||||
if (strncmp ("msgstr", buf, 6) == 0) {
|
||||
while (tok_read (f, buf, leavings, sizeof (leavings)) &&
|
||||
strncmp ("msgid", buf, 5) != 0)
|
||||
strcat (trans, buf);
|
||||
if (strncmp("msgstr", buf, 6) == 0) {
|
||||
while (tok_read(f, buf, leavings, sizeof(leavings)) &&
|
||||
strncmp("msgid", buf, 5) != 0)
|
||||
strcat(trans, buf);
|
||||
|
||||
if (strncmp ("msgid", buf, 5) == 0)
|
||||
if (strncmp("msgid", buf, 5) == 0)
|
||||
donotread = TRUE;
|
||||
|
||||
if (strlen (id) > 0 && strlen (trans) > 0)
|
||||
hash_insert (msgids, id, jstrdup (trans));
|
||||
if (strlen(id) > 0 && strlen(trans) > 0)
|
||||
hash_insert(msgids, id, jstrdup(trans));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose (f);
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void msgids_clear (void)
|
||||
void msgids_clear(void)
|
||||
{
|
||||
if (msgids) {
|
||||
hash_free (msgids, jfree);
|
||||
hash_free(msgids, jfree);
|
||||
msgids = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
const char *msgids_get (const char *id)
|
||||
const char *msgids_get(const char *id)
|
||||
{
|
||||
if (msgids) {
|
||||
const char *trans = hash_lookup (msgids, id);
|
||||
const char *trans = hash_lookup(msgids, id);
|
||||
if (trans)
|
||||
return trans;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -19,8 +19,8 @@
|
|||
#ifndef INTL_MSGIDS_H
|
||||
#define INTL_MSGIDS_H
|
||||
|
||||
int msgids_load (const char *filename);
|
||||
void msgids_clear (void);
|
||||
const char *msgids_get (const char *id);
|
||||
int msgids_load(const char *filename);
|
||||
void msgids_clear(void);
|
||||
const char *msgids_get(const char *id);
|
||||
|
||||
#endif /* !INTL_MSGIDS_H */
|
||||
|
|
|
|||
|
|
@ -134,9 +134,9 @@ static void proc_one_word(JAccel accel, char *word)
|
|||
if (((*tok >= 'a') && (*tok <= 'z')) ||
|
||||
((*tok >= 'A') && (*tok <= 'Z'))) {
|
||||
/* if (shifts & KB_CTRL_FLAG) */
|
||||
/* ascii = tolower (*tok) - 'a' + 1; */
|
||||
/* ascii = tolower(*tok) - 'a' + 1; */
|
||||
/* else */
|
||||
ascii = tolower (*tok);
|
||||
ascii = tolower(*tok);
|
||||
}
|
||||
/* else if ((*tok >= '0') && (*tok <= '9')) { */
|
||||
/* if (shifts & KB_CTRL_FLAG) */
|
||||
|
|
@ -150,7 +150,7 @@ static void proc_one_word(JAccel accel, char *word)
|
|||
#else
|
||||
if (((*tok >= 'a') && (*tok <= 'z')) ||
|
||||
((*tok >= 'A') && (*tok <= 'Z')))
|
||||
scancode = KEY_A + tolower (*tok) - 'a';
|
||||
scancode = KEY_A + tolower(*tok) - 'a';
|
||||
else if ((*tok >= '0') && (*tok <= '9'))
|
||||
scancode = KEY_0 + *tok - '0';
|
||||
else {
|
||||
|
|
@ -376,7 +376,7 @@ static void keycombo_get_string(KeyCombo *key, char *buf)
|
|||
|
||||
/* key */
|
||||
if (key->ascii)
|
||||
usprintf(buf+ustrlen (buf), "%c", toupper(key->ascii));
|
||||
usprintf(buf+ustrlen(buf), "%c", toupper(key->ascii));
|
||||
else if (key->scancode)
|
||||
ustrcat(buf, table[key->scancode]);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -68,9 +68,9 @@ JWidget jalert_new(const char *format, ...)
|
|||
va_list ap;
|
||||
|
||||
/* process arguments */
|
||||
va_start (ap, format);
|
||||
vsprintf (buf, format, ap);
|
||||
va_end (ap);
|
||||
va_start(ap, format);
|
||||
vsprintf(buf, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
/* create the alert window */
|
||||
labels = jlist_new();
|
||||
|
|
@ -162,7 +162,7 @@ static JWidget create_alert(char *buf, JList *labels, JList *buttons)
|
|||
buf[c] = 0;
|
||||
|
||||
if (title) {
|
||||
window = jwindow_new (beg);
|
||||
window = jwindow_new(beg);
|
||||
}
|
||||
else if (label) {
|
||||
JWidget label = jlabel_new(beg);
|
||||
|
|
@ -235,7 +235,7 @@ static JWidget create_alert(char *buf, JList *labels, JList *buttons)
|
|||
|
||||
/* default button is the last one */
|
||||
if (jlist_last (*buttons))
|
||||
jwidget_magnetic ((JWidget)jlist_last (*buttons)->data, TRUE);
|
||||
jwidget_magnetic((JWidget)jlist_last(*buttons)->data, TRUE);
|
||||
}
|
||||
|
||||
return window;
|
||||
|
|
|
|||
|
|
@ -263,11 +263,11 @@ void jfree (void *mem);
|
|||
char *jstrdup (const char *string);
|
||||
|
||||
#define jnew(struct_type, n_structs) \
|
||||
((struct_type *)jmalloc(sizeof (struct_type) * (n_structs)))
|
||||
((struct_type *)jmalloc(sizeof(struct_type) * (n_structs)))
|
||||
#define jnew0(struct_type, n_structs) \
|
||||
((struct_type *)jmalloc0(sizeof (struct_type) * (n_structs)))
|
||||
((struct_type *)jmalloc0(sizeof(struct_type) * (n_structs)))
|
||||
#define jrenew(struct_type, mem, n_structs) \
|
||||
((struct_type *)jrealloc((mem), (sizeof (struct_type) * (n_structs))))
|
||||
((struct_type *)jrealloc((mem), (sizeof(struct_type) * (n_structs))))
|
||||
|
||||
JI_END_DECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ static void box_request_size(JWidget widget, int *w, int *h)
|
|||
*h += widget->border_width.t + widget->border_width.b;
|
||||
}
|
||||
|
||||
static void box_set_position (JWidget widget, JRect rect)
|
||||
static void box_set_position(JWidget widget, JRect rect)
|
||||
{
|
||||
#define FIXUP(x, y, w, h, l, t, r, b) \
|
||||
{ \
|
||||
|
|
@ -153,9 +153,9 @@ static void box_set_position (JWidget widget, JRect rect)
|
|||
\
|
||||
x = widget->rc->x##1 + widget->border_width.l; \
|
||||
y = widget->rc->y##1 + widget->border_width.t; \
|
||||
h = MAX (1, jrect_##h(widget->rc) \
|
||||
- widget->border_width.t \
|
||||
- widget->border_width.b); \
|
||||
h = MAX(1, jrect_##h(widget->rc) \
|
||||
- widget->border_width.t \
|
||||
- widget->border_width.b); \
|
||||
\
|
||||
JI_LIST_FOR_EACH(widget->children, link) { \
|
||||
child = (JWidget)link->data; \
|
||||
|
|
@ -186,7 +186,7 @@ static void box_set_position (JWidget widget, JRect rect)
|
|||
} \
|
||||
} \
|
||||
\
|
||||
w = MAX (1, child_width/* - child->padding * 2 */); \
|
||||
w = MAX(1, child_width/* - child->padding * 2 */); \
|
||||
\
|
||||
if (widget->align & JI_HORIZONTAL) \
|
||||
jrect_replace(&cpos, x, y, x+w, y+h); \
|
||||
|
|
@ -197,7 +197,7 @@ static void box_set_position (JWidget widget, JRect rect)
|
|||
/* x = x + child->padding; */ \
|
||||
/* child->w = w; */ \
|
||||
/* child->h = h; */ \
|
||||
/* jwidget_size (child, w, h); */ \
|
||||
/* jwidget_size(child, w, h); */ \
|
||||
\
|
||||
x += child_width + widget->child_spacing; \
|
||||
} \
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
JI_BEGIN_DECLS
|
||||
|
||||
JWidget jbox_new (int align);
|
||||
JWidget jbox_new(int align);
|
||||
|
||||
JI_END_DECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -330,7 +330,7 @@ static bool button_msg_proc(JWidget widget, JMessage msg)
|
|||
if ((msg->key.scancode == KEY_ENTER) ||
|
||||
(msg->key.scancode == KEY_ENTER_PAD) ||
|
||||
(msg->key.scancode == KEY_SPACE)) {
|
||||
jwidget_select (widget);
|
||||
jwidget_select(widget);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,15 +33,15 @@
|
|||
|
||||
static char *clipboard_text = NULL;
|
||||
|
||||
const char *jclipboard_get_text (void)
|
||||
const char *jclipboard_get_text(void)
|
||||
{
|
||||
return clipboard_text;
|
||||
}
|
||||
|
||||
void jclipboard_set_text (const char *text)
|
||||
void jclipboard_set_text(const char *text)
|
||||
{
|
||||
if (clipboard_text)
|
||||
jfree (clipboard_text);
|
||||
jfree(clipboard_text);
|
||||
|
||||
clipboard_text = text ? jstrdup (text) : NULL;
|
||||
clipboard_text = text ? jstrdup(text) : NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,13 +58,13 @@ static void combobox_close_window(JWidget widget);
|
|||
static void combobox_switch_window(JWidget widget);
|
||||
static JRect combobox_get_windowpos(ComboBox *combobox);
|
||||
|
||||
JWidget jcombobox_new (void)
|
||||
JWidget jcombobox_new(void)
|
||||
{
|
||||
JWidget widget = jbox_new(JI_HORIZONTAL);
|
||||
ComboBox *combobox = jnew(ComboBox, 1);
|
||||
|
||||
combobox->entry = jentry_new (256, "");
|
||||
combobox->button = jbutton_new ("^");
|
||||
combobox->entry = jentry_new(256, "");
|
||||
combobox->button = jbutton_new("^");
|
||||
combobox->window = NULL;
|
||||
combobox->items = jlist_new();
|
||||
combobox->selected = 0;
|
||||
|
|
@ -94,53 +94,53 @@ JWidget jcombobox_new (void)
|
|||
return widget;
|
||||
}
|
||||
|
||||
void jcombobox_editable (JWidget widget, bool state)
|
||||
void jcombobox_editable(JWidget widget, bool state)
|
||||
{
|
||||
ComboBox *combobox = jwidget_get_data (widget, JI_COMBOBOX);
|
||||
ComboBox *combobox = jwidget_get_data(widget, JI_COMBOBOX);
|
||||
|
||||
combobox->editable = state;
|
||||
|
||||
if (state) {
|
||||
jentry_readonly (combobox->entry, FALSE);
|
||||
jentry_show_cursor (combobox->entry);
|
||||
jentry_readonly(combobox->entry, FALSE);
|
||||
jentry_show_cursor(combobox->entry);
|
||||
}
|
||||
else {
|
||||
jentry_readonly (combobox->entry, TRUE);
|
||||
jentry_hide_cursor (combobox->entry);
|
||||
jentry_readonly(combobox->entry, TRUE);
|
||||
jentry_hide_cursor(combobox->entry);
|
||||
}
|
||||
}
|
||||
|
||||
void jcombobox_clickopen (JWidget widget, bool state)
|
||||
void jcombobox_clickopen(JWidget widget, bool state)
|
||||
{
|
||||
ComboBox *combobox = jwidget_get_data (widget, JI_COMBOBOX);
|
||||
ComboBox *combobox = jwidget_get_data(widget, JI_COMBOBOX);
|
||||
|
||||
combobox->clickopen = state;
|
||||
}
|
||||
|
||||
void jcombobox_casesensitive (JWidget widget, bool state)
|
||||
void jcombobox_casesensitive(JWidget widget, bool state)
|
||||
{
|
||||
ComboBox *combobox = jwidget_get_data (widget, JI_COMBOBOX);
|
||||
ComboBox *combobox = jwidget_get_data(widget, JI_COMBOBOX);
|
||||
|
||||
combobox->casesensitive = state;
|
||||
}
|
||||
|
||||
bool jcombobox_is_editable (JWidget widget)
|
||||
bool jcombobox_is_editable(JWidget widget)
|
||||
{
|
||||
ComboBox *combobox = jwidget_get_data (widget, JI_COMBOBOX);
|
||||
ComboBox *combobox = jwidget_get_data(widget, JI_COMBOBOX);
|
||||
|
||||
return combobox->editable;
|
||||
}
|
||||
|
||||
bool jcombobox_is_clickopen (JWidget widget)
|
||||
bool jcombobox_is_clickopen(JWidget widget)
|
||||
{
|
||||
ComboBox *combobox = jwidget_get_data (widget, JI_COMBOBOX);
|
||||
ComboBox *combobox = jwidget_get_data(widget, JI_COMBOBOX);
|
||||
|
||||
return combobox->clickopen;
|
||||
}
|
||||
|
||||
bool jcombobox_is_casesensitive (JWidget widget)
|
||||
bool jcombobox_is_casesensitive(JWidget widget)
|
||||
{
|
||||
ComboBox *combobox = jwidget_get_data (widget, JI_COMBOBOX);
|
||||
ComboBox *combobox = jwidget_get_data(widget, JI_COMBOBOX);
|
||||
|
||||
return combobox->casesensitive;
|
||||
}
|
||||
|
|
@ -158,23 +158,23 @@ void jcombobox_add_string(JWidget widget, const char *string)
|
|||
|
||||
void jcombobox_del_string(JWidget widget, const char *string)
|
||||
{
|
||||
jcombobox_del_index (widget, jcombobox_get_index (widget, string));
|
||||
jcombobox_del_index(widget, jcombobox_get_index(widget, string));
|
||||
}
|
||||
|
||||
void jcombobox_del_index(JWidget widget, int index)
|
||||
{
|
||||
ComboBox *combobox = jwidget_get_data(widget, JI_COMBOBOX);
|
||||
|
||||
jlist_remove(combobox->items, jlist_nth_data (combobox->items, index));
|
||||
jlist_remove(combobox->items, jlist_nth_data(combobox->items, index));
|
||||
}
|
||||
|
||||
void jcombobox_select_index(JWidget widget, int index)
|
||||
{
|
||||
ComboBox *combobox = jwidget_get_data (widget, JI_COMBOBOX);
|
||||
JLink link = jlist_nth_link (combobox->items, index);
|
||||
ComboBox *combobox = jwidget_get_data(widget, JI_COMBOBOX);
|
||||
JLink link = jlist_nth_link(combobox->items, index);
|
||||
if (link != combobox->items->end) {
|
||||
combobox->selected = index;
|
||||
jwidget_set_text (combobox->entry, link->data);
|
||||
jwidget_set_text(combobox->entry, link->data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@
|
|||
|
||||
/* TODO optional anti-aliased textout */
|
||||
#define SETUP_ANTIALISING(f, bg, fill_bg) \
|
||||
ji_font_set_aa_mode (f, fill_bg || \
|
||||
bitmap_color_depth (ji_screen) == 8 ? bg: -1)
|
||||
ji_font_set_aa_mode(f, fill_bg || \
|
||||
bitmap_color_depth(ji_screen) == 8 ? bg: -1)
|
||||
|
||||
void jdraw_rect(const JRect r, int color)
|
||||
{
|
||||
|
|
@ -75,28 +75,28 @@ void jdraw_rectshade(const JRect rect, int c1, int c2, int align)
|
|||
x2 = rect->x2-1;
|
||||
y2 = rect->y2-1;
|
||||
|
||||
r[0] = getr (c1);
|
||||
g[0] = getg (c1);
|
||||
b[0] = getb (c1);
|
||||
r[0] = getr(c1);
|
||||
g[0] = getg(c1);
|
||||
b[0] = getb(c1);
|
||||
|
||||
r[1] = getr (c2);
|
||||
g[1] = getg (c2);
|
||||
b[1] = getb (c2);
|
||||
r[1] = getr(c2);
|
||||
g[1] = getg(c2);
|
||||
b[1] = getb(c2);
|
||||
|
||||
if (align & JI_VERTICAL) {
|
||||
if (y1 == y2)
|
||||
hline (ji_screen, x1, y1, x2, c1);
|
||||
hline(ji_screen, x1, y1, x2, c1);
|
||||
else
|
||||
for (c=y1; c<=y2; c++)
|
||||
hline (ji_screen,
|
||||
x1, c, x2,
|
||||
makecol ((r[0] + (r[1] - r[0]) * (c - y1) / (y2 - y1)),
|
||||
(g[0] + (g[1] - g[0]) * (c - y1) / (y2 - y1)),
|
||||
(b[0] + (b[1] - b[0]) * (c - y1) / (y2 - y1))));
|
||||
hline(ji_screen,
|
||||
x1, c, x2,
|
||||
makecol((r[0] + (r[1] - r[0]) * (c - y1) / (y2 - y1)),
|
||||
(g[0] + (g[1] - g[0]) * (c - y1) / (y2 - y1)),
|
||||
(b[0] + (b[1] - b[0]) * (c - y1) / (y2 - y1))));
|
||||
}
|
||||
else if (align & JI_HORIZONTAL) {
|
||||
if (x1 == x2)
|
||||
vline (ji_screen, x1, y1, y2, c1);
|
||||
vline(ji_screen, x1, y1, y2, c1);
|
||||
else
|
||||
for (c=x1; c<=x2; c++)
|
||||
vline(ji_screen,
|
||||
|
|
@ -137,41 +137,41 @@ void jdraw_text(FONT *font, const char *s, int x, int y,
|
|||
|
||||
while (((c = ugetc(s+in_pos)) != 0) && (out_pos<(int)(sizeof(tmp)-ucwidth(0)))) {
|
||||
if (c == '&') {
|
||||
in_pos += uwidth (s+in_pos);
|
||||
c = ugetc (s+in_pos);
|
||||
in_pos += uwidth(s+in_pos);
|
||||
c = ugetc(s+in_pos);
|
||||
if (c == '&') {
|
||||
out_pos += usetc (tmp+out_pos, '&');
|
||||
in_pos += uwidth (s+in_pos);
|
||||
out_pos += usetc(tmp+out_pos, '&');
|
||||
in_pos += uwidth(s+in_pos);
|
||||
len++;
|
||||
}
|
||||
else
|
||||
hline_pos = len;
|
||||
}
|
||||
else {
|
||||
out_pos += usetc (tmp+out_pos, c);
|
||||
in_pos += uwidth (s+in_pos);
|
||||
out_pos += usetc(tmp+out_pos, c);
|
||||
in_pos += uwidth(s+in_pos);
|
||||
len++;
|
||||
}
|
||||
}
|
||||
|
||||
usetc (tmp+out_pos, 0);
|
||||
usetc(tmp+out_pos, 0);
|
||||
|
||||
SETUP_ANTIALISING (font, bg_color, fill_bg);
|
||||
SETUP_ANTIALISING(font, bg_color, fill_bg);
|
||||
|
||||
text_mode (fill_bg ? bg_color: -1);
|
||||
textout (ji_screen, font, tmp, x, y, fg_color);
|
||||
text_mode(fill_bg ? bg_color: -1);
|
||||
textout(ji_screen, font, tmp, x, y, fg_color);
|
||||
|
||||
if (hline_pos >= 0) {
|
||||
c = ugetat (tmp, hline_pos);
|
||||
usetat (tmp, hline_pos, 0);
|
||||
hline_pos = text_length (font, tmp);
|
||||
c = usetc (tmp, c);
|
||||
usetc (tmp+c, 0);
|
||||
c = text_length (font, tmp);
|
||||
hline (ji_screen, x+hline_pos,
|
||||
/* y+text_height (font)-1, */
|
||||
y+text_height (font),
|
||||
x+hline_pos+c-1, fg_color);
|
||||
c = ugetat(tmp, hline_pos);
|
||||
usetat(tmp, hline_pos, 0);
|
||||
hline_pos = text_length(font, tmp);
|
||||
c = usetc(tmp, c);
|
||||
usetc(tmp+c, 0);
|
||||
c = text_length(font, tmp);
|
||||
hline(ji_screen, x+hline_pos,
|
||||
/* y+text_height(font)-1, */
|
||||
y+text_height(font),
|
||||
x+hline_pos+c-1, fg_color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -236,7 +236,7 @@ typedef struct XPM_COLOR {
|
|||
int color;
|
||||
} XPM_COLOR;
|
||||
|
||||
BITMAP *ji_xpm_to_bitmap (const char *xpm_image, int depth)
|
||||
BITMAP *ji_xpm_to_bitmap(const char *xpm_image, int depth)
|
||||
{
|
||||
int w, h, colors, charsbycolor;
|
||||
int *colormap;
|
||||
|
|
@ -245,19 +245,19 @@ BITMAP *ji_xpm_to_bitmap (const char *xpm_image, int depth)
|
|||
|
||||
/* read header */
|
||||
p = xpm_image[0];
|
||||
w = ustrtol (p, (char *)&p, 10);
|
||||
h = ustrtol (p, (char *)&p, 10);
|
||||
colors = ustrtol (p, (char *)&p, 10);
|
||||
charsbycolor = ustrtol (p, (char *)&p, 10);
|
||||
w = ustrtol(p,(char *)&p, 10);
|
||||
h = ustrtol(p,(char *)&p, 10);
|
||||
colors = ustrtol(p,(char *)&p, 10);
|
||||
charsbycolor = ustrtol(p,(char *)&p, 10);
|
||||
|
||||
/* error? */
|
||||
if (w < 1 || h < 1 || colors < 1 || charsbycolor < 1)
|
||||
return NULL;
|
||||
|
||||
/* read color map */
|
||||
colormap = jmalloc (sizeof (XPM_COLOR) * colors);
|
||||
colormap = jmalloc(sizeof(XPM_COLOR) * colors);
|
||||
for (c=0; c<colors; c++) {
|
||||
colormap[c].chars = jmalloc (charsbycolor);
|
||||
colormap[c].chars = jmalloc(charsbycolor);
|
||||
colormap[c].color = makecol
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@
|
|||
JI_BEGIN_DECLS
|
||||
|
||||
#define JI_COLOR_SHADE(color, r, g, b) \
|
||||
makecol(MID (0, getr(color)+(r), 255), \
|
||||
MID (0, getg(color)+(g), 255), \
|
||||
MID (0, getb(color)+(b), 255))
|
||||
makecol(MID(0, getr(color)+(r), 255), \
|
||||
MID(0, getg(color)+(g), 255), \
|
||||
MID(0, getb(color)+(b), 255))
|
||||
|
||||
#define JI_COLOR_INTERP(c1, c2, step, max) \
|
||||
makecol(getr(c1)+(getr(c2)-getr(c1)) * step / max, \
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@
|
|||
#include "jinete/jtheme.h"
|
||||
#include "jinete/jwidget.h"
|
||||
|
||||
#define CHARACTER_LENGTH(f, c) ((f)->vtable->char_length ((f), (c)))
|
||||
#define CHARACTER_LENGTH(f, c) ((f)->vtable->char_length((f), (c)))
|
||||
|
||||
typedef struct Entry
|
||||
{
|
||||
|
|
@ -240,7 +240,7 @@ static bool entry_msg_proc(JWidget widget, JMessage msg)
|
|||
break;
|
||||
|
||||
case JM_REQSIZE:
|
||||
entry_request_size (widget, &msg->reqsize.w, &msg->reqsize.h);
|
||||
entry_request_size(widget, &msg->reqsize.w, &msg->reqsize.h);
|
||||
return TRUE;
|
||||
|
||||
case JM_TIMER:
|
||||
|
|
@ -271,13 +271,13 @@ static bool entry_msg_proc(JWidget widget, JMessage msg)
|
|||
break;
|
||||
|
||||
case JM_CHAR:
|
||||
if (jwidget_has_focus (widget) && !jentry_is_readonly (widget)) {
|
||||
char *text = jmalloc (widget->text_size);
|
||||
if (jwidget_has_focus(widget) && !jentry_is_readonly(widget)) {
|
||||
char *text = jmalloc(widget->text_size);
|
||||
int c, selbeg, selend;
|
||||
|
||||
jtheme_entry_info (widget, NULL, NULL, NULL, &selbeg, &selend);
|
||||
jtheme_entry_info(widget, NULL, NULL, NULL, &selbeg, &selend);
|
||||
|
||||
ustrcpy (text, widget->text);
|
||||
ustrcpy(text, widget->text);
|
||||
|
||||
switch (msg->key.scancode) {
|
||||
|
||||
|
|
@ -292,7 +292,7 @@ static bool entry_msg_proc(JWidget widget, JMessage msg)
|
|||
|
||||
/* backward word */
|
||||
if (msg->any.shifts & KB_CTRL_FLAG)
|
||||
entry_backward_word (widget);
|
||||
entry_backward_word(widget);
|
||||
/* backward char */
|
||||
else if (entry->cursor > 0)
|
||||
entry->cursor--;
|
||||
|
|
@ -309,7 +309,7 @@ static bool entry_msg_proc(JWidget widget, JMessage msg)
|
|||
|
||||
/* forward word */
|
||||
if (msg->any.shifts & KB_CTRL_FLAG)
|
||||
entry_forward_word (widget);
|
||||
entry_forward_word(widget);
|
||||
/* forward char */
|
||||
else if (entry->cursor < ustrlen (text))
|
||||
entry->cursor++;
|
||||
|
|
@ -336,7 +336,7 @@ static bool entry_msg_proc(JWidget widget, JMessage msg)
|
|||
else
|
||||
entry->select = -1;
|
||||
|
||||
entry->cursor = ustrlen (text);
|
||||
entry->cursor = ustrlen(text);
|
||||
break;
|
||||
|
||||
case KEY_DEL:
|
||||
|
|
@ -345,22 +345,22 @@ static bool entry_msg_proc(JWidget widget, JMessage msg)
|
|||
/* *cut* text! */
|
||||
if (msg->any.shifts & KB_SHIFT_FLAG) {
|
||||
char buf[1024];
|
||||
ustrcpy (buf, empty_string);
|
||||
ustrcpy(buf, empty_string);
|
||||
for (c=selbeg; c<=selend; c++)
|
||||
uinsert (buf, ustrlen (buf), ugetat (text, c));
|
||||
jclipboard_set_text (buf);
|
||||
uinsert(buf, ustrlen(buf), ugetat(text, c));
|
||||
jclipboard_set_text(buf);
|
||||
}
|
||||
|
||||
/* remove text */
|
||||
for (c=0; c<selend-selbeg+1; c++)
|
||||
uremove (text, selbeg);
|
||||
uremove(text, selbeg);
|
||||
|
||||
entry->cursor = selbeg;
|
||||
}
|
||||
/* delete the next character */
|
||||
else {
|
||||
if (entry->cursor < ustrlen (text))
|
||||
uremove (text, entry->cursor);
|
||||
uremove(text, entry->cursor);
|
||||
}
|
||||
|
||||
entry->select = -1;
|
||||
|
|
@ -375,7 +375,7 @@ static bool entry_msg_proc(JWidget widget, JMessage msg)
|
|||
/* delete the entire selection */
|
||||
if (selbeg >= 0) {
|
||||
for (c=0; c<selend-selbeg+1; c++)
|
||||
uremove (text, selbeg);
|
||||
uremove(text, selbeg);
|
||||
|
||||
entry->cursor = selbeg;
|
||||
entry->select = -1;
|
||||
|
|
@ -394,9 +394,9 @@ static bool entry_msg_proc(JWidget widget, JMessage msg)
|
|||
/* *copy* text */
|
||||
else if ((selbeg >= 0) && (msg->any.shifts & KB_CTRL_FLAG)) {
|
||||
char buf[1024];
|
||||
ustrcpy (buf, empty_string);
|
||||
ustrcpy(buf, empty_string);
|
||||
for (c=selbeg; c<=selend; c++)
|
||||
uinsert(buf, ustrlen(buf), ugetat (text, c));
|
||||
uinsert(buf, ustrlen(buf), ugetat(text, c));
|
||||
jclipboard_set_text(buf);
|
||||
}
|
||||
break;
|
||||
|
|
@ -482,7 +482,7 @@ static bool entry_msg_proc(JWidget widget, JMessage msg)
|
|||
x = widget->rc->x1 + widget->border_width.l;
|
||||
for (c=entry->scroll; ; c++) {
|
||||
x += CHARACTER_LENGTH(widget->text_font,
|
||||
(c < ustrlen (text))? ugetat (text, c): ' ');
|
||||
(c < ustrlen(text))? ugetat(text, c): ' ');
|
||||
if (x > widget->rc->x2-widget->border_width.r) {
|
||||
c--;
|
||||
break;
|
||||
|
|
@ -493,18 +493,18 @@ static bool entry_msg_proc(JWidget widget, JMessage msg)
|
|||
entry->cursor = c;
|
||||
move = FALSE;
|
||||
dirty = TRUE;
|
||||
jwidget_dirty (widget);
|
||||
jwidget_dirty(widget);
|
||||
}
|
||||
}
|
||||
|
||||
/* move cursor */
|
||||
if (move) {
|
||||
c = entry_get_cursor_from_mouse (widget, msg);
|
||||
c = entry_get_cursor_from_mouse(widget, msg);
|
||||
|
||||
if (entry->cursor != c) {
|
||||
entry->cursor = c;
|
||||
dirty = TRUE;
|
||||
jwidget_dirty (widget);
|
||||
jwidget_dirty(widget);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -576,7 +576,7 @@ static int entry_get_cursor_from_mouse(JWidget widget, JMessage msg)
|
|||
|
||||
x = widget->rc->x1 + widget->border_width.l;
|
||||
for (c=entry->scroll; ugetat (widget->text, c); c++) {
|
||||
w = CHARACTER_LENGTH(widget->text_font, ugetat (widget->text, c));
|
||||
w = CHARACTER_LENGTH(widget->text_font, ugetat(widget->text, c));
|
||||
if (x+w >= widget->rc->x2-widget->border_width.r)
|
||||
break;
|
||||
if ((mx >= x) && (mx < x+w)) {
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
((chr) == '\r'))
|
||||
|
||||
#define TRANSLATE_ATTR(attr) \
|
||||
((attr->translatable) ? ji_translate_string (attr->value): (attr->value))
|
||||
((attr->translatable) ? ji_translate_string(attr->value): (attr->value))
|
||||
|
||||
typedef struct Attr
|
||||
{
|
||||
|
|
@ -127,7 +127,7 @@ static JWidget convert_tag_to_widget(Tag *tag)
|
|||
Attr *text = tag_get_attr(tag, "text");
|
||||
|
||||
if (text) {
|
||||
widget = jbutton_new (TRANSLATE_ATTR (text));
|
||||
widget = jbutton_new(TRANSLATE_ATTR(text));
|
||||
if (widget) {
|
||||
Attr *left = tag_get_attr(tag, "left");
|
||||
Attr *right = tag_get_attr(tag, "right");
|
||||
|
|
@ -187,7 +187,7 @@ static JWidget convert_tag_to_widget(Tag *tag)
|
|||
Attr *text = tag_get_attr(tag, "text");
|
||||
|
||||
if (text) {
|
||||
widget = jlabel_new(TRANSLATE_ATTR (text));
|
||||
widget = jlabel_new(TRANSLATE_ATTR(text));
|
||||
if (widget) {
|
||||
Attr *center = tag_get_attr(tag, "center");
|
||||
Attr *right = tag_get_attr(tag, "right");
|
||||
|
|
@ -228,7 +228,7 @@ static JWidget convert_tag_to_widget(Tag *tag)
|
|||
|
||||
if (text && group && group->value) {
|
||||
widget = jradio_new(TRANSLATE_ATTR(text),
|
||||
strtol (group->value, NULL, 10));
|
||||
strtol(group->value, NULL, 10));
|
||||
if (widget) {
|
||||
Attr *center = tag_get_attr(tag, "center");
|
||||
Attr *right = tag_get_attr(tag, "right");
|
||||
|
|
@ -253,7 +253,7 @@ static JWidget convert_tag_to_widget(Tag *tag)
|
|||
Attr *horizontal = tag_get_attr(tag, "horizontal");
|
||||
Attr *vertical = tag_get_attr(tag, "vertical");
|
||||
|
||||
widget = ji_separator_new(text ? TRANSLATE_ATTR (text): NULL,
|
||||
widget = ji_separator_new(text ? TRANSLATE_ATTR(text): NULL,
|
||||
(horizontal ? JI_HORIZONTAL: 0) |
|
||||
(vertical ? JI_VERTICAL: 0) |
|
||||
(center ? JI_CENTER:
|
||||
|
|
@ -291,7 +291,7 @@ static JWidget convert_tag_to_widget(Tag *tag)
|
|||
if (desktop)
|
||||
widget = jwindow_new_desktop();
|
||||
else
|
||||
widget = jwindow_new(TRANSLATE_ATTR (text));
|
||||
widget = jwindow_new(TRANSLATE_ATTR(text));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -424,10 +424,10 @@ static JList read_tags(FILE *f)
|
|||
*s = 0;
|
||||
|
||||
/* create the new tag */
|
||||
tag = tag_new_from_string (open ? tag_start: tag_start+1);
|
||||
tag = tag_new_from_string(open ? tag_start: tag_start+1);
|
||||
|
||||
if (tag) {
|
||||
/* fprintf (stderr, "%s tag: %s (parent %s)\n", */
|
||||
/* fprintf(stderr, "%s tag: %s(parent %s)\n", */
|
||||
/* open ? "open": "close", */
|
||||
/* tag->name, */
|
||||
/* !jlist_empty(parent_stack) ? ((Tag *)parent_stack->data)->name: "ROOT"); */
|
||||
|
|
@ -454,7 +454,7 @@ static JList read_tags(FILE *f)
|
|||
}
|
||||
else {
|
||||
/* TODO error msg */
|
||||
/* printf ("you must open the tag before close it\n"); */
|
||||
/* printf("you must open the tag before close it\n"); */
|
||||
}
|
||||
|
||||
tag_free(tag);
|
||||
|
|
@ -467,8 +467,8 @@ static JList read_tags(FILE *f)
|
|||
Tag *tag = jlist_first(parent_stack)->data;
|
||||
|
||||
if (tag->text || IS_BLANK(*s)) {
|
||||
int len = tag->text ? strlen (tag->text): 0;
|
||||
tag->text = jrealloc (tag->text, len+2);
|
||||
int len = tag->text ? strlen(tag->text): 0;
|
||||
tag->text = jrealloc(tag->text, len+2);
|
||||
tag->text[len] = *s;
|
||||
tag->text[len+1] = 0;
|
||||
}
|
||||
|
|
@ -558,7 +558,7 @@ static Tag *tag_new_from_string(char *tag_string)
|
|||
|
||||
c = *s;
|
||||
*s = 0;
|
||||
name = jstrdup (name_beg);
|
||||
name = jstrdup(name_beg);
|
||||
*s = c;
|
||||
|
||||
if (*s == '=') {
|
||||
|
|
@ -578,7 +578,7 @@ static Tag *tag_new_from_string(char *tag_string)
|
|||
/* read the attribute-value */
|
||||
while (*s) {
|
||||
if (*s == '\\') {
|
||||
memmove (s, s+1, strlen (s)-1);
|
||||
memmove(s, s+1, strlen(s)-1);
|
||||
}
|
||||
else if (*s == '\"') {
|
||||
go_next = TRUE;
|
||||
|
|
@ -595,7 +595,7 @@ static Tag *tag_new_from_string(char *tag_string)
|
|||
|
||||
c = *s;
|
||||
*s = 0;
|
||||
value = jstrdup (value_beg);
|
||||
value = jstrdup(value_beg);
|
||||
*s = c;
|
||||
|
||||
if (go_next)
|
||||
|
|
@ -603,11 +603,11 @@ static Tag *tag_new_from_string(char *tag_string)
|
|||
}
|
||||
|
||||
/* create the attribute */
|
||||
attr = attr_new (name, value, translatable);
|
||||
attr = attr_new(name, value, translatable);
|
||||
|
||||
/* add the attribute to the tag */
|
||||
if (attr)
|
||||
tag_add_attr (tag, attr);
|
||||
tag_add_attr(tag, attr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -407,12 +407,12 @@ static bool enter_to_path_in_entry(void)
|
|||
ustrcpy(path, buf);
|
||||
|
||||
#ifdef HAVE_DRIVES
|
||||
if (ugetat (buf, -1) == DEVICE_SEPARATOR) {
|
||||
uinsert(path, ustrlen (path), OTHER_PATH_SEPARATOR);
|
||||
if (ugetat(buf, -1) == DEVICE_SEPARATOR) {
|
||||
uinsert(path, ustrlen(path), OTHER_PATH_SEPARATOR);
|
||||
ustrcat(buf, "./");
|
||||
}
|
||||
else if ((ugetat (buf, -1) == OTHER_PATH_SEPARATOR) &&
|
||||
(ugetat (buf, -2) == DEVICE_SEPARATOR)) {
|
||||
else if ((ugetat(buf, -1) == OTHER_PATH_SEPARATOR) &&
|
||||
(ugetat(buf, -2) == DEVICE_SEPARATOR)) {
|
||||
uremove(buf, -1);
|
||||
ustrcat(buf, "./");
|
||||
}
|
||||
|
|
@ -516,7 +516,7 @@ static void fill_listbox_with_files(char *path, int size)
|
|||
#else
|
||||
int drive = 0;
|
||||
#endif
|
||||
_al_getdcwd(drive, path, size - ucwidth (OTHER_PATH_SEPARATOR));
|
||||
_al_getdcwd(drive, path, size - ucwidth(OTHER_PATH_SEPARATOR));
|
||||
}
|
||||
|
||||
ch = ugetat(path, -1);
|
||||
|
|
@ -527,11 +527,11 @@ static void fill_listbox_with_files(char *path, int size)
|
|||
}
|
||||
}
|
||||
|
||||
replace_filename(buf, path, uconvert_ascii ("*.*", tmp), sizeof (buf));
|
||||
replace_filename(buf, path, uconvert_ascii("*.*", tmp), sizeof(buf));
|
||||
|
||||
/* clean the list boxes */
|
||||
|
||||
list = jwidget_get_children (listbox1);
|
||||
list = jwidget_get_children(listbox1);
|
||||
JI_LIST_FOR_EACH(list, link) {
|
||||
jmanager_free_widget(link->data);
|
||||
jwidget_remove_child(listbox1, link->data);
|
||||
|
|
@ -542,8 +542,8 @@ static void fill_listbox_with_files(char *path, int size)
|
|||
list = jwidget_get_children(listbox2);
|
||||
JI_LIST_FOR_EACH(list, link) {
|
||||
jmanager_free_widget(link->data);
|
||||
jwidget_remove_child (listbox2, link->data);
|
||||
jwidget_free (link->data);
|
||||
jwidget_remove_child(listbox2, link->data);
|
||||
jwidget_free(link->data);
|
||||
}
|
||||
jlist_free(list);
|
||||
|
||||
|
|
@ -578,7 +578,7 @@ static void generate_extensions(const char *exts)
|
|||
|
||||
extensions = jlist_new();
|
||||
|
||||
ustrzcpy(buf, sizeof (buf), exts);
|
||||
ustrzcpy(buf, sizeof(buf), exts);
|
||||
|
||||
for (tok = ustrtok(buf, ",;"); tok;
|
||||
tok = ustrtok(NULL, ",;")) {
|
||||
|
|
@ -687,12 +687,12 @@ static void fixup_filename(char *buf, char *from, const char *filename)
|
|||
|
||||
/* remove all double-slashes "//" */
|
||||
for (c=0, ch=-1; ch; ) {
|
||||
ch = ugetat (buf, c);
|
||||
ch = ugetat(buf, c);
|
||||
if ((ch == '/') || (ch == OTHER_PATH_SEPARATOR)) {
|
||||
ch = ugetat (buf, ++c);
|
||||
ch = ugetat(buf, ++c);
|
||||
while ((ch == '/') || (ch == OTHER_PATH_SEPARATOR)) {
|
||||
uremove (buf, c);
|
||||
ch = ugetat (buf, c);
|
||||
uremove(buf, c);
|
||||
ch = ugetat(buf, c);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -701,14 +701,14 @@ static void fixup_filename(char *buf, char *from, const char *filename)
|
|||
|
||||
/* remove all "/." */
|
||||
for (c=0, ch=-1; ; ) {
|
||||
ch = ugetat (buf, c);
|
||||
ch = ugetat(buf, c);
|
||||
|
||||
if ((ch == '/') || (ch == OTHER_PATH_SEPARATOR)) {
|
||||
ch = ugetat (buf, c+2);
|
||||
if ((ugetat (buf, c+1) == '.') &&
|
||||
ch = ugetat(buf, c+2);
|
||||
if ((ugetat(buf, c+1) == '.') &&
|
||||
((ch == 0) || (ch == '/') || (ch == OTHER_PATH_SEPARATOR))) {
|
||||
uremove (buf, c); /* `/' */
|
||||
uremove (buf, c); /* `.' */
|
||||
uremove(buf, c); /* `/' */
|
||||
uremove(buf, c); /* `.' */
|
||||
c--;
|
||||
}
|
||||
}
|
||||
|
|
@ -721,39 +721,39 @@ static void fixup_filename(char *buf, char *from, const char *filename)
|
|||
|
||||
/* fixup all "dir/.." */
|
||||
for (c=0, ch=-1; ; ) {
|
||||
ch = ugetat (buf, c);
|
||||
ch = ugetat(buf, c);
|
||||
|
||||
if ((ch == '/') || (ch == OTHER_PATH_SEPARATOR)) {
|
||||
ch = ugetat (buf, c+3);
|
||||
if ((ugetat (buf, c+1) == '.') &&
|
||||
(ugetat (buf, c+2) == '.') &&
|
||||
ch = ugetat(buf, c+3);
|
||||
if ((ugetat(buf, c+1) == '.') &&
|
||||
(ugetat(buf, c+2) == '.') &&
|
||||
((ch == 0) || (ch == '/') || (ch == OTHER_PATH_SEPARATOR))) {
|
||||
uremove (buf, c); /* `/' */
|
||||
uremove (buf, c); /* `.' */
|
||||
uremove (buf, c); /* `.' */
|
||||
uremove(buf, c); /* `/' */
|
||||
uremove(buf, c); /* `.' */
|
||||
uremove(buf, c); /* `.' */
|
||||
|
||||
/* remove the parent directory */
|
||||
|
||||
for (ch=-1; ((c >= 0) && (ch != '/') && (ch != OTHER_PATH_SEPARATOR)); )
|
||||
ch = ugetat (buf, --c);
|
||||
ch = ugetat(buf, --c);
|
||||
|
||||
c++;
|
||||
|
||||
ustrcpy (from, empty_string);
|
||||
ustrcpy(from, empty_string);
|
||||
|
||||
ch = ugetat (buf, c);
|
||||
ch = ugetat(buf, c);
|
||||
for (; ((ch) && (ch != '/') && (ch != OTHER_PATH_SEPARATOR)); ) {
|
||||
uinsert (from, ustrlen (from), ch);
|
||||
uinsert(from, ustrlen(from), ch);
|
||||
|
||||
uremove (buf, c);
|
||||
ch = ugetat (buf, c);
|
||||
uremove(buf, c);
|
||||
ch = ugetat(buf, c);
|
||||
}
|
||||
|
||||
c--;
|
||||
|
||||
if (c >= 0) {
|
||||
uremove (buf, c);
|
||||
ch = ugetat (buf, c--);
|
||||
uremove(buf, c);
|
||||
ch = ugetat(buf, c--);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -769,7 +769,7 @@ static void fixup_filename(char *buf, char *from, const char *filename)
|
|||
* ustricmp for filenames: makes sure that eg "foo.bar" comes before
|
||||
* "foo-1.bar", and also that "foo9.bar" comes before "foo10.bar".
|
||||
*/
|
||||
static int my_ustrfilecmp (const char *s1, const char *s2)
|
||||
static int my_ustrfilecmp(const char *s1, const char *s2)
|
||||
{
|
||||
int c1, c2;
|
||||
int x1, x2;
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ extern FONT_VTABLE *ji_font_vtable_aa;
|
|||
|
||||
/* helpers */
|
||||
|
||||
static void _font_reget_fixed_sizes (FONT *f)
|
||||
static void _font_reget_fixed_sizes(FONT *f)
|
||||
{
|
||||
FONT_AA_DATA *af = f->data;
|
||||
|
||||
|
|
@ -100,7 +100,7 @@ static void _font_reget_fixed_sizes (FONT *f)
|
|||
}
|
||||
}
|
||||
|
||||
static void _font_uncache_glyphs (FONT *f)
|
||||
static void _font_uncache_glyphs(FONT *f)
|
||||
{
|
||||
FONT_AA_DATA *af = f->data;
|
||||
|
||||
|
|
@ -111,11 +111,11 @@ static void _font_uncache_glyphs (FONT *f)
|
|||
if (af->cached_glyphs[i].is_cached) {
|
||||
af->cached_glyphs[i].is_cached = FALSE;
|
||||
if (af->cached_glyphs[i].bmp) {
|
||||
jfree (af->cached_glyphs[i].bmp);
|
||||
jfree(af->cached_glyphs[i].bmp);
|
||||
af->cached_glyphs[i].bmp = NULL;
|
||||
}
|
||||
if (af->cached_glyphs[i].aabmp) {
|
||||
jfree (af->cached_glyphs[i].aabmp);
|
||||
jfree(af->cached_glyphs[i].aabmp);
|
||||
af->cached_glyphs[i].aabmp = NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -123,19 +123,19 @@ static void _font_uncache_glyphs (FONT *f)
|
|||
}
|
||||
}
|
||||
|
||||
static void _font_delete_glyphs (FONT *f)
|
||||
static void _font_delete_glyphs(FONT *f)
|
||||
{
|
||||
FONT_AA_DATA *af = f->data;
|
||||
|
||||
_font_uncache_glyphs (f);
|
||||
_font_uncache_glyphs(f);
|
||||
|
||||
if (af->cached_glyphs) {
|
||||
jfree (af->cached_glyphs);
|
||||
jfree(af->cached_glyphs);
|
||||
af->cached_glyphs = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void _font_cache_glyph (AL_CONST FONT *f, int glyph_number)
|
||||
static void _font_cache_glyph(AL_CONST FONT *f, int glyph_number)
|
||||
{
|
||||
FONT_AA_DATA *af = f->data;
|
||||
|
||||
|
|
@ -143,8 +143,8 @@ static void _font_cache_glyph (AL_CONST FONT *f, int glyph_number)
|
|||
if (!af->cached_glyphs[glyph_number].is_cached) {
|
||||
FT_Glyph new_glyph;
|
||||
/* load the font glyph */
|
||||
FT_Load_Glyph (af->face, glyph_number, FT_LOAD_DEFAULT);
|
||||
FT_Get_Glyph (af->face->glyph, &new_glyph);
|
||||
FT_Load_Glyph(af->face, glyph_number, FT_LOAD_DEFAULT);
|
||||
FT_Get_Glyph(af->face->glyph, &new_glyph);
|
||||
|
||||
/* ok, this glyph is now cached */
|
||||
af->cached_glyphs[glyph_number].is_cached = TRUE;
|
||||
|
|
@ -180,7 +180,7 @@ static void _font_cache_glyph (AL_CONST FONT *f, int glyph_number)
|
|||
|
||||
/* allocate bitmap */
|
||||
af->cached_glyphs[glyph_number].bmp =
|
||||
jnew (unsigned char, ft_bmp->width * ft_bmp->rows);
|
||||
jnew(unsigned char, ft_bmp->width * ft_bmp->rows);
|
||||
|
||||
/* monochrome drawing */
|
||||
{
|
||||
|
|
@ -243,7 +243,7 @@ static void _font_cache_glyph (AL_CONST FONT *f, int glyph_number)
|
|||
|
||||
/* allocate bitmap */
|
||||
af->cached_glyphs[glyph_number].aabmp =
|
||||
jnew (unsigned char, ft_bmp->width * ft_bmp->rows);
|
||||
jnew(unsigned char, ft_bmp->width * ft_bmp->rows);
|
||||
|
||||
/* aa drawing */
|
||||
{
|
||||
|
|
@ -283,17 +283,17 @@ static void _font_cache_glyph (AL_CONST FONT *f, int glyph_number)
|
|||
af->cached_glyphs[glyph_number].advancey = af->face->glyph->advance.y >> 6;
|
||||
|
||||
/* delete the glyph */
|
||||
FT_Done_Glyph (new_glyph);
|
||||
FT_Done_Glyph(new_glyph);
|
||||
}
|
||||
}
|
||||
|
||||
static void _font_new_cache_glyph (FONT *f)
|
||||
static void _font_new_cache_glyph(FONT *f)
|
||||
{
|
||||
FONT_AA_DATA *af = f->data;
|
||||
int i;
|
||||
|
||||
if (!af->cached_glyphs)
|
||||
af->cached_glyphs = jnew (struct CACHED_GLYPH, af->face->num_glyphs);
|
||||
af->cached_glyphs = jnew(struct CACHED_GLYPH, af->face->num_glyphs);
|
||||
|
||||
for (i=0; i<af->face->num_glyphs; i++) {
|
||||
af->cached_glyphs[i].is_cached = FALSE;
|
||||
|
|
@ -304,7 +304,7 @@ static void _font_new_cache_glyph (FONT *f)
|
|||
|
||||
/* API */
|
||||
|
||||
int _ji_font_init (void)
|
||||
int _ji_font_init(void)
|
||||
{
|
||||
if (!ji_font_inited) {
|
||||
if (FT_Init_FreeType (&ft_library))
|
||||
|
|
@ -315,56 +315,56 @@ int _ji_font_init (void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void _ji_font_exit (void)
|
||||
void _ji_font_exit(void)
|
||||
{
|
||||
if (ji_font_inited) {
|
||||
FT_Done_FreeType (ft_library);
|
||||
FT_Done_FreeType(ft_library);
|
||||
|
||||
ji_font_inited = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
FONT *ji_font_load (const char *filepathname)
|
||||
FONT *ji_font_load(const char *filepathname)
|
||||
{
|
||||
FONT *f = ji_font_load_bmp (filepathname);
|
||||
FONT *f = ji_font_load_bmp(filepathname);
|
||||
if (!f)
|
||||
f = ji_font_load_ttf (filepathname);
|
||||
f = ji_font_load_ttf(filepathname);
|
||||
return f;
|
||||
}
|
||||
|
||||
FONT *ji_font_load_bmp (const char *filepathname)
|
||||
FONT *ji_font_load_bmp(const char *filepathname)
|
||||
{
|
||||
int old_color_conv = _color_conv;
|
||||
FONT *f = NULL;
|
||||
PALETTE junk;
|
||||
BITMAP *bmp;
|
||||
|
||||
set_color_conversion (COLORCONV_NONE);
|
||||
bmp = load_bitmap (filepathname, junk);
|
||||
set_color_conversion (old_color_conv);
|
||||
set_color_conversion(COLORCONV_NONE);
|
||||
bmp = load_bitmap(filepathname, junk);
|
||||
set_color_conversion(old_color_conv);
|
||||
|
||||
if (bmp) {
|
||||
f = _ji_bitmap2font (bmp);
|
||||
destroy_bitmap (bmp);
|
||||
f = _ji_bitmap2font(bmp);
|
||||
destroy_bitmap(bmp);
|
||||
}
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
FONT *ji_font_load_ttf (const char *filepathname)
|
||||
FONT *ji_font_load_ttf(const char *filepathname)
|
||||
{
|
||||
FONT_AA_DATA *af;
|
||||
int error;
|
||||
FONT *f;
|
||||
|
||||
/* try to allocate the memory */
|
||||
f = jmalloc (sizeof (FONT));
|
||||
f = jmalloc(sizeof(FONT));
|
||||
if (!f)
|
||||
return NULL;
|
||||
|
||||
f->data = af = jmalloc0 (sizeof (FONT_AA_DATA));
|
||||
f->data = af = jmalloc0(sizeof(FONT_AA_DATA));
|
||||
if (!f->data) {
|
||||
jfree (f);
|
||||
jfree(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -379,10 +379,10 @@ FONT *ji_font_load_ttf (const char *filepathname)
|
|||
af->data_size = 0;
|
||||
|
||||
/* load the font */
|
||||
error = FT_New_Face (ft_library, filepathname, 0, &af->face);
|
||||
error = FT_New_Face(ft_library, filepathname, 0, &af->face);
|
||||
if (error) {
|
||||
jfree (af);
|
||||
jfree (f);
|
||||
jfree(af);
|
||||
jfree(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -392,37 +392,37 @@ FONT *ji_font_load_ttf (const char *filepathname)
|
|||
else
|
||||
af->num_fixed_sizes = -1;
|
||||
|
||||
_font_new_cache_glyph (f);
|
||||
_font_new_cache_glyph(f);
|
||||
|
||||
if (af->num_fixed_sizes < 0) {
|
||||
af->fixed_sizes = jmalloc (sizeof (int));
|
||||
_font_reget_fixed_sizes (f);
|
||||
af->fixed_sizes = jmalloc(sizeof(int));
|
||||
_font_reget_fixed_sizes(f);
|
||||
|
||||
ji_font_set_size (f, 8);
|
||||
ji_font_set_size(f, 8);
|
||||
}
|
||||
else {
|
||||
af->fixed_sizes = jnew (int, af->num_fixed_sizes + 1);
|
||||
_font_reget_fixed_sizes (f);
|
||||
af->fixed_sizes = jnew(int, af->num_fixed_sizes + 1);
|
||||
_font_reget_fixed_sizes(f);
|
||||
|
||||
/* set as current size the first found fixed size */
|
||||
ji_font_set_size (f, af->fixed_sizes[0]);
|
||||
ji_font_set_size(f, af->fixed_sizes[0]);
|
||||
}
|
||||
|
||||
ji_font_set_char_extra_spacing (f, 0);
|
||||
ji_font_set_char_extra_spacing(f, 0);
|
||||
return f;
|
||||
}
|
||||
|
||||
int ji_font_get_size (FONT *f)
|
||||
int ji_font_get_size(FONT *f)
|
||||
{
|
||||
if (f->vtable == ji_font_vtable_aa) {
|
||||
FONT_AA_DATA *af = f->data;
|
||||
return af->face_h;
|
||||
}
|
||||
else
|
||||
return text_height (f);
|
||||
return text_height(f);
|
||||
}
|
||||
|
||||
int ji_font_set_size (FONT *f, int h)
|
||||
int ji_font_set_size(FONT *f, int h)
|
||||
{
|
||||
int error, test_h, direction;
|
||||
FONT_AA_DATA *af = f->data;
|
||||
|
|
@ -442,13 +442,13 @@ int ji_font_set_size (FONT *f, int h)
|
|||
direction = 0;
|
||||
while (1) {
|
||||
int real_height;
|
||||
error = FT_Set_Pixel_Sizes (af->face, 0, test_h);
|
||||
error = FT_Set_Pixel_Sizes(af->face, 0, test_h);
|
||||
if (error)
|
||||
break;
|
||||
|
||||
/* compare real height with asked height */
|
||||
real_height = abs (af->face->size->metrics.ascender >> 6)
|
||||
+ abs (af->face->size->metrics.descender >> 6);
|
||||
real_height = abs(af->face->size->metrics.ascender >> 6)
|
||||
+ abs(af->face->size->metrics.descender >> 6);
|
||||
if (real_height == h) {
|
||||
/* we found the wanted height */
|
||||
break;
|
||||
|
|
@ -467,7 +467,7 @@ int ji_font_set_size (FONT *f, int h)
|
|||
else if ((direction > 0) && (real_height > h)) {
|
||||
/* decrease one and found */
|
||||
test_h--;
|
||||
FT_Set_Pixel_Sizes (af->face, 0, test_h);
|
||||
FT_Set_Pixel_Sizes(af->face, 0, test_h);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -487,19 +487,19 @@ int ji_font_set_size (FONT *f, int h)
|
|||
}
|
||||
|
||||
if (!error) {
|
||||
_font_uncache_glyphs (f);
|
||||
_font_uncache_glyphs(f);
|
||||
af->face_h = h;
|
||||
af->real_face_h = test_h;
|
||||
af->face_ascender = af->face->size->metrics.ascender >> 6;
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
FT_Set_Pixel_Sizes (af->face, 0, af->real_face_h);
|
||||
FT_Set_Pixel_Sizes(af->face, 0, af->real_face_h);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int ji_font_get_aa_mode (struct FONT *f)
|
||||
int ji_font_get_aa_mode(struct FONT *f)
|
||||
{
|
||||
if (f->vtable == ji_font_vtable_aa) {
|
||||
FONT_AA_DATA *af = f->data;
|
||||
|
|
@ -509,7 +509,7 @@ int ji_font_get_aa_mode (struct FONT *f)
|
|||
return -1;
|
||||
}
|
||||
|
||||
int ji_font_set_aa_mode (struct FONT *f, int mode)
|
||||
int ji_font_set_aa_mode(struct FONT *f, int mode)
|
||||
{
|
||||
if (f->vtable == ji_font_vtable_aa) {
|
||||
FONT_AA_DATA *af = f->data;
|
||||
|
|
@ -521,7 +521,7 @@ int ji_font_set_aa_mode (struct FONT *f, int mode)
|
|||
return -1;
|
||||
}
|
||||
|
||||
bool ji_font_is_fixed (FONT *f)
|
||||
bool ji_font_is_fixed(FONT *f)
|
||||
{
|
||||
if (f->vtable == ji_font_vtable_aa) {
|
||||
FONT_AA_DATA *af = f->data;
|
||||
|
|
@ -535,7 +535,7 @@ bool ji_font_is_fixed (FONT *f)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
bool ji_font_is_scalable (FONT *f)
|
||||
bool ji_font_is_scalable(FONT *f)
|
||||
{
|
||||
if (f->vtable == ji_font_vtable_aa) {
|
||||
FONT_AA_DATA *af = f->data;
|
||||
|
|
@ -549,13 +549,13 @@ bool ji_font_is_scalable (FONT *f)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
const int *ji_font_get_available_fixed_sizes (FONT *f, int *n)
|
||||
const int *ji_font_get_available_fixed_sizes(FONT *f, int *n)
|
||||
{
|
||||
if (f->vtable == ji_font_vtable_aa) {
|
||||
FONT_AA_DATA *af = f->data;
|
||||
|
||||
/* we reget them just to make sure the contents where not changed */
|
||||
_font_reget_fixed_sizes (f);
|
||||
_font_reget_fixed_sizes(f);
|
||||
|
||||
if (n)
|
||||
*n = af->num_fixed_sizes;
|
||||
|
|
@ -563,10 +563,10 @@ const int *ji_font_get_available_fixed_sizes (FONT *f, int *n)
|
|||
return af->fixed_sizes;
|
||||
}
|
||||
else
|
||||
return NULL; /* TODO return text_height (...) size */
|
||||
return NULL; /* TODO return text_height(...) size */
|
||||
}
|
||||
|
||||
int ji_font_get_char_extra_spacing (FONT *f)
|
||||
int ji_font_get_char_extra_spacing(FONT *f)
|
||||
{
|
||||
if (f->vtable == ji_font_vtable_aa) {
|
||||
FONT_AA_DATA *af = f->data;
|
||||
|
|
@ -577,22 +577,22 @@ int ji_font_get_char_extra_spacing (FONT *f)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void ji_font_set_char_extra_spacing (FONT *f, int spacing)
|
||||
void ji_font_set_char_extra_spacing(FONT *f, int spacing)
|
||||
{
|
||||
if (f->vtable == ji_font_vtable_aa) {
|
||||
FONT_AA_DATA *af = f->data;
|
||||
|
||||
af->ch_spacing = MID (0, spacing, 4096);
|
||||
af->ch_spacing = MID(0, spacing, 4096);
|
||||
}
|
||||
}
|
||||
|
||||
int ji_font_char_len (FONT *f, int chr)
|
||||
int ji_font_char_len(FONT *f, int chr)
|
||||
{
|
||||
return f->vtable->char_length (f, chr);
|
||||
return f->vtable->char_length(f, chr);
|
||||
}
|
||||
|
||||
/* see jdraw_text */
|
||||
int ji_font_text_len (struct FONT *f, const char *s)
|
||||
int ji_font_text_len(struct FONT *f, const char *s)
|
||||
{
|
||||
int in_pos = 0;
|
||||
int pix_len = 0;
|
||||
|
|
@ -600,16 +600,16 @@ int ji_font_text_len (struct FONT *f, const char *s)
|
|||
|
||||
while ((c = ugetc(s+in_pos)) != 0) {
|
||||
if (c == '&') {
|
||||
in_pos += uwidth (s+in_pos);
|
||||
c = ugetc (s+in_pos);
|
||||
in_pos += uwidth(s+in_pos);
|
||||
c = ugetc(s+in_pos);
|
||||
if (c == '&') {
|
||||
pix_len += f->vtable->char_length (f, '&');
|
||||
in_pos += uwidth (s+in_pos);
|
||||
pix_len += f->vtable->char_length(f, '&');
|
||||
in_pos += uwidth(s+in_pos);
|
||||
}
|
||||
}
|
||||
else {
|
||||
pix_len += f->vtable->char_length (f, c);
|
||||
in_pos += uwidth (s+in_pos);
|
||||
pix_len += f->vtable->char_length(f, c);
|
||||
in_pos += uwidth(s+in_pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -619,14 +619,14 @@ int ji_font_text_len (struct FONT *f, const char *s)
|
|||
/* _aa_find_glyph:
|
||||
* Helper for aa vtable entries, below.
|
||||
*/
|
||||
static CACHED_GLYPH *_aa_find_glyph (AL_CONST FONT *f, int ch)
|
||||
static CACHED_GLYPH *_aa_find_glyph(AL_CONST FONT *f, int ch)
|
||||
{
|
||||
FONT_AA_DATA *af = f->data;
|
||||
int glyph_index;
|
||||
|
||||
/* get the character out of the font */
|
||||
if (af->face->charmap)
|
||||
glyph_index = FT_Get_Char_Index (af->face, ch);
|
||||
glyph_index = FT_Get_Char_Index(af->face, ch);
|
||||
else
|
||||
glyph_index = ch;
|
||||
|
||||
|
|
@ -638,7 +638,7 @@ static CACHED_GLYPH *_aa_find_glyph (AL_CONST FONT *f, int ch)
|
|||
}*/
|
||||
|
||||
/* cache */
|
||||
_font_cache_glyph (f, glyph_index);
|
||||
_font_cache_glyph(f, glyph_index);
|
||||
|
||||
return af->cached_glyphs + glyph_index;
|
||||
}
|
||||
|
|
@ -646,7 +646,7 @@ static CACHED_GLYPH *_aa_find_glyph (AL_CONST FONT *f, int ch)
|
|||
/* font_height:
|
||||
* Returns the height, in pixels of the font.
|
||||
*/
|
||||
static int aa_font_height (AL_CONST FONT *f)
|
||||
static int aa_font_height(AL_CONST FONT *f)
|
||||
{
|
||||
/* TODO */
|
||||
/* return f->height; */
|
||||
|
|
@ -659,9 +659,9 @@ static int aa_font_height (AL_CONST FONT *f)
|
|||
* Returns the length of a character, in pixels, as it would be rendered
|
||||
* in this font.
|
||||
*/
|
||||
static int aa_char_length (AL_CONST FONT *f, int ch)
|
||||
static int aa_char_length(AL_CONST FONT *f, int ch)
|
||||
{
|
||||
CACHED_GLYPH *g = _aa_find_glyph (f, ch);
|
||||
CACHED_GLYPH *g = _aa_find_glyph(f, ch);
|
||||
|
||||
/* return g->advancex ? g->advancex + af->ch_spacing: 0; */
|
||||
return g->advancex;
|
||||
|
|
@ -670,22 +670,22 @@ static int aa_char_length (AL_CONST FONT *f, int ch)
|
|||
/* aa_length:
|
||||
* Returns the length, in pixels, of a string as rendered in a font.
|
||||
*/
|
||||
static int aa_length (AL_CONST FONT *f, AL_CONST char *text)
|
||||
static int aa_length(AL_CONST FONT *f, AL_CONST char *text)
|
||||
{
|
||||
FONT_AA_DATA *af = f->data;
|
||||
AL_CONST char *p = text;
|
||||
int ch = 0, w = 0;
|
||||
|
||||
while ((ch = ugetxc (&p))) {
|
||||
w += f->vtable->char_length (f, ch)
|
||||
w += f->vtable->char_length(f, ch)
|
||||
+ af->ch_spacing;
|
||||
}
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
static void _aa_prepare_alpha_table (AL_CONST FONT *f, int color,
|
||||
int *alpha_table, int depth)
|
||||
static void _aa_prepare_alpha_table(AL_CONST FONT *f, int color,
|
||||
int *alpha_table, int depth)
|
||||
{
|
||||
AL_CONST FONT_AA_DATA *af = f->data;
|
||||
int i, r, g, b, br, bg, bb, ir, ig, ib;
|
||||
|
|
@ -693,18 +693,18 @@ static void _aa_prepare_alpha_table (AL_CONST FONT *f, int color,
|
|||
|
||||
/* if we are gonna use transparent mode, set blender */
|
||||
if (af->aa_mode < 0)
|
||||
drawing_mode (DRAW_MODE_TRANS, NULL, 0, 0);
|
||||
drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
|
||||
/* else if we are doing opaque mode, draw a rect and init our table*/
|
||||
else {
|
||||
/* get the color rgb */
|
||||
r = getr_depth (depth, color);
|
||||
g = getg_depth (depth, color);
|
||||
b = getb_depth (depth, color);
|
||||
r = getr_depth(depth, color);
|
||||
g = getg_depth(depth, color);
|
||||
b = getb_depth(depth, color);
|
||||
|
||||
/* get the background rgb */
|
||||
br = getr_depth (depth, af->aa_mode);
|
||||
bg = getg_depth (depth, af->aa_mode);
|
||||
bb = getb_depth (depth, af->aa_mode);
|
||||
br = getr_depth(depth, af->aa_mode);
|
||||
bg = getg_depth(depth, af->aa_mode);
|
||||
bb = getb_depth(depth, af->aa_mode);
|
||||
|
||||
/* get increments */
|
||||
if (r == br)
|
||||
|
|
@ -731,8 +731,8 @@ static void _aa_prepare_alpha_table (AL_CONST FONT *f, int color,
|
|||
if (i == 0)
|
||||
alpha_table[i] = -1;
|
||||
else
|
||||
alpha_table[i] = makecol_depth (depth,
|
||||
blendr >> 8, blendg >> 8, blendb >> 8);
|
||||
alpha_table[i] = makecol_depth(depth,
|
||||
blendr >> 8, blendg >> 8, blendb >> 8);
|
||||
|
||||
blendr += ir;
|
||||
blendg += ig;
|
||||
|
|
@ -741,8 +741,8 @@ static void _aa_prepare_alpha_table (AL_CONST FONT *f, int color,
|
|||
}
|
||||
}
|
||||
|
||||
static void _aa_render_glyph (BITMAP *bmp, FONT_AA_DATA *af, CACHED_GLYPH *g,
|
||||
int u, int v, int color, int *alpha_table)
|
||||
static void _aa_render_glyph(BITMAP *bmp, FONT_AA_DATA *af, CACHED_GLYPH *g,
|
||||
int u, int v, int color, int *alpha_table)
|
||||
{
|
||||
int max_bmp_x, max_bmp_y;
|
||||
unsigned char *bmp_p;
|
||||
|
|
@ -766,7 +766,7 @@ static void _aa_render_glyph (BITMAP *bmp, FONT_AA_DATA *af, CACHED_GLYPH *g,
|
|||
for (bmp_x=u; bmp_x<max_bmp_x; bmp_x++) {
|
||||
c = alpha_table[*bmp_p];
|
||||
if (c >= 0)
|
||||
putpixel (bmp, bmp_x, bmp_y, c);
|
||||
putpixel(bmp, bmp_x, bmp_y, c);
|
||||
bmp_p++;
|
||||
}
|
||||
}
|
||||
|
|
@ -776,8 +776,8 @@ static void _aa_render_glyph (BITMAP *bmp, FONT_AA_DATA *af, CACHED_GLYPH *g,
|
|||
/* copy the FT character bitmap to our dest one */
|
||||
for (bmp_y=v; bmp_y<max_bmp_y; bmp_y++) {
|
||||
for (bmp_x=u; bmp_x<max_bmp_x; bmp_x++) {
|
||||
set_trans_blender (0, 0, 0, *bmp_p);
|
||||
putpixel (bmp, bmp_x, bmp_y, color);
|
||||
set_trans_blender(0, 0, 0, *bmp_p);
|
||||
putpixel(bmp, bmp_x, bmp_y, color);
|
||||
bmp_p++;
|
||||
}
|
||||
}
|
||||
|
|
@ -797,9 +797,9 @@ static void _aa_render_glyph (BITMAP *bmp, FONT_AA_DATA *af, CACHED_GLYPH *g,
|
|||
for (bmp_y=u; bmp_y<max_bmp_y; bmp_y++) {
|
||||
for (bmp_x=v; bmp_x<max_bmp_x; bmp_x++) {
|
||||
if (*bmp_p)
|
||||
putpixel (bmp, bmp_x, bmp_y, color);
|
||||
putpixel(bmp, bmp_x, bmp_y, color);
|
||||
/* else if (af->aa_mode >= 0) */
|
||||
/* putpixel (bmp, bmp_x, bmp_y, af->aa_mode); */
|
||||
/* putpixel(bmp, bmp_x, bmp_y, af->aa_mode); */
|
||||
bmp_p++;
|
||||
}
|
||||
}
|
||||
|
|
@ -812,35 +812,35 @@ static void _aa_render_glyph (BITMAP *bmp, FONT_AA_DATA *af, CACHED_GLYPH *g,
|
|||
* mono; if bg == -1, render as transparent, else render as opaque.
|
||||
* Returns the character width, in pixels.
|
||||
*/
|
||||
static int aa_render_char (AL_CONST FONT *f, int ch, int fg, int bg, BITMAP *bmp, int x, int y)
|
||||
static int aa_render_char(AL_CONST FONT *f, int ch, int fg, int bg, BITMAP *bmp, int x, int y)
|
||||
{
|
||||
FONT_AA_DATA *af = f->data;
|
||||
CACHED_GLYPH *g = NULL;
|
||||
int w = 0;
|
||||
|
||||
acquire_bitmap (bmp);
|
||||
acquire_bitmap(bmp);
|
||||
|
||||
if (bg >= 0) {
|
||||
rectfill (bmp, x, y,
|
||||
x + f->vtable->char_length (f, ch) - 1,
|
||||
y + f->vtable->font_height (f) - 1, bg);
|
||||
rectfill(bmp, x, y,
|
||||
x + f->vtable->char_length(f, ch) - 1,
|
||||
y + f->vtable->font_height(f) - 1, bg);
|
||||
}
|
||||
|
||||
g = _aa_find_glyph (f, ch);
|
||||
g = _aa_find_glyph(f, ch);
|
||||
if (g) {
|
||||
int alpha_table[256];
|
||||
|
||||
_aa_prepare_alpha_table (f, fg, alpha_table, bitmap_color_depth (bmp));
|
||||
_aa_render_glyph (bmp, af, g, x, y, fg, alpha_table);
|
||||
_aa_prepare_alpha_table(f, fg, alpha_table, bitmap_color_depth(bmp));
|
||||
_aa_render_glyph(bmp, af, g, x, y, fg, alpha_table);
|
||||
|
||||
w += g->advancex;
|
||||
|
||||
/* reset blender */
|
||||
if (af->aa_mode < 0)
|
||||
solid_mode ();
|
||||
solid_mode();
|
||||
}
|
||||
|
||||
release_bitmap (bmp);
|
||||
release_bitmap(bmp);
|
||||
|
||||
return w;
|
||||
}
|
||||
|
|
@ -850,7 +850,7 @@ static int aa_render_char (AL_CONST FONT *f, int ch, int fg, int bg, BITMAP *bmp
|
|||
* the specified colors. If fg == -1, render as color, else render as
|
||||
* mono; if bg == -1, render as transparent, else render as opaque.
|
||||
*/
|
||||
static void aa_render (AL_CONST FONT *f, AL_CONST char *text, int fg, int bg, BITMAP *bmp, int x, int y)
|
||||
static void aa_render(AL_CONST FONT *f, AL_CONST char *text, int fg, int bg, BITMAP *bmp, int x, int y)
|
||||
{
|
||||
AL_CONST char *p = text;
|
||||
FONT_AA_DATA *af = f->data;
|
||||
|
|
@ -858,21 +858,21 @@ static void aa_render (AL_CONST FONT *f, AL_CONST char *text, int fg, int bg, BI
|
|||
int alpha_table[256];
|
||||
int ch = 0;
|
||||
|
||||
acquire_bitmap (bmp);
|
||||
acquire_bitmap(bmp);
|
||||
|
||||
if (bg >= 0) {
|
||||
rectfill (bmp, x, y,
|
||||
x + text_length (f, text) - 1,
|
||||
y + text_height (f) - 1, bg);
|
||||
rectfill(bmp, x, y,
|
||||
x + text_length(f, text) - 1,
|
||||
y + text_height(f) - 1, bg);
|
||||
bg = -1; /* to avoid filling rectangles for each character */
|
||||
}
|
||||
|
||||
_aa_prepare_alpha_table (f, fg, alpha_table, bitmap_color_depth (bmp));
|
||||
_aa_prepare_alpha_table(f, fg, alpha_table, bitmap_color_depth(bmp));
|
||||
|
||||
while ((ch = ugetxc (&p))) {
|
||||
g = _aa_find_glyph (f, ch);
|
||||
g = _aa_find_glyph(f, ch);
|
||||
if (g) {
|
||||
_aa_render_glyph (bmp, af, g, x, y, fg, alpha_table);
|
||||
_aa_render_glyph(bmp, af, g, x, y, fg, alpha_table);
|
||||
|
||||
if (g->advancex) x += g->advancex + af->ch_spacing;
|
||||
if (g->advancey) y += g->advancey + af->ch_spacing;
|
||||
|
|
@ -881,12 +881,12 @@ static void aa_render (AL_CONST FONT *f, AL_CONST char *text, int fg, int bg, BI
|
|||
|
||||
/* reset blender */
|
||||
if (af->aa_mode < 0)
|
||||
solid_mode ();
|
||||
solid_mode();
|
||||
|
||||
release_bitmap (bmp);
|
||||
release_bitmap(bmp);
|
||||
}
|
||||
|
||||
static void aa_destroy (FONT *f)
|
||||
static void aa_destroy(FONT *f)
|
||||
{
|
||||
FONT_AA_DATA *af;
|
||||
|
||||
|
|
@ -894,20 +894,20 @@ static void aa_destroy (FONT *f)
|
|||
af = f->data;
|
||||
|
||||
/* delete old glyphs */
|
||||
_font_delete_glyphs (f);
|
||||
_font_delete_glyphs(f);
|
||||
|
||||
/* delete the face */
|
||||
FT_Done_Face (af->face);
|
||||
FT_Done_Face(af->face);
|
||||
|
||||
if (af->fixed_sizes)
|
||||
jfree (af->fixed_sizes);
|
||||
jfree(af->fixed_sizes);
|
||||
|
||||
/* deallocate the data */
|
||||
if (af->data)
|
||||
jfree (af->data);
|
||||
jfree(af->data);
|
||||
|
||||
jfree (af);
|
||||
jfree (f);
|
||||
jfree(af);
|
||||
jfree(f);
|
||||
}
|
||||
|
||||
/********
|
||||
|
|
@ -930,100 +930,100 @@ FONT_VTABLE *ji_font_vtable_aa = &_ji_font_vtable_aa;
|
|||
#else /* without FreeType */
|
||||
/**********************************************************************/
|
||||
|
||||
int _ji_font_init (void)
|
||||
int _ji_font_init(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void _ji_font_exit (void)
|
||||
void _ji_font_exit(void)
|
||||
{
|
||||
}
|
||||
|
||||
FONT *ji_font_load (const char *filepathname)
|
||||
FONT *ji_font_load(const char *filepathname)
|
||||
{
|
||||
FONT *f = ji_font_load_bmp (filepathname);
|
||||
FONT *f = ji_font_load_bmp(filepathname);
|
||||
if (!f)
|
||||
f = ji_font_load_ttf (filepathname);
|
||||
f = ji_font_load_ttf(filepathname);
|
||||
return f;
|
||||
}
|
||||
|
||||
FONT *ji_font_load_bmp (const char *filepathname)
|
||||
FONT *ji_font_load_bmp(const char *filepathname)
|
||||
{
|
||||
int old_color_conv = _color_conv;
|
||||
FONT *f = NULL;
|
||||
PALETTE junk;
|
||||
BITMAP *bmp;
|
||||
|
||||
set_color_conversion (COLORCONV_NONE);
|
||||
bmp = load_bitmap (filepathname, junk);
|
||||
set_color_conversion (old_color_conv);
|
||||
set_color_conversion(COLORCONV_NONE);
|
||||
bmp = load_bitmap(filepathname, junk);
|
||||
set_color_conversion(old_color_conv);
|
||||
|
||||
if (bmp) {
|
||||
f = _ji_bitmap2font (bmp);
|
||||
destroy_bitmap (bmp);
|
||||
f = _ji_bitmap2font(bmp);
|
||||
destroy_bitmap(bmp);
|
||||
}
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
FONT *ji_font_load_ttf (const char *filepathname)
|
||||
FONT *ji_font_load_ttf(const char *filepathname)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int ji_font_get_size (FONT *f)
|
||||
int ji_font_get_size(FONT *f)
|
||||
{
|
||||
return text_height (f);
|
||||
return text_height(f);
|
||||
}
|
||||
|
||||
int ji_font_set_size (FONT *f, int h)
|
||||
int ji_font_set_size(FONT *f, int h)
|
||||
{
|
||||
/* do nothing */
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ji_font_get_aa_mode (struct FONT *f)
|
||||
int ji_font_get_aa_mode(struct FONT *f)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ji_font_set_aa_mode (struct FONT *f, int mode)
|
||||
int ji_font_set_aa_mode(struct FONT *f, int mode)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool ji_font_is_fixed (FONT *f)
|
||||
bool ji_font_is_fixed(FONT *f)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool ji_font_is_scalable (FONT *f)
|
||||
bool ji_font_is_scalable(FONT *f)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
const int *ji_font_get_available_fixed_sizes (FONT *f, int *n)
|
||||
const int *ji_font_get_available_fixed_sizes(FONT *f, int *n)
|
||||
{
|
||||
return NULL; /* TODO return text_height (...) size */
|
||||
return NULL; /* TODO return text_height(...) size */
|
||||
}
|
||||
|
||||
int ji_font_get_char_extra_spacing (FONT *f)
|
||||
int ji_font_get_char_extra_spacing(FONT *f)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ji_font_set_char_extra_spacing (FONT *f, int spacing)
|
||||
void ji_font_set_char_extra_spacing(FONT *f, int spacing)
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
int ji_font_char_len (FONT *f, int chr)
|
||||
int ji_font_char_len(FONT *f, int chr)
|
||||
{
|
||||
return f->vtable->char_length (f, chr);
|
||||
return f->vtable->char_length(f, chr);
|
||||
}
|
||||
|
||||
/* see jdraw_text */
|
||||
int ji_font_text_len (struct FONT *f, const char *s)
|
||||
int ji_font_text_len(struct FONT *f, const char *s)
|
||||
{
|
||||
int in_pos = 0;
|
||||
int pix_len = 0;
|
||||
|
|
@ -1031,16 +1031,16 @@ int ji_font_text_len (struct FONT *f, const char *s)
|
|||
|
||||
while ((c = ugetc(s+in_pos)) != 0) {
|
||||
if (c == '&') {
|
||||
in_pos += uwidth (s+in_pos);
|
||||
c = ugetc (s+in_pos);
|
||||
in_pos += uwidth(s+in_pos);
|
||||
c = ugetc(s+in_pos);
|
||||
if (c == '&') {
|
||||
pix_len += f->vtable->char_length (f, '&');
|
||||
in_pos += uwidth (s+in_pos);
|
||||
pix_len += f->vtable->char_length(f, '&');
|
||||
in_pos += uwidth(s+in_pos);
|
||||
}
|
||||
}
|
||||
else {
|
||||
pix_len += f->vtable->char_length (f, c);
|
||||
in_pos += uwidth (s+in_pos);
|
||||
pix_len += f->vtable->char_length(f, c);
|
||||
in_pos += uwidth(s+in_pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ static int bitmap_font_count(BITMAP* bmp)
|
|||
return num;
|
||||
}
|
||||
|
||||
FONT *_ji_bitmap2font (BITMAP *bmp)
|
||||
FONT *_ji_bitmap2font(BITMAP *bmp)
|
||||
{
|
||||
FONT *f;
|
||||
int begin = ' ';
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
#include "jinete/jtheme.h"
|
||||
#include "jinete/jwidget.h"
|
||||
|
||||
static bool image_msg_proc (JWidget widget, JMessage msg);
|
||||
static bool image_msg_proc(JWidget widget, JMessage msg);
|
||||
|
||||
JWidget jimage_new(BITMAP *bmp, int align)
|
||||
{
|
||||
|
|
@ -60,7 +60,7 @@ static bool image_msg_proc(JWidget widget, JMessage msg)
|
|||
struct jrect box, text, icon;
|
||||
|
||||
jwidget_get_texticon_info(widget, &box, &text, &icon,
|
||||
jwidget_get_align (widget),
|
||||
jwidget_get_align(widget),
|
||||
bmp->w, bmp->h);
|
||||
|
||||
msg->reqsize.w = widget->border_width.l + jrect_w(&box) + widget->border_width.r;
|
||||
|
|
@ -73,7 +73,7 @@ static bool image_msg_proc(JWidget widget, JMessage msg)
|
|||
struct jrect box, text, icon;
|
||||
|
||||
jwidget_get_texticon_info(widget, &box, &text, &icon,
|
||||
jwidget_get_align (widget),
|
||||
jwidget_get_align(widget),
|
||||
bmp->w, bmp->h);
|
||||
|
||||
jdraw_rectexclude(widget->rc, &icon,
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "jinete/jmanager.h"
|
||||
#include "jinete/jtheme.h"
|
||||
#include "jinete/jwidget.h"
|
||||
|
|
@ -39,7 +41,7 @@ static JWidget *widgets = NULL;
|
|||
|
||||
JWidget _ji_get_widget_by_id(JID widget_id)
|
||||
{
|
||||
/* ji_assert ((widget_id >= 0) && (widget_id < nwidgets)); */
|
||||
assert((widget_id >= 0) && (widget_id < nwidgets));
|
||||
|
||||
return widgets[widget_id];
|
||||
}
|
||||
|
|
@ -57,13 +59,13 @@ JWidget _ji_get_new_widget(void)
|
|||
/* first widget */
|
||||
if (!widgets) {
|
||||
nwidgets = 2;
|
||||
widgets = (JWidget *)jmalloc (sizeof (JWidget) * nwidgets);
|
||||
widgets = (JWidget *)jmalloc(sizeof(JWidget) * nwidgets);
|
||||
|
||||
/* id=0 no widget */
|
||||
widgets[0] = NULL;
|
||||
|
||||
/* id>0 all widgets */
|
||||
widgets[1] = (JWidget)jnew (struct jwidget, 1);
|
||||
widgets[1] = (JWidget)jnew(struct jwidget, 1);
|
||||
widgets[1]->id = widget_id = 1;
|
||||
}
|
||||
else {
|
||||
|
|
@ -78,9 +80,9 @@ JWidget _ji_get_new_widget(void)
|
|||
/* we need make other widget? */
|
||||
if (widget_id == nwidgets) {
|
||||
nwidgets++;
|
||||
widgets = (JWidget *)jrealloc (widgets,
|
||||
sizeof (JWidget) * nwidgets);
|
||||
widgets[widget_id] = (JWidget)jnew (struct jwidget, 1);
|
||||
widgets = (JWidget *)jrealloc(widgets,
|
||||
sizeof(JWidget) * nwidgets);
|
||||
widgets[widget_id] = (JWidget)jnew(struct jwidget, 1);
|
||||
}
|
||||
|
||||
/* using this */
|
||||
|
|
@ -101,9 +103,9 @@ void _ji_free_all_widgets(void)
|
|||
|
||||
if (nwidgets) {
|
||||
for (c=0; c<nwidgets; c++)
|
||||
jfree (widgets[c]);
|
||||
jfree(widgets[c]);
|
||||
|
||||
jfree (widgets);
|
||||
jfree(widgets);
|
||||
widgets = NULL;
|
||||
nwidgets = 0;
|
||||
}
|
||||
|
|
@ -118,7 +120,7 @@ bool _ji_is_valid_widget(JWidget widget)
|
|||
widgets[widget->id]->id == widget->id);
|
||||
}
|
||||
|
||||
void _ji_set_font_of_all_widgets (struct FONT *f)
|
||||
void _ji_set_font_of_all_widgets(struct FONT *f)
|
||||
{
|
||||
int c, l, t, r, b;
|
||||
|
||||
|
|
@ -129,8 +131,8 @@ void _ji_set_font_of_all_widgets (struct FONT *f)
|
|||
r = widgets[c]->border_width.r;
|
||||
b = widgets[c]->border_width.b;
|
||||
|
||||
jwidget_set_font (widgets[c], f);
|
||||
jwidget_init_theme (widgets[c]);
|
||||
jwidget_set_font(widgets[c], f);
|
||||
jwidget_init_theme(widgets[c]);
|
||||
|
||||
widgets[c]->border_width.l = l;
|
||||
widgets[c]->border_width.t = t;
|
||||
|
|
@ -141,10 +143,10 @@ void _ji_set_font_of_all_widgets (struct FONT *f)
|
|||
for (c=0; c<nwidgets; c++)
|
||||
if (_ji_is_valid_widget (widgets[c])) {
|
||||
if (widgets[c]->type == JI_WINDOW)
|
||||
jwindow_remap (widgets[c]);
|
||||
jwindow_remap(widgets[c]);
|
||||
}
|
||||
|
||||
jmanager_refresh_screen ();
|
||||
jmanager_refresh_screen();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
#include "jinete/jtheme.h"
|
||||
#include "jinete/jwidget.h"
|
||||
|
||||
static bool label_msg_proc (JWidget widget, JMessage msg);
|
||||
static bool label_msg_proc(JWidget widget, JMessage msg);
|
||||
|
||||
JWidget jlabel_new(const char *text)
|
||||
{
|
||||
|
|
@ -53,8 +53,8 @@ static bool label_msg_proc(JWidget widget, JMessage msg)
|
|||
|
||||
case JM_REQSIZE:
|
||||
if (widget->text) {
|
||||
msg->reqsize.w = jwidget_get_text_length (widget);
|
||||
msg->reqsize.h = jwidget_get_text_height (widget);
|
||||
msg->reqsize.w = jwidget_get_text_length(widget);
|
||||
msg->reqsize.h = jwidget_get_text_height(widget);
|
||||
}
|
||||
else
|
||||
msg->reqsize.w = msg->reqsize.h = 0;
|
||||
|
|
|
|||
|
|
@ -50,23 +50,23 @@ static void listitem_request_size(JWidget widget, int *w, int *h);
|
|||
|
||||
JWidget jlistbox_new(void)
|
||||
{
|
||||
JWidget widget = jwidget_new (JI_LISTBOX);
|
||||
JWidget widget = jwidget_new(JI_LISTBOX);
|
||||
|
||||
jwidget_add_hook (widget, JI_LISTBOX, listbox_msg_proc, NULL);
|
||||
jwidget_focusrest (widget, TRUE);
|
||||
jwidget_init_theme (widget);
|
||||
jwidget_add_hook(widget, JI_LISTBOX, listbox_msg_proc, NULL);
|
||||
jwidget_focusrest(widget, TRUE);
|
||||
jwidget_init_theme(widget);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
JWidget jlistitem_new(const char *text)
|
||||
{
|
||||
JWidget widget = jwidget_new (JI_LISTITEM);
|
||||
JWidget widget = jwidget_new(JI_LISTITEM);
|
||||
|
||||
jwidget_add_hook (widget, JI_LISTITEM, listitem_msg_proc, NULL);
|
||||
jwidget_set_align (widget, JI_LEFT | JI_MIDDLE);
|
||||
jwidget_set_text (widget, text);
|
||||
jwidget_init_theme (widget);
|
||||
jwidget_add_hook(widget, JI_LISTITEM, listitem_msg_proc, NULL);
|
||||
jwidget_set_align(widget, JI_LEFT | JI_MIDDLE);
|
||||
jwidget_set_text(widget, text);
|
||||
jwidget_init_theme(widget);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
|
@ -123,11 +123,11 @@ void jlistbox_select_child(JWidget widget, JWidget listitem)
|
|||
jview_get_scroll(view, &scroll_x, &scroll_y);
|
||||
|
||||
if (listitem->rc->y1 < vp->y1)
|
||||
jview_set_scroll (view, scroll_x, listitem->rc->y1 - widget->rc->y1);
|
||||
jview_set_scroll(view, scroll_x, listitem->rc->y1 - widget->rc->y1);
|
||||
else if (listitem->rc->y1 > vp->y2 - jrect_h(listitem->rc))
|
||||
jview_set_scroll (view, scroll_x,
|
||||
listitem->rc->y1 - widget->rc->y1
|
||||
- jrect_h(vp) + jrect_h(listitem->rc));
|
||||
jview_set_scroll(view, scroll_x,
|
||||
listitem->rc->y1 - widget->rc->y1
|
||||
- jrect_h(vp) + jrect_h(listitem->rc));
|
||||
|
||||
jrect_free(vp);
|
||||
}
|
||||
|
|
@ -153,12 +153,12 @@ void jlistbox_center_scroll(JWidget widget)
|
|||
JRect vp = jview_get_viewport_position(view);
|
||||
int scroll_x, scroll_y;
|
||||
|
||||
jview_get_scroll (view, &scroll_x, &scroll_y);
|
||||
jview_set_scroll (view,
|
||||
scroll_x,
|
||||
(listitem->rc->y1 - widget->rc->y1)
|
||||
- jrect_h(vp)/2 + jrect_h(listitem->rc)/2);
|
||||
jrect_free (vp);
|
||||
jview_get_scroll(view, &scroll_x, &scroll_y);
|
||||
jview_set_scroll(view,
|
||||
scroll_x,
|
||||
(listitem->rc->y1 - widget->rc->y1)
|
||||
- jrect_h(vp)/2 + jrect_h(listitem->rc)/2);
|
||||
jrect_free(vp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -167,61 +167,61 @@ static bool listbox_msg_proc(JWidget widget, JMessage msg)
|
|||
switch (msg->type) {
|
||||
|
||||
case JM_REQSIZE:
|
||||
listbox_request_size (widget, &msg->reqsize.w, &msg->reqsize.h);
|
||||
listbox_request_size(widget, &msg->reqsize.w, &msg->reqsize.h);
|
||||
return TRUE;
|
||||
|
||||
case JM_SETPOS:
|
||||
listbox_set_position (widget, &msg->setpos.rect);
|
||||
listbox_set_position(widget, &msg->setpos.rect);
|
||||
return TRUE;
|
||||
|
||||
case JM_DIRTYCHILDREN:
|
||||
listbox_dirty_children (widget);
|
||||
listbox_dirty_children(widget);
|
||||
return TRUE;
|
||||
|
||||
case JM_OPEN:
|
||||
jlistbox_center_scroll (widget);
|
||||
jlistbox_center_scroll(widget);
|
||||
break;
|
||||
|
||||
case JM_BUTTONPRESSED:
|
||||
jwidget_capture_mouse (widget);
|
||||
jwidget_capture_mouse(widget);
|
||||
|
||||
case JM_MOTION:
|
||||
if (jwidget_has_capture (widget)) {
|
||||
int select = jlistbox_get_selected_index (widget);
|
||||
JWidget view = jwidget_get_view (widget);
|
||||
if (jwidget_has_capture(widget)) {
|
||||
int select = jlistbox_get_selected_index(widget);
|
||||
JWidget view = jwidget_get_view(widget);
|
||||
bool pick_item = TRUE;
|
||||
|
||||
if (view) {
|
||||
JRect vp = jview_get_viewport_position (view);
|
||||
JRect vp = jview_get_viewport_position(view);
|
||||
|
||||
if (msg->mouse.y < vp->y1) {
|
||||
int num = MAX (1, (vp->y1 - msg->mouse.y) / 8);
|
||||
jlistbox_select_index (widget, select-num);
|
||||
int num = MAX(1, (vp->y1 - msg->mouse.y) / 8);
|
||||
jlistbox_select_index(widget, select-num);
|
||||
pick_item = FALSE;
|
||||
}
|
||||
else if (msg->mouse.y >= vp->y2) {
|
||||
int num = MAX (1, (msg->mouse.y - (vp->y2-1)) / 8);
|
||||
jlistbox_select_index (widget, select+num);
|
||||
int num = MAX(1, (msg->mouse.y - (vp->y2-1)) / 8);
|
||||
jlistbox_select_index(widget, select+num);
|
||||
pick_item = FALSE;
|
||||
}
|
||||
|
||||
jrect_free (vp);
|
||||
jrect_free(vp);
|
||||
}
|
||||
|
||||
if (pick_item) {
|
||||
JWidget picked;
|
||||
|
||||
if (view) {
|
||||
picked = jwidget_pick (jview_get_viewport (view),
|
||||
msg->mouse.x, msg->mouse.y);
|
||||
picked = jwidget_pick(jview_get_viewport(view),
|
||||
msg->mouse.x, msg->mouse.y);
|
||||
}
|
||||
else {
|
||||
picked = jwidget_pick (widget, msg->mouse.x, msg->mouse.y);
|
||||
picked = jwidget_pick(widget, msg->mouse.x, msg->mouse.y);
|
||||
}
|
||||
|
||||
/* if the picked widget is a child of the list, select it */
|
||||
if (picked && jwidget_has_child (widget, picked))
|
||||
jlistbox_select_child (widget, picked);
|
||||
if (picked && jwidget_has_child(widget, picked))
|
||||
jlistbox_select_child(widget, picked);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
|
@ -229,11 +229,11 @@ static bool listbox_msg_proc(JWidget widget, JMessage msg)
|
|||
break;
|
||||
|
||||
case JM_BUTTONRELEASED:
|
||||
jwidget_release_mouse (widget);
|
||||
jwidget_release_mouse(widget);
|
||||
break;
|
||||
|
||||
case JM_WHEEL: {
|
||||
JWidget view = jwidget_get_view (widget);
|
||||
JWidget view = jwidget_get_view(widget);
|
||||
if (view) {
|
||||
int scroll_x, scroll_y;
|
||||
|
||||
|
|
@ -270,7 +270,7 @@ static bool listbox_msg_proc(JWidget widget, JMessage msg)
|
|||
if (view) {
|
||||
JRect vp = jview_get_viewport_position(view);
|
||||
select -= jrect_h(vp) / jwidget_get_text_height(widget);
|
||||
jrect_free (vp);
|
||||
jrect_free(vp);
|
||||
}
|
||||
else
|
||||
select = 0;
|
||||
|
|
@ -426,8 +426,8 @@ static void listitem_request_size(JWidget widget, int *w, int *h)
|
|||
JI_LIST_FOR_EACH(widget->children, link) {
|
||||
jwidget_request_size(link->data, &req_w, &req_h);
|
||||
|
||||
max_w = MAX (max_w, req_w);
|
||||
max_h = MAX (max_h, req_h);
|
||||
max_w = MAX(max_w, req_w);
|
||||
max_h = MAX(max_h, req_h);
|
||||
}
|
||||
|
||||
*w = widget->border_width.l + max_w + widget->border_width.r;
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ typedef struct Timer {
|
|||
int last_time;
|
||||
} Timer;
|
||||
|
||||
#define NFILTERS (JM_REGISTERED_MESSAGES+1)
|
||||
#define NFILTERS (JM_REGISTERED_MESSAGES+1)
|
||||
|
||||
typedef struct Filter {
|
||||
int message;
|
||||
|
|
@ -324,7 +324,7 @@ bool jmanager_generate_messages(JWidget manager)
|
|||
generate_proc_windows_list();
|
||||
}
|
||||
|
||||
/* generate_proc_windows_list (manager); */
|
||||
/* generate_proc_windows_list(manager); */
|
||||
if (jlist_empty(proc_windows_list))
|
||||
generate_proc_windows_list();
|
||||
|
||||
|
|
@ -449,12 +449,12 @@ bool jmanager_generate_messages(JWidget manager)
|
|||
JWidget win_manager = window ? jwidget_get_manager(window): NULL;
|
||||
|
||||
if ((window) &&
|
||||
(!jwindow_is_desktop (window)) &&
|
||||
(!jwindow_is_desktop(window)) &&
|
||||
(window != TOPWND(win_manager))) {
|
||||
/* put it in the top of the list */
|
||||
jlist_remove(win_manager->children, window);
|
||||
|
||||
if (jwindow_is_ontop (window))
|
||||
if (jwindow_is_ontop(window))
|
||||
jlist_prepend(win_manager->children, window);
|
||||
else {
|
||||
int pos = jlist_length(win_manager->children);
|
||||
|
|
@ -521,13 +521,16 @@ bool jmanager_generate_messages(JWidget manager)
|
|||
/* timers */
|
||||
if (n_timers > 0) {
|
||||
int t = ji_clock;
|
||||
int count;
|
||||
|
||||
for (c=0; c<n_timers; ++c) {
|
||||
if (timers[c] && timers[c]->last_time >= 0) {
|
||||
count = 0;
|
||||
while (t - timers[c]->last_time > timers[c]->interval) {
|
||||
timers[c]->last_time += timers[c]->interval;
|
||||
|
||||
msg = jmessage_new(JM_TIMER);
|
||||
msg->timer.count = count;
|
||||
msg->timer.timer_id = c;
|
||||
jmessage_add_dest(msg, timers[c]->widget);
|
||||
jmanager_enqueue_message(msg);
|
||||
|
|
@ -721,7 +724,7 @@ void jmanager_set_focus(JWidget widget)
|
|||
else
|
||||
link = jlist_first(widget_parents);
|
||||
|
||||
msg = jmessage_new (JM_FOCUSENTER);
|
||||
msg = jmessage_new(JM_FOCUSENTER);
|
||||
|
||||
for (; link != widget_parents->end; link=link->next) {
|
||||
JWidget w = (JWidget)link->data;
|
||||
|
|
@ -1250,7 +1253,7 @@ static void manager_redraw_region(JWidget widget, JRegion region)
|
|||
JRegion reg3;
|
||||
JLink link;
|
||||
|
||||
/* TODO intersect with jwidget_get_drawable_region ()??? */
|
||||
/* TODO intersect with jwidget_get_drawable_region()??? */
|
||||
jregion_intersect(reg1, region, reg2);
|
||||
|
||||
/* redraw windows from top to background */
|
||||
|
|
@ -1447,7 +1450,7 @@ static bool move_focus(JWidget manager, JMessage msg)
|
|||
/* one at least */
|
||||
if (count > 0) {
|
||||
/* list of widgets */
|
||||
list = jmalloc (sizeof (JWidget) * count);
|
||||
list = jmalloc(sizeof(JWidget) * count);
|
||||
if (!list)
|
||||
return ret;
|
||||
|
||||
|
|
@ -1524,10 +1527,10 @@ static bool move_focus(JWidget manager, JMessage msg)
|
|||
break;
|
||||
}
|
||||
|
||||
jfree (list);
|
||||
jfree(list);
|
||||
|
||||
if ((focus) && (focus != focus_widget))
|
||||
jmanager_set_focus (focus);
|
||||
jmanager_set_focus(focus);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -983,19 +983,19 @@ static bool menuitem_msg_proc(JWidget widget, JMessage msg)
|
|||
|
||||
static void menuitem_request_size(JWidget widget, int *w, int *h)
|
||||
{
|
||||
MenuItem *menuitem = MITEM (widget);
|
||||
MenuItem *menuitem = MITEM(widget);
|
||||
int bar = widget->parent->parent->type == JI_MENUBAR;
|
||||
|
||||
if (widget->text) {
|
||||
*w =
|
||||
+ widget->border_width.l
|
||||
+ jwidget_get_text_length (widget)
|
||||
+ jwidget_get_text_length(widget)
|
||||
+ ((bar) ? widget->child_spacing/4: widget->child_spacing)
|
||||
+ widget->border_width.r;
|
||||
|
||||
*h =
|
||||
+ widget->border_width.t
|
||||
+ jwidget_get_text_height (widget)
|
||||
+ jwidget_get_text_height(widget)
|
||||
+ widget->border_width.b;
|
||||
|
||||
if (menuitem->accel) {
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ struct jmessage_key
|
|||
struct jmessage_draw
|
||||
{
|
||||
struct jmessage_any any;
|
||||
int count; /* cound=0 if it's last msg of draw-chains */
|
||||
int count; /* cound=0 if it's last msg of draw-chain */
|
||||
struct jrect rect; /* area to draw */
|
||||
};
|
||||
|
||||
|
|
@ -96,6 +96,7 @@ struct jmessage_signal
|
|||
struct jmessage_timer
|
||||
{
|
||||
struct jmessage_any any;
|
||||
int count; /* cound=0 if it's first msg of timer-chain */
|
||||
int timer_id; /* number of timer */
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -238,8 +238,8 @@ static void panel_request_size(JWidget widget, int *w, int *h)
|
|||
{
|
||||
#define GET_CHILD_SIZE(w, h) \
|
||||
do { \
|
||||
*w = MAX (*w, req_##w); \
|
||||
*h = MAX (*h, req_##h); \
|
||||
*w = MAX(*w, req_##w); \
|
||||
*h = MAX(*h, req_##h); \
|
||||
} while(0)
|
||||
|
||||
#define FINAL_SIZE(w) \
|
||||
|
|
@ -297,10 +297,10 @@ static void panel_set_position(JWidget widget, JRect rect)
|
|||
pos->y##1 = widget->rc->y##1; \
|
||||
pos->x##2 = pos->x##1 + avail*panel->pos/100; \
|
||||
/* TODO uncomment this to make a restricted panel */ \
|
||||
/* pos->w = MID (req1_##w, pos->w, avail-req2_##w); */ \
|
||||
/* pos->w = MID(req1_##w, pos->w, avail-req2_##w); */ \
|
||||
pos->y##2 = pos->y##1 + jrect_##h(widget->rc); \
|
||||
\
|
||||
jwidget_set_rect (child1, pos); \
|
||||
jwidget_set_rect(child1, pos); \
|
||||
\
|
||||
pos->x##1 = child1->rc->x##1 + jrect_##w(child1->rc) \
|
||||
+ widget->child_spacing; \
|
||||
|
|
@ -308,14 +308,14 @@ static void panel_set_position(JWidget widget, JRect rect)
|
|||
pos->x##2 = pos->x##1 + avail - jrect_##w(child1->rc); \
|
||||
pos->y##2 = pos->y##1 + jrect_##h(widget->rc); \
|
||||
\
|
||||
jwidget_set_rect (child2, pos); \
|
||||
jwidget_set_rect(child2, pos); \
|
||||
} while(0)
|
||||
|
||||
JRect pos = jrect_new(0, 0, 0, 0);
|
||||
Panel *panel = jwidget_get_data(widget, JI_PANEL);
|
||||
int avail;
|
||||
|
||||
jrect_copy (widget->rc, rect);
|
||||
jrect_copy(widget->rc, rect);
|
||||
|
||||
if (jlist_length(widget->children) == 2) {
|
||||
JWidget child1 = jlist_first(widget->children)->data;
|
||||
|
|
|
|||
|
|
@ -39,39 +39,39 @@
|
|||
|
||||
typedef struct QuickData
|
||||
{
|
||||
void (*quick_handler) (JWidget widget, int user_data);
|
||||
void (*quick_handler)(JWidget widget, int user_data);
|
||||
int user_data;
|
||||
} QuickData;
|
||||
|
||||
static void process_quickmenu (JWidget menu, JQuickMenu quick_menu);
|
||||
static bool quickmenu_msg_proc (JWidget widget, JMessage msg);
|
||||
static void process_quickmenu(JWidget menu, JQuickMenu quick_menu);
|
||||
static bool quickmenu_msg_proc(JWidget widget, JMessage msg);
|
||||
|
||||
static int quickmenu_type (void)
|
||||
static int quickmenu_type(void)
|
||||
{
|
||||
static int type = 0;
|
||||
if (!type)
|
||||
type = ji_register_widget_type ();
|
||||
type = ji_register_widget_type();
|
||||
return type;
|
||||
}
|
||||
|
||||
JWidget jmenubar_new_quickmenu (JQuickMenu quick_menu)
|
||||
JWidget jmenubar_new_quickmenu(JQuickMenu quick_menu)
|
||||
{
|
||||
JWidget menubar = jmenubar_new ();
|
||||
JWidget menu = jmenu_new ();
|
||||
JWidget menubar = jmenubar_new();
|
||||
JWidget menu = jmenu_new();
|
||||
|
||||
jmenubar_set_menu (menubar, menu);
|
||||
process_quickmenu (menu, quick_menu);
|
||||
jmenubar_set_menu(menubar, menu);
|
||||
process_quickmenu(menu, quick_menu);
|
||||
|
||||
return menubar;
|
||||
}
|
||||
|
||||
JWidget jmenubox_new_quickmenu (JQuickMenu quick_menu)
|
||||
JWidget jmenubox_new_quickmenu(JQuickMenu quick_menu)
|
||||
{
|
||||
JWidget menubox = jmenubox_new ();
|
||||
JWidget menu = jmenu_new ();
|
||||
JWidget menubox = jmenubox_new();
|
||||
JWidget menu = jmenu_new();
|
||||
|
||||
jmenubox_set_menu (menubox, menu);
|
||||
process_quickmenu (menu, quick_menu);
|
||||
jmenubox_set_menu(menubox, menu);
|
||||
process_quickmenu(menu, quick_menu);
|
||||
|
||||
return menubox;
|
||||
}
|
||||
|
|
@ -87,21 +87,21 @@ static void process_quickmenu(JWidget menu, JQuickMenu quick_menu)
|
|||
for (c=0; quick_menu[c].level >= 0; c++) {
|
||||
if (old_level < quick_menu[c].level) {
|
||||
if (menuitem) {
|
||||
menu = jmenu_new ();
|
||||
jmenuitem_set_submenu (menuitem, menu);
|
||||
menu = jmenu_new();
|
||||
jmenuitem_set_submenu(menuitem, menu);
|
||||
jlist_append(parent, menu);
|
||||
}
|
||||
}
|
||||
else {
|
||||
while (old_level > quick_menu[c].level) {
|
||||
old_level--;
|
||||
jlist_remove (parent, jlist_last (parent)->data);
|
||||
jlist_remove(parent, jlist_last(parent)->data);
|
||||
}
|
||||
}
|
||||
|
||||
/* normal menu item */
|
||||
if (quick_menu[c].text) {
|
||||
menuitem = jmenuitem_new (quick_menu[c].text);
|
||||
menuitem = jmenuitem_new(quick_menu[c].text);
|
||||
|
||||
if (quick_menu[c].accel) {
|
||||
JAccel accel = jaccel_new();
|
||||
|
|
@ -110,18 +110,18 @@ static void process_quickmenu(JWidget menu, JQuickMenu quick_menu)
|
|||
}
|
||||
|
||||
if (quick_menu[c].quick_handler) {
|
||||
QuickData *quick_data = jnew (QuickData, 1);
|
||||
QuickData *quick_data = jnew(QuickData, 1);
|
||||
|
||||
quick_data->quick_handler = quick_menu[c].quick_handler;
|
||||
quick_data->user_data = quick_menu[c].user_data;
|
||||
|
||||
jwidget_add_hook (menuitem, quickmenu_type (),
|
||||
quickmenu_msg_proc, quick_data);
|
||||
jwidget_add_hook(menuitem, quickmenu_type(),
|
||||
quickmenu_msg_proc, quick_data);
|
||||
}
|
||||
}
|
||||
/* separator */
|
||||
else {
|
||||
menuitem = ji_separator_new (NULL, JI_HORIZONTAL);
|
||||
menuitem = ji_separator_new(NULL, JI_HORIZONTAL);
|
||||
}
|
||||
|
||||
jwidget_add_child((JWidget)jlist_last(parent)->data, menuitem);
|
||||
|
|
@ -132,18 +132,18 @@ static void process_quickmenu(JWidget menu, JQuickMenu quick_menu)
|
|||
jlist_free(parent);
|
||||
}
|
||||
|
||||
static bool quickmenu_msg_proc (JWidget widget, JMessage msg)
|
||||
static bool quickmenu_msg_proc(JWidget widget, JMessage msg)
|
||||
{
|
||||
switch (msg->type) {
|
||||
|
||||
case JM_DESTROY:
|
||||
jfree (jwidget_get_data (widget, quickmenu_type ()));
|
||||
jfree(jwidget_get_data(widget, quickmenu_type()));
|
||||
break;
|
||||
|
||||
case JM_SIGNAL:
|
||||
if (msg->signal.num == JI_SIGNAL_MENUITEM_SELECT) {
|
||||
QuickData *quick_data = jwidget_get_data (widget, quickmenu_type ());
|
||||
(*quick_data->quick_handler) (widget, quick_data->user_data);
|
||||
QuickData *quick_data = jwidget_get_data(widget, quickmenu_type());
|
||||
(*quick_data->quick_handler)(widget, quick_data->user_data);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -31,11 +31,11 @@
|
|||
|
||||
#include "jinete/jrect.h"
|
||||
|
||||
JRect jrect_new (int x1, int y1, int x2, int y2)
|
||||
JRect jrect_new(int x1, int y1, int x2, int y2)
|
||||
{
|
||||
JRect rect;
|
||||
|
||||
rect = jnew (struct jrect, 1);
|
||||
rect = jnew(struct jrect, 1);
|
||||
if (!rect)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -47,17 +47,17 @@ JRect jrect_new (int x1, int y1, int x2, int y2)
|
|||
return rect;
|
||||
}
|
||||
|
||||
JRect jrect_new_copy (const JRect rect)
|
||||
JRect jrect_new_copy(const JRect rect)
|
||||
{
|
||||
return jrect_new (rect->x1, rect->y1, rect->x2, rect->y2);
|
||||
return jrect_new(rect->x1, rect->y1, rect->x2, rect->y2);
|
||||
}
|
||||
|
||||
void jrect_free (JRect rect)
|
||||
void jrect_free(JRect rect)
|
||||
{
|
||||
jfree (rect);
|
||||
jfree(rect);
|
||||
}
|
||||
|
||||
void jrect_copy (JRect dst, const JRect src)
|
||||
void jrect_copy(JRect dst, const JRect src)
|
||||
{
|
||||
dst->x1 = src->x1;
|
||||
dst->y1 = src->y1;
|
||||
|
|
@ -65,7 +65,7 @@ void jrect_copy (JRect dst, const JRect src)
|
|||
dst->y2 = src->y2;
|
||||
}
|
||||
|
||||
void jrect_replace (JRect rect, int x1, int y1, int x2, int y2)
|
||||
void jrect_replace(JRect rect, int x1, int y1, int x2, int y2)
|
||||
{
|
||||
rect->x1 = x1;
|
||||
rect->y1 = y1;
|
||||
|
|
@ -73,29 +73,29 @@ void jrect_replace (JRect rect, int x1, int y1, int x2, int y2)
|
|||
rect->y2 = y2;
|
||||
}
|
||||
|
||||
void jrect_union (JRect r1, const JRect r2)
|
||||
void jrect_union(JRect r1, const JRect r2)
|
||||
{
|
||||
r1->x1 = MIN (r1->x1, r2->x1);
|
||||
r1->y1 = MIN (r1->y1, r2->y1);
|
||||
r1->x2 = MAX (r1->x2, r2->x2);
|
||||
r1->y2 = MAX (r1->y2, r2->y2);
|
||||
r1->x1 = MIN(r1->x1, r2->x1);
|
||||
r1->y1 = MIN(r1->y1, r2->y1);
|
||||
r1->x2 = MAX(r1->x2, r2->x2);
|
||||
r1->y2 = MAX(r1->y2, r2->y2);
|
||||
}
|
||||
|
||||
bool jrect_intersect (JRect r1, const JRect r2)
|
||||
bool jrect_intersect(JRect r1, const JRect r2)
|
||||
{
|
||||
if (!((r1->x2 <= r2->x1) || (r1->x1 >= r2->x2) ||
|
||||
(r1->y2 <= r2->y1) || (r1->y1 >= r2->y2))) {
|
||||
r1->x1 = MAX (r1->x1, r2->x1);
|
||||
r1->y1 = MAX (r1->y1, r2->y1);
|
||||
r1->x2 = MIN (r1->x2, r2->x2);
|
||||
r1->y2 = MIN (r1->y2, r2->y2);
|
||||
r1->x1 = MAX(r1->x1, r2->x1);
|
||||
r1->y1 = MAX(r1->y1, r2->y1);
|
||||
r1->x2 = MIN(r1->x2, r2->x2);
|
||||
r1->y2 = MIN(r1->y2, r2->y2);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void jrect_shrink (JRect rect, int border)
|
||||
void jrect_shrink(JRect rect, int border)
|
||||
{
|
||||
rect->x1 += border;
|
||||
rect->y1 += border;
|
||||
|
|
@ -103,7 +103,7 @@ void jrect_shrink (JRect rect, int border)
|
|||
rect->y2 -= border;
|
||||
}
|
||||
|
||||
void jrect_stretch (JRect rect, int border)
|
||||
void jrect_stretch(JRect rect, int border)
|
||||
{
|
||||
rect->x1 -= border;
|
||||
rect->y1 -= border;
|
||||
|
|
@ -111,7 +111,7 @@ void jrect_stretch (JRect rect, int border)
|
|||
rect->y2 += border;
|
||||
}
|
||||
|
||||
void jrect_moveto (JRect rect, int x, int y)
|
||||
void jrect_moveto(JRect rect, int x, int y)
|
||||
{
|
||||
rect->x2 += x-rect->x1;
|
||||
rect->y2 += y-rect->y1;
|
||||
|
|
@ -119,7 +119,7 @@ void jrect_moveto (JRect rect, int x, int y)
|
|||
rect->y1 = y;
|
||||
}
|
||||
|
||||
void jrect_displace (JRect rect, int dx, int dy)
|
||||
void jrect_displace(JRect rect, int dx, int dy)
|
||||
{
|
||||
rect->x1 += dx;
|
||||
rect->y1 += dy;
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ struct ji_point { int x, y; };
|
|||
#define miRegionAppend jregion_append
|
||||
#define miRegionValidate jregion_validate
|
||||
|
||||
/* JRegion jrects_to_region (int nrects, JRect *prect, int ctype); */
|
||||
/* JRegion jrects_to_region(int nrects, JRect *prect, int ctype); */
|
||||
|
||||
#define miSubtract jregion_subtract
|
||||
#define miInverse jregion_inverse
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ bool jregion_union(JRegion new, JRegion reg1, JRegion reg2);
|
|||
bool jregion_append(JRegion dstrgn, JRegion rgn);
|
||||
bool jregion_validate(JRegion badreg, bool *overlap);
|
||||
|
||||
/* JRegion jrects_to_region (int nrects, JRect *prect, int ctype); */
|
||||
/* JRegion jrects_to_region(int nrects, JRect *prect, int ctype); */
|
||||
|
||||
bool jregion_subtract(JRegion regD, JRegion regM, JRegion regS);
|
||||
bool jregion_inverse(JRegion newReg, JRegion reg1, JRect invRect);
|
||||
|
|
|
|||
|
|
@ -35,21 +35,21 @@
|
|||
#include "jinete/jtheme.h"
|
||||
#include "jinete/jwidget.h"
|
||||
|
||||
static bool separator_msg_proc (JWidget widget, JMessage msg);
|
||||
static bool separator_msg_proc(JWidget widget, JMessage msg);
|
||||
|
||||
JWidget ji_separator_new (const char *text, int align)
|
||||
JWidget ji_separator_new(const char *text, int align)
|
||||
{
|
||||
JWidget widget = jwidget_new (JI_SEPARATOR);
|
||||
JWidget widget = jwidget_new(JI_SEPARATOR);
|
||||
|
||||
jwidget_add_hook (widget, JI_SEPARATOR, separator_msg_proc, NULL);
|
||||
jwidget_set_align (widget, align);
|
||||
jwidget_set_text (widget, text);
|
||||
jwidget_init_theme (widget);
|
||||
jwidget_add_hook(widget, JI_SEPARATOR, separator_msg_proc, NULL);
|
||||
jwidget_set_align(widget, align);
|
||||
jwidget_set_text(widget, text);
|
||||
jwidget_init_theme(widget);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
static bool separator_msg_proc (JWidget widget, JMessage msg)
|
||||
static bool separator_msg_proc(JWidget widget, JMessage msg)
|
||||
{
|
||||
switch (msg->type) {
|
||||
|
||||
|
|
@ -63,13 +63,13 @@ static bool separator_msg_proc (JWidget widget, JMessage msg)
|
|||
JI_LIST_FOR_EACH(widget->children, link) {
|
||||
child = (JWidget)link->data;
|
||||
|
||||
jwidget_request_size (child, &req_w, &req_h);
|
||||
max_w = MAX (max_w, req_w);
|
||||
max_h = MAX (max_h, req_h);
|
||||
jwidget_request_size(child, &req_w, &req_h);
|
||||
max_w = MAX(max_w, req_w);
|
||||
max_h = MAX(max_h, req_h);
|
||||
}
|
||||
|
||||
if (widget->text)
|
||||
max_w = MAX (max_w, jwidget_get_text_length (widget));
|
||||
max_w = MAX(max_w, jwidget_get_text_length(widget));
|
||||
|
||||
msg->reqsize.w = widget->border_width.l + max_w + widget->border_width.r;
|
||||
msg->reqsize.h = widget->border_width.t + max_h + widget->border_width.b;
|
||||
|
|
|
|||
|
|
@ -46,59 +46,59 @@ typedef struct Slider
|
|||
int value;
|
||||
} Slider;
|
||||
|
||||
static bool slider_msg_proc (JWidget widget, JMessage msg);
|
||||
static void slider_request_size (JWidget widget, int *w, int *h);
|
||||
static bool slider_msg_proc(JWidget widget, JMessage msg);
|
||||
static void slider_request_size(JWidget widget, int *w, int *h);
|
||||
|
||||
JWidget jslider_new (int min, int max, int value)
|
||||
JWidget jslider_new(int min, int max, int value)
|
||||
{
|
||||
JWidget widget = jwidget_new (JI_SLIDER);
|
||||
Slider *slider = jnew (Slider, 1);
|
||||
JWidget widget = jwidget_new(JI_SLIDER);
|
||||
Slider *slider = jnew(Slider, 1);
|
||||
|
||||
slider->min = min;
|
||||
slider->max = max;
|
||||
slider->value = MID (min, value, max);
|
||||
slider->value = MID(min, value, max);
|
||||
|
||||
jwidget_add_hook (widget, JI_SLIDER, slider_msg_proc, slider);
|
||||
jwidget_focusrest (widget, TRUE);
|
||||
jwidget_init_theme (widget);
|
||||
jwidget_add_hook(widget, JI_SLIDER, slider_msg_proc, slider);
|
||||
jwidget_focusrest(widget, TRUE);
|
||||
jwidget_init_theme(widget);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
void jslider_set_range (JWidget widget, int min, int max)
|
||||
void jslider_set_range(JWidget widget, int min, int max)
|
||||
{
|
||||
Slider *slider = jwidget_get_data (widget, JI_SLIDER);
|
||||
Slider *slider = jwidget_get_data(widget, JI_SLIDER);
|
||||
|
||||
slider->min = min;
|
||||
slider->max = max;
|
||||
slider->value = MID (min, slider->value, max);
|
||||
slider->value = MID(min, slider->value, max);
|
||||
|
||||
jwidget_dirty (widget);
|
||||
jwidget_dirty(widget);
|
||||
}
|
||||
|
||||
void jslider_set_value (JWidget widget, int value)
|
||||
void jslider_set_value(JWidget widget, int value)
|
||||
{
|
||||
Slider *slider = jwidget_get_data (widget, JI_SLIDER);
|
||||
Slider *slider = jwidget_get_data(widget, JI_SLIDER);
|
||||
int old_value = slider->value;
|
||||
|
||||
slider->value = MID (slider->min, value, slider->max);
|
||||
slider->value = MID(slider->min, value, slider->max);
|
||||
|
||||
if (slider->value != old_value)
|
||||
jwidget_dirty (widget);
|
||||
jwidget_dirty(widget);
|
||||
|
||||
/* it DOES NOT emit CHANGE signal! to avoid recursive calls */
|
||||
}
|
||||
|
||||
int jslider_get_value (JWidget widget)
|
||||
int jslider_get_value(JWidget widget)
|
||||
{
|
||||
Slider *slider = jwidget_get_data (widget, JI_SLIDER);
|
||||
Slider *slider = jwidget_get_data(widget, JI_SLIDER);
|
||||
|
||||
return slider->value;
|
||||
}
|
||||
|
||||
void jtheme_slider_info (JWidget widget, int *min, int *max, int *value)
|
||||
void jtheme_slider_info(JWidget widget, int *min, int *max, int *value)
|
||||
{
|
||||
Slider *slider = jwidget_get_data (widget, JI_SLIDER);
|
||||
Slider *slider = jwidget_get_data(widget, JI_SLIDER);
|
||||
|
||||
if (min) *min = slider->min;
|
||||
if (max) *max = slider->max;
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ static bool textbox_msg_proc(JWidget widget, JMessage msg)
|
|||
switch (msg->type) {
|
||||
|
||||
case JM_REQSIZE:
|
||||
textbox_request_size (widget, &msg->reqsize.w, &msg->reqsize.h);
|
||||
textbox_request_size(widget, &msg->reqsize.w, &msg->reqsize.h);
|
||||
return TRUE;
|
||||
|
||||
case JM_SIGNAL:
|
||||
|
|
@ -123,7 +123,7 @@ static bool textbox_msg_proc(JWidget widget, JMessage msg)
|
|||
break;
|
||||
|
||||
default:
|
||||
jrect_free (vp);
|
||||
jrect_free(vp);
|
||||
return FALSE;
|
||||
}
|
||||
jrect_free(vp);
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ JTheme jtheme_new(void)
|
|||
{
|
||||
JTheme theme;
|
||||
|
||||
theme = jmalloc(sizeof (struct jtheme));
|
||||
theme = jmalloc(sizeof(struct jtheme));
|
||||
if (!theme)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -108,7 +108,7 @@ void jtheme_set_method(JTheme theme, int widget_type, JDrawFunc draw_widget)
|
|||
|
||||
theme->nmethods = widget_type+1;
|
||||
theme->methods = jrealloc(theme->methods,
|
||||
sizeof (JDrawFunc) * theme->nmethods);
|
||||
sizeof(JDrawFunc) * theme->nmethods);
|
||||
|
||||
for (c=old_nmethods; c<theme->nmethods; c++)
|
||||
theme->methods[c] = NULL;
|
||||
|
|
@ -312,7 +312,7 @@ void _ji_theme_textbox_draw(BITMAP *bmp, JWidget widget, int *w, int *h)
|
|||
int width;
|
||||
|
||||
if (view) {
|
||||
JRect vp = jview_get_viewport_position (view);
|
||||
JRect vp = jview_get_viewport_position(view);
|
||||
x1 = vp->x1;
|
||||
y1 = vp->y1;
|
||||
viewport_w = jrect_w(vp);
|
||||
|
|
@ -368,7 +368,7 @@ void _ji_theme_textbox_draw(BITMAP *bmp, JWidget widget, int *w, int *h)
|
|||
|
||||
/* without word-wrap */
|
||||
if (!(widget->align & JI_WORDWRAP)) {
|
||||
end = ustrchr (beg, '\n');
|
||||
end = ustrchr(beg, '\n');
|
||||
if (end) {
|
||||
chr = *end;
|
||||
*end = 0;
|
||||
|
|
@ -434,7 +434,7 @@ void _ji_theme_textbox_draw(BITMAP *bmp, JWidget widget, int *w, int *h)
|
|||
|
||||
/* width */
|
||||
if (w)
|
||||
*w = MAX (*w, len);
|
||||
*w = MAX(*w, len);
|
||||
|
||||
y += textheight;
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ static void scrollbar_info(JWidget widget, int *_pos, int *_len,
|
|||
|
||||
static void displace_widgets(JWidget widget, int x, int y);
|
||||
|
||||
JWidget jview_new (void)
|
||||
JWidget jview_new(void)
|
||||
{
|
||||
JWidget widget = jwidget_new(JI_VIEW);
|
||||
View *view = jnew(View, 1);
|
||||
|
|
@ -149,7 +149,7 @@ void jview_set_size(JWidget widget, int w, int h)
|
|||
- view->viewport->border_width.r) && \
|
||||
(BAR_SIZE < jrect_##w(pos)) && (BAR_SIZE < jrect_##h(pos)))
|
||||
|
||||
View *view = jwidget_get_data (widget, JI_VIEW);
|
||||
View *view = jwidget_get_data(widget, JI_VIEW);
|
||||
JRect pos, rect;
|
||||
|
||||
view->max_w = w;
|
||||
|
|
@ -164,31 +164,31 @@ void jview_set_size(JWidget widget, int w, int h)
|
|||
if (view->hasbars) {
|
||||
if (CHECK (w, h, l, t, r, b)) {
|
||||
pos->y2 -= BAR_SIZE;
|
||||
jwidget_add_child (widget, view->scrollbar_h);
|
||||
jwidget_add_child(widget, view->scrollbar_h);
|
||||
|
||||
if (CHECK (h, w, t, l, b, r)) {
|
||||
pos->x2 -= BAR_SIZE;
|
||||
if (CHECK (w, h, l, t, r, b))
|
||||
jwidget_add_child (widget, view->scrollbar_v);
|
||||
jwidget_add_child(widget, view->scrollbar_v);
|
||||
else {
|
||||
pos->x2 += BAR_SIZE;
|
||||
pos->y2 += BAR_SIZE;
|
||||
jwidget_remove_child (widget, view->scrollbar_h);
|
||||
jwidget_remove_child(widget, view->scrollbar_h);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (CHECK (h, w, t, l, b, r)) {
|
||||
pos->x2 -= BAR_SIZE;
|
||||
jwidget_add_child (widget, view->scrollbar_v);
|
||||
jwidget_add_child(widget, view->scrollbar_v);
|
||||
|
||||
if (CHECK (w, h, l, t, r, b)) {
|
||||
pos->y2 -= BAR_SIZE;
|
||||
if (CHECK (h, w, t, l, b, r))
|
||||
jwidget_add_child (widget, view->scrollbar_h);
|
||||
jwidget_add_child(widget, view->scrollbar_h);
|
||||
else {
|
||||
pos->x2 += BAR_SIZE;
|
||||
pos->y2 += BAR_SIZE;
|
||||
jwidget_remove_child (widget, view->scrollbar_v);
|
||||
jwidget_remove_child(widget, view->scrollbar_v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -236,8 +236,8 @@ void jview_set_scroll(JWidget widget, int x, int y)
|
|||
- view->viewport->border_width.t
|
||||
- view->viewport->border_width.b;
|
||||
|
||||
view->scroll_x = MID(0, x, MAX (0, view->max_w - avail_w));
|
||||
view->scroll_y = MID(0, y, MAX (0, view->max_h - avail_h));
|
||||
view->scroll_x = MID(0, x, MAX(0, view->max_w - avail_w));
|
||||
view->scroll_y = MID(0, y, MAX(0, view->max_h - avail_h));
|
||||
|
||||
if ((view->scroll_x == old_x) && (view->scroll_y == old_y))
|
||||
return;
|
||||
|
|
@ -254,7 +254,7 @@ void jview_get_scroll(JWidget widget, int *x, int *y)
|
|||
*y = view->scroll_y;
|
||||
}
|
||||
|
||||
void jview_get_max_size (JWidget widget, int *w, int *h)
|
||||
void jview_get_max_size(JWidget widget, int *w, int *h)
|
||||
{
|
||||
View *view = jwidget_get_data(widget, JI_VIEW);
|
||||
|
||||
|
|
@ -349,7 +349,7 @@ static bool view_msg_proc(JWidget widget, JMessage msg)
|
|||
}
|
||||
|
||||
case JM_REQSIZE: {
|
||||
View *view = jwidget_get_data (widget, JI_VIEW);
|
||||
View *view = jwidget_get_data(widget, JI_VIEW);
|
||||
|
||||
jwidget_request_size(view->viewport,
|
||||
&msg->reqsize.w,
|
||||
|
|
@ -424,8 +424,8 @@ static void viewport_needed_size(JWidget widget, int *w, int *h)
|
|||
JI_LIST_FOR_EACH(widget->children, link) {
|
||||
jwidget_request_size((JWidget)link->data, &req_w, &req_h);
|
||||
|
||||
*w = MAX (*w, req_w);
|
||||
*h = MAX (*h, req_h);
|
||||
*w = MAX(*w, req_w);
|
||||
*h = MAX(*h, req_h);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -484,13 +484,13 @@ static bool scrollbar_msg_proc(JWidget widget, JMessage msg)
|
|||
switch (msg->type) {
|
||||
|
||||
case JM_BUTTONPRESSED: {
|
||||
View *view = jwidget_get_data (widget->parent, JI_VIEW);
|
||||
View *view = jwidget_get_data(widget->parent, JI_VIEW);
|
||||
int x1, y1, x2, y2;
|
||||
int u1, v1, u2, v2;
|
||||
int ret = FALSE;
|
||||
int pos, len;
|
||||
|
||||
jtheme_scrollbar_info (widget, &pos, &len);
|
||||
jtheme_scrollbar_info(widget, &pos, &len);
|
||||
|
||||
view->wherepos = pos;
|
||||
view->whereclick = widget->align & JI_HORIZONTAL ? msg->mouse.x:
|
||||
|
|
@ -508,41 +508,41 @@ static bool scrollbar_msg_proc(JWidget widget, JMessage msg)
|
|||
|
||||
if (widget->align & JI_HORIZONTAL) {
|
||||
/* in the bar */
|
||||
if (MOUSE_IN (u1+pos, v1, u1+pos+len-1, v2)) {
|
||||
if (MOUSE_IN(u1+pos, v1, u1+pos+len-1, v2)) {
|
||||
/* capture mouse */
|
||||
}
|
||||
/* left */
|
||||
else if (MOUSE_IN (x1, y1, u1+pos-1, y2)) {
|
||||
jview_set_scroll (widget->parent,
|
||||
view->scroll_x - jrect_w(view->viewport->rc)/2,
|
||||
view->scroll_y);
|
||||
else if (MOUSE_IN(x1, y1, u1+pos-1, y2)) {
|
||||
jview_set_scroll(widget->parent,
|
||||
view->scroll_x - jrect_w(view->viewport->rc)/2,
|
||||
view->scroll_y);
|
||||
ret = TRUE;
|
||||
}
|
||||
/* right */
|
||||
else if (MOUSE_IN (u1+pos+len, y1, x2, y2)) {
|
||||
jview_set_scroll (widget->parent,
|
||||
view->scroll_x + jrect_w(view->viewport->rc)/2,
|
||||
view->scroll_y);
|
||||
else if (MOUSE_IN(u1+pos+len, y1, x2, y2)) {
|
||||
jview_set_scroll(widget->parent,
|
||||
view->scroll_x + jrect_w(view->viewport->rc)/2,
|
||||
view->scroll_y);
|
||||
ret = TRUE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* in the bar */
|
||||
if (MOUSE_IN (u1, v1+pos, u2, v1+pos+len-1)) {
|
||||
if (MOUSE_IN(u1, v1+pos, u2, v1+pos+len-1)) {
|
||||
/* capture mouse */
|
||||
}
|
||||
/* left */
|
||||
else if (MOUSE_IN (x1, y1, x2, v1+pos-1)) {
|
||||
jview_set_scroll (widget->parent,
|
||||
view->scroll_x,
|
||||
view->scroll_y - jrect_h(view->viewport->rc)/2);
|
||||
else if (MOUSE_IN(x1, y1, x2, v1+pos-1)) {
|
||||
jview_set_scroll(widget->parent,
|
||||
view->scroll_x,
|
||||
view->scroll_y - jrect_h(view->viewport->rc)/2);
|
||||
ret = TRUE;
|
||||
}
|
||||
/* right */
|
||||
else if (MOUSE_IN (x1, v1+pos+len, x2, y2)) {
|
||||
jview_set_scroll (widget->parent,
|
||||
view->scroll_x,
|
||||
view->scroll_y + jrect_h(view->viewport->rc)/2);
|
||||
else if (MOUSE_IN(x1, v1+pos+len, x2, y2)) {
|
||||
jview_set_scroll(widget->parent,
|
||||
view->scroll_x,
|
||||
view->scroll_y + jrect_h(view->viewport->rc)/2);
|
||||
ret = TRUE;
|
||||
}
|
||||
}
|
||||
|
|
@ -550,24 +550,24 @@ static bool scrollbar_msg_proc(JWidget widget, JMessage msg)
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
jwidget_select (widget);
|
||||
jwidget_capture_mouse (widget);
|
||||
jwidget_select(widget);
|
||||
jwidget_capture_mouse(widget);
|
||||
}
|
||||
|
||||
case JM_MOTION:
|
||||
if (jwidget_has_capture (widget)) {
|
||||
View *view = jwidget_get_data (widget->parent, JI_VIEW);
|
||||
View *view = jwidget_get_data(widget->parent, JI_VIEW);
|
||||
int pos, len, bar_size, viewport_size;
|
||||
int old_pos;
|
||||
|
||||
scrollbar_info (widget, &pos, &len,
|
||||
&bar_size, &viewport_size);
|
||||
scrollbar_info(widget, &pos, &len,
|
||||
&bar_size, &viewport_size);
|
||||
old_pos = pos;
|
||||
|
||||
if (bar_size > len) {
|
||||
if (widget->align & JI_HORIZONTAL) {
|
||||
pos = (view->wherepos + msg->mouse.x - view->whereclick);
|
||||
pos = MID (0, pos, bar_size - len);
|
||||
pos = MID(0, pos, bar_size - len);
|
||||
|
||||
jview_set_scroll
|
||||
(widget->parent,
|
||||
|
|
@ -576,7 +576,7 @@ static bool scrollbar_msg_proc(JWidget widget, JMessage msg)
|
|||
}
|
||||
else {
|
||||
pos = (view->wherepos + msg->mouse.y - view->whereclick);
|
||||
pos = MID (0, pos, bar_size - len);
|
||||
pos = MID(0, pos, bar_size - len);
|
||||
|
||||
jview_set_scroll
|
||||
(widget->parent,
|
||||
|
|
@ -588,14 +588,14 @@ static bool scrollbar_msg_proc(JWidget widget, JMessage msg)
|
|||
break;
|
||||
|
||||
case JM_BUTTONRELEASED:
|
||||
jwidget_deselect (widget);
|
||||
jwidget_release_mouse (widget);
|
||||
jwidget_deselect(widget);
|
||||
jwidget_release_mouse(widget);
|
||||
break;
|
||||
|
||||
case JM_MOUSEENTER:
|
||||
case JM_MOUSELEAVE:
|
||||
/* TODO add something to avoid this (theme specific stuff) */
|
||||
jwidget_invalidate (widget);
|
||||
jwidget_invalidate(widget);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -605,7 +605,7 @@ static bool scrollbar_msg_proc(JWidget widget, JMessage msg)
|
|||
static void scrollbar_info(JWidget widget, int *_pos, int *_len,
|
||||
int *_bar_size, int *_viewport_size)
|
||||
{
|
||||
View *view = jwidget_get_data (widget->parent, JI_VIEW);
|
||||
View *view = jwidget_get_data(widget->parent, JI_VIEW);
|
||||
int bar_size, viewport_size;
|
||||
int pos, len, max, scroll;
|
||||
int border_width;
|
||||
|
|
@ -639,9 +639,9 @@ static void scrollbar_info(JWidget widget, int *_pos, int *_len,
|
|||
}
|
||||
else {
|
||||
len = bar_size - (max-viewport_size);
|
||||
len = MID (BAR_SIZE-border_width, len, bar_size);
|
||||
len = MID(BAR_SIZE-border_width, len, bar_size);
|
||||
pos = (bar_size-len) * scroll / (max-viewport_size);
|
||||
pos = MID (0, pos, bar_size-len);
|
||||
pos = MID(0, pos, bar_size-len);
|
||||
}
|
||||
|
||||
if (_pos) *_pos = pos;
|
||||
|
|
|
|||
|
|
@ -301,9 +301,9 @@ void jwidget_set_name(JWidget widget, const char *name)
|
|||
assert_valid_widget(widget);
|
||||
|
||||
if (widget->name)
|
||||
jfree (widget->name);
|
||||
jfree(widget->name);
|
||||
|
||||
widget->name = name ? jstrdup (name) : NULL;
|
||||
widget->name = name ? jstrdup(name) : NULL;
|
||||
}
|
||||
|
||||
void jwidget_set_text(JWidget widget, const char *text)
|
||||
|
|
@ -313,24 +313,24 @@ void jwidget_set_text(JWidget widget, const char *text)
|
|||
if (text) {
|
||||
/* more space needed */
|
||||
if (!widget->text || widget->text_size < strlen (text)+1) {
|
||||
widget->text_size = strlen (text)+1;
|
||||
widget->text = jrealloc (widget->text, widget->text_size);
|
||||
widget->text_size = strlen(text)+1;
|
||||
widget->text = jrealloc(widget->text, widget->text_size);
|
||||
}
|
||||
|
||||
/* copy the text string */
|
||||
strcpy (widget->text, text);
|
||||
strcpy(widget->text, text);
|
||||
|
||||
if (widget->text_font)
|
||||
widget->text_size_pix = ji_font_text_len (widget->text_font,
|
||||
widget->text);
|
||||
widget->text_size_pix = ji_font_text_len(widget->text_font,
|
||||
widget->text);
|
||||
|
||||
jwidget_emit_signal (widget, JI_SIGNAL_SET_TEXT);
|
||||
jwidget_dirty (widget);
|
||||
jwidget_emit_signal(widget, JI_SIGNAL_SET_TEXT);
|
||||
jwidget_dirty(widget);
|
||||
}
|
||||
/* NULL text */
|
||||
else if (widget->text) {
|
||||
widget->text_size = 0;
|
||||
jfree (widget->text);
|
||||
jfree(widget->text);
|
||||
widget->text = NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -341,7 +341,7 @@ void jwidget_set_align(JWidget widget, int align)
|
|||
|
||||
widget->align = align;
|
||||
|
||||
jwidget_dirty (widget);
|
||||
jwidget_dirty(widget);
|
||||
}
|
||||
|
||||
void jwidget_set_font(JWidget widget, FONT *font)
|
||||
|
|
@ -351,12 +351,12 @@ void jwidget_set_font(JWidget widget, FONT *font)
|
|||
widget->text_font = font;
|
||||
|
||||
if (widget->text && widget->text_font)
|
||||
widget->text_size_pix = ji_font_text_len (widget->text_font,
|
||||
widget->text);
|
||||
widget->text_size_pix = ji_font_text_len(widget->text_font,
|
||||
widget->text);
|
||||
else
|
||||
widget->text_size_pix = 0;
|
||||
|
||||
jwidget_dirty (widget);
|
||||
jwidget_dirty(widget);
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
|
|
@ -446,11 +446,11 @@ void jwidget_dirty(JWidget widget)
|
|||
widget->flags |= JI_DIRTY;
|
||||
|
||||
/* dirty children */
|
||||
msg = jmessage_new (JM_DIRTYCHILDREN);
|
||||
jwidget_send_message (widget, msg);
|
||||
jmessage_free (msg);
|
||||
msg = jmessage_new(JM_DIRTYCHILDREN);
|
||||
jwidget_send_message(widget, msg);
|
||||
jmessage_free(msg);
|
||||
|
||||
jwidget_emit_signal (widget, JI_SIGNAL_DIRTY);
|
||||
jwidget_emit_signal(widget, JI_SIGNAL_DIRTY);
|
||||
}
|
||||
#else
|
||||
jwidget_invalidate(widget);
|
||||
|
|
@ -464,8 +464,8 @@ void jwidget_show(JWidget widget)
|
|||
if (widget->flags & JI_HIDDEN) {
|
||||
widget->flags &= ~JI_HIDDEN;
|
||||
|
||||
jwidget_dirty (widget);
|
||||
jwidget_emit_signal (widget, JI_SIGNAL_SHOW);
|
||||
jwidget_dirty(widget);
|
||||
jwidget_emit_signal(widget, JI_SIGNAL_SHOW);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -474,10 +474,10 @@ void jwidget_hide(JWidget widget)
|
|||
assert_valid_widget(widget);
|
||||
|
||||
if (!(widget->flags & JI_HIDDEN)) {
|
||||
jmanager_free_widget (widget); /* free from mananger */
|
||||
jmanager_free_widget(widget); /* free from mananger */
|
||||
|
||||
widget->flags |= JI_HIDDEN;
|
||||
jwidget_emit_signal (widget, JI_SIGNAL_HIDE);
|
||||
jwidget_emit_signal(widget, JI_SIGNAL_HIDE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -487,9 +487,9 @@ void jwidget_enable(JWidget widget)
|
|||
|
||||
if (widget->flags & JI_DISABLED) {
|
||||
widget->flags &= ~JI_DISABLED;
|
||||
jwidget_dirty (widget);
|
||||
jwidget_dirty(widget);
|
||||
|
||||
jwidget_emit_signal (widget, JI_SIGNAL_ENABLE);
|
||||
jwidget_emit_signal(widget, JI_SIGNAL_ENABLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -498,12 +498,12 @@ void jwidget_disable(JWidget widget)
|
|||
assert_valid_widget(widget);
|
||||
|
||||
if (!(widget->flags & JI_DISABLED)) {
|
||||
jmanager_free_widget (widget); /* free from the manager */
|
||||
jmanager_free_widget(widget); /* free from the manager */
|
||||
|
||||
widget->flags |= JI_DISABLED;
|
||||
jwidget_dirty (widget);
|
||||
jwidget_dirty(widget);
|
||||
|
||||
jwidget_emit_signal (widget, JI_SIGNAL_DISABLE);
|
||||
jwidget_emit_signal(widget, JI_SIGNAL_DISABLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -513,9 +513,9 @@ void jwidget_select(JWidget widget)
|
|||
|
||||
if (!(widget->flags & JI_SELECTED)) {
|
||||
widget->flags |= JI_SELECTED;
|
||||
jwidget_dirty (widget);
|
||||
jwidget_dirty(widget);
|
||||
|
||||
jwidget_emit_signal (widget, JI_SIGNAL_SELECT);
|
||||
jwidget_emit_signal(widget, JI_SIGNAL_SELECT);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -525,9 +525,9 @@ void jwidget_deselect(JWidget widget)
|
|||
|
||||
if (widget->flags & JI_SELECTED) {
|
||||
widget->flags &= ~JI_SELECTED;
|
||||
jwidget_dirty (widget);
|
||||
jwidget_dirty(widget);
|
||||
|
||||
jwidget_emit_signal (widget, JI_SIGNAL_DESELECT);
|
||||
jwidget_emit_signal(widget, JI_SIGNAL_DESELECT);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -666,7 +666,7 @@ void jwidget_replace_child(JWidget widget, JWidget old_child, JWidget new_child)
|
|||
return;
|
||||
before = before->next;
|
||||
|
||||
jwidget_remove_child (widget, old_child);
|
||||
jwidget_remove_child(widget, old_child);
|
||||
|
||||
jlist_insert_before(widget->children, before, new_child);
|
||||
new_child->parent = widget;
|
||||
|
|
@ -880,8 +880,8 @@ JRegion jwidget_get_drawable_region(JWidget widget, int flags)
|
|||
jregion_free(reg3);
|
||||
}
|
||||
jregion_free(reg1);
|
||||
jregion_free (reg2);
|
||||
jrect_free (cpos);
|
||||
jregion_free(reg2);
|
||||
jrect_free(cpos);
|
||||
}
|
||||
|
||||
/* cut the parent area */
|
||||
|
|
@ -924,14 +924,14 @@ JRegion jwidget_get_drawable_region(JWidget widget, int flags)
|
|||
else
|
||||
cpos = jwidget_get_child_rect(manager);
|
||||
/* if (!manager->parent) */
|
||||
/* cpos = jwidget_get_rect (manager); */
|
||||
/* cpos = jwidget_get_rect(manager); */
|
||||
/* else */
|
||||
/* cpos = jwidget_get_child_rect (manager->parent); */
|
||||
/* cpos = jwidget_get_child_rect(manager->parent); */
|
||||
|
||||
reg1 = jregion_new (cpos, 1);
|
||||
jregion_intersect (region, region, reg1);
|
||||
jregion_free (reg1);
|
||||
jrect_free (cpos);
|
||||
reg1 = jregion_new(cpos, 1);
|
||||
jregion_intersect(region, region, reg1);
|
||||
jregion_free(reg1);
|
||||
jrect_free(cpos);
|
||||
|
||||
window = jwidget_get_window(manager);
|
||||
manager = window ? jwidget_get_manager(window): NULL;
|
||||
|
|
@ -946,7 +946,7 @@ int jwidget_get_bg_color(JWidget widget)
|
|||
assert_valid_widget(widget);
|
||||
|
||||
if (widget->bg_color < 0 && widget->parent)
|
||||
return jwidget_get_bg_color (widget->parent);
|
||||
return jwidget_get_bg_color(widget->parent);
|
||||
else
|
||||
return widget->bg_color;
|
||||
}
|
||||
|
|
@ -961,7 +961,7 @@ JTheme jwidget_get_theme(JWidget widget)
|
|||
int jwidget_get_text_length(JWidget widget)
|
||||
{
|
||||
#if 1
|
||||
return ji_font_text_len (widget->text_font, widget->text);
|
||||
return ji_font_text_len(widget->text_font, widget->text);
|
||||
#else /* use cached text size */
|
||||
return widget->text_size_pix;
|
||||
#endif
|
||||
|
|
@ -995,8 +995,8 @@ void jwidget_get_texticon_info(JWidget widget,
|
|||
|
||||
/* size of the text */
|
||||
if (widget->text) {
|
||||
text_w = jwidget_get_text_length (widget);
|
||||
text_h = jwidget_get_text_height (widget);
|
||||
text_w = jwidget_get_text_length(widget);
|
||||
text_h = jwidget_get_text_height(widget);
|
||||
}
|
||||
else {
|
||||
text_w = text_h = 0;
|
||||
|
|
@ -1005,19 +1005,19 @@ void jwidget_get_texticon_info(JWidget widget,
|
|||
/* box size */
|
||||
if (icon_align & JI_CENTER) { /* with the icon in the center */
|
||||
if (icon_align & JI_MIDDLE) { /* with the icon inside the text */
|
||||
box_w = MAX (icon_w, text_w);
|
||||
box_h = MAX (icon_h, text_h);
|
||||
box_w = MAX(icon_w, text_w);
|
||||
box_h = MAX(icon_h, text_h);
|
||||
}
|
||||
/* with the icon in the top or bottom */
|
||||
else {
|
||||
box_w = MAX (icon_w, text_w);
|
||||
box_w = MAX(icon_w, text_w);
|
||||
box_h = icon_h + ((widget->text)? widget->child_spacing: 0) + text_h;
|
||||
}
|
||||
}
|
||||
/* with the icon in left or right that doesn't care by now */
|
||||
else {
|
||||
box_w = icon_w + ((widget->text)? widget->child_spacing: 0) + text_w;
|
||||
box_h = MAX (icon_h, text_h);
|
||||
box_h = MAX(icon_h, text_h);
|
||||
}
|
||||
|
||||
/* box position */
|
||||
|
|
@ -1557,7 +1557,7 @@ static bool widget_msg_proc(JWidget widget, JMessage msg)
|
|||
|
||||
if (redraw) {
|
||||
/* get areas to draw */
|
||||
region2 = jwidget_get_drawable_region (widget, 0);
|
||||
region2 = jwidget_get_drawable_region(widget, 0);
|
||||
jregion_intersect2 (region2, msg->drawrgn.region);
|
||||
|
||||
/* draw the widget */
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ void jwindow_position(JWidget widget, int x, int y)
|
|||
window_action = WINDOW_MOVE;
|
||||
|
||||
if (window->is_autoremap)
|
||||
jwindow_remap (widget);
|
||||
jwindow_remap(widget);
|
||||
|
||||
rect = jrect_new(x, y, x+jrect_w(widget->rc), y+jrect_h(widget->rc));
|
||||
jwidget_set_rect(widget, rect);
|
||||
|
|
@ -172,13 +172,13 @@ void jwindow_position(JWidget widget, int x, int y)
|
|||
|
||||
void jwindow_move(JWidget widget, JRect rect)
|
||||
{
|
||||
move_window (widget, rect, TRUE);
|
||||
move_window(widget, rect, TRUE);
|
||||
}
|
||||
|
||||
void jwindow_open(JWidget widget)
|
||||
{
|
||||
if (!widget->parent) {
|
||||
Window *window = jwidget_get_data (widget, JI_WINDOW);
|
||||
Window *window = jwidget_get_data(widget, JI_WINDOW);
|
||||
|
||||
if (window->is_autoremap)
|
||||
jwindow_center(widget);
|
||||
|
|
@ -231,7 +231,7 @@ bool jwindow_is_toplevel(JWidget widget)
|
|||
|
||||
bool jwindow_is_foreground(JWidget widget)
|
||||
{
|
||||
Window *window = jwidget_get_data (widget, JI_WINDOW);
|
||||
Window *window = jwidget_get_data(widget, JI_WINDOW);
|
||||
|
||||
return window->is_foreground;
|
||||
}
|
||||
|
|
@ -379,7 +379,7 @@ static bool window_msg_proc(JWidget widget, JMessage msg)
|
|||
else if (window_action & WINDOW_RESIZE_BOTTOM)
|
||||
h += (msg->mouse.y - press_y);
|
||||
|
||||
limit_size (widget, &w, &h);
|
||||
limit_size(widget, &w, &h);
|
||||
|
||||
if ((jrect_w(widget->rc) != w) ||
|
||||
(jrect_h(widget->rc) != h)) {
|
||||
|
|
@ -624,8 +624,8 @@ static void move_window(JWidget widget, JRect rect, bool use_blit)
|
|||
jmessage_broadcast_to_children(msg, widget);
|
||||
jmanager_enqueue_message(msg);
|
||||
|
||||
old_reg = jwidget_get_region (widget);
|
||||
old_drawable_region = jwidget_get_drawable_region (widget, FLAGS);
|
||||
old_reg = jwidget_get_region(widget);
|
||||
old_drawable_region = jwidget_get_drawable_region(widget, FLAGS);
|
||||
|
||||
if (jrect_w(old_pos) != jrect_w(rect) ||
|
||||
jrect_h(old_pos) != jrect_h(rect)) {
|
||||
|
|
|
|||
|
|
@ -470,10 +470,10 @@ static JList read_nodes(JStream stream)
|
|||
/* create the new tag */
|
||||
tag = read_elem(open ? tag_start: tag_start+1);
|
||||
if (tag) {
|
||||
/* fprintf (stderr, "%s tag: %s (parent %s)\n", */
|
||||
/* open ? "open": "close", */
|
||||
/* jxmlelem_get_name(tag), */
|
||||
/* !jlist_empty(parent_stack) ? ((JXmlNode)jlist_first_data(parent_stack))->value: "ROOT"); */
|
||||
/* fprintf(stderr, "%s tag: %s (parent %s)\n", */
|
||||
/* open ? "open": "close", */
|
||||
/* jxmlelem_get_name(tag), */
|
||||
/* !jlist_empty(parent_stack) ? ((JXmlNode)jlist_first_data(parent_stack))->value: "ROOT"); */
|
||||
|
||||
/* open a level */
|
||||
if (open) {
|
||||
|
|
@ -497,7 +497,7 @@ static JList read_nodes(JStream stream)
|
|||
}
|
||||
else {
|
||||
/* TODO error msg */
|
||||
/* printf ("you must open the tag before close it\n"); */
|
||||
/* printf("you must open the tag before close it\n"); */
|
||||
}
|
||||
|
||||
jxmlelem_free(tag);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
#include "jstandard_theme_icons.h"
|
||||
#include "pcx2data.c"
|
||||
|
||||
#define CHARACTER_LENGTH(f, c) ((f)->vtable->char_length ((f), (c)))
|
||||
#define CHARACTER_LENGTH(f, c) ((f)->vtable->char_length((f), (c)))
|
||||
|
||||
#define BGCOLOR (get_bg_color(widget))
|
||||
|
||||
|
|
@ -132,13 +132,13 @@ 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 less_bevel(int *bevel);
|
||||
|
||||
static bool theme_button_msg_proc (JWidget widget, JMessage msg);
|
||||
static bool theme_button_msg_proc(JWidget widget, JMessage msg);
|
||||
|
||||
JTheme jtheme_new_standard (void)
|
||||
JTheme jtheme_new_standard(void)
|
||||
{
|
||||
JTheme theme;
|
||||
|
||||
theme = jtheme_new ();
|
||||
theme = jtheme_new();
|
||||
if (!theme)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -182,21 +182,21 @@ JTheme jtheme_new_standard (void)
|
|||
return theme;
|
||||
}
|
||||
|
||||
static void theme_destroy (void)
|
||||
static void theme_destroy(void)
|
||||
{
|
||||
int c;
|
||||
|
||||
for (c=0; c<ICONS; c++) {
|
||||
if (icons_bitmap[c]) {
|
||||
destroy_bitmap (icons_bitmap[c]);
|
||||
destroy_bitmap(icons_bitmap[c]);
|
||||
icons_bitmap[c] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void theme_regen (void)
|
||||
static void theme_regen(void)
|
||||
{
|
||||
JTheme theme = ji_get_theme ();
|
||||
JTheme theme = ji_get_theme();
|
||||
int c, cmap[8], mask_cmap[2];
|
||||
|
||||
theme->desktop_color = COLOR_DISABLED;
|
||||
|
|
@ -217,12 +217,12 @@ static void theme_regen (void)
|
|||
|
||||
for (c=0; c<ICONS; c++) {
|
||||
if (icons_bitmap[c])
|
||||
destroy_bitmap (icons_bitmap[c]);
|
||||
destroy_bitmap(icons_bitmap[c]);
|
||||
|
||||
if (icons_data[c].mask)
|
||||
icons_bitmap[c] = data2bmp(8, icons_data[c].data, mask_cmap);
|
||||
else
|
||||
icons_bitmap[c] = data2bmp(bitmap_color_depth (ji_screen),
|
||||
icons_bitmap[c] = data2bmp(bitmap_color_depth(ji_screen),
|
||||
icons_data[c].data, cmap);
|
||||
}
|
||||
}
|
||||
|
|
@ -352,28 +352,28 @@ static void theme_init_widget(JWidget widget)
|
|||
/* frame */
|
||||
if ((widget->align & JI_HORIZONTAL) &&
|
||||
(widget->align & JI_VERTICAL)) {
|
||||
BORDER (4);
|
||||
BORDER(4);
|
||||
}
|
||||
/* horizontal bar */
|
||||
else if (widget->align & JI_HORIZONTAL) {
|
||||
BORDER4 (2, 4, 2, 0);
|
||||
BORDER4(2, 4, 2, 0);
|
||||
}
|
||||
/* vertical bar */
|
||||
else {
|
||||
BORDER4 (4, 2, 0, 2);
|
||||
BORDER4(4, 2, 0, 2);
|
||||
}
|
||||
|
||||
if (widget->text) {
|
||||
if (widget->align & JI_TOP)
|
||||
widget->border_width.t = jwidget_get_text_height (widget);
|
||||
widget->border_width.t = jwidget_get_text_height(widget);
|
||||
else if (widget->align & JI_BOTTOM)
|
||||
widget->border_width.b = jwidget_get_text_height (widget);
|
||||
widget->border_width.b = jwidget_get_text_height(widget);
|
||||
}
|
||||
break;
|
||||
|
||||
case JI_SLIDER:
|
||||
BORDER(4);
|
||||
widget->child_spacing = jwidget_get_text_height (widget);
|
||||
widget->child_spacing = jwidget_get_text_height(widget);
|
||||
break;
|
||||
|
||||
case JI_TEXTBOX:
|
||||
|
|
@ -417,7 +417,7 @@ static void theme_init_widget(JWidget widget)
|
|||
}
|
||||
}
|
||||
else {
|
||||
BORDER (0);
|
||||
BORDER(0);
|
||||
}
|
||||
widget->child_spacing = 4;
|
||||
break;
|
||||
|
|
@ -427,12 +427,12 @@ static void theme_init_widget(JWidget widget)
|
|||
}
|
||||
}
|
||||
|
||||
static JRegion theme_get_window_mask (JWidget widget)
|
||||
static JRegion theme_get_window_mask(JWidget widget)
|
||||
{
|
||||
return jregion_new (widget->rc, 1);
|
||||
return jregion_new(widget->rc, 1);
|
||||
}
|
||||
|
||||
static void theme_map_decorative_widget (JWidget widget)
|
||||
static void theme_map_decorative_widget(JWidget widget)
|
||||
{
|
||||
if (ustrcmp(widget->name, "theme_close_button") == 0) {
|
||||
JWidget window = widget->parent;
|
||||
|
|
@ -482,7 +482,7 @@ static int theme_color_background(void)
|
|||
|
||||
static void theme_draw_box(JWidget widget)
|
||||
{
|
||||
jdraw_rectfill (widget->rc, BGCOLOR);
|
||||
jdraw_rectfill(widget->rc, BGCOLOR);
|
||||
}
|
||||
|
||||
static void theme_draw_button(JWidget widget)
|
||||
|
|
@ -541,7 +541,7 @@ static void theme_draw_button(JWidget widget)
|
|||
COLOR_FOREGROUND, COLOR_FOREGROUND, bevel);
|
||||
else {
|
||||
less_bevel(bevel);
|
||||
draw_bevel_box (x1, y1, x2, y2, c1, c2, bevel);
|
||||
draw_bevel_box(x1, y1, x2, y2, c1, c2, bevel);
|
||||
}
|
||||
|
||||
less_bevel(bevel);
|
||||
|
|
@ -621,11 +621,11 @@ static void theme_draw_check(JWidget widget)
|
|||
widget->theme->check_icon_size);
|
||||
|
||||
/* background */
|
||||
jdraw_rectfill (widget->rc, bg = BGCOLOR);
|
||||
jdraw_rectfill(widget->rc, bg = BGCOLOR);
|
||||
|
||||
/* mouse */
|
||||
if (jwidget_is_enabled(widget) && jwidget_has_mouse(widget))
|
||||
jdraw_rectfill (&box, bg = COLOR_HOTFACE);
|
||||
jdraw_rectfill(&box, bg = COLOR_HOTFACE);
|
||||
|
||||
/* focus */
|
||||
if (jwidget_has_focus(widget)) {
|
||||
|
|
@ -634,22 +634,22 @@ static void theme_draw_check(JWidget widget)
|
|||
}
|
||||
|
||||
/* text */
|
||||
draw_textstring (NULL, -1, bg, FALSE, widget, &text, 0);
|
||||
draw_textstring(NULL, -1, bg, FALSE, widget, &text, 0);
|
||||
|
||||
/* icon */
|
||||
draw_icons (icon.x1, icon.y1, widget, ICON_CHECK_EDGE);
|
||||
draw_icons(icon.x1, icon.y1, widget, ICON_CHECK_EDGE);
|
||||
}
|
||||
|
||||
static void theme_draw_entry(JWidget widget)
|
||||
{
|
||||
bool password = jentry_is_password (widget);
|
||||
bool password = jentry_is_password(widget);
|
||||
int scroll, cursor, state, selbeg, selend;
|
||||
const char *text = widget->text;
|
||||
int c, ch, x, y, w, fg, bg;
|
||||
int x1, y1, x2, y2;
|
||||
int cursor_x;
|
||||
|
||||
jtheme_entry_info (widget, &scroll, &cursor, &state, &selbeg, &selend);
|
||||
jtheme_entry_info(widget, &scroll, &cursor, &state, &selbeg, &selend);
|
||||
|
||||
/* main pos */
|
||||
x1 = widget->rc->x1;
|
||||
|
|
@ -666,20 +666,20 @@ static void theme_draw_entry(JWidget widget)
|
|||
/* 2nd border */
|
||||
x1++, y1++, x2--, y2--;
|
||||
if (jwidget_has_focus (widget))
|
||||
rect (ji_screen, x1, y1, x2, y2, COLOR_FOREGROUND);
|
||||
rect(ji_screen, x1, y1, x2, y2, COLOR_FOREGROUND);
|
||||
else
|
||||
rect (ji_screen, x1, y1, x2, y2, BGCOLOR);
|
||||
rect(ji_screen, x1, y1, x2, y2, BGCOLOR);
|
||||
|
||||
/* background border */
|
||||
x1++, y1++, x2--, y2--;
|
||||
rectfill (ji_screen, x1, y1, x2, y2, bg);
|
||||
rectfill(ji_screen, x1, y1, x2, y2, bg);
|
||||
|
||||
/* draw the text */
|
||||
x = widget->rc->x1 + widget->border_width.l;
|
||||
y = (widget->rc->y1+widget->rc->y2)/2 - jwidget_get_text_height (widget)/2;
|
||||
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);
|
||||
ch = password ? '*': ugetat(text, c);
|
||||
|
||||
/* normal text */
|
||||
bg = -1;
|
||||
|
|
@ -700,36 +700,36 @@ static void theme_draw_entry(JWidget widget)
|
|||
fg = COLOR_DISABLED;
|
||||
}
|
||||
|
||||
w = CHARACTER_LENGTH (widget->text_font, ch);
|
||||
w = CHARACTER_LENGTH(widget->text_font, ch);
|
||||
if (x+w > widget->rc->x2-3)
|
||||
return;
|
||||
|
||||
cursor_x = x;
|
||||
ji_font_set_aa_mode (widget->text_font,
|
||||
bg >= 0 ? bg: COLOR_BACKGROUND);
|
||||
widget->text_font->vtable->render_char (widget->text_font,
|
||||
ch, fg, bg, ji_screen, x, y);
|
||||
ji_font_set_aa_mode(widget->text_font,
|
||||
bg >= 0 ? bg: COLOR_BACKGROUND);
|
||||
widget->text_font->vtable->render_char(widget->text_font,
|
||||
ch, fg, bg, ji_screen, x, y);
|
||||
x += w;
|
||||
|
||||
/* cursor */
|
||||
if ((c == cursor) && (state) && (jwidget_has_focus (widget)))
|
||||
draw_entry_cursor (widget, cursor_x, y);
|
||||
draw_entry_cursor(widget, cursor_x, y);
|
||||
}
|
||||
|
||||
/* draw the cursor if it is next of the last character */
|
||||
if ((c == cursor) && (state) &&
|
||||
(jwidget_has_focus (widget)) &&
|
||||
(jwidget_is_enabled (widget)))
|
||||
draw_entry_cursor (widget, x, y);
|
||||
(jwidget_has_focus(widget)) &&
|
||||
(jwidget_is_enabled(widget)))
|
||||
draw_entry_cursor(widget, x, y);
|
||||
}
|
||||
|
||||
static void theme_draw_label(JWidget widget)
|
||||
{
|
||||
int bg = BGCOLOR;
|
||||
|
||||
jdraw_rectfill (widget->rc, bg);
|
||||
jdraw_rectfill(widget->rc, bg);
|
||||
|
||||
draw_textstring (NULL, -1, bg, FALSE, widget, widget->rc, 0);
|
||||
draw_textstring(NULL, -1, bg, FALSE, widget, widget->rc, 0);
|
||||
}
|
||||
|
||||
static void theme_draw_listbox(JWidget widget)
|
||||
|
|
@ -890,7 +890,7 @@ static void theme_draw_menuitem(JWidget widget)
|
|||
pos = jwidget_get_rect(widget);
|
||||
pos->x2 -= widget->child_spacing/4;
|
||||
|
||||
jaccel_to_string (jmenuitem_get_accel (widget), buf);
|
||||
jaccel_to_string(jmenuitem_get_accel(widget), buf);
|
||||
|
||||
widget->align = JI_RIGHT | JI_MIDDLE;
|
||||
draw_textstring(buf, fg, bg, FALSE, widget, pos, 0);
|
||||
|
|
@ -901,7 +901,7 @@ static void theme_draw_menuitem(JWidget widget)
|
|||
}
|
||||
}
|
||||
|
||||
static void theme_draw_panel (JWidget widget)
|
||||
static void theme_draw_panel(JWidget widget)
|
||||
{
|
||||
JWidget c1, c2;
|
||||
JLink link;
|
||||
|
|
@ -920,12 +920,12 @@ static void theme_draw_panel (JWidget widget)
|
|||
c2 = (JWidget)link->next->data;
|
||||
|
||||
if (widget->align & JI_HORIZONTAL) {
|
||||
/* vline (ji_screen, */
|
||||
/* 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, COLOR_FOREGROUND); */
|
||||
|
||||
/* vline (ji_screen, */
|
||||
/* 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, COLOR_FOREGROUND); */
|
||||
|
|
@ -937,12 +937,12 @@ static void theme_draw_panel (JWidget widget)
|
|||
c2->rc->x1-3, COLOR_FOREGROUND);
|
||||
}
|
||||
else {
|
||||
/* hline (ji_screen, */
|
||||
/* 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, COLOR_FOREGROUND); */
|
||||
|
||||
/* hline (ji_screen, */
|
||||
/* 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, COLOR_FOREGROUND); */
|
||||
|
|
@ -957,18 +957,18 @@ static void theme_draw_panel (JWidget widget)
|
|||
}
|
||||
}
|
||||
|
||||
static void theme_draw_radio (JWidget widget)
|
||||
static void theme_draw_radio(JWidget widget)
|
||||
{
|
||||
struct jrect box, text, icon;
|
||||
int bg = BGCOLOR;
|
||||
|
||||
jwidget_get_texticon_info(widget, &box, &text, &icon,
|
||||
ji_generic_button_get_icon_align(widget),
|
||||
widget->theme->radio_icon_size,
|
||||
widget->theme->radio_icon_size);
|
||||
ji_generic_button_get_icon_align(widget),
|
||||
widget->theme->radio_icon_size,
|
||||
widget->theme->radio_icon_size);
|
||||
|
||||
/* background */
|
||||
jdraw_rectfill (widget->rc, bg);
|
||||
jdraw_rectfill(widget->rc, bg);
|
||||
|
||||
/* mouse */
|
||||
if (jwidget_is_enabled(widget) && jwidget_has_mouse(widget))
|
||||
|
|
@ -997,55 +997,55 @@ static void theme_draw_separator(JWidget widget)
|
|||
y2 = widget->rc->y2 - 1 - widget->border_width.b/2;
|
||||
|
||||
/* background */
|
||||
jdraw_rectfill (widget->rc, BGCOLOR);
|
||||
jdraw_rectfill(widget->rc, BGCOLOR);
|
||||
|
||||
/* TOP line */
|
||||
if (widget->align & JI_HORIZONTAL) {
|
||||
hline (ji_screen, x1, y1-1, x2, COLOR_DISABLED);
|
||||
hline (ji_screen, x1, y1, x2, COLOR_BACKGROUND);
|
||||
hline(ji_screen, x1, y1-1, x2, COLOR_DISABLED);
|
||||
hline(ji_screen, x1, y1, x2, COLOR_BACKGROUND);
|
||||
}
|
||||
|
||||
/* LEFT line */
|
||||
if (widget->align & JI_VERTICAL) {
|
||||
vline (ji_screen, x1-1, y1, y2, COLOR_DISABLED);
|
||||
vline (ji_screen, x1, y1, y2, COLOR_BACKGROUND);
|
||||
vline(ji_screen, x1-1, y1, y2, COLOR_DISABLED);
|
||||
vline(ji_screen, x1, y1, y2, COLOR_BACKGROUND);
|
||||
}
|
||||
|
||||
/* frame */
|
||||
if ((widget->align & JI_HORIZONTAL) &&
|
||||
(widget->align & JI_VERTICAL)) {
|
||||
/* union between the LEFT and TOP lines */
|
||||
putpixel (ji_screen, x1-1, y1-1, COLOR_DISABLED);
|
||||
putpixel(ji_screen, x1-1, y1-1, COLOR_DISABLED);
|
||||
|
||||
/* BOTTOM line */
|
||||
hline (ji_screen, x1, y2, x2, COLOR_DISABLED);
|
||||
hline (ji_screen, x1-1, y2+1, x2, COLOR_BACKGROUND);
|
||||
hline(ji_screen, x1, y2, x2, COLOR_DISABLED);
|
||||
hline(ji_screen, x1-1, y2+1, x2, COLOR_BACKGROUND);
|
||||
|
||||
/* RIGHT line */
|
||||
vline (ji_screen, x2, y1, y2, COLOR_DISABLED);
|
||||
vline (ji_screen, x2+1, y1-1, y2, COLOR_BACKGROUND);
|
||||
vline(ji_screen, x2, y1, y2, COLOR_DISABLED);
|
||||
vline(ji_screen, x2+1, y1-1, y2, COLOR_BACKGROUND);
|
||||
|
||||
/* union between the RIGHT and BOTTOM lines */
|
||||
putpixel (ji_screen, x2+1, y2+1, COLOR_BACKGROUND);
|
||||
putpixel(ji_screen, x2+1, y2+1, COLOR_BACKGROUND);
|
||||
}
|
||||
|
||||
/* text */
|
||||
if (widget->text) {
|
||||
int h = jwidget_get_text_height (widget);
|
||||
int h = jwidget_get_text_height(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);
|
||||
draw_textstring(NULL, -1, BGCOLOR, FALSE, widget, &r, 0);
|
||||
}
|
||||
}
|
||||
|
||||
#if 1
|
||||
/* TODO 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)
|
||||
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);
|
||||
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;
|
||||
|
|
@ -1062,7 +1062,7 @@ static void theme_draw_slider(JWidget widget)
|
|||
int min, max, value;
|
||||
char buf[256];
|
||||
|
||||
jtheme_slider_info (widget, &min, &max, &value);
|
||||
jtheme_slider_info(widget, &min, &max, &value);
|
||||
|
||||
/* main pos */
|
||||
x1 = widget->rc->x1;
|
||||
|
|
@ -1084,9 +1084,9 @@ static void theme_draw_slider(JWidget widget)
|
|||
/* 2nd border */
|
||||
x1++, y1++, x2--, y2--;
|
||||
if (jwidget_has_focus (widget))
|
||||
rect (ji_screen, x1, y1, x2, y2, COLOR_FOREGROUND);
|
||||
rect(ji_screen, x1, y1, x2, y2, COLOR_FOREGROUND);
|
||||
else
|
||||
rect (ji_screen, x1, y1, x2, y2, bg);
|
||||
rect(ji_screen, x1, y1, x2, y2, bg);
|
||||
|
||||
/* 3rd border */
|
||||
if (!jwidget_is_selected (widget)) {
|
||||
|
|
@ -1099,7 +1099,7 @@ static void theme_draw_slider(JWidget widget)
|
|||
}
|
||||
|
||||
x1++, y1++, x2--, y2--;
|
||||
_ji_theme_rectedge (ji_screen, x1, y1, x2, y2, c1, c2);
|
||||
_ji_theme_rectedge(ji_screen, x1, y1, x2, y2, c1, c2);
|
||||
|
||||
/* progress bar */
|
||||
x1++, y1++, x2--, y2--;
|
||||
|
|
@ -1110,15 +1110,15 @@ static void theme_draw_slider(JWidget widget)
|
|||
x = x1;
|
||||
|
||||
if (value == min) {
|
||||
rectfill (ji_screen, x1, y1, x2, y2, bg);
|
||||
rectfill(ji_screen, x1, y1, x2, y2, bg);
|
||||
}
|
||||
else {
|
||||
rectfill (ji_screen, x1, y1, x, y2,
|
||||
(jwidget_is_disabled (widget)) ?
|
||||
bg: COLOR_SELECTED);
|
||||
rectfill(ji_screen, x1, y1, x, y2,
|
||||
(jwidget_is_disabled(widget)) ?
|
||||
bg: COLOR_SELECTED);
|
||||
|
||||
if (x < x2)
|
||||
rectfill (ji_screen, x+1, y1, x2, y2, bg);
|
||||
rectfill(ji_screen, x+1, y1, x2, y2, bg);
|
||||
}
|
||||
|
||||
/* text */
|
||||
|
|
@ -1167,7 +1167,7 @@ static void theme_draw_textbox(JWidget widget)
|
|||
|
||||
static void theme_draw_view(JWidget widget)
|
||||
{
|
||||
JRect pos = jwidget_get_rect (widget);
|
||||
JRect pos = jwidget_get_rect(widget);
|
||||
|
||||
if (jwidget_has_focus(widget)) {
|
||||
/* 1st border */
|
||||
|
|
@ -1190,7 +1190,7 @@ static void theme_draw_view(JWidget widget)
|
|||
jrect_shrink(pos, 1);
|
||||
jdraw_rectfill(pos, BGCOLOR);
|
||||
|
||||
jrect_free (pos);
|
||||
jrect_free(pos);
|
||||
}
|
||||
|
||||
static void theme_draw_view_scrollbar(JWidget widget)
|
||||
|
|
@ -1199,7 +1199,7 @@ static void theme_draw_view_scrollbar(JWidget widget)
|
|||
int u1, v1, u2, v2;
|
||||
int pos, len;
|
||||
|
||||
jtheme_scrollbar_info (widget, &pos, &len);
|
||||
jtheme_scrollbar_info(widget, &pos, &len);
|
||||
|
||||
x1 = widget->rc->x1;
|
||||
y1 = widget->rc->y1;
|
||||
|
|
@ -1207,7 +1207,7 @@ static void theme_draw_view_scrollbar(JWidget widget)
|
|||
y2 = widget->rc->y2-1;
|
||||
|
||||
/* border */
|
||||
rect (ji_screen, x1, y1, x2, y2, BGCOLOR);
|
||||
rect(ji_screen, x1, y1, x2, y2, BGCOLOR);
|
||||
|
||||
/* draw the content */
|
||||
x1++, y1++, x2--, y2--;
|
||||
|
|
@ -1228,17 +1228,17 @@ static void theme_draw_view_scrollbar(JWidget widget)
|
|||
}
|
||||
|
||||
/* background */
|
||||
_ji_theme_rectfill_exclude (ji_screen,
|
||||
x1, y1, x2, y2,
|
||||
u1, v1, u2, v2, BGCOLOR);
|
||||
_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,
|
||||
COLOR_DISABLED, COLOR_BACKGROUND);
|
||||
if (jwidget_is_selected(widget))
|
||||
_ji_theme_rectedge(ji_screen, u1, v1, u2, v2,
|
||||
COLOR_DISABLED, COLOR_BACKGROUND);
|
||||
else
|
||||
_ji_theme_rectedge (ji_screen, u1, v1, u2, v2,
|
||||
COLOR_BACKGROUND, COLOR_DISABLED);
|
||||
_ji_theme_rectedge(ji_screen, u1, v1, u2, v2,
|
||||
COLOR_BACKGROUND, COLOR_DISABLED);
|
||||
|
||||
/* bar-block background */
|
||||
u1++, v1++, u2--, v2--;
|
||||
|
|
@ -1248,7 +1248,7 @@ static void theme_draw_view_scrollbar(JWidget widget)
|
|||
rectfill(ji_screen, u1, v1, u2, v2, BGCOLOR);
|
||||
}
|
||||
|
||||
static void theme_draw_view_viewport (JWidget widget)
|
||||
static void theme_draw_view_viewport(JWidget widget)
|
||||
{
|
||||
jdraw_rectfill(widget->rc, BGCOLOR);
|
||||
}
|
||||
|
|
@ -1293,30 +1293,30 @@ static void theme_draw_window(JWidget widget)
|
|||
jrect_free(cpos);
|
||||
}
|
||||
|
||||
static int get_bg_color (JWidget widget)
|
||||
static int get_bg_color(JWidget widget)
|
||||
{
|
||||
int c = jwidget_get_bg_color (widget);
|
||||
int decorative = jwidget_is_decorative (widget);
|
||||
int c = jwidget_get_bg_color(widget);
|
||||
int decorative = jwidget_is_decorative(widget);
|
||||
|
||||
return c >= 0 ? c: (decorative ? COLOR_SELECTED:
|
||||
COLOR_FACE);
|
||||
}
|
||||
|
||||
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_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);
|
||||
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);
|
||||
w = ji_font_text_len(widget->text_font, t);
|
||||
h = text_height(widget->text_font);
|
||||
}
|
||||
|
||||
/* horizontally text alignment */
|
||||
|
|
@ -1345,9 +1345,9 @@ static void draw_textstring (const char *t, int fg_color, int bg_color,
|
|||
/* background */
|
||||
if (bg_color >= 0) {
|
||||
if (jwidget_is_disabled (widget))
|
||||
rectfill (ji_screen, x, y, x+w, y+h, bg_color);
|
||||
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);
|
||||
rectfill(ji_screen, x, y, x+w-1, y+h-1, bg_color);
|
||||
}
|
||||
|
||||
/* text */
|
||||
|
|
|
|||
|
|
@ -10,40 +10,40 @@
|
|||
#include <allegro.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void pcx2data (const char *filename)
|
||||
void pcx2data(const char *filename)
|
||||
{
|
||||
char buf[512];
|
||||
PALETTE pal;
|
||||
BITMAP *bmp;
|
||||
int x, y;
|
||||
|
||||
bmp = load_bitmap (filename, pal);
|
||||
bmp = load_bitmap(filename, pal);
|
||||
if (!bmp)
|
||||
return;
|
||||
|
||||
ustrcpy (buf, get_filename (filename));
|
||||
if (get_extension (buf))
|
||||
*(get_extension (buf)-1) = 0;
|
||||
ustrcpy(buf, get_filename(filename));
|
||||
if (get_extension(buf))
|
||||
*(get_extension(buf)-1) = 0;
|
||||
|
||||
printf ("static unsigned char default_theme_%s[%d] = {\n",
|
||||
buf, 2 + bmp->w * bmp->h);
|
||||
printf("static unsigned char default_theme_%s[%d] = {\n",
|
||||
buf, 2 + bmp->w * bmp->h);
|
||||
|
||||
printf (" %d, %d,\n", bmp->w, bmp->h);
|
||||
printf(" %d, %d,\n", bmp->w, bmp->h);
|
||||
|
||||
for (y=0; y<bmp->h; y++) {
|
||||
printf (" ");
|
||||
printf(" ");
|
||||
for (x=0; x<bmp->w; x++)
|
||||
printf ("%d%s", getpixel (bmp, x, y), x == bmp->w-1 ? "": ", ");
|
||||
printf ("%s\n", y == bmp->h-1 ? "": ",");
|
||||
printf("%d%s", getpixel(bmp, x, y), x == bmp->w-1 ? "": ", ");
|
||||
printf("%s\n", y == bmp->h-1 ? "": ",");
|
||||
}
|
||||
|
||||
printf ("};\n\n");
|
||||
printf("};\n\n");
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int c;
|
||||
allegro_init ();
|
||||
allegro_init();
|
||||
printf ("/* Generated by pcx2data */\n\n");
|
||||
for (c=1; c<argc; c++) {
|
||||
fprintf(stderr, "Converting %s...\n", argv[c]);
|
||||
|
|
@ -52,22 +52,22 @@ int main (int argc, char *argv[])
|
|||
return 0;
|
||||
}
|
||||
|
||||
END_OF_MAIN ();
|
||||
END_OF_MAIN();
|
||||
|
||||
#else
|
||||
|
||||
static BITMAP *data2bmp (int color_depth, const unsigned char *data, int *cmap)
|
||||
static BITMAP *data2bmp(int color_depth, const unsigned char *data, int *cmap)
|
||||
{
|
||||
int x, y, c = 2;
|
||||
BITMAP *bmp;
|
||||
|
||||
bmp = create_bitmap_ex (color_depth, data[0], data[1]);
|
||||
bmp = create_bitmap_ex(color_depth, data[0], data[1]);
|
||||
if (!bmp)
|
||||
return NULL;
|
||||
|
||||
for (y=0; y<bmp->h; y++)
|
||||
for (x=0; x<bmp->w; x++)
|
||||
putpixel (bmp, x, y, cmap[data[c++]]);
|
||||
putpixel(bmp, x, y, cmap[data[c++]]);
|
||||
|
||||
return bmp;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -43,195 +43,195 @@ static struct {
|
|||
static char *fg_color = NULL;
|
||||
static char *bg_color = NULL;
|
||||
|
||||
static void fill_color_struct (const char *color);
|
||||
static int get_mask_for_bitmap (int depth);
|
||||
static void fill_color_struct(const char *color);
|
||||
static int get_mask_for_bitmap(int depth);
|
||||
|
||||
int init_module_color (void)
|
||||
int init_module_color(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void exit_module_color (void)
|
||||
void exit_module_color(void)
|
||||
{
|
||||
set_bg_color (NULL);
|
||||
set_bg_color (NULL);
|
||||
set_bg_color(NULL);
|
||||
set_bg_color(NULL);
|
||||
}
|
||||
|
||||
const char *get_fg_color (void)
|
||||
const char *get_fg_color(void)
|
||||
{
|
||||
JWidget color_bar = app_get_color_bar ();
|
||||
JWidget color_bar = app_get_color_bar();
|
||||
|
||||
if (color_bar && !fg_color)
|
||||
return color_bar_get_color (color_bar, 0);
|
||||
return color_bar_get_color(color_bar, 0);
|
||||
else
|
||||
return fg_color ? fg_color: DEFAULT_FG;
|
||||
}
|
||||
|
||||
const char *get_bg_color (void)
|
||||
const char *get_bg_color(void)
|
||||
{
|
||||
JWidget color_bar = app_get_color_bar ();
|
||||
JWidget color_bar = app_get_color_bar();
|
||||
|
||||
if (color_bar && !bg_color)
|
||||
return color_bar_get_color (color_bar, 1);
|
||||
return color_bar_get_color(color_bar, 1);
|
||||
else
|
||||
return bg_color ? bg_color: DEFAULT_BG;
|
||||
}
|
||||
|
||||
void set_fg_color (const char *string)
|
||||
void set_fg_color(const char *string)
|
||||
{
|
||||
if (fg_color) {
|
||||
jfree (fg_color);
|
||||
jfree(fg_color);
|
||||
fg_color = NULL;
|
||||
}
|
||||
|
||||
if (string)
|
||||
fg_color = jstrdup (string);
|
||||
fg_color = jstrdup(string);
|
||||
}
|
||||
|
||||
void set_bg_color (const char *string)
|
||||
void set_bg_color(const char *string)
|
||||
{
|
||||
if (bg_color) {
|
||||
jfree (bg_color);
|
||||
jfree(bg_color);
|
||||
bg_color = NULL;
|
||||
}
|
||||
|
||||
if (string)
|
||||
bg_color = jstrdup (string);
|
||||
bg_color = jstrdup(string);
|
||||
}
|
||||
|
||||
int color_type (const char *color)
|
||||
int color_type(const char *color)
|
||||
{
|
||||
fill_color_struct (color);
|
||||
fill_color_struct(color);
|
||||
return color_struct.type;
|
||||
}
|
||||
|
||||
char *color_mask (void)
|
||||
char *color_mask(void)
|
||||
{
|
||||
return jstrdup ("mask");
|
||||
return jstrdup("mask");
|
||||
}
|
||||
|
||||
char *color_rgb (int r, int g, int b, int a)
|
||||
char *color_rgb(int r, int g, int b, int a)
|
||||
{
|
||||
char buf[256];
|
||||
usprintf (buf, "rgb{%d,%d,%d", r, g, b);
|
||||
usprintf(buf, "rgb{%d,%d,%d", r, g, b);
|
||||
if (a == 255)
|
||||
ustrcat (buf, "}");
|
||||
ustrcat(buf, "}");
|
||||
else
|
||||
usprintf (buf+ustrlen (buf), ",%d}", a);
|
||||
return jstrdup (buf);
|
||||
usprintf(buf+ustrlen(buf), ",%d}", a);
|
||||
return jstrdup(buf);
|
||||
}
|
||||
|
||||
char *color_gray (int g, int a)
|
||||
char *color_gray(int g, int a)
|
||||
{
|
||||
char buf[256];
|
||||
usprintf (buf, "gray{%d", g);
|
||||
usprintf(buf, "gray{%d", g);
|
||||
if (a == 255)
|
||||
ustrcat (buf, "}");
|
||||
ustrcat(buf, "}");
|
||||
else
|
||||
usprintf (buf+ustrlen (buf), ",%d}", a);
|
||||
return jstrdup (buf);
|
||||
usprintf(buf+ustrlen(buf), ",%d}", a);
|
||||
return jstrdup(buf);
|
||||
}
|
||||
|
||||
char *color_index (int index)
|
||||
char *color_index(int index)
|
||||
{
|
||||
char buf[256];
|
||||
usprintf (buf, "index{%d}", index);
|
||||
return jstrdup (buf);
|
||||
usprintf(buf, "index{%d}", index);
|
||||
return jstrdup(buf);
|
||||
}
|
||||
|
||||
int color_get_black (int imgtype, const char *color)
|
||||
int color_get_black(int imgtype, const char *color)
|
||||
{
|
||||
fill_color_struct (color);
|
||||
fill_color_struct(color);
|
||||
|
||||
if (color_struct.type == COLOR_TYPE_MASK)
|
||||
return 0;
|
||||
else if (color_struct.type == COLOR_TYPE_RGB) {
|
||||
PRINTF ("Getting `black' from a rgb color\n");
|
||||
PRINTF("Getting `black' from a rgb color\n");
|
||||
}
|
||||
else if (color_struct.type == COLOR_TYPE_GRAY)
|
||||
return _graya_getk (color_struct.data);
|
||||
return _graya_getk(color_struct.data);
|
||||
else if (color_struct.type == COLOR_TYPE_INDEX) {
|
||||
PRINTF ("Getting `black' from a index color\n");
|
||||
PRINTF("Getting `black' from a index color\n");
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int color_get_red (int imgtype, const char *color)
|
||||
int color_get_red(int imgtype, const char *color)
|
||||
{
|
||||
fill_color_struct (color);
|
||||
fill_color_struct(color);
|
||||
|
||||
if (color_struct.type == COLOR_TYPE_MASK)
|
||||
return imgtype == IMAGE_INDEXED ? _rgb_scale_6[current_palette[0].r]: 0;
|
||||
else if (color_struct.type == COLOR_TYPE_RGB)
|
||||
return _rgba_getr (color_struct.data);
|
||||
return _rgba_getr(color_struct.data);
|
||||
else if (color_struct.type == COLOR_TYPE_GRAY)
|
||||
return _graya_getk (color_struct.data);
|
||||
return _graya_getk(color_struct.data);
|
||||
else if (color_struct.type == COLOR_TYPE_INDEX)
|
||||
return _rgb_scale_6[current_palette[color_struct.data & 0xff].r];
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int color_get_green (int imgtype, const char *color)
|
||||
int color_get_green(int imgtype, const char *color)
|
||||
{
|
||||
fill_color_struct (color);
|
||||
fill_color_struct(color);
|
||||
|
||||
if (color_struct.type == COLOR_TYPE_MASK)
|
||||
return imgtype == IMAGE_INDEXED ? _rgb_scale_6[current_palette[0].g]: 0;
|
||||
else if (color_struct.type == COLOR_TYPE_RGB)
|
||||
return _rgba_getg (color_struct.data);
|
||||
return _rgba_getg(color_struct.data);
|
||||
else if (color_struct.type == COLOR_TYPE_GRAY)
|
||||
return _graya_getk (color_struct.data);
|
||||
return _graya_getk(color_struct.data);
|
||||
else if (color_struct.type == COLOR_TYPE_INDEX)
|
||||
return _rgb_scale_6[current_palette[color_struct.data & 0xff].g];
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int color_get_blue (int imgtype, const char *color)
|
||||
int color_get_blue(int imgtype, const char *color)
|
||||
{
|
||||
fill_color_struct (color);
|
||||
fill_color_struct(color);
|
||||
|
||||
if (color_struct.type == COLOR_TYPE_MASK)
|
||||
return imgtype == IMAGE_INDEXED ? _rgb_scale_6[current_palette[0].b]: 0;
|
||||
else if (color_struct.type == COLOR_TYPE_RGB)
|
||||
return _rgba_getb (color_struct.data);
|
||||
return _rgba_getb(color_struct.data);
|
||||
else if (color_struct.type == COLOR_TYPE_GRAY)
|
||||
return _graya_getk (color_struct.data);
|
||||
return _graya_getk(color_struct.data);
|
||||
else if (color_struct.type == COLOR_TYPE_INDEX)
|
||||
return _rgb_scale_6[current_palette[color_struct.data & 0xff].b];
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int color_get_index (int imgtype, const char *color)
|
||||
int color_get_index(int imgtype, const char *color)
|
||||
{
|
||||
fill_color_struct (color);
|
||||
fill_color_struct(color);
|
||||
|
||||
if (color_struct.type == COLOR_TYPE_MASK)
|
||||
return 0;
|
||||
else if (color_struct.type == COLOR_TYPE_RGB) {
|
||||
PRINTF ("Getting `index' from a rgb color\n");
|
||||
PRINTF("Getting `index' from a rgb color\n");
|
||||
}
|
||||
else if (color_struct.type == COLOR_TYPE_GRAY)
|
||||
return _graya_getk (color_struct.data);
|
||||
return _graya_getk(color_struct.data);
|
||||
else if (color_struct.type == COLOR_TYPE_INDEX)
|
||||
return color_struct.data & 0xff;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int color_get_alpha (int imgtype, const char *color)
|
||||
int color_get_alpha(int imgtype, const char *color)
|
||||
{
|
||||
fill_color_struct (color);
|
||||
fill_color_struct(color);
|
||||
|
||||
if (color_struct.type == COLOR_TYPE_MASK)
|
||||
return imgtype == IMAGE_INDEXED ? 255: 0;
|
||||
else if (color_struct.type == COLOR_TYPE_RGB)
|
||||
return _rgba_geta (color_struct.data);
|
||||
return _rgba_geta(color_struct.data);
|
||||
else if (color_struct.type == COLOR_TYPE_GRAY)
|
||||
return _graya_geta (color_struct.data);
|
||||
return _graya_geta(color_struct.data);
|
||||
else if (color_struct.type == COLOR_TYPE_INDEX)
|
||||
return 255;
|
||||
|
||||
|
|
@ -239,95 +239,95 @@ int color_get_alpha (int imgtype, const char *color)
|
|||
}
|
||||
|
||||
/* set the alpha channel in the color */
|
||||
void color_set_alpha (char **color, int alpha)
|
||||
void color_set_alpha(char **color, int alpha)
|
||||
{
|
||||
fill_color_struct (*color);
|
||||
fill_color_struct(*color);
|
||||
|
||||
if (color_struct.type == COLOR_TYPE_RGB) {
|
||||
jfree (*color);
|
||||
*color = color_rgb (_rgba_getr (color_struct.data),
|
||||
_rgba_getg (color_struct.data),
|
||||
_rgba_getb (color_struct.data), alpha);
|
||||
jfree(*color);
|
||||
*color = color_rgb(_rgba_getr(color_struct.data),
|
||||
_rgba_getg(color_struct.data),
|
||||
_rgba_getb(color_struct.data), alpha);
|
||||
}
|
||||
else if (color_struct.type == COLOR_TYPE_GRAY) {
|
||||
jfree (*color);
|
||||
*color = color_gray (_rgba_getg (color_struct.data), alpha);
|
||||
jfree(*color);
|
||||
*color = color_gray(_rgba_getg(color_struct.data), alpha);
|
||||
}
|
||||
}
|
||||
|
||||
char *color_from_image (int imgtype, int c)
|
||||
char *color_from_image(int imgtype, int c)
|
||||
{
|
||||
char *color = NULL;
|
||||
|
||||
switch (imgtype) {
|
||||
|
||||
case IMAGE_RGB:
|
||||
if (_rgba_geta (c) > 0) {
|
||||
color = color_rgb (_rgba_getr (c),
|
||||
_rgba_getg (c),
|
||||
_rgba_getb (c),
|
||||
_rgba_geta (c));
|
||||
if (_rgba_geta(c) > 0) {
|
||||
color = color_rgb(_rgba_getr(c),
|
||||
_rgba_getg(c),
|
||||
_rgba_getb(c),
|
||||
_rgba_geta(c));
|
||||
}
|
||||
break;
|
||||
|
||||
case IMAGE_GRAYSCALE:
|
||||
if (_graya_geta (c) > 0) {
|
||||
color = color_gray (_graya_getk (c),
|
||||
_graya_geta (c));
|
||||
if (_graya_geta(c) > 0) {
|
||||
color = color_gray(_graya_getk(c),
|
||||
_graya_geta(c));
|
||||
}
|
||||
break;
|
||||
|
||||
case IMAGE_INDEXED:
|
||||
if (c > 0)
|
||||
color = color_index (c);
|
||||
color = color_index(c);
|
||||
break;
|
||||
}
|
||||
|
||||
return (color)? color: color_mask ();
|
||||
return (color) ? color: color_mask();
|
||||
}
|
||||
|
||||
int blackandwhite (int r, int g, int b)
|
||||
int blackandwhite(int r, int g, int b)
|
||||
{
|
||||
return (r*30+g*59+b*11)/100 < 128 ?
|
||||
makecol (0, 0, 0): makecol (255, 255, 255);
|
||||
makecol(0, 0, 0): makecol(255, 255, 255);
|
||||
}
|
||||
|
||||
int blackandwhite_neg (int r, int g, int b)
|
||||
int blackandwhite_neg(int r, int g, int b)
|
||||
{
|
||||
return (r*30+g*59+b*11)/100 < 128 ?
|
||||
makecol (255, 255, 255): makecol (0, 0, 0);
|
||||
makecol(255, 255, 255): makecol(0, 0, 0);
|
||||
}
|
||||
|
||||
int get_color_for_allegro (int depth, const char *color)
|
||||
int get_color_for_allegro(int depth, const char *color)
|
||||
{
|
||||
int c;
|
||||
|
||||
fill_color_struct (color);
|
||||
fill_color_struct(color);
|
||||
|
||||
if (color_struct.type == COLOR_TYPE_MASK) {
|
||||
c = get_mask_for_bitmap (depth);
|
||||
c = get_mask_for_bitmap(depth);
|
||||
}
|
||||
else if (color_struct.type == COLOR_TYPE_RGB) {
|
||||
c = makeacol_depth (depth,
|
||||
_rgba_getr (color_struct.data),
|
||||
_rgba_getg (color_struct.data),
|
||||
_rgba_getb (color_struct.data),
|
||||
_rgba_geta (color_struct.data));
|
||||
c = makeacol_depth(depth,
|
||||
_rgba_getr(color_struct.data),
|
||||
_rgba_getg(color_struct.data),
|
||||
_rgba_getb(color_struct.data),
|
||||
_rgba_geta(color_struct.data));
|
||||
}
|
||||
else if (color_struct.type == COLOR_TYPE_GRAY) {
|
||||
c = _graya_getk (color_struct.data);
|
||||
c = _graya_getk(color_struct.data);
|
||||
|
||||
if (depth != 8)
|
||||
c = makeacol_depth (depth, c, c, c, _graya_geta (color_struct.data));
|
||||
c = makeacol_depth(depth, c, c, c, _graya_geta(color_struct.data));
|
||||
}
|
||||
else if (color_struct.type == COLOR_TYPE_INDEX) {
|
||||
c = color_struct.data & 0xff;
|
||||
|
||||
if (depth != 8)
|
||||
c = makeacol_depth (depth,
|
||||
_rgb_scale_6[current_palette[c].r],
|
||||
_rgb_scale_6[current_palette[c].g],
|
||||
_rgb_scale_6[current_palette[c].b], 255);
|
||||
c = makeacol_depth(depth,
|
||||
_rgb_scale_6[current_palette[c].r],
|
||||
_rgb_scale_6[current_palette[c].g],
|
||||
_rgb_scale_6[current_palette[c].b], 255);
|
||||
}
|
||||
else
|
||||
c = -1;
|
||||
|
|
@ -338,52 +338,52 @@ int get_color_for_allegro (int depth, const char *color)
|
|||
return c;
|
||||
}
|
||||
|
||||
int get_color_for_image (int imgtype, const char *color)
|
||||
int get_color_for_image(int imgtype, const char *color)
|
||||
{
|
||||
int c = -1;
|
||||
|
||||
fill_color_struct (color);
|
||||
fill_color_struct(color);
|
||||
|
||||
switch (imgtype) {
|
||||
|
||||
case IMAGE_RGB:
|
||||
if (color_struct.type == COLOR_TYPE_MASK) {
|
||||
c = _rgba (0, 0, 0, 0);
|
||||
c = _rgba(0, 0, 0, 0);
|
||||
}
|
||||
else if (color_struct.type == COLOR_TYPE_RGB) {
|
||||
c = color_struct.data;
|
||||
}
|
||||
else if (color_struct.type == COLOR_TYPE_GRAY) {
|
||||
c = _graya_getk (color_struct.data);
|
||||
c = _rgba (c, c, c, _graya_geta (color_struct.data));
|
||||
c = _graya_getk(color_struct.data);
|
||||
c = _rgba(c, c, c, _graya_geta(color_struct.data));
|
||||
}
|
||||
else if (color_struct.type == COLOR_TYPE_INDEX) {
|
||||
c = color_struct.data & 0xff;
|
||||
c = _rgba (_rgb_scale_6[current_palette[c].r],
|
||||
_rgb_scale_6[current_palette[c].g],
|
||||
_rgb_scale_6[current_palette[c].b], 255);
|
||||
c = _rgba(_rgb_scale_6[current_palette[c].r],
|
||||
_rgb_scale_6[current_palette[c].g],
|
||||
_rgb_scale_6[current_palette[c].b], 255);
|
||||
}
|
||||
break;
|
||||
|
||||
case IMAGE_GRAYSCALE:
|
||||
if (color_struct.type == COLOR_TYPE_MASK) {
|
||||
c = _graya (0, 0);
|
||||
c = _graya(0, 0);
|
||||
}
|
||||
else if (color_struct.type == COLOR_TYPE_RGB) {
|
||||
int r = _rgba_getr (color_struct.data);
|
||||
int g = _rgba_getg (color_struct.data);
|
||||
int b = _rgba_getb (color_struct.data);
|
||||
int r = _rgba_getr(color_struct.data);
|
||||
int g = _rgba_getg(color_struct.data);
|
||||
int b = _rgba_getb(color_struct.data);
|
||||
|
||||
rgb_to_hsv_int (&r, &g, &b);
|
||||
rgb_to_hsv_int(&r, &g, &b);
|
||||
|
||||
c = _graya (b, _rgba_geta (color_struct.data));
|
||||
c = _graya(b, _rgba_geta(color_struct.data));
|
||||
}
|
||||
else if (color_struct.type == COLOR_TYPE_GRAY) {
|
||||
c = _graya (_graya_getk (color_struct.data),
|
||||
_graya_geta (color_struct.data));
|
||||
c = _graya(_graya_getk(color_struct.data),
|
||||
_graya_geta(color_struct.data));
|
||||
}
|
||||
else if (color_struct.type == COLOR_TYPE_INDEX) {
|
||||
c = _graya (color_struct.data & 0xff, 255);
|
||||
c = _graya(color_struct.data & 0xff, 255);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -393,12 +393,12 @@ int get_color_for_image (int imgtype, const char *color)
|
|||
}
|
||||
else if (color_struct.type == COLOR_TYPE_RGB) {
|
||||
c = orig_rgb_map->data
|
||||
[_rgba_getr (color_struct.data) >> 3]
|
||||
[_rgba_getg (color_struct.data) >> 3]
|
||||
[_rgba_getb (color_struct.data) >> 3];
|
||||
[_rgba_getr(color_struct.data) >> 3]
|
||||
[_rgba_getg(color_struct.data) >> 3]
|
||||
[_rgba_getb(color_struct.data) >> 3];
|
||||
}
|
||||
else if (color_struct.type == COLOR_TYPE_GRAY) {
|
||||
c = _graya_getk (color_struct.data);
|
||||
c = _graya_getk(color_struct.data);
|
||||
c = orig_rgb_map->data[c>>3][c>>3][c>>3];
|
||||
}
|
||||
else if (color_struct.type == COLOR_TYPE_INDEX) {
|
||||
|
|
@ -410,95 +410,95 @@ int get_color_for_image (int imgtype, const char *color)
|
|||
return c;
|
||||
}
|
||||
|
||||
char *image_getpixel_color (Image *image, int x, int y)
|
||||
char *image_getpixel_color(Image *image, int x, int y)
|
||||
{
|
||||
if ((x >= 0) && (y >= 0) && (x < image->w) && (y < image->h))
|
||||
return color_from_image (image->imgtype, image_getpixel (image, x, y));
|
||||
return color_from_image(image->imgtype, image_getpixel(image, x, y));
|
||||
else
|
||||
return color_mask ();
|
||||
return color_mask();
|
||||
}
|
||||
|
||||
void color_to_formalstring (int imgtype, const char *color, char *buf,
|
||||
int size, int long_format)
|
||||
void color_to_formalstring(int imgtype, const char *color, char *buf,
|
||||
int size, int long_format)
|
||||
{
|
||||
fill_color_struct (color);
|
||||
fill_color_struct(color);
|
||||
|
||||
/* long format */
|
||||
if (long_format) {
|
||||
if (color_struct.type == COLOR_TYPE_MASK) {
|
||||
uszprintf (buf, size, _("Mask"));
|
||||
uszprintf(buf, size, _("Mask"));
|
||||
}
|
||||
else if (color_struct.type == COLOR_TYPE_RGB) {
|
||||
if (imgtype == IMAGE_GRAYSCALE) {
|
||||
uszprintf (buf, size, "%s %d %s %d",
|
||||
_("Gray"),
|
||||
_graya_getk (get_color_for_image (imgtype, color)),
|
||||
_("Alpha"),
|
||||
_rgba_geta (color_struct.data));
|
||||
uszprintf(buf, size, "%s %d %s %d",
|
||||
_("Gray"),
|
||||
_graya_getk(get_color_for_image(imgtype, color)),
|
||||
_("Alpha"),
|
||||
_rgba_geta(color_struct.data));
|
||||
}
|
||||
else {
|
||||
uszprintf (buf, size, "%s %d %d %d",
|
||||
_("RGB"),
|
||||
_rgba_getr (color_struct.data),
|
||||
_rgba_getg (color_struct.data),
|
||||
_rgba_getb (color_struct.data));
|
||||
uszprintf(buf, size, "%s %d %d %d",
|
||||
_("RGB"),
|
||||
_rgba_getr(color_struct.data),
|
||||
_rgba_getg(color_struct.data),
|
||||
_rgba_getb(color_struct.data));
|
||||
|
||||
if (imgtype == IMAGE_INDEXED)
|
||||
uszprintf (buf+ustrlen(buf), size, " %s %d",
|
||||
_("Index"), get_color_for_image (imgtype, color));
|
||||
uszprintf(buf+ustrlen(buf), size, " %s %d",
|
||||
_("Index"), get_color_for_image(imgtype, color));
|
||||
else if (imgtype == IMAGE_RGB)
|
||||
uszprintf (buf+ustrlen(buf), size, " %s %d",
|
||||
_("Alpha"), _rgba_geta (color_struct.data));
|
||||
uszprintf(buf+ustrlen(buf), size, " %s %d",
|
||||
_("Alpha"), _rgba_geta(color_struct.data));
|
||||
}
|
||||
}
|
||||
else if (color_struct.type == COLOR_TYPE_GRAY) {
|
||||
uszprintf (buf, size, "%s %d",
|
||||
_("Gray"), _graya_getk (color_struct.data));
|
||||
uszprintf(buf, size, "%s %d",
|
||||
_("Gray"), _graya_getk(color_struct.data));
|
||||
|
||||
if ((imgtype == IMAGE_RGB) ||
|
||||
(imgtype == IMAGE_GRAYSCALE)) {
|
||||
uszprintf (buf+ustrlen(buf), size, " %s %d",
|
||||
_("Alpha"), _graya_geta (color_struct.data));
|
||||
uszprintf(buf+ustrlen(buf), size, " %s %d",
|
||||
_("Alpha"), _graya_geta(color_struct.data));
|
||||
}
|
||||
}
|
||||
else if (color_struct.type == COLOR_TYPE_INDEX) {
|
||||
uszprintf (buf, size, "%s %d (RGB %d %d %d)",
|
||||
_("Index"),
|
||||
color_struct.data & 0xff,
|
||||
_rgb_scale_6[current_palette[color_struct.data & 0xff].r],
|
||||
_rgb_scale_6[current_palette[color_struct.data & 0xff].g],
|
||||
_rgb_scale_6[current_palette[color_struct.data & 0xff].b]);
|
||||
uszprintf(buf, size, "%s %d(RGB %d %d %d)",
|
||||
_("Index"),
|
||||
color_struct.data & 0xff,
|
||||
_rgb_scale_6[current_palette[color_struct.data & 0xff].r],
|
||||
_rgb_scale_6[current_palette[color_struct.data & 0xff].g],
|
||||
_rgb_scale_6[current_palette[color_struct.data & 0xff].b]);
|
||||
}
|
||||
else {
|
||||
uszprintf (buf, size, _("Unknown"));
|
||||
uszprintf(buf, size, _("Unknown"));
|
||||
}
|
||||
}
|
||||
/* short format */
|
||||
else {
|
||||
if (color_struct.type == COLOR_TYPE_MASK) {
|
||||
uszprintf (buf, size, "MASK");
|
||||
uszprintf(buf, size, "MASK");
|
||||
}
|
||||
else if (color_struct.type == COLOR_TYPE_RGB) {
|
||||
if (imgtype == IMAGE_GRAYSCALE) {
|
||||
uszprintf (buf, size, "KA %02x (%d)",
|
||||
_graya_getk (get_color_for_image (imgtype, color)),
|
||||
_graya_getk (get_color_for_image (imgtype, color)));
|
||||
uszprintf(buf, size, "KA %02x(%d)",
|
||||
_graya_getk(get_color_for_image(imgtype, color)),
|
||||
_graya_getk(get_color_for_image(imgtype, color)));
|
||||
}
|
||||
else {
|
||||
uszprintf(buf, size, "RGB %02x%02x%02x",
|
||||
_rgba_getr (color_struct.data),
|
||||
_rgba_getg (color_struct.data),
|
||||
_rgba_getb (color_struct.data));
|
||||
_rgba_getr(color_struct.data),
|
||||
_rgba_getg(color_struct.data),
|
||||
_rgba_getb(color_struct.data));
|
||||
|
||||
if (imgtype == IMAGE_INDEXED)
|
||||
uszprintf (buf+ustrlen (buf), size, " (%d)",
|
||||
get_color_for_image (imgtype, color));
|
||||
uszprintf(buf+ustrlen(buf), size, "(%d)",
|
||||
get_color_for_image(imgtype, color));
|
||||
}
|
||||
}
|
||||
else if (color_struct.type == COLOR_TYPE_GRAY) {
|
||||
uszprintf(buf, size, "I %02x (%d)",
|
||||
_graya_getk (color_struct.data),
|
||||
_graya_getk (color_struct.data));
|
||||
_graya_getk(color_struct.data),
|
||||
_graya_getk(color_struct.data));
|
||||
}
|
||||
else if (color_struct.type == COLOR_TYPE_INDEX) {
|
||||
uszprintf(buf, size, "I %02x (%d)",
|
||||
|
|
@ -511,95 +511,95 @@ void color_to_formalstring (int imgtype, const char *color, char *buf,
|
|||
}
|
||||
}
|
||||
|
||||
void draw_color (BITMAP *bmp, int x1, int y1, int x2, int y2,
|
||||
int imgtype, const char *color)
|
||||
void draw_color(BITMAP *bmp, int x1, int y1, int x2, int y2,
|
||||
int imgtype, const char *color)
|
||||
{
|
||||
int w = x2 - x1 + 1;
|
||||
int h = y2 - y1 + 1;
|
||||
BITMAP *graph;
|
||||
int grid;
|
||||
|
||||
grid = MIN (w, h) / 2;
|
||||
grid += MIN (w, h) - grid*2;
|
||||
grid = MIN(w, h) / 2;
|
||||
grid += MIN(w, h) - grid*2;
|
||||
|
||||
fill_color_struct (color);
|
||||
fill_color_struct(color);
|
||||
|
||||
if (color_struct.type == COLOR_TYPE_INDEX) {
|
||||
rectfill (bmp, x1, y1, x2, y2,
|
||||
/* get_color_for_allegro (bitmap_color_depth (bmp), color)); */
|
||||
palette_color[_index_cmap[color_struct.data & 0xff]]);
|
||||
rectfill(bmp, x1, y1, x2, y2,
|
||||
/* get_color_for_allegro(bitmap_color_depth(bmp), color)); */
|
||||
palette_color[_index_cmap[color_struct.data & 0xff]]);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (imgtype) {
|
||||
|
||||
case IMAGE_INDEXED:
|
||||
rectfill (bmp, x1, y1, x2, y2,
|
||||
palette_color[_index_cmap[get_color_for_image (imgtype, color)]]);
|
||||
rectfill(bmp, x1, y1, x2, y2,
|
||||
palette_color[_index_cmap[get_color_for_image(imgtype, color)]]);
|
||||
break;
|
||||
|
||||
case IMAGE_RGB:
|
||||
graph = create_bitmap_ex (32, w, h);
|
||||
graph = create_bitmap_ex(32, w, h);
|
||||
if (!graph)
|
||||
return;
|
||||
|
||||
rectgrid (graph, 0, 0, w-1, h-1, grid, grid);
|
||||
rectgrid(graph, 0, 0, w-1, h-1, grid, grid);
|
||||
|
||||
drawing_mode (DRAW_MODE_TRANS, NULL, 0, 0);
|
||||
set_trans_blender (0, 0, 0, color_get_alpha (imgtype, color));
|
||||
drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
|
||||
set_trans_blender(0, 0, 0, color_get_alpha(imgtype, color));
|
||||
{
|
||||
int rgb_bitmap_color = get_color_for_image (imgtype, color);
|
||||
char *color2 = color_rgb (_rgba_getr (rgb_bitmap_color),
|
||||
_rgba_getg (rgb_bitmap_color),
|
||||
_rgba_getb (rgb_bitmap_color),
|
||||
_rgba_geta (rgb_bitmap_color));
|
||||
rectfill (graph, 0, 0, w-1, h-1, get_color_for_allegro (32, color2));
|
||||
jfree (color2);
|
||||
int rgb_bitmap_color = get_color_for_image(imgtype, color);
|
||||
char *color2 = color_rgb(_rgba_getr(rgb_bitmap_color),
|
||||
_rgba_getg(rgb_bitmap_color),
|
||||
_rgba_getb(rgb_bitmap_color),
|
||||
_rgba_geta(rgb_bitmap_color));
|
||||
rectfill(graph, 0, 0, w-1, h-1, get_color_for_allegro(32, color2));
|
||||
jfree(color2);
|
||||
}
|
||||
drawing_mode (DRAW_MODE_SOLID, NULL, 0, 0);
|
||||
drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
|
||||
|
||||
use_current_sprite_rgb_map ();
|
||||
blit (graph, bmp, 0, 0, x1, y1, w, h);
|
||||
restore_rgb_map ();
|
||||
use_current_sprite_rgb_map();
|
||||
blit(graph, bmp, 0, 0, x1, y1, w, h);
|
||||
restore_rgb_map();
|
||||
|
||||
destroy_bitmap (graph);
|
||||
destroy_bitmap(graph);
|
||||
break;
|
||||
|
||||
case IMAGE_GRAYSCALE:
|
||||
graph = create_bitmap_ex (32, w, h);
|
||||
graph = create_bitmap_ex(32, w, h);
|
||||
if (!graph)
|
||||
return;
|
||||
|
||||
rectgrid (graph, 0, 0, w-1, h-1, grid, grid);
|
||||
rectgrid(graph, 0, 0, w-1, h-1, grid, grid);
|
||||
|
||||
drawing_mode (DRAW_MODE_TRANS, NULL, 0, 0);
|
||||
set_trans_blender (0, 0, 0, color_get_alpha (imgtype, color));
|
||||
drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
|
||||
set_trans_blender(0, 0, 0, color_get_alpha(imgtype, color));
|
||||
{
|
||||
int gray_bitmap_color = get_color_for_image (imgtype, color);
|
||||
char *color2 = color_gray (_graya_getk (gray_bitmap_color),
|
||||
_graya_geta (gray_bitmap_color));
|
||||
rectfill (graph, 0, 0, w-1, h-1, get_color_for_allegro(32, color2));
|
||||
jfree (color2);
|
||||
int gray_bitmap_color = get_color_for_image(imgtype, color);
|
||||
char *color2 = color_gray(_graya_getk(gray_bitmap_color),
|
||||
_graya_geta(gray_bitmap_color));
|
||||
rectfill(graph, 0, 0, w-1, h-1, get_color_for_allegro(32, color2));
|
||||
jfree(color2);
|
||||
}
|
||||
drawing_mode (DRAW_MODE_SOLID, NULL, 0, 0);
|
||||
drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
|
||||
|
||||
use_current_sprite_rgb_map ();
|
||||
blit (graph, bmp, 0, 0, x1, y1, w, h);
|
||||
restore_rgb_map ();
|
||||
use_current_sprite_rgb_map();
|
||||
blit(graph, bmp, 0, 0, x1, y1, w, h);
|
||||
restore_rgb_map();
|
||||
|
||||
destroy_bitmap (graph);
|
||||
destroy_bitmap(graph);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void fill_color_struct (const char *color)
|
||||
static void fill_color_struct(const char *color)
|
||||
{
|
||||
char *buf, *tok;
|
||||
|
||||
color_struct.type = COLOR_TYPE_MASK;
|
||||
color_struct.data = 0;
|
||||
|
||||
buf = color ? jstrdup (color): NULL;
|
||||
buf = color ? jstrdup(color): NULL;
|
||||
if (!buf)
|
||||
return;
|
||||
|
||||
|
|
@ -607,39 +607,39 @@ static void fill_color_struct (const char *color)
|
|||
if (ustrncmp (buf, "rgb{", 4) == 0) {
|
||||
int c=0, table[4] = { 0, 0, 0, 255 };
|
||||
|
||||
for (tok=ustrtok (buf+4, ","); tok;
|
||||
tok=ustrtok (NULL, ",")) {
|
||||
for (tok=ustrtok(buf+4, ","); tok;
|
||||
tok=ustrtok(NULL, ",")) {
|
||||
if (c < 4)
|
||||
table[c++] = ustrtol (tok, NULL, 10);
|
||||
table[c++] = ustrtol(tok, NULL, 10);
|
||||
}
|
||||
|
||||
color_struct.type = COLOR_TYPE_RGB;
|
||||
color_struct.data = _rgba (table[0], table[1], table[2], table[3]);
|
||||
color_struct.data = _rgba(table[0], table[1], table[2], table[3]);
|
||||
}
|
||||
else if (ustrncmp (buf, "gray{", 5) == 0) {
|
||||
int c=0, table[2] = { 0, 255 };
|
||||
|
||||
for (tok=ustrtok (buf+5, ","); tok;
|
||||
tok=ustrtok (NULL, ",")) {
|
||||
for (tok=ustrtok(buf+5, ","); tok;
|
||||
tok=ustrtok(NULL, ",")) {
|
||||
if (c < 2)
|
||||
table[c++] = ustrtol (tok, NULL, 10);
|
||||
table[c++] = ustrtol(tok, NULL, 10);
|
||||
}
|
||||
|
||||
color_struct.type = COLOR_TYPE_GRAY;
|
||||
color_struct.data = _graya (table[0], table[1]);
|
||||
color_struct.data = _graya(table[0], table[1]);
|
||||
}
|
||||
else if (ustrncmp (buf, "index{", 6) == 0) {
|
||||
color_struct.type = COLOR_TYPE_INDEX;
|
||||
color_struct.data = ustrtol (buf+6, NULL, 10);
|
||||
color_struct.data = ustrtol(buf+6, NULL, 10);
|
||||
}
|
||||
}
|
||||
|
||||
jfree (buf);
|
||||
jfree(buf);
|
||||
}
|
||||
|
||||
/* returns the same values of bitmap_mask_color() (this function *must*
|
||||
returns the same values) */
|
||||
static int get_mask_for_bitmap (int depth)
|
||||
static int get_mask_for_bitmap(int depth)
|
||||
{
|
||||
switch (depth) {
|
||||
case 8: return MASK_COLOR_8; break;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -33,8 +33,8 @@
|
|||
#endif
|
||||
|
||||
#define FIXUP_TOP_WINDOW() \
|
||||
jwindow_remap (app_get_top_window ()); \
|
||||
jwidget_dirty (app_get_top_window ());
|
||||
jwindow_remap(app_get_top_window()); \
|
||||
jwidget_dirty(app_get_top_window());
|
||||
|
||||
JWidget current_editor = NULL;
|
||||
JWidget box_editors = NULL;
|
||||
|
|
@ -95,7 +95,7 @@ void update_editors_with_sprite(Sprite *sprite)
|
|||
}
|
||||
}
|
||||
|
||||
/* void dirty_editors_with_sprite (Sprite *sprite) */
|
||||
/* void dirty_editors_with_sprite(Sprite *sprite) */
|
||||
/* { */
|
||||
/* JWidget widget; */
|
||||
/* JLink link; */
|
||||
|
|
@ -127,10 +127,10 @@ void editors_draw_sprite_tiled(Sprite *sprite, int x1, int y1, int x2, int y2)
|
|||
{
|
||||
int lx1, ly1, lx2, ly2;
|
||||
|
||||
lx1 = MAX (x1, 0);
|
||||
ly1 = MAX (y1, 0);
|
||||
lx2 = MIN (x2, sprite->w-1);
|
||||
ly2 = MIN (y2, sprite->h-1);
|
||||
lx1 = MAX(x1, 0);
|
||||
ly1 = MAX(y1, 0);
|
||||
lx2 = MIN(x2, sprite->w-1);
|
||||
ly2 = MIN(y2, sprite->h-1);
|
||||
|
||||
/* draw the rectangles inside the editor */
|
||||
editors_draw_sprite(sprite, lx1, ly1, lx2, ly2);
|
||||
|
|
@ -138,14 +138,14 @@ void editors_draw_sprite_tiled(Sprite *sprite, int x1, int y1, int x2, int y2)
|
|||
/* left */
|
||||
if (x1 < 0 && lx2 < sprite->w-1) {
|
||||
editors_draw_sprite_tiled(sprite,
|
||||
MAX (lx2, sprite->w+x1), y1,
|
||||
MAX(lx2, sprite->w+x1), y1,
|
||||
sprite->w-1, y2);
|
||||
}
|
||||
|
||||
/* top */
|
||||
if (y1 < 0 && ly2 < sprite->h-1) {
|
||||
editors_draw_sprite_tiled(sprite,
|
||||
x1, MAX (ly2, sprite->h+y1),
|
||||
x1, MAX(ly2, sprite->h+y1),
|
||||
x2, sprite->h-1);
|
||||
}
|
||||
|
||||
|
|
@ -153,14 +153,14 @@ void editors_draw_sprite_tiled(Sprite *sprite, int x1, int y1, int x2, int y2)
|
|||
if (x2 >= sprite->w && lx1 > 0) {
|
||||
editors_draw_sprite_tiled(sprite,
|
||||
0, y1,
|
||||
MIN (lx1, x2-sprite->w), y2);
|
||||
MIN(lx1, x2-sprite->w), y2);
|
||||
}
|
||||
|
||||
/* bottom */
|
||||
if (y2 >= sprite->h && ly1 > 0) {
|
||||
editors_draw_sprite_tiled(sprite,
|
||||
x1, 0,
|
||||
x2, MIN (ly1, y2-sprite->h));
|
||||
x2, MIN(ly1, y2-sprite->h));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -176,7 +176,7 @@ void editors_hide_sprite(Sprite *sprite)
|
|||
widget = link->data;
|
||||
|
||||
if (sprite == editor_get_sprite(widget))
|
||||
editor_set_sprite(widget, get_more_reliable_sprite ());
|
||||
editor_set_sprite(widget, get_more_reliable_sprite());
|
||||
}
|
||||
|
||||
if (refresh) {
|
||||
|
|
@ -299,8 +299,8 @@ void split_editor(JWidget editor, int align)
|
|||
jview_set_scroll(new_view, scroll_x, scroll_y);
|
||||
|
||||
jrect_copy(new_view->rc, view->rc);
|
||||
jrect_copy(jview_get_viewport (new_view)->rc,
|
||||
jview_get_viewport (view)->rc);
|
||||
jrect_copy(jview_get_viewport(new_view)->rc,
|
||||
jview_get_viewport(view)->rc);
|
||||
jrect_copy(new_editor->rc, editor->rc);
|
||||
|
||||
editor_data(new_editor)->offset_x = editor_data(editor)->offset_x;
|
||||
|
|
@ -374,12 +374,12 @@ void make_unique_editor(JWidget editor)
|
|||
JI_LIST_FOR_EACH_SAFE(box_editors->children, link, next) {
|
||||
child = (JWidget)link->data;
|
||||
|
||||
jwidget_remove_child (box_editors, child);
|
||||
jwidget_free (child);
|
||||
jwidget_remove_child(box_editors, child);
|
||||
jwidget_free(child);
|
||||
}
|
||||
|
||||
/* append the editor to main box */
|
||||
jwidget_add_child (box_editors, view);
|
||||
jwidget_add_child(box_editors, view);
|
||||
|
||||
/* new current editor */
|
||||
set_current_editor(editor);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -264,29 +264,29 @@ void dotted_mode(int offset)
|
|||
|
||||
if (offset < 0) {
|
||||
if (pattern) {
|
||||
destroy_bitmap (pattern);
|
||||
destroy_bitmap(pattern);
|
||||
pattern = NULL;
|
||||
}
|
||||
drawing_mode (DRAW_MODE_SOLID, NULL, 0, 0);
|
||||
drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!pattern)
|
||||
pattern = create_bitmap (8, 8);
|
||||
pattern = create_bitmap(8, 8);
|
||||
|
||||
offset = 7 - (offset & 7);
|
||||
|
||||
bg = makecol (0, 0, 0);
|
||||
fg = makecol (255, 255, 255);
|
||||
bg = makecol(0, 0, 0);
|
||||
fg = makecol(255, 255, 255);
|
||||
|
||||
clear_bitmap (pattern);
|
||||
clear_bitmap(pattern);
|
||||
|
||||
for (y=0; y<8; y++)
|
||||
for (x=0; x<8; x++)
|
||||
putpixel (pattern, x, y,
|
||||
(pattern_data[offset][y] & (1<<(7-x)))? fg: bg);
|
||||
putpixel(pattern, x, y,
|
||||
(pattern_data[offset][y] & (1<<(7-x)))? fg: bg);
|
||||
|
||||
drawing_mode (DRAW_MODE_COPY_PATTERN, pattern, 0, 0);
|
||||
drawing_mode(DRAW_MODE_COPY_PATTERN, pattern, 0, 0);
|
||||
}
|
||||
|
||||
void simple_dotted_mode(BITMAP *bmp, int fg, int bg)
|
||||
|
|
@ -296,7 +296,7 @@ void simple_dotted_mode(BITMAP *bmp, int fg, int bg)
|
|||
if (pattern && bitmap_color_depth(pattern) != bitmap_color_depth(bmp))
|
||||
destroy_bitmap(pattern);
|
||||
|
||||
pattern = create_bitmap_ex(bitmap_color_depth (bmp), 2, 2);
|
||||
pattern = create_bitmap_ex(bitmap_color_depth(bmp), 2, 2);
|
||||
clear_bitmap(pattern);
|
||||
|
||||
putpixel(pattern, 0, 0, fg);
|
||||
|
|
@ -337,7 +337,7 @@ void *subclip(BITMAP *bmp, int x1, int y1, int x2, int y2)
|
|||
|
||||
set_clip(bmp, x1, y1, x2, y2);
|
||||
|
||||
data = jnew (CLIP_DATA, 1);
|
||||
data = jnew(CLIP_DATA, 1);
|
||||
data->bmp = bmp;
|
||||
data->cl = cl;
|
||||
data->ct = ct;
|
||||
|
|
@ -366,8 +366,8 @@ typedef struct RECT_DATA
|
|||
int *pixel;
|
||||
} RECT_DATA;
|
||||
|
||||
static void do_rect (BITMAP *bmp, int x1, int y1, int x2, int y2, int c,
|
||||
void (*proc)(BITMAP *bmp, int x, int y, int c))
|
||||
static void do_rect(BITMAP *bmp, int x1, int y1, int x2, int y2, int c,
|
||||
void (*proc)(BITMAP *bmp, int x, int y, int c))
|
||||
{
|
||||
int x, y, u1, u2, v1, v2;
|
||||
|
||||
|
|
@ -375,8 +375,8 @@ static void do_rect (BITMAP *bmp, int x1, int y1, int x2, int y2, int c,
|
|||
(y2 < bmp->ct) || (y1 >= bmp->cb))
|
||||
return;
|
||||
|
||||
u1 = MID (bmp->cl, x1, bmp->cr-1);
|
||||
u2 = MID (x1, x2, bmp->cr-1);
|
||||
u1 = MID(bmp->cl, x1, bmp->cr-1);
|
||||
u2 = MID(x1, x2, bmp->cr-1);
|
||||
|
||||
if ((y1 >= bmp->ct) && (y1 < bmp->cb)) {
|
||||
for (x=u1; x<=u2; x++)
|
||||
|
|
@ -388,17 +388,17 @@ static void do_rect (BITMAP *bmp, int x1, int y1, int x2, int y2, int c,
|
|||
(*proc) (bmp, x, y2, c);
|
||||
}
|
||||
|
||||
v1 = MID (bmp->ct, y1+1, bmp->cb-1);
|
||||
v2 = MID (v1, y2-1, bmp->cb-1);
|
||||
v1 = MID(bmp->ct, y1+1, bmp->cb-1);
|
||||
v2 = MID(v1, y2-1, bmp->cb-1);
|
||||
|
||||
if ((x1 >= bmp->cl) && (x1 < bmp->cr)) {
|
||||
for (y=v1; y<=v2; y++)
|
||||
(*proc) (bmp, x1, y, c);
|
||||
(*proc)(bmp, x1, y, c);
|
||||
}
|
||||
|
||||
if ((x2 >= bmp->cl) && (x2 < bmp->cr)) {
|
||||
for (y=v1; y<=v2; y++)
|
||||
(*proc) (bmp, x2, y, c);
|
||||
(*proc)(bmp, x2, y, c);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -456,7 +456,7 @@ void rectrestore(void *_data)
|
|||
(int)data, restore_rect);
|
||||
}
|
||||
|
||||
void rectdiscard (void *_data)
|
||||
void rectdiscard(void *_data)
|
||||
{
|
||||
RECT_DATA *data = _data;
|
||||
|
||||
|
|
@ -470,29 +470,29 @@ void rectdiscard (void *_data)
|
|||
/**********************************************************************/
|
||||
/* Rectangles */
|
||||
|
||||
void bevel_box (BITMAP *bmp, int x1, int y1, int x2, int y2, int c1, int c2, int bevel)
|
||||
void bevel_box(BITMAP *bmp, int x1, int y1, int x2, int y2, int c1, int c2, int bevel)
|
||||
{
|
||||
hline (bmp, x1+bevel, y1, x2-bevel, c1); /* top */
|
||||
hline (bmp, x1+bevel, y2, x2-bevel, c2); /* bottom */
|
||||
hline(bmp, x1+bevel, y1, x2-bevel, c1); /* top */
|
||||
hline(bmp, x1+bevel, y2, x2-bevel, c2); /* bottom */
|
||||
|
||||
vline (bmp, x1, y1+bevel, y2-bevel, c1); /* left */
|
||||
vline (bmp, x2, y1+bevel, y2-bevel, c2); /* right */
|
||||
vline(bmp, x1, y1+bevel, y2-bevel, c1); /* left */
|
||||
vline(bmp, x2, y1+bevel, y2-bevel, c2); /* right */
|
||||
|
||||
line (bmp, x1, y1+bevel, x1+bevel, y1, c1); /* top-left */
|
||||
line (bmp, x1, y2-bevel, x1+bevel, y2, c2); /* bottom-left */
|
||||
line(bmp, x1, y1+bevel, x1+bevel, y1, c1); /* top-left */
|
||||
line(bmp, x1, y2-bevel, x1+bevel, y2, c2); /* bottom-left */
|
||||
|
||||
line (bmp, x2-bevel, y1, x2, y1+bevel, c2); /* top-right */
|
||||
line (bmp, x2-bevel, y2, x2, y2-bevel, c2); /* bottom-right */
|
||||
line(bmp, x2-bevel, y1, x2, y1+bevel, c2); /* top-right */
|
||||
line(bmp, x2-bevel, y2, x2, y2-bevel, c2); /* bottom-right */
|
||||
}
|
||||
|
||||
void rectdotted (BITMAP *bmp, int x1, int y1, int x2, int y2, int fg, int bg)
|
||||
void rectdotted(BITMAP *bmp, int x1, int y1, int x2, int y2, int fg, int bg)
|
||||
{
|
||||
simple_dotted_mode (bmp, fg, bg);
|
||||
rect (bmp, x1, y1, x2, y2, 0);
|
||||
solid_mode ();
|
||||
simple_dotted_mode(bmp, fg, bg);
|
||||
rect(bmp, x1, y1, x2, y2, 0);
|
||||
solid_mode();
|
||||
}
|
||||
|
||||
void rectgrid (BITMAP *bmp, int x1, int y1, int x2, int y2, int w, int h)
|
||||
void rectgrid(BITMAP *bmp, int x1, int y1, int x2, int y2, int w, int h)
|
||||
{
|
||||
int x, y, u, v, c1, c2;
|
||||
|
||||
|
|
@ -520,13 +520,13 @@ void rectgrid (BITMAP *bmp, int x1, int y1, int x2, int y2, int w, int h)
|
|||
}
|
||||
}
|
||||
|
||||
void rectfill_exclude (BITMAP *bmp, int x1, int y1, int x2, int y2, int ex1, int ey1, int ex2, int ey2, int color)
|
||||
void rectfill_exclude(BITMAP *bmp, int x1, int y1, int x2, int y2, int ex1, int ey1, int ex2, int ey2, int color)
|
||||
{
|
||||
_ji_theme_rectfill_exclude (bmp, x1, y1, x2, y2,
|
||||
ex1, ey1, ex2, ey2, color);
|
||||
_ji_theme_rectfill_exclude(bmp, x1, y1, x2, y2,
|
||||
ex1, ey1, ex2, ey2, color);
|
||||
}
|
||||
|
||||
void rectshade (BITMAP *bmp, int x1, int y1, int x2, int y2, int top, int bottom)
|
||||
void rectshade(BITMAP *bmp, int x1, int y1, int x2, int y2, int top, int bottom)
|
||||
{
|
||||
int x, y, r[3], g[3], b[3];
|
||||
|
||||
|
|
@ -563,7 +563,7 @@ void rectshade (BITMAP *bmp, int x1, int y1, int x2, int y2, int top, int bottom
|
|||
/************************************************************************/
|
||||
/* Font related */
|
||||
|
||||
int character_length (FONT *font, int chr)
|
||||
int character_length(FONT *font, int chr)
|
||||
{
|
||||
return font->vtable->char_length(font, chr);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -416,19 +416,19 @@ void gui_setup_screen(void)
|
|||
|
||||
void reload_default_font(void)
|
||||
{
|
||||
JTheme theme = ji_get_theme ();
|
||||
JTheme theme = ji_get_theme();
|
||||
const char *default_font;
|
||||
DIRS *dirs, *dir;
|
||||
|
||||
/* no font for now */
|
||||
|
||||
if (theme->default_font && theme->default_font != font)
|
||||
destroy_font (theme->default_font);
|
||||
destroy_font(theme->default_font);
|
||||
|
||||
theme->default_font = NULL;
|
||||
|
||||
/* directories */
|
||||
dirs = dirs_new ();
|
||||
dirs = dirs_new();
|
||||
|
||||
default_font = get_config_string("Options", "DefaultFont", "");
|
||||
if ((default_font) && (*default_font))
|
||||
|
|
@ -443,7 +443,7 @@ void reload_default_font(void)
|
|||
|
||||
/* try to load the font */
|
||||
for (dir=dirs; dir; dir=dir->next) {
|
||||
theme->default_font = ji_font_load (dir->path);
|
||||
theme->default_font = ji_font_load(dir->path);
|
||||
if (theme->default_font) {
|
||||
if (ji_font_is_scalable (theme->default_font)) {
|
||||
ji_font_set_size(theme->default_font,
|
||||
|
|
@ -453,7 +453,7 @@ void reload_default_font(void)
|
|||
}
|
||||
}
|
||||
|
||||
dirs_free (dirs);
|
||||
dirs_free(dirs);
|
||||
|
||||
/* default font: the Allegro one */
|
||||
|
||||
|
|
@ -667,7 +667,7 @@ void add_gfxicon_to_button(JWidget button, int gfx_id, int icon_align)
|
|||
jlist_append(icon_buttons, button);
|
||||
}
|
||||
|
||||
void set_gfxicon_in_button (JWidget button, int gfx_id)
|
||||
void set_gfxicon_in_button(JWidget button, int gfx_id)
|
||||
{
|
||||
button->user_data[3] = (void *)gfx_id;
|
||||
|
||||
|
|
@ -676,7 +676,7 @@ void set_gfxicon_in_button (JWidget button, int gfx_id)
|
|||
jwidget_dirty(button);
|
||||
}
|
||||
|
||||
static bool button_with_icon_msg_proc (JWidget widget, JMessage msg)
|
||||
static bool button_with_icon_msg_proc(JWidget widget, JMessage msg)
|
||||
{
|
||||
if (msg->type == JM_DESTROY)
|
||||
jlist_remove(icon_buttons, widget);
|
||||
|
|
@ -751,17 +751,17 @@ void change_to_button_style(JWidget widget, int b1, int b2, int b3, int b4)
|
|||
|
||||
/* put a cusomized hook to filter only some messages to the real
|
||||
JI_BUTTON hook msg_proc */
|
||||
jwidget_add_hook (widget, button_style_type (), button_style_msg_proc, hook);
|
||||
jwidget_add_hook(widget, button_style_type(), button_style_msg_proc, hook);
|
||||
|
||||
/* setup widget geometry */
|
||||
widget->align = button->align;
|
||||
widget->border_width = button->border_width;
|
||||
widget->draw_method = button->draw_method;
|
||||
|
||||
/* jwidget_set_border (widget, 2, 2, 2, 2); */
|
||||
/* jwidget_set_border(widget, 2, 2, 2, 2); */
|
||||
|
||||
/* the data will be free after */
|
||||
jwidget_free (button);
|
||||
jwidget_free(button);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -63,9 +63,9 @@ static RGB system_color[] =
|
|||
|
||||
int init_module_palette(void)
|
||||
{
|
||||
orig_rgb_map = jnew (RGB_MAP, 1);
|
||||
orig_trans_map = jnew (COLOR_MAP, 1);
|
||||
my_rgb_map = jnew (RGB_MAP, 1);
|
||||
orig_rgb_map = jnew(RGB_MAP, 1);
|
||||
orig_trans_map = jnew(COLOR_MAP, 1);
|
||||
my_rgb_map = jnew(RGB_MAP, 1);
|
||||
|
||||
hooks = jlist_new();
|
||||
rgb_map = my_rgb_map;
|
||||
|
|
@ -179,7 +179,7 @@ bool set_current_palette(RGB *_palette, int forced)
|
|||
}
|
||||
|
||||
/* changes a color of the current system palette */
|
||||
void set_current_color (int index, int r, int g, int b)
|
||||
void set_current_color(int index, int r, int g, int b)
|
||||
{
|
||||
if (index >= 0 && index <= 255 &&
|
||||
(current_palette[index].r != r ||
|
||||
|
|
@ -193,24 +193,24 @@ void set_current_color (int index, int r, int g, int b)
|
|||
(_index_cmap[index] != index))
|
||||
_index_cmap[index] = index;
|
||||
|
||||
set_color (index, &rgb);
|
||||
set_color(index, &rgb);
|
||||
}
|
||||
}
|
||||
|
||||
/* inserts a new palette-hook in the end of the list */
|
||||
void hook_palette_changes (void (*proc)(void))
|
||||
void hook_palette_changes(void (*proc)(void))
|
||||
{
|
||||
jlist_append(hooks, proc);
|
||||
}
|
||||
|
||||
/* removes a palette-hook */
|
||||
void unhook_palette_changes (void (*proc)(void))
|
||||
void unhook_palette_changes(void (*proc)(void))
|
||||
{
|
||||
jlist_remove(hooks, proc);
|
||||
}
|
||||
|
||||
/* calls all hooks */
|
||||
void call_palette_hooks (void)
|
||||
void call_palette_hooks(void)
|
||||
{
|
||||
JLink link;
|
||||
|
||||
|
|
@ -223,7 +223,7 @@ void call_palette_hooks (void)
|
|||
|
||||
static int regen_rgb_map = FALSE;
|
||||
|
||||
void use_current_sprite_rgb_map (void)
|
||||
void use_current_sprite_rgb_map(void)
|
||||
{
|
||||
rgb_map = orig_rgb_map;
|
||||
}
|
||||
|
|
@ -237,20 +237,20 @@ void use_sprite_rgb_map(Sprite *sprite)
|
|||
sprite_get_palette(sprite, sprite->frame), NULL);
|
||||
}
|
||||
|
||||
void restore_rgb_map (void)
|
||||
void restore_rgb_map(void)
|
||||
{
|
||||
rgb_map = my_rgb_map;
|
||||
|
||||
if (regen_rgb_map) {
|
||||
regen_rgb_map = FALSE;
|
||||
create_rgb_table (my_rgb_map, _current_palette, NULL);
|
||||
create_rgb_table(my_rgb_map, _current_palette, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
/* creates a linear ramp in the palette */
|
||||
void make_palette_ramp (RGB *p, int from, int to)
|
||||
void make_palette_ramp(RGB *p, int from, int to)
|
||||
{
|
||||
float rv, gv, bv;
|
||||
float rd, gd, bd;
|
||||
|
|
@ -287,20 +287,20 @@ void make_palette_ramp (RGB *p, int from, int to)
|
|||
}
|
||||
|
||||
/* creates a rectangular ramp in the palette */
|
||||
void make_palette_rect_ramp (RGB *p, int from, int to, int cols)
|
||||
void make_palette_rect_ramp(RGB *p, int from, int to, int cols)
|
||||
{
|
||||
float rv1, gv1, bv1, rv2, gv2, bv2;
|
||||
float rd1, gd1, bd1, rd2, gd2, bd2;
|
||||
int imin = MIN (from, to);
|
||||
int imax = MAX (from, to);
|
||||
int imin = MIN(from, to);
|
||||
int imax = MAX(from, to);
|
||||
int xmin = imin % cols;
|
||||
int ymin = imin / cols;
|
||||
int xmax = imax % cols;
|
||||
int ymax = imax / cols;
|
||||
int x1 = MIN (xmin, xmax);
|
||||
int y1 = MIN (ymin, ymax);
|
||||
int x2 = MAX (xmin, xmax);
|
||||
int y2 = MAX (ymin, ymax);
|
||||
int x1 = MIN(xmin, xmax);
|
||||
int y1 = MIN(ymin, ymax);
|
||||
int x2 = MAX(xmin, xmax);
|
||||
int y2 = MAX(ymin, ymax);
|
||||
int i, rows;
|
||||
|
||||
rows = y2 - y1;
|
||||
|
|
@ -345,7 +345,7 @@ void make_palette_rect_ramp (RGB *p, int from, int to, int cols)
|
|||
p[i*cols+x2].b = bv2;
|
||||
|
||||
/* ramp from left to right side */
|
||||
make_palette_ramp (p, i*cols+x1, i*cols+x2);
|
||||
make_palette_ramp(p, i*cols+x1, i*cols+x2);
|
||||
|
||||
rv1 += rd1;
|
||||
gv1 += gd1;
|
||||
|
|
@ -381,61 +381,61 @@ int palette_diff(RGB *p1, RGB *p2, int *from, int *to)
|
|||
|
||||
void palette_copy(RGB *dst, RGB *src)
|
||||
{
|
||||
memcpy(dst, src, sizeof (PALETTE));
|
||||
memcpy(dst, src, sizeof(PALETTE));
|
||||
}
|
||||
|
||||
RGB *palette_load (const char *filename)
|
||||
RGB *palette_load(const char *filename)
|
||||
{
|
||||
RGB *palette = NULL;
|
||||
char ext[64];
|
||||
|
||||
ustrcpy (ext, get_extension (filename));
|
||||
ustrcpy(ext, get_extension(filename));
|
||||
|
||||
if ((ustricmp (ext, "pcx") == 0) ||
|
||||
(ustricmp (ext, "bmp") == 0) ||
|
||||
(ustricmp (ext, "tga") == 0) ||
|
||||
(ustricmp (ext, "lbm") == 0)) {
|
||||
if ((ustricmp(ext, "pcx") == 0) ||
|
||||
(ustricmp(ext, "bmp") == 0) ||
|
||||
(ustricmp(ext, "tga") == 0) ||
|
||||
(ustricmp(ext, "lbm") == 0)) {
|
||||
BITMAP *bmp;
|
||||
|
||||
palette = jmalloc (sizeof (PALETTE));
|
||||
bmp = load_bitmap (filename, palette);
|
||||
palette = jmalloc(sizeof(PALETTE));
|
||||
bmp = load_bitmap(filename, palette);
|
||||
if (bmp)
|
||||
destroy_bitmap (bmp);
|
||||
destroy_bitmap(bmp);
|
||||
else {
|
||||
jfree (palette);
|
||||
jfree(palette);
|
||||
palette = NULL;
|
||||
}
|
||||
}
|
||||
else if (ustricmp (ext, "col") == 0) {
|
||||
palette = load_col_file (filename);
|
||||
else if (ustricmp(ext, "col") == 0) {
|
||||
palette = load_col_file(filename);
|
||||
}
|
||||
|
||||
return palette;
|
||||
}
|
||||
|
||||
int palette_save (RGB *palette, const char *filename)
|
||||
int palette_save(RGB *palette, const char *filename)
|
||||
{
|
||||
int ret = -1;
|
||||
char ext[64];
|
||||
|
||||
ustrcpy (ext, get_extension (filename));
|
||||
ustrcpy(ext, get_extension(filename));
|
||||
|
||||
if ((ustricmp (ext, "pcx") == 0) ||
|
||||
(ustricmp (ext, "bmp") == 0) ||
|
||||
(ustricmp (ext, "tga") == 0)) {
|
||||
if ((ustricmp(ext, "pcx") == 0) ||
|
||||
(ustricmp(ext, "bmp") == 0) ||
|
||||
(ustricmp(ext, "tga") == 0)) {
|
||||
int c, x, y;
|
||||
BITMAP *bmp;
|
||||
|
||||
bmp = create_bitmap_ex (8, 16, 16);
|
||||
bmp = create_bitmap_ex(8, 16, 16);
|
||||
for (y=c=0; y<16; y++)
|
||||
for (x=0; x<16; x++)
|
||||
putpixel (bmp, x, y, c++);
|
||||
putpixel(bmp, x, y, c++);
|
||||
|
||||
ret = save_bitmap (filename, bmp, palette);
|
||||
destroy_bitmap (bmp);
|
||||
ret = save_bitmap(filename, bmp, palette);
|
||||
destroy_bitmap(bmp);
|
||||
}
|
||||
else if (ustricmp (ext, "col") == 0) {
|
||||
ret = save_col_file (palette, filename);
|
||||
else if (ustricmp(ext, "col") == 0) {
|
||||
ret = save_col_file(palette, filename);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue