gimp r25839 - in trunk: . app/display libgimpwidgets
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r25839 - in trunk: . app/display libgimpwidgets
- Date: Wed, 28 May 2008 14:33:47 +0000 (UTC)
Author: neo
Date: Wed May 28 14:33:46 2008
New Revision: 25839
URL: http://svn.gnome.org/viewvc/gimp?rev=25839&view=rev
Log:
2008-05-28 Sven Neumann <sven gimp org>
* app/display/gimpdisplayshell-scale.c
(gimp_display_shell_scale_setup): set the display unit on the ruler.
* libgimpwidgets/gimphruler.c (gimp_hruler_draw_ticks)
* libgimpwidgets/gimpvruler.c (gimp_vruler_draw_ticks): hack around
to get nicer subdivisions for rulers showing pixels.
Modified:
trunk/ChangeLog
trunk/app/display/gimpdisplayshell-scale.c
trunk/libgimpwidgets/gimphruler.c
trunk/libgimpwidgets/gimpvruler.c
Modified: trunk/app/display/gimpdisplayshell-scale.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-scale.c (original)
+++ trunk/app/display/gimpdisplayshell-scale.c Wed May 28 14:33:46 2008
@@ -174,6 +174,7 @@
}
gimp_ruler_set_range (GIMP_RULER (shell->hrule), lower, upper, max_size);
+ gimp_ruler_set_unit (GIMP_RULER (shell->hrule), shell->unit);
/* vertical ruler */
@@ -214,7 +215,7 @@
}
gimp_ruler_set_range (GIMP_RULER (shell->vrule), lower, upper, max_size);
-
+ gimp_ruler_set_unit (GIMP_RULER (shell->vrule), shell->unit);
#if 0
g_printerr ("offset_x: %d\n"
Modified: trunk/libgimpwidgets/gimphruler.c
==============================================================================
--- trunk/libgimpwidgets/gimphruler.c (original)
+++ trunk/libgimpwidgets/gimphruler.c Wed May 28 14:33:46 2008
@@ -30,15 +30,14 @@
#include "gimphruler.h"
-#define RULER_HEIGHT 13
-#define MINIMUM_INCR 5
-#define MAXIMUM_SUBDIVIDE 5
+#define RULER_HEIGHT 13
+#define MINIMUM_INCR 5
static const struct
{
gdouble ruler_scale[16];
- gint subdivide[5]; /* five possible modes of subdivision */
+ gint subdivide[5];
} ruler_metric =
{
{ 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000, 10000, 25000, 50000, 100000 },
@@ -102,7 +101,6 @@
GimpRuler *ruler = GIMP_RULER (widget);
gdouble lower;
gdouble upper;
- gdouble position;
gint x;
gdk_event_request_motions (event);
@@ -138,6 +136,7 @@
gint text_width;
gint pos;
gdouble max_size;
+ GimpUnit unit;
PangoLayout *layout;
PangoRectangle logical_rect, ink_rect;
@@ -196,16 +195,28 @@
if (scale == G_N_ELEMENTS (ruler_metric.ruler_scale))
scale = G_N_ELEMENTS (ruler_metric.ruler_scale) - 1;
+ unit = gimp_ruler_get_unit (ruler);
+
/* drawing starts here */
length = 0;
- for (i = MAXIMUM_SUBDIVIDE - 1; i >= 0; i--)
+ for (i = G_N_ELEMENTS (ruler_metric.subdivide) - 1; i >= 0; i--)
{
- gdouble subd_incr = ((gdouble) ruler_metric.ruler_scale[scale] /
- (gdouble) ruler_metric.subdivide[i]);
+ gdouble subd_incr;
+
+ /* hack to get proper subdivisions at full pixels */
+ if (unit == GIMP_UNIT_PIXEL && scale == 1 && i == 1)
+ subd_incr = 1.0;
+ else
+ subd_incr = ((gdouble) ruler_metric.ruler_scale[scale] /
+ (gdouble) ruler_metric.subdivide[i]);
if (subd_incr * fabs (increment) <= MINIMUM_INCR)
continue;
+ /* don't subdivide pixels */
+ if (unit == GIMP_UNIT_PIXEL && subd_incr < 1.0)
+ continue;
+
/* Calculate the length of the tickmarks. Make sure that
* this length increases for each set of ticks
*/
Modified: trunk/libgimpwidgets/gimpvruler.c
==============================================================================
--- trunk/libgimpwidgets/gimpvruler.c (original)
+++ trunk/libgimpwidgets/gimpvruler.c Wed May 28 14:33:46 2008
@@ -30,14 +30,13 @@
#include "gimpvruler.h"
-#define RULER_WIDTH 13
-#define MINIMUM_INCR 5
-#define MAXIMUM_SUBDIVIDE 5
+#define RULER_WIDTH 13
+#define MINIMUM_INCR 5
static const struct
{
gdouble ruler_scale[16];
- gint subdivide[5]; /* five possible modes of subdivision */
+ gint subdivide[5];
} ruler_metric =
{
{ 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000, 10000, 25000, 50000, 100000 },
@@ -137,6 +136,7 @@
gint text_height;
gint pos;
gdouble max_size;
+ GimpUnit unit;
PangoLayout *layout;
PangoRectangle logical_rect, ink_rect;
@@ -196,16 +196,28 @@
if (scale == G_N_ELEMENTS (ruler_metric.ruler_scale))
scale = G_N_ELEMENTS (ruler_metric.ruler_scale) - 1;
+ unit = gimp_ruler_get_unit (ruler);
+
/* drawing starts here */
length = 0;
- for (i = MAXIMUM_SUBDIVIDE - 1; i >= 0; i--)
+ for (i = G_N_ELEMENTS (ruler_metric.subdivide) - 1; i >= 0; i--)
{
- gdouble subd_incr = ((gdouble) ruler_metric.ruler_scale[scale] /
- (gdouble) ruler_metric.subdivide[i]);
+ gdouble subd_incr;
+
+ /* hack to get proper subdivisions at full pixels */
+ if (unit == GIMP_UNIT_PIXEL && scale == 1 && i == 1)
+ subd_incr = 1.0;
+ else
+ subd_incr = ((gdouble) ruler_metric.ruler_scale[scale] /
+ (gdouble) ruler_metric.subdivide[i]);
if (subd_incr * fabs (increment) <= MINIMUM_INCR)
continue;
+ /* don't subdivide pixels */
+ if (unit == GIMP_UNIT_PIXEL && subd_incr < 1)
+ continue;
+
/* Calculate the length of the tickmarks. Make sure that
* this length increases for each set of ticks
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]