diff options
| author | Matthias Melcher <github@matthiasm.com> | 2022-11-04 17:49:37 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-04 17:49:37 +0100 |
| commit | 4b4591dd72e2e9e9b2ee3f00afe7963c8f578616 (patch) | |
| tree | 277fb13d7e79adfe3d2f52f297b1f16831593120 | |
| parent | 425bd5865d70fc751dd364ace701a8540cb2d352 (diff) | |
Fluid now stores set sizes for Fl_Flex. (#529)
https://groups.google.com/g/fltkcoredev/c/2JA-CcTbrX4
| -rw-r--r-- | fluid/Fl_Group_Type.cxx | 37 | ||||
| -rw-r--r-- | fluid/Fl_Group_Type.h | 6 |
2 files changed, 24 insertions, 19 deletions
diff --git a/fluid/Fl_Group_Type.cxx b/fluid/Fl_Group_Type.cxx index 5bc3525d9..d83d7fa2d 100644 --- a/fluid/Fl_Group_Type.cxx +++ b/fluid/Fl_Group_Type.cxx @@ -214,10 +214,12 @@ void Fl_Flex_Type::write_properties() if (f->set_size(f->child(i))) nSet++; if (nSet) { - write_string("size_set {%d", nSet); - for (int i=0; i<f->children(); i++) - if (f->set_size(f->child(i))) - write_string(" %d", i); + write_string("set_size_tuples {%d", nSet); + for (int i=0; i<f->children(); i++) { + Fl_Widget *ci = f->child(i); + if (f->set_size(ci)) + write_string(" %d %d", i, f->horizontal() ? ci->w() : ci->h()); + } write_string("}"); } } @@ -234,14 +236,16 @@ void Fl_Flex_Type::read_property(const char *c) int g; if (sscanf(read_word(),"%d",&g)) f->gap(g); - } else if (!strcmp(c,"size_set")) { + } else if (!strcmp(c,"set_size_tuples")) { read_word(1); // must be '{' const char *nStr = read_word(1); // number of indices in table - fixedSizeTableSize = atoi(nStr); - fixedSizeTable = new int[fixedSizeTableSize]; - for (int i=0; i<fixedSizeTableSize; i++) { + fixedSizeTupleSize = atoi(nStr); + fixedSizeTuple = new int[fixedSizeTupleSize*2]; + for (int i=0; i<fixedSizeTupleSize; i++) { const char *ix = read_word(1); // child at that index is fixed in size - fixedSizeTable[i] = atoi(ix); + fixedSizeTuple[i*2] = atoi(ix); + const char *size = read_word(1); // fixed size of that child + fixedSizeTuple[i*2+1] = atoi(size); } read_word(1); // must be '}' } else { @@ -251,18 +255,19 @@ void Fl_Flex_Type::read_property(const char *c) void Fl_Flex_Type::postprocess_read() { - if (fixedSizeTableSize==0) return; + if (fixedSizeTupleSize==0) return; Fl_Flex* f = (Fl_Flex*)o; - for (int i=0; i<fixedSizeTableSize; i++) { - int ix = fixedSizeTable[i]; + for (int i=0; i<fixedSizeTupleSize; i++) { + int ix = fixedSizeTuple[2*i]; + int size = fixedSizeTuple[2*i+1]; if (ix>=0 && ix<f->children()) { Fl_Widget *ci = f->child(ix); - f->set_size(ci, f->horizontal()?ci->w():ci->h()); + f->set_size(ci, size); } } - fixedSizeTableSize = 0; - delete[] fixedSizeTable; - fixedSizeTable = NULL; + fixedSizeTupleSize = 0; + delete[] fixedSizeTuple; + fixedSizeTuple = NULL; f->layout(); suspend_auto_layout = 0; } diff --git a/fluid/Fl_Group_Type.h b/fluid/Fl_Group_Type.h index 3d21a44b6..f0ab0f8ce 100644 --- a/fluid/Fl_Group_Type.h +++ b/fluid/Fl_Group_Type.h @@ -88,11 +88,11 @@ extern Fl_Menu_Item flex_type_menu[]; class Fl_Flex_Type : public Fl_Group_Type { Fl_Menu_Item *subtypes() {return flex_type_menu;} - int fixedSizeTableSize; - int *fixedSizeTable; + int fixedSizeTupleSize; /* number of pairs in array */ + int *fixedSizeTuple; /* [ index, size, index2, size2, ... ] */ int suspend_auto_layout; public: - Fl_Flex_Type() : fixedSizeTableSize(0), fixedSizeTable(NULL), suspend_auto_layout(0) { } + Fl_Flex_Type() : fixedSizeTupleSize(0), fixedSizeTuple(NULL), suspend_auto_layout(0) { } virtual const char *type_name() {return flex_type_name;} virtual const char *alt_type_name() {return "fltk::FlexGroup";} Fl_Widget_Type *_make() { return new Fl_Flex_Type(); } |
