Fixes some FLUID bugs
Fl_Flex would not change type when it had no children. Function evaluation could read past string end. Fl_Window_Type would not initialise all member variables.
This commit is contained in:
parent
e19d2d98ba
commit
6f36a63629
@ -315,30 +315,32 @@ void Fl_Flex_Type::remove_child(Fl_Type* a) {
|
||||
// We need to relayout existing children.
|
||||
void Fl_Flex_Type::change_subtype_to(int n) {
|
||||
Fl_Flex* f = (Fl_Flex*)o;
|
||||
if (f->type()==n) return;
|
||||
|
||||
int nc = f->children();
|
||||
if (f->type()==n || nc==0) return;
|
||||
|
||||
int dw = Fl::box_dw(f->box());
|
||||
int dh = Fl::box_dh(f->box());
|
||||
int lm, tm, rm, bm;
|
||||
f->margins(&lm, &tm, &rm, &bm);
|
||||
int gap = f->gap();
|
||||
int fw = f->w()-dw-lm-rm-(nc*gap);
|
||||
if (fw<=nc) fw = nc; // avoid division by zero
|
||||
int fh = f->h()-dh-tm-bm-(nc*gap);
|
||||
if (fh<=nc) fh = nc; // avoid division by zero
|
||||
|
||||
if (f->type()==Fl_Flex::HORIZONTAL && n==Fl_Flex::VERTICAL) {
|
||||
float scl = (float)fh/(float)fw;
|
||||
for (int i=0; i<nc; i++) {
|
||||
Fl_Widget* c = f->child(i);
|
||||
c->size(f->w(), (int)(c->w()*scl));
|
||||
}
|
||||
} else if (f->type()==Fl_Flex::VERTICAL && n==Fl_Flex::HORIZONTAL) {
|
||||
float scl = (float)fw/(float)fh;
|
||||
for (int i=0; i<nc; i++) {
|
||||
Fl_Widget* c = f->child(i);
|
||||
c->size((int)(c->h()*scl), f->h());
|
||||
if (nc > 0) {
|
||||
int dw = Fl::box_dw(f->box());
|
||||
int dh = Fl::box_dh(f->box());
|
||||
int lm, tm, rm, bm;
|
||||
f->margins(&lm, &tm, &rm, &bm);
|
||||
int gap = f->gap();
|
||||
int fw = f->w()-dw-lm-rm-(nc*gap);
|
||||
if (fw<=nc) fw = nc; // avoid division by zero
|
||||
int fh = f->h()-dh-tm-bm-(nc*gap);
|
||||
if (fh<=nc) fh = nc; // avoid division by zero
|
||||
|
||||
if (f->type()==Fl_Flex::HORIZONTAL && n==Fl_Flex::VERTICAL) {
|
||||
float scl = (float)fh/(float)fw;
|
||||
for (int i=0; i<nc; i++) {
|
||||
Fl_Widget* c = f->child(i);
|
||||
c->size(f->w(), (int)(c->w()*scl));
|
||||
}
|
||||
} else if (f->type()==Fl_Flex::VERTICAL && n==Fl_Flex::HORIZONTAL) {
|
||||
float scl = (float)fw/(float)fh;
|
||||
for (int i=0; i<nc; i++) {
|
||||
Fl_Widget* c = f->child(i);
|
||||
c->size((int)(c->h()*scl), f->h());
|
||||
}
|
||||
}
|
||||
}
|
||||
f->type(n);
|
||||
|
@ -67,7 +67,18 @@ protected:
|
||||
|
||||
public:
|
||||
|
||||
Fl_Window_Type() { drag = dx = dy = 0; sr_min_w = sr_min_h = sr_max_w = sr_max_h = 0; }
|
||||
Fl_Window_Type() :
|
||||
mx(0), my(0),
|
||||
x1(0), y1(0),
|
||||
bx(0), by(0), br(0), bt(0),
|
||||
sx(0), sy(0), sr(0), st(0),
|
||||
dx(0), dy(0),
|
||||
drag(0),
|
||||
numselected(0),
|
||||
recalc(0),
|
||||
modal(0), non_modal(0),
|
||||
sr_min_w(0), sr_min_h(0), sr_max_w(0), sr_max_h(0)
|
||||
{ }
|
||||
uchar modal, non_modal;
|
||||
|
||||
Fl_Type *make(Strategy strategy);
|
||||
|
@ -283,14 +283,15 @@ int Fluid_Coord_Input::eval(uchar *&s, int prio) const {
|
||||
} else {
|
||||
return v; // syntax error
|
||||
}
|
||||
c = *s++;
|
||||
c = *s;
|
||||
if (c) s++;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
/**
|
||||
Evaluate a formula into an integer.
|
||||
The interpreter understand unary plus and minus, basic integer math
|
||||
The interpreter understands unary plus and minus, basic integer math
|
||||
(+, -, *, /), brackets, and can handle a user defined list of variables
|
||||
by name. There is no error checking. We assume that the formula is
|
||||
entered correctly.
|
||||
|
Loading…
Reference in New Issue
Block a user