summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2022-12-30 19:20:52 +0100
committerGitHub <noreply@github.com>2022-12-30 19:20:52 +0100
commit2c5a5ce948a47d067659f4745039af44ede5829b (patch)
tree0535614a09c741a1f3ef7bd303485f2cfa5acd0c
parent44c874b731f9f58c2f50c3c6076371058cbe26e3 (diff)
FLUID support for inline image data (see #542, #592) (#604)
-rw-r--r--fluid/Fl_Menu_Type.cxx2
-rw-r--r--fluid/Fl_Widget_Type.cxx66
-rw-r--r--fluid/Fl_Widget_Type.h2
-rw-r--r--fluid/Fluid_Image.cxx216
-rw-r--r--fluid/Fluid_Image.h5
-rw-r--r--fluid/README_fl.txt2
-rw-r--r--fluid/pixmaps.cxx3
-rw-r--r--fluid/pixmaps.h1
-rw-r--r--fluid/pixmaps/bind.xpm30
-rw-r--r--fluid/pixmaps/compressed.xpm45
-rw-r--r--fluid/widget_panel.cxx22
-rw-r--r--fluid/widget_panel.fl26
-rw-r--r--fluid/widget_panel.h2
-rw-r--r--test/preferences.fl4
14 files changed, 328 insertions, 98 deletions
diff --git a/fluid/Fl_Menu_Type.cxx b/fluid/Fl_Menu_Type.cxx
index 6d71bce85..92445ff17 100644
--- a/fluid/Fl_Menu_Type.cxx
+++ b/fluid/Fl_Menu_Type.cxx
@@ -303,7 +303,7 @@ void Fl_Menu_Item_Type::write_static() {
}
if (image) {
if (image->written != write_number) {
- image->write_static();
+ image->write_static(compress_image_);
image->written = write_number;
}
}
diff --git a/fluid/Fl_Widget_Type.cxx b/fluid/Fl_Widget_Type.cxx
index eb071a412..17e522e14 100644
--- a/fluid/Fl_Widget_Type.cxx
+++ b/fluid/Fl_Widget_Type.cxx
@@ -211,7 +211,9 @@ Fl_Widget_Type::Fl_Widget_Type() {
o = 0;
public_ = 1;
bind_image_ = 0;
+ compress_image_ = 1;
bind_deimage_ = 0;
+ compress_deimage_ = 1;
}
Fl_Widget_Type::~Fl_Widget_Type() {
@@ -497,6 +499,26 @@ void bind_image_cb(Fl_Button* b, void *v) {
}
}
+void compress_image_cb(Fl_Button* b, void *v) {
+ if (v == LOAD) {
+ if (current_widget->is_widget() && !current_widget->is_window()) {
+ b->activate();
+ b->value(current_widget->compress_image_);
+ } else {
+ b->deactivate();
+ }
+ } else {
+ int mod = 0;
+ for (Fl_Type *o = Fl_Type::first; o; o = o->next) {
+ if (o->selected && o->is_widget()) {
+ ((Fl_Widget_Type*)o)->compress_image_ = b->value();
+ mod = 1;
+ }
+ }
+ if (mod) set_modflag(1);
+ }
+}
+
static Fl_Input *inactive_input;
void inactive_cb(Fl_Input* i, void *v) {
@@ -559,6 +581,26 @@ void bind_deimage_cb(Fl_Button* b, void *v) {
}
}
+void compress_deimage_cb(Fl_Button* b, void *v) {
+ if (v == LOAD) {
+ if (current_widget->is_widget() && !current_widget->is_window()) {
+ b->activate();
+ b->value(current_widget->compress_deimage_);
+ } else {
+ b->deactivate();
+ }
+ } else {
+ int mod = 0;
+ for (Fl_Type *o = Fl_Type::first; o; o = o->next) {
+ if (o->selected && o->is_widget()) {
+ ((Fl_Widget_Type*)o)->compress_deimage_ = b->value();
+ mod = 1;
+ }
+ }
+ if (mod) set_modflag(1);
+ }
+}
+
void tooltip_cb(Fl_Input* i, void *v) {
if (v == LOAD) {
if (current_widget->is_widget()) {
@@ -2739,13 +2781,13 @@ void Fl_Widget_Type::write_static() {
}
if (image) {
if (image->written != write_number) {
- image->write_static();
+ image->write_static(compress_image_);
image->written = write_number;
}
}
if (inactive) {
if (inactive->written != write_number) {
- inactive->write_static();
+ inactive->write_static(compress_deimage_);
inactive->written = write_number;
}
}
@@ -3084,11 +3126,13 @@ void Fl_Widget_Type::write_properties() {
if (image_name() && *image_name()) {
write_string("image");
write_word(image_name());
+ write_string("compress_image %d", compress_image_);
}
if (bind_image_) write_string("bind_image 1");
if (inactive_name() && *inactive_name()) {
write_string("deimage");
write_word(inactive_name());
+ write_string("compress_deimage %d", compress_deimage_);
}
if (bind_deimage_) write_string("bind_deimage 1");
write_string("xywh {%d %d %d %d}", o->x(), o->y(), o->w(), o->h());
@@ -3211,12 +3255,30 @@ void Fl_Widget_Type::read_property(const char *c) {
tooltip(read_word());
} else if (!strcmp(c,"image")) {
image_name(read_word());
+ // starting in 2023, `image` is always followed by `compress_image`
+ // the code below is for compatibility with older .fl files
+ const char *ext = fl_filename_ext(image_name_);
+ if ( strcmp(ext, ".jpg")
+ && strcmp(ext, ".svg")
+ && strcmp(ext, ".svgz"))
+ compress_image_ = 0; // if it is neither of those, default to uncompressed
} else if (!strcmp(c,"bind_image")) {
bind_image_ = (int)atol(read_word());
+ } else if (!strcmp(c,"compress_image")) {
+ compress_image_ = (int)atol(read_word());
} else if (!strcmp(c,"deimage")) {
inactive_name(read_word());
+ // starting in 2023, `deimage` is always followed by `compress_deimage`
+ // the code below is for compatibility with older .fl files
+ const char *ext = fl_filename_ext(inactive_name_);
+ if ( strcmp(ext, ".jpg")
+ && strcmp(ext, ".svg")
+ && strcmp(ext, ".svgz"))
+ compress_deimage_ = 0; // if it is neither of those, default to uncompressed
} else if (!strcmp(c,"bind_deimage")) {
bind_deimage_ = (int)atol(read_word());
+ } else if (!strcmp(c,"compress_deimage")) {
+ compress_deimage_ = (int)atol(read_word());
} else if (!strcmp(c,"type")) {
if (is_spinner())
((Fl_Spinner*)o)->type(item_number(subtypes(), read_word()));
diff --git a/fluid/Fl_Widget_Type.h b/fluid/Fl_Widget_Type.h
index a9e9942e1..c821c7c1a 100644
--- a/fluid/Fl_Widget_Type.h
+++ b/fluid/Fl_Widget_Type.h
@@ -67,7 +67,9 @@ public:
Fl_Widget *o;
int public_;
int bind_image_;
+ int compress_image_;
int bind_deimage_;
+ int compress_deimage_;
Fluid_Image *image;
void setimage(Fluid_Image *);
diff --git a/fluid/Fluid_Image.cxx b/fluid/Fluid_Image.cxx
index c16ea4d00..a72768014 100644
--- a/fluid/Fluid_Image.cxx
+++ b/fluid/Fluid_Image.cxx
@@ -29,6 +29,7 @@
#include <FL/fl_string_functions.h>
#include <FL/fl_utf8.h> // fl_fopen()
#include <FL/Fl_File_Chooser.H>
+#include <FL/Fl_SVG_Image.H>
#include "../src/flstring.h"
#include <stdio.h>
@@ -48,13 +49,111 @@ static int pixmap_header_written = 0;
static int bitmap_header_written = 0;
static int image_header_written = 0;
static int jpeg_header_written = 0;
+static int png_header_written = 0;
+static int gif_header_written = 0;
+static int bmp_header_written = 0;
static int svg_header_written = 0;
-void Fluid_Image::write_static() {
+/** Write the contents of the name() file as binary source code. */
+size_t Fluid_Image::write_static_binary() {
+ size_t nData = 0;
+ enter_project_dir();
+ FILE *f = fl_fopen(name(), "rb");
+ leave_project_dir();
+ if (!f) {
+ return -1;
+ } else {
+ fseek(f, 0, SEEK_END);
+ nData = ftell(f);
+ fseek(f, 0, SEEK_SET);
+ if (nData) {
+ char *data = (char*)calloc(nData, 1);
+ if (fread(data, nData, 1, f)==0) { /* ignore */ }
+ write_cdata(data, (int)nData);
+ free(data);
+ }
+ fclose(f);
+ }
+ return nData;
+}
+
+/** Write the contents of the name() file as textual source code. */
+size_t Fluid_Image::write_static_text() {
+ size_t nData = 0;
+ enter_project_dir();
+ FILE *f = fl_fopen(name(), "rb");
+ leave_project_dir();
+ if (!f) {
+ return -1;
+ } else {
+ fseek(f, 0, SEEK_END);
+ nData = ftell(f);
+ fseek(f, 0, SEEK_SET);
+ if (nData) {
+ char *data = (char*)calloc(nData+1, 1);
+ if (fread(data, nData, 1, f)==0) { /* ignore */ }
+ write_cstring(data, (int)nData);
+ free(data);
+ }
+ fclose(f);
+ }
+ return nData;
+}
+
+void Fluid_Image::write_static_rgb(const char* idata_name) {
+ // Write image data...
+ write_c("\n");
+ if (image_header_written != write_number) {
+ write_c("#include <FL/Fl_Image.H>\n");
+ image_header_written = write_number;
+ }
+ write_c("static const unsigned char %s[] =\n", idata_name);
+ const int extra_data = img->ld() ? (img->ld()-img->w()*img->d()) : 0;
+ write_cdata(img->data()[0], (img->w() * img->d() + extra_data) * img->h());
+ write_c(";\n");
+ write_initializer("Fl_RGB_Image", "%s, %d, %d, %d, %d", idata_name, img->w(), img->h(), img->d(), img->ld());
+}
+
+/**
+ Write the static image data into the soutrce file.
+
+ If \p compressed is set, write the original image format, which requires
+ linking the matching image reader at runtime, or if we want to store the raw
+ uncompressed pixels, which makes images fast, needs no reader, but takes a
+ lot of memory (current default for PNG)
+
+ \param compressed write data in the original compressed file format
+ */
+void Fluid_Image::write_static(int compressed) {
if (!img) return;
const char *idata_name = unique_id(this, "idata", fl_filename_name(name()), 0);
function_name_ = unique_id(this, "image", fl_filename_name(name()), 0);
- if (img->count() > 1) {
+ // TODO: GIF, ICO, BMP
+ if (compressed && strcmp(fl_filename_ext(name()), ".gif")==0) {
+ // Write gif image data...
+ write_c("\n");
+ if (gif_header_written != write_number) {
+ write_c("#include <FL/Fl_GIF_Image.H>\n");
+ gif_header_written = write_number;
+ }
+ write_c("static const unsigned char %s[] =\n", idata_name);
+ size_t nData = write_static_binary();
+ if (nData == -1) write_file_error("GIF");
+ write_c(";\n");
+ write_initializer("Fl_GIF_Image", "\"%s\", %s, %d", fl_filename_name(name()), idata_name, nData);
+ } else if (compressed && strcmp(fl_filename_ext(name()), ".bmp")==0) {
+ // Write bmp image data...
+ write_c("\n");
+ if (gif_header_written != write_number) {
+ write_c("#include <FL/Fl_BMP_Image.H>\n");
+ gif_header_written = write_number;
+ }
+ write_c("static const unsigned char %s[] =\n", idata_name);
+ size_t nData = write_static_binary();
+ if (nData == -1) write_file_error("BMP");
+ write_c(";\n");
+ write_initializer("Fl_BMP_Image", "\"%s\", %s, %d", fl_filename_name(name()), idata_name, nData);
+ } else if (img->count() > 1) {
// Write Pixmap data...
write_c("\n");
if (pixmap_header_written != write_number) {
@@ -95,7 +194,7 @@ void Fluid_Image::write_static() {
write_cdata(img->data()[0], ((img->w() + 7) / 8) * img->h());
write_c(";\n");
write_initializer( "Fl_Bitmap", "%s, %d, %d, %d", idata_name, ((img->w() + 7) / 8) * img->h(), img->w(), img->h());
- } else if (strcmp(fl_filename_ext(name()), ".jpg")==0) {
+ } else if (compressed && strcmp(fl_filename_ext(name()), ".jpg")==0) {
// Write jpeg image data...
write_c("\n");
if (jpeg_header_written != write_number) {
@@ -103,79 +202,62 @@ void Fluid_Image::write_static() {
jpeg_header_written = write_number;
}
write_c("static const unsigned char %s[] =\n", idata_name);
-
- size_t nData = 0;
- enter_project_dir();
- FILE *f = fl_fopen(name(), "rb");
- leave_project_dir();
- if (!f) {
- write_file_error("JPEG");
- } else {
- fseek(f, 0, SEEK_END);
- nData = ftell(f);
- fseek(f, 0, SEEK_SET);
- if (nData) {
- char *data = (char*)calloc(nData, 1);
- if (fread(data, nData, 1, f)==0) { /* ignore */ }
- write_cdata(data, (int)nData);
- free(data);
- }
- fclose(f);
- }
-
+ size_t nData = write_static_binary();
+ if (nData == -1) write_file_error("JPEG");
write_c(";\n");
write_initializer("Fl_JPEG_Image", "\"%s\", %s, %d", fl_filename_name(name()), idata_name, nData);
+ } else if (compressed && strcmp(fl_filename_ext(name()), ".png")==0) {
+ // Write png image data...
+ write_c("\n");
+ if (png_header_written != write_number) {
+ write_c("#include <FL/Fl_PNG_Image.H>\n");
+ png_header_written = write_number;
+ }
+ write_c("static const unsigned char %s[] =\n", idata_name);
+ size_t nData = write_static_binary();
+ if (nData == -1) write_file_error("PNG");
+ write_c(";\n");
+ write_initializer("Fl_PNG_Image", "\"%s\", %s, %d", fl_filename_name(name()), idata_name, nData);
} else if (strcmp(fl_filename_ext(name()), ".svg")==0 || strcmp(fl_filename_ext(name()), ".svgz")==0) {
bool gzipped = (strcmp(fl_filename_ext(name()), ".svgz") == 0);
// Write svg image data...
- write_c("\n");
- if (svg_header_written != write_number) {
- write_c("#include <FL/Fl_SVG_Image.H>\n");
- svg_header_written = write_number;
- }
- write_c(
- (gzipped ? "static const unsigned char %s[] =\n" : "static const char %s[] =\n"),
- idata_name);
-
- enter_project_dir();
- FILE *f = fl_fopen(name(), "rb");
- leave_project_dir();
- size_t nData = 0;
- if (!f) {
- write_file_error("SVG");
+ if (compressed) {
+ write_c("\n");
+ if (svg_header_written != write_number) {
+ write_c("#include <FL/Fl_SVG_Image.H>\n");
+ svg_header_written = write_number;
+ }
+ if (gzipped) {
+ write_c("static const unsigned char %s[] =\n", idata_name);
+ size_t nData = write_static_binary();
+ if (nData == -1) write_file_error("SVGZ");
+ write_c(";\n");
+ write_initializer("Fl_SVG_Image", "\"%s\", %s, %ld", fl_filename_name(name()), idata_name, nData);
+ } else {
+ write_c("static const char %s[] =\n", idata_name);
+ size_t nData = write_static_text();
+ if (nData == -1) write_file_error("SVG");
+ write_c(";\n");
+ write_initializer("Fl_SVG_Image", "\"%s\", %s", fl_filename_name(name()), idata_name);
+ }
} else {
- fseek(f, 0, SEEK_END);
- nData = ftell(f);
- fseek(f, 0, SEEK_SET);
- if (nData) {
- char *data = (char*)calloc(nData+1, 1);
- if (fread(data, nData, 1, f)==0) { /* ignore */ }
- if (gzipped)
- write_cdata(data, (int)nData);
- else
- write_cstring(data, (int)nData);
- free(data);
+ // if FLUID runs from the command line, make sure that the image is not
+ // only loade but also rasterized, so we can write the RGB image data
+ Fl_RGB_Image* rgb_image = NULL;
+ Fl_SVG_Image* svg_image = NULL;
+ if (img->d()>0)
+ rgb_image = (Fl_RGB_Image*)img->image();
+ if (rgb_image)
+ svg_image = rgb_image->as_svg_image();
+ if (svg_image) {
+ svg_image->resize(svg_image->w(), svg_image->h());
+ write_static_rgb(idata_name);
+ } else {
+ write_file_error("RGB_from_SVG");
}
- fclose(f);
}
-
- write_c(";\n");
- if (gzipped)
- write_initializer("Fl_SVG_Image", "\"%s\", (const char*)%s, %ld", fl_filename_name(name()), idata_name, nData);
- else
- write_initializer("Fl_SVG_Image", "\"%s\", %s", fl_filename_name(name()), idata_name);
} else {
- // Write image data...
- write_c("\n");
- if (image_header_written != write_number) {
- write_c("#include <FL/Fl_Image.H>\n");
- image_header_written = write_number;
- }
- write_c("static const unsigned char %s[] =\n", idata_name);
- const int extra_data = img->ld() ? (img->ld()-img->w()*img->d()) : 0;
- write_cdata(img->data()[0], (img->w() * img->d() + extra_data) * img->h());
- write_c(";\n");
- write_initializer("Fl_RGB_Image", "%s, %d, %d, %d, %d", idata_name, img->w(), img->h(), img->d(), img->ld());
+ write_static_rgb(idata_name);
}
}
diff --git a/fluid/Fluid_Image.h b/fluid/Fluid_Image.h
index 738789223..705495b65 100644
--- a/fluid/Fluid_Image.h
+++ b/fluid/Fluid_Image.h
@@ -31,6 +31,9 @@ class Fluid_Image {
protected:
Fluid_Image(const char *name); // no public constructor
~Fluid_Image(); // no public destructor
+ size_t write_static_binary();
+ size_t write_static_text();
+ void write_static_rgb(const char* idata_name);
public:
int written;
static Fluid_Image* find(const char *);
@@ -38,7 +41,7 @@ public:
void increment();
void image(Fl_Widget *); // set the image of this widget
void deimage(Fl_Widget *); // set the deimage of this widget
- void write_static();
+ void write_static(int compressed);
void write_initializer(const char *type_name, const char *format, ...);
void write_code(int bind, const char *var, int inactive = 0);
void write_inline(int inactive = 0);
diff --git a/fluid/README_fl.txt b/fluid/README_fl.txt
index f70c217b2..f1105081a 100644
--- a/fluid/README_fl.txt
+++ b/fluid/README_fl.txt
@@ -380,8 +380,10 @@ Type "Fl_Widget" <word> : C++ variable name
"xywh" <word> : "{%d %d %d %d}" x, y, w, h
"tooltip" <word> : tooltip text
"image" <word> : image name
+ "compress_image" <word> : integer (1.4 and up, only if `image` is set)
"bind_image" <word> : integer (1.4 and up)
"deimage" <word> : deactivated image name
+ "compress_deimage" <word> : integer (1.4 and up, only if `deimage` is set)
"bind_deimage" <word> : integer (1.4 and up)
"type" <word> : integer
"box" <word> : text or integer (see FLTK boxtypes)
diff --git a/fluid/pixmaps.cxx b/fluid/pixmaps.cxx
index 358dd2c24..01b26afd7 100644
--- a/fluid/pixmaps.cxx
+++ b/fluid/pixmaps.cxx
@@ -22,6 +22,7 @@
#include "pixmaps/lock.xpm"
#include "pixmaps/protected.xpm"
#include "pixmaps/invisible.xpm"
+#include "pixmaps/compressed.xpm"
#include "pixmaps/flWindow.xpm"
#include "pixmaps/flButton.xpm"
@@ -84,6 +85,7 @@ Fl_Pixmap *bind_pixmap;
Fl_Pixmap *lock_pixmap;
Fl_Pixmap *protected_pixmap;
Fl_Pixmap *invisible_pixmap;
+Fl_Pixmap *compressed_pixmap;
Fl_Pixmap *window_pixmap;
Fl_Pixmap *button_pixmap;
@@ -150,6 +152,7 @@ void loadPixmaps()
lock_pixmap = new Fl_Pixmap(lock_xpm); lock_pixmap->scale(16, 16);
protected_pixmap = new Fl_Pixmap(protected_xpm); protected_pixmap->scale(16, 16);
invisible_pixmap = new Fl_Pixmap(invisible_xpm); invisible_pixmap->scale(16, 16);
+ compressed_pixmap = new Fl_Pixmap(compressed_xpm); compressed_pixmap->scale(16, 16);
pixmap[1] = window_pixmap = new Fl_Pixmap(flWindow_xpm); window_pixmap->scale(16, 16);
pixmap[2] = button_pixmap = new Fl_Pixmap(flButton_xpm); button_pixmap->scale(16, 16);
diff --git a/fluid/pixmaps.h b/fluid/pixmaps.h
index 0fafec78a..4d33ca9be 100644
--- a/fluid/pixmaps.h
+++ b/fluid/pixmaps.h
@@ -23,6 +23,7 @@ extern Fl_Pixmap *bind_pixmap;
extern Fl_Pixmap *lock_pixmap;
extern Fl_Pixmap *protected_pixmap;
extern Fl_Pixmap *invisible_pixmap;
+extern Fl_Pixmap *compressed_pixmap;
extern Fl_Pixmap *window_pixmap;
extern Fl_Pixmap *button_pixmap;
diff --git a/fluid/pixmaps/bind.xpm b/fluid/pixmaps/bind.xpm
index 7d98189ac..db3d9e824 100644
--- a/fluid/pixmaps/bind.xpm
+++ b/fluid/pixmaps/bind.xpm
@@ -3,12 +3,12 @@ static const char * const bind_xpm[] = {
/* width height ncolors chars_per_picel */
"32 32 6 1",
/* colors */
-"- c #aaaaaa",
-"= c #666666",
+"- c #000",
+"= c #444",
"c c none",
"d c #cccccc",
-". c #000000",
-", c #222222",
+". c #666",
+", c #888",
/* pixels */
"cccccccccccccccccccccccccccccccc",
"cccccccccccccccccccccccccccccccc",
@@ -21,17 +21,17 @@ static const char * const bind_xpm[] = {
"cccccccc------cccccccccc......cc",
"cccccccc-----cccccccccccc.....cc",
"cccccc,,,,,,,,,,,,,,cccccc....cc",
-"cccc,,................cccc....cc",
-"ccc,...................ccc....cc",
-"cc,...............=====ccc....cc",
-"cc......-----cccccc-----c,....cc",
-"cc.....c-----cccccc-----,.....cc",
-"cc....ccc=====,,,,,,,,,,.....ccc",
-"cc....ccc....................ccc",
-"cc....cccc..................cccc",
-"cc....cccccc..............cccccc",
-"cc.....cccccccccccc-----cccccccc",
-"cc......cccccccccc------cccccccc",
+"cccc,,................cccc,...cc",
+"ccc,...................ccc,...cc",
+"ccc,..............=====ccc,...cc",
+"cc,.....-----cccccc-----c,....cc",
+"cc,....c-----cccccc-----,.....cc",
+"cc,...ccc=====,,,,,,,,,,.....ccc",
+"cc,...ccc....................ccc",
+"cc,...cccc..................cccc",
+"cc,...cccccc..............cccccc",
+"cc,....cccccccccccc-----cccccccc",
+"cc,.....cccccccccc------cccccccc",
"ccc.....,,,,,,,,=======ccccccccc",
"ccc....................ccccccccc",
"cccc..................cccccccccc",
diff --git a/fluid/pixmaps/compressed.xpm b/fluid/pixmaps/compressed.xpm
new file mode 100644
index 000000000..fc4663d07
--- /dev/null
+++ b/fluid/pixmaps/compressed.xpm
@@ -0,0 +1,45 @@
+/* cPM */
+static const char * const compressed_xpm[] = {
+/* width height ncolors chars_per_picel */
+"32 32 6 1",
+/* colors */
+"- c #000",
+"= c #444",
+"c c none",
+"d c #cccccc",
+". c #888",
+", c #888",
+/* pixels */
+"cccccccccccccccccccccccccccccccc",
+"cccccccccccccccccccccccccccccccc",
+"ccccccc==================ccccccc",
+"cccccccc================cccccccc",
+"ccccccccc==============ccccccccc",
+"cccccccccc============cccccccccc",
+"ccccccccccc==========ccccccccccc",
+"cccccccccccc========cccccccccccc",
+"ccccccccccccc======ccccccccccccc",
+"cccccccccccccc====cccccccccccccc",
+"cc==.cccccccccc==ccccccccccc==cc",
+"cc.====..cccccccccccccc..====.cc",
+"cccc.======================.cccc",
+"cccccccc..============..cccccccc",
+"cccccccccccccccccccccccccccccccc",
+"cccccccccccccccccccccccccccccccc",
+"cccccccc..============..cccccccc",
+"cccc.======================.cccc",
+"cc.====..cccccccccccccc..====.cc",
+"cc==.cccccccccc==ccccccccccc==cc",
+"cccccccccccccc====cccccccccccccc",
+"ccccccccccccc======ccccccccccccc",
+"cccccccccccc========cccccccccccc",
+"ccccccccccc==========ccccccccccc",
+"cccccccccc============cccccccccc",
+"ccccccccc==============ccccccccc",
+"cccccccc================cccccccc",
+"ccccccc==================ccccccc",
+"cccccccccccccccccccccccccccccccc",
+"cccccccccccccccccccccccccccccccc",
+"cccccccccccccccccccccccccccccccc",
+"cccccccccccccccccccccccccccccccc",
+};
diff --git a/fluid/widget_panel.cxx b/fluid/widget_panel.cxx
index 1a6b825a3..4464f417d 100644
--- a/fluid/widget_panel.cxx
+++ b/fluid/widget_panel.cxx
@@ -165,7 +165,7 @@ Fl_Double_Window* make_widget_panel() {
o->labelsize(11);
o->callback((Fl_Callback*)propagate_load);
o->align(Fl_Align(FL_ALIGN_LEFT));
- { Fl_Input* o = new Fl_Input(95, 65, 220, 20);
+ { Fl_Input* o = new Fl_Input(95, 65, 200, 20);
o->tooltip("The active image for the widget.");
o->labelfont(1);
o->labelsize(11);
@@ -173,7 +173,7 @@ Fl_Double_Window* make_widget_panel() {
o->callback((Fl_Callback*)image_cb);
Fl_Group::current()->resizable(o);
} // Fl_Input* o
- { Fl_Button* o = new Fl_Button(314, 65, 70, 20, "Browse...");
+ { Fl_Button* o = new Fl_Button(294, 65, 70, 20, "Browse...");
o->tooltip("Click to choose the active image.");
o->labelsize(11);
o->callback((Fl_Callback*)image_browse_cb);
@@ -184,6 +184,13 @@ Fl_Double_Window* make_widget_panel() {
o->callback((Fl_Callback*)bind_image_cb);
o->image(bind_pixmap);
} // Fl_Button* o
+ { Fl_Button* o = new Fl_Button(364, 65, 20, 20);
+ o->tooltip("store image uncompressed as RGBA data\nor compressed in the original file for\
+mat");
+ o->type(1);
+ o->callback((Fl_Callback*)compress_image_cb);
+ o->image(compressed_pixmap);
+ } // Fl_Button* o
o->end();
} // Fl_Group* o
{ Fl_Group* o = new Fl_Group(95, 90, 309, 20, "Inactive:");
@@ -191,7 +198,7 @@ Fl_Double_Window* make_widget_panel() {
o->labelsize(11);
o->callback((Fl_Callback*)propagate_load);
o->align(Fl_Align(FL_ALIGN_LEFT));
- { Fl_Input* o = new Fl_Input(95, 90, 220, 20);
+ { Fl_Input* o = new Fl_Input(95, 90, 200, 20);
o->tooltip("The inactive image for the widget.");
o->labelfont(1);
o->labelsize(11);
@@ -199,7 +206,7 @@ Fl_Double_Window* make_widget_panel() {
o->callback((Fl_Callback*)inactive_cb);
Fl_Group::current()->resizable(o);
} // Fl_Input* o
- { Fl_Button* o = new Fl_Button(314, 90, 70, 20, "Browse...");
+ { Fl_Button* o = new Fl_Button(294, 90, 70, 20, "Browse...");
o->tooltip("Click to choose the inactive image.");
o->labelsize(11);
o->callback((Fl_Callback*)inactive_browse_cb);
@@ -210,6 +217,13 @@ Fl_Double_Window* make_widget_panel() {
o->callback((Fl_Callback*)bind_deimage_cb);
o->image(bind_pixmap);
} // Fl_Button* o
+ { Fl_Button* o = new Fl_Button(364, 90, 20, 20);
+ o->tooltip("store image uncompressed as RGBA data\nor compressed in the original file for\
+mat");
+ o->type(1);
+ o->callback((Fl_Callback*)compress_deimage_cb);
+ o->image(compressed_pixmap);
+ } // Fl_Button* o
o->end();
} // Fl_Group* o
{ Fl_Group* o = new Fl_Group(95, 115, 310, 20, "Alignment:");
diff --git a/fluid/widget_panel.fl b/fluid/widget_panel.fl
index a88aa09c4..2673aed86 100644
--- a/fluid/widget_panel.fl
+++ b/fluid/widget_panel.fl
@@ -67,19 +67,26 @@ Use Ctrl-J for newlines.} xywh {95 40 190 20} labelfont 1 labelsize 11 when 15 t
} {
Fl_Input {} {
callback image_cb
- tooltip {The active image for the widget.} xywh {95 65 220 20} labelfont 1 labelsize 11 textsize 11 resizable
+ tooltip {The active image for the widget.} xywh {95 65 200 20} labelfont 1 labelsize 11 textsize 11 resizable
}
Fl_Button {} {
label {Browse...}
callback image_browse_cb
- tooltip {Click to choose the active image.} xywh {314 65 70 20} labelsize 11
+ tooltip {Click to choose the active image.} xywh {294 65 70 20} labelsize 11
}
Fl_Button {} {
- callback bind_image_cb selected
+ callback bind_image_cb
tooltip {bind the image to the widget, so it will be deleted automatically} xywh {384 65 20 20} type Toggle
code0 {o->image(bind_pixmap);}
code3 {\#include "pixmaps.h"}
}
+ Fl_Button {} {
+ callback compress_image_cb
+ tooltip {store image uncompressed as RGBA data
+or compressed in the original file format} xywh {364 65 20 20} type Toggle
+ code0 {o->image(compressed_pixmap);}
+ code3 {\#include "pixmaps.h"}
+ }
}
Fl_Group {} {
label {Inactive:}
@@ -88,12 +95,12 @@ Use Ctrl-J for newlines.} xywh {95 40 190 20} labelfont 1 labelsize 11 when 15 t
} {
Fl_Input {} {
callback inactive_cb
- tooltip {The inactive image for the widget.} xywh {95 90 220 20} labelfont 1 labelsize 11 textsize 11 resizable
+ tooltip {The inactive image for the widget.} xywh {95 90 200 20} labelfont 1 labelsize 11 textsize 11 resizable
}
Fl_Button {} {
label {Browse...}
callback inactive_browse_cb
- tooltip {Click to choose the inactive image.} xywh {314 90 70 20} labelsize 11
+ tooltip {Click to choose the inactive image.} xywh {294 90 70 20} labelsize 11
}
Fl_Button {} {
callback bind_deimage_cb
@@ -101,6 +108,13 @@ Use Ctrl-J for newlines.} xywh {95 40 190 20} labelfont 1 labelsize 11 when 15 t
code0 {o->image(bind_pixmap);}
code3 {\#include "pixmaps.h"}
}
+ Fl_Button {} {
+ callback compress_deimage_cb
+ tooltip {store image uncompressed as RGBA data
+or compressed in the original file format} xywh {364 90 20 20} type Toggle
+ code0 {o->image(compressed_pixmap);}
+ code3 {\#include "pixmaps.h"}
+ }
}
Fl_Group {} {
label {Alignment:}
@@ -798,7 +812,7 @@ wCallback->do_callback(wCallback, v);} open
}
Fl_Button wLiveMode {
label {Live &Resize}
- callback live_mode_cb
+ callback live_mode_cb selected
tooltip {Create a live duplicate of the selected widgets to test resizing and menu behavior.} xywh {155 370 80 20} type Toggle labelsize 11
}
Fl_Button {} {
diff --git a/fluid/widget_panel.h b/fluid/widget_panel.h
index 35ef3c622..630e5fd60 100644
--- a/fluid/widget_panel.h
+++ b/fluid/widget_panel.h
@@ -34,9 +34,11 @@ extern void image_cb(Fl_Input*, void*);
extern void image_browse_cb(Fl_Button*, void*);
#include "pixmaps.h"
extern void bind_image_cb(Fl_Button*, void*);
+extern void compress_image_cb(Fl_Button*, void*);
extern void inactive_cb(Fl_Input*, void*);
extern void inactive_browse_cb(Fl_Button*, void*);
extern void bind_deimage_cb(Fl_Button*, void*);
+extern void compress_deimage_cb(Fl_Button*, void*);
extern void align_cb(Fl_Button*, void*);
extern void align_text_image_cb(Fl_Choice*, void*);
extern void align_position_cb(Fl_Choice*, void*);
diff --git a/test/preferences.fl b/test/preferences.fl
index a855ce0f4..211a77396 100644
--- a/test/preferences.fl
+++ b/test/preferences.fl
@@ -145,7 +145,7 @@ Function {} {open return_type int
}
Fl_Button {} {
label OK
- callback saveAndCloseWindowCB
+ callback saveAndCloseWindowCB selected
xywh {125 303 75 25}
}
Fl_Group {} {
@@ -283,7 +283,7 @@ Function {} {open return_type int
}
Fl_Choice wLanguage {
label {Language:}
- callback {fl_message("%s", _("Please restart the app to use your new language setting."));} open selected
+ callback {fl_message("%s", _("Please restart the app to use your new language setting."));} open
xywh {120 269 105 20} down_box BORDER_BOX
code0 {\#include <FL/fl_ask.H>}
} {