Fluid: convert modal panels into tabs in the widget panel (#1339)
Build and Test / build-linux (push) Has been cancelled
Build and Test / build-wayland (push) Has been cancelled
Build and Test / build-macos (push) Has been cancelled
Build and Test / build-windows (push) Has been cancelled

This commit is contained in:
Matthias Melcher
2025-11-29 12:57:08 +01:00
committed by GitHub
parent 725be0116f
commit 349b818d3f
24 changed files with 4834 additions and 3769 deletions
+7
View File
@@ -23,6 +23,7 @@
#define FL_TEXT_BUFFER_H
#include <stdarg.h> /* va_list */
#include <string>
#include "fl_attr.h" /* Doxygen can't find <FL/fl_attr.h> */
#undef ASSERT_UTF8
@@ -230,6 +231,12 @@ public:
*/
char* text() const;
/**
\brief Get a copy of the entire contents of the text buffer.
\return text as a UTF-8 string
*/
std::string text_str() const;
/**
Replaces the entire contents of the text buffer.
\param text Text must be valid UTF-8. If null, an empty string is substituted.
+2 -1
View File
@@ -412,6 +412,7 @@ Type "data" <word> : C++ variable name
"filename" <word> : name or path as entered by user, forward slashes
"textmode" : defaults to binary mode
"compressed" : defaults to not compressed
"std_binary", "std_textmode", "std_compressed"
... : inherits more from decl
Type "declblock" <word> : C++ code
@@ -431,7 +432,7 @@ Type "comment" <word> : comment text
Type "class" <word> <word> : prefix, class name
none or "private" or "protected" : defaults to public
":" <word> : name of super class
":" <word> : name of base class
... : inherits more from Node
Type "Fl_Widget" <word> : C++ variable name
+5 -5
View File
@@ -79,12 +79,12 @@
On macOS, we can write Apple Scripts:
#!/usr/bin/env osascript
say "@BASENAME@"
#!/usr/bin/env osascript
say "@BASENAME@"
osascript <<EOD
say "spark"
EOD
osascript <<EOD
say "spark"
EOD
osascript <<EOD
tell application "Xcode"
+5 -2
View File
@@ -319,9 +319,12 @@ Node *Project_Reader::read_children(Node *p, int merge, Strategy strategy, char
t->name(read_word());
c = read_word(1);
// There can actually be two keywords here. The first one used to be a
// "prefix" in Fluid < 1.5.0, but is no longer supported. So if we still
// find the prefix in files, it will simply be prefixed to the name.
if (strcmp(c,"{") && t->is_class()) { // <prefix> <name>
((Class_Node*)t)->prefix(t->name());
t->name(c);
std::string tmp = std::string {t->name() } + " " + c;
t->name(tmp.c_str());
c = read_word(1);
}
File diff suppressed because it is too large Load Diff
+38 -10
View File
@@ -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);
+20 -6
View File
@@ -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
+2
View File
@@ -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;
};
+2
View File
@@ -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_);
+71 -21
View File
@@ -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();
+2 -1
View File
@@ -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);
+1
View File
@@ -2,6 +2,7 @@
version 1.0500
header_name {.h}
code_name {.cxx}
include_guard {}
comment {//
// About dialog for the Fast Light Tool Kit (FLTK).
//
+1
View File
@@ -2,6 +2,7 @@
version 1.0500
header_name {.h}
code_name {.cxx}
include_guard {}
comment {//
// Code dialogs for the Fast Light Tool Kit (FLTK).
//
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+2 -88
View File
@@ -19,97 +19,11 @@
#ifndef function_panel_h
#define function_panel_h
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
extern Fl_Double_Window *function_panel;
#include <FL/Fl_Group.H>
#include <FL/Fl_Choice.H>
extern Fl_Choice *f_public_member_choice;
extern Fl_Choice *f_public_choice;
#include <FL/Fl_Light_Button.H>
extern Fl_Light_Button *f_c_button;
#include <FL/Fl_Box.H>
#include <FL/Fl_Input.H>
extern Fl_Input *f_name_input;
extern Fl_Input *f_return_type_input;
#include <FL/Fl_Text_Editor.H>
extern Fl_Text_Editor *f_comment_input;
#include <FL/Fl_Return_Button.H>
extern Fl_Return_Button *f_panel_ok;
#include <FL/Fl_Button.H>
extern Fl_Button *f_panel_cancel;
Fl_Double_Window* make_function_panel();
extern Fl_Menu_Item menu_f_public_member_choice[];
extern Fl_Menu_Item menu_f_public_choice[];
extern Fl_Double_Window *code_panel;
#include "widgets/Code_Editor.h"
extern fld::widget::Code_Editor *code_input;
extern Fl_Return_Button *code_panel_ok;
extern Fl_Button *code_panel_cancel;
Fl_Double_Window* make_code_panel();
extern Fl_Double_Window *codeblock_panel;
extern Fl_Input *code_before_input;
extern Fl_Input *code_after_input;
extern Fl_Return_Button *codeblock_panel_ok;
extern Fl_Button *codeblock_panel_cancel;
Fl_Double_Window* make_codeblock_panel();
extern Fl_Double_Window *declblock_panel;
extern Fl_Input *declblock_before_input;
extern Fl_Input *declblock_after_input;
#include <FL/Fl_Check_Button.H>
extern Fl_Check_Button *declblock_code_source;
extern Fl_Check_Button *declblock_static_source;
extern Fl_Check_Button *declblock_code_header;
extern Fl_Check_Button *declblock_static_header;
extern Fl_Text_Editor *declblock_comment_input;
extern Fl_Return_Button *declblock_panel_ok;
extern Fl_Button *declblock_panel_cancel;
Fl_Double_Window* make_declblock_panel();
extern Fl_Double_Window *decl_panel;
extern Fl_Choice *decl_choice;
extern Fl_Choice *decl_class_choice;
#include <FL/Fl_Tile.H>
extern fld::widget::Code_Editor *decl_input;
extern Fl_Text_Editor *decl_comment_input;
extern Fl_Return_Button *decl_panel_ok;
extern Fl_Button *decl_panel_cancel;
Fl_Double_Window* make_decl_panel();
extern Fl_Menu_Item menu_decl_choice[];
extern Fl_Menu_Item menu_decl_class_choice[];
extern Fl_Double_Window *data_panel;
extern Fl_Choice *data_choice;
extern Fl_Choice *data_class_choice;
extern Fl_Choice *data_mode;
extern Fl_Input *data_input;
extern Fl_Input *data_filename;
extern Fl_Button *data_filebrowser;
extern Fl_Text_Editor *data_comment_input;
extern Fl_Return_Button *data_panel_ok;
extern Fl_Button *data_panel_cancel;
Fl_Double_Window* make_data_panel();
extern Fl_Menu_Item menu_data_choice[];
extern Fl_Menu_Item menu_data_class_choice[];
extern Fl_Menu_Item menu_data_mode[];
extern Fl_Double_Window *class_panel;
extern Fl_Light_Button *c_public_button;
extern Fl_Input *c_name_input;
extern Fl_Input *c_subclass_input;
extern Fl_Text_Editor *c_comment_input;
extern Fl_Return_Button *c_panel_ok;
extern Fl_Button *c_panel_cancel;
Fl_Double_Window* make_class_panel();
extern Fl_Double_Window *comment_panel;
extern Fl_Text_Editor *comment_input;
extern Fl_Return_Button *comment_panel_ok;
extern Fl_Button *comment_panel_cancel;
extern Fl_Light_Button *comment_in_source;
extern Fl_Light_Button *comment_in_header;
#include <FL/Fl_Menu_Button.H>
extern Fl_Menu_Button *comment_predefined;
extern Fl_Button *comment_load;
Fl_Double_Window* make_comment_panel();
void type_make_cb(Fl_Widget*,void*d);
#include <FL/Fl_Window.H>
extern Fl_Window *widgetbin_panel;
#include <FL/Fl_Group.H>
#include <FL/Fl_Button.H>
Fl_Window* make_widgetbin();
#endif
+1
View File
@@ -2,6 +2,7 @@
version 1.0500
header_name {.h}
code_name {.cxx}
include_guard {}
comment {//
// FLUID template support for the Fast Light Tool Kit (FLTK).
//
File diff suppressed because it is too large Load Diff
+1970 -746
View File
File diff suppressed because it is too large Load Diff
+32
View File
@@ -43,6 +43,8 @@ extern Fl_Button *image_panel_close;
Fl_Double_Window* make_image_panel();
void run_image_panel();
void flex_margin_cb(Fl_Value_Input* i, void* v, void (*load_margin)(Fl_Flex*,Fl_Value_Input*), int (*update_margin)(Fl_Flex*,int));
#include <FL/Fl_Wizard.H>
extern Fl_Wizard *tabs_wizard;
#include <FL/Fl_Tabs.H>
extern Fl_Tabs *widget_tabs;
extern Fl_Group *wp_gui_tab;
@@ -105,6 +107,28 @@ extern Fl_Menu_Item whenmenu[];
extern Fl_Box *w_when_box;
extern Grid_Tab *widget_tab_grid;
extern Grid_Child_Tab *widget_tab_grid_child;
extern Fl_Tabs *data_tabs;
extern Fl_Group *data_tabs_data;
extern Fl_Input *wp_data_filename;
extern Fl_Tabs *comment_tabs;
extern Fl_Group *comment_tabs_comment;
extern Fl_Text_Editor *comment_tabs_name;
extern void load_comments_preset(Fl_Preferences &menu);
#include <FL/fl_string_functions.h>
extern Fl_Menu_Button *comment_predefined_2;
extern Fl_Button *comment_load_2;
extern Fl_Tabs *class_tabs;
extern Fl_Group *class_tabs_main;
extern Fl_Tabs *declblock_tabs;
extern Fl_Group *declblock_tabs_main;
extern Fl_Tabs *decl_tabs;
extern Fl_Group *decl_tabs_main;
extern Fl_Tabs *codeblock_tabs;
extern Fl_Group *codeblock_tabs_main;
extern Fl_Tabs *code_tabs;
extern Fl_Group *code_tabs_main;
extern Fl_Tabs *func_tabs;
extern Fl_Group *func_tabs_main;
extern Fl_Tabs *widget_tabs_repo;
extern void live_mode_cb(Fl_Button*, void*);
extern Fl_Button *wLiveMode;
@@ -119,4 +143,12 @@ extern Fl_Menu_Item menu_Children[];
extern Fl_Menu_Item menu_2[];
extern Fl_Menu_Item menu_3[];
extern Fl_Menu_Item menu_4[];
extern Fl_Menu_Item menu_5[];
extern Fl_Menu_Item menu_6[];
extern Fl_Menu_Item menu_7[];
extern Fl_Menu_Item menu_8[];
extern Fl_Menu_Item menu_9[];
extern Fl_Menu_Item menu_a[];
extern Fl_Menu_Item menu_b[];
extern Fl_Menu_Item menu_c[];
#endif
@@ -2,6 +2,7 @@
version 1.0500
header_name {.h}
code_name {.cxx}
include_guard {}
decl {\#include "widgets/Formula_Input.h"} {public global
}
+1
View File
@@ -2,6 +2,7 @@
version 1.0500
header_name {.h}
code_name {.cxx}
include_guard {}
decl {\#include "widgets/Formula_Input.h"} {public global
}
+35 -43
View File
@@ -23,6 +23,7 @@
#include "nodes/factory.h"
#include "nodes/Widget_Node.h"
#include "nodes/Window_Node.h"
#include "nodes/Function_Node.h"
#include "panels/widget_panel.h"
#include "panels/function_panel.h"
#include "panels/settings_panel.h"
@@ -401,6 +402,17 @@ void run_autodoc(const std::string &target_dir) {
select_only(t_grp);
Node *t_grd = add_new_widget_from_user("Fl_Grid", Strategy::AS_LAST_CHILD, false);
Node *t_grdc = add_new_widget_from_user("Fl_Button", Strategy::AS_LAST_CHILD, false);
Node *t_data = add_new_widget_from_user("Data", Strategy::AS_LAST_CHILD, false);
Node *t_comment = add_new_widget_from_user("Comment", Strategy::AS_LAST_CHILD, false);
t_comment->name("All work and no play make Jack a dull boy.");
Node *t_class = add_new_widget_from_user("Class", Strategy::AS_LAST_CHILD, false);
Node *t_decl = add_new_widget_from_user("Decl", Strategy::AS_LAST_CHILD, false);
t_decl->name("const char *damage = \"'tis but a scratch\";");
Node *t_func = add_new_widget_from_user("Function", Strategy::AS_LAST_CHILD, false);
Node *t_code = add_new_widget_from_user("Code", Strategy::AS_LAST_CHILD, false);
t_code->name("// increment user count\nif (new_user) {\n user_count++;\n}\n");
Node *t_codeblock = add_new_widget_from_user("CodeBlock", Strategy::AFTER_CURRENT, false);
Node *t_declblock = add_new_widget_from_user("DeclBlock", Strategy::AS_LAST_CHILD, false);
widget_browser->rebuild();
Fluid.proj.update_settings_dialog();
@@ -487,64 +499,39 @@ void run_autodoc(const std::string &target_dir) {
// ---- dialog types
// list and show all non-widget types and their respective dialog boxes
// Make sure we have a widget panel
t_win->open();
t_win->open();
// -- Type::Function
Fl_Window *adoc_function_panel = make_function_panel();
f_name_input->value("count_trees(const char *forest_name)");
f_return_type_input->value("unsigned int");
fl_snapshot((target_dir + "function_panel.png").c_str(), adoc_function_panel, win_margin, win_blend);
adoc_function_panel->hide();
select_only(t_func);
fl_snapshot((target_dir + "function_panel.png").c_str(), func_tabs_main, tab_margin, row_blend);
// -- Type::Code
Fl_Window *adoc_code_panel = make_code_panel();
code_input->buffer()->text("// increment user count\nif (new_user) {\n user_count++;\n}\n");
fl_snapshot((target_dir + "code_panel.png").c_str(), adoc_code_panel, win_margin, win_blend);
adoc_code_panel->hide();
select_only(t_code);
fl_snapshot((target_dir + "code_panel.png").c_str(), code_tabs_main, tab_margin, row_blend);
// -- Type::CodeBlock
Fl_Window *adoc_codeblock_panel = make_codeblock_panel();
code_before_input->value("if (test())");
code_after_input->value("// test widgets added...");
fl_snapshot((target_dir + "codeblock_panel.png").c_str(), adoc_codeblock_panel, win_margin, win_blend);
adoc_codeblock_panel->hide();
select_only(t_codeblock);
fl_snapshot((target_dir + "codeblock_panel.png").c_str(), declblock_tabs_main, tab_margin, row_blend);
// -- Type::Decl
Fl_Window *adoc_decl_panel = make_decl_panel();
decl_class_choice->hide();
decl_input->buffer()->text("const char *damage = \"'tis but a scratch\";");
fl_snapshot((target_dir + "decl_panel.png").c_str(), adoc_decl_panel, win_margin, win_blend);
adoc_decl_panel->hide();
select_only(t_decl);
fl_snapshot((target_dir + "decl_panel.png").c_str(), decl_tabs_main, tab_margin, row_blend);
// -- Type::DeclBlock
Fl_Window *adoc_declblock_panel = make_declblock_panel();
declblock_before_input->value("#ifdef NDEBUG");
declblock_after_input->value("#endif // NDEBUG");
fl_snapshot((target_dir + "declblock_panel.png").c_str(), adoc_declblock_panel, win_margin, win_blend);
adoc_declblock_panel->hide();
select_only(t_declblock);
fl_snapshot((target_dir + "declblock_panel.png").c_str(), declblock_tabs_main, tab_margin, row_blend);
// -- Type::Class
Fl_Window *adoc_class_panel = make_class_panel();
decl_class_choice->hide();
c_name_input->value("Zoo_Giraffe");
c_subclass_input->value("Zoo_Animal");
fl_snapshot((target_dir + "class_panel.png").c_str(), adoc_class_panel, win_margin, win_blend);
adoc_class_panel->hide();
select_only(t_class);
fl_snapshot((target_dir + "class_panel.png").c_str(), class_tabs_main, tab_margin, row_blend);
// -- Type::Widget_Class is handled like Window_Node
// -- Type::Comment
Fl_Window *adoc_comment_panel = make_comment_panel();
comment_input->buffer()->text("Make sure that the giraffe gets enough hay,\nbut the monkey can't reach it.");
fl_snapshot((target_dir + "comment_panel.png").c_str(), adoc_comment_panel, win_margin, win_blend);
adoc_comment_panel->hide();
// -- Type::Data
Fl_Window *adoc_data_panel = make_data_panel();
data_class_choice->hide();
data_input->value("emulated_ROM");
data_filename->value("./ROM.bin");
fl_snapshot((target_dir + "data_panel.png").c_str(), adoc_data_panel, win_margin, win_blend);
adoc_data_panel->hide();
select_only(t_comment);
fl_snapshot((target_dir + "comment_panel.png").c_str(), comment_tabs_comment, tab_margin, row_blend);
// ---- widget dialog
t_win->open(); // open the window
@@ -608,6 +595,11 @@ void run_autodoc(const std::string &target_dir) {
select_only(t_grdc);
widget_tabs->value(widget_tab_grid_child);
fl_snapshot((target_dir + "wp_gridc_tab.png").c_str(), widget_tab_grid_child, tab_margin, row_blend);
// -- Type::Data
select_only(t_data);
fl_snapshot((target_dir + "data_panel.png").c_str(), data_tabs_data, tab_margin, row_blend);
}
+15
View File
@@ -267,6 +267,21 @@ char *Fl_Text_Buffer::text() const {
}
/*
This function copies verbose whatever is in front and after the gap into a
single buffer.
*/
std::string Fl_Text_Buffer::text_str() const {
std::string t;
if (mLength) {
t.reserve(mLength);
t.insert(0, mBuf, mGapStart);
t.insert(mGapStart, mBuf+mGapEnd, mLength - mGapStart);
}
return t;
}
/*
Set the text buffer to a new string.
*/