Fluid now stores set sizes for Fl_Flex. (#529)
https://groups.google.com/g/fltkcoredev/c/2JA-CcTbrX4
This commit is contained in:
parent
425bd5865d
commit
4b4591dd72
@ -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;
|
||||
}
|
||||
|
||||
@ -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(); }
|
||||
|
||||
Loading…
Reference in New Issue
Block a user