mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-23 04:51:44 +00:00
take the layout line's x coordinate into account so the stuff works for
2008-10-27 Michael Natterer <mitch@gimp.org> * app/tools/gimptexttool.c (gimp_text_tool_key_press): take the layout line's x coordinate into account so the stuff works for right-aligned or centered text. svn path=/trunk/; revision=27440
This commit is contained in:
parent
50f043c3a2
commit
b258af7af8
|
@ -1,3 +1,9 @@
|
|||
2008-10-27 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/tools/gimptexttool.c (gimp_text_tool_key_press): take the
|
||||
layout line's x coordinate into account so the stuff works for
|
||||
right-aligned or centered text.
|
||||
|
||||
2008-10-27 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/tools/gimptexttool.c (gimp_text_tool_key_press): argh, need
|
||||
|
|
|
@ -845,21 +845,33 @@ gimp_text_tool_key_press (GimpTool *tool,
|
|||
gint line_index;
|
||||
gint trailing;
|
||||
PangoLayoutLine *layout_line;
|
||||
PangoLayoutIter *layout_iter;
|
||||
PangoRectangle logical;
|
||||
gint i;
|
||||
|
||||
line = gtk_text_iter_get_line (&selection);
|
||||
line_index = gtk_text_iter_get_line_index (&selection);
|
||||
|
||||
layout_line = pango_layout_get_line_readonly (text_tool->layout->layout,
|
||||
line);
|
||||
layout_iter = pango_layout_get_iter (text_tool->layout->layout);
|
||||
for (i = 0; i < line; i++)
|
||||
pango_layout_iter_next_line (layout_iter);
|
||||
|
||||
layout_line = pango_layout_iter_get_line_readonly (layout_iter);
|
||||
|
||||
pango_layout_line_index_to_x (layout_line,
|
||||
layout_line->start_index + line_index,
|
||||
FALSE, &x_pos);
|
||||
|
||||
pango_layout_iter_get_line_extents (layout_iter, NULL, &logical);
|
||||
x_pos += logical.x;
|
||||
|
||||
pango_layout_iter_free (layout_iter);
|
||||
|
||||
/* try to go to the remembered x_pos if it exists *and* we are at
|
||||
* the end of the current line
|
||||
* the beginning or at the end of the current line
|
||||
*/
|
||||
if (text_tool->x_pos != -1 && line_index == layout_line->length)
|
||||
if (text_tool->x_pos != -1 && (line_index == layout_line->length ||
|
||||
line_index == 0))
|
||||
x_pos = text_tool->x_pos;
|
||||
|
||||
if (kevent->keyval == GDK_Up ||
|
||||
|
@ -900,7 +912,15 @@ gimp_text_tool_key_press (GimpTool *tool,
|
|||
break;
|
||||
}
|
||||
|
||||
pango_layout_line_x_to_index (layout_line, x_pos,
|
||||
layout_iter = pango_layout_get_iter (text_tool->layout->layout);
|
||||
for (i = 0; i < line; i++)
|
||||
pango_layout_iter_next_line (layout_iter);
|
||||
|
||||
pango_layout_iter_get_line_extents (layout_iter, NULL, &logical);
|
||||
|
||||
pango_layout_iter_free (layout_iter);
|
||||
|
||||
pango_layout_line_x_to_index (layout_line, x_pos - logical.x,
|
||||
&line_index, &trailing);
|
||||
|
||||
line_index -= layout_line->start_index;
|
||||
|
|
Loading…
Reference in a new issue