diff options
Diffstat (limited to 'fluid/panels/widget_panel.fl')
| -rw-r--r-- | fluid/panels/widget_panel.fl | 139 |
1 files changed, 79 insertions, 60 deletions
diff --git a/fluid/panels/widget_panel.fl b/fluid/panels/widget_panel.fl index 0fb788ff2..a98916654 100644 --- a/fluid/panels/widget_panel.fl +++ b/fluid/panels/widget_panel.fl @@ -84,7 +84,7 @@ decl {\#include <ctype.h>} {uid 43de private global decl {\#include <stdlib.h> // free()} {uid 053c private global } -decl {\#include <functional> // std::function} {uid 29a1 private global +decl {\#include <string.h>} {uid 29a1 private global } decl {\#define ZERO_ENTRY 1000} {uid e18b private global @@ -99,7 +99,7 @@ extern void color_common(Fl_Color c); extern void color2_common(Fl_Color c); extern void textcolor_common(Fl_Color c); extern int widget_i; -extern fld::widget::Formula_Input_Vars widget_vars[];} {uid 81c9 private global +extern Formula_Input_Vars widget_vars[];} {uid 81c9 private global } decl {extern int numselected; @@ -116,32 +116,34 @@ Function {use_tab_navigation(int, Fl_Text_Editor*)} {uid 42b9 } } -Function {update_current(Fl_Input* o, void *v, - std::function<std::string()> getter, - std::function<void(std::string)> setter)} {uid a6e0 open private return_type void +Function {update_current_input(Fl_Input* o, void *v, + const char *cur_val, void (*setter_fn)(void*, const char*), void *nd)} {uid a6e0 open private return_type void } { code {if (v == LOAD) { - o->value( getter().c_str() ); + o->value(cur_val ? cur_val : ""); } else { - std::string v = o->value(); - if (v != getter()) { - setter(v); + const char *nv = o->value(); + if (!cur_val) cur_val = ""; + if (!nv) nv = ""; + if (strcmp(nv, cur_val) != 0) { + setter_fn(nd, nv); Fluid.proj.set_modflag(1); } }} {uid e438 } } -Function {update_current(Fl_Text_Editor* o, void *v, - std::function<std::string()> getter, - std::function<void(std::string)> setter)} {uid 7c05 open private return_type void +Function {update_current_editor(Fl_Text_Editor* o, void *v, + const char *cur_val, void (*setter_fn)(void*, const char*), void *nd)} {uid 7c05 open private return_type void } { code {if (v == LOAD) { - o->buffer()->text( getter().c_str() ); + o->buffer()->text(cur_val ? cur_val : ""); } else { - std::string v = o->buffer()->text(); - if (v != getter()) { - setter(v); + const char *nv = o->buffer()->text(); + if (!cur_val) cur_val = ""; + if (!nv) nv = ""; + if (strcmp(nv, cur_val) != 0) { + setter_fn(nd, nv); Fluid.proj.set_modflag(1); } }} {uid c364 @@ -217,7 +219,7 @@ Function {make_image_panel()} {uid b832 if (mod) Fluid.proj.set_modflag(1); }} tooltip {Scale image to this width in pixel units} xywh {75 75 55 20} labelsize 11 align 5 textsize 11 - class {fld::widget::Formula_Input} + class {Formula_Input} } Fl_Input image_panel_imageh {uid e676 label {Height:} @@ -247,7 +249,7 @@ Function {make_image_panel()} {uid b832 if (mod) Fluid.proj.set_modflag(1); }} tooltip {Scale image to this height in pixel units} xywh {135 75 55 20} labelsize 11 align 5 textsize 11 - class {fld::widget::Formula_Input} + class {Formula_Input} } Fl_Button {} {uid 4df5 label Reset @@ -367,7 +369,7 @@ Function {make_image_panel()} {uid b832 if (mod) Fluid.proj.set_modflag(1); }} tooltip {Scale image to this width in pixel units} xywh {75 215 55 20} labelsize 11 align 5 textsize 11 - class {fld::widget::Formula_Input} + class {Formula_Input} } Fl_Input image_panel_deimageh {uid c6c4 label {Height:} @@ -397,7 +399,7 @@ Function {make_image_panel()} {uid b832 if (mod) Fluid.proj.set_modflag(1); }} tooltip {Scale image to this height in pixel units} xywh {135 215 55 20} labelsize 11 align 5 textsize 11 - class {fld::widget::Formula_Input} + class {Formula_Input} } Fl_Button {} {uid a381 label Reset @@ -850,7 +852,7 @@ Use Ctrl-J for newlines.} xywh {95 40 190 20} labelfont 1 labelsize 11 when 15 t tooltip {The X position of the widget as a number or formula. Formulas can be simple math, including the variables x, px, sx, cx, and i} xywh {95 150 55 20} labelsize 11 align 5 textsize 11 - class {fld::widget::Formula_Input} + class {Formula_Input} } Fl_Input widget_y_input {uid 5985 label {Y:} @@ -883,7 +885,7 @@ x, px, sx, cx, and i} xywh {95 150 55 20} labelsize 11 align 5 textsize 11 tooltip {The Y position of the widget as a number or formula. Formulas can be simple math, including the variables y, py, sy, cy, and i} xywh {155 150 55 20} labelsize 11 align 5 textsize 11 - class {fld::widget::Formula_Input} + class {Formula_Input} } Fl_Input widget_w_input {uid 2e88 label {Width:} @@ -916,7 +918,7 @@ y, py, sy, cy, and i} xywh {155 150 55 20} labelsize 11 align 5 textsize 11 tooltip {The width of the widget as a number or formula. Formulas can be simple math, including the variables w, pw, sw, cw, and i} xywh {215 150 55 20} labelsize 11 align 5 textsize 11 - class {fld::widget::Formula_Input} + class {Formula_Input} } Fl_Input widget_h_input {uid 2382 label {Height:} @@ -949,7 +951,7 @@ w, pw, sw, cw, and i} xywh {215 150 55 20} labelsize 11 align 5 textsize 11 tooltip {The height of the widget as a number or formula. Formulas can be simple math, including the variables h, ph, sh, ch, and i} xywh {275 150 55 20} labelsize 11 align 5 textsize 11 - class {fld::widget::Formula_Input} + class {Formula_Input} } Fl_Choice {} {uid 4f6a label {Children:} @@ -2495,7 +2497,7 @@ wCallback->do_callback(wCallback, v);} open }} tooltip {The callback function or code for the widget. Use the variable name 'o' to access the Widget pointer and 'v' to access the user value.} xywh {95 225 310 80} box DOWN_BOX labelfont 1 labelsize 11 align 4 textfont 4 textsize 11 resizable code0 {\#include "widgets/Code_Editor.h"} - class {fld::widget::Code_Editor} + class {Code_Editor} } } } @@ -2737,21 +2739,6 @@ if (v == LOAD) { user_data 2 user_data_type long xywh {10 10 100 20} labelsize 11 } - MenuItem {} {uid a638 - label {binary: std::vector<uint8_t>} - user_data 3 user_data_type long - xywh {10 10 100 20} labelsize 11 - } - MenuItem {} {uid c0e7 - label {text: std::string} - user_data 4 user_data_type long - xywh {10 10 100 20} labelsize 11 - } - MenuItem {} {uid 8d7a - label {compressed: std::vector<uint8_t>} - user_data 5 user_data_type long - xywh {10 10 100 20} labelsize 11 - } } Fl_Box {} {uid 4a0a xywh {363 75 42 20} resizable @@ -2781,10 +2768,18 @@ if (v == LOAD) { label {Filename:} callback {if (!current_node || !current_node->is_a(FLD_NODE_TYPE_Data)) return; Data_Node* nd = (Data_Node*)current_node; -update_current(o, v, - [nd](){return nd->filename();}, - [nd](std::string s){nd->filename(s);} -);} +if (v == LOAD) { + o->value(nd->filename() ? nd->filename() : ""); +} else { + const char *nv = o->value(); + const char *cur = nd->filename(); + if (!cur) cur = ""; + if (!nv) nv = ""; + if (strcmp(nv, cur) != 0) { + nd->filename(nv); + Fluid.proj.set_modflag(1); + } +}} tooltip {name and path of file that will be inlined} xywh {95 125 270 20} labelfont 1 labelsize 11 align 132 textfont 4 textsize 11 resizable } Fl_Button {} {uid a0fe @@ -3196,10 +3191,18 @@ if (v == LOAD) { label {End Code:} callback {if (!current_node || !current_node->is_a(FLD_NODE_TYPE_DeclBlock)) return; DeclBlock_Node* nd = (DeclBlock_Node*)current_node; -update_current(o, v, - [nd](){return nd->end_code();}, - [nd](std::string s){nd->end_code(s);} -);} +if (v == LOAD) { + o->value(nd->end_code() ? nd->end_code() : ""); +} else { + const char *nv = o->value(); + const char *cur = nd->end_code(); + if (!cur) cur = ""; + if (!nv) nv = ""; + if (strcmp(nv, cur) != 0) { + nd->end_code(nv); + Fluid.proj.set_modflag(1); + } +}} tooltip {`\#endif` or similar declaration code block} xywh {95 75 305 20} labelfont 1 labelsize 11 textfont 4 textsize 11 } Fl_Group {} {uid 9b63 @@ -3456,7 +3459,7 @@ a `\#` directive: `\#include <foo.h>`, a typedef `typedef char byte;`, or a `using` statement, etc.} xywh {95 75 310 100} labelfont 1 labelsize 11 align 132 textsize 11 resizable code0 {\#include "widgets/Code_Editor.h"} code1 {o->add_key_binding(FL_Tab, 0, use_tab_navigation);} - class {fld::widget::Code_Editor} + class {Code_Editor} } } Fl_Group {} {uid 160e @@ -3525,10 +3528,18 @@ if (v == LOAD) { label {End Code:} callback {if (!current_node || !current_node->is_a(FLD_NODE_TYPE_CodeBlock)) return; CodeBlock_Node* nd = (CodeBlock_Node*)current_node; -update_current(o, v, - [nd](){return nd->end_code();}, - [nd](std::string s){nd->end_code(s);} -);} +if (v == LOAD) { + o->value(nd->end_code() ? nd->end_code() : ""); +} else { + const char *nv = o->value(); + const char *cur = nd->end_code(); + if (!cur) cur = ""; + if (!nv) nv = ""; + if (strcmp(nv, cur) != 0) { + nd->end_code(nv); + Fluid.proj.set_modflag(1); + } +}} tooltip {condition end: `while (x==1);`, or empty} xywh {95 75 305 20} labelfont 1 labelsize 11 textfont 4 textsize 11 } Fl_Text_Editor {} {uid 13f0 @@ -3595,7 +3606,7 @@ Code_Node* nd = (Code_Node*)current_node; code1 {\#include "widgets/Code_Editor.h"} code2 {o->linenumber_width(60); o->linenumber_size(o->Fl_Text_Display::textsize());} - class {fld::widget::Code_Editor} + class {Code_Editor} } } } @@ -3743,7 +3754,7 @@ if (v == LOAD) { tooltip {function name and args, or blank for `main(..)`} xywh {95 100 310 50} labelfont 1 labelsize 11 align 132 textsize 11 resizable code0 {\#include "widgets/Code_Editor.h"} code1 {o->add_key_binding(FL_Tab, 0, use_tab_navigation);} - class {fld::widget::Code_Editor} + class {Code_Editor} } } Fl_Group {} {uid 3cb7 @@ -3754,14 +3765,22 @@ if (v == LOAD) { label {Return Type:} callback {if (!current_node || !current_node->is_a(FLD_NODE_TYPE_Function)) return; Function_Node* nd = (Function_Node*)current_node; -update_current(o, v, - [nd](){return nd->return_type();}, - [nd](std::string s){nd->return_type(s);} -);} +if (v == LOAD) { + o->buffer()->text(nd->return_type() ? nd->return_type() : ""); +} else { + const char *nv = o->buffer()->text(); + const char *cur = nd->return_type(); + if (!cur) cur = ""; + if (!nv) nv = ""; + if (strcmp(nv, cur) != 0) { + nd->return_type(nv); + Fluid.proj.set_modflag(1); + } +}} tooltip {return type, or blank to return outermost widget} xywh {95 160 310 50} labelfont 1 labelsize 11 align 132 textsize 11 resizable code0 {\#include "widgets/Code_Editor.h"} code1 {o->add_key_binding(FL_Tab, 0, use_tab_navigation);} - class {fld::widget::Code_Editor} + class {Code_Editor} } } Fl_Group {} {uid 01de |
