Commit Graph

5 Commits

Author SHA1 Message Date
Ell a9e357d72d libgimpwidgets: fix percentage use in size-entry arithmetic when lower-bound != 0
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.
2020-01-06 21:35:52 +02:00
Michael Natterer 5f700549e7 Change the license URL from http://www.gnu.org/licenses/ to https:// 2018-07-11 23:29:46 +02:00
Ell 6caae9c53b libgimpwidgets: add ratio expressions to eevl
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.
2017-10-04 14:25:01 -04:00
Ell 7362d47922 libgimpwidgets: use struct, not parameters, to pass eevl options
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.
2017-10-04 14:25:01 -04:00
Fredrik Alströmer bcee243fa3 Bug 76616 – Size entry widgets could use some simple math
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".
2009-05-17 13:47:37 +02:00