[gimp] Bug 763734 - better decimal places for physical units.



commit f83689231474cda32a7281fe069bd12d48881455
Author: Jehan <jehan girinstud io>
Date:   Wed Nov 23 18:12:51 2016 +0100

    Bug 763734 - better decimal places for physical units.
    
    Compute the ideal decimal precision for cursor position and length
    status so that you get the best precision on physical units depending
    on the current resolution, yet avoiding over-precision (which can be
    misleading). The unit's "digits" value is now used as a minimum
    precision only.

 app/display/gimpstatusbar.c |   25 +++++++++++++++++++++----
 1 files changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/app/display/gimpstatusbar.c b/app/display/gimpstatusbar.c
index efcb114..690bbd3 100644
--- a/app/display/gimpstatusbar.c
+++ b/app/display/gimpstatusbar.c
@@ -1345,16 +1345,33 @@ gimp_statusbar_shell_scaled (GimpDisplayShell *shell,
     }
   else /* show real world units */
     {
+      gint w_digits = 0;
+      gint h_digits = 0;
+      gint length_digits;
+
+      if (image)
+        {
+          w_digits = ceil (log10 (image_width /
+                                  gimp_pixels_to_units (image_width,
+                                                        shell->unit,
+                                                        image_xres)));
+          h_digits = ceil (log10 (image_width /
+                                  gimp_pixels_to_units (image_height,
+                                                        shell->unit,
+                                                        image_yres)));
+        }
+      w_digits = MAX (w_digits, gimp_unit_get_digits (shell->unit));
+      h_digits = MAX (h_digits, gimp_unit_get_digits (shell->unit));
+      length_digits = MAX (w_digits, h_digits);
+
       g_snprintf (statusbar->cursor_format_str,
                   sizeof (statusbar->cursor_format_str),
                   "%%s%%.%df%%s%%.%df%%s",
-                  gimp_unit_get_digits (shell->unit),
-                  gimp_unit_get_digits (shell->unit));
+                  w_digits, h_digits);
       strcpy (statusbar->cursor_format_str_f, statusbar->cursor_format_str);
       g_snprintf (statusbar->length_format_str,
                   sizeof (statusbar->length_format_str),
-                  "%%s%%.%df%%s",
-                  gimp_unit_get_digits (shell->unit));
+                  "%%s%%.%df%%s", length_digits);
     }
 
   gimp_statusbar_update_cursor (statusbar, GIMP_CURSOR_PRECISION_SUBPIXEL,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]