summaryrefslogtreecommitdiff
path: root/fluid/Fl_Function_Type.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <git@matthiasm.com>2021-12-11 19:43:00 +0100
committerMatthias Melcher <github@matthiasm.com>2021-12-13 18:17:07 +0100
commit160832ce04f932fbb3df199aa01d1c93148bb292 (patch)
treed1ce303700666997a8608b7a488a25e633f07804 /fluid/Fl_Function_Type.cxx
parenta802aaeb170e3c233c5d92ae29d8703a0b9c2768 (diff)
STR 3442: copy/paste now inserts widget as expected.
Fluid would add pasted widgets as the last child of the current group, even if they were cut at the beginning of the group. This patch adds a 'startegy' to adding widgets to allow merging closer to the 'current' widget. Also added d'n'd for the widget bin and some other UI improvements. STR 3442: some preparation, variable renaming STR 3442: unifying functions to add widgets. Adding widgets interactively is merged into one function, making undo/redo work as expected and removing unexpected differences between adding by menu or bin. STR 3442: adding drag'n'drop for windows from bin. Just drag the window symbol out of the tree and drop it anywhere on the desktop. Visual representation of dragged Window. STR 3442: insert individual nodes after 'current' STR 3442: adding new widget at expected positions. The widget bin can finally do drag'n'drop. Widgets appear in the tree close to the last selection. Duplicating now ads right below. Cut and paste inserts after last selection. Fluid: replaced #define with strict enum type.
Diffstat (limited to 'fluid/Fl_Function_Type.cxx')
-rw-r--r--fluid/Fl_Function_Type.cxx52
1 files changed, 32 insertions, 20 deletions
diff --git a/fluid/Fl_Function_Type.cxx b/fluid/Fl_Function_Type.cxx
index 2f9a18075..ac367c7b9 100644
--- a/fluid/Fl_Function_Type.cxx
+++ b/fluid/Fl_Function_Type.cxx
@@ -187,15 +187,16 @@ Fl_Function_Type::~Fl_Function_Type() {
/**
Create a new function for the widget tree.
+ \param[in] strategy new function add after current or as last child
\return the new node
*/
-Fl_Type *Fl_Function_Type::make() {
+Fl_Type *Fl_Function_Type::make(Strategy strategy) {
Fl_Type *p = Fl_Type::current;
while (p && !p->is_decl_block()) p = p->parent;
Fl_Function_Type *o = new Fl_Function_Type();
o->name("make_window()");
o->return_type = 0;
- o->add(p);
+ o->add(p, strategy);
o->factory = this;
o->public_ = 1;
o->cdecl_ = 0;
@@ -556,8 +557,10 @@ Fl_Code_Type::Fl_Code_Type() :
Make a new code node.
If the parent node is not a function, a message box will pop up and
the request will be ignored.
+ \param[in] strategy add code after current or as last child
+ \return new Code node
*/
-Fl_Type *Fl_Code_Type::make() {
+Fl_Type *Fl_Code_Type::make(Strategy strategy) {
Fl_Type *p = Fl_Type::current;
while (p && !p->is_code_block()) p = p->parent;
if (!p) {
@@ -566,7 +569,7 @@ Fl_Type *Fl_Code_Type::make() {
}
Fl_Code_Type *o = new Fl_Code_Type();
o->name("printf(\"Hello, World!\\n\");");
- o->add(p);
+ o->add(p, strategy);
o->factory = this;
return o;
}
@@ -726,8 +729,10 @@ Fl_CodeBlock_Type::~Fl_CodeBlock_Type() {
Make a new code block.
If the parent node is not a function or another codeblock, a message box will
pop up and the request will be ignored.
+ \param[in] strategy add after current or as last child
+ \return new CodeBlock
*/
-Fl_Type *Fl_CodeBlock_Type::make() {
+Fl_Type *Fl_CodeBlock_Type::make(Strategy strategy) {
Fl_Type *p = Fl_Type::current;
while (p && !p->is_code_block()) p = p->parent;
if (!p) {
@@ -737,7 +742,7 @@ Fl_Type *Fl_CodeBlock_Type::make() {
Fl_CodeBlock_Type *o = new Fl_CodeBlock_Type();
o->name("if (test())");
o->after = 0;
- o->add(p);
+ o->add(p, strategy);
o->factory = this;
return o;
}
@@ -851,15 +856,17 @@ int Fl_Decl_Type::is_public() const
/**
Make a new declaration.
+ \param[in] strategy add after current or as last child
+ \return new Declaration node
*/
-Fl_Type *Fl_Decl_Type::make() {
+Fl_Type *Fl_Decl_Type::make(Strategy strategy) {
Fl_Type *p = Fl_Type::current;
while (p && !p->is_decl_block()) p = p->parent;
Fl_Decl_Type *o = new Fl_Decl_Type();
o->public_ = 0;
o->static_ = 1;
o->name("int x;");
- o->add(p);
+ o->add(p, strategy);
o->factory = this;
return o;
}
@@ -966,7 +973,7 @@ BREAK2:
/**
Write the code to the source and header files.
\todo There are a lot of side effect in this node depending on the given text
- and the parent node which should really be documented.
+ and the parent node. They need to be understood and documented.
*/
void Fl_Decl_Type::write_code1() {
const char* c = name();
@@ -1063,8 +1070,10 @@ Fl_Data_Type::~Fl_Data_Type() {
/**
Create an empty inline data node.
+ \param[in] strategy add after current or as last child
+ \return new inline data node
*/
-Fl_Type *Fl_Data_Type::make() {
+Fl_Type *Fl_Data_Type::make(Strategy strategy) {
Fl_Type *p = Fl_Type::current;
while (p && !p->is_decl_block()) p = p->parent;
Fl_Data_Type *o = new Fl_Data_Type();
@@ -1073,7 +1082,7 @@ Fl_Type *Fl_Data_Type::make() {
o->filename_ = 0;
o->text_mode_ = 0;
o->name("myInlineData");
- o->add(p);
+ o->add(p, strategy);
o->factory = this;
return o;
}
@@ -1352,15 +1361,17 @@ int Fl_DeclBlock_Type::is_public() const {return public_;}
/**
Create a new declaration block.
+ \param[in] strategy add after current or as last child
+ \return new Declaration Blocknode
*/
-Fl_Type *Fl_DeclBlock_Type::make() {
+Fl_Type *Fl_DeclBlock_Type::make(Strategy strategy) {
Fl_Type *p = Fl_Type::current;
while (p && !p->is_decl_block()) p = p->parent;
Fl_DeclBlock_Type *o = new Fl_DeclBlock_Type();
o->name("#if 1");
o->public_ = 0;
o->after = fl_strdup("#endif");
- o->add(p);
+ o->add(p, strategy);
o->factory = this;
return o;
}
@@ -1479,8 +1490,10 @@ Fl_Comment_Type::Fl_Comment_Type() :
/**
Make a new comment node.
+ \param[in] strategy add after current or as last child
+ \return new Comment node
*/
-Fl_Type *Fl_Comment_Type::make() {
+Fl_Type *Fl_Comment_Type::make(Strategy strategy) {
Fl_Type *p = Fl_Type::current;
while (p && !p->is_code_block()) p = p->parent;
Fl_Comment_Type *o = new Fl_Comment_Type();
@@ -1488,7 +1501,7 @@ Fl_Type *Fl_Comment_Type::make() {
o->in_h_ = 1;
o->style_ = 0;
o->name("my comment");
- o->add(p);
+ o->add(p, strategy);
o->factory = this;
o->title_buf[0] = 0;
return o;
@@ -1735,9 +1748,6 @@ void Fl_Comment_Type::write_code1() {
/** \class Fl_Class_Type
Manage a class declaration and implementation.
-
- \todo This is pretty complex and needs to be revisited to give
- a good description.
*/
/// Prototype for a class node to be used by the factory.
@@ -1780,8 +1790,10 @@ void Fl_Class_Type::prefix(const char*p) {
/**
Make a new class node.
+ \param[in] strategy add after current or as last child
+ \return new Class node
*/
-Fl_Type *Fl_Class_Type::make() {
+Fl_Type *Fl_Class_Type::make(Strategy strategy) {
Fl_Type *p = Fl_Type::current;
while (p && !p->is_decl_block()) p = p->parent;
Fl_Class_Type *o = new Fl_Class_Type();
@@ -1789,7 +1801,7 @@ Fl_Type *Fl_Class_Type::make() {
o->class_prefix = NULL;
o->subclass_of = NULL;
o->public_ = 1;
- o->add(p);
+ o->add(p, strategy);
o->factory = this;
return o;
}