summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2024-10-22 13:49:48 +0200
committerMatthias Melcher <github@matthiasm.com>2024-10-22 13:49:48 +0200
commit2228ec22d71117fbf346da1f1c0ae341328dbc02 (patch)
treeffc0c24052f73319e38456bd1e925095daec0c4b
parentfb5c6522005d08c547bf93cddfc9cd156a59fd81 (diff)
FLUID: Adds missing code for Grid and Flex live: #1092
-rw-r--r--fluid/Fl_Grid_Type.cxx28
-rw-r--r--fluid/Fl_Grid_Type.h1
-rw-r--r--fluid/Fl_Group_Type.cxx14
-rw-r--r--fluid/Fl_Group_Type.h1
-rw-r--r--fluid/Fl_Type.h1
-rw-r--r--fluid/Fl_Widget_Type.cxx2
6 files changed, 46 insertions, 1 deletions
diff --git a/fluid/Fl_Grid_Type.cxx b/fluid/Fl_Grid_Type.cxx
index af1c6267e..45110a880 100644
--- a/fluid/Fl_Grid_Type.cxx
+++ b/fluid/Fl_Grid_Type.cxx
@@ -303,13 +303,39 @@ void Fl_Grid_Type::copy_properties()
{
super::copy_properties();
Fl_Grid *d = (Fl_Grid*)live_widget, *s =(Fl_Grid*)o;
+ d->layout(s->rows(), s->cols());
int lm, tm, rm, bm;
s->margin(&lm, &tm, &rm, &bm);
d->margin(lm, tm, rm, bm);
int rg, cg;
s->gap(&rg, &cg);
d->gap(rg, cg);
- // TODO: lots to do!
+ // copy col widths, heights, and gaps
+ for (int c=0; c<s->cols(); c++) {
+ d->col_width(c, s->col_width(c));
+ d->col_gap(c, s->col_gap(c));
+ d->col_weight(c, s->col_weight(c));
+ }
+ // copy row widths, heights, and gaps
+ for (int r=0; r<s->rows(); r++) {
+ d->row_height(r, s->row_height(r));
+ d->row_gap(r, s->row_gap(r));
+ d->row_weight(r, s->row_weight(r));
+ }
+}
+
+void Fl_Grid_Type::copy_properties_for_children() {
+ Fl_Grid *d = (Fl_Grid*)live_widget, *s =(Fl_Grid*)o;
+ for (int i=0; i<s->children(); i++) {
+ Fl_Grid::Cell *cell = s->cell(s->child(i));
+ if (cell && i<d->children()) {
+ d->widget(d->child(i),
+ cell->row(), cell->col(),
+ cell->rowspan(), cell->colspan(),
+ cell->align());
+ }
+ }
+ d->layout();
}
void Fl_Grid_Type::write_properties(Fd_Project_Writer &f)
diff --git a/fluid/Fl_Grid_Type.h b/fluid/Fl_Grid_Type.h
index 1fd59277b..2098cf783 100644
--- a/fluid/Fl_Grid_Type.h
+++ b/fluid/Fl_Grid_Type.h
@@ -64,6 +64,7 @@ public:
Fl_Widget *enter_live_mode(int top=0) FL_OVERRIDE;
void leave_live_mode() FL_OVERRIDE;
void copy_properties() FL_OVERRIDE;
+ void copy_properties_for_children() FL_OVERRIDE;
void write_code1(Fd_Code_Writer& f) FL_OVERRIDE;
void write_code2(Fd_Code_Writer& f) FL_OVERRIDE;
void add_child(Fl_Type*, Fl_Type*) FL_OVERRIDE;
diff --git a/fluid/Fl_Group_Type.cxx b/fluid/Fl_Group_Type.cxx
index dca269927..bac04a462 100644
--- a/fluid/Fl_Group_Type.cxx
+++ b/fluid/Fl_Group_Type.cxx
@@ -334,6 +334,20 @@ void Fl_Flex_Type::copy_properties()
d->gap( s->gap() );
}
+void Fl_Flex_Type::copy_properties_for_children() {
+ Fl_Flex *d = (Fl_Flex*)live_widget, *s =(Fl_Flex*)o;
+ for (int i=0; i<s->children(); i++) {
+ if (s->fixed(s->child(i)) && i<d->children()) {
+ if (s->horizontal()) {
+ d->fixed(d->child(i), d->child(i)->w());
+ } else {
+ d->fixed(d->child(i), d->child(i)->h());
+ }
+ }
+ }
+ d->layout();
+}
+
void Fl_Flex_Type::write_properties(Fd_Project_Writer &f)
{
Fl_Group_Type::write_properties(f);
diff --git a/fluid/Fl_Group_Type.h b/fluid/Fl_Group_Type.h
index ac20829d7..1f7bc2747 100644
--- a/fluid/Fl_Group_Type.h
+++ b/fluid/Fl_Group_Type.h
@@ -118,6 +118,7 @@ public:
void read_property(Fd_Project_Reader &f, const char *) FL_OVERRIDE;
Fl_Widget *enter_live_mode(int top=0) FL_OVERRIDE;
void copy_properties() FL_OVERRIDE;
+ void copy_properties_for_children() FL_OVERRIDE;
void postprocess_read() FL_OVERRIDE;
void write_code2(Fd_Code_Writer& f) FL_OVERRIDE;
// void add_child(Fl_Type*, Fl_Type*) FL_OVERRIDE;
diff --git a/fluid/Fl_Type.h b/fluid/Fl_Type.h
index be5e5f1a6..59bd89556 100644
--- a/fluid/Fl_Type.h
+++ b/fluid/Fl_Type.h
@@ -253,6 +253,7 @@ public:
virtual Fl_Widget *enter_live_mode(int top=0); // build widgets needed for live mode
virtual void leave_live_mode(); // free allocated resources
virtual void copy_properties(); // copy properties from this type into a potential live object
+ virtual void copy_properties_for_children() { } // copy remaining properties after children were added
// get message number for I18N
int msgnum();
diff --git a/fluid/Fl_Widget_Type.cxx b/fluid/Fl_Widget_Type.cxx
index 44b470102..aaa96883f 100644
--- a/fluid/Fl_Widget_Type.cxx
+++ b/fluid/Fl_Widget_Type.cxx
@@ -3834,6 +3834,8 @@ Fl_Widget* Fl_Widget_Type::propagate_live_mode(Fl_Group* grp) {
}
}
grp->end();
+ live_widget = grp;
+ copy_properties_for_children();
return live_widget;
}