From 4b4591dd72e2e9e9b2ee3f00afe7963c8f578616 Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Fri, 4 Nov 2022 17:49:37 +0100 Subject: Fluid now stores set sizes for Fl_Flex. (#529) https://groups.google.com/g/fltkcoredev/c/2JA-CcTbrX4 --- fluid/Fl_Group_Type.cxx | 37 +++++++++++++++++++++---------------- 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; ichildren(); i++) - if (f->set_size(f->child(i))) - write_string(" %d", i); + write_string("set_size_tuples {%d", nSet); + for (int i=0; ichildren(); 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=0 && ixchildren()) { 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(); } -- cgit v1.2.3