In GimpSizeEntry, the value corresponding to 0%, as per
gimp_size_entry_set_size(), may be non-zero. This works correctly
when using the size entry in percentage mode, but not when using
precentage as part of arithmetic.
Fix this by adding an 'offset' parameter to eevl's unit-resolution
callback, which can be specifies a constant value to add as part
of unit conversion, after scaling the converted value by the
conversion factor. In GimpSizeEntry, use this parameter to offset
percentages by their lower bound.
Ratio expressions have the form 'x : y' (the ':' operator has the
highest precedence for a binary operator, and is left-associative).
Given a reference value 'a', the expression evaluates to
'a * (x / y)'.
Ratio expressions can be controlled by the caller by:
- Enabling or disabling them: They're meant to be used when the
eevl servers two paired entries, and can be disabled otherwise.
- Setting the reference value: That's normally the value of the
"other" entry of the pair--the one not currently being
evaluated.
- Inverting the ratios: Normally, one entry refers to the
antecedent term of the ratio, and the other entry refers to the
consequent term of the ratio. When evaluating the latter one,
the ratio should be inverted.
Pass the evaluation options to gimp_eevl_evaluate() using a single
parameter of type GimpEevlOptions, instead of using individual
parameters for each option. Add a GIMP_EEVL_OPTIONS_INIT macro,
used to initialize a GimpEevlOptions struct to the default set of
options. This would allow us to add evaluation options more
easily.
Add a simple parser to the GimpSizeEntry widget so that one can write
things such as "40in" and "50%" in a size entry widget and get that
converted to the current unit.
The parser also handles basic expresions such as "20cm + 20px" and
"2 * 3.14in".