[gimp] app: fix publically reported layout offset for a couple of cases
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: fix publically reported layout offset for a couple of cases
- Date: Thu, 11 Mar 2010 19:58:43 +0000 (UTC)
commit 13cbdabcc30e35f26b267b3d46cb72c39155e67c
Author: Michael Natterer <mitch gimp org>
Date: Thu Mar 11 20:50:16 2010 +0100
app: fix publically reported layout offset for a couple of cases
Move the code that adjusts the layout's x-offset for fixed-width text
boxes and RTL, centered- and right justified text. It was living in
gimp_text_layout_render() and was correctly applied at rendering time,
so everything looked fine. Move it to gimp_text_layout_position() so
it becomes part of the layout's permanent properties, is reported by
gimp_text_layout_get_offsets() and thus used by the text tool which
can draw cursor and selection at the right place.
app/text/gimptextlayout-render.c | 31 ++-----------------------------
app/text/gimptextlayout.c | 25 +++++++++++++++++++++++++
2 files changed, 27 insertions(+), 29 deletions(-)
---
diff --git a/app/text/gimptextlayout-render.c b/app/text/gimptextlayout-render.c
index 058744f..c5c0a42 100644
--- a/app/text/gimptextlayout-render.c
+++ b/app/text/gimptextlayout-render.c
@@ -24,10 +24,6 @@
#include "text-types.h"
-#include "base/pixel-region.h"
-#include "base/tile-manager.h"
-
-#include "gimptext.h"
#include "gimptextlayout.h"
#include "gimptextlayout-render.h"
@@ -47,36 +43,13 @@ gimp_text_layout_render (GimpTextLayout *layout,
gimp_text_layout_get_offsets (layout, &x, &y);
- pango_layout = gimp_text_layout_get_pango_layout (layout);
-
- /* If the width of the layout is > 0, then the text-box is FIXED and
- * the layout position should be offset if the alignment is centered
- * or right-aligned, also adjust for RTL text direction.
- */
- if (pango_layout_get_width (pango_layout) > 0)
- {
- PangoAlignment align = pango_layout_get_alignment (pango_layout);
- gint width;
-
- pango_layout_get_pixel_size (pango_layout, &width, NULL);
-
- if ((base_dir == GIMP_TEXT_DIRECTION_LTR && align == PANGO_ALIGN_RIGHT) ||
- (base_dir == GIMP_TEXT_DIRECTION_RTL && align == PANGO_ALIGN_LEFT))
- {
- x += PANGO_PIXELS (pango_layout_get_width (pango_layout)) - width;
- }
- else if (align == PANGO_ALIGN_CENTER)
- {
- x += (PANGO_PIXELS (pango_layout_get_width (pango_layout))
- - width) / 2;
- }
- }
-
cairo_translate (cr, x, y);
gimp_text_layout_get_transform (layout, &trafo);
cairo_transform (cr, &trafo);
+ pango_layout = gimp_text_layout_get_pango_layout (layout);
+
if (path)
pango_cairo_layout_path (cr, pango_layout);
else
diff --git a/app/text/gimptextlayout.c b/app/text/gimptextlayout.c
index 4f84516..2a5c67f 100644
--- a/app/text/gimptextlayout.c
+++ b/app/text/gimptextlayout.c
@@ -507,6 +507,31 @@ gimp_text_layout_position (GimpTextLayout *layout)
layout->extents.width = x2 - x1;
layout->extents.height = y2 - y1;
+ /* If the width of the layout is > 0, then the text-box is FIXED and
+ * the layout position should be offset if the alignment is centered
+ * or right-aligned, also adjust for RTL text direction.
+ */
+ if (pango_layout_get_width (layout->layout) > 0)
+ {
+ PangoAlignment align = pango_layout_get_alignment (layout->layout);
+ GimpTextDirection base_dir = layout->text->base_dir;
+ gint width;
+
+ pango_layout_get_pixel_size (layout->layout, &width, NULL);
+
+ if ((base_dir == GIMP_TEXT_DIRECTION_LTR && align == PANGO_ALIGN_RIGHT) ||
+ (base_dir == GIMP_TEXT_DIRECTION_RTL && align == PANGO_ALIGN_LEFT))
+ {
+ layout->extents.x +=
+ PANGO_PIXELS (pango_layout_get_width (layout->layout)) - width;
+ }
+ else if (align == PANGO_ALIGN_CENTER)
+ {
+ layout->extents.x +=
+ (PANGO_PIXELS (pango_layout_get_width (layout->layout)) - width) / 2;
+ }
+ }
+
if (layout->text->border > 0)
{
gint border = layout->text->border;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]