mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-30 04:20:23 +00:00
Removed a lot of GUI functionality for scripting.
Added support to save PNG files. Added alternative dirty rectangles technique to Jinete.
This commit is contained in:
parent
c50df75059
commit
d1c38d7dfe
@ -1,3 +1,12 @@
|
||||
2007-12-05 David A. Capello <dacap@users.sourceforge.net>
|
||||
|
||||
* src/widgets/statebar.c (status_bar_set_text): Uses dirty
|
||||
region. This optimized the speed of the loading bar.
|
||||
|
||||
* src/jinete/jsystem.c (ji_flip_dirty_region): Added dirty region.
|
||||
|
||||
* src/file/png_format.c (save_png): Added.
|
||||
|
||||
2007-12-03 David A. Capello <dacap@users.sourceforge.net>
|
||||
|
||||
* src/raster/sprite.h (struct Sprite): Added "stock" (now the
|
||||
|
2
NEWS.txt
2
NEWS.txt
@ -18,7 +18,7 @@ NEWS
|
||||
+ GUI enhanced:
|
||||
+ more borders for windows and more spacing between widgets.
|
||||
+ better mouse behavior (in Windows).
|
||||
+ Added support for PNG files (through libpng).
|
||||
+ Added support to load and save PNG files (through libpng).
|
||||
+ Finished the support for ICO files.
|
||||
+ Finally screen scaling supported (with double-buffering). This means
|
||||
that you can use a screen of 320x240 between a window of 640x480
|
||||
|
17
makefile.lst
17
makefile.lst
@ -118,7 +118,7 @@ COMMON_SOURCES = \
|
||||
src/jinete/jalert.c \
|
||||
src/jinete/jbox.c \
|
||||
src/jinete/jbutton.c \
|
||||
src/jinete/jclipbrd.c \
|
||||
src/jinete/jclipboard.c \
|
||||
src/jinete/jcombox.c \
|
||||
src/jinete/jdraw.c \
|
||||
src/jinete/jentry.c \
|
||||
@ -137,7 +137,7 @@ COMMON_SOURCES = \
|
||||
src/jinete/jmenu.c \
|
||||
src/jinete/jmessage.c \
|
||||
src/jinete/jpanel.c \
|
||||
src/jinete/jqckmenu.c \
|
||||
src/jinete/jquickmenu.c \
|
||||
src/jinete/jrect.c \
|
||||
src/jinete/jregion.c \
|
||||
src/jinete/jsep.c \
|
||||
@ -150,8 +150,7 @@ COMMON_SOURCES = \
|
||||
src/jinete/jwidget.c \
|
||||
src/jinete/jwindow.c \
|
||||
src/jinete/jxml.c \
|
||||
src/jinete/themes/jsimple.c \
|
||||
src/jinete/themes/jstand.c \
|
||||
src/jinete/themes/jstandard_theme.c \
|
||||
src/modules/color.c \
|
||||
src/modules/editors.c \
|
||||
src/modules/gfx.c \
|
||||
@ -214,14 +213,14 @@ COMMON_SOURCES = \
|
||||
src/widgets/target.c \
|
||||
src/widgets/toolbar.c
|
||||
|
||||
COMMON_OBJS = $(addprefix $(OBJ_DIR)/, \
|
||||
$(addsuffix $(OBJ), \
|
||||
$(notdir $(basename $(COMMON_SOURCES)))))
|
||||
COMMON_OBJS = $(addprefix $(OBJ_DIR)/, \
|
||||
$(addsuffix $(OBJ), \
|
||||
$(notdir $(basename $(COMMON_SOURCES)))))
|
||||
|
||||
ASE_SOURCES = src/main.c $(COMMON_SOURCES)
|
||||
|
||||
ASE_OBJS = $(addprefix $(OBJ_DIR)/, \
|
||||
$(addsuffix $(OBJ), \
|
||||
ASE_OBJS = $(addprefix $(OBJ_DIR)/, \
|
||||
$(addsuffix $(OBJ), \
|
||||
$(notdir $(basename $(ASE_SOURCES)))))
|
||||
|
||||
######################################################################
|
||||
|
18
misc/deps.sh
18
misc/deps.sh
@ -1,31 +1,20 @@
|
||||
#! /bin/sh
|
||||
|
||||
# Jinete dependencies
|
||||
|
||||
GCC="gcc -MM"
|
||||
CFLAGS="-Iinclude -Ifreetype/include"
|
||||
|
||||
cd jinete
|
||||
$GCC $CFLAGS src/*.c \
|
||||
| sed -e 's/^\([a-z_\-]*\.o\)/obj\/mingw32\/\1/' > makefile.dep
|
||||
cd ..
|
||||
|
||||
# ASE dependencies
|
||||
|
||||
CFLAGS="-I. \
|
||||
-Isrc -Ijinete/include -Ilibase \
|
||||
-Isrc \
|
||||
-Ithird_party/lua/include \
|
||||
-Ithird_party/gfli \
|
||||
-Ithird_party/intl \
|
||||
-Ithird_party/libpng \
|
||||
-Ithird_party/zlib \
|
||||
-Ithird_party/jpeg \
|
||||
-Ijinete/freetype/include \
|
||||
-Ithird_party/freetype/include \
|
||||
-Ithird_party"
|
||||
|
||||
rm -f makefile.dep
|
||||
|
||||
$GCC $CFLAGS jinete/src/*.c \
|
||||
$GCC $CFLAGS \
|
||||
src/*.c \
|
||||
src/commands/*.c \
|
||||
src/commands/fx/*.c \
|
||||
@ -35,6 +24,7 @@ $GCC $CFLAGS jinete/src/*.c \
|
||||
src/effect/*.c \
|
||||
src/file/*.c \
|
||||
src/intl/*.c \
|
||||
src/jinete/*.c \
|
||||
src/modules/*.c \
|
||||
src/raster/*.c \
|
||||
src/script/bindings.c src/script/script.c \
|
||||
|
@ -240,9 +240,6 @@ void app_loop(void)
|
||||
jmanager_refresh_screen();
|
||||
}
|
||||
|
||||
/* load all startup scripts */
|
||||
load_all_scripts();
|
||||
|
||||
/* set background mode for non-GUI modes */
|
||||
/* if (!(ase_mode & MODE_GUI)) */
|
||||
/* set_display_switch_mode(SWITCH_BACKAMNESIA); */
|
||||
|
@ -31,8 +31,8 @@
|
||||
|
||||
#endif
|
||||
|
||||
static Sprite *load_BMP (const char *filename);
|
||||
static int save_BMP (Sprite *sprite);
|
||||
static Sprite *load_BMP(const char *filename);
|
||||
static int save_BMP(Sprite *sprite);
|
||||
|
||||
FileFormat format_bmp =
|
||||
{
|
||||
@ -500,7 +500,7 @@ static void read_bitfields_image (PACKFILE *f, Image *image, int bpp, BITMAPINFO
|
||||
}
|
||||
}
|
||||
|
||||
static Sprite *load_BMP (const char *filename)
|
||||
static Sprite *load_BMP(const char *filename)
|
||||
{
|
||||
BITMAPFILEHEADER fileheader;
|
||||
BITMAPINFOHEADER infoheader;
|
||||
@ -618,7 +618,7 @@ static Sprite *load_BMP (const char *filename)
|
||||
return sprite;
|
||||
}
|
||||
|
||||
static int save_BMP (Sprite *sprite)
|
||||
static int save_BMP(Sprite *sprite)
|
||||
{
|
||||
Image *image;
|
||||
PACKFILE *f;
|
||||
|
@ -442,7 +442,8 @@ int sprite_save(Sprite *sprite)
|
||||
usprintf(buf+ustrlen(buf), "<<- %s", _("RGB format"));
|
||||
fatal = TRUE;
|
||||
}
|
||||
if (!(file->flags & FILE_SUPPORT_RGBA)) {
|
||||
if (!(file->flags & FILE_SUPPORT_RGBA) &&
|
||||
_rgba_geta(sprite->bgcolor) < 255) {
|
||||
usprintf(buf+ustrlen(buf), "<<- %s", _("Alpha channel"));
|
||||
}
|
||||
break;
|
||||
@ -452,7 +453,8 @@ int sprite_save(Sprite *sprite)
|
||||
usprintf(buf+ustrlen(buf), "<<- %s", _("Grayscale format"));
|
||||
fatal = TRUE;
|
||||
}
|
||||
if (!(file->flags & FILE_SUPPORT_GRAYA)) {
|
||||
if (!(file->flags & FILE_SUPPORT_GRAYA) &&
|
||||
_graya_geta(sprite->bgcolor) < 255) {
|
||||
usprintf(buf+ustrlen(buf), "<<- %s", _("Alpha channel"));
|
||||
}
|
||||
break;
|
||||
|
@ -38,8 +38,8 @@
|
||||
|
||||
#include "jpeglib.h"
|
||||
|
||||
static Sprite *load_jpeg(const char *filename);
|
||||
static int save_jpeg(Sprite *sprite);
|
||||
static Sprite *load_JPEG(const char *filename);
|
||||
static int save_JPEG(Sprite *sprite);
|
||||
|
||||
static int configure_jpeg(void);
|
||||
|
||||
@ -47,8 +47,8 @@ FileFormat format_jpeg =
|
||||
{
|
||||
"jpeg",
|
||||
"jpeg,jpg",
|
||||
load_jpeg,
|
||||
save_jpeg,
|
||||
load_JPEG,
|
||||
save_JPEG,
|
||||
FILE_SUPPORT_RGB |
|
||||
FILE_SUPPORT_GRAY |
|
||||
FILE_SUPPORT_SEQUENCES
|
||||
@ -90,7 +90,7 @@ static void output_message(j_common_ptr cinfo)
|
||||
console_printf("%s\n", buffer);
|
||||
}
|
||||
|
||||
static Sprite *load_jpeg(const char *filename)
|
||||
static Sprite *load_JPEG(const char *filename)
|
||||
{
|
||||
struct jpeg_decompress_struct cinfo;
|
||||
struct error_mgr jerr;
|
||||
@ -233,7 +233,7 @@ static Sprite *load_jpeg(const char *filename)
|
||||
return file_sequence_sprite();
|
||||
}
|
||||
|
||||
static int save_jpeg(Sprite *sprite)
|
||||
static int save_JPEG(Sprite *sprite)
|
||||
{
|
||||
struct jpeg_compress_struct cinfo;
|
||||
struct jpeg_error_mgr jerr;
|
||||
|
@ -31,8 +31,8 @@
|
||||
|
||||
#endif
|
||||
|
||||
static Sprite *load_PCX (const char *filename);
|
||||
static int save_PCX (Sprite *sprite);
|
||||
static Sprite *load_PCX(const char *filename);
|
||||
static int save_PCX(Sprite *sprite);
|
||||
|
||||
FileFormat format_pcx =
|
||||
{
|
||||
@ -46,7 +46,7 @@ FileFormat format_pcx =
|
||||
FILE_SUPPORT_SEQUENCES
|
||||
};
|
||||
|
||||
static Sprite *load_PCX (const char *filename)
|
||||
static Sprite *load_PCX(const char *filename)
|
||||
{
|
||||
Image *image;
|
||||
PACKFILE *f;
|
||||
@ -178,7 +178,7 @@ static Sprite *load_PCX (const char *filename)
|
||||
return file_sequence_sprite ();
|
||||
}
|
||||
|
||||
static int save_PCX (Sprite *sprite)
|
||||
static int save_PCX(Sprite *sprite)
|
||||
{
|
||||
PACKFILE *f;
|
||||
Image *image;
|
||||
|
@ -30,12 +30,14 @@
|
||||
#include "file/file.h"
|
||||
#include "raster/raster.h"
|
||||
#include "script/script.h"
|
||||
|
||||
#define PNG_NO_TYPECAST_NULL
|
||||
#include "png.h"
|
||||
|
||||
#endif
|
||||
|
||||
static Sprite *load_png(const char *filename);
|
||||
static int save_png(Sprite *sprite);
|
||||
static Sprite *load_PNG(const char *filename);
|
||||
static int save_PNG(Sprite *sprite);
|
||||
|
||||
/* static int configure_png(void); */
|
||||
|
||||
@ -43,8 +45,8 @@ FileFormat format_png =
|
||||
{
|
||||
"png",
|
||||
"png",
|
||||
load_png,
|
||||
save_png,
|
||||
load_PNG,
|
||||
save_PNG,
|
||||
FILE_SUPPORT_RGB |
|
||||
FILE_SUPPORT_RGBA |
|
||||
FILE_SUPPORT_GRAY |
|
||||
@ -53,56 +55,18 @@ FileFormat format_png =
|
||||
FILE_SUPPORT_SEQUENCES
|
||||
};
|
||||
|
||||
/* static void progress_monitor(j_common_ptr cinfo) */
|
||||
/* { */
|
||||
/* if (cinfo->progress->pass_limit > 1) */
|
||||
/* do_progress(100 * */
|
||||
/* (cinfo->progress->pass_counter) / */
|
||||
/* (cinfo->progress->pass_limit-1)); */
|
||||
/* } */
|
||||
|
||||
/* struct error_mgr { */
|
||||
/* struct jpeg_error_mgr pub; */
|
||||
/* jmp_buf setjmp_buffer; */
|
||||
/* }; */
|
||||
|
||||
/* static void error_exit(j_common_ptr cinfo) */
|
||||
/* { */
|
||||
/* /\* Display the message. *\/ */
|
||||
/* (*cinfo->err->output_message)(cinfo); */
|
||||
|
||||
/* /\* Return control to the setjmp point. *\/ */
|
||||
/* longjmp(((struct error_mgr *)cinfo->err)->setjmp_buffer, 1); */
|
||||
/* } */
|
||||
|
||||
/* static void output_message(j_common_ptr cinfo) */
|
||||
/* { */
|
||||
/* char buffer[JMSG_LENGTH_MAX]; */
|
||||
|
||||
/* /\* Format the message. *\/ */
|
||||
/* (*cinfo->err->format_message)(cinfo, buffer); */
|
||||
|
||||
/* /\* Put in the log file if. *\/ */
|
||||
/* PRINTF("JPEG library: \"%s\"\n", buffer); */
|
||||
|
||||
/* /\* Leave the message for the application. *\/ */
|
||||
/* console_printf("%s\n", buffer); */
|
||||
/* } */
|
||||
|
||||
static void report_png_error(png_structp png_ptr, png_const_charp error)
|
||||
{
|
||||
console_printf("libpng: %s\n", error);
|
||||
}
|
||||
|
||||
static Sprite *load_png(const char *filename)
|
||||
static Sprite *load_PNG(const char *filename)
|
||||
{
|
||||
png_uint_32 width, height, y;
|
||||
unsigned int sig_read = 0;
|
||||
png_structp png_ptr;
|
||||
png_infop info_ptr;
|
||||
int bit_depth, color_type, interlace_type;
|
||||
int intent, screen_gamma;
|
||||
int max_screen_colors = 256;
|
||||
int pass, number_passes;
|
||||
int num_palette;
|
||||
png_colorp palette;
|
||||
@ -186,10 +150,6 @@ static Sprite *load_png(const char *filename)
|
||||
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
|
||||
png_set_gray_1_2_4_to_8(png_ptr);
|
||||
|
||||
/* Note that screen gamma is the display_exponent, which includes
|
||||
* the CRT_exponent and any correction for viewing conditions */
|
||||
screen_gamma = 2.2;
|
||||
|
||||
/* Turn on interlace handling. REQUIRED if you are not using
|
||||
* png_read_image(). To see how to handle interlacing passes,
|
||||
* see the png_read_row() method below:
|
||||
@ -203,6 +163,10 @@ static Sprite *load_png(const char *filename)
|
||||
|
||||
/* create the output image */
|
||||
switch (info_ptr->color_type) {
|
||||
case PNG_COLOR_TYPE_RGB:
|
||||
case PNG_COLOR_TYPE_RGB_ALPHA:
|
||||
imgtype = IMAGE_RGB;
|
||||
break;
|
||||
case PNG_COLOR_TYPE_GRAY:
|
||||
case PNG_COLOR_TYPE_GRAY_ALPHA:
|
||||
imgtype = IMAGE_GRAYSCALE;
|
||||
@ -210,10 +174,6 @@ static Sprite *load_png(const char *filename)
|
||||
case PNG_COLOR_TYPE_PALETTE:
|
||||
imgtype = IMAGE_INDEXED;
|
||||
break;
|
||||
case PNG_COLOR_TYPE_RGB:
|
||||
case PNG_COLOR_TYPE_RGB_ALPHA:
|
||||
imgtype = IMAGE_RGB;
|
||||
break;
|
||||
default:
|
||||
console_printf("Color type not supported\n)");
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
|
||||
@ -252,13 +212,14 @@ static Sprite *load_png(const char *filename)
|
||||
row_pointer = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr));
|
||||
for (pass = 0; pass < number_passes; pass++) {
|
||||
for (y = 0; y < height; y++) {
|
||||
/* read the line */
|
||||
png_read_row(png_ptr, row_pointer, png_bytepp_NULL);
|
||||
|
||||
/* RGB_ALPHA */
|
||||
if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
|
||||
unsigned char *src_address = row_pointer;
|
||||
unsigned long *dst_address = ((unsigned long **)image->line)[y];
|
||||
int x, r, g, b, a;
|
||||
register unsigned char *src_address = row_pointer;
|
||||
register unsigned long *dst_address = ((unsigned long **)image->line)[y];
|
||||
register int x, r, g, b, a;
|
||||
|
||||
for (x=0; x<width; x++) {
|
||||
r = *(src_address++);
|
||||
@ -270,9 +231,9 @@ static Sprite *load_png(const char *filename)
|
||||
}
|
||||
/* RGB */
|
||||
else if (info_ptr->color_type == PNG_COLOR_TYPE_RGB) {
|
||||
unsigned char *src_address = row_pointer;
|
||||
unsigned long *dst_address = ((unsigned long **)image->line)[y];
|
||||
int x, r, g, b;
|
||||
register unsigned char *src_address = row_pointer;
|
||||
register unsigned long *dst_address = ((unsigned long **)image->line)[y];
|
||||
register int x, r, g, b;
|
||||
|
||||
for (x=0; x<width; x++) {
|
||||
r = *(src_address++);
|
||||
@ -283,9 +244,9 @@ static Sprite *load_png(const char *filename)
|
||||
}
|
||||
/* GRAY_ALPHA */
|
||||
else if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
|
||||
unsigned char *src_address = row_pointer;
|
||||
unsigned short *dst_address = ((unsigned short **)image->line)[y];
|
||||
int x, k, a;
|
||||
register unsigned char *src_address = row_pointer;
|
||||
register unsigned short *dst_address = ((unsigned short **)image->line)[y];
|
||||
register int x, k, a;
|
||||
|
||||
for (x=0; x<width; x++) {
|
||||
k = *(src_address++);
|
||||
@ -295,8 +256,8 @@ static Sprite *load_png(const char *filename)
|
||||
}
|
||||
/* GRAY */
|
||||
else if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY) {
|
||||
unsigned char *src_address = row_pointer;
|
||||
unsigned short *dst_address = ((unsigned short **)image->line)[y];
|
||||
register unsigned char *src_address = row_pointer;
|
||||
register unsigned short *dst_address = ((unsigned short **)image->line)[y];
|
||||
int x, k;
|
||||
|
||||
for (x=0; x<width; x++) {
|
||||
@ -306,9 +267,9 @@ static Sprite *load_png(const char *filename)
|
||||
}
|
||||
/* PALETTE */
|
||||
else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
|
||||
unsigned char *src_address = row_pointer;
|
||||
unsigned char *dst_address = ((unsigned char **)image->line)[y];
|
||||
int x, c;
|
||||
register unsigned char *src_address = row_pointer;
|
||||
register unsigned char *dst_address = ((unsigned char **)image->line)[y];
|
||||
register int x, c;
|
||||
|
||||
for (x=0; x<width; x++) {
|
||||
c = *(src_address++);
|
||||
@ -331,150 +292,216 @@ static Sprite *load_png(const char *filename)
|
||||
return file_sequence_sprite();
|
||||
}
|
||||
|
||||
static int save_png(Sprite *sprite)
|
||||
static int save_PNG(Sprite *sprite)
|
||||
{
|
||||
#if 0
|
||||
struct jpeg_compress_struct cinfo;
|
||||
struct jpeg_error_mgr jerr;
|
||||
struct jpeg_progress_mgr progress;
|
||||
FILE *file;
|
||||
JSAMPARRAY buffer;
|
||||
JDIMENSION buffer_height;
|
||||
png_uint_32 width, height, y;
|
||||
png_structp png_ptr;
|
||||
png_infop info_ptr;
|
||||
png_colorp palette;
|
||||
png_bytep row_pointer;
|
||||
int color_type;
|
||||
Image *image;
|
||||
int c;
|
||||
int smooth;
|
||||
int quality;
|
||||
J_DCT_METHOD method;
|
||||
int pass, number_passes;
|
||||
FILE *fp;
|
||||
|
||||
/* Configure JPEG compression only in the first frame. */
|
||||
if (sprite->frpos == 0 && configure_jpeg() < 0)
|
||||
return 0;
|
||||
/* open the file */
|
||||
fp = fopen(sprite->filename, "wb");
|
||||
if (fp == NULL)
|
||||
return -1;
|
||||
|
||||
/* Options. */
|
||||
smooth = get_config_int("JPEG", "Smooth", 0);
|
||||
quality = get_config_int("JPEG", "Quality", 100);
|
||||
method = get_config_int("JPEG", "Method", JDCT_DEFAULT);
|
||||
|
||||
/* Open the file for write in it. */
|
||||
file = fopen(sprite->filename, "wb");
|
||||
if (!file) {
|
||||
console_printf(_("Error creating file.\n"));
|
||||
/* Create and initialize the png_struct with the desired error handler
|
||||
* functions. If you want to use the default stderr and longjump method,
|
||||
* you can supply NULL for the last three parameters. We also check that
|
||||
* the library version is compatible with the one used at compile time,
|
||||
* in case we are using dynamically linked libraries. REQUIRED.
|
||||
*/
|
||||
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL,
|
||||
report_png_error, report_png_error);
|
||||
if (png_ptr == NULL) {
|
||||
fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Allocate/initialize the image information data. REQUIRED */
|
||||
info_ptr = png_create_info_struct(png_ptr);
|
||||
if (info_ptr == NULL) {
|
||||
fclose(fp);
|
||||
png_destroy_write_struct(&png_ptr, png_infopp_NULL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Set error handling. REQUIRED if you aren't supplying your own
|
||||
* error handling functions in the png_create_write_struct() call.
|
||||
*/
|
||||
if (setjmp(png_jmpbuf(png_ptr))) {
|
||||
/* If we get here, we had a problem reading the file */
|
||||
fclose(fp);
|
||||
png_destroy_write_struct(&png_ptr, &info_ptr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* set up the output control if you are using standard C streams */
|
||||
png_init_io(png_ptr, fp);
|
||||
|
||||
/* Set the image information here. Width and height are up to 2^31,
|
||||
* bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on
|
||||
* the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY,
|
||||
* PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB,
|
||||
* or PNG_COLOR_TYPE_RGB_ALPHA. interlace is either PNG_INTERLACE_NONE or
|
||||
* PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST
|
||||
* currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE. REQUIRED
|
||||
*/
|
||||
image = file_sequence_image_to_save();
|
||||
width = image->w;
|
||||
height = image->h;
|
||||
|
||||
/* Allocate and initialize JPEG compression object. */
|
||||
cinfo.err = jpeg_std_error(&jerr);
|
||||
jpeg_create_compress(&cinfo);
|
||||
|
||||
/* Specify data destination file. */
|
||||
jpeg_stdio_dest(&cinfo, file);
|
||||
|
||||
/* Set parameters for compression. */
|
||||
cinfo.image_width = image->w;
|
||||
cinfo.image_height = image->h;
|
||||
|
||||
if (image->imgtype == IMAGE_GRAYSCALE) {
|
||||
cinfo.input_components = 1;
|
||||
cinfo.in_color_space = JCS_GRAYSCALE;
|
||||
}
|
||||
else {
|
||||
cinfo.input_components = 3;
|
||||
cinfo.in_color_space = JCS_RGB;
|
||||
switch (image->imgtype) {
|
||||
case IMAGE_RGB:
|
||||
color_type = _rgba_geta(sprite->bgcolor) < 255 ?
|
||||
PNG_COLOR_TYPE_RGB_ALPHA:
|
||||
PNG_COLOR_TYPE_RGB;
|
||||
break;
|
||||
case IMAGE_GRAYSCALE:
|
||||
color_type = _graya_geta(sprite->bgcolor) < 255 ?
|
||||
PNG_COLOR_TYPE_GRAY_ALPHA:
|
||||
PNG_COLOR_TYPE_GRAY;
|
||||
break;
|
||||
case IMAGE_INDEXED:
|
||||
color_type = PNG_COLOR_TYPE_PALETTE;
|
||||
break;
|
||||
}
|
||||
|
||||
jpeg_set_defaults(&cinfo);
|
||||
jpeg_set_quality(&cinfo, quality, TRUE);
|
||||
cinfo.dct_method = method;
|
||||
cinfo.smoothing_factor = smooth;
|
||||
png_set_IHDR(png_ptr, info_ptr, width, height, 8, color_type,
|
||||
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||
|
||||
/* Start compressor. */
|
||||
jpeg_start_compress(&cinfo, TRUE);
|
||||
if (image->imgtype == IMAGE_INDEXED) {
|
||||
int c, r, g, b;
|
||||
|
||||
/* Create the buffer. */
|
||||
buffer_height = 1;
|
||||
buffer = jmalloc(sizeof(JSAMPROW) * buffer_height);
|
||||
if (!buffer) {
|
||||
console_printf(_("Not enough memory for the buffer.\n"));
|
||||
jpeg_destroy_compress(&cinfo);
|
||||
fclose(file);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (c=0; c<(int)buffer_height; c++) {
|
||||
buffer[c] = jmalloc(sizeof(JSAMPLE) *
|
||||
cinfo.image_width * cinfo.num_components);
|
||||
if (!buffer[c]) {
|
||||
console_printf(_("Not enough memory for buffer scanlines.\n"));
|
||||
for (c--; c>=0; c--)
|
||||
jfree(buffer[c]);
|
||||
jfree(buffer);
|
||||
jpeg_destroy_compress(&cinfo);
|
||||
fclose(file);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* For progress bar. */
|
||||
progress.progress_monitor = progress_monitor;
|
||||
cinfo.progress = &progress;
|
||||
|
||||
/* Write each scan line. */
|
||||
while (cinfo.next_scanline < cinfo.image_height) {
|
||||
/* RGB */
|
||||
if (image->imgtype == IMAGE_RGB) {
|
||||
unsigned long *src_address;
|
||||
unsigned char *dst_address;
|
||||
int x, y;
|
||||
for (y=0; y<(int)buffer_height; y++) {
|
||||
src_address = ((unsigned long **)image->line)[cinfo.next_scanline+y];
|
||||
dst_address = ((unsigned char **)buffer)[y];
|
||||
for (x=0; x<image->w; x++) {
|
||||
c = *(src_address++);
|
||||
*(dst_address++) = _rgba_getr(c);
|
||||
*(dst_address++) = _rgba_getg(c);
|
||||
*(dst_address++) = _rgba_getb(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Grayscale */
|
||||
else {
|
||||
unsigned short *src_address;
|
||||
unsigned char *dst_address;
|
||||
int x, y;
|
||||
for (y=0; y<(int)buffer_height; y++) {
|
||||
src_address = ((unsigned short **)image->line)[cinfo.next_scanline+y];
|
||||
dst_address = ((unsigned char **)buffer)[y];
|
||||
for (x=0; x<image->w; x++)
|
||||
*(dst_address++) = _graya_getk(*(src_address++));
|
||||
}
|
||||
}
|
||||
jpeg_write_scanlines(&cinfo, buffer, buffer_height);
|
||||
}
|
||||
|
||||
/* Destroy all data. */
|
||||
for (c=0; c<(int)buffer_height; c++)
|
||||
jfree(buffer[c]);
|
||||
jfree(buffer);
|
||||
|
||||
/* Finish compression. */
|
||||
jpeg_finish_compress(&cinfo);
|
||||
|
||||
/* Release JPEG compression object. */
|
||||
jpeg_destroy_compress(&cinfo);
|
||||
|
||||
/* We can close the output file. */
|
||||
fclose(file);
|
||||
|
||||
/* All fine. */
|
||||
return 0;
|
||||
#else
|
||||
return -1;
|
||||
#if PNG_MAX_PALETTE_LENGTH != 256
|
||||
#error PNG_MAX_PALETTE_LENGTH should be 256
|
||||
#endif
|
||||
|
||||
/* set the palette if there is one. REQUIRED for indexed-color images */
|
||||
palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH
|
||||
* png_sizeof(png_color));
|
||||
/* ... set palette colors ... */
|
||||
for (c = 0; c < PNG_MAX_PALETTE_LENGTH; c++) {
|
||||
file_sequence_get_color(c, &r, &g, &b);
|
||||
palette[c].red = _rgb_scale_6[r];
|
||||
palette[c].green = _rgb_scale_6[g];
|
||||
palette[c].blue = _rgb_scale_6[b];
|
||||
}
|
||||
|
||||
png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH);
|
||||
}
|
||||
|
||||
/* Write the file header information. */
|
||||
png_write_info(png_ptr, info_ptr);
|
||||
|
||||
/* pack pixels into bytes */
|
||||
png_set_packing(png_ptr);
|
||||
|
||||
/* non-interlaced */
|
||||
number_passes = 1;
|
||||
|
||||
row_pointer = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr));
|
||||
|
||||
/* The number of passes is either 1 for non-interlaced images,
|
||||
* or 7 for interlaced images.
|
||||
*/
|
||||
for (pass = 0; pass < number_passes; pass++) {
|
||||
/* If you are only writing one row at a time, this works */
|
||||
for (y = 0; y < height; y++) {
|
||||
/* RGB_ALPHA */
|
||||
if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
|
||||
register unsigned long *src_address = ((unsigned long **)image->line)[y];
|
||||
register unsigned char *dst_address = row_pointer;
|
||||
register int x, c;
|
||||
|
||||
for (x=0; x<width; x++) {
|
||||
c = *(src_address++);
|
||||
*(dst_address++) = _rgba_getr(c);
|
||||
*(dst_address++) = _rgba_getg(c);
|
||||
*(dst_address++) = _rgba_getb(c);
|
||||
*(dst_address++) = _rgba_geta(c);
|
||||
}
|
||||
}
|
||||
/* RGB */
|
||||
else if (info_ptr->color_type == PNG_COLOR_TYPE_RGB) {
|
||||
register unsigned long *src_address = ((unsigned long **)image->line)[y];
|
||||
register unsigned char *dst_address = row_pointer;
|
||||
register int x, c;
|
||||
|
||||
for (x=0; x<width; x++) {
|
||||
c = *(src_address++);
|
||||
*(dst_address++) = _rgba_getr(c);
|
||||
*(dst_address++) = _rgba_getg(c);
|
||||
*(dst_address++) = _rgba_getb(c);
|
||||
}
|
||||
}
|
||||
/* GRAY_ALPHA */
|
||||
else if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
|
||||
register unsigned short *src_address = ((unsigned short **)image->line)[y];
|
||||
register unsigned char *dst_address = row_pointer;
|
||||
register int x, c;
|
||||
|
||||
for (x=0; x<width; x++) {
|
||||
c = *(src_address++);
|
||||
*(dst_address++) = _graya_getk(c);
|
||||
*(dst_address++) = _graya_geta(c);
|
||||
}
|
||||
}
|
||||
/* GRAY */
|
||||
else if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY) {
|
||||
register unsigned short *src_address = ((unsigned short **)image->line)[y];
|
||||
register unsigned char *dst_address = row_pointer;
|
||||
register int x, c;
|
||||
|
||||
for (x=0; x<width; x++) {
|
||||
c = *(src_address++);
|
||||
*(dst_address++) = _graya_getk(c);
|
||||
}
|
||||
}
|
||||
/* PALETTE */
|
||||
else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
|
||||
register unsigned char *src_address = ((unsigned char **)image->line)[y];
|
||||
register unsigned char *dst_address = row_pointer;
|
||||
register int x;
|
||||
|
||||
for (x=0; x<width; x++)
|
||||
*(dst_address++) = *(src_address++);
|
||||
}
|
||||
|
||||
/* write the line */
|
||||
png_write_rows(png_ptr, &row_pointer, 1);
|
||||
do_progress(100 * y / height);
|
||||
}
|
||||
}
|
||||
|
||||
png_free(png_ptr, row_pointer);
|
||||
|
||||
/* It is REQUIRED to call this to finish writing the rest of the file */
|
||||
png_write_end(png_ptr, info_ptr);
|
||||
|
||||
/* If you png_malloced a palette, free it here (don't free info_ptr->palette,
|
||||
as recommended in versions 1.0.5m and earlier of this example; if
|
||||
libpng mallocs info_ptr->palette, libpng will free it). If you
|
||||
allocated it with malloc() instead of png_malloc(), use free() instead
|
||||
of png_free(). */
|
||||
png_free(png_ptr, palette);
|
||||
palette = NULL;
|
||||
|
||||
/* clean up after the write, and free any memory allocated */
|
||||
png_destroy_write_struct(&png_ptr, &info_ptr);
|
||||
|
||||
/* close the file */
|
||||
fclose(fp);
|
||||
|
||||
/* all right */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* static int configure_jpeg(void) */
|
||||
/* static int configure_png(void) */
|
||||
/* { */
|
||||
/* /\* interactive mode *\/ */
|
||||
/* if (is_interactive()) { */
|
||||
|
@ -29,9 +29,11 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <allegro.h>
|
||||
#include <allegro/internal/aintern.h>
|
||||
|
||||
#include "jinete/jdraw.h"
|
||||
#include "jinete/jfont.h"
|
||||
#include "jinete/jintern.h"
|
||||
#include "jinete/jlist.h"
|
||||
@ -188,6 +190,12 @@ void ji_blit_region(JRegion region, int dx, int dy)
|
||||
int c, nrects = JI_REGION_NUM_RECTS(region);
|
||||
JRect rc;
|
||||
|
||||
if (ji_dirty_region) {
|
||||
jregion_translate(region, dx, dy);
|
||||
ji_add_dirty_region(region);
|
||||
jregion_translate(region, -dx, -dy);
|
||||
}
|
||||
|
||||
/* blit directly screen to screen *************************************/
|
||||
if (is_linear_bitmap(ji_screen) && nrects == 1) {
|
||||
rc = JI_REGION_RECTS(region);
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "jinete/jclipbrd.h"
|
||||
#include "jinete/jclipboard.h"
|
||||
#include "jinete/jfont.h"
|
||||
#include "jinete/jmanager.h"
|
||||
#include "jinete/jmessage.h"
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include "jinete/jbase.h"
|
||||
#include "jinete/jbox.h"
|
||||
#include "jinete/jbutton.h"
|
||||
#include "jinete/jclipbrd.h"
|
||||
#include "jinete/jclipboard.h"
|
||||
#include "jinete/jcombobox.h"
|
||||
#include "jinete/jdraw.h"
|
||||
#include "jinete/jentry.h"
|
||||
@ -53,7 +53,7 @@
|
||||
#include "jinete/jmenu.h"
|
||||
#include "jinete/jmessage.h"
|
||||
#include "jinete/jpanel.h"
|
||||
#include "jinete/jqckmenu.h"
|
||||
#include "jinete/jquickmenu.h"
|
||||
#include "jinete/jrect.h"
|
||||
#include "jinete/jregion.h"
|
||||
#include "jinete/jscroll.h"
|
||||
|
@ -336,7 +336,7 @@ bool jmanager_poll(JWidget manager, bool all_windows)
|
||||
that aren't the desktop) */
|
||||
if (msg->type == JM_BUTTONPRESSED) {
|
||||
JWidget window = jwidget_get_window(mouse_widget);
|
||||
JWidget win_manager = window ? jwindow_get_manager(window): NULL;
|
||||
JWidget win_manager = window ? jwidget_get_manager(window): NULL;
|
||||
|
||||
if ((window) &&
|
||||
(!jwindow_is_desktop (window)) &&
|
||||
@ -1081,6 +1081,10 @@ static void dispatch_msgs(void)
|
||||
if (msg->type == JM_DRAW) {
|
||||
set_clip(ji_screen, 0, 0, JI_SCREEN_W-1, JI_SCREEN_H-1);
|
||||
|
||||
/* dirty rectangles */
|
||||
if (ji_dirty_region)
|
||||
ji_add_dirty_rect(&msg->draw.rect);
|
||||
|
||||
release_bitmap(ji_screen);
|
||||
jmouse_show();
|
||||
}
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "jinete/jlist.h"
|
||||
#include "jinete/jmenu.h"
|
||||
#include "jinete/jmessage.h"
|
||||
#include "jinete/jqckmenu.h"
|
||||
#include "jinete/jquickmenu.h"
|
||||
#include "jinete/jsep.h"
|
||||
#include "jinete/jwidget.h"
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <allegro.h>
|
||||
#include <allegro.h>
|
||||
#ifndef min
|
||||
#define min MIN
|
||||
#endif
|
||||
#define min MIN
|
||||
#endif
|
||||
#ifndef max
|
||||
#define max MAX
|
||||
#define max MAX
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
@ -29,6 +29,7 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <allegro.h>
|
||||
#ifdef ALLEGRO_WINDOWS
|
||||
#include <winalleg.h>
|
||||
@ -37,6 +38,7 @@
|
||||
#include "jinete/jintern.h"
|
||||
#include "jinete/jmanager.h"
|
||||
#include "jinete/jrect.h"
|
||||
#include "jinete/jregion.h"
|
||||
#include "jinete/jsystem.h"
|
||||
#include "jinete/jtheme.h"
|
||||
#include "jinete/jwidget.h"
|
||||
@ -44,6 +46,7 @@
|
||||
/* Global output bitmap. */
|
||||
|
||||
BITMAP *ji_screen = NULL;
|
||||
JRegion ji_dirty_region = NULL;
|
||||
|
||||
/* Global timer. */
|
||||
|
||||
@ -199,12 +202,80 @@ void ji_set_screen(BITMAP *bmp)
|
||||
JRect rect = jrect_new(0, 0, JI_SCREEN_W, JI_SCREEN_H);
|
||||
jwidget_set_rect(manager, rect);
|
||||
jrect_free(rect);
|
||||
|
||||
if (ji_dirty_region)
|
||||
jregion_reset(ji_dirty_region, manager->rc);
|
||||
}
|
||||
|
||||
jmouse_set_cursor(cursor); /* restore mouse cursor */
|
||||
}
|
||||
}
|
||||
|
||||
void ji_add_dirty_rect(JRect rect)
|
||||
{
|
||||
JRegion reg1;
|
||||
|
||||
assert(ji_dirty_region != NULL);
|
||||
|
||||
reg1 = jregion_new(rect, 1);
|
||||
jregion_union(ji_dirty_region, ji_dirty_region, reg1);
|
||||
jregion_free(reg1);
|
||||
}
|
||||
|
||||
void ji_add_dirty_region(JRegion region)
|
||||
{
|
||||
assert(ji_dirty_region != NULL);
|
||||
|
||||
jregion_union(ji_dirty_region, ji_dirty_region, region);
|
||||
}
|
||||
|
||||
void ji_flip_dirty_region(void)
|
||||
{
|
||||
int c, nrects;
|
||||
JRect rc;
|
||||
|
||||
assert(ji_dirty_region != NULL);
|
||||
|
||||
nrects = JI_REGION_NUM_RECTS(ji_dirty_region);
|
||||
|
||||
if (nrects == 1) {
|
||||
rc = JI_REGION_RECTS(ji_dirty_region);
|
||||
ji_flip_rect(rc);
|
||||
}
|
||||
else if (nrects > 1) {
|
||||
for (c=0, rc=JI_REGION_RECTS(ji_dirty_region);
|
||||
c<nrects;
|
||||
c++, rc++)
|
||||
ji_flip_rect(rc);
|
||||
}
|
||||
|
||||
jregion_empty(ji_dirty_region);
|
||||
}
|
||||
|
||||
void ji_flip_rect(JRect rect)
|
||||
{
|
||||
assert(ji_screen != screen);
|
||||
|
||||
if (JI_SCREEN_W == SCREEN_W && JI_SCREEN_H == SCREEN_H) {
|
||||
blit(ji_screen, screen,
|
||||
rect->x1, rect->y1,
|
||||
rect->x1, rect->y1,
|
||||
jrect_w(rect),
|
||||
jrect_h(rect));
|
||||
}
|
||||
else {
|
||||
stretch_blit(ji_screen, screen,
|
||||
rect->x1,
|
||||
rect->y1,
|
||||
jrect_w(rect),
|
||||
jrect_h(rect),
|
||||
rect->x1 * SCREEN_W / JI_SCREEN_W,
|
||||
rect->y1 * SCREEN_H / JI_SCREEN_H,
|
||||
jrect_w(rect) * SCREEN_W / JI_SCREEN_W,
|
||||
jrect_h(rect) * SCREEN_H / JI_SCREEN_H);
|
||||
}
|
||||
}
|
||||
|
||||
void ji_set_translation_hook(const char *(*gettext) (const char *msgid))
|
||||
{
|
||||
strings_hook = gettext;
|
||||
@ -269,6 +340,9 @@ void jmouse_draw_cursor()
|
||||
/* rectfill(ji_screen, rect->x1, rect->y1, rect->x2-1, rect->y2-1, makecol(0, 0, 255)); */
|
||||
draw_sprite(ji_screen, sprite_cursor, x, y);
|
||||
|
||||
if (ji_dirty_region)
|
||||
ji_add_dirty_rect(rect);
|
||||
|
||||
jrect_free(rect);
|
||||
}
|
||||
}
|
||||
|
@ -45,9 +45,15 @@ JI_BEGIN_DECLS
|
||||
#define JI_SCREEN_H ((ji_screen == screen) ? SCREEN_H: ji_screen->h)
|
||||
|
||||
extern struct BITMAP *ji_screen;
|
||||
extern JRegion ji_dirty_region;
|
||||
|
||||
void ji_set_screen(struct BITMAP *bmp);
|
||||
|
||||
void ji_add_dirty_rect(JRect rect);
|
||||
void ji_add_dirty_region(JRegion region);
|
||||
void ji_flip_dirty_region(void);
|
||||
void ji_flip_rect(JRect rect);
|
||||
|
||||
/***********************************************************************/
|
||||
/* strings related */
|
||||
|
||||
|
@ -609,6 +609,18 @@ JWidget jwidget_get_window(JWidget widget)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JWidget jwidget_get_manager(JWidget widget)
|
||||
{
|
||||
while (widget) {
|
||||
if (widget->type == JI_MANAGER)
|
||||
return widget;
|
||||
|
||||
widget = widget->parent;
|
||||
}
|
||||
|
||||
return ji_get_default_manager();
|
||||
}
|
||||
|
||||
/* returns a list of parents (you must free the list), if "ascendant"
|
||||
is TRUE the list is build from child to parents, else the list is
|
||||
from parent to children */
|
||||
@ -711,8 +723,8 @@ JRegion jwidget_get_drawable_region(JWidget widget, int flags)
|
||||
|
||||
/* cut the top windows areas */
|
||||
if (flags & JI_GDR_CUTTOPWINDOWS) {
|
||||
window = jwidget_get_window (widget);
|
||||
manager = window ? jwindow_get_manager (window): NULL;
|
||||
window = jwidget_get_window(widget);
|
||||
manager = window ? jwidget_get_manager(window): NULL;
|
||||
|
||||
while (manager) {
|
||||
windows_list = manager->children;
|
||||
@ -730,7 +742,7 @@ JRegion jwidget_get_drawable_region(JWidget widget, int flags)
|
||||
}
|
||||
|
||||
window = jwidget_get_window(manager);
|
||||
manager = window ? jwindow_get_manager(window): NULL;
|
||||
manager = window ? jwidget_get_manager(window): NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -787,7 +799,7 @@ JRegion jwidget_get_drawable_region(JWidget widget, int flags)
|
||||
|
||||
/* limit to the manager area */
|
||||
window = jwidget_get_window(widget);
|
||||
manager = window ? jwindow_get_manager(window): NULL;
|
||||
manager = window ? jwidget_get_manager(window): NULL;
|
||||
|
||||
while (manager) {
|
||||
view = jwidget_get_view(manager);
|
||||
@ -805,8 +817,8 @@ JRegion jwidget_get_drawable_region(JWidget widget, int flags)
|
||||
jregion_free (reg1);
|
||||
jrect_free (cpos);
|
||||
|
||||
window = jwidget_get_window (manager);
|
||||
manager = window ? jwindow_get_manager (window): NULL;
|
||||
window = jwidget_get_window(manager);
|
||||
manager = window ? jwidget_get_manager(window): NULL;
|
||||
}
|
||||
|
||||
/* return the region */
|
||||
@ -1074,7 +1086,7 @@ void jwidget_invalidate_region(JWidget widget, const JRegion region)
|
||||
jregion_rect_in(region, widget->rc) != JI_RGNOUT) {
|
||||
JRegion reg1 = jregion_new(NULL, 0);
|
||||
JRegion reg2 = jwidget_get_drawable_region(widget,
|
||||
JI_GDR_CUTTOPWINDOWS);
|
||||
JI_GDR_CUTTOPWINDOWS);
|
||||
JLink link;
|
||||
|
||||
jregion_union(reg1, widget->update_region, region);
|
||||
|
@ -165,6 +165,7 @@ void jwidget_replace_child(JWidget widget, JWidget old_child,
|
||||
|
||||
JWidget jwidget_get_parent(JWidget widget);
|
||||
JWidget jwidget_get_window(JWidget widget);
|
||||
JWidget jwidget_get_manager(JWidget window);
|
||||
JList jwidget_get_parents(JWidget widget, bool ascendant);
|
||||
JList jwidget_get_children(JWidget widget);
|
||||
JWidget jwidget_pick(JWidget widget, int x, int y);
|
||||
|
@ -93,18 +93,6 @@ JWidget jwindow_get_killer(JWidget widget)
|
||||
return window->killer;
|
||||
}
|
||||
|
||||
JWidget jwindow_get_manager(JWidget widget)
|
||||
{
|
||||
while (widget) {
|
||||
if (widget->type == JI_MANAGER)
|
||||
return widget;
|
||||
|
||||
widget = widget->parent;
|
||||
}
|
||||
|
||||
return ji_get_default_manager();
|
||||
}
|
||||
|
||||
void jwindow_moveable(JWidget widget, bool state)
|
||||
{
|
||||
Window *window = jwidget_get_data(widget, JI_WINDOW);
|
||||
@ -151,8 +139,8 @@ void jwindow_remap(JWidget widget)
|
||||
|
||||
void jwindow_center(JWidget widget)
|
||||
{
|
||||
Window *window = jwidget_get_data (widget, JI_WINDOW);
|
||||
JWidget manager = jwindow_get_manager (widget);
|
||||
Window *window = jwidget_get_data(widget, JI_WINDOW);
|
||||
JWidget manager = jwidget_get_manager(widget);
|
||||
|
||||
if (window->is_autoremap)
|
||||
jwindow_remap(widget);
|
||||
@ -205,7 +193,7 @@ void jwindow_open_fg(JWidget widget)
|
||||
JWidget manager;
|
||||
|
||||
jwindow_open(widget);
|
||||
manager = jwindow_get_manager(widget);
|
||||
manager = jwidget_get_manager(widget);
|
||||
|
||||
window->is_foreground = TRUE;
|
||||
|
||||
@ -227,12 +215,12 @@ void jwindow_close(JWidget widget, JWidget killer)
|
||||
|
||||
window->killer = killer;
|
||||
|
||||
_jmanager_close_window(jwindow_get_manager(widget), widget, TRUE, TRUE);
|
||||
_jmanager_close_window(jwidget_get_manager(widget), widget, TRUE, TRUE);
|
||||
}
|
||||
|
||||
bool jwindow_is_toplevel(JWidget widget)
|
||||
{
|
||||
JWidget manager = jwindow_get_manager(widget);
|
||||
JWidget manager = jwidget_get_manager(widget);
|
||||
|
||||
if (!jlist_empty(manager->children))
|
||||
return (widget == jlist_first(manager->children)->data);
|
||||
@ -291,7 +279,7 @@ static bool window_msg_proc(JWidget widget, JMessage msg)
|
||||
switch (msg->type) {
|
||||
|
||||
case JM_DESTROY:
|
||||
_jmanager_close_window(jwindow_get_manager(widget), widget,
|
||||
_jmanager_close_window(jwidget_get_manager(widget), widget,
|
||||
FALSE, FALSE);
|
||||
jfree(window);
|
||||
break;
|
||||
@ -434,7 +422,7 @@ static bool window_msg_proc(JWidget widget, JMessage msg)
|
||||
static void window_request_size(JWidget widget, int *w, int *h)
|
||||
{
|
||||
Window *window = jwidget_get_data(widget, JI_WINDOW);
|
||||
JWidget manager = jwindow_get_manager(widget);
|
||||
JWidget manager = jwidget_get_manager(widget);
|
||||
|
||||
if (window->is_desktop) {
|
||||
JRect cpos = jwidget_get_child_rect(manager);
|
||||
@ -629,7 +617,7 @@ static void move_window(JWidget widget, JRect rect, bool use_blit)
|
||||
JRegion manager_refresh_region;
|
||||
JRegion window_refresh_region;
|
||||
JRect old_pos = jrect_new_copy(widget->rc);
|
||||
JRect man_pos = jwidget_get_rect(jwindow_get_manager (widget));
|
||||
JRect man_pos = jwidget_get_rect(jwidget_get_manager(widget));
|
||||
JMessage msg;
|
||||
|
||||
msg = jmessage_new(JM_WINMOVE);
|
||||
@ -673,17 +661,10 @@ static void move_window(JWidget widget, JRect rect, bool use_blit)
|
||||
new_drawable_region);
|
||||
|
||||
/* add a region to draw areas that were outside the screen */
|
||||
/* jregion_reset(reg2, man_pos); */
|
||||
/* jregion_subtract(reg1, old_reg, reg2); */
|
||||
/* jregion_translate(reg1, */
|
||||
/* widget->rc->x1 - old_pos->x1, */
|
||||
/* widget->rc->y1 - old_pos->y1); */
|
||||
/* jregion_union(window_refresh_region, window_refresh_region, reg1); */
|
||||
|
||||
jregion_copy(reg1, new_drawable_region);
|
||||
jregion_translate(reg1,
|
||||
old_pos->x1 - widget->rc->x1,
|
||||
old_pos->y1 - widget->rc->y1);
|
||||
old_pos->x1 - widget->rc->x1,
|
||||
old_pos->y1 - widget->rc->y1);
|
||||
jregion_intersect(moveable_region, old_drawable_region, reg1);
|
||||
|
||||
jregion_subtract(reg1, reg1, moveable_region);
|
||||
@ -692,21 +673,10 @@ static void move_window(JWidget widget, JRect rect, bool use_blit)
|
||||
widget->rc->y1 - old_pos->y1);
|
||||
jregion_union(window_refresh_region, window_refresh_region, reg1);
|
||||
|
||||
/* add a region to draw background areas that will be moved with blit() */
|
||||
/* jregion_reset(reg2, widget->rc); */
|
||||
/* jregion_subtract(reg1, reg2, new_drawable_region); */
|
||||
/* jregion_union(manager_refresh_region, manager_refresh_region, reg1); */
|
||||
|
||||
/* move the window's graphics */
|
||||
jmouse_hide();
|
||||
set_clip(ji_screen,
|
||||
man_pos->x1, man_pos->y1, man_pos->x2-1, man_pos->y2-1);
|
||||
/* blit (ji_screen, ji_screen, */
|
||||
/* old_pos->x1, old_pos->y1, */
|
||||
/* widget->rc->x1, widget->rc->y1, */
|
||||
/* jrect_w(widget->rc), jrect_h(widget->rc)); */
|
||||
|
||||
/* ji_blit_region(old_drawable_region, */
|
||||
|
||||
ji_blit_region(moveable_region,
|
||||
widget->rc->x1 - old_pos->x1,
|
||||
@ -719,11 +689,8 @@ static void move_window(JWidget widget, JRect rect, bool use_blit)
|
||||
jregion_free(moveable_region);
|
||||
}
|
||||
|
||||
/* jwidget_invalidate_region(jwindow_get_manager (widget), */
|
||||
/* manager_refresh_region); */
|
||||
/* jwidget_invalidate_region(widget, window_refresh_region); */
|
||||
jwidget_redraw_region(jwindow_get_manager(widget),
|
||||
manager_refresh_region);
|
||||
jwidget_redraw_region(jwidget_get_manager(widget),
|
||||
manager_refresh_region);
|
||||
jwidget_redraw_region(widget, window_refresh_region);
|
||||
|
||||
jregion_free(old_reg);
|
||||
|
@ -40,7 +40,6 @@ JWidget jwindow_new(const char *text);
|
||||
JWidget jwindow_new_desktop(void);
|
||||
|
||||
JWidget jwindow_get_killer(JWidget window);
|
||||
JWidget jwindow_get_manager(JWidget window);
|
||||
|
||||
void jwindow_moveable(JWidget window, bool state);
|
||||
void jwindow_sizeable(JWidget window, bool state);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -36,7 +36,7 @@
|
||||
#include "jinete/jintern.h"
|
||||
|
||||
/* data related */
|
||||
#include "stdicons.c"
|
||||
#include "jstandard_theme_icons.h"
|
||||
#include "pcx2data.c"
|
||||
|
||||
#define CHARACTER_LENGTH(f, c) ((f)->vtable->char_length ((f), (c)))
|
@ -368,19 +368,21 @@ void gui_feedback(void)
|
||||
|
||||
/* double buffering? */
|
||||
if (double_buffering) {
|
||||
/* jmanager_dispatch_draw_messages(); */
|
||||
jmouse_draw_cursor();
|
||||
|
||||
if (JI_SCREEN_W == SCREEN_W && JI_SCREEN_H == SCREEN_H) {
|
||||
blit(ji_screen, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
|
||||
if (ji_dirty_region) {
|
||||
ji_flip_dirty_region();
|
||||
}
|
||||
else {
|
||||
stretch_blit(ji_screen, screen,
|
||||
0, 0, ji_screen->w, ji_screen->h,
|
||||
0, 0, SCREEN_W, SCREEN_H);
|
||||
if (JI_SCREEN_W == SCREEN_W && JI_SCREEN_H == SCREEN_H) {
|
||||
blit(ji_screen, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
|
||||
}
|
||||
else {
|
||||
stretch_blit(ji_screen, screen,
|
||||
0, 0, ji_screen->w, ji_screen->h,
|
||||
0, 0, SCREEN_W, SCREEN_H);
|
||||
}
|
||||
}
|
||||
|
||||
/* jmanager_dispatch_draw_messages(); */
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,12 +19,12 @@
|
||||
#ifndef MODULES_TOOLS2_H
|
||||
#define MODULES_TOOLS2_H
|
||||
|
||||
void SetBrush (const char *string);
|
||||
void SetDrawMode (const char *string);
|
||||
void ToolTrace (const char *string);
|
||||
void SetBrush(const char *string);
|
||||
void SetDrawMode(const char *string);
|
||||
void ToolTrace(const char *string);
|
||||
|
||||
void ResetConfig (void);
|
||||
void RestoreConfig (void);
|
||||
void ResetConfig(void);
|
||||
void RestoreConfig(void);
|
||||
|
||||
#endif /* MODULES_TOOLS2_H */
|
||||
|
||||
|
@ -544,169 +544,6 @@ static int bind_GetImage2(lua_State *L)
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Extra GUI routines */
|
||||
|
||||
/* bind load_widget() as "ji_load_widget" */
|
||||
static int bind_ji_load_widget(lua_State *L)
|
||||
{
|
||||
JWidget return_value;
|
||||
const char *filename = lua_tostring(L, 1);
|
||||
const char *name = lua_tostring(L, 2);
|
||||
return_value = load_widget(filename, name); /* use "load_widget" */
|
||||
push_userdata(L, Type_JWidget, return_value);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* The routine "ji_file_select" for LUA scripts really call the
|
||||
* GUI_FileSelect routine.
|
||||
*/
|
||||
static int bind_ji_file_select(lua_State *L)
|
||||
{
|
||||
char *return_value;
|
||||
const char *message = lua_tostring(L, 1);
|
||||
const char *init_path = lua_tostring(L, 2);
|
||||
const char *exts = lua_tostring(L, 3);
|
||||
return_value = GUI_FileSelect(message, init_path, exts);
|
||||
if (return_value) {
|
||||
lua_pushstring(L, return_value);
|
||||
jfree(return_value);
|
||||
}
|
||||
else {
|
||||
lua_pushnil(L);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int bind_ji_color_select(lua_State *L)
|
||||
{
|
||||
char *return_value;
|
||||
int imgtype = lua_tonumber(L, 1);
|
||||
const char *color = lua_tostring(L, 2);
|
||||
return_value = ji_color_select(imgtype, color);
|
||||
if (return_value) {
|
||||
lua_pushstring(L, return_value);
|
||||
jfree(return_value);
|
||||
}
|
||||
else {
|
||||
lua_pushnil(L);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
/**********************************************************************/
|
||||
/* Interface to hook widget's signals with Lua functions **************/
|
||||
|
||||
/* The system is very simple, in the 4th slot of widget's user data
|
||||
(widget->user_data[3]), we put a list (GList) of Data3 structures,
|
||||
each Data3 structure has the references to Lua data.
|
||||
|
||||
First time we hook a signal from Lua, the JI_SIGNAL_DESTROY event
|
||||
is hooked with the "destroy_signal_for_widgets" routine, it's
|
||||
necessary to free the references (and memory) used by the widget.
|
||||
With this, you can't hook the destroy signal with Lua scripts.
|
||||
|
||||
Routine "handle_signals_for_lua_functions" calls the respectives
|
||||
scripts routines.
|
||||
*/
|
||||
|
||||
typedef struct Data3
|
||||
{
|
||||
int signal;
|
||||
int function;
|
||||
int user_data;
|
||||
} Data3;
|
||||
|
||||
static int destroy_signal_for_widgets (JWidget widget, int user_data)
|
||||
{
|
||||
lua_State *L = get_lua_state ();
|
||||
Data3 *data3;
|
||||
JLink link;
|
||||
|
||||
for (it=widget->user_data[3]; it; it=it->next) {
|
||||
data3 = it->data;
|
||||
if (data3->function != LUA_NOREF) lua_unref (L, data3->function);
|
||||
if (data3->user_data != LUA_NOREF) lua_unref (L, data3->user_data);
|
||||
jfree (data3);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int handle_signals_for_lua_functions (JWidget widget, int user_data)
|
||||
{
|
||||
lua_State *L = get_lua_state ();
|
||||
int ret = FALSE;
|
||||
Data3 *data3;
|
||||
JLink link;
|
||||
|
||||
for (it=widget->user_data[3]; it; it=it->next) {
|
||||
data3 = it->data;
|
||||
|
||||
PRINTF ("CALL HOOK %d %d %d %d\n",
|
||||
widget->id, data3->signal, data3->function, data3->user_data);
|
||||
|
||||
if ((data3->signal == user_data) && (data3->function != LUA_NOREF)) {
|
||||
lua_getref (L, data3->function);
|
||||
push_userdata (L, Type_JWidget, widget);
|
||||
lua_getref (L, data3->user_data);
|
||||
do_script_raw (L, 2, 1);
|
||||
ret = lua_toboolean (L, -1);
|
||||
lua_pop (L, 1);
|
||||
}
|
||||
|
||||
PRINTF ("RET VALUE %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int bind_jwidget_hook_signal (lua_State *L)
|
||||
{
|
||||
JWidget widget = to_userdata (L, Type_JWidget, 1);
|
||||
int signal = (int)lua_tonumber (L, 2);
|
||||
int user_data = lua_ref (L, 1); /* lua_pop (L, -1) */
|
||||
int function = lua_ref (L, 1); /* lua_pop (L, -1) */
|
||||
Data3 *data3;
|
||||
JHook hook;
|
||||
|
||||
/* check the references */
|
||||
function = (function > 0) ? function: LUA_NOREF;
|
||||
user_data = (user_data > 0) ? user_data: LUA_NOREF;
|
||||
|
||||
/* is the 4th slot of data is empty, means that it's the first time
|
||||
that we hook a signal in this widget */
|
||||
if (!widget->user_data[3]) {
|
||||
/* hook the destroy signal to clear all the 4th slot data */
|
||||
hook = jhook_new (JI_SIGNAL_DESTROY, destroy_signal_for_widgets, 0);
|
||||
jwidget_hook_signal (widget, hook);
|
||||
}
|
||||
|
||||
/* create a new Data3 block */
|
||||
data3 = jmalloc (sizeof (Data3));
|
||||
data3->signal = signal;
|
||||
data3->function = function;
|
||||
data3->user_data = user_data;
|
||||
|
||||
/* append this to the 4th slot */
|
||||
widget->user_data[3] = jlist_append (widget->user_data[3], data3);
|
||||
|
||||
/* append the hook to the signal that the user wants to hook */
|
||||
hook = jhook_new (data3->signal, handle_signals_for_lua_functions,
|
||||
data3->signal);
|
||||
jwidget_hook_signal (widget, hook);
|
||||
|
||||
PRINTF ("NEW HOOK %d %d %d %d\n",
|
||||
widget, data3->signal, data3->function, data3->user_data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/********************************************************************/
|
||||
/* Include generated bindings file */
|
||||
|
||||
|
@ -54,23 +54,6 @@ double tanh(double x);
|
||||
bool file_exists(const char *filename);
|
||||
char *get_filename(const char *filename);
|
||||
|
||||
/* configuration routines */
|
||||
|
||||
int get_config_int(const char *section, const char *name, int value);
|
||||
void set_config_int(const char *section, const char *name, int value);
|
||||
|
||||
const char *get_config_string(const char *section, const char *name, const char *value);
|
||||
void set_config_string(const char *section, const char *name, const char *value);
|
||||
|
||||
float get_config_float(const char *section, const char *name, float value);
|
||||
void set_config_float(const char *section, const char *name, float value);
|
||||
|
||||
bool get_config_bool(const char *section, const char *name, bool value);
|
||||
void set_config_bool(const char *section, const char *name, bool value);
|
||||
|
||||
void get_config_rect(const char *section, const char *name, JRect rect);
|
||||
void set_config_rect(const char *section, const char *name, JRect rect);
|
||||
|
||||
/*===================================================================*/
|
||||
/* Miscellaneous routines */
|
||||
/*===================================================================*/
|
||||
@ -142,9 +125,6 @@ void SetBrush(const char *string);
|
||||
void SetDrawMode(const char *string);
|
||||
void ToolTrace(const char *string);
|
||||
|
||||
void ResetConfig(void);
|
||||
void RestoreConfig(void);
|
||||
|
||||
/* modules/color.c */
|
||||
|
||||
const char *get_fg_color(void);
|
||||
@ -616,510 +596,6 @@ void set_replace_colors(int from, int to, int fuzziness);
|
||||
|
||||
void set_median_size(int w, int h);
|
||||
|
||||
/*===================================================================*/
|
||||
/* GUI routines */
|
||||
/*===================================================================*/
|
||||
|
||||
void reload_default_font(void);
|
||||
|
||||
void load_window_pos(JWidget window, const char *section);
|
||||
void save_window_pos(JWidget window, const char *section);
|
||||
|
||||
JWidget ji_load_widget(const char *filename, const char *name); /* CODE */
|
||||
|
||||
char *ji_file_select(const char *message, const char *init_path, const char *exts); /* CODE */
|
||||
char *ji_color_select(int imgtype, const char *color); /* CODE */
|
||||
|
||||
/* Alert ************************************************************/
|
||||
|
||||
JWidget jalert_new(const char *format);
|
||||
int jalert(const char *format);
|
||||
|
||||
/* Base *************************************************************/
|
||||
|
||||
#define JI_HORIZONTAL
|
||||
#define JI_VERTICAL
|
||||
#define JI_LEFT
|
||||
#define JI_CENTER
|
||||
#define JI_RIGHT
|
||||
#define JI_TOP
|
||||
#define JI_MIDDLE
|
||||
#define JI_BOTTOM
|
||||
#define JI_HOMOGENEOUS
|
||||
#define JI_WORDWRAP
|
||||
|
||||
#define JI_HIDDEN
|
||||
#define JI_SELECTED
|
||||
#define JI_DISABLED
|
||||
#define JI_HASFOCUS
|
||||
#define JI_HASMOUSE
|
||||
#define JI_HASCAPTURE
|
||||
#define JI_FOCUSREST
|
||||
#define JI_MAGNETIC
|
||||
#define JI_EXPANSIVE
|
||||
#define JI_DECORATIVE
|
||||
#define JI_AUTODESTROY
|
||||
#define JI_HARDCAPTURE
|
||||
#define JI_INITIALIZED
|
||||
|
||||
#define JI_WIDGET
|
||||
#define JI_BOX
|
||||
#define JI_BUTTON
|
||||
#define JI_CHECK
|
||||
#define JI_COMBOBOX
|
||||
#define JI_ENTRY
|
||||
#define JI_IMAGE
|
||||
#define JI_LABEL
|
||||
#define JI_LISTBOX
|
||||
#define JI_LISTITEM
|
||||
#define JI_MANAGER
|
||||
#define JI_MENU
|
||||
#define JI_MENUBAR
|
||||
#define JI_MENUBOX
|
||||
#define JI_MENUITEM
|
||||
#define JI_PANEL
|
||||
#define JI_RADIO
|
||||
#define JI_SEPARATOR
|
||||
#define JI_SLIDER
|
||||
#define JI_TEXTBOX
|
||||
#define JI_VIEW
|
||||
#define JI_VIEW_SCROLLBAR
|
||||
#define JI_VIEW_VIEWPORT
|
||||
#define JI_WINDOW
|
||||
#define JI_USER_WIDGET
|
||||
|
||||
#define JM_OPEN
|
||||
#define JM_CLOSE
|
||||
#define JM_DESTROY
|
||||
#define JM_DRAW
|
||||
#define JM_IDLE
|
||||
#define JM_SIGNAL
|
||||
#define JM_REQSIZE
|
||||
#define JM_SETPOS
|
||||
#define JM_WINMOVE
|
||||
#define JM_DRAWRGN
|
||||
#define JM_DIRTYCHILDREN
|
||||
#define JM_CHAR
|
||||
#define JM_KEYPRESSED
|
||||
#define JM_KEYRELEASED
|
||||
#define JM_FOCUSENTER
|
||||
#define JM_FOCUSLEAVE
|
||||
#define JM_BUTTONPRESSED
|
||||
#define JM_BUTTONRELEASED
|
||||
#define JM_DOUBLECLICK
|
||||
#define JM_MOUSEENTER
|
||||
#define JM_MOUSELEAVE
|
||||
#define JM_MOTION
|
||||
#define JM_WHEEL
|
||||
|
||||
#define JI_SIGNAL_DIRTY
|
||||
#define JI_SIGNAL_ENABLE
|
||||
#define JI_SIGNAL_DISABLE
|
||||
#define JI_SIGNAL_SELECT
|
||||
#define JI_SIGNAL_DESELECT
|
||||
#define JI_SIGNAL_SHOW
|
||||
#define JI_SIGNAL_HIDE
|
||||
#define JI_SIGNAL_ADD_CHILD
|
||||
#define JI_SIGNAL_REMOVE_CHILD
|
||||
#define JI_SIGNAL_NEW_PARENT
|
||||
#define JI_SIGNAL_GET_TEXT
|
||||
#define JI_SIGNAL_SET_TEXT
|
||||
#define JI_SIGNAL_BUTTON_SELECT
|
||||
#define JI_SIGNAL_CHECK_CHANGE
|
||||
#define JI_SIGNAL_RADIO_CHANGE
|
||||
#define JI_SIGNAL_ENTRY_CHANGE
|
||||
#define JI_SIGNAL_LISTBOX_CHANGE
|
||||
#define JI_SIGNAL_LISTBOX_SELECT
|
||||
#define JI_SIGNAL_MANAGER_EXTERNAL_CLOSE
|
||||
#define JI_SIGNAL_MANAGER_ADD_WINDOW
|
||||
#define JI_SIGNAL_MANAGER_REMOVE_WINDOW
|
||||
#define JI_SIGNAL_MANAGER_LOSTCHAR
|
||||
#define JI_SIGNAL_MENUITEM_SELECT
|
||||
#define JI_SIGNAL_SLIDER_CHANGE
|
||||
#define JI_SIGNAL_WINDOW_CLOSE
|
||||
#define JI_SIGNAL_WINDOW_RESIZE
|
||||
|
||||
/* Box **************************************************************/
|
||||
|
||||
JWidget jbox_new(int align);
|
||||
|
||||
/* Button ***********************************************************/
|
||||
|
||||
JWidget jbutton_new(const char *text);
|
||||
|
||||
/* void jbutton_set_icon(JWidget button, struct BITMAP *icon); */
|
||||
/* void jbutton_set_icon_align(JWidget button, int icon_align); */
|
||||
|
||||
/* void jbutton_set_bevel(JWidget button, int b0, int b1, int b2, int b3); */
|
||||
/* void jbutton_get_bevel(JWidget button, int *b4); */
|
||||
|
||||
/* Check ************************************************************/
|
||||
|
||||
JWidget jcheck_new(const char *text);
|
||||
|
||||
/* void jcheck_set_icon_align (JWidget check, int icon_align); */
|
||||
|
||||
/* Combobox *********************************************************/
|
||||
|
||||
JWidget jcombobox_new(void);
|
||||
|
||||
void jcombobox_editable(JWidget combobox, bool state);
|
||||
void jcombobox_clickopen(JWidget combobox, bool state);
|
||||
void jcombobox_casesensitive(JWidget combobox, bool state);
|
||||
|
||||
bool jcombobox_is_editable(JWidget combobox);
|
||||
bool jcombobox_is_clickopen(JWidget combobox);
|
||||
bool jcombobox_is_casesensitive(JWidget combobox);
|
||||
|
||||
void jcombobox_add_string(JWidget combobox, const char *string);
|
||||
void jcombobox_del_string(JWidget combobox, const char *string);
|
||||
void jcombobox_del_index(JWidget combobox, int index);
|
||||
|
||||
void jcombobox_select_index(JWidget combobox, int index);
|
||||
void jcombobox_select_string(JWidget combobox, const char *string);
|
||||
int jcombobox_get_selected_index(JWidget combobox);
|
||||
const char *jcombobox_get_selected_string(JWidget combobox);
|
||||
|
||||
const char *jcombobox_get_string(JWidget combobox, int index);
|
||||
int jcombobox_get_index(JWidget combobox, const char *string);
|
||||
int jcombobox_get_count(JWidget combobox);
|
||||
|
||||
JWidget jcombobox_get_entry_widget(JWidget combobox);
|
||||
|
||||
/* Clipboard ********************************************************/
|
||||
|
||||
const char *jclipboard_get_text(void);
|
||||
void jclipboard_set_text(const char *text);
|
||||
|
||||
/* Entry ************************************************************/
|
||||
|
||||
JWidget jentry_new(int maxsize, const char *format);
|
||||
|
||||
void jentry_readonly(JWidget entry, bool state);
|
||||
void jentry_password(JWidget entry, bool state);
|
||||
bool jentry_is_password(JWidget entry);
|
||||
bool jentry_is_readonly(JWidget entry);
|
||||
|
||||
void jentry_show_cursor(JWidget entry);
|
||||
void jentry_hide_cursor(JWidget entry);
|
||||
|
||||
void jentry_set_cursor_pos(JWidget entry, int pos);
|
||||
void jentry_select_text(JWidget entry, int from, int to);
|
||||
void jentry_deselect_text(JWidget entry);
|
||||
|
||||
/* Image ************************************************************/
|
||||
|
||||
/* JWidget jimage_new(struct BITMAP *bmp, int align); */
|
||||
|
||||
/* Label ************************************************************/
|
||||
|
||||
JWidget jlabel_new(const char *text);
|
||||
|
||||
/* Listbox **********************************************************/
|
||||
|
||||
JWidget jlistbox_new(void);
|
||||
JWidget jlistitem_new(const char *text);
|
||||
|
||||
JWidget jlistbox_get_selected_child(JWidget listbox);
|
||||
int jlistbox_get_selected_index(JWidget listbox);
|
||||
void jlistbox_select_child(JWidget listbox, JWidget listitem);
|
||||
void jlistbox_select_index(JWidget listbox, int index);
|
||||
|
||||
void jlistbox_center_scroll(JWidget listbox);
|
||||
|
||||
/* Manager **********************************************************/
|
||||
|
||||
JWidget ji_get_default_manager(void);
|
||||
|
||||
JWidget jmanager_new(void);
|
||||
void jmanager_free(JWidget manager);
|
||||
|
||||
void jmanager_run(JWidget manager);
|
||||
bool jmanager_poll(JWidget manager, bool all_windows);
|
||||
|
||||
void jmanager_send_message(JMessage msg);
|
||||
|
||||
JWidget jmanager_get_focus(void);
|
||||
JWidget jmanager_get_mouse(void);
|
||||
JWidget jmanager_get_capture(void);
|
||||
|
||||
void jmanager_set_focus(JWidget widget);
|
||||
void jmanager_set_mouse(JWidget widget);
|
||||
void jmanager_set_capture(JWidget widget);
|
||||
void jmanager_attract_focus(JWidget widget);
|
||||
void jmanager_free_focus(void);
|
||||
void jmanager_free_mouse(void);
|
||||
void jmanager_free_capture(void);
|
||||
void jmanager_free_widget(JWidget widget);
|
||||
void jmanager_remove_message(JMessage msg);
|
||||
void jmanager_remove_messages_for(JWidget widget);
|
||||
void jmanager_refresh_screen(void);
|
||||
|
||||
/* Menu *************************************************************/
|
||||
|
||||
JWidget jmenu_new(void);
|
||||
JWidget jmenubar_new(void);
|
||||
JWidget jmenubox_new(void);
|
||||
JWidget jmenuitem_new(const char *text);
|
||||
|
||||
JWidget jmenubox_get_menu(JWidget menubox);
|
||||
JWidget jmenubar_get_menu(JWidget menubar);
|
||||
JWidget jmenuitem_get_submenu(JWidget menuitem);
|
||||
/* JAccel jmenuitem_get_accel(JWidget menuitem); */
|
||||
|
||||
void jmenubox_set_menu(JWidget menubox, JWidget menu);
|
||||
void jmenubar_set_menu(JWidget menubar, JWidget menu);
|
||||
void jmenuitem_set_submenu(JWidget menuitem, JWidget menu);
|
||||
/* void jmenuitem_set_accel(JWidget menuitem, JAccel accel); */
|
||||
|
||||
int jmenuitem_is_highlight(JWidget menuitem);
|
||||
|
||||
void jmenu_popup(JWidget menu, int x, int y);
|
||||
|
||||
/* Message **********************************************************/
|
||||
|
||||
JMessage jmessage_new(int type);
|
||||
JMessage jmessage_new_copy(JMessage msg);
|
||||
void jmessage_free(JMessage msg);
|
||||
|
||||
void jmessage_add_dest(JMessage msg, JWidget widget);
|
||||
|
||||
void jmessage_broadcast_to_children(JMessage msg, JWidget widget);
|
||||
void jmessage_broadcast_to_parents(JMessage msg, JWidget widget);
|
||||
|
||||
void jmessage_set_sub_msg(JMessage msg, JMessage sub_msg);
|
||||
|
||||
/* Panel ************************************************************/
|
||||
|
||||
JWidget jpanel_new(int align);
|
||||
|
||||
double jpanel_get_pos(JWidget panel);
|
||||
void jpanel_set_pos(JWidget panel, double pos);
|
||||
|
||||
/* QuickMenu ********************************************************/
|
||||
|
||||
/* JWidget jmenubar_new_quickmenu(JQuickMenu quick_menu); */
|
||||
/* JWidget jmenubox_new_quickmenu(JQuickMenu quick_menu); */
|
||||
|
||||
/* Radio ************************************************************/
|
||||
|
||||
JWidget jradio_new(const char *text, int radio_group);
|
||||
|
||||
/* void jradio_set_icon_align(JWidget radio, int icon_align); */
|
||||
|
||||
int jradio_get_group(JWidget radio);
|
||||
void jradio_deselect_group(JWidget radio);
|
||||
|
||||
/* Rect *************************************************************/
|
||||
|
||||
int jrect_w(JRect rect);
|
||||
int jrect_h(JRect rect);
|
||||
bool jrect_point_in(JRect rect, int x, int y);
|
||||
|
||||
JRect jrect_new(int x1, int y1, int x2, int y2);
|
||||
JRect jrect_new_copy(const JRect rect);
|
||||
void jrect_free(JRect rect);
|
||||
|
||||
void jrect_copy(JRect dst, const JRect src);
|
||||
void jrect_replace(JRect rect, int x1, int y1, int x2, int y2);
|
||||
|
||||
void jrect_union(JRect r1, const JRect r2);
|
||||
bool jrect_intersect(JRect r1, const JRect r2);
|
||||
|
||||
void jrect_shrink(JRect rect, int border);
|
||||
void jrect_stretch(JRect rect, int border);
|
||||
|
||||
void jrect_moveto(JRect rect, int x, int y);
|
||||
void jrect_displace(JRect rect, int dx, int dy);
|
||||
|
||||
/* Region ***********************************************************/
|
||||
|
||||
JRegion jregion_new(JRect rect, int size);
|
||||
void jregion_init(JRegion reg, JRect rect, int size);
|
||||
void jregion_free(JRegion reg);
|
||||
void jregion_uninit(JRegion reg);
|
||||
|
||||
bool jregion_copy(JRegion dst, JRegion src);
|
||||
bool jregion_intersect(JRegion new, JRegion reg1, JRegion reg2);
|
||||
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); */
|
||||
|
||||
bool jregion_subtract(JRegion regD, JRegion regM, JRegion regS);
|
||||
bool jregion_inverse(JRegion newReg, JRegion reg1, JRect invRect);
|
||||
|
||||
int jregion_rect_in(JRegion region, JRect rect);
|
||||
void jregion_translate(JRegion reg, int x, int y);
|
||||
|
||||
void jregion_reset(JRegion reg, JRect box);
|
||||
bool jregion_break(JRegion reg);
|
||||
bool jregion_point_in(JRegion reg, int x, int y, JRect box);
|
||||
|
||||
bool jregion_equal(JRegion reg1, JRegion reg2);
|
||||
bool jregion_notempty(JRegion reg);
|
||||
void jregion_empty(JRegion reg);
|
||||
JRect jregion_extents(JRegion reg);
|
||||
|
||||
/* Separator ********************************************************/
|
||||
|
||||
JWidget ji_separator_new(const char *text, int align);
|
||||
|
||||
/* Slider ***********************************************************/
|
||||
|
||||
JWidget jslider_new(int min, int max, int value);
|
||||
|
||||
void jslider_set_value(JWidget slider, int value);
|
||||
int jslider_get_value(JWidget slider);
|
||||
|
||||
/* System ***********************************************************/
|
||||
|
||||
/* Textbox **********************************************************/
|
||||
|
||||
JWidget jtextbox_new(const char *text, int align);
|
||||
|
||||
/* Theme ************************************************************/
|
||||
|
||||
/* View *************************************************************/
|
||||
|
||||
JWidget jview_new(void);
|
||||
|
||||
bool jview_has_bars(JWidget view);
|
||||
|
||||
void jview_attach(JWidget view, JWidget viewable_widget);
|
||||
void jview_maxsize(JWidget view);
|
||||
void jview_without_bars(JWidget view);
|
||||
|
||||
void jview_set_size(JWidget view, int w, int h);
|
||||
void jview_set_scroll(JWidget view, int x, int y);
|
||||
/* void jview_get_scroll(JWidget view, int *x, int *y); */
|
||||
/* void jview_get_max_size(JWidget view, int *w, int *h); */
|
||||
|
||||
void jview_update(JWidget view);
|
||||
|
||||
JWidget jview_get_viewport(JWidget view);
|
||||
JRect jview_get_viewport_position(JWidget view);
|
||||
|
||||
JWidget jwidget_get_view(JWidget viewable_widget);
|
||||
|
||||
/* Widget ***********************************************************/
|
||||
|
||||
int ji_register_widget_type(void);
|
||||
|
||||
JWidget jwidget_new(int type);
|
||||
void jwidget_free(JWidget widget);
|
||||
|
||||
int jwidget_get_type(JWidget widget);
|
||||
const char *jwidget_get_name(JWidget widget);
|
||||
const char *jwidget_get_text(JWidget widget);
|
||||
int jwidget_get_align(JWidget widget);
|
||||
|
||||
void jwidget_set_name(JWidget widget, const char *name);
|
||||
void jwidget_set_text(JWidget widget, const char *text);
|
||||
void jwidget_set_align(JWidget widget, int align);
|
||||
|
||||
void jwidget_magnetic(JWidget widget, bool state);
|
||||
void jwidget_expansive(JWidget widget, bool state);
|
||||
void jwidget_decorative(JWidget widget, bool state);
|
||||
void jwidget_autodestroy(JWidget widget, bool state);
|
||||
void jwidget_focusrest(JWidget widget, bool state);
|
||||
|
||||
bool jwidget_is_magnetic(JWidget widget);
|
||||
bool jwidget_is_expansive(JWidget widget);
|
||||
bool jwidget_is_decorative(JWidget widget);
|
||||
bool jwidget_is_autodestroy(JWidget widget);
|
||||
bool jwidget_is_focusrest(JWidget widget);
|
||||
|
||||
void jwidget_dirty(JWidget widget);
|
||||
void jwidget_show(JWidget widget);
|
||||
void jwidget_hide(JWidget widget);
|
||||
void jwidget_enable(JWidget widget);
|
||||
void jwidget_disable(JWidget widget);
|
||||
void jwidget_select(JWidget widget);
|
||||
void jwidget_deselect(JWidget widget);
|
||||
|
||||
bool jwidget_is_visible(JWidget widget);
|
||||
bool jwidget_is_hidden(JWidget widget);
|
||||
bool jwidget_is_enabled(JWidget widget);
|
||||
bool jwidget_is_disabled(JWidget widget);
|
||||
bool jwidget_is_selected(JWidget widget);
|
||||
bool jwidget_is_deselected(JWidget widget);
|
||||
|
||||
bool jwidget_has_focus(JWidget widget);
|
||||
bool jwidget_has_mouse(JWidget widget);
|
||||
bool jwidget_has_capture(JWidget widget);
|
||||
|
||||
void jwidget_add_child(JWidget widget, JWidget child);
|
||||
void jwidget_remove_child(JWidget widget, JWidget child);
|
||||
void jwidget_replace_child(JWidget widget, JWidget old_child, JWidget new_child);
|
||||
|
||||
JWidget jwidget_get_parent(JWidget widget);
|
||||
JWidget jwidget_get_window(JWidget widget);
|
||||
/* JList jwidget_get_parents(JWidget widget, bool ascendant); */
|
||||
/* JList jwidget_get_children(JWidget widget); */
|
||||
JWidget jwidget_pick(JWidget widget, int x, int y);
|
||||
bool jwidget_has_child(JWidget widget, JWidget child);
|
||||
|
||||
JRect jwidget_get_rect(JWidget widget);
|
||||
JRect jwidget_get_child_rect(JWidget widget);
|
||||
JRegion jwidget_get_region(JWidget widget);
|
||||
JRegion jwidget_get_drawable_region(JWidget widget, int flags);
|
||||
int jwidget_get_bg_color(JWidget widget);
|
||||
int jwidget_get_text_length(JWidget widget);
|
||||
int jwidget_get_text_height(JWidget widget);
|
||||
|
||||
void jwidget_noborders(JWidget widget);
|
||||
void jwidget_set_border(JWidget widget, int l, int t, int r, int b);
|
||||
void jwidget_set_rect(JWidget widget, JRect rect);
|
||||
void jwidget_set_static_size(JWidget widget, int w, int h);
|
||||
void jwidget_set_bg_color(JWidget widget, int color);
|
||||
|
||||
void jwidget_flush_redraw(JWidget widget);
|
||||
void jwidget_redraw_region(JWidget widget, JRegion region);
|
||||
|
||||
void jwidget_signal_on(JWidget widget);
|
||||
void jwidget_signal_off(JWidget widget);
|
||||
|
||||
int jwidget_emit_signal(JWidget widget, int signal);
|
||||
|
||||
bool jwidget_send_message(JWidget widget, JMessage msg);
|
||||
bool jwidget_send_message_after_type(JWidget widget, JMessage msg, int type);
|
||||
void jwidget_close_window(JWidget widget);
|
||||
void jwidget_capture_mouse(JWidget widget);
|
||||
void jwidget_hard_capture_mouse(JWidget widget);
|
||||
void jwidget_release_mouse(JWidget widget);
|
||||
|
||||
JWidget jwidget_find_name(JWidget widget, const char *name);
|
||||
bool jwidget_check_underscored(JWidget widget, int scancode);
|
||||
|
||||
/* Window routines **************************************************/
|
||||
|
||||
JWidget jwindow_new(const char *text);
|
||||
JWidget jwindow_new_desktop(void);
|
||||
|
||||
JWidget jwindow_get_killer(JWidget window);
|
||||
JWidget jwindow_get_manager(JWidget window);
|
||||
|
||||
void jwindow_moveable(JWidget window, bool state);
|
||||
void jwindow_sizeable(JWidget window, bool state);
|
||||
void jwindow_ontop(JWidget window, bool state);
|
||||
|
||||
void jwindow_remap(JWidget window);
|
||||
void jwindow_center(JWidget window);
|
||||
void jwindow_position(JWidget window, int x, int y);
|
||||
void jwindow_move(JWidget window, JRect rect);
|
||||
|
||||
void jwindow_open(JWidget window);
|
||||
void jwindow_open_fg(JWidget window);
|
||||
void jwindow_open_bg(JWidget window);
|
||||
void jwindow_close(JWidget window, JWidget killer);
|
||||
|
||||
bool jwindow_is_toplevel(JWidget window);
|
||||
bool jwindow_is_foreground(JWidget window);
|
||||
bool jwindow_is_desktop(JWidget window);
|
||||
bool jwindow_is_ontop(JWidget window);
|
||||
|
||||
/*===================================================================*/
|
||||
/* End */
|
||||
/*===================================================================*/
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -27,6 +27,7 @@
|
||||
#include "core/dirs.h"
|
||||
#include "modules/editors.h"
|
||||
#include "modules/sprites.h"
|
||||
#include "modules/tools2.h"
|
||||
#include "script/bindings.h"
|
||||
#include "script/script.h"
|
||||
#include "widgets/editor.h"
|
||||
@ -42,202 +43,191 @@ static lua_State *L;
|
||||
|
||||
static int running = 0;
|
||||
|
||||
static void prepare (void);
|
||||
static void release (void);
|
||||
static void prepare(void);
|
||||
static void release(void);
|
||||
|
||||
/* Installs all the scripting capability. */
|
||||
|
||||
int init_module_script (void)
|
||||
int init_module_script(void)
|
||||
{
|
||||
/* create the main lua state */
|
||||
L = lua_open ();
|
||||
L = lua_open();
|
||||
if (!L)
|
||||
return -1;
|
||||
|
||||
/* setup the garbage collector */
|
||||
lua_setgcthreshold (L, 0);
|
||||
lua_setgcthreshold(L, 0);
|
||||
|
||||
/* install the base library */
|
||||
lua_baselibopen (L);
|
||||
/* lua_tablibopen (L); */
|
||||
/* lua_iolibopen (L); */
|
||||
/* lua_strlibopen (L); */
|
||||
/* lua_mathlibopen (L); */
|
||||
/* lua_dblibopen (L); */
|
||||
lua_baselibopen(L);
|
||||
/* lua_tablibopen(L); */
|
||||
/* lua_iolibopen(L); */
|
||||
/* lua_strlibopen(L); */
|
||||
/* lua_mathlibopen(L); */
|
||||
/* lua_dblibopen(L); */
|
||||
|
||||
/* export C routines to use in Lua scripts */
|
||||
register_bindings (L);
|
||||
register_bindings(L);
|
||||
|
||||
/* object metatable */
|
||||
register_lua_object_metatable ();
|
||||
register_lua_object_metatable();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Removes the scripting feature. */
|
||||
|
||||
void exit_module_script (void)
|
||||
void exit_module_script(void)
|
||||
{
|
||||
/* remove object metatable */
|
||||
unregister_lua_object_metatable ();
|
||||
unregister_lua_object_metatable();
|
||||
|
||||
/* delete Lua state */
|
||||
lua_close (L);
|
||||
lua_close(L);
|
||||
L = NULL;
|
||||
}
|
||||
|
||||
lua_State *get_lua_state (void)
|
||||
lua_State *get_lua_state(void)
|
||||
{
|
||||
return L;
|
||||
}
|
||||
|
||||
int script_is_running (void)
|
||||
int script_is_running(void)
|
||||
{
|
||||
return (running > 0) ? TRUE: FALSE;
|
||||
}
|
||||
|
||||
void script_show_err (lua_State *L, int err)
|
||||
void script_show_err(lua_State *L, int err)
|
||||
{
|
||||
switch (err) {
|
||||
case 0:
|
||||
/* nothing */
|
||||
break;
|
||||
case LUA_ERRRUN:
|
||||
console_printf ("** lua error (run): %s\n", lua_tostring (L, -1));
|
||||
console_printf("** lua error (run): %s\n", lua_tostring(L, -1));
|
||||
break;
|
||||
case LUA_ERRFILE:
|
||||
console_printf ("** lua error (file): %s\n", lua_tostring (L, -1));
|
||||
console_printf("** lua error (file): %s\n", lua_tostring(L, -1));
|
||||
break;
|
||||
case LUA_ERRSYNTAX:
|
||||
console_printf ("** lua error (syntax): %s\n", lua_tostring (L, -1));
|
||||
console_printf("** lua error (syntax): %s\n", lua_tostring(L, -1));
|
||||
break;
|
||||
case LUA_ERRMEM:
|
||||
console_printf ("** lua error (mem): %s\n", lua_tostring (L, -1));
|
||||
console_printf("** lua error (mem): %s\n", lua_tostring(L, -1));
|
||||
break;
|
||||
case LUA_ERRERR:
|
||||
console_printf ("** lua error (err): %s\n", lua_tostring (L, -1));
|
||||
console_printf("** lua error (err): %s\n", lua_tostring(L, -1));
|
||||
break;
|
||||
default:
|
||||
console_printf ("** lua error (unknown): %s\n", lua_tostring (L, -1));
|
||||
console_printf("** lua error (unknown): %s\n", lua_tostring(L, -1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int do_script_raw (lua_State *L, int nargs, int nresults)
|
||||
int do_script_raw(lua_State *L, int nargs, int nresults)
|
||||
{
|
||||
int err;
|
||||
|
||||
prepare ();
|
||||
prepare();
|
||||
|
||||
err = lua_pcall (L, nargs, nresults, 0);
|
||||
err = lua_pcall(L, nargs, nresults, 0);
|
||||
if (err != 0)
|
||||
script_show_err (L, err);
|
||||
script_show_err(L, err);
|
||||
|
||||
release ();
|
||||
release();
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int do_script_expr (const char *exp)
|
||||
int do_script_expr(const char *exp)
|
||||
{
|
||||
int err = luaL_loadbuffer (L, exp, ustrlen (exp), exp);
|
||||
int err = luaL_loadbuffer(L, exp, ustrlen(exp), exp);
|
||||
|
||||
prepare ();
|
||||
|
||||
if (err == 0)
|
||||
err = lua_pcall (L, 0, LUA_MULTRET, 0);
|
||||
err = lua_pcall(L, 0, LUA_MULTRET, 0);
|
||||
|
||||
if (err != 0)
|
||||
script_show_err (L, err);
|
||||
script_show_err(L, err);
|
||||
|
||||
release ();
|
||||
release();
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int do_script_file (const char *filename)
|
||||
int do_script_file(const char *filename)
|
||||
{
|
||||
int found = FALSE;
|
||||
char buf[512];
|
||||
int err;
|
||||
|
||||
PRINTF ("Calling script file \"%s\"\n", filename);
|
||||
PRINTF("Calling script file \"%s\"\n", filename);
|
||||
|
||||
if (exists (filename)) {
|
||||
ustrcpy (buf, filename);
|
||||
if (exists(filename)) {
|
||||
ustrcpy(buf, filename);
|
||||
found = TRUE;
|
||||
}
|
||||
else {
|
||||
DIRS *it, *dirs;
|
||||
|
||||
usprintf (buf, "scripts/%s", filename);
|
||||
dirs = filename_in_datadir (buf);
|
||||
usprintf(buf, "scripts/%s", filename);
|
||||
dirs = filename_in_datadir(buf);
|
||||
for (it=dirs; it; it=it->next) {
|
||||
if (exists (it->path)) {
|
||||
ustrcpy (buf, it->path);
|
||||
if (exists(it->path)) {
|
||||
ustrcpy(buf, it->path);
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
dirs_free (dirs);
|
||||
dirs_free(dirs);
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
console_printf (_("File not found: \"%s\"\n"), filename);
|
||||
console_printf(_("File not found: \"%s\"\n"), filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
prepare ();
|
||||
prepare();
|
||||
|
||||
err = luaL_loadfile (L, buf);
|
||||
err = luaL_loadfile(L, buf);
|
||||
|
||||
if (err == 0)
|
||||
err = lua_pcall (L, 0, LUA_MULTRET, 0);
|
||||
err = lua_pcall(L, 0, LUA_MULTRET, 0);
|
||||
|
||||
if (err != 0)
|
||||
script_show_err (L, err);
|
||||
script_show_err(L, err);
|
||||
|
||||
release ();
|
||||
release();
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
void load_all_scripts (void)
|
||||
{
|
||||
struct al_ffblk fi;
|
||||
DIRS *it, *dirs;
|
||||
char buf[512];
|
||||
int done;
|
||||
|
||||
dirs = filename_in_datadir ("scripts/*.lua");
|
||||
for (it=dirs; it; it=it->next) {
|
||||
done = al_findfirst (it->path, &fi, FA_RDONLY | FA_SYSTEM | FA_ARCH);
|
||||
while (!done) {
|
||||
replace_filename (buf, it->path, fi.name, sizeof (buf));
|
||||
do_script_file (buf);
|
||||
done = al_findnext (&fi);
|
||||
}
|
||||
al_findclose (&fi);
|
||||
}
|
||||
dirs_free (dirs);
|
||||
}
|
||||
|
||||
static void prepare (void)
|
||||
/**
|
||||
* Prepare the application to run a script.
|
||||
*/
|
||||
static void prepare(void)
|
||||
{
|
||||
if (running == 0) {
|
||||
console_open ();
|
||||
update_global_script_variables ();
|
||||
ResetConfig();
|
||||
console_open();
|
||||
update_global_script_variables();
|
||||
}
|
||||
running++;
|
||||
}
|
||||
|
||||
static void release (void)
|
||||
/**
|
||||
* Restore the configuration of the application after running a
|
||||
* script.
|
||||
*/
|
||||
static void release(void)
|
||||
{
|
||||
running--;
|
||||
if (running == 0) {
|
||||
console_close ();
|
||||
RestoreConfig();
|
||||
console_close();
|
||||
if (current_editor)
|
||||
set_current_sprite (editor_get_sprite (current_editor));
|
||||
set_current_sprite(editor_get_sprite(current_editor));
|
||||
}
|
||||
}
|
||||
|
@ -24,18 +24,16 @@
|
||||
#include "lua.h"
|
||||
#include "lualib.h"
|
||||
|
||||
int init_module_script (void);
|
||||
void exit_module_script (void);
|
||||
int init_module_script(void);
|
||||
void exit_module_script(void);
|
||||
|
||||
lua_State *get_lua_state (void);
|
||||
lua_State *get_lua_state(void);
|
||||
|
||||
int script_is_running (void);
|
||||
void script_show_err (lua_State *L, int err);
|
||||
int script_is_running(void);
|
||||
void script_show_err(lua_State *L, int err);
|
||||
|
||||
int do_script_raw (lua_State *L, int nargs, int nresults);
|
||||
int do_script_expr (const char *expr);
|
||||
int do_script_file (const char *filename);
|
||||
|
||||
void load_all_scripts (void);
|
||||
int do_script_raw(lua_State *L, int nargs, int nresults);
|
||||
int do_script_expr(const char *expr);
|
||||
int do_script_file(const char *filename);
|
||||
|
||||
#endif /* SCRIPT_H */
|
||||
|
@ -150,7 +150,7 @@ void status_bar_set_text(JWidget widget, int msecs, const char *format, ...)
|
||||
|
||||
widget->text = buf ? jstrdup (buf) : NULL;
|
||||
status_bar->timeout = ji_clock + JI_TICKS_PER_SEC*msecs/1000;
|
||||
jwidget_dirty (widget);
|
||||
jwidget_dirty(widget);
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,6 +177,8 @@ void status_bar_add_progress(JWidget widget, int max)
|
||||
status_bar->progress[n].max = max;
|
||||
status_bar->progress[n].pos = 0;
|
||||
|
||||
ji_dirty_region = jregion_new(NULL, 0);
|
||||
|
||||
jwidget_dirty(widget);
|
||||
}
|
||||
|
||||
@ -193,6 +195,9 @@ void status_bar_del_progress(JWidget widget)
|
||||
jmanager_dispatch_messages();
|
||||
rest(5);
|
||||
jwidget_dirty(widget);
|
||||
|
||||
jregion_free(ji_dirty_region);
|
||||
ji_dirty_region = NULL;
|
||||
}
|
||||
|
||||
status_bar->nprogress--;
|
||||
|
Loading…
x
Reference in New Issue
Block a user