diff options
Diffstat (limited to 'fluid')
| -rw-r--r-- | fluid/Fl_Widget_Type.cxx | 37 | ||||
| -rw-r--r-- | fluid/Shortcut_Button.cxx | 17 |
2 files changed, 41 insertions, 13 deletions
diff --git a/fluid/Fl_Widget_Type.cxx b/fluid/Fl_Widget_Type.cxx index 12772eabe..e933ad6d7 100644 --- a/fluid/Fl_Widget_Type.cxx +++ b/fluid/Fl_Widget_Type.cxx @@ -670,17 +670,23 @@ void x_cb(Fluid_Coord_Input *i, void *v) { undo_checkpoint(); widget_i = 0; int mod = 0; + int v = 0; for (Fl_Type *o = Fl_Type::first; o; o = o->next) { if (o->selected && o->is_widget()) { Fl_Widget *w = ((Fl_Widget_Type *)o)->o; i->variables(widget_vars, o); - w->resize((int)i->value(), w->y(), w->w(), w->h()); + v = i->value(); + w->resize(v, w->y(), w->w(), w->h()); if (w->window()) w->window()->redraw(); widget_i++; mod = 1; } } - if (mod) set_modflag(1); + if (mod) { + set_modflag(1); + i->value(v); // change the displayed value to the result of the last + // calculation. Keep the formula if it was not used. + } } } @@ -695,17 +701,22 @@ void y_cb(Fluid_Coord_Input *i, void *v) { undo_checkpoint(); widget_i = 0; int mod = 0; + int v = 0; for (Fl_Type *o = Fl_Type::first; o; o = o->next) { if (o->selected && o->is_widget()) { Fl_Widget *w = ((Fl_Widget_Type *)o)->o; i->variables(widget_vars, o); - w->resize(w->x(), (int)i->value(), w->w(), w->h()); + v = i->value(); + w->resize(w->x(), v, w->w(), w->h()); if (w->window()) w->window()->redraw(); widget_i++; mod = 1; } } - if (mod) set_modflag(1); + if (mod) { + set_modflag(1); + i->value(v); + } } } @@ -720,17 +731,22 @@ void w_cb(Fluid_Coord_Input *i, void *v) { undo_checkpoint(); widget_i = 0; int mod = 0; + int v = 0; for (Fl_Type *o = Fl_Type::first; o; o = o->next) { if (o->selected && o->is_widget()) { Fl_Widget *w = ((Fl_Widget_Type *)o)->o; i->variables(widget_vars, o); - w->resize(w->x(), w->y(), (int)i->value(), w->h()); + v = i->value(); + w->resize(w->x(), w->y(), v, w->h()); if (w->window()) w->window()->redraw(); widget_i++; mod = 1; } } - if (mod) set_modflag(1); + if (mod) { + set_modflag(1); + i->value(v); + } } } @@ -745,17 +761,22 @@ void h_cb(Fluid_Coord_Input *i, void *v) { undo_checkpoint(); widget_i = 0; int mod = 0; + int v = 0; for (Fl_Type *o = Fl_Type::first; o; o = o->next) { if (o->selected && o->is_widget()) { Fl_Widget *w = ((Fl_Widget_Type *)o)->o; i->variables(widget_vars, o); - w->resize(w->x(), w->y(), w->w(), (int)i->value()); + v = i->value(); + w->resize(w->x(), w->y(), w->w(), v); if (w->window()) w->window()->redraw(); widget_i++; mod = 1; } } - if (mod) set_modflag(1); + if (mod) { + set_modflag(1); + i->value(v); + } } } diff --git a/fluid/Shortcut_Button.cxx b/fluid/Shortcut_Button.cxx index 9c64b760a..97fa7f262 100644 --- a/fluid/Shortcut_Button.cxx +++ b/fluid/Shortcut_Button.cxx @@ -203,7 +203,8 @@ void Fluid_Coord_Input::callback_handler_cb(Fluid_Coord_Input *This, void *v) { void Fluid_Coord_Input::callback_handler(void *v) { if (user_callback_) (*user_callback_)(this, v); - value( value() ); + // do *not* update the value to show the evaluated fomule here, because the + // values of the variables have already updated after the user callback. } /** @@ -238,14 +239,20 @@ int Fluid_Coord_Input::eval_var(uchar *&s) const { \return the value so far */ int Fluid_Coord_Input::eval(uchar *&s, int prio) const { - int v =0, sgn = 1; + int v = 0, sgn = 1; uchar c = *s++; + // check for end of text + if (c==0) { s--; return sgn*v; } + // check for unary operator if (c=='-') { sgn = -1; c = *s++; } else if (c=='+') { sgn = 1; c = *s++; } - if (c>='0' && c<='9') { + // read value, variable, or bracketed term + if (c==0) { + s--; return sgn*v; + } else if (c>='0' && c<='9') { // numeric value while (c>='0' && c<='9') { v = v*10 + (c-'0'); @@ -265,6 +272,7 @@ int Fluid_Coord_Input::eval(uchar *&s, int prio) const { // Now evaluate all following binary operators for (;;) { if (c==0) { + s--; return v; } else if (c=='+' || c=='-') { if (prio<=4) { s--; return v; } @@ -283,8 +291,7 @@ int Fluid_Coord_Input::eval(uchar *&s, int prio) const { } else { return v; // syntax error } - c = *s; - if (c) s++; + c = *s++; } return v; } |
