summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2023-10-31 22:00:29 +0100
committerMatthias Melcher <github@matthiasm.com>2023-10-31 22:00:38 +0100
commit8bd1bd71622df37f097b04746a98389ddb890558 (patch)
treee1ac3dde93bb660deab8013f7e50ec85c4bf8f22
parent4b02c3614971f9334514e3f37cc27686c6485e2b (diff)
FLUID: Improves interactive handling of Grid and Flex
-rw-r--r--fluid/Fl_Grid_Type.cxx19
-rw-r--r--fluid/Fl_Grid_Type.h8
-rw-r--r--fluid/Fl_Group_Type.cxx46
-rw-r--r--fluid/Fl_Group_Type.h39
-rw-r--r--fluid/Fl_Type.cxx2
-rw-r--r--fluid/Fl_Type.h3
-rw-r--r--fluid/Fl_Window_Type.cxx22
-rw-r--r--fluid/align_widget.cxx143
-rw-r--r--fluid/alignment_panel.cxx2
-rw-r--r--fluid/alignment_panel.fl8
-rw-r--r--fluid/sourceview_panel.fl2365
11 files changed, 156 insertions, 501 deletions
diff --git a/fluid/Fl_Grid_Type.cxx b/fluid/Fl_Grid_Type.cxx
index 383785778..dfcbe3d28 100644
--- a/fluid/Fl_Grid_Type.cxx
+++ b/fluid/Fl_Grid_Type.cxx
@@ -39,11 +39,21 @@ const char grid_type_name[] = "Fl_Grid";
Fl_Grid_Type Fl_Grid_type; // the "factory"
+// Override group's resize behavior to do nothing to children:
+void Fl_Grid_Proxy::resize(int X, int Y, int W, int H) {
+ if (Fl_Type::allow_layout > 0) {
+ Fl_Grid::resize(X, Y, W, H);
+ } else {
+ Fl_Widget::resize(X, Y, W, H);
+ }
+ redraw();
+}
+
Fl_Grid_Type::Fl_Grid_Type() {
}
Fl_Widget *Fl_Grid_Type::widget(int X,int Y,int W,int H) {
- Fl_Grid *g = new Fl_Grid(X,Y,W,H);
+ Fl_Grid *g = new Fl_Grid_Proxy(X,Y,W,H);
g->layout(3, 3);
g->show_grid(1, FL_RED);
Fl_Group::current(0);
@@ -654,3 +664,10 @@ void grid_align_cb(Fl_Choice* i, void* v) {
}
}
}
+
+void Fl_Grid_Type::layout_widget() {
+ allow_layout++;
+ ((Fl_Grid*)o)->need_layout(1);
+ allow_layout--;
+}
+
diff --git a/fluid/Fl_Grid_Type.h b/fluid/Fl_Grid_Type.h
index 358489469..23f94c628 100644
--- a/fluid/Fl_Grid_Type.h
+++ b/fluid/Fl_Grid_Type.h
@@ -18,11 +18,18 @@
#define _FLUID_FL_GRID_TYPE_H
#include "Fl_Group_Type.h"
+#include <FL/Fl_Grid.H>
// ---- Fl_Grid_Type --------------------------------------------------- MARK: -
extern const char grid_type_name[];
+class Fl_Grid_Proxy : public Fl_Grid {
+public:
+ Fl_Grid_Proxy(int X,int Y,int W,int H) : Fl_Grid(X,Y,W,H) {}
+ void resize(int,int,int,int) FL_OVERRIDE;
+};
+
class Fl_Grid_Type : public Fl_Group_Type
{
typedef Fl_Group_Type super;
@@ -44,6 +51,7 @@ public:
void add_child(Fl_Type*, Fl_Type*) FL_OVERRIDE;
void move_child(Fl_Type*, Fl_Type*) FL_OVERRIDE;
void remove_child(Fl_Type*) FL_OVERRIDE;
+ void layout_widget() FL_OVERRIDE;
void child_resized(Fl_Widget_Type *child);
void insert_child_at(Fl_Widget *child, int x, int y);
void insert_child(Fl_Widget *child);
diff --git a/fluid/Fl_Group_Type.cxx b/fluid/Fl_Group_Type.cxx
index 4efa2dc14..c66e4daab 100644
--- a/fluid/Fl_Group_Type.cxx
+++ b/fluid/Fl_Group_Type.cxx
@@ -42,9 +42,17 @@
Fl_Group_Type Fl_Group_type; // the "factory"
-// Override group's resize behavior to do nothing to children:
-void igroup::resize(int X, int Y, int W, int H) {
- Fl_Widget::resize(X,Y,W,H);
+/**
+ Override group's resize behavior to do nothing to children by default.
+
+ \param[in] X, Y, W, H new size
+ */
+void Fl_Group_Proxy::resize(int X, int Y, int W, int H) {
+ if (Fl_Type::allow_layout > 0) {
+ Fl_Group::resize(X, Y, W, H);
+ } else {
+ Fl_Widget::resize(X, Y, W, H);
+ }
redraw();
}
@@ -230,6 +238,20 @@ Fl_Menu_Item flex_type_menu[] = {
Fl_Flex_Type Fl_Flex_type; // the "factory"
+/**
+ Override flex's resize behavior to do nothing to children by default.
+
+ \param[in] X, Y, W, H new size
+ */
+void Fl_Flex_Proxy::resize(int X, int Y, int W, int H) {
+ if (Fl_Type::allow_layout > 0) {
+ Fl_Flex::resize(X, Y, W, H);
+ } else {
+ Fl_Widget::resize(X, Y, W, H);
+ }
+ redraw();
+}
+
Fl_Widget *Fl_Flex_Type::enter_live_mode(int) {
Fl_Flex *grp = new Fl_Flex(o->x(), o->y(), o->w(), o->h());
propagate_live_mode(grp);
@@ -367,7 +389,9 @@ void Fl_Flex_Type::remove_child(Fl_Type* a) {
}
void Fl_Flex_Type::layout_widget() {
+ allow_layout++;
((Fl_Flex*)o)->layout();
+ allow_layout--;
}
// Change from HORIZONTAL to VERTICAL or back.
@@ -565,8 +589,12 @@ Fl_Tabs_Type Fl_Tabs_type; // the "factory"
const char tabs_type_name[] = "Fl_Tabs";
// Override group's resize behavior to do nothing to children:
-void itabs::resize(int X, int Y, int W, int H) {
- Fl_Widget::resize(X,Y,W,H);
+void Fl_Tabs_Proxy::resize(int X, int Y, int W, int H) {
+ if (Fl_Type::allow_layout > 0) {
+ Fl_Tabs::resize(X, Y, W, H);
+ } else {
+ Fl_Widget::resize(X, Y, W, H);
+ }
redraw();
}
@@ -655,7 +683,11 @@ Fl_Wizard_Type Fl_Wizard_type; // the "factory"
const char wizard_type_name[] = "Fl_Wizard";
// Override group's resize behavior to do nothing to children:
-void iwizard::resize(int X, int Y, int W, int H) {
- Fl_Widget::resize(X,Y,W,H);
+void Fl_Wizard_Proxy::resize(int X, int Y, int W, int H) {
+ if (Fl_Type::allow_layout > 0) {
+ Fl_Wizard::resize(X, Y, W, H);
+ } else {
+ Fl_Widget::resize(X, Y, W, H);
+ }
redraw();
}
diff --git a/fluid/Fl_Group_Type.h b/fluid/Fl_Group_Type.h
index 36a4821df..fb8feb16d 100644
--- a/fluid/Fl_Group_Type.h
+++ b/fluid/Fl_Group_Type.h
@@ -29,11 +29,18 @@ void ungroup_cb(Fl_Widget *, void *);
// ---- Fl_Group_Type -------------------------------------------------- MARK: -
-class igroup : public Fl_Group {
+/**
+ Proxy group to use in place of Fl_Group in the interactive window.
+
+ In an interactive environment, groups should not automatically resize their
+ children. This proxy disables the layout of children by default. Children
+ layout propagation may be enable temporarily by incrementing `allow_layout`
+ before resizing and decrementing it again afterwards.
+ */
+class Fl_Group_Proxy : public Fl_Group {
public:
- void resize(int,int,int,int) FL_OVERRIDE;
- void full_resize(int X, int Y, int W, int H) { Fl_Group::resize(X, Y, W, H); }
- igroup(int X,int Y,int W,int H) : Fl_Group(X,Y,W,H) {Fl_Group::current(0);}
+ Fl_Group_Proxy(int X,int Y,int W,int H) : Fl_Group(X, Y, W, H) { Fl_Group::current(0); }
+ void resize(int x, int y, int w, int h) FL_OVERRIDE;
};
class Fl_Group_Type : public Fl_Widget_Type
@@ -44,7 +51,7 @@ public:
const char *type_name() FL_OVERRIDE {return "Fl_Group";}
const char *alt_type_name() FL_OVERRIDE {return "fltk::Group";}
Fl_Widget *widget(int X,int Y,int W,int H) FL_OVERRIDE {
- igroup *g = new igroup(X,Y,W,H); Fl_Group::current(0); return g;}
+ Fl_Group_Proxy *g = new Fl_Group_Proxy(X,Y,W,H); Fl_Group::current(0); return g;}
Fl_Widget_Type *_make() FL_OVERRIDE {return new Fl_Group_Type();}
void write_code1(Fd_Code_Writer& f) FL_OVERRIDE;
void write_code2(Fd_Code_Writer& f) FL_OVERRIDE;
@@ -83,6 +90,12 @@ public:
extern const char flex_type_name[];
extern Fl_Menu_Item flex_type_menu[];
+class Fl_Flex_Proxy : public Fl_Flex {
+public:
+ Fl_Flex_Proxy(int X,int Y,int W,int H) : Fl_Flex(X, Y, W, H) { Fl_Group::current(0); }
+ void resize(int x, int y, int w, int h) FL_OVERRIDE;
+};
+
class Fl_Flex_Type : public Fl_Group_Type
{
typedef Fl_Group_Type super;
@@ -96,7 +109,7 @@ public:
const char *alt_type_name() FL_OVERRIDE {return "fltk::FlexGroup";}
Fl_Widget_Type *_make() FL_OVERRIDE { return new Fl_Flex_Type(); }
Fl_Widget *widget(int X,int Y,int W,int H) FL_OVERRIDE {
- Fl_Flex *g = new Fl_Flex(X,Y,W,H); Fl_Group::current(0); return g;}
+ Fl_Flex *g = new Fl_Flex_Proxy(X,Y,W,H); Fl_Group::current(0); return g;}
ID id() const FL_OVERRIDE { return ID_Flex; }
bool is_a(ID inID) const FL_OVERRIDE { return (inID==ID_Flex) ? true : super::is_a(inID); }
void write_properties(Fd_Project_Writer &f) FL_OVERRIDE;
@@ -138,11 +151,10 @@ public:
extern const char tabs_type_name[];
-class itabs : public Fl_Tabs {
+class Fl_Tabs_Proxy : public Fl_Tabs {
public:
+ Fl_Tabs_Proxy(int X,int Y,int W,int H) : Fl_Tabs(X,Y,W,H) {}
void resize(int,int,int,int) FL_OVERRIDE;
- void full_resize(int X, int Y, int W, int H) { Fl_Group::resize(X, Y, W, H); }
- itabs(int X,int Y,int W,int H) : Fl_Tabs(X,Y,W,H) {}
};
class Fl_Tabs_Type : public Fl_Group_Type
@@ -152,7 +164,7 @@ public:
const char *type_name() FL_OVERRIDE {return tabs_type_name;}
const char *alt_type_name() FL_OVERRIDE {return "fltk::TabGroup";}
Fl_Widget *widget(int X,int Y,int W,int H) FL_OVERRIDE {
- itabs *g = new itabs(X,Y,W,H); Fl_Group::current(0); return g;}
+ Fl_Tabs_Proxy *g = new Fl_Tabs_Proxy(X,Y,W,H); Fl_Group::current(0); return g;}
Fl_Widget_Type *_make() FL_OVERRIDE {return new Fl_Tabs_Type();}
Fl_Type* click_test(int,int) FL_OVERRIDE;
void add_child(Fl_Type*, Fl_Type*) FL_OVERRIDE;
@@ -199,11 +211,10 @@ public:
// ---- Fl_Wizard_Type ------------------------------------------------- MARK: -
-class iwizard : public Fl_Wizard {
+class Fl_Wizard_Proxy : public Fl_Wizard {
public:
+ Fl_Wizard_Proxy(int X,int Y,int W,int H) : Fl_Wizard(X,Y,W,H) {}
void resize(int,int,int,int) FL_OVERRIDE;
- void full_resize(int X, int Y, int W, int H) { Fl_Group::resize(X, Y, W, H); }
- iwizard(int X,int Y,int W,int H) : Fl_Wizard(X,Y,W,H) {}
};
extern const char wizard_type_name[];
@@ -215,7 +226,7 @@ public:
const char *type_name() FL_OVERRIDE {return wizard_type_name;}
const char *alt_type_name() FL_OVERRIDE {return "fltk::WizardGroup";}
Fl_Widget *widget(int X,int Y,int W,int H) FL_OVERRIDE {
- iwizard *g = new iwizard(X,Y,W,H); Fl_Group::current(0); return g;}
+ Fl_Wizard_Proxy *g = new Fl_Wizard_Proxy(X,Y,W,H); Fl_Group::current(0); return g;}
Fl_Widget_Type *_make() FL_OVERRIDE {return new Fl_Wizard_Type();}
ID id() const FL_OVERRIDE { return ID_Wizard; }
bool is_a(ID inID) const FL_OVERRIDE { return (inID==ID_Wizard) ? true : super::is_a(inID); }
diff --git a/fluid/Fl_Type.cxx b/fluid/Fl_Type.cxx
index a4e39373c..dc514e90a 100644
--- a/fluid/Fl_Type.cxx
+++ b/fluid/Fl_Type.cxx
@@ -123,9 +123,11 @@ Fl_Type *Fl_Type::first = NULL;
Fl_Type *Fl_Type::last = NULL;
Fl_Type *Fl_Type::current = NULL;
Fl_Type *Fl_Type::current_dnd = NULL;
+int Fl_Type::allow_layout = 0;
Fl_Type *in_this_only; // set if menu popped-up in window
+
// ---- various functions
void select_all_cb(Fl_Widget *,void *) {
diff --git a/fluid/Fl_Type.h b/fluid/Fl_Type.h
index 7e2072228..f1ab02025 100644
--- a/fluid/Fl_Type.h
+++ b/fluid/Fl_Type.h
@@ -263,6 +263,9 @@ public:
static Fl_Type *find_by_uid(unsigned short uid);
static Fl_Type *find_in_text(int text_type, int crsr);
+
+ /// If this is greater zero, widgets will be allowed to lay out their children.
+ static int allow_layout;
};
#endif // _FLUID_FL_TYPE_H
diff --git a/fluid/Fl_Window_Type.cxx b/fluid/Fl_Window_Type.cxx
index 433fc5863..2cf39e9da 100644
--- a/fluid/Fl_Window_Type.cxx
+++ b/fluid/Fl_Window_Type.cxx
@@ -822,7 +822,13 @@ void Fl_Window_Type::moveallchildren()
Fl_Widget_Type* myo = (Fl_Widget_Type*)i;
int x,y,r,t,ow=myo->o->w(),oh=myo->o->h();
newposition(myo,x,y,r,t);
- myo->o->resize(x,y,r-x,t-y);
+ if (myo->is_a(ID_Flex) || myo->is_a(ID_Grid)) {
+ allow_layout++;
+ myo->o->resize(x,y,r-x,t-y);
+ allow_layout--;
+ } else {
+ myo->o->resize(x,y,r-x,t-y);
+ }
if (Fl_Flex_Type::parent_is_flex(myo)) {
Fl_Flex_Type* ft = (Fl_Flex_Type*)myo->parent;
Fl_Flex* f = (Fl_Flex*)ft->o;
@@ -837,15 +843,21 @@ void Fl_Window_Type::moveallchildren()
f->layout();
}
}
- }
- if (myo->parent && myo->parent->is_a(ID_Grid)) {
+ } else if (myo->parent && myo->parent->is_a(ID_Grid)) {
Fl_Grid_Type* gt = (Fl_Grid_Type*)myo->parent;
- gt->child_resized(myo);
+ if (drag & FD_DRAG) {
+ gt->insert_child_at(myo->o, Fl::event_x(), Fl::event_y());
+ } else {
+ gt->child_resized(myo);
+ }
+ } else if (myo->parent && myo->parent->is_a(ID_Group)) {
+ Fl_Group_Type* gt = (Fl_Group_Type*)myo->parent;
+ ((Fl_Group*)gt->o)->init_sizes();
}
// move all the children, whether selected or not:
Fl_Type* p;
for (p = myo->next; p && p->level>myo->level; p = p->next)
- if (p->is_true_widget() && !myo->is_a(ID_Flex)) {
+ if (p->is_true_widget() && !myo->is_a(ID_Flex) && !myo->is_a(ID_Grid)) {
Fl_Widget_Type* myo2 = (Fl_Widget_Type*)p;
int X,Y,R,T;
newposition(myo2,X,Y,R,T);
diff --git a/fluid/align_widget.cxx b/fluid/align_widget.cxx
index 6bf7afee6..56cbd7c87 100644
--- a/fluid/align_widget.cxx
+++ b/fluid/align_widget.cxx
@@ -59,14 +59,9 @@ void align_widget_cb(Fl_Widget*, long how)
undo_checkpoint();
}
Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
- if (o->next && o->next->level > o->level && !o->next->selected &&
- !o->is_a(ID_Menu_Manager_)) {
- // When resizing a group, make sure we also move the children...
- ((igroup *)w)->full_resize(left, w->y(), w->w(), w->h());
- } else {
- // Otherwise, just do the widget...
- w->resize(left, w->y(), w->w(), w->h());
- }
+ Fl_Type::allow_layout++;
+ w->resize(left, w->y(), w->w(), w->h());
+ Fl_Type::allow_layout--;
w->redraw();
if (w->window()) w->window()->redraw();
}
@@ -94,14 +89,9 @@ void align_widget_cb(Fl_Widget*, long how)
undo_checkpoint();
}
Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
- if (o->next && o->next->level > o->level && !o->next->selected &&
- !o->is_a(ID_Menu_Manager_)) {
- // When resizing a group, make sure we also move the children...
- ((igroup *)w)->full_resize((center2-w->w())/2, w->y(), w->w(), w->h());
- } else {
- // Otherwise, just do the widget...
- w->resize((center2-w->w())/2, w->y(), w->w(), w->h());
- }
+ Fl_Type::allow_layout++;
+ w->resize((center2-w->w())/2, w->y(), w->w(), w->h());
+ Fl_Type::allow_layout--;
w->redraw();
if (w->window()) w->window()->redraw();
}
@@ -126,14 +116,9 @@ void align_widget_cb(Fl_Widget*, long how)
undo_checkpoint();
}
Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
- if (o->next && o->next->level > o->level && !o->next->selected &&
- !o->is_a(ID_Menu_Manager_)) {
- // When resizing a group, make sure we also move the children...
- ((igroup *)w)->full_resize(right-w->w(), w->y(), w->w(), w->h());
- } else {
- // Otherwise, just do the widget...
- w->resize(right-w->w(), w->y(), w->w(), w->h());
- }
+ Fl_Type::allow_layout++;
+ w->resize(right-w->w(), w->y(), w->w(), w->h());
+ Fl_Type::allow_layout--;
w->redraw();
if (w->window()) w->window()->redraw();
}
@@ -157,14 +142,9 @@ void align_widget_cb(Fl_Widget*, long how)
undo_checkpoint();
}
Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
- if (o->next && o->next->level > o->level && !o->next->selected &&
- !o->is_a(ID_Menu_Manager_)) {
- // When resizing a group, make sure we also move the children...
- ((igroup *)w)->full_resize(w->x(), top, w->w(), w->h());
- } else {
- // Otherwise, just do the widget...
- w->resize(w->x(), top, w->w(), w->h());
- }
+ Fl_Type::allow_layout++;
+ w->resize(w->x(), top, w->w(), w->h());
+ Fl_Type::allow_layout--;
w->redraw();
if (w->window()) w->window()->redraw();
}
@@ -192,14 +172,9 @@ void align_widget_cb(Fl_Widget*, long how)
undo_checkpoint();
}
Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
- if (o->next && o->next->level > o->level && !o->next->selected &&
- !o->is_a(ID_Menu_Manager_)) {
- // When resizing a group, make sure we also move the children...
- ((igroup *)w)->full_resize(w->x(), (center2-w->h())/2, w->w(), w->h());
- } else {
- // Otherwise, just do the widget...
- w->resize(w->x(), (center2-w->h())/2, w->w(), w->h());
- }
+ Fl_Type::allow_layout++;
+ w->resize(w->x(), (center2-w->h())/2, w->w(), w->h());
+ Fl_Type::allow_layout--;
w->redraw();
if (w->window()) w->window()->redraw();
}
@@ -224,14 +199,9 @@ void align_widget_cb(Fl_Widget*, long how)
undo_checkpoint();
}
Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
- if (o->next && o->next->level > o->level && !o->next->selected &&
- !o->is_a(ID_Menu_Manager_)) {
- // When resizing a group, make sure we also move the children...
- ((igroup *)w)->full_resize( w->x(), bot-w->h(), w->w(), w->h());
- } else {
- // Otherwise, just do the widget...
- w->resize( w->x(), bot-w->h(), w->w(), w->h());
- }
+ Fl_Type::allow_layout++;
+ w->resize( w->x(), bot-w->h(), w->w(), w->h());
+ Fl_Type::allow_layout--;
w->redraw();
if (w->window()) w->window()->redraw();
}
@@ -264,14 +234,9 @@ void align_widget_cb(Fl_Widget*, long how)
undo_checkpoint();
}
Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
- if (o->next && o->next->level > o->level && !o->next->selected &&
- !o->is_a(ID_Menu_Manager_)) {
- // When resizing a group, make sure we also move the children...
- ((igroup *)w)->full_resize(left+wsum+wdt*cnt/n, w->y(), w->w(), w->h());
- } else {
- // Otherwise, just do the widget...
- w->resize(left+wsum+wdt*cnt/n, w->y(), w->w(), w->h());
- }
+ Fl_Type::allow_layout++;
+ w->resize(left+wsum+wdt*cnt/n, w->y(), w->w(), w->h());
+ Fl_Type::allow_layout--;
w->redraw();
if (w->window()) w->window()->redraw();
cnt++;
@@ -306,14 +271,9 @@ void align_widget_cb(Fl_Widget*, long how)
undo_checkpoint();
}
Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
- if (o->next && o->next->level > o->level && !o->next->selected &&
- !o->is_a(ID_Menu_Manager_)) {
- // When resizing a group, make sure we also move the children...
- ((igroup *)w)->full_resize(w->x(), top+hsum+hgt*cnt/n, w->w(), w->h());
- } else {
- // Otherwise, just do the widget...
- w->resize(w->x(), top+hsum+hgt*cnt/n, w->w(), w->h());
- }
+ Fl_Type::allow_layout++;
+ w->resize(w->x(), top+hsum+hgt*cnt/n, w->w(), w->h());
+ Fl_Type::allow_layout--;
w->redraw();
if (w->window()) w->window()->redraw();
cnt++;
@@ -341,14 +301,9 @@ void align_widget_cb(Fl_Widget*, long how)
undo_checkpoint();
}
Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
- if (o->next && o->next->level > o->level && !o->next->selected &&
- !o->is_a(ID_Menu_Manager_)) {
- // When resizing a group, make sure we also move the children...
- ((igroup *)w)->full_resize(w->x(), w->y(), wdt, w->h());
- } else {
- // Otherwise, just do the widget...
- w->resize(w->x(), w->y(), wdt, w->h());
- }
+ Fl_Type::allow_layout++;
+ w->resize(w->x(), w->y(), wdt, w->h());
+ Fl_Type::allow_layout--;
w->redraw();
if (w->window()) w->window()->redraw();
}
@@ -372,14 +327,9 @@ void align_widget_cb(Fl_Widget*, long how)
undo_checkpoint();
}
Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
- if (o->next && o->next->level > o->level && !o->next->selected &&
- !o->is_a(ID_Menu_Manager_)) {
- // When resizing a group, make sure we also move the children...
- ((igroup *)w)->full_resize( w->x(), w->y(), w->w(), hgt);
- } else {
- // Otherwise, just do the widget...
- w->resize( w->x(), w->y(), w->w(), hgt);
- }
+ Fl_Type::allow_layout++;
+ w->resize( w->x(), w->y(), w->w(), hgt);
+ Fl_Type::allow_layout--;
w->redraw();
if (w->window()) w->window()->redraw();
}
@@ -405,14 +355,9 @@ void align_widget_cb(Fl_Widget*, long how)
undo_checkpoint();
}
Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
- if (o->next && o->next->level > o->level && !o->next->selected &&
- !o->is_a(ID_Menu_Manager_)) {
- // When resizing a group, make sure we also move the children...
- ((igroup *)w)->full_resize( w->x(), w->y(), wdt, hgt);
- } else {
- // Otherwise, just do the widget...
- w->resize( w->x(), w->y(), wdt, hgt);
- }
+ Fl_Type::allow_layout++;
+ w->resize( w->x(), w->y(), wdt, hgt);
+ Fl_Type::allow_layout--;
w->redraw();
if (w->window()) w->window()->redraw();
}
@@ -433,14 +378,9 @@ void align_widget_cb(Fl_Widget*, long how)
if (w->window() == p) center2 = p->w();
else center2 = 2*p->x()+p->w();
- if (o->next && o->next->level > o->level && !o->next->selected &&
- !o->is_a(ID_Menu_Manager_)) {
- // When resizing a group, make sure we also move the children...
- ((igroup *)w)->full_resize((center2-w->w())/2, w->y(), w->w(), w->h());
- } else {
- // Otherwise, just do the widget...
- w->resize((center2-w->w())/2, w->y(), w->w(), w->h());
- }
+ Fl_Type::allow_layout++;
+ w->resize((center2-w->w())/2, w->y(), w->w(), w->h());
+ Fl_Type::allow_layout--;
w->redraw();
if (w->window()) w->window()->redraw();
}
@@ -460,14 +400,9 @@ void align_widget_cb(Fl_Widget*, long how)
if (w->window() == p) center2 = p->h();
else center2 = 2*p->y()+p->h();
- if (o->next && o->next->level > o->level && !o->next->selected &&
- !o->is_a(ID_Menu_Manager_)) {
- // When resizing a group, make sure we also move the children...
- ((igroup *)w)->full_resize(w->x(), (center2-w->h())/2, w->w(), w->h());
- } else {
- // Otherwise, just do the widget...
- w->resize(w->x(), (center2-w->h())/2, w->w(), w->h());
- }
+ Fl_Type::allow_layout++;
+ w->resize(w->x(), (center2-w->h())/2, w->w(), w->h());
+ Fl_Type::allow_layout--;
set_modflag(1);
w->redraw();
if (w->window()) w->window()->redraw();
diff --git a/fluid/alignment_panel.cxx b/fluid/alignment_panel.cxx
index 8bb4ac2a3..86100fe0e 100644
--- a/fluid/alignment_panel.cxx
+++ b/fluid/alignment_panel.cxx
@@ -2136,7 +2136,6 @@ Fl_Double_Window* make_settings_window() {
{ Fl_Group* o = new Fl_Group(10, 60, 320, 480, "General");
o->image( image_general_64() );
o->labelsize(11);
- o->hide();
{ Fl_Group* o = new Fl_Group(120, 78, 130, 25);
o->callback((Fl_Callback*)cb_);
{ scheme_choice = new Fl_Scheme_Choice(120, 78, 120, 25, "Scheme: ");
@@ -2276,6 +2275,7 @@ ps");
w_settings_project_tab->image( image_document_64() );
w_settings_project_tab->labelsize(11);
w_settings_project_tab->callback((Fl_Callback*)cb_w_settings_project_tab);
+ w_settings_project_tab->hide();
{ Fl_Group* o = new Fl_Group(100, 78, 220, 30);
{ Fl_Box* o = new Fl_Box(100, 78, 210, 30, "Use \"name.ext\" to set a file name\nor just \".ext\" to set extension.");
o->labelsize(11);
diff --git a/fluid/alignment_panel.fl b/fluid/alignment_panel.fl
index f64f7c52e..0316ad1b4 100644
--- a/fluid/alignment_panel.fl
+++ b/fluid/alignment_panel.fl
@@ -145,7 +145,7 @@ script_input->linenumber_width(60);
script_input->linenumber_size(script_input->Fl_Text_Display::textsize());} {}
}
-Function {make_settings_window()} {open
+Function {make_settings_window()} {open selected
} {
Fl_Window settings_window {
label {FLUID Settings} open
@@ -157,7 +157,7 @@ Function {make_settings_window()} {open
} {
Fl_Group {} {
label General open
- image {icons/general_64.png} compress_image 1 xywh {10 60 320 480} labelsize 11 hide resizable
+ image {icons/general_64.png} compress_image 1 xywh {10 60 320 480} labelsize 11 resizable
code0 {o->image()->scale(36, 24);}
} {
Fl_Group {} {
@@ -287,7 +287,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
+ image {icons/document_64.png} compress_image 1 xywh {10 60 320 480} labelsize 11 hide
code0 {o->image()->scale(36, 24);}
} {
Fl_Group {} {open
@@ -394,7 +394,7 @@ or just ".ext" to set extension.}
g_project.write_mergeback_data = o->value();
}
}}
- comment {// Matt: disabled} selected
+ comment {// Matt: disabled}
tooltip {MergeBack is a feature under construction that allows changes in code files to be merged back into the project file. Checking this option will generate additional data in code and project files.} xywh {100 283 220 20} down_box DOWN_BOX labelsize 11 hide
}
Fl_Box {} {
diff --git a/fluid/sourceview_panel.fl2 b/fluid/sourceview_panel.fl2
deleted file mode 100644
index bc4179292..000000000
--- a/fluid/sourceview_panel.fl2
+++ /dev/null
@@ -1,365 +0,0 @@
-# data file for the Fltk User Interface Designer (fluid)
-version 1.0400
-header_name {.h}
-code_name {.cxx}
-comment {//
-// Code dialogs for the Fast Light Tool Kit (FLTK).
-//
-// Copyright 1998-2023 by Bill Spitzak and others.
-//
-// This library is free software. Distribution and use rights are outlined in
-// the file "COPYING" which should have been included with this file. If this
-// file is missing or damaged, see the license at:
-//
-// https://www.fltk.org/COPYING.php
-//
-// Please see the following page on how to report bugs and issues:
-//
-// https://www.fltk.org/bugs.php
-//
-} {in_source in_header
-}
-
-decl {\#include "fluid.h"} {private local
-}
-
-decl {\#include "file.h"} {private local
-}
-
-decl {\#include "../src/flstring.h"} {private local
-}
-
-decl {\#include <FL/Fl_Tabs.H>} {private local
-}
-
-decl {\#include <FL/Fl_Button.H>} {private local
-}
-
-decl {char *sv_source_filename = NULL;} {private local
-}
-
-decl {char *sv_header_filename = NULL;} {private local
-}
-
-decl {char *sv_design_filename = NULL;} {private local
-}
-
-decl {int sv_code_choice;} {public local
-}
-
-Function {update_sourceview_position()} {
- comment {Update the header and source code highlighting depending on the
-currently selected object
-
-The Source View system offers an immediate preview of the code
-files that will be generated by FLUID. It also marks the code
-generated for the last selected item in the header and the source
-file.} open return_type void
-} {
- code {if (!sourceview_panel || !sourceview_panel->visible())
- return;
- if (sv_autoposition->value()==0)
- return;
- if (sourceview_panel && sourceview_panel->visible() && Fl_Type::current) {
- int pos0, pos1;
- if (sv_source->visible_r()) {
- switch (sv_code_choice) {
- case 0: // prolog: not yet (include statements)
- pos0 = Fl_Type::current->code1_start;
- pos1 = Fl_Type::current->code1_end;
- break;
- case 1: // static: callbacks, menu declarations
- pos0 = Fl_Type::current->code_static_start;
- pos1 = Fl_Type::current->code_static_end;
- break;
- case 2: // code: entire implementation block including children
- pos0 = Fl_Type::current->code1_start;
- pos1 = Fl_Type::current->code2_end;
- break;
- case 3: // code1: all implementation code before the children
- pos0 = Fl_Type::current->code1_start;
- pos1 = Fl_Type::current->code1_end;
- break;
- case 4: // code1: all implementation code before the children
- pos0 = Fl_Type::current->code2_start;
- pos1 = Fl_Type::current->code2_end;
- break;
- }
- if (pos0>=0) {
- if (pos1<pos0)
- pos1 = pos0;
- sv_source->buffer()->highlight(pos0, pos1);
- int line = sv_source->buffer()->count_lines(0, pos0);
- sv_source->scroll(line, 0);
- }
- }
- if (sv_header->visible_r()) {
- switch (sv_code_choice) {
- case 2: // code: entire implementation block including children
- case 3: // code1: all implementation code before the children
- case 4: // code1: all implementation code before the children
- pos0 = Fl_Type::current->header_start;
- pos1 = Fl_Type::current->header_end;
- break;
- case 0: // prolog: not yet (include statements)
- case 1: // static: callbacks, menu declarations
- pos0 = Fl_Type::current->header_static_start;
- pos1 = Fl_Type::current->header_static_end;
- break;
- }
- if (pos0>=0) {
- if (pos1<pos0)
- pos1 = pos0;
- sv_header->buffer()->highlight(pos0, pos1);
- int line = sv_header->buffer()->count_lines(0, pos0);
- sv_header->scroll(line, 0);
- }
- }
- }} {}
-}
-
-Function {update_sourceview_position_cb(class Fl_Tabs*, void*)} {
- comment {Callback to update the sourceview position.} open return_type void
-} {
- code {// make sure that the selected tab shows the current view
- update_sourceview_cb(0,0);
- // highlight the selected widget in the selected tab
- update_sourceview_position();} {}
-}
-
-Function {update_sourceview_cb(class Fl_Button*, void*)} {
- comment {Generate a header, source, strings, or design file in a temporary directory
-and load those into the Code Viewer widgets.} open return_type void
-} {
- code {if (!sourceview_panel || !sourceview_panel->visible())
- return;
-
- if (!sv_source_filename) {
- sv_source_filename = (char*)malloc(FL_PATH_MAX);
- fl_strlcpy(sv_source_filename, get_tmpdir().c_str(), FL_PATH_MAX);
- fl_strlcat(sv_source_filename, "source_view_tmp.cxx", FL_PATH_MAX);
- }
- if (!sv_header_filename) {
- sv_header_filename = (char*)malloc(FL_PATH_MAX);
- fl_strlcpy(sv_header_filename, get_tmpdir().c_str(), FL_PATH_MAX);
- fl_strlcat(sv_header_filename, "source_view_tmp.h", FL_PATH_MAX);
- }
- if (!sv_design_filename) {
- sv_design_filename = (char*)malloc(FL_PATH_MAX);
- fl_strlcpy(sv_design_filename, get_tmpdir().c_str(), FL_PATH_MAX);
- fl_strlcat(sv_design_filename, "source_view_tmp.fl", FL_PATH_MAX);
- }
-
- if (sv_project->visible_r()) {
- write_file(sv_design_filename);
- int top = sv_project->top_line();
- sv_project->buffer()->loadfile(sv_design_filename);
- sv_project->scroll(top, 0);
- } else if (sv_strings->visible_r()) {
- static const char *exts[] = { ".txt", ".po", ".msg" };
- char fn[FL_PATH_MAX+1];
- fl_strlcpy(fn, get_tmpdir().c_str(), FL_PATH_MAX);
- fl_strlcat(fn, "strings", FL_PATH_MAX);
- fl_filename_setext(fn, FL_PATH_MAX, exts[g_project.i18n_type]);
- write_strings(fn);
- int top = sv_strings->top_line();
- sv_strings->buffer()->loadfile(fn);
- sv_strings->scroll(top, 0);
- } else if (sv_source->visible_r() || sv_header->visible_r()) {
- Fl_String code_file_name_bak = g_project.code_file_name;
- g_project.code_file_name = sv_source_filename;
- Fl_String header_file_name_bak = g_project.header_file_name;
- g_project.header_file_name = sv_header_filename;
-
- // generate the code and load the files
- Fd_Code_Writer f;
- // generate files
- if (f.write_code(sv_source_filename, sv_header_filename, true))
- {
- // load file into source editor
- int pos = sv_source->top_line();
- sv_source->buffer()->loadfile(sv_source_filename);
- sv_source->scroll(pos, 0);
- // load file into header editor
- pos = sv_header->top_line();
- sv_header->buffer()->loadfile(sv_header_filename);
- sv_header->scroll(pos, 0);
- // update the source code highlighting
- update_sourceview_position();
- }
-
- g_project.code_file_name = code_file_name_bak;
- g_project.header_file_name = header_file_name_bak;
- }} {}
-}
-
-Function {update_sourceview_timer(void*)} {
- comment {This is called by the timer itself
-} open return_type void
-} {
- code {update_sourceview_cb(0,0);} {}
-}
-
-Function {sourceview_defer_update()} {open return_type void
-} {
- code {// we will only update earliest 0.5 seconds after the last change, and only
- // if no other change was made, so dragging a widget will not generate any
- // CPU load
- Fl::remove_timeout(update_sourceview_timer, 0);
- Fl::add_timeout(0.5, update_sourceview_timer, 0);} {}
-}
-
-Function {sourceview_toggle_visibility()} {
- comment {Show or hide the source code preview.
-The state is stored in the app preferences.
-} open return_type void
-} {
- code {if (!sourceview_panel) {
- make_sourceview();
- sourceview_panel->callback((Fl_Callback*)toggle_sourceview_cb);
- Fl_Preferences svp(fluid_prefs, "sourceview");
- int autorefresh;
- svp.get("autorefresh", autorefresh, 1);
- sv_autorefresh->value(autorefresh);
- int autoposition;
- svp.get("autoposition", autoposition, 1);
- sv_autoposition->value(autoposition);
- int tab;
- svp.get("tab", tab, 0);
- if (tab>=0 && tab<sv_tab->children()) sv_tab->value(sv_tab->child(tab));
- svp.get("code_choice", sv_code_choice, 2);
- sv_code_choice_w->value(sv_code_choice_w->find_item_with_argument(sv_code_choice));
- if (!position_window(sourceview_panel,"sourceview_pos", 0, 320, 120, 550, 500)) return;
- }
-
- if (sourceview_panel->visible()) {
- sourceview_panel->hide();
- sourceview_item->label("Show Source Code...");
- } else {
- sourceview_panel->show();
- sourceview_item->label("Hide Source Code...");
- update_sourceview_cb(0,0);
- }} {}
-}
-
-Function {make_sourceview()} {open
-} {
- Fl_Window sourceview_panel {
- label {Code View}
- callback toggle_sourceview_cb open
- xywh {400 569 520 490} type Double align 80 resizable size_range {384 120 0 0} visible
- } {
- Fl_Tabs sv_tab {
- callback update_sourceview_position_cb open
- xywh {10 10 500 440} selection_color 4 labelcolor 7 resizable
- } {
- Fl_Group {} {
- label Source open
- xywh {10 35 500 415} labelsize 13 resizable
- } {
- Fl_Text_Editor sv_source {selected
- xywh {20 50 480 390} textfont 4 textsize 11 resizable
- code0 {\#include "CodeEditor.h"}
- code1 {o->linenumber_width(60);}
- code2 {o->linenumber_size(o->Fl_Text_Display::textsize());}
- class CodeViewer
- }
- }
- Fl_Group {} {
- label Header open
- xywh {10 35 500 415} labelsize 13 hide
- } {
- Fl_Text_Editor sv_header {
- xywh {20 50 480 390} textfont 4 textsize 11 resizable
- code0 {\#include "CodeEditor.h"}
- code1 {o->linenumber_width(60);}
- code2 {o->linenumber_size(o->Fl_Text_Display::textsize());}
- class CodeViewer
- }
- }
- Fl_Group {} {
- label Strings open
- xywh {10 35 500 415} labelsize 13 hide
- } {
- Fl_Text_Display sv_strings {
- xywh {20 50 480 390} textfont 4 textsize 11 resizable
- code1 {o->linenumber_width(60);}
- code2 {o->linenumber_size(o->Fl_Text_Display::textsize());}
- class TextViewer
- }
- }
- Fl_Group {} {
- label Project open
- xywh {10 35 500 415} labelsize 13 hide
- } {
- Fl_Text_Display sv_project {
- xywh {20 50 480 390} textfont 4 textsize 11 resizable
- code1 {o->linenumber_width(60);}
- code2 {o->linenumber_size(o->Fl_Text_Display::textsize());}
- class TextViewer
- }
- }
- }
- Fl_Group {} {open
- xywh {10 460 500 22}
- } {
- Fl_Button {} {
- label Refresh
- callback update_sourceview_cb
- xywh {10 460 61 20} labelsize 11
- }
- Fl_Light_Button sv_autorefresh {
- label {Auto-Refresh}
- xywh {77 460 91 20} labelsize 11
- code0 {o->callback((Fl_Callback*)update_sourceview_cb);}
- }
- Fl_Light_Button sv_autoposition {
- label {Auto-Position}
- xywh {172 460 89 20} labelsize 11
- }
- Fl_Choice sv_code_choice_w {
- callback {sv_code_choice = (int)o->mvalue()->argument();
-update_sourceview_position();} open
- xywh {265 460 70 20} down_box BORDER_BOX labelsize 11 textsize 11
- } {
- MenuItem {} {
- label prolog
- user_data 0 user_data_type long
- tooltip {Include statements in header or source code} xywh {0 0 100 20} labelsize 11
- }
- MenuItem {} {
- label static
- user_data 1 user_data_type long
- tooltip {static declarations in source code} xywh {10 10 100 20} labelsize 11
- }
- MenuItem {} {
- label code
- user_data 2 user_data_type long
- tooltip {widget code block including children} xywh {20 20 100 20} labelsize 11
- }
- MenuItem {} {
- label {code 1}
- user_data 3 user_data_type long
- tooltip {widget code block before children} xywh {30 30 100 20} labelsize 11
- }
- MenuItem {} {
- label {code 2}
- user_data 4 user_data_type long
- tooltip {widget code block after children} xywh {40 40 100 20} labelsize 11
- }
- }
- Fl_Box {} {
- xywh {375 460 80 20} resizable
- }
- Fl_Button {} {
- label Close
- callback toggle_sourceview_b_cb
- xywh {460 460 50 20} labelsize 11
- }
- }
- }
-}
-
-comment {
-//} {in_source in_header
-}