diff options
Diffstat (limited to 'fluid')
| -rw-r--r-- | fluid/Fl_Widget_Type.cxx | 82 | ||||
| -rw-r--r-- | fluid/Fl_Widget_Type.h | 2 | ||||
| -rw-r--r-- | fluid/README_fl.txt | 2 | ||||
| -rw-r--r-- | fluid/alignment_panel.cxx | 18 | ||||
| -rw-r--r-- | fluid/alignment_panel.fl | 15 | ||||
| -rw-r--r-- | fluid/widget_panel.cxx | 509 | ||||
| -rw-r--r-- | fluid/widget_panel.fl | 348 | ||||
| -rw-r--r-- | fluid/widget_panel.h | 34 |
8 files changed, 863 insertions, 147 deletions
diff --git a/fluid/Fl_Widget_Type.cxx b/fluid/Fl_Widget_Type.cxx index 9a5c3251a..f11c7f968 100644 --- a/fluid/Fl_Widget_Type.cxx +++ b/fluid/Fl_Widget_Type.cxx @@ -151,8 +151,17 @@ void Fl_Widget_Type::setimage(Fluid_Image *i) { if (image) image->decrement(); if (i) i->increment(); image = i; - if (i) i->image(o); - else o->image(0); + if (i) { + i->image(o); + if (o->image() && (scale_image_w_ || scale_image_h_)) { + int iw = scale_image_w_>0 ? scale_image_w_ : o->image()->data_w(); + int ih = scale_image_h_>0 ? scale_image_h_ : o->image()->data_h(); + o->image()->scale(iw, ih, 0, 1); + } + } else { + o->image(0); + //scale_image_w_ = scale_image_h_ = 0; + } redraw(); } @@ -161,8 +170,17 @@ void Fl_Widget_Type::setinactive(Fluid_Image *i) { if (inactive) inactive->decrement(); if (i) i->increment(); inactive = i; - if (i) i->deimage(o); - else o->deimage(0); + if (i) { + i->deimage(o); + if (o->deimage()) { + int iw = scale_deimage_w_>0 ? scale_deimage_w_ : o->deimage()->data_w(); + int ih = scale_deimage_h_>0 ? scale_deimage_h_ : o->deimage()->data_h(); + o->deimage()->scale(iw, ih, 0, 1); + } + } else { + o->deimage(0); + //scale_deimage_w_ = scale_deimage_h_ = 0; + } redraw(); } @@ -188,6 +206,10 @@ Fl_Widget_Type::Fl_Widget_Type() compress_image_ = 1; bind_deimage_ = 0; compress_deimage_ = 1; + scale_image_w_ = 0; + scale_image_h_ = 0; + scale_deimage_w_ = 0; + scale_deimage_h_ = 0; } Fl_Widget_Type::~Fl_Widget_Type() { @@ -457,7 +479,7 @@ void image_browse_cb(Fl_Button* b, void *v) { } } -void bind_image_cb(Fl_Button* b, void *v) { +void bind_image_cb(Fl_Check_Button* b, void *v) { if (v == LOAD) { if (current_widget->is_widget() && !current_widget->is_a(ID_Window)) { b->activate(); @@ -477,7 +499,7 @@ void bind_image_cb(Fl_Button* b, void *v) { } } -void compress_image_cb(Fl_Button* b, void *v) { +void compress_image_cb(Fl_Check_Button* b, void *v) { if (v == LOAD) { if (current_widget->is_widget() && !current_widget->is_a(ID_Window)) { b->activate(); @@ -539,7 +561,7 @@ void inactive_browse_cb(Fl_Button* b, void *v) { } } -void bind_deimage_cb(Fl_Button* b, void *v) { +void bind_deimage_cb(Fl_Check_Button* b, void *v) { if (v == LOAD) { if (current_widget->is_widget() && !current_widget->is_a(ID_Window)) { b->activate(); @@ -559,7 +581,7 @@ void bind_deimage_cb(Fl_Button* b, void *v) { } } -void compress_deimage_cb(Fl_Button* b, void *v) { +void compress_deimage_cb(Fl_Check_Button* b, void *v) { if (v == LOAD) { if (current_widget->is_widget() && !current_widget->is_a(ID_Window)) { b->activate(); @@ -3109,8 +3131,34 @@ void Fl_Widget_Type::write_widget_code(Fd_Code_Writer& f) { write_color(f, "color", o->color()); if (o->selection_color() != tplate->selection_color() || subclass()) write_color(f, "selection_color", o->selection_color()); - if (image) image->write_code(f, bind_image_, var); - if (inactive) inactive->write_code(f, bind_deimage_, var, 1); + if (image) { + image->write_code(f, bind_image_, var); + if (scale_image_w_ || scale_image_h_) { + f.write_c("%s%s->image()->scale(", f.indent(), var); + if (scale_image_w_>0) + f.write_c("%d, ", scale_image_w_); + else + f.write_c("%s->image()->data_w(), ", var); + if (scale_image_h_>0) + f.write_c("%d, 0, 1);\n", scale_image_h_); + else + f.write_c("%s->image()->data_h(), 0, 1);\n", var); + } + } + if (inactive) { + inactive->write_code(f, bind_deimage_, var, 1); + if (scale_deimage_w_ || scale_deimage_h_) { + f.write_c("%s%s->deimage()->scale(", f.indent(), var); + if (scale_deimage_w_>0) + f.write_c("%d, ", scale_deimage_w_); + else + f.write_c("%s->deimage()->data_w(), ", var); + if (scale_deimage_h_>0) + f.write_c("%d, 0, 1);\n", scale_deimage_h_); + else + f.write_c("%s->deimage()->data_h(), 0, 1);\n", var); + } + } if (o->labeltype() != tplate->labeltype() || subclass()) f.write_c("%s%s->labeltype(FL_%s);\n", f.indent(), var, item_name(labeltypemenu, o->labeltype())); @@ -3232,12 +3280,16 @@ void Fl_Widget_Type::write_properties(Fd_Project_Writer &f) { f.write_word(tooltip()); } if (image_name() && *image_name()) { + if (scale_image_w_ || scale_image_h_) + f.write_string("scale_image {%d %d}", scale_image_w_, scale_image_h_); f.write_string("image"); f.write_word(image_name()); f.write_string("compress_image %d", compress_image_); } if (bind_image_) f.write_string("bind_image 1"); if (inactive_name() && *inactive_name()) { + if (scale_deimage_w_ || scale_deimage_h_) + f.write_string("scale_deimage {%d %d}", scale_deimage_w_, scale_deimage_h_); f.write_string("deimage"); f.write_word(inactive_name()); f.write_string("compress_deimage %d", compress_deimage_); @@ -3361,6 +3413,11 @@ void Fl_Widget_Type::read_property(Fd_Project_Reader &f, const char *c) { } } else if (!strcmp(c,"tooltip")) { tooltip(f.read_word()); + } else if (!strcmp(c,"scale_image")) { + if (sscanf(f.read_word(),"%d %d",&w,&h) == 2) { + scale_image_w_ = w; + scale_image_h_ = h; + } } else if (!strcmp(c,"image")) { image_name(f.read_word()); // starting in 2023, `image` is always followed by `compress_image` @@ -3374,6 +3431,11 @@ void Fl_Widget_Type::read_property(Fd_Project_Reader &f, const char *c) { bind_image_ = (int)atol(f.read_word()); } else if (!strcmp(c,"compress_image")) { compress_image_ = (int)atol(f.read_word()); + } else if (!strcmp(c,"scale_deimage")) { + if (sscanf(f.read_word(),"%d %d",&w,&h) == 2) { + scale_deimage_w_ = w; + scale_deimage_h_ = h; + } } else if (!strcmp(c,"deimage")) { inactive_name(f.read_word()); // starting in 2023, `deimage` is always followed by `compress_deimage` diff --git a/fluid/Fl_Widget_Type.h b/fluid/Fl_Widget_Type.h index 1c68de428..bcbafe4a1 100644 --- a/fluid/Fl_Widget_Type.h +++ b/fluid/Fl_Widget_Type.h @@ -76,6 +76,8 @@ public: int compress_image_; int bind_deimage_; int compress_deimage_; + int scale_image_w_, scale_image_h_; + int scale_deimage_w_, scale_deimage_h_; Fluid_Image *image; void setimage(Fluid_Image *); diff --git a/fluid/README_fl.txt b/fluid/README_fl.txt index 1a824b1e2..12480b039 100644 --- a/fluid/README_fl.txt +++ b/fluid/README_fl.txt @@ -439,9 +439,11 @@ Type "Fl_Widget" <word> : C++ variable name none or "private" or "protected" : default is public "xywh" <word> : "{%d %d %d %d}" x, y, w, h "tooltip" <word> : tooltip text + "scale_image <word>: "{%d %d}" width, height, default is 0, 0 "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) + "scale_deimage <word>: "{%d %d}" width, height, default is 0, 0 "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) diff --git a/fluid/alignment_panel.cxx b/fluid/alignment_panel.cxx index 96d21c994..1b97f08fc 100644 --- a/fluid/alignment_panel.cxx +++ b/fluid/alignment_panel.cxx @@ -2207,6 +2207,7 @@ Fl_Double_Window* make_settings_window() { w_settings_tabs->callback((Fl_Callback*)cb_w_settings_tabs); { Fl_Group* o = new Fl_Group(10, 60, 320, 480, "General"); o->image( image_general_64() ); + o->image()->scale(36, 24, 0, 1); o->labelsize(11); { Fl_Group* o = new Fl_Group(120, 78, 130, 25); o->callback((Fl_Callback*)cb_); @@ -2347,12 +2348,12 @@ th a dim outline in the editing window only"); o->hide(); Fl_Group::current()->resizable(o); } // Fl_Box* o - o->image()->scale(36, 24); o->end(); Fl_Group::current()->resizable(o); } // Fl_Group* o - { Fl_Group* o = w_settings_project_tab = new Fl_Group(10, 60, 320, 480, "Project"); + { w_settings_project_tab = new Fl_Group(10, 60, 320, 480, "Project"); w_settings_project_tab->image( image_document_64() ); + w_settings_project_tab->image()->scale(36, 24, 0, 1); w_settings_project_tab->labelsize(11); w_settings_project_tab->callback((Fl_Callback*)cb_w_settings_project_tab); w_settings_project_tab->hide(); @@ -2438,11 +2439,11 @@ itional data in code and project files."); o->hide(); Fl_Group::current()->resizable(o); } // Fl_Box* o - o->image()->scale(36, 24); w_settings_project_tab->end(); } // Fl_Group* w_settings_project_tab - { Fl_Group* o = w_settings_layout_tab = new Fl_Group(10, 60, 320, 480, "Layout"); + { w_settings_layout_tab = new Fl_Group(10, 60, 320, 480, "Layout"); w_settings_layout_tab->image( image_layout_64() ); + w_settings_layout_tab->image()->scale(36, 24, 0, 1); w_settings_layout_tab->labelsize(11); w_settings_layout_tab->callback((Fl_Callback*)cb_w_settings_layout_tab); w_settings_layout_tab->hide(); @@ -2762,11 +2763,11 @@ itional data in code and project files."); o->hide(); Fl_Group::current()->resizable(o); } // Fl_Box* o - o->image()->scale(36, 24); w_settings_layout_tab->end(); } // Fl_Group* w_settings_layout_tab - { Fl_Group* o = w_settings_shell_tab = new Fl_Group(10, 60, 320, 480, "Shell"); + { w_settings_shell_tab = new Fl_Group(10, 60, 320, 480, "Shell"); w_settings_shell_tab->image( image_shell_64() ); + w_settings_shell_tab->image()->scale(36, 24, 0, 1); w_settings_shell_tab->labelsize(11); w_settings_shell_tab->callback((Fl_Callback*)propagate_load); w_settings_shell_tab->hide(); @@ -2981,11 +2982,11 @@ le"); w_settings_shell_fd_user->deactivate(); o->image()->scale(16, 16); } // Fl_Box* w_settings_shell_fd_user - o->image()->scale(36, 24); w_settings_shell_tab->end(); } // Fl_Group* w_settings_shell_tab - { Fl_Group* o = w_settings_i18n_tab = new Fl_Group(10, 60, 320, 480, "Locale"); + { w_settings_i18n_tab = new Fl_Group(10, 60, 320, 480, "Locale"); w_settings_i18n_tab->image( image_language_64() ); + w_settings_i18n_tab->image()->scale(36, 24, 0, 1); w_settings_i18n_tab->labelsize(11); w_settings_i18n_tab->callback((Fl_Callback*)cb_w_settings_i18n_tab); w_settings_i18n_tab->hide(); @@ -3096,7 +3097,6 @@ le FLTK_GETTEXT_FOUND"); o->hide(); Fl_Group::current()->resizable(o); } // Fl_Box* o - o->image()->scale(36, 24); w_settings_i18n_tab->end(); } // Fl_Group* w_settings_i18n_tab w_settings_tabs->end(); diff --git a/fluid/alignment_panel.fl b/fluid/alignment_panel.fl index 9ce4439a6..aee3fa3fc 100644 --- a/fluid/alignment_panel.fl +++ b/fluid/alignment_panel.fl @@ -157,8 +157,7 @@ Function {make_settings_window()} {open } { Fl_Group {} { label General open selected - image {icons/general_64.png} compress_image 1 xywh {10 60 320 480} labelsize 11 resizable - code0 {o->image()->scale(36, 24);} + scale_image {36 24} image {icons/general_64.png} compress_image 1 xywh {10 60 320 480} labelsize 11 resizable } { Fl_Group {} { callback {propagate_load(o, v);} open @@ -293,8 +292,7 @@ Examples: Fl_Group w_settings_project_tab { label Project callback {propagate_load(o, v);} open - image {icons/document_64.png} compress_image 1 xywh {10 60 320 480} labelsize 11 hide - code0 {o->image()->scale(36, 24);} + scale_image {36 24} image {icons/document_64.png} compress_image 1 xywh {10 60 320 480} labelsize 11 hide } { Fl_Group {} {open xywh {100 78 220 30} @@ -410,8 +408,7 @@ or just ".ext" to set extension.} Fl_Group w_settings_layout_tab { label Layout callback {propagate_load(o, v);} open - image {icons/layout_64.png} compress_image 1 xywh {10 60 320 480} labelsize 11 hide - code0 {o->image()->scale(36, 24);} + scale_image {36 24} image {icons/layout_64.png} compress_image 1 xywh {10 60 320 480} labelsize 11 hide } { Fl_Box {} { label {Layout:} @@ -856,8 +853,7 @@ g_layout_list.update_dialogs();} Fl_Group w_settings_shell_tab { label Shell callback propagate_load open - image {icons/shell_64.png} compress_image 1 xywh {10 60 320 480} labelsize 11 hide - code0 {o->image()->scale(36, 24);} + scale_image {36 24} image {icons/shell_64.png} compress_image 1 xywh {10 60 320 480} labelsize 11 hide } { Fl_Group {} { callback propagate_load open @@ -1483,8 +1479,7 @@ if (v == LOAD) { Fl_Group w_settings_i18n_tab { label Locale callback {propagate_load(o, v);} open - image {icons/language_64.png} compress_image 1 xywh {10 60 320 480} labelsize 11 hide - code0 {o->image()->scale(36, 24);} + scale_image {36 24} image {icons/language_64.png} compress_image 1 xywh {10 60 320 480} labelsize 11 hide } { Fl_Group {} { callback propagate_load open diff --git a/fluid/widget_panel.cxx b/fluid/widget_panel.cxx index 24d3d91ae..967e6b13f 100644 --- a/fluid/widget_panel.cxx +++ b/fluid/widget_panel.cxx @@ -23,12 +23,406 @@ #include <FL/Fl_Grid.H> extern void set_modflag(int mf, int mfc=-1); +Fl_Double_Window *image_panel_window=(Fl_Double_Window *)0; + +static void cb_image_panel_window(Fl_Double_Window* o, void* v) { + propagate_load(o, v); +} + +Fl_Group *image_panel_imagegroup=(Fl_Group *)0; + +Fl_Box *image_panel_data=(Fl_Box *)0; + +static void cb_image_panel_data(Fl_Box* o, void* v) { + if (v == LOAD) { + Fl_Shared_Image *img = Fl_Shared_Image::get(widget_image_input->value()); + o->user_data(img); + if (img) { + char buf[256]; + snprintf(buf, 255, "%d x %d pixels, %d channels", img->data_w(), img->data_h(), img->d()); + o->copy_label(buf); + image_panel_imagegroup->activate(); + } else if (widget_image_input->value() && widget_image_input->value()[0]) { + o->label("Can't load image"); + image_panel_imagegroup->activate(); + } else { + o->label("... x ... pixels, ..."); + image_panel_imagegroup->deactivate(); + } + } +} + +Fluid_Coord_Input *image_panel_imagew=(Fluid_Coord_Input *)0; + +static void cb_image_panel_imagew(Fluid_Coord_Input* o, void* v) { + if (v == LOAD) { + if (current_widget->is_widget() && !current_widget->is_a(ID_Window)) { + o->value(current_widget->scale_image_w_); + } + } else { + int mod = 0; + for (Fl_Type *t = Fl_Type::first; t; t = t->next) { + if (t->selected && t->is_widget()) { + Fl_Widget_Type* wt = ((Fl_Widget_Type*)t); + wt->scale_image_w_ = o->value(); + Fl_Image *img = wt->o->image(); + if (img) { + int iw = wt->scale_image_w_; + if (iw<=0) iw = img->data_w(); + int ih = wt->scale_image_h_; + if (ih<=0) ih = img->data_w(); + img->scale(iw, ih, 0, 1); + wt->o->redraw(); + if (wt->o->parent()) wt->o->parent()->redraw(); + } + mod = 1; + } + } + if (mod) set_modflag(1); + } +} + +Fluid_Coord_Input *image_panel_imageh=(Fluid_Coord_Input *)0; + +static void cb_image_panel_imageh(Fluid_Coord_Input* o, void* v) { + if (v == LOAD) { + if (current_widget->is_widget() && !current_widget->is_a(ID_Window)) { + o->value(current_widget->scale_image_h_); + } + } else { + int mod = 0; + for (Fl_Type *t = Fl_Type::first; t; t = t->next) { + if (t->selected && t->is_widget()) { + Fl_Widget_Type* wt = ((Fl_Widget_Type*)t); + wt->scale_image_h_ = o->value(); + Fl_Image *img = wt->o->image(); + if (img) { + int iw = wt->scale_image_w_; + if (iw<=0) iw = img->data_w(); + int ih = wt->scale_image_h_; + if (ih<=0) ih = img->data_w(); + img->scale(iw, ih, 0, 1); + wt->o->redraw(); + if (wt->o->parent()) wt->o->parent()->redraw(); + } + mod = 1; + } + } + if (mod) set_modflag(1); + } +} + +static void cb_Reset(Fl_Button*, void* v) { + if (v != LOAD) { + image_panel_imagew->value(0); + image_panel_imageh->value(0); + image_panel_imagew->do_callback(); + image_panel_imageh->do_callback(); + } +} + +Fl_Group *image_panel_deimagegroup=(Fl_Group *)0; + +Fl_Box *image_panel_dedata=(Fl_Box *)0; + +static void cb_image_panel_dedata(Fl_Box* o, void* v) { + if (v == LOAD) { + Fl_Shared_Image *img = Fl_Shared_Image::get(widget_deimage_input->value()); + o->user_data(img); + if (img) { + char buf[256]; + snprintf(buf, 255, "%d x %d pixels, %d channels", img->data_w(), img->data_h(), img->d()); + o->copy_label(buf); + image_panel_deimagegroup->activate(); + } else if (widget_deimage_input->value() && widget_deimage_input->value()[0]) { + o->label("Can't load image"); + image_panel_deimagegroup->activate(); + } else { + o->label("... x ... pixels, ..."); + image_panel_deimagegroup->deactivate(); + } + } +} + +Fluid_Coord_Input *image_panel_deimagew=(Fluid_Coord_Input *)0; + +static void cb_image_panel_deimagew(Fluid_Coord_Input* o, void* v) { + if (v == LOAD) { + if (current_widget->is_widget() && !current_widget->is_a(ID_Window)) { + o->value(current_widget->scale_deimage_w_); + } + } else { + int mod = 0; + for (Fl_Type *t = Fl_Type::first; t; t = t->next) { + if (t->selected && t->is_widget()) { + Fl_Widget_Type* wt = ((Fl_Widget_Type*)t); + wt->scale_deimage_w_ = o->value(); + Fl_Image *img = wt->o->deimage(); + if (img) { + int iw = wt->scale_deimage_w_; + if (iw<=0) iw = img->data_w(); + int ih = wt->scale_deimage_h_; + if (ih<=0) ih = img->data_w(); + img->scale(iw, ih, 0, 1); + wt->o->redraw(); + if (wt->o->parent()) wt->o->parent()->redraw(); + } + mod = 1; + } + } + if (mod) set_modflag(1); + } +} + +Fluid_Coord_Input *image_panel_deimageh=(Fluid_Coord_Input *)0; + +static void cb_image_panel_deimageh(Fluid_Coord_Input* o, void* v) { + if (v == LOAD) { + if (current_widget->is_widget() && !current_widget->is_a(ID_Window)) { + o->value(current_widget->scale_deimage_h_); + } + } else { + int mod = 0; + for (Fl_Type *t = Fl_Type::first; t; t = t->next) { + if (t->selected && t->is_widget()) { + Fl_Widget_Type* wt = ((Fl_Widget_Type*)t); + wt->scale_deimage_h_ = o->value(); + Fl_Image *img = wt->o->deimage(); + if (img) { + int iw = wt->scale_deimage_w_; + if (iw<=0) iw = img->data_w(); + int ih = wt->scale_deimage_h_; + if (ih<=0) ih = img->data_w(); + img->scale(iw, ih, 0, 1); + wt->o->redraw(); + if (wt->o->parent()) wt->o->parent()->redraw(); + } + mod = 1; + } + } + if (mod) set_modflag(1); + } +} + +static void cb_Reset1(Fl_Button*, void* v) { + if (v != LOAD) { + image_panel_deimagew->value(0); + image_panel_deimageh->value(0); + image_panel_deimagew->do_callback(); + image_panel_deimageh->do_callback(); + } +} + +Fl_Button *image_panel_close=(Fl_Button *)0; + +static void cb_image_panel_close(Fl_Button*, void* v) { + if (v != LOAD) + image_panel_window->hide(); +} + +/** + Create a panel for editing widget image data +*/ +Fl_Double_Window* make_image_panel() { + { image_panel_window = new Fl_Double_Window(260, 332, "Image Options"); + image_panel_window->callback((Fl_Callback*)cb_image_panel_window); + { image_panel_imagegroup = new Fl_Group(10, 15, 235, 125); + image_panel_imagegroup->callback((Fl_Callback*)propagate_load); + { Fl_Box* o = new Fl_Box(75, 15, 170, 20, " ---- Active Image ----"); + o->labelfont(1); + o->labelsize(11); + o->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); + } // Fl_Box* o + { image_panel_data = new Fl_Box(75, 35, 170, 20, "... x ... pixels, ..."); + image_panel_data->labelsize(11); + image_panel_data->callback((Fl_Callback*)cb_image_panel_data); + image_panel_data->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); + } // Fl_Box* image_panel_data + { Fl_Group* o = new Fl_Group(75, 75, 170, 20); + o->callback((Fl_Callback*)propagate_load); + { image_panel_imagew = new Fluid_Coord_Input(75, 75, 55, 20, "Width:"); + image_panel_imagew->tooltip("Scale image to this width in pixel units"); + image_panel_imagew->box(FL_DOWN_BOX); + image_panel_imagew->color(FL_BACKGROUND2_COLOR); + image_panel_imagew->selection_color(FL_SELECTION_COLOR); + image_panel_imagew->labeltype(FL_NORMAL_LABEL); + image_panel_imagew->labelfont(0); + image_panel_imagew->labelsize(11); + image_panel_imagew->labelcolor(FL_FOREGROUND_COLOR); + image_panel_imagew->textsize(11); + image_panel_imagew->callback((Fl_Callback*)cb_image_panel_imagew); + image_panel_imagew->align(Fl_Align(FL_ALIGN_TOP_LEFT)); + image_panel_imagew->when(FL_WHEN_RELEASE); + } // Fluid_Coord_Input* image_panel_imagew + { image_panel_imageh = new Fluid_Coord_Input(135, 75, 55, 20, "Height:"); + image_panel_imageh->tooltip("Scale image to this height in pixel units"); + image_panel_imageh->box(FL_DOWN_BOX); + image_panel_imageh->color(FL_BACKGROUND2_COLOR); + image_panel_imageh->selection_color(FL_SELECTION_COLOR); + image_panel_imageh->labeltype(FL_NORMAL_LABEL); + image_panel_imageh->labelfont(0); + image_panel_imageh->labelsize(11); + image_panel_imageh->labelcolor(FL_FOREGROUND_COLOR); + image_panel_imageh->textsize(11); + image_panel_imageh->callback((Fl_Callback*)cb_image_panel_imageh); + image_panel_imageh->align(Fl_Align(FL_ALIGN_TOP_LEFT)); + image_panel_imageh->when(FL_WHEN_RELEASE); + } // Fluid_Coord_Input* image_panel_imageh + { Fl_Button* o = new Fl_Button(195, 75, 50, 20, "Reset"); + o->tooltip("Reset scale to original size"); + o->labelsize(11); + o->callback((Fl_Callback*)cb_Reset); + } // Fl_Button* o + o->end(); + } // Fl_Group* o + { Fl_Box* o = new Fl_Box(10, 75, 60, 20, "Scale:"); + o->labelfont(1); + o->labelsize(11); + o->align(Fl_Align(FL_ALIGN_RIGHT|FL_ALIGN_INSIDE)); + } // Fl_Box* o + { Fl_Box* o = new Fl_Box(10, 100, 60, 20, "Storage:"); + o->labelfont(1); + o->labelsize(11); + o->align(Fl_Align(FL_ALIGN_RIGHT|FL_ALIGN_INSIDE)); + } // Fl_Box* o + { Fl_Check_Button* o = new Fl_Check_Button(75, 100, 170, 20, "compressed"); + o->tooltip("store image uncompressed as RGBA data\nor compressed in the original file for\ +mat"); + o->down_box(FL_DOWN_BOX); + o->labelsize(11); + o->callback((Fl_Callback*)compress_image_cb); + } // Fl_Check_Button* o + { Fl_Check_Button* o = new Fl_Check_Button(75, 120, 170, 20, "bind to widget"); + o->tooltip("bind the image to the widget, so it will be deleted automatically"); + o->down_box(FL_DOWN_BOX); + o->labelsize(11); + o->callback((Fl_Callback*)bind_image_cb); + o->window()->hotspot(o); + } // Fl_Check_Button* o + image_panel_imagegroup->end(); + } // Fl_Group* image_panel_imagegroup + { image_panel_deimagegroup = new Fl_Group(10, 155, 235, 125); + image_panel_deimagegroup->callback((Fl_Callback*)propagate_load); + { Fl_Box* o = new Fl_Box(75, 155, 170, 20, " ---- Inactive Image ----"); + o->labelfont(1); + o->labelsize(11); + o->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); + } // Fl_Box* o + { image_panel_dedata = new Fl_Box(75, 175, 170, 20, "... x ... pixels, ..."); + image_panel_dedata->labelsize(11); + image_panel_dedata->callback((Fl_Callback*)cb_image_panel_dedata); + image_panel_dedata->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); + } // Fl_Box* image_panel_dedata + { Fl_Group* o = new Fl_Group(75, 215, 170, 20); + o->callback((Fl_Callback*)propagate_load); + { image_panel_deimagew = new Fluid_Coord_Input(75, 215, 55, 20, "Width:"); + image_panel_deimagew->tooltip("Scale image to this width in pixel units"); + image_panel_deimagew->box(FL_DOWN_BOX); + image_panel_deimagew->color(FL_BACKGROUND2_COLOR); + image_panel_deimagew->selection_color(FL_SELECTION_COLOR); + image_panel_deimagew->labeltype(FL_NORMAL_LABEL); + image_panel_deimagew->labelfont(0); + image_panel_deimagew->labelsize(11); + image_panel_deimagew->labelcolor(FL_FOREGROUND_COLOR); + image_panel_deimagew->textsize(11); + image_panel_deimagew->callback((Fl_Callback*)cb_image_panel_deimagew); + image_panel_deimagew->align(Fl_Align(FL_ALIGN_TOP_LEFT)); + image_panel_deimagew->when(FL_WHEN_RELEASE); + } // Fluid_Coord_Input* image_panel_deimagew + { image_panel_deimageh = new Fluid_Coord_Input(135, 215, 55, 20, "Height:"); + image_panel_deimageh->tooltip("Scale image to this height in pixel units"); + image_panel_deimageh->box(FL_DOWN_BOX); + image_panel_deimageh->color(FL_BACKGROUND2_COLOR); + image_panel_deimageh->selection_color(FL_SELECTION_COLOR); + image_panel_deimageh->labeltype(FL_NORMAL_LABEL); + image_panel_deimageh->labelfont(0); + image_panel_deimageh->labelsize(11); + image_panel_deimageh->labelcolor(FL_FOREGROUND_COLOR); + image_panel_deimageh->textsize(11); + image_panel_deimageh->callback((Fl_Callback*)cb_image_panel_deimageh); + image_panel_deimageh->align(Fl_Align(FL_ALIGN_TOP_LEFT)); + image_panel_deimageh->when(FL_WHEN_RELEASE); + } // Fluid_Coord_Input* image_panel_deimageh + { Fl_Button* o = new Fl_Button(195, 215, 50, 20, "Reset"); + o->tooltip("Reset scale to original size"); + o->labelsize(11); + o->callback((Fl_Callback*)cb_Reset1); + } // Fl_Button* o + o->end(); + } // Fl_Group* o + { Fl_Box* o = new Fl_Box(10, 215, 60, 20, "Scale:"); + o->labelfont(1); + o->labelsize(11); + o->align(Fl_Align(FL_ALIGN_RIGHT|FL_ALIGN_INSIDE)); + } // Fl_Box* o + { Fl_Box* o = new Fl_Box(10, 240, 60, 20, "Storage:"); + o->labelfont(1); + o->labelsize(11); + o->align(Fl_Align(FL_ALIGN_RIGHT|FL_ALIGN_INSIDE)); + } // Fl_Box* o + { Fl_Check_Button* o = new Fl_Check_Button(75, 240, 170, 20, "compressed"); + o->tooltip("store image uncompressed as RGBA data\nor compressed in the original file for\ +mat"); + o->down_box(FL_DOWN_BOX); + o->labelsize(11); + o->callback((Fl_Callback*)compress_deimage_cb); + } // Fl_Check_Button* o + { Fl_Check_Button* o = new Fl_Check_Button(75, 260, 170, 20, "bind to widget"); + o->tooltip("bind the image to the widget, so it will be deleted automatically"); + o->down_box(FL_DOWN_BOX); + o->labelsize(11); + o->callback((Fl_Callback*)bind_deimage_cb); + } // Fl_Check_Button* o + image_panel_deimagegroup->end(); + } // Fl_Group* image_panel_deimagegroup + { image_panel_close = new Fl_Button(165, 295, 80, 20, "Close"); + image_panel_close->labelsize(11); + image_panel_close->callback((Fl_Callback*)cb_image_panel_close); + } // Fl_Button* image_panel_close + image_panel_window->set_modal(); + image_panel_window->end(); + } // Fl_Double_Window* image_panel_window + return image_panel_window; +} + +void run_image_panel() { + if (!image_panel_window) + make_image_panel(); + + image_panel_window->do_callback(image_panel_window, LOAD); + + Fl::pushed(0); + Fl_Window *g = Fl::grab(); + if (g) Fl::grab(0); + image_panel_window->show(); + while (image_panel_window->shown()) + Fl::wait(); + if (g) + Fl::grab(g); + + Fl_Shared_Image *img = (Fl_Shared_Image*)image_panel_data->user_data(); + if (img) { + img->release(); + image_panel_data->user_data(NULL); + } +} + Fl_Tabs *widget_tabs=(Fl_Tabs *)0; static void cb_widget_tabs(Fl_Tabs* o, void* v) { propagate_load((Fl_Group *)o,v); } +Fl_Input *widget_image_input=(Fl_Input *)0; + +static void cb_(Fl_Button*, void* v) { + if (v != LOAD) { + run_image_panel(); + } +} + +Fl_Input *widget_deimage_input=(Fl_Input *)0; + Fl_Menu_Item menu_[] = { {" Image Alignment ", 0, 0, (void*)((fl_intptr_t)0xFFFFFFFF), 1, (uchar)FL_NORMAL_LABEL, 2, 11, 0}, {"image over text", 0, 0, (void*)((fl_intptr_t)FL_ALIGN_IMAGE_OVER_TEXT), 0, (uchar)FL_NORMAL_LABEL, 0, 11, 0}, @@ -100,7 +494,7 @@ Fl_Menu_Item menu_3[] = { Fl_Input *v_input[4]={(Fl_Input *)0}; -static void cb_(Fl_Tile*, void* v) { +static void cb_1(Fl_Tile*, void* v) { wComment->do_callback(wComment, v); wCallback->do_callback(wCallback, v); } @@ -193,14 +587,14 @@ static void cb_widget_grid_rows(Fluid_Coord_Input* o, void* v) { } } -static void cb_1(Fl_Button*, void* v) { +static void cb_2(Fl_Button*, void* v) { if (v != LOAD) { widget_grid_rows->value( widget_grid_rows->value()-1 ); widget_grid_rows->do_callback(); } } -static void cb_2(Fl_Button*, void* v) { +static void cb_3(Fl_Button*, void* v) { if (v != LOAD) { widget_grid_rows->value( widget_grid_rows->value()+1 ); widget_grid_rows->do_callback(); @@ -235,14 +629,14 @@ static void cb_widget_grid_cols(Fluid_Coord_Input* o, void* v) { } } -static void cb_3(Fl_Button*, void* v) { +static void cb_4(Fl_Button*, void* v) { if (v != LOAD) { widget_grid_cols->value( widget_grid_cols->value()-1 ); widget_grid_cols->do_callback(); } } -static void cb_4(Fl_Button*, void* v) { +static void cb_5(Fl_Button*, void* v) { if (v != LOAD) { widget_grid_cols->value( widget_grid_cols->value()+1 ); widget_grid_cols->do_callback(); @@ -390,14 +784,14 @@ static void cb_widget_grid_curr_row(Fluid_Coord_Input* o, void* v) { } } -static void cb_5(Fl_Button*, void* v) { +static void cb_6(Fl_Button*, void* v) { if (v != LOAD) { widget_grid_curr_row->value( widget_grid_curr_row->value()-1 ); widget_grid_curr_row->do_callback(); } } -static void cb_6(Fl_Button*, void* v) { +static void cb_7(Fl_Button*, void* v) { if (v != LOAD) { widget_grid_curr_row->value( widget_grid_curr_row->value()+1 ); widget_grid_curr_row->do_callback(); @@ -476,14 +870,14 @@ static void cb_widget_grid_curr_col(Fluid_Coord_Input* o, void* v) { } } -static void cb_7(Fl_Button*, void* v) { +static void cb_8(Fl_Button*, void* v) { if (v != LOAD) { widget_grid_curr_col->value( widget_grid_curr_col->value()-1 ); widget_grid_curr_col->do_callback(); } } -static void cb_8(Fl_Button*, void* v) { +static void cb_9(Fl_Button*, void* v) { if (v != LOAD) { widget_grid_curr_col->value( widget_grid_curr_col->value()+1 ); widget_grid_curr_col->do_callback(); @@ -573,7 +967,6 @@ Fl_Double_Window* make_widget_panel() { o->labelsize(11); o->callback((Fl_Callback*)propagate_load); o->when(FL_WHEN_NEVER); - o->hide(); { Fl_Group* o = new Fl_Group(95, 40, 309, 20, "Label:"); o->labelfont(1); o->labelsize(11); @@ -605,31 +998,23 @@ 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, 200, 20); - o->tooltip("The active image for the widget."); - o->labelfont(1); - o->labelsize(11); - o->textsize(11); - o->callback((Fl_Callback*)image_cb); - Fl_Group::current()->resizable(o); - } // Fl_Input* o - { Fl_Button* o = new Fl_Button(295, 65, 69, 20, "Browse..."); + { widget_image_input = new Fl_Input(95, 65, 200, 20); + widget_image_input->tooltip("The active image for the widget."); + widget_image_input->labelfont(1); + widget_image_input->labelsize(11); + widget_image_input->textsize(11); + widget_image_input->callback((Fl_Callback*)image_cb); + Fl_Group::current()->resizable(widget_image_input); + } // Fl_Input* widget_image_input + { Fl_Button* o = new Fl_Button(295, 65, 89, 20, "Browse..."); o->tooltip("Click to choose the active image."); o->labelsize(11); o->callback((Fl_Callback*)image_browse_cb); + o->align(Fl_Align(256)); } // 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 - { Fl_Button* o = new Fl_Button(384, 65, 20, 20); - o->tooltip("bind the image to the widget, so it will be deleted automatically"); - o->type(1); - o->callback((Fl_Callback*)bind_image_cb); - o->image(bind_pixmap); + { Fl_Button* o = new Fl_Button(384, 65, 20, 20, "..."); + o->tooltip("more image options"); + o->callback((Fl_Callback*)cb_); } // Fl_Button* o o->end(); } // Fl_Group* o @@ -638,32 +1023,19 @@ mat"); o->labelsize(11); o->callback((Fl_Callback*)propagate_load); o->align(Fl_Align(FL_ALIGN_LEFT)); - { Fl_Input* o = new Fl_Input(95, 90, 200, 20); - o->tooltip("The inactive image for the widget."); - o->labelfont(1); - o->labelsize(11); - o->textsize(11); - o->callback((Fl_Callback*)inactive_cb); - Fl_Group::current()->resizable(o); - } // Fl_Input* o - { Fl_Button* o = new Fl_Button(295, 90, 69, 20, "Browse..."); + { widget_deimage_input = new Fl_Input(95, 90, 200, 20); + widget_deimage_input->tooltip("The inactive image for the widget."); + widget_deimage_input->labelfont(1); + widget_deimage_input->labelsize(11); + widget_deimage_input->textsize(11); + widget_deimage_input->callback((Fl_Callback*)inactive_cb); + Fl_Group::current()->resizable(widget_deimage_input); + } // Fl_Input* widget_deimage_input + { Fl_Button* o = new Fl_Button(295, 90, 89, 20, "Browse..."); o->tooltip("Click to choose the inactive image."); o->labelsize(11); o->callback((Fl_Callback*)inactive_browse_cb); } // 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 - { Fl_Button* o = new Fl_Button(384, 90, 20, 20); - o->tooltip("bind the image to the widget, so it will be deleted automatically"); - o->type(1); - o->callback((Fl_Callback*)bind_deimage_cb); - o->image(bind_pixmap); - } // Fl_Button* o o->end(); } // Fl_Group* o { Fl_Group* o = new Fl_Group(95, 115, 310, 20, "Alignment:"); @@ -1348,7 +1720,7 @@ sized to fit the container."); v_input[3]->callback((Fl_Callback*)v_input_cb, (void*)(3)); } // Fl_Input* v_input[3] { Fl_Tile* o = new Fl_Tile(95, 175, 310, 130); - o->callback((Fl_Callback*)cb_); + o->callback((Fl_Callback*)cb_1); { Fl_Group* o = new Fl_Group(95, 175, 310, 48); o->box(FL_FLAT_BOX); { wComment = new Fl_Text_Editor(95, 175, 310, 45, "Comment:"); @@ -1447,6 +1819,7 @@ access the Widget pointer and \'v\' to access the user value."); { widget_tab_grid_child = new Fl_Group(10, 30, 400, 330, "Grid Child"); widget_tab_grid_child->labelsize(11); widget_tab_grid_child->callback((Fl_Callback*)propagate_load); + widget_tab_grid_child->hide(); { Fl_Group* o = new Fl_Group(95, 60, 315, 20, "Location:"); o->box(FL_FLAT_BOX); o->labelfont(1); @@ -1525,7 +1898,7 @@ access the Widget pointer and \'v\' to access the user value."); } // Fl_Box* widget_grid_unlinked o->end(); } // Fl_Group* o - { Fl_Group* o = new Fl_Group(95, 90, 315, 30, "Align:"); + { Fl_Group* o = new Fl_Group(95, 100, 315, 20, "Align:"); o->labelfont(1); o->labelsize(11); o->callback((Fl_Callback*)propagate_load); @@ -1546,13 +1919,13 @@ access the Widget pointer and \'v\' to access the user value."); o->align(Fl_Align(FL_ALIGN_TOP_LEFT)); o->menu(menu_Vertical); } // Fl_Choice* o - { Fl_Box* o = new Fl_Box(395, 90, 1, 20); + { Fl_Box* o = new Fl_Box(395, 100, 1, 20); o->hide(); Fl_Group::current()->resizable(o); } // Fl_Box* o o->end(); } // Fl_Group* o - { Fl_Group* o = new Fl_Group(95, 125, 315, 30, "Min. Size:"); + { Fl_Group* o = new Fl_Group(95, 135, 315, 20, "Min. Size:"); o->labelfont(1); o->labelsize(11); o->callback((Fl_Callback*)propagate_load); @@ -1583,13 +1956,13 @@ access the Widget pointer and \'v\' to access the user value."); o->align(Fl_Align(FL_ALIGN_TOP_LEFT)); o->when(FL_WHEN_RELEASE); } // Fluid_Coord_Input* o - { Fl_Box* o = new Fl_Box(395, 125, 1, 20); + { Fl_Box* o = new Fl_Box(395, 135, 1, 20); o->hide(); Fl_Group::current()->resizable(o); } // Fl_Box* o o->end(); } // Fl_Group* o - { Fl_Group* o = new Fl_Group(95, 160, 315, 30, "Span:"); + { Fl_Group* o = new Fl_Group(95, 170, 315, 20, "Span:"); o->labelfont(1); o->labelsize(11); o->callback((Fl_Callback*)propagate_load); @@ -1650,7 +2023,7 @@ access the Widget pointer and \'v\' to access the user value."); } // Fl_Button* o o->end(); } // Fl_Group* o - { Fl_Box* o = new Fl_Box(395, 160, 1, 20); + { Fl_Box* o = new Fl_Box(395, 170, 1, 20); o->hide(); Fl_Group::current()->resizable(o); } // Fl_Box* o @@ -1690,13 +2063,13 @@ access the Widget pointer and \'v\' to access the user value."); { Fl_Button* o = new Fl_Button(135, 60, 15, 20, "-"); o->compact(1); o->labelsize(11); - o->callback((Fl_Callback*)cb_1); + o->callback((Fl_Callback*)cb_2); o->clear_visible_focus(); } // Fl_Button* o { Fl_Button* o = new Fl_Button(150, 60, 15, 20, "+"); o->compact(1); o->labelsize(11); - o->callback((Fl_Callback*)cb_2); + o->callback((Fl_Callback*)cb_3); o->clear_visible_focus(); } // Fl_Button* o o->end(); @@ -1719,13 +2092,13 @@ access the Widget pointer and \'v\' to access the user value."); { Fl_Button* o = new Fl_Button(215, 60, 15, 20, "-"); o->compact(1); o->labelsize(11); - o->callback((Fl_Callback*)cb_3); + o->callback((Fl_Callback*)cb_4); o->clear_visible_focus(); } // Fl_Button* o { Fl_Button* o = new Fl_Button(230, 60, 15, 20, "+"); o->compact(1); o->labelsize(11); - o->callback((Fl_Callback*)cb_4); + o->callback((Fl_Callback*)cb_5); o->clear_visible_focus(); } // Fl_Button* o o->end(); @@ -1832,13 +2205,13 @@ access the Widget pointer and \'v\' to access the user value."); { Fl_Button* o = new Fl_Button(135, 175, 15, 20, "-"); o->compact(1); o->labelsize(11); - o->callback((Fl_Callback*)cb_5); + o->callback((Fl_Callback*)cb_6); o->clear_visible_focus(); } // Fl_Button* o { Fl_Button* o = new Fl_Button(150, 175, 15, 20, "+"); o->compact(1); o->labelsize(11); - o->callback((Fl_Callback*)cb_6); + o->callback((Fl_Callback*)cb_7); o->clear_visible_focus(); } // Fl_Button* o o->end(); @@ -1917,13 +2290,13 @@ access the Widget pointer and \'v\' to access the user value."); { Fl_Button* o = new Fl_Button(135, 210, 15, 20, "-"); o->compact(1); o->labelsize(11); - o->callback((Fl_Callback*)cb_7); + o->callback((Fl_Callback*)cb_8); o->clear_visible_focus(); } // Fl_Button* o { Fl_Button* o = new Fl_Button(150, 210, 15, 20, "+"); o->compact(1); o->labelsize(11); - o->callback((Fl_Callback*)cb_8); + o->callback((Fl_Callback*)cb_9); o->clear_visible_focus(); } // Fl_Button* o o->end(); diff --git a/fluid/widget_panel.fl b/fluid/widget_panel.fl index d6e90e421..e9733e4b6 100644 --- a/fluid/widget_panel.fl +++ b/fluid/widget_panel.fl @@ -43,12 +43,299 @@ decl {\#include "custom_widgets.h"} {public global decl {extern void set_modflag(int mf, int mfc=-1);} {private local } +Function {make_image_panel()} { + comment {Create a panel for editing widget image data} open +} { + Fl_Window image_panel_window { + label {Image Options} + callback {propagate_load(o, v);} open + xywh {527 684 260 332} type Double modal visible + } { + Fl_Group image_panel_imagegroup { + callback propagate_load open + xywh {10 15 235 125} + } { + Fl_Box {} { + label { ---- Active Image ----} + xywh {75 15 170 20} labelfont 1 labelsize 11 align 20 + } + Fl_Box image_panel_data { + label {... x ... pixels, ...} + callback {if (v == LOAD) { + Fl_Shared_Image *img = Fl_Shared_Image::get(widget_image_input->value()); + o->user_data(img); + if (img) { + char buf[256]; + snprintf(buf, 255, "%d x %d pixels, %d channels", img->data_w(), img->data_h(), img->d()); + o->copy_label(buf); + image_panel_imagegroup->activate(); + } else if (widget_image_input->value() && widget_image_input->value()[0]) { + o->label("Can't load image"); + image_panel_imagegroup->activate(); + } else { + o->label("... x ... pixels, ..."); + image_panel_imagegroup->deactivate(); + } +}} + xywh {75 35 170 20} labelsize 11 align 20 + code0 {\#include <FL/Fl_Shared_Image.H>} + } + Fl_Group {} { + callback propagate_load open + xywh {75 75 170 20} + } { + Fl_Input image_panel_imagew { + label {Width:} + callback {if (v == LOAD) { + if (current_widget->is_widget() && !current_widget->is_a(ID_Window)) { + o->value(current_widget->scale_image_w_); + } + } else { + int mod = 0; + for (Fl_Type *t = Fl_Type::first; t; t = t->next) { + if (t->selected && t->is_widget()) { + Fl_Widget_Type* wt = ((Fl_Widget_Type*)t); + wt->scale_image_w_ = o->value(); + Fl_Image *img = wt->o->image(); + if (img) { + int iw = wt->scale_image_w_; + if (iw<=0) iw = img->data_w(); + int ih = wt->scale_image_h_; + if (ih<=0) ih = img->data_w(); + img->scale(iw, ih, 0, 1); + wt->o->redraw(); + if (wt->o->parent()) wt->o->parent()->redraw(); + } + mod = 1; + } + } + if (mod) set_modflag(1); + }} + tooltip {Scale image to this width in pixel units} xywh {75 75 55 20} labelsize 11 align 5 textsize 11 + class Fluid_Coord_Input + } + Fl_Input image_panel_imageh { + label {Height:} + callback {if (v == LOAD) { + if (current_widget->is_widget() && !current_widget->is_a(ID_Window)) { + o->value(current_widget->scale_image_h_); + } + } else { + int mod = 0; + for (Fl_Type *t = Fl_Type::first; t; t = t->next) { + if (t->selected && t->is_widget()) { + Fl_Widget_Type* wt = ((Fl_Widget_Type*)t); + wt->scale_image_h_ = o->value(); + Fl_Image *img = wt->o->image(); + if (img) { + int iw = wt->scale_image_w_; + if (iw<=0) iw = img->data_w(); + int ih = wt->scale_image_h_; + if (ih<=0) ih = img->data_w(); + img->scale(iw, ih, 0, 1); + wt->o->redraw(); + if (wt->o->parent()) wt->o->parent()->redraw(); + } + mod = 1; + } + } + if (mod) set_modflag(1); + }} + tooltip {Scale image to this height in pixel units} xywh {135 75 55 20} labelsize 11 align 5 textsize 11 + class Fluid_Coord_Input + } + Fl_Button {} { + label Reset + callback {if (v != LOAD) { + image_panel_imagew->value(0); + image_panel_imageh->value(0); + image_panel_imagew->do_callback(); + image_panel_imageh->do_callback(); +}} + tooltip {Reset scale to original size} xywh {195 75 50 20} labelsize 11 + } + } + Fl_Box {} { + label {Scale:} + xywh {10 75 60 20} labelfont 1 labelsize 11 align 24 + } + Fl_Box {} { + label {Storage:} + xywh {10 100 60 20} labelfont 1 labelsize 11 align 24 + } + Fl_Check_Button {} { + label compressed + callback compress_image_cb + tooltip {store image uncompressed as RGBA data +or compressed in the original file format} xywh {75 100 170 20} down_box DOWN_BOX labelsize 11 + } + Fl_Check_Button {} { + label {bind to widget} + callback bind_image_cb + tooltip {bind the image to the widget, so it will be deleted automatically} xywh {75 120 170 20} down_box DOWN_BOX labelsize 11 hotspot + } + } + Fl_Group image_panel_deimagegroup { + callback propagate_load open + xywh {10 155 235 125} + } { + Fl_Box {} { + label { ---- Inactive Image ----} + xywh {75 155 170 20} labelfont 1 labelsize 11 align 20 + } + Fl_Box image_panel_dedata { + label {... x ... pixels, ...} + callback {if (v == LOAD) { + Fl_Shared_Image *img = Fl_Shared_Image::get(widget_deimage_input->value()); + o->user_data(img); + if (img) { + char buf[256]; + snprintf(buf, 255, "%d x %d pixels, %d channels", img->data_w(), img->data_h(), img->d()); + o->copy_label(buf); + image_panel_deimagegroup->activate(); + } else if (widget_deimage_input->value() && widget_deimage_input->value()[0]) { + o->label("Can't load image"); + image_panel_deimagegroup->activate(); + } else { + o->label("... x ... pixels, ..."); + image_panel_deimagegroup->deactivate(); + } +}} + xywh {75 175 170 20} labelsize 11 align 20 + } + Fl_Group {} { + callback propagate_load open + xywh {75 215 170 20} + } { + Fl_Input image_panel_deimagew { + label {Width:} + callback {if (v == LOAD) { + if (current_widget->is_widget() && !current_widget->is_a(ID_Window)) { + o->value(current_widget->scale_deimage_w_); + } + } else { + int mod = 0; + for (Fl_Type *t = Fl_Type::first; t; t = t->next) { + if (t->selected && t->is_widget()) { + Fl_Widget_Type* wt = ((Fl_Widget_Type*)t); + wt->scale_deimage_w_ = o->value(); + Fl_Image *img = wt->o->deimage(); + if (img) { + int iw = wt->scale_deimage_w_; + if (iw<=0) iw = img->data_w(); + int ih = wt->scale_deimage_h_; + if (ih<=0) ih = img->data_w(); + img->scale(iw, ih, 0, 1); + wt->o->redraw(); + if (wt->o->parent()) wt->o->parent()->redraw(); + } + mod = 1; + } + } + if (mod) set_modflag(1); + }} + tooltip {Scale image to this width in pixel units} xywh {75 215 55 20} labelsize 11 align 5 textsize 11 + class Fluid_Coord_Input + } + Fl_Input image_panel_deimageh { + label {Height:} + callback {if (v == LOAD) { + if (current_widget->is_widget() && !current_widget->is_a(ID_Window)) { + o->value(current_widget->scale_deimage_h_); + } + } else { + int mod = 0; + for (Fl_Type *t = Fl_Type::first; t; t = t->next) { + if (t->selected && t->is_widget()) { + Fl_Widget_Type* wt = ((Fl_Widget_Type*)t); + wt->scale_deimage_h_ = o->value(); + Fl_Image *img = wt->o->deimage(); + if (img) { + int iw = wt->scale_deimage_w_; + if (iw<=0) iw = img->data_w(); + int ih = wt->scale_deimage_h_; + if (ih<=0) ih = img->data_w(); + img->scale(iw, ih, 0, 1); + wt->o->redraw(); + if (wt->o->parent()) wt->o->parent()->redraw(); + } + mod = 1; + } + } + if (mod) set_modflag(1); + }} + tooltip {Scale image to this height in pixel units} xywh {135 215 55 20} labelsize 11 align 5 textsize 11 + class Fluid_Coord_Input + } + Fl_Button {} { + label Reset + callback {if (v != LOAD) { + image_panel_deimagew->value(0); + image_panel_deimageh->value(0); + image_panel_deimagew->do_callback(); + image_panel_deimageh->do_callback(); +}} + tooltip {Reset scale to original size} xywh {195 215 50 20} labelsize 11 + } + } + Fl_Box {} { + label {Scale:} + xywh {10 215 60 20} labelfont 1 labelsize 11 align 24 + } + Fl_Box {} { + label {Storage:} + xywh {10 240 60 20} labelfont 1 labelsize 11 align 24 + } + Fl_Check_Button {} { + label compressed + callback compress_deimage_cb + tooltip {store image uncompressed as RGBA data +or compressed in the original file format} xywh {75 240 170 20} down_box DOWN_BOX labelsize 11 + } + Fl_Check_Button {} { + label {bind to widget} + callback bind_deimage_cb + tooltip {bind the image to the widget, so it will be deleted automatically} xywh {75 260 170 20} down_box DOWN_BOX labelsize 11 + } + } + Fl_Button image_panel_close { + label Close + callback {if (v != LOAD) + image_panel_window->hide();} + xywh {165 295 80 20} labelsize 11 + } + } +} + +Function {run_image_panel()} {open return_type void +} { + code {if (!image_panel_window) + make_image_panel(); + +image_panel_window->do_callback(image_panel_window, LOAD); + +Fl::pushed(0); +Fl_Window *g = Fl::grab(); +if (g) Fl::grab(0); +image_panel_window->show(); +while (image_panel_window->shown()) + Fl::wait(); +if (g) + Fl::grab(g); + +Fl_Shared_Image *img = (Fl_Shared_Image*)image_panel_data->user_data(); +if (img) { + img->release(); + image_panel_data->user_data(NULL); +}} {} +} + Function {make_widget_panel()} { comment {Create a panel that can be used with all known widgets} open } { Fl_Window {} { comment {Use a Double Window to avoid flickering.} open - xywh {430 248 420 400} type Double labelsize 11 align 80 resizable hotspot + xywh {160 297 420 400} type Double labelsize 11 align 80 resizable hotspot code0 {o->size_range(o->w(), o->h());} size_range {420 400 0 0} visible } { Fl_Tabs widget_tabs { @@ -58,8 +345,8 @@ Function {make_widget_panel()} { } { Fl_Group {} { label GUI - callback propagate_load - xywh {10 30 400 330} labelsize 11 when 0 hide resizable + callback propagate_load open + xywh {10 30 400 330} labelsize 11 when 0 resizable } { Fl_Group {} { label {Label:} @@ -83,27 +370,21 @@ Use Ctrl-J for newlines.} xywh {95 40 190 20} labelfont 1 labelsize 11 when 15 t callback propagate_load open xywh {95 65 309 20} labelfont 1 labelsize 11 align 4 } { - Fl_Input {} { + Fl_Input widget_image_input { callback image_cb 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 {295 65 69 20} labelsize 11 - } - 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"} + callback image_browse_cb selected + tooltip {Click to choose the active image.} xywh {295 65 89 20} labelsize 11 align 256 } Fl_Button {} { - 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"} + label {...} + callback {if (v != LOAD) { + run_image_panel(); +}} + tooltip {more image options} bind_image 1 xywh {384 65 20 20} } } Fl_Group {} { @@ -111,27 +392,14 @@ or compressed in the original file format} xywh {364 65 20 20} type Toggle callback propagate_load open xywh {95 90 309 20} labelfont 1 labelsize 11 align 4 } { - Fl_Input {} { + Fl_Input widget_deimage_input { callback inactive_cb 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 {295 90 69 20} labelsize 11 - } - 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_Button {} { - callback bind_deimage_cb - tooltip {bind the image to the widget, so it will be deleted automatically} xywh {384 90 20 20} type Toggle - code0 {o->image(bind_pixmap);} - code3 {\#include "pixmaps.h"} + tooltip {Click to choose the inactive image.} xywh {295 90 89 20} labelsize 11 } } Fl_Group {} { @@ -835,7 +1103,7 @@ wCallback->do_callback(wCallback, v);} open Fl_Group widget_tab_grid_child { label {Grid Child} callback propagate_load open - xywh {10 30 400 330} labelsize 11 + xywh {10 30 400 330} labelsize 11 hide } { Fl_Group {} { label {Location:} @@ -903,7 +1171,7 @@ wCallback->do_callback(wCallback, v);} open } else if (!g->cell(child)) { widget_grid_unlinked->show(); } -}} selected +}} xywh {250 60 80 20} labelsize 11 labelcolor 1 } Fl_Box widget_grid_unlinked { @@ -914,7 +1182,7 @@ wCallback->do_callback(wCallback, v);} open Fl_Group {} { label {Align:} callback propagate_load open - xywh {95 90 315 30} labelfont 1 labelsize 11 align 4 + xywh {95 100 315 20} labelfont 1 labelsize 11 align 4 } { Fl_Choice {} { label Horizontal @@ -969,13 +1237,13 @@ wCallback->do_callback(wCallback, v);} open } } Fl_Box {} { - xywh {395 90 1 20} hide resizable + xywh {395 100 1 20} hide resizable } } Fl_Group {} { label {Min. Size:} callback propagate_load open - xywh {95 125 315 30} labelfont 1 labelsize 11 align 4 + xywh {95 135 315 20} labelfont 1 labelsize 11 align 4 } { Fl_Input {} { label {Width:} @@ -990,13 +1258,13 @@ wCallback->do_callback(wCallback, v);} open class Fluid_Coord_Input } Fl_Box {} { - xywh {395 125 1 20} hide resizable + xywh {395 135 1 20} hide resizable } } Fl_Group {} { label {Span:} callback propagate_load open - xywh {95 160 315 30} labelfont 1 labelsize 11 align 4 + xywh {95 170 315 20} labelfont 1 labelsize 11 align 4 } { Fl_Input widget_grid_rowspan_input { label {Row Span:} @@ -1043,7 +1311,7 @@ wCallback->do_callback(wCallback, v);} open } } Fl_Box {} { - xywh {395 160 1 20} hide resizable + xywh {395 170 1 20} hide resizable } } Fl_Box {} { diff --git a/fluid/widget_panel.h b/fluid/widget_panel.h index 83e1f9766..013fa4abd 100644 --- a/fluid/widget_panel.h +++ b/fluid/widget_panel.h @@ -21,29 +21,44 @@ #include <FL/Fl.H> #include "custom_widgets.h" #include <FL/Fl_Double_Window.H> -#include <FL/Fl_Tabs.H> -extern Fl_Tabs *widget_tabs; +extern Fl_Double_Window *image_panel_window; #include <FL/Fl_Group.H> extern void propagate_load(Fl_Group*, void*); +extern Fl_Group *image_panel_imagegroup; +#include <FL/Fl_Box.H> +#include <FL/Fl_Shared_Image.H> +extern Fl_Box *image_panel_data; +extern Fluid_Coord_Input *image_panel_imagew; +extern Fluid_Coord_Input *image_panel_imageh; +#include <FL/Fl_Button.H> +#include <FL/Fl_Check_Button.H> +extern void compress_image_cb(Fl_Check_Button*, void*); +extern void bind_image_cb(Fl_Check_Button*, void*); +extern Fl_Group *image_panel_deimagegroup; +extern Fl_Box *image_panel_dedata; +extern Fluid_Coord_Input *image_panel_deimagew; +extern Fluid_Coord_Input *image_panel_deimageh; +extern void compress_deimage_cb(Fl_Check_Button*, void*); +extern void bind_deimage_cb(Fl_Check_Button*, void*); +extern Fl_Button *image_panel_close; +Fl_Double_Window* make_image_panel(); +void run_image_panel(); +#include <FL/Fl_Tabs.H> +extern Fl_Tabs *widget_tabs; #include <FL/Fl_Input.H> extern void label_cb(Fl_Input*, void*); #include <FL/Fl_Choice.H> extern Fl_Menu_Item labeltypemenu[]; extern void labeltype_cb(Fl_Choice*, void*); extern void image_cb(Fl_Input*, void*); -#include <FL/Fl_Button.H> +extern Fl_Input *widget_image_input; extern void image_browse_cb(Fl_Button*, void*); -#include "pixmaps.h" -extern void compress_image_cb(Fl_Button*, void*); -extern void bind_image_cb(Fl_Button*, void*); extern void inactive_cb(Fl_Input*, void*); +extern Fl_Input *widget_deimage_input; extern void inactive_browse_cb(Fl_Button*, void*); -extern void compress_deimage_cb(Fl_Button*, void*); -extern void bind_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*); -#include <FL/Fl_Box.H> extern void position_group_cb(Fl_Group*, void*); extern void x_cb(Fluid_Coord_Input*, void*); extern Fluid_Coord_Input *widget_x_input; @@ -58,7 +73,6 @@ extern void flex_size_group_cb(Fl_Group*, void*); #include <FL/Fl_Value_Input.H> extern void flex_size_cb(Fl_Value_Input*, void*); extern Fl_Value_Input *widget_flex_size; -#include <FL/Fl_Check_Button.H> extern void flex_fixed_cb(Fl_Check_Button*, void*); extern Fl_Check_Button *widget_flex_fixed; extern void values_group_cb(Fl_Group*, void*); |
