summaryrefslogtreecommitdiff
path: root/fluid/nodes
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2025-11-29 12:57:08 +0100
committerGitHub <noreply@github.com>2025-11-29 12:57:08 +0100
commit349b818d3fd4f568160537616857b9ff7d68d3aa (patch)
treeaa4deb3b74345abf0dd6584bd9e3139c5812e43d /fluid/nodes
parent725be0116f1d4dbcd64a99b555572341f2d29eda (diff)
Fluid: convert modal panels into tabs in the widget panel (#1339)
Diffstat (limited to 'fluid/nodes')
-rw-r--r--fluid/nodes/Function_Node.cxx786
-rw-r--r--fluid/nodes/Function_Node.h48
-rw-r--r--fluid/nodes/Group_Node.cxx26
-rw-r--r--fluid/nodes/Group_Node.h2
-rw-r--r--fluid/nodes/Node.cxx2
-rw-r--r--fluid/nodes/Widget_Node.cxx92
-rw-r--r--fluid/nodes/Widget_Node.h3
7 files changed, 271 insertions, 688 deletions
diff --git a/fluid/nodes/Function_Node.cxx b/fluid/nodes/Function_Node.cxx
index a70b10462..095b3fc5f 100644
--- a/fluid/nodes/Function_Node.cxx
+++ b/fluid/nodes/Function_Node.cxx
@@ -35,6 +35,8 @@
#include <zlib.h>
+extern void open_panel();
+
using namespace fld;
using namespace fld::io;
using namespace fld::proj;
@@ -191,9 +193,9 @@ Function_Node Function_Node::prototype;
*/
Function_Node::Function_Node() :
Node(),
- return_type(nullptr),
+ return_type_(nullptr),
public_(0),
- cdecl_(0),
+ declare_c_(0),
constructor(0),
havewidgets(0)
{ }
@@ -202,7 +204,7 @@ Function_Node::Function_Node() :
Destructor.
*/
Function_Node::~Function_Node() {
- if (return_type) free((void*)return_type);
+ if (return_type_) free((void*)return_type_);
}
/**
@@ -221,11 +223,11 @@ Node *Function_Node::make(Strategy strategy) {
}
Function_Node *o = new Function_Node();
o->name("make_window()");
- o->return_type = nullptr;
+ o->return_type_ = nullptr;
o->add(anchor, strategy);
o->factory = this;
o->public_ = 1;
- o->cdecl_ = 0;
+ o->declare_c_ = 0;
return o;
}
@@ -241,10 +243,10 @@ void Function_Node::write_properties(fld::io::Project_Writer &f) {
case 0: f.write_string("private"); break;
case 2: f.write_string("protected"); break;
}
- if (cdecl_) f.write_string("C");
- if (return_type) {
+ if (declare_c_) f.write_string("C");
+ if (return_type_) {
f.write_string("return_type");
- f.write_word(return_type);
+ f.write_word(return_type_);
}
}
@@ -258,9 +260,9 @@ void Function_Node::read_property(fld::io::Project_Reader &f, const char *c) {
} else if (!strcmp(c,"protected")) {
public_ = 2;
} else if (!strcmp(c,"C")) {
- cdecl_ = 1;
+ declare_c_ = 1;
} else if (!strcmp(c,"return_type")) {
- storestring(f.read_word(),return_type);
+ storestring(f.read_word(),return_type_);
} else {
Node::read_property(f, c);
}
@@ -270,90 +272,7 @@ void Function_Node::read_property(fld::io::Project_Reader &f, const char *c) {
Open the function_panel dialog box to edit this function.
*/
void Function_Node::open() {
- // fill dialog box
- if (!function_panel) make_function_panel();
- f_return_type_input->value(return_type);
- f_name_input->value(name());
- if (is_in_class()) {
- f_public_member_choice->value(public_);
- f_public_member_choice->show();
- f_public_choice->hide();
- f_c_button->hide();
- } else {
- f_public_choice->value(public_);
- f_public_choice->show();
- f_public_member_choice->hide();
- f_c_button->show();
- }
- f_c_button->value(cdecl_);
- const char *c = comment();
- f_comment_input->buffer()->text(c?c:"");
- function_panel->show();
- const char* message = nullptr;
- for (;;) { // repeat as long as there are errors
- // - message loop until OK or cancel is pressed
- for (;;) {
- Fl_Widget* w = Fl::readqueue();
- if (w == f_panel_cancel) goto BREAK2;
- else if (w == f_panel_ok) break;
- else if (!w) Fl::wait();
- }
- // - check syntax
- const char *c = f_name_input->value();
- while (isspace(*c)) c++;
- message = c_check(c);
- if (!message) {
- const char *d = c;
- for (; *d != '('; d++) if (isspace(*d) || !*d) break;
- if (*c && *d != '(')
- message = "must be 'name(arguments)'";
- }
- if (!message) {
- c = f_return_type_input->value();
- message = c_check(c);
- }
- // - alert user
- if (message) {
- int v = fl_choice("Potential syntax error detected: %s",
- "Continue Editing", "Ignore Error", nullptr, message);
- if (v==0) continue; // Continue Editing
- //if (v==1) { } // Ignore Error and close dialog
- }
- // - copy dialog data to target variables
- int mod = 0;
- name(f_name_input->value());
- storestring(f_return_type_input->value(), return_type);
- if (is_in_class()) {
- if (public_ != f_public_member_choice->value()) {
- mod = 1;
- public_ = f_public_member_choice->value();
- redraw_browser();
- }
- } else {
- if (public_ != f_public_choice->value()) {
- mod = 1;
- public_ = f_public_choice->value();
- redraw_browser();
- }
- }
- if (cdecl_ != f_c_button->value()) {
- mod = 1;
- cdecl_ = f_c_button->value();
- }
- c = f_comment_input->buffer()->text();
- if (c && *c) {
- if (!comment() || strcmp(c, comment())) { Fluid.proj.set_modflag(1); redraw_browser(); }
- comment(c);
- } else {
- if (comment()) { Fluid.proj.set_modflag(1); redraw_browser(); }
- comment(nullptr);
- }
- if (c) free((void*)c);
- if (mod) Fluid.proj.set_modflag(1);
- break;
- }
-BREAK2:
- function_panel->hide();
+ open_panel();
}
/**
@@ -435,7 +354,7 @@ void Function_Node::write_code1(fld::io::Code_Writer& f) {
if (havechildren)
f.write_c("int main(int argc, char **argv) {\n");
} else {
- const char* rtype = return_type;
+ const char* rtype = return_type_;
const char* star = "";
// from matt: let the user type "static " at the start of type
// in order to declare a static method;
@@ -503,7 +422,7 @@ void Function_Node::write_code1(fld::io::Code_Writer& f) {
if (havechildren)
write_comment_c(f);
if (public_==1) {
- if (cdecl_)
+ if (declare_c_)
f.write_h("extern \"C\" { %s%s %s; }\n", rtype, star, name());
else
f.write_h("%s%s %s;\n", rtype, star, name());
@@ -547,7 +466,7 @@ void Function_Node::write_code2(fld::io::Code_Writer& f) {
f.write_c("%s%s->show(argc, argv);\n", f.indent(1), var);
if (havechildren)
f.write_c("%sreturn Fl::run();\n", f.indent(1));
- } else if (havewidgets && !constructor && !return_type) {
+ } else if (havewidgets && !constructor && !return_type_) {
f.write_c("%sreturn %s;\n", f.indent(1), var);
}
if (havechildren)
@@ -562,9 +481,9 @@ void Function_Node::write_code2(fld::io::Code_Writer& f) {
\return 1 if they match, 0 if not
*/
int Function_Node::has_signature(const char *rtype, const char *sig) const {
- if (rtype && !return_type) return 0;
+ if (rtype && !return_type_) return 0;
if (!name()) return 0;
- if ( (rtype==nullptr || strcmp(return_type, rtype)==0)
+ if ( (rtype==nullptr || strcmp(return_type_, rtype)==0)
&& fl_filename_match(name(), sig)) {
return 1;
}
@@ -632,38 +551,7 @@ void Code_Node::open() {
if ( editor_.open_editor(cmd, code) == 0 )
return; // return if editor opened ok, fall thru to built-in if not
}
- // Use built-in code editor..
- if (!code_panel) make_code_panel();
- const char *text = name();
- code_input->buffer()->text( text ? text : "" );
- code_input->insert_position(cursor_position_);
- code_input->scroll(code_input_scroll_row, code_input_scroll_col);
- code_panel->show();
- const char* message = nullptr;
- for (;;) { // repeat as long as there are errors
- for (;;) {
- Fl_Widget* w = Fl::readqueue();
- if (w == code_panel_cancel) goto BREAK2;
- else if (w == code_panel_ok) break;
- else if (!w) Fl::wait();
- }
- char*c = code_input->buffer()->text();
- message = c_check(c);
- if (message) {
- int v = fl_choice("Potential syntax error detected: %s",
- "Continue Editing", "Ignore Error", nullptr, message);
- if (v==0) continue; // Continue Editing
- //if (v==1) { } // Ignore Error and close dialog
- }
- name(c);
- free(c);
- break;
- }
- cursor_position_ = code_input->insert_position();
- code_input_scroll_row = code_input->scroll_row();
- code_input_scroll_col = code_input->scroll_col();
-BREAK2:
- code_panel->hide();
+ open_panel();
}
/**
@@ -817,38 +705,7 @@ void CodeBlock_Node::read_property(fld::io::Project_Reader &f, const char *c) {
Open the codeblock_panel.
*/
void CodeBlock_Node::open() {
- if (!codeblock_panel) make_codeblock_panel();
- code_before_input->value(name());
- code_after_input->value(after);
- codeblock_panel->show();
- const char* message = nullptr;
- for (;;) { // repeat as long as there are errors
- // event loop
- for (;;) {
- Fl_Widget* w = Fl::readqueue();
- if (w == codeblock_panel_cancel) goto BREAK2;
- else if (w == codeblock_panel_ok) break;
- else if (!w) Fl::wait();
- }
- // check for syntax errors
- message = c_check(code_before_input->value());
- if (!message) {
- message = c_check(code_after_input->value());
- }
- // alert user
- if (message) {
- int v = fl_choice("Potential syntax error detected: %s",
- "Continue Editing", "Ignore Error", nullptr, message);
- if (v==0) continue; // Continue Editing
- //if (v==1) { } // Ignore Error and close dialog
- }
- // write to variables
- name(code_before_input->value());
- storestring(code_after_input->value(), after);
- break;
- }
-BREAK2:
- codeblock_panel->hide();
+ open_panel();
}
/**
@@ -969,70 +826,7 @@ void Decl_Node::read_property(fld::io::Project_Reader &f, const char *c) {
Open the decl_panel to edit this node.
*/
void Decl_Node::open() {
- if (!decl_panel) make_decl_panel();
- decl_input->buffer()->text(name());
- if (is_in_class()) {
- decl_class_choice->value(public_);
- decl_class_choice->show();
- decl_choice->hide();
- } else {
- decl_choice->value((public_&1)|((static_&1)<<1));
- decl_choice->show();
- decl_class_choice->hide();
- }
- const char *c = comment();
- decl_comment_input->buffer()->text(c?c:"");
- decl_panel->show();
- const char* message = nullptr;
- for (;;) { // repeat as long as there are errors
- // event loop
- for (;;) {
- Fl_Widget* w = Fl::readqueue();
- if (w == decl_panel_cancel) goto BREAK2;
- else if (w == decl_panel_ok) break;
- else if (!w) Fl::wait();
- }
- // check values
- const char*c = decl_input->buffer()->text();
- while (isspace(*c)) c++;
- message = c_check(c&&c[0]=='#' ? c+1 : c);
- // alert user
- if (message) {
- int v = fl_choice("Potential syntax error detected: %s",
- "Continue Editing", "Ignore Error", nullptr, message);
- if (v==0) continue; // Continue Editing
- //if (v==1) { } // Ignore Error and close dialog
- }
- // copy vlaues
- name(c);
- if (is_in_class()) {
- if (public_!=decl_class_choice->value()) {
- Fluid.proj.set_modflag(1);
- public_ = decl_class_choice->value();
- }
- } else {
- if (public_!=(decl_choice->value()&1)) {
- Fluid.proj.set_modflag(1);
- public_ = (decl_choice->value()&1);
- }
- if (static_!=((decl_choice->value()>>1)&1)) {
- Fluid.proj.set_modflag(1);
- static_ = ((decl_choice->value()>>1)&1);
- }
- }
- c = decl_comment_input->buffer()->text();
- if (c && *c) {
- if (!comment() || strcmp(c, comment())) { Fluid.proj.set_modflag(1); redraw_browser(); }
- comment(c);
- } else {
- if (comment()) { Fluid.proj.set_modflag(1); redraw_browser(); }
- comment(nullptr);
- }
- if (c) free((void*)c);
- break;
- }
-BREAK2:
- decl_panel->hide();
+ open_panel();
}
/**
@@ -1120,9 +914,7 @@ Data_Node Data_Node::prototype;
Constructor.
*/
Data_Node::Data_Node() :
- Decl_Node(),
- filename_(nullptr),
- text_mode_(0)
+ Decl_Node()
{ }
/**
@@ -1151,7 +943,7 @@ Node *Data_Node::make(Strategy strategy) {
o->public_ = 1;
o->static_ = 1;
o->filename_ = nullptr;
- o->text_mode_ = 0;
+ o->output_format_ = 0;
o->name("myInlineData");
o->add(anchor, strategy);
o->factory = this;
@@ -1169,11 +961,12 @@ void Data_Node::write_properties(fld::io::Project_Writer &f) {
f.write_string("filename");
f.write_word(filename_);
}
- if (text_mode_ == 1) {
- f.write_string("textmode");
- }
- if (text_mode_ == 2) {
- f.write_string("compressed");
+ switch (output_format_) {
+ case 1: f.write_string("textmode"); break;
+ case 2: f.write_string("compressed"); break;
+ case 3: f.write_string("std_binary"); break;
+ case 4: f.write_string("std_textmode"); break;
+ case 5: f.write_string("std_compressed"); break;
}
}
@@ -1184,9 +977,15 @@ void Data_Node::read_property(fld::io::Project_Reader &f, const char *c) {
if (!strcmp(c,"filename")) {
storestring(f.read_word(), filename_, 1);
} else if (!strcmp(c,"textmode")) {
- text_mode_ = 1;
+ output_format_ = 1;
} else if (!strcmp(c,"compressed")) {
- text_mode_ = 2;
+ output_format_ = 2;
+ } else if (!strcmp(c,"std_binary")) {
+ output_format_ = 3;
+ } else if (!strcmp(c,"std_textmode")) {
+ output_format_ = 4;
+ } else if (!strcmp(c,"std_compressed")) {
+ output_format_ = 5;
} else {
Decl_Node::read_property(f, c);
}
@@ -1196,110 +995,7 @@ void Data_Node::read_property(fld::io::Project_Reader &f, const char *c) {
Open the data_panel to edit this node.
*/
void Data_Node::open() {
- if (!data_panel) make_data_panel();
- data_input->value(name());
- if (is_in_class()) {
- data_class_choice->value(public_);
- data_class_choice->show();
- data_choice->hide();
- } else {
- data_choice->value((public_&1)|((static_&1)<<1));
- data_choice->show();
- data_class_choice->hide();
- }
- data_mode->value(text_mode_);
- data_filename->value(filename_?filename_:"");
- const char *c = comment();
- data_comment_input->buffer()->text(c?c:"");
- data_panel->show();
- for (;;) { // repeat as long as there are errors
- for (;;) {
- Fl_Widget* w = Fl::readqueue();
- if (w == data_panel_cancel) goto BREAK2;
- else if (w == data_panel_ok) break;
- else if (w == data_filebrowser) {
- Fluid.proj.enter_project_dir();
- const char *fn = fl_file_chooser("Load Inline Data", nullptr, data_filename->value(), 1);
- Fluid.proj.leave_project_dir();
- if (fn) {
- if (strcmp(fn, data_filename->value()))
- Fluid.proj.set_modflag(1);
- data_filename->value(fn);
- }
- }
- else if (!w) Fl::wait();
- }
- // store the variable name:
- const char*c = data_input->value();
- char *s = fl_strdup(c), *p = s, *q, *n;
- for (;;++p) { // remove leading spaces
- if (!isspace((unsigned char)(*p))) break;
- }
- n = p;
- if ( (!isalpha((unsigned char)(*p))) && ((*p)!='_') && ((*p)!=':') ) goto OOPS;
- ++p;
- for (;;++p) {
- if ( (!isalnum((unsigned char)(*p))) && ((*p)!='_') && ((*p)!=':') ) break;
- }
- q = p;
- for (;;++q) {
- if (!*q) break;
- if (!isspace((unsigned char)(*q))) goto OOPS;
- }
- *p = 0; // remove trailing spaces
- if (n==q) {
- OOPS:
- int v = fl_choice("%s",
- "Continue Editing", "Ignore Error", nullptr,
- "Variable name must be a C identifier");
- if (v==0) { free(s); continue; } // Continue Editing
- //if (v==1) { } // Ignore Error and close dialog
- }
- Fluid.proj.undo.checkpoint();
- name(n);
- free(s);
- // store flags
- if (is_in_class()) {
- if (public_!=data_class_choice->value()) {
- Fluid.proj.set_modflag(1);
- public_ = data_class_choice->value();
- }
- } else {
- if (public_!=(data_choice->value()&1)) {
- Fluid.proj.set_modflag(1);
- public_ = (data_choice->value()&1);
- }
- if (static_!=((data_choice->value()>>1)&1)) {
- Fluid.proj.set_modflag(1);
- static_ = ((data_choice->value()>>1)&1);
- }
- }
- text_mode_ = data_mode->value();
- if (text_mode_ < 0) text_mode_ = 0;
- if (text_mode_ > 2) text_mode_ = 2;
- // store the filename
- c = data_filename->value();
- if (filename_ && strcmp(filename_, data_filename->value()))
- Fluid.proj.set_modflag(1);
- else if (!filename_ && *c)
- Fluid.proj.set_modflag(1);
- if (filename_) { free((void*)filename_); filename_ = nullptr; }
- if (c && *c) filename_ = fl_strdup(c);
- // store the comment
- c = data_comment_input->buffer()->text();
- if (c && *c) {
- if (!comment() || strcmp(c, comment())) { Fluid.proj.set_modflag(1); redraw_browser(); }
- comment(c);
- } else {
- if (comment()) { Fluid.proj.set_modflag(1); redraw_browser(); }
- comment(nullptr);
- }
- if (c) free((void*)c);
- Fluid.proj.set_modflag(1);
- break;
- }
-BREAK2:
- data_panel->hide();
+ open_panel();
}
/**
@@ -1327,7 +1023,7 @@ void Data_Node::write_code1(fld::io::Code_Writer& f) {
if (nData) {
data = (char*)calloc(nData, 1);
if (fread(data, nData, 1, f)==0) { /* use default */ }
- if (text_mode_ == 2) {
+ if ((output_format_ == 2) || (output_format_ == 5)) {
uncompressedDataSize = nData;
uLong nzData = compressBound(nData);
Bytef *zdata = (Bytef*)::malloc(nzData);
@@ -1344,27 +1040,47 @@ void Data_Node::write_code1(fld::io::Code_Writer& f) {
}
if (is_in_class()) {
f.write_public(public_);
- if (text_mode_ == 1) {
- f.write_h("%sstatic const char *%s;\n", f.indent(1), c);
+ if ((output_format_ == 1) || (output_format_ == 4)) {
f.write_c("\n");
write_comment_c(f);
- f.write_c("const char *%s::%s = /* text inlined from %s */\n", class_name(1), c, fn);
+ if (output_format_ == 1) {
+ f.write_h("%sstatic const char *%s;\n", f.indent(1), c);
+ f.write_c("const char *%s::%s = /* text inlined from %s */\n", class_name(1), c, fn);
+ } else {
+ f.write_h_once("#include <string>");
+ f.write_h("%sstatic const std::string %s;\n", f.indent(1), c);
+ f.write_c("const std::string %s::%s = /* text inlined from %s */\n", class_name(1), c, fn);
+ }
if (message) f.write_c("#error %s %s\n", message, fn);
f.write_cstring(data, nData);
- } else if (text_mode_ == 2) {
+ } else if ((output_format_ == 2) || (output_format_ == 5)) {
f.write_h("%sstatic int %s_size;\n", f.indent(1), c);
- f.write_h("%sstatic unsigned char %s[%d];\n", f.indent(1), c, nData);
f.write_c("\n");
write_comment_c(f);
f.write_c("int %s::%s_size = %d;\n", class_name(1), c, uncompressedDataSize);
- f.write_c("unsigned char %s::%s[%d] = /* data compressed and inlined from %s */\n", class_name(1), c, nData, fn);
+ if (output_format_ == 2) {
+ f.write_h("%sstatic unsigned char %s[%d];\n", f.indent(1), c, nData);
+ f.write_c("unsigned char %s::%s[%d] = /* data compressed and inlined from %s */\n", class_name(1), c, nData, fn);
+ } else {
+ f.write_h_once("#include <stdint.h>");
+ f.write_h_once("#include <vector>");
+ f.write_h("%sstatic std::vector<uint8_t> %s;\n", f.indent(1), c);
+ f.write_c("std::vector<uint8_t> %s::%s = /* data compressed and inlined from %s */\n", class_name(1), c, fn);
+ }
if (message) f.write_c("#error %s %s\n", message, fn);
f.write_cdata(data, nData);
} else {
- f.write_h("%sstatic unsigned char %s[%d];\n", f.indent(1), c, nData);
f.write_c("\n");
write_comment_c(f);
- f.write_c("unsigned char %s::%s[%d] = /* data inlined from %s */\n", class_name(1), c, nData, fn);
+ if (output_format_ == 0) {
+ f.write_h("%sstatic unsigned char %s[%d];\n", f.indent(1), c, nData);
+ f.write_c("unsigned char %s::%s[%d] = /* data inlined from %s */\n", class_name(1), c, nData, fn);
+ } else {
+ f.write_h_once("#include <stdint.h>");
+ f.write_h_once("#include <vector>");
+ f.write_h("%sstatic std::vector<uint8_t> %s;\n", f.indent(1), c);
+ f.write_c("std::vector<uint8_t> %s::%s = /* data inlined from %s */\n", class_name(1), c, fn);
+ }
if (message) f.write_c("#error %s %s\n", message, fn);
f.write_cdata(data, nData);
}
@@ -1373,27 +1089,47 @@ void Data_Node::write_code1(fld::io::Code_Writer& f) {
// the "header only" option does not apply here!
if (public_) {
if (static_) {
- if (text_mode_ == 1) {
- f.write_h("extern const char *%s;\n", c);
+ if ((output_format_ == 1) || (output_format_ == 4)) {
f.write_c("\n");
write_comment_c(f);
- f.write_c("const char *%s = /* text inlined from %s */\n", c, fn);
+ if (output_format_ == 1) {
+ f.write_h("extern const char *%s;\n", c);
+ f.write_c("const char *%s = /* text inlined from %s */\n", c, fn);
+ } else {
+ f.write_h_once("#include <string>");
+ f.write_h("extern const std::string %s;\n", c);
+ f.write_c("const std::string %s = /* text inlined from %s */\n", c, fn);
+ }
if (message) f.write_c("#error %s %s\n", message, fn);
f.write_cstring(data, nData);
- } else if (text_mode_ == 2) {
+ } else if ((output_format_ == 2) || (output_format_ == 5)) {
f.write_h("extern int %s_size;\n", c);
- f.write_h("extern unsigned char %s[%d];\n", c, nData);
f.write_c("\n");
write_comment_c(f);
f.write_c("int %s_size = %d;\n", c, uncompressedDataSize);
- f.write_c("unsigned char %s[%d] = /* data compressed and inlined from %s */\n", c, nData, fn);
+ if (output_format_ == 2) {
+ f.write_h("extern unsigned char %s[%d];\n", c, nData);
+ f.write_c("unsigned char %s[%d] = /* data compressed and inlined from %s */\n", c, nData, fn);
+ } else {
+ f.write_h_once("#include <stdint.h>");
+ f.write_h_once("#include <vector>");
+ f.write_h("extern std::vector<uint8_t> %s;\n", c);
+ f.write_c("std::vector<uint8_t> %s = /* data compressed and inlined from %s */\n", c, fn);
+ }
if (message) f.write_c("#error %s %s\n", message, fn);
f.write_cdata(data, nData);
} else {
- f.write_h("extern unsigned char %s[%d];\n", c, nData);
f.write_c("\n");
write_comment_c(f);
- f.write_c("unsigned char %s[%d] = /* data inlined from %s */\n", c, nData, fn);
+ if (output_format_ == 0) {
+ f.write_h("extern unsigned char %s[%d];\n", c, nData);
+ f.write_c("unsigned char %s[%d] = /* data inlined from %s */\n", c, nData, fn);
+ } else {
+ f.write_h_once("#include <stdint.h>");
+ f.write_h_once("#include <vector>");
+ f.write_h("extern std::vector<uint8_t> %s;\n", c);
+ f.write_c("std::vector<uint8_t> %s = /* data inlined from %s */\n", c, fn);
+ }
if (message) f.write_c("#error %s %s\n", message, fn);
f.write_cdata(data, nData);
}
@@ -1401,7 +1137,7 @@ void Data_Node::write_code1(fld::io::Code_Writer& f) {
} else {
write_comment_h(f);
f.write_h("#error Unsupported declaration loading inline data %s\n", fn);
- if (text_mode_ == 1)
+ if (output_format_ == 1)
f.write_h("const char *%s = \"abc...\";\n", c);
else
f.write_h("unsigned char %s[3] = { 1, 2, 3 };\n", c);
@@ -1409,20 +1145,41 @@ void Data_Node::write_code1(fld::io::Code_Writer& f) {
} else {
f.write_c("\n");
write_comment_c(f);
- if (static_)
- f.write_c("static ");
- if (text_mode_ == 1) {
- f.write_c("const char *%s = /* text inlined from %s */\n", c, fn);
+ if ((output_format_ == 1) || (output_format_ == 4)) {
+ if (output_format_ == 1) {
+ if (static_) f.write_c("static ");
+ f.write_c("const char *%s = /* text inlined from %s */\n", c, fn);
+ } else {
+ f.write_c_once("#include <string>");
+ if (static_) f.write_c("static ");
+ f.write_c("const std::string %s = /* text inlined from %s */\n", c, fn);
+ }
if (message) f.write_c("#error %s %s\n", message, fn);
f.write_cstring(data, nData);
- } else if (text_mode_ == 2) {
- f.write_c("int %s_size = %d;\n", c, uncompressedDataSize);
+ } else if ((output_format_ == 2) || (output_format_ == 5)) {
if (static_) f.write_c("static ");
- f.write_c("unsigned char %s[%d] = /* data compressed and inlined from %s */\n", c, nData, fn);
+ f.write_c("int %s_size = %d;\n", c, uncompressedDataSize);
+ if (output_format_ == 2) {
+ if (static_) f.write_c("static ");
+ f.write_c("unsigned char %s[%d] = /* data compressed and inlined from %s */\n", c, nData, fn);
+ } else {
+ f.write_c_once("#include <stdint.h>");
+ f.write_c_once("#include <vector>");
+ if (static_) f.write_c("static ");
+ f.write_c("std::vector<uint8_t> %s = /* data compressed and inlined from %s */\n", c, fn);
+ }
if (message) f.write_c("#error %s %s\n", message, fn);
f.write_cdata(data, nData);
} else {
- f.write_c("unsigned char %s[%d] = /* data inlined from %s */\n", c, nData, fn);
+ if (output_format_ == 0) {
+ if (static_) f.write_c("static ");
+ f.write_c("unsigned char %s[%d] = /* data inlined from %s */\n", c, nData, fn);
+ } else {
+ f.write_c_once("#include <stdint.h>");
+ f.write_c_once("#include <vector>");
+ if (static_) f.write_c("static ");
+ f.write_c("std::vector<uint8_t> %s = /* data inlined from %s */\n", c, fn);
+ }
if (message) f.write_c("#error %s %s\n", message, fn);
f.write_cdata(data, nData);
}
@@ -1440,6 +1197,11 @@ void Data_Node::write_code1(fld::io::Code_Writer& f) {
if (data) free(data);
}
+void Data_Node::filename(const char* fn) {
+ storestring(fn, filename_);
+}
+
+
// ---- DeclBlock_Node declaration
/** \class DeclBlock_Node
@@ -1456,10 +1218,8 @@ DeclBlock_Node DeclBlock_Node::prototype;
/**
Constructor.
*/
-DeclBlock_Node::DeclBlock_Node() :
- Node(),
- after(nullptr),
- write_map_(CODE_IN_SOURCE)
+DeclBlock_Node::DeclBlock_Node()
+: Node()
{ }
/**
@@ -1536,101 +1296,7 @@ void DeclBlock_Node::read_property(fld::io::Project_Reader &f, const char *c) {
Open the declblock_panel to edit this node.
*/
void DeclBlock_Node::open() {
- // build dialog box
- if (!declblock_panel) make_declblock_panel();
- // preset all values
- declblock_before_input->value(name());
- declblock_after_input->value(after);
- declblock_static_header->value(write_map_ & STATIC_IN_HEADER);
- declblock_static_source->value(write_map_ & STATIC_IN_SOURCE);
- declblock_code_header->value(write_map_ & CODE_IN_HEADER);
- declblock_code_source->value(write_map_ & CODE_IN_SOURCE);
- const char *c = comment();
- declblock_comment_input->buffer()->text(c?c:"");
- // show modal dialog and loop until satisfied
- declblock_panel->show();
- const char* message = nullptr;
- for (;;) { // repeat as long as there are errors
- for (;;) {
- Fl_Widget* w = Fl::readqueue();
- if (w == declblock_panel_cancel) goto BREAK2;
- else if (w == declblock_panel_ok) break;
- else if (!w) Fl::wait();
- }
- // verify user input
- const char* a = declblock_before_input->value();
- while (isspace(*a)) a++;
- const char* b = declblock_after_input->value();
- while (isspace(*b)) b++;
- message = c_check(a&&a[0]=='#' ? a+1 : a);
- if (!message)
- message = c_check(b&&b[0]=='#' ? b+1 : b);
- if (message) {
- int v = fl_choice("Potential syntax error detected: %s",
- "Continue Editing", "Ignore Error", nullptr, message);
- if (v==0) continue; // Continue Editing
- //if (v==1) { } // Ignore Error and close dialog
- }
- // store user choices in data structure
- name(a);
- storestring(b, after);
- if (write_map_ & STATIC_IN_HEADER) {
- if (declblock_static_header->value()==0) {
- write_map_ &= ~STATIC_IN_HEADER;
- Fluid.proj.set_modflag(1);
- }
- } else {
- if (declblock_static_header->value()) {
- write_map_ |= STATIC_IN_HEADER;
- Fluid.proj.set_modflag(1);
- }
- }
- if (write_map_ & STATIC_IN_SOURCE) {
- if (declblock_static_source->value()==0) {
- write_map_ &= ~STATIC_IN_SOURCE;
- Fluid.proj.set_modflag(1);
- }
- } else {
- if (declblock_static_source->value()) {
- write_map_ |= STATIC_IN_SOURCE;
- Fluid.proj.set_modflag(1);
- }
- }
- if (write_map_ & CODE_IN_HEADER) {
- if (declblock_code_header->value()==0) {
- write_map_ &= ~CODE_IN_HEADER;
- Fluid.proj.set_modflag(1);
- }
- } else {
- if (declblock_code_header->value()) {
- write_map_ |= CODE_IN_HEADER;
- Fluid.proj.set_modflag(1);
- }
- }
- if (write_map_ & CODE_IN_SOURCE) {
- if (declblock_code_source->value()==0) {
- write_map_ &= ~CODE_IN_SOURCE;
- Fluid.proj.set_modflag(1);
- }
- } else {
- if (declblock_code_source->value()) {
- write_map_ |= CODE_IN_SOURCE;
- Fluid.proj.set_modflag(1);
- }
- }
- c = declblock_comment_input->buffer()->text();
- if (c && *c) {
- if (!comment() || strcmp(c, comment())) { Fluid.proj.set_modflag(1); redraw_browser(); }
- comment(c);
- } else {
- if (comment()) { Fluid.proj.set_modflag(1); redraw_browser(); }
- comment(nullptr);
- }
- if (c) free((void*)c);
- break;
- }
-BREAK2:
- declblock_panel->hide();
+ open_panel();
}
/**
@@ -1767,7 +1433,7 @@ void Comment_Node::read_property(fld::io::Project_Reader &f, const char *c) {
add their own presets which are stored per user in a separate
preferences database.
*/
-static void load_comments_preset(Fl_Preferences &menu) {
+void load_comments_preset(Fl_Preferences &menu) {
static const char * const predefined_comment[] = {
"GNU Public License v3/GPL Header", "GNU Public License v3/GPL Footer",
"GNU Public License v3/LGPL Header", "GNU Public License v3/LGPL Footer",
@@ -1787,119 +1453,7 @@ static void load_comments_preset(Fl_Preferences &menu) {
Open the comment_panel to edit this node.
*/
void Comment_Node::open() {
- if (!comment_panel) make_comment_panel();
- const char *text = name();
- {
- int i=0, n=0, version = 0;
- Fl_Preferences menu(Fl_Preferences::USER_L, "fltk.org", "fluid_comments_menu");
- comment_predefined->clear();
- comment_predefined->add("_Edit/Add current comment...");
- comment_predefined->add("_Edit/Remove last selection...");
- menu.get("version", version, -1);
- if (version < 10400) load_comments_preset(menu);
- menu.get("n", n, 0);
- for (i=0;i<n;i++) {
- char *text;
- menu.get(Fl_Preferences::Name(i), text, "");
- comment_predefined->add(text);
- free(text);
- }
- }
- comment_input->buffer()->text( text ? text : "" );
- comment_in_source->value(in_c_);
- comment_in_header->value(in_h_);
- comment_panel->show();
- char itempath[FL_PATH_MAX]; itempath[0] = 0;
- int last_selected_item = 0;
- for (;;) { // repeat as long as there are errors
- for (;;) {
- Fl_Widget* w = Fl::readqueue();
- if (w == comment_panel_cancel) goto BREAK2;
- else if (w == comment_panel_ok) break;
- else if (w == comment_predefined) {
- if (comment_predefined->value()==1) {
- // add the current comment to the database
- const char *xname = fl_input(
- "Please enter a name to reference the current\ncomment in your database.\n\n"
- "Use forward slashes '/' to create submenus.",
- "My Comment");
- if (xname) {
- char *name = fl_strdup(xname);
- for (char*s=name;*s;s++) if (*s==':') *s = ';';
- int n;
- Fl_Preferences db(Fl_Preferences::USER_L, "fltk.org", "fluid_comments");
- db.set(name, comment_input->buffer()->text());
- Fl_Preferences menu(Fl_Preferences::USER_L, "fltk.org", "fluid_comments_menu");
- menu.get("n", n, 0);
- menu.set(Fl_Preferences::Name(n), name);
- menu.set("n", ++n);
- comment_predefined->add(name);
- free(name);
- }
- } else if (comment_predefined->value()==2) {
- // remove the last selected comment from the database
- if (itempath[0]==0 || last_selected_item==0) {
- fl_message("Please select an entry from this menu first.");
- } else if (fl_choice("Are you sure that you want to delete the entry\n"
- "\"%s\"\nfrom the database?", "Cancel", "Delete",
- nullptr, itempath)) {
- Fl_Preferences db(Fl_Preferences::USER_L, "fltk.org", "fluid_comments");
- db.deleteEntry(itempath);
- comment_predefined->remove(last_selected_item);
- Fl_Preferences menu(Fl_Preferences::USER_L, "fltk.org", "fluid_comments_menu");
- int i, n;
- for (i=4, n=0; i<comment_predefined->size(); i++) {
- const Fl_Menu_Item *mi = comment_predefined->menu()+i;
- if (comment_predefined->item_pathname(itempath, 255, mi)==0) {
- if (itempath[0]=='/') memmove(itempath, itempath+1, 255);
- if (itempath[0]) menu.set(Fl_Preferences::Name(n++), itempath);
- }
- }
- menu.set("n", n);
- }
- } else {
- // load the selected comment from the database
- if (comment_predefined->item_pathname(itempath, 255)==0) {
- if (itempath[0]=='/') memmove(itempath, itempath+1, 255);
- Fl_Preferences db(Fl_Preferences::USER_L, "fltk.org", "fluid_comments");
- char *text;
- db.get(itempath, text, "(no text found in data base)");
- comment_input->buffer()->text(text);
- free(text);
- last_selected_item = comment_predefined->value();
- }
- }
- }
- else if (w == comment_load) {
- // load a comment from disk
- fl_file_chooser_ok_label("Use File");
- const char *fname = fl_file_chooser("Pick a comment", nullptr, nullptr);
- fl_file_chooser_ok_label(nullptr);
- if (fname) {
- if (comment_input->buffer()->loadfile(fname)) {
- fl_alert("Error loading file\n%s", fname);
- }
- }
- }
- else if (!w) Fl::wait();
- }
- char*c = comment_input->buffer()->text();
- name(c);
- free(c);
- int mod = 0;
- if (in_c_ != comment_in_source->value()) {
- in_c_ = comment_in_source->value();
- mod = 1;
- }
- if (in_h_ != comment_in_header->value()) {
- in_h_ = comment_in_header->value();
- mod = 1;
- }
- if (mod) Fluid.proj.set_modflag(1);
- break;
- }
-BREAK2:
- comment_panel->hide();
+ open_panel();
}
/**
@@ -2049,75 +1603,7 @@ void Class_Node::read_property(fld::io::Project_Reader &f, const char *c) {
Open the class_panel to edit the class name and superclass name.
*/
void Class_Node::open() {
- if (!class_panel) make_class_panel();
- char fullname[FL_PATH_MAX]="";
- if (prefix() && strlen(prefix()))
- sprintf(fullname,"%s %s",prefix(),name());
- else
- strcpy(fullname, name());
- c_name_input->value(fullname);
- c_subclass_input->value(subclass_of);
- c_public_button->value(public_);
- const char *c = comment();
- c_comment_input->buffer()->text(c?c:"");
- class_panel->show();
- const char* message = nullptr;
-
- char *na=nullptr,*pr=nullptr,*p=nullptr; // name and prefix substrings
-
- for (;;) { // repeat as long as there are errors
- // we don;t give the option to ignore this error here because code depends
- // on this being a C++ identifier
- if (message) fl_alert("%s", message);
- for (;;) {
- Fl_Widget* w = Fl::readqueue();
- if (w == c_panel_cancel) goto BREAK2;
- else if (w == c_panel_ok) break;
- else if (!w) Fl::wait();
- }
- const char*c = c_name_input->value();
- char *s = fl_strdup(c);
- size_t len = strlen(s);
- if (!*s) goto OOPS;
- p = (char*) (s+len-1);
- while (p>=s && isspace(*p)) *(p--)='\0';
- if (p<s) goto OOPS;
- while (p>=s && is_id(*p)) p--;
- if ( (p<s && !is_id(*(p+1))) || !*(p+1) ) {
- OOPS: message = "class name must be C++ identifier";
- free((void*)s);
- continue;
- }
- na=p+1; // now we have the name
- if(p>s) *p--='\0';
- while (p>=s && isspace(*p)) *(p--)='\0';
- while (p>=s && is_id(*p)) p--;
- if (p<s) p++;
- if (is_id(*p) && p<na) pr=p; // prefix detected
- c = c_subclass_input->value();
- message = c_check(c);
- if (message) { free((void*)s);continue;}
- name(na);
- prefix(pr);
- free((void*)s);
- storestring(c, subclass_of);
- if (public_ != c_public_button->value()) {
- public_ = c_public_button->value();
- Fluid.proj.set_modflag(1);
- }
- c = c_comment_input->buffer()->text();
- if (c && *c) {
- if (!comment() || strcmp(c, comment())) { Fluid.proj.set_modflag(1); redraw_browser(); }
- comment(c);
- } else {
- if (comment()) { Fluid.proj.set_modflag(1); redraw_browser(); }
- comment(nullptr);
- }
- if (c) free((void*)c);
- break;
- }
-BREAK2:
- class_panel->hide();
+ open_panel();
}
/**
diff --git a/fluid/nodes/Function_Node.h b/fluid/nodes/Function_Node.h
index ac8bcdcc2..56a0046e0 100644
--- a/fluid/nodes/Function_Node.h
+++ b/fluid/nodes/Function_Node.h
@@ -48,8 +48,8 @@ public:
typedef Node super;
static Function_Node prototype;
private:
- const char* return_type;
- char public_, cdecl_, constructor, havewidgets;
+ const char* return_type_;
+ char public_, declare_c_, constructor, havewidgets;
public:
Function_Node();
~Function_Node();
@@ -70,6 +70,12 @@ public:
void write_properties(fld::io::Project_Writer &f) override;
void read_property(fld::io::Project_Reader &f, const char *) override;
int has_signature(const char *, const char*) const;
+ const char *return_type() { return return_type_; }
+ void return_type(const char *t) { storestring(t, return_type_); }
+ char visibility() { return public_; }
+ void visibility(char v) { public_ = v; }
+ char declare_c() { return declare_c_; }
+ void declare_c(char v) { declare_c_ = v; }
};
// ---- Code_Node declaration
@@ -79,11 +85,11 @@ class Code_Node : public Node
public:
typedef Node super;
static Code_Node prototype;
-private:
- ExternalCodeEditor editor_;
int cursor_position_;
int code_input_scroll_row;
int code_input_scroll_col;
+private:
+ ExternalCodeEditor editor_;
public:
Code_Node();
Node *make(Strategy strategy) override;
@@ -125,6 +131,8 @@ public:
bool is_a(Type inType) const override { return (inType==Type::CodeBlock) ? true : super::is_a(inType); }
void write_properties(fld::io::Project_Writer &f) override;
void read_property(fld::io::Project_Reader &f, const char *) override;
+ const char *end_code() { return after; }
+ void end_code(const char *c) { storestring(c, after); }
};
// ---- Decl_Node declaration
@@ -135,7 +143,7 @@ public:
typedef Node super;
static Decl_Node prototype;
protected:
- char public_;
+ char public_; // public = 0, private = 1, protected = 2
char static_;
public:
@@ -150,6 +158,10 @@ public:
int is_public() const override;
Type type() const override { return Type::Decl; }
bool is_a(Type inType) const override { return (inType==Type::Decl) ? true : super::is_a(inType); }
+ char visibility() { return public_; }
+ void visibility(char v) { public_ = v; }
+ char output_file() { return (public_&1)|((static_&1)<<1); }
+ void output_file(char f) { public_ = (f&1); static_ = ((f>>1)&1); }
};
// ---- Data_Node declaration
@@ -160,8 +172,8 @@ public:
typedef Decl_Node super;
static Data_Node prototype;
private:
- const char *filename_;
- int text_mode_;
+ const char *filename_ { nullptr };
+ int output_format_ { 0 };
public:
Data_Node();
@@ -175,6 +187,10 @@ public:
void read_property(fld::io::Project_Reader &f, const char *) override;
Type type() const override { return Type::Data; }
bool is_a(Type inType) const override { return (inType==Type::Data) ? true : super::is_a(inType); }
+ void filename(const char* fn);
+ const char* filename() { return filename_; }
+ int output_format() { return output_format_; }
+ void output_format(int fmt) { output_format_ = fmt; }
};
// ---- DeclBlock_Node declaration
@@ -184,15 +200,15 @@ class DeclBlock_Node : public Node
public:
typedef Node super;
static DeclBlock_Node prototype;
-private:
enum {
CODE_IN_HEADER = 1,
CODE_IN_SOURCE = 2,
STATIC_IN_HEADER = 4,
STATIC_IN_SOURCE = 8
};
- const char* after; ///< code after all children of this block
- int write_map_; ///< see enum above
+private:
+ const char* after { nullptr }; ///< code after all children of this block
+ int write_map_ { CODE_IN_SOURCE }; ///< see enum above
public:
DeclBlock_Node();
@@ -211,6 +227,10 @@ public:
int is_public() const override;
Type type() const override { return Type::DeclBlock; }
bool is_a(Type inType) const override { return (inType==Type::DeclBlock) ? true : super::is_a(inType); }
+ const char *end_code() { return after; }
+ void end_code(const char *c) { storestring(c, after); }
+ int write_map() { return write_map_; }
+ void write_map(int v) { write_map_ = v; }
};
// ---- Comment_Node declaration
@@ -235,6 +255,10 @@ public:
int is_public() const override { return 1; }
Type type() const override { return Type::Comment; }
bool is_a(Type inType) const override { return (inType==Type::Comment) ? true : super::is_a(inType); }
+ bool in_h() { return in_h_; }
+ void in_h(bool v) { in_h_ = v; }
+ bool in_c() { return in_c_; }
+ void in_c(bool v) { in_c_ = v; }
};
// ---- Class_Node declaration
@@ -268,6 +292,10 @@ public:
bool is_a(Type inType) const override { return (inType==Type::Class) ? true : super::is_a(inType); }
void write_properties(fld::io::Project_Writer &f) override;
void read_property(fld::io::Project_Reader &f, const char *) override;
+ const char* base_class_name() { return subclass_of; }
+ void base_class_name(const char* name) { storestring(name, subclass_of); }
+ char visibility() { return public_; }
+ void visibility(char v) { public_ = v; }
// class prefix attribute access
void prefix(const char* p);
diff --git a/fluid/nodes/Group_Node.cxx b/fluid/nodes/Group_Node.cxx
index d269b62ab..7565a5552 100644
--- a/fluid/nodes/Group_Node.cxx
+++ b/fluid/nodes/Group_Node.cxx
@@ -30,6 +30,7 @@
#include <FL/Fl.H>
#include <FL/Fl_Group.H>
+#include <FL/Fl_Tile.H>
#include <FL/Fl_Table.H>
#include <FL/Fl_Menu_Item.H>
#include <FL/fl_message.H>
@@ -222,8 +223,10 @@ void Group_Node::add_child(Node* cc, Node* before) {
// This is called when o is deleted. If it is in the tab group make
// sure it is not visible:
void Group_Node::remove_child(Node* cc) {
- Widget_Node* c = (Widget_Node*)cc;
- ((Fl_Group*)o)->remove(c->o);
+ if (cc->is_widget()) {
+ Widget_Node* c = (Widget_Node*)cc;
+ ((Fl_Group*)o)->remove(c->o);
+ }
o->redraw();
}
@@ -764,10 +767,12 @@ void Tabs_Node::add_child(Node* c, Node* before) {
}
void Tabs_Node::remove_child(Node* cc) {
- Widget_Node* c = (Widget_Node*)cc;
- Fl_Tabs *t = (Fl_Tabs*)o;
- if (t->value() == c->o) t->value(nullptr);
- Group_Node::remove_child(c);
+ if (cc->is_widget()) {
+ Widget_Node* c = (Widget_Node*)cc;
+ Fl_Tabs *t = (Fl_Tabs*)o;
+ if (t->value() == c->o) t->value(nullptr);
+ }
+ Group_Node::remove_child(cc);
}
Fl_Widget *Tabs_Node::enter_live_mode(int) {
@@ -816,6 +821,15 @@ Tile_Node Tile_Node::prototype; // the "factory"
const char tile_type_name[] = "Fl_Tile";
+// live mode support
+Fl_Widget* Tile_Node::enter_live_mode(int) {
+ Fl_Group *grp = new Fl_Tile(o->x(), o->y(), o->w(), o->h());
+ return propagate_live_mode(grp);
+}
+
+void Tile_Node::leave_live_mode() {
+}
+
void Tile_Node::copy_properties() {
Group_Node::copy_properties();
// no additional properties
diff --git a/fluid/nodes/Group_Node.h b/fluid/nodes/Group_Node.h
index 6b6fe9fcd..1aea39df5 100644
--- a/fluid/nodes/Group_Node.h
+++ b/fluid/nodes/Group_Node.h
@@ -229,6 +229,8 @@ public:
Widget_Node *_make() override {return new Tile_Node();}
Type type() const override { return Type::Tile; }
bool is_a(Type inType) const override { return (inType==Type::Tile) ? true : super::is_a(inType); }
+ Fl_Widget *enter_live_mode(int top=0) override;
+ void leave_live_mode() override;
void copy_properties() override;
};
diff --git a/fluid/nodes/Node.cxx b/fluid/nodes/Node.cxx
index 86c5d16f7..0b1cb2d4d 100644
--- a/fluid/nodes/Node.cxx
+++ b/fluid/nodes/Node.cxx
@@ -537,6 +537,8 @@ Node::~Node() {
if (Fluid.proj.tree.last == this) Fluid.proj.tree.last = prev;
if (Fluid.proj.tree.first == this) Fluid.proj.tree.first = next;
if (Fluid.proj.tree.current == this) Fluid.proj.tree.current = nullptr;
+ if (current_widget == this) current_widget = nullptr;
+ if (current_node == this) current_node = nullptr;
if (parent) parent->remove_child(this);
if (name_) free((void*)name_);
if (label_) free((void*)label_);
diff --git a/fluid/nodes/Widget_Node.cxx b/fluid/nodes/Widget_Node.cxx
index 3d076b29b..7a2a7c98a 100644
--- a/fluid/nodes/Widget_Node.cxx
+++ b/fluid/nodes/Widget_Node.cxx
@@ -321,6 +321,7 @@ Fl_Window *the_panel;
// with any actual useful values for the argument. I also use this to
// initialized parts of the widget that are nyi by fluid.
+Node* current_node { nullptr };
Widget_Node *current_widget; // one of the selected ones
void* const LOAD = (void *)"LOAD"; // "magic" pointer to indicate that we need to load values into the dialog
int numselected; // number selected
@@ -1192,12 +1193,18 @@ void overlay_cb(Fl_Button*o,void *v) {
void leave_live_mode_cb(Fl_Widget*, void*);
-void live_mode_cb(Fl_Button*o,void *) {
+void live_mode_cb(Fl_Button* o, void *) {
/// \todo live mode should end gracefully when the application quits
/// or when the user closes the live widget
static Node *live_type = nullptr;
static Fl_Widget *live_widget = nullptr;
static Fl_Window *live_window = nullptr;
+
+ if (!current_widget) {
+ o->value(0);
+ return;
+ }
+
// if 'o' is 0, we must quit live mode
if (!o) {
o = wLiveMode;
@@ -1263,29 +1270,67 @@ void load_panel() {
numselected = 0;
current_widget = nullptr;
if (Fluid.proj.tree.current) {
- if (Fluid.proj.tree.current->is_widget())
- current_widget=(Widget_Node*)Fluid.proj.tree.current;
- for (Node *o = Fluid.proj.tree.first; o; o = o->next) {
- if (o->is_widget() && o->selected) {
- numselected++;
- if (!current_widget) current_widget = (Widget_Node*)o;
+ if (Fluid.proj.tree.current->is_a(Type::Data)) {
+ current_node = Fluid.proj.tree.current;
+ tabs_wizard->value(data_tabs);
+ numselected = 1;
+ } else if (Fluid.proj.tree.current->is_a(Type::Comment)) {
+ current_node = Fluid.proj.tree.current;
+ tabs_wizard->value(comment_tabs);
+ numselected = 1;
+ } else if (Fluid.proj.tree.current->is_a(Type::Class)) {
+ current_node = Fluid.proj.tree.current;
+ tabs_wizard->value(class_tabs);
+ numselected = 1;
+ } else if (Fluid.proj.tree.current->is_a(Type::DeclBlock)) {
+ current_node = Fluid.proj.tree.current;
+ tabs_wizard->value(declblock_tabs);
+ numselected = 1;
+ } else if (Fluid.proj.tree.current->is_a(Type::Decl)) {
+ current_node = Fluid.proj.tree.current;
+ tabs_wizard->value(decl_tabs);
+ numselected = 1;
+ } else if (Fluid.proj.tree.current->is_a(Type::CodeBlock)) {
+ current_node = Fluid.proj.tree.current;
+ tabs_wizard->value(codeblock_tabs);
+ numselected = 1;
+ } else if (Fluid.proj.tree.current->is_a(Type::Code)) {
+ current_node = Fluid.proj.tree.current;
+ tabs_wizard->value(code_tabs);
+ numselected = 1;
+ } else if (Fluid.proj.tree.current->is_a(Type::Function)) {
+ current_node = Fluid.proj.tree.current;
+ tabs_wizard->value(func_tabs);
+ numselected = 1;
+ } else {
+ current_node = nullptr;
+ if (Fluid.proj.tree.current->is_widget())
+ current_widget=(Widget_Node*)Fluid.proj.tree.current;
+ for (Node *o = Fluid.proj.tree.first; o; o = o->next) {
+ if (o->is_widget() && o->selected) {
+ numselected++;
+ if (!current_widget) current_widget = (Widget_Node*)o;
+ }
}
}
}
- if (current_widget && current_widget->is_a(Type::Grid)) {
- if (widget_tab_grid->parent()!=widget_tabs)
- widget_tabs->add(widget_tab_grid);
- } else {
- if (widget_tab_grid->parent()==widget_tabs) {
- widget_tabs_repo->add(widget_tab_grid);
+ if (current_widget) {
+ tabs_wizard->value(widget_tabs);
+ if (current_widget && current_widget->is_a(Type::Grid)) {
+ if (widget_tab_grid->parent()!=widget_tabs)
+ widget_tabs->add(widget_tab_grid);
+ } else {
+ if (widget_tab_grid->parent()==widget_tabs) {
+ widget_tabs_repo->add(widget_tab_grid);
+ }
}
- }
- if (current_widget && current_widget->parent && current_widget->parent->is_a(Type::Grid)) {
- if (widget_tab_grid_child->parent()!=widget_tabs)
- widget_tabs->add(widget_tab_grid_child);
- } else {
- if (widget_tab_grid_child->parent()==widget_tabs) {
- widget_tabs_repo->add(widget_tab_grid_child);
+ if (current_widget && current_widget->parent && current_widget->parent->is_a(Type::Grid)) {
+ if (widget_tab_grid_child->parent()!=widget_tabs)
+ widget_tabs->add(widget_tab_grid_child);
+ } else {
+ if (widget_tab_grid_child->parent()==widget_tabs) {
+ widget_tabs_repo->add(widget_tab_grid_child);
+ }
}
}
if (numselected)
@@ -1297,7 +1342,7 @@ void load_panel() {
extern Fl_Window *widgetbin_panel;
// This is called when user double-clicks an item, open or update the panel:
-void Widget_Node::open() {
+void open_panel() {
bool adjust_position = false;
if (!the_panel) {
the_panel = make_widget_panel();
@@ -1323,6 +1368,11 @@ void Widget_Node::open() {
}
}
+// This is called when user double-clicks an item, open or update the panel:
+void Widget_Node::open() {
+ open_panel();
+}
+
extern void redraw_overlays();
extern void check_redraw_corresponding_parent(Node*);
extern void redraw_browser();
diff --git a/fluid/nodes/Widget_Node.h b/fluid/nodes/Widget_Node.h
index fd0b7ddbe..0276cbcdf 100644
--- a/fluid/nodes/Widget_Node.h
+++ b/fluid/nodes/Widget_Node.h
@@ -29,7 +29,8 @@ class Widget_Node;
class Image_Asset;
extern void* const LOAD;
-extern Widget_Node *current_widget; // one of the selected ones
+extern Node* current_node; // one of the selected ones
+extern Widget_Node* current_widget; // one of the selected ones
extern const char* subclassname(Node* l);
extern int is_name(const char *c);